private void lstLayers_KeyDown(object sender, KeyEventArgs e) { if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) { if (e.Key == Key.C) { Global.Clipboard = (this.lstLayers.SelectedItem as Layers.Layer)?.Clone(); } else if (e.Key == Key.V && Global.Clipboard is Layers.Layer) { Layers.Layer lyr = (Layers.Layer)((Layers.Layer)Global.Clipboard)?.Clone(); if (Global.LightingStateManager.DefaultLayerHandlers.Contains(lyr.Handler.ID) || FocusedApplication.Config.ExtraAvailableLayers.Contains(lyr.Handler.ID)) { lyr.Name += " - Copy"; lyr.SetProfile(FocusedApplication); if (this.FocusedApplication is Profiles.Generic_Application.GenericApplication && this.radiobtn_nighttime.IsChecked.Value) { ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Insert(0, lyr); } else { FocusedApplication.Profile.Layers.Insert(0, lyr); } } } } else if (e.Key == Key.Delete) { this.btnRemoveLayer_Click(null, null); } }
private void add_layer_button_Click(object sender, RoutedEventArgs e) { Layers.Layer lyr = new Layers.Layer("New layer " + Utils.Time.GetMilliSeconds()); lyr.AnythingChanged += this.FocusedApplication.SaveProfilesEvent; lyr.SetProfile(FocusedApplication); if (this.FocusedApplication is Profiles.Generic_Application.GenericApplication && this.radiobtn_nighttime.IsChecked.Value) { ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Insert(0, lyr); } else { this.FocusedApplication?.Profile?.Layers.Insert(0, lyr); } this.lstLayers.SelectedItem = lyr; }
private void Layers_listbox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 1) { var hander = NewLayer; if (lstLayers.SelectedItem != null) { if (!(lstLayers.SelectedItem is Layers.Layer)) { throw new ArgumentException($"Items contained in the ListView must be of type 'Layer', not '{lstLayers.SelectedItem.GetType()}'"); } Layers.Layer lyr = (Layers.Layer)lstLayers.SelectedItem; lyr.SetProfile(FocusedApplication); hander?.Invoke(lyr); } } }