void EditorKeyUp(object sender, KeyEventArgs e) { StyleViewer selected = (StyleViewer)StyleList.SelectedItem; if ((e.Key == Key.N && Keyboard.IsKeyDown(Key.LeftCtrl)) || e.Key == Key.Add || e.Key == Key.Insert) { New(selected); } else if (e.Key == Key.D && Keyboard.IsKeyDown(Key.LeftCtrl)) { Duplicate(selected); } else if ((e.Key == Key.R && Keyboard.IsKeyDown(Key.LeftCtrl)) || e.Key == Key.F2) { selected.Rename(null, null); } else if (e.Key == Key.Delete || e.Key == Key.Back) { Delete(selected); } else if (e.Key == Key.I && Keyboard.IsKeyDown(Key.LeftCtrl)) { Import(selected); } else if (e.Key == Key.E && Keyboard.IsKeyDown(Key.LeftCtrl)) { selected.Export(null, null); } }
public void StyleListDrop(object sender, DragEventArgs e) { StyleViewer dropped = (StyleViewer)e.Data.GetData(typeof(StyleViewer)); int source = StyleList.Items.IndexOf(dropped); int dest = (sender is StyleViewer viewer)? StyleList.Items.IndexOf(viewer) : StyleList.Items.Count; FreezeEvents = true; if (!e.KeyStates.HasFlag(DragDropKeyStates.ControlKey)) { if (dest == StyleList.Items.Count) { dest--; } Preferences.Styles.RemoveAt(source); StyleList.Items.RemoveAt(source); Insert(dest, dropped.CustomStyle); } else { Insert(dest, dropped.CustomStyle.Clone()); } FreezeEvents = false; e.Handled = true; }
public void Delete(StyleViewer item) { if (Preferences.Styles.Count <= 1) { return; } int index = StyleList.Items.IndexOf(item); Preferences.Styles.RemoveAt(index); if (Preferences.StyleIndex >= index) { Preferences.StyleIndex--; } Preferences.Save(); StyleList.Items.RemoveAt(index); StyleList.SelectedIndex = Math.Min(index, StyleList.Items.Count - 1); }
public void Import(StyleViewer item) => Import(StyleList.Items.IndexOf(item));
public void Duplicate(StyleViewer item) { int index = StyleList.Items.IndexOf(item); Insert(index + 1, Preferences.Styles[index].Clone()); }
public void New(StyleViewer item) => New(StyleList.Items.IndexOf(item) + 1);