private void btnClone_Click(object sender, RoutedEventArgs e) { if (dgProps.SelectedItem is UnitBinDrawSlot) { UnitBinDrawSlot selProp = (UnitBinDrawSlot)dgProps.SelectedItem; selProp.UpdateTransform(); UnitBinDrawSlot prop = new UnitBinDrawSlot(); prop.Transform = selProp.Transform.Clone(); prop.Index = selProp.Index; prop.Slot = selProp.Slot; prop.CreateGeometry(); UnitFileEntry.UnitBinDrawSlots[selProp.Index].Add(prop); UnitFileEntry.UnitBinDrawSlots[selProp.Index].Changed(); prop.ModelRepresentation.Parent = prop; if (checkBoxProps.IsChecked.GetValueOrDefault(false)) { viewPort.Children.Add(prop.ModelRepresentation); } UnitFileEntry.UnitBinDrawSlotList.Add(prop); UnitFileEntry.UnitBinDrawSlotList.Changed(); UnitFileEntry.UnitBinDrawSlots[selProp.Index].Changed(); } }
private void dgProps_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dgProps.SelectedItem is UnitBinDrawSlot) { UnitBinDrawSlot prop = (UnitBinDrawSlot)dgProps.SelectedItem; if (prop.ModelRepresentation != null) { BindingOperations.SetBinding(manipulator, CombinedManipulator.TargetTransformProperty, new Binding("Transform") { Source = prop.ModelRepresentation }); ResizeManipulator(prop.ModelRepresentation); } contentHolder.Content = prop; } }
private void viewPort_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { //Delete the selected item from the list (if any) if (tabProps.IsSelected) { UnitBinDrawSlot selectedItem = dgProps.SelectedItem as UnitBinDrawSlot; viewPort.Children.Remove(selectedItem.ModelRepresentation); foreach (ObservableList <UnitBinDrawSlot> slotList in UnitFileEntry.UnitBinDrawSlots) { slotList.Remove(selectedItem); } } if (tabEffects.IsSelected) { UnitEffect selectedItem = dgEffects.SelectedItem as UnitEffect; viewPort.Children.Remove(selectedItem.ModelRepresentation); UnitFileEntry.UnitEffects.Remove(selectedItem); } if (tabLights.IsSelected) { UnitLight selectedItem = lbLights.SelectedItem as UnitLight; viewPort.Children.Remove(selectedItem.ModelRepresentation); UnitFileEntry.UnitLights.Remove(selectedItem); } if (tabDecals.IsSelected) { UnitDecal selectedItem = dgDecals.SelectedItem as UnitDecal; viewPort.Children.Remove(selectedItem.ModelRepresentation); foreach (ObservableList <UnitDecal> slotList in UnitFileEntry.UnitBinDecals) { slotList.Remove(selectedItem); } } } }