Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public void Import(StyleViewer item) =>
 Import(StyleList.Items.IndexOf(item));
Ejemplo n.º 5
0
        public void Duplicate(StyleViewer item)
        {
            int index = StyleList.Items.IndexOf(item);

            Insert(index + 1, Preferences.Styles[index].Clone());
        }
Ejemplo n.º 6
0
 public void New(StyleViewer item) =>
 New(StyleList.Items.IndexOf(item) + 1);