Changeset 15167 for trunk/sources
- Timestamp:
- 07/07/17 10:07:32 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml
r14978 r15167 30 30 MouseWheel="Container3DView_OnMouseWheel" 31 31 MouseEnter="Container3DView_OnMouseEnter" 32 KeyDown="Container3DView_OnKeyDown"33 32 Focusable="true" 34 33 > -
trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml.cs
r14979 r15167 46 46 Color.FromRgb(0x63, 0xC2, 0x16), 47 47 }; 48 48 49 49 private static readonly Color hiddenColor = Color.FromArgb(0x1A, 0xAA, 0xAA, 0xAA); 50 50 private static readonly Color containerColor = Color.FromArgb(0x7F, 0xAA, 0xAA, 0xAA); … … 52 52 private Point startPos; 53 53 private bool mouseDown = false; 54 private bool ctrlDown = false;55 54 private double startAngleX; 56 55 private double startAngleY; … … 106 105 var selectedItem = packing.Items.Single(x => selectedItemKey == x.Key); 107 106 var selectedPos = packing.Positions[selectedItem.Key]; 108 DiffuseMaterial material; 109 if (!materials.TryGetValue(selectedItem.Value.Material, out material)) { 110 var colorIdx = selectedItem.Value.Material; 111 while (colorIdx < 0) colorIdx += colors.Length; 112 colorIdx = colorIdx % colors.Length; 113 var color = colors[colorIdx]; 114 material = new DiffuseMaterial { Brush = new SolidColorBrush(color) }; 115 materials[selectedItem.Value.Material] = material; 116 } 107 108 var colorIdx = selectedItem.Value.Material; 109 while (colorIdx < 0) colorIdx += colors.Length; 110 colorIdx = colorIdx % colors.Length; 111 var color = colors[colorIdx]; 112 var material = new DiffuseMaterial { Brush = new SolidColorBrush(color) }; 113 materials[selectedItem.Value.Material] = material; 114 117 115 var selectedModel = new GeometryModel3D { Geometry = new MeshGeometry3D(), Material = material }; 118 116 AddSolidCube((MeshGeometry3D)selectedModel.Geometry, selectedPos.X, selectedPos.Y, selectedPos.Z, … … 185 183 ((Model3DGroup)MyModel.Content).Children.Clear(); 186 184 materials.Clear(); 187 185 188 186 mouseDown = false; 189 187 startAngleX = 0; … … 194 192 if (!mouseDown) return; 195 193 var pos = e.GetPosition((IInputElement)this); 196 194 197 195 ((AxisAngleRotation3D)rotateX.Rotation).Angle = startAngleX + (pos.X - startPos.X) / 4; 198 196 ((AxisAngleRotation3D)rotateY.Rotation).Angle = startAngleY + (pos.Y - startPos.Y) / 4; … … 225 223 Focus(); // for mouse wheel events 226 224 } 227 228 private void Container3DView_OnKeyDown(object sender, KeyEventArgs e) {229 ctrlDown = e.Key.HasFlag(Key.LeftCtrl) || e.Key.HasFlag(Key.RightCtrl);230 }231 232 225 233 226 #region helper for cubes
Note: See TracChangeset
for help on using the changeset viewer.