Example #1
0
        private void LoadItems(List <object> items, Panel panel, ContextMenuEditorCanvas canvas, ScrollViewer scroll, int indent = 0)
        {
            for (int i = 0; i < items.Count; i++)
            {
                dynamic o = (items[i] as dynamic);

                if (o is List <object> )
                {
                    LoadItems(o, panel, canvas, scroll, indent + 1);
                }
                else
                {
                    ContextMenuItem item = new ContextMenuItem(o is string?o: o.name, o is string? "" : o.func, this, panel, canvas, scroll, indent);
                    panel.Children.Add(item);
                    Items.Add(item);

                    Canvas.SetTop(item, item.MinHeight * (panel.Children.Count - 1));
                }
            }
        }
        public ContextMenuItem(string name, dynamic func, ContextMenu contextMenu, Panel parentPanel, ContextMenuEditorCanvas canvas, ScrollViewer scroll, int indent = 0)
        {
            InitializeComponent();

            ContextMenuEditor = contextMenu;
            ParentPanel       = parentPanel;
            ParentCanvas      = canvas;
            ScrollViewer      = scroll;
            Indent            = indent;
            SetFunctions();

            ItemName.Text = name;

            int funcIndex = ItemFunction.Items.IndexOf((string)(func is vimage.Action ? ((vimage.Action)func).ToNameString() : func));

            if (funcIndex != -1)
            {
                ItemFunction.SelectedIndex = funcIndex;
            }
        }
Example #3
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            Panel panel = Tabs.SelectedIndex == 0 ? ContextMenuItems_General : ContextMenuItems_Animation;
            ContextMenuEditorCanvas canvas = Tabs.SelectedIndex == 0 ? ContextMenuItems_GeneralCanvas : ContextMenuItems_AnimationCanvas;
            ScrollViewer            scroll = Tabs.SelectedIndex == 0 ? ContextMenuItems_GeneralScroll : ContextMenuItems_AnimationScroll;

            ContextMenuItem item = new ContextMenuItem("", "", this, panel, canvas, scroll, CurrentItemSelection == null ? 0 : CurrentItemSelection.Indent);

            if (CurrentItemSelection == null)
            {
                panel.Children.Add(item);
                Items.Add(item);

                Canvas.SetTop(item, item.MinHeight * (panel.Children.Count - 1));
            }
            else
            {
                panel.Children.Insert(panel.Children.IndexOf(CurrentItemSelection) + 1, item);
                Items.Insert(Items.IndexOf(CurrentItemSelection) + 1, item);
            }

            CurrentItemSelection?.UnselectItem();
            item.SelectItem(true);
        }