private DropDownMenu GetSliceOptionsMenuDropList()
        {
            DropDownMenu sliceOptionsMenuDropList;

            sliceOptionsMenuDropList = new DropDownMenu("Profile".Localize() + "... ")
            {
                HoverColor        = new RGBA_Bytes(0, 0, 0, 50),
                NormalColor       = new RGBA_Bytes(0, 0, 0, 0),
                BorderColor       = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100),
                BackgroundColor   = new RGBA_Bytes(0, 0, 0, 0),
                BorderWidth       = 1,
                MenuAsWideAsItems = false,
                AlignToRightEdge  = true,
            };
            sliceOptionsMenuDropList.Name     = "Slice Settings Options Menu";
            sliceOptionsMenuDropList.VAnchor |= VAnchor.ParentCenter;

            sliceOptionsMenuDropList.AddItem("Import".Localize()).Selected += (s, e) => { ImportSettingsMenu_Click(); };
            sliceOptionsMenuDropList.AddItem("Export".Localize()).Selected += (s, e) => { WizardWindow.Show <ExportSettingsPage>("ExportSettingsPage", "Export Settings"); };

            MenuItem settingsHistory = sliceOptionsMenuDropList.AddItem("Settings History".Localize());

            settingsHistory.Selected += (s, e) => { WizardWindow.Show <PrinterProfileHistoryPage>("PrinterProfileHistory", "Settings History"); };

            settingsHistory.Enabled = !string.IsNullOrEmpty(AuthenticationData.Instance.ActiveSessionUsername);

            sliceOptionsMenuDropList.AddItem("Reset to defaults".Localize()).Selected += (s, e) => { UiThread.RunOnIdle(ResetToDefaults); };

            return(sliceOptionsMenuDropList);
        }
Пример #2
0
        private DropDownMenu GetSliceOptionsMenuDropList()
        {
            DropDownMenu sliceOptionsMenuDropList;

            sliceOptionsMenuDropList = new DropDownMenu("Options".Localize() + "... ")
            {
                HoverColor        = new RGBA_Bytes(0, 0, 0, 50),
                NormalColor       = new RGBA_Bytes(0, 0, 0, 0),
                BorderColor       = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100),
                BackgroundColor   = new RGBA_Bytes(0, 0, 0, 0),
                BorderWidth       = 1,
                MenuAsWideAsItems = false,
                AlignToRightEdge  = true,
            };
            sliceOptionsMenuDropList.Name     = "Slice Settings Options Menu";
            sliceOptionsMenuDropList.VAnchor |= VAnchor.ParentCenter;


            showHelpBox = new CheckBox("Show Help".Localize());

            if (primarySettingsView)
            {
                // only turn on the help if in the main view and it is set to on
                showHelpBox.Checked = UserSettings.Instance.get(SliceSettingsShowHelpEntry) == "true";
            }

            showHelpBox.CheckedStateChanged += (s, e) =>
            {
                if (primarySettingsView)
                {
                    // only save the help settings if in the main view
                    UserSettings.Instance.set(SliceSettingsShowHelpEntry, showHelpBox.Checked.ToString().ToLower());
                }
                ShowHelpChanged?.Invoke(this, null);
            };

            MenuItem showHelp = new MenuItem(showHelpBox, "Show Help Checkbox")
            {
                Padding = sliceOptionsMenuDropList.MenuItemsPadding,
            };

            sliceOptionsMenuDropList.MenuItems.Add(showHelp);
            sliceOptionsMenuDropList.AddHorizontalLine();

            sliceOptionsMenuDropList.AddItem("Import".Localize()).Selected += (s, e) => { ImportSettingsMenu_Click(); };
            sliceOptionsMenuDropList.AddItem("Export".Localize()).Selected += (s, e) => { WizardWindow.Show <ExportSettingsPage>("ExportSettingsPage", "Export Settings"); };

            MenuItem settingsHistory = sliceOptionsMenuDropList.AddItem("Restore Settings".Localize());

            settingsHistory.Selected += (s, e) => { WizardWindow.Show <PrinterProfileHistoryPage>("PrinterProfileHistory", "Restore Settings"); };

            settingsHistory.Enabled = !string.IsNullOrEmpty(AuthenticationData.Instance.ActiveSessionUsername);

            sliceOptionsMenuDropList.AddItem("Reset to Defaults".Localize()).Selected += (s, e) => { UiThread.RunOnIdle(ResetToDefaults); };

            return(sliceOptionsMenuDropList);
        }
Пример #3
0
        private DropDownMenu CreateScaleDropDownMenu()
        {
            DropDownMenu presetScaleMenu = new DropDownMenu("", Direction.Down);

            presetScaleMenu.NormalArrowColor  = ActiveTheme.Instance.PrimaryTextColor;
            presetScaleMenu.HoverArrowColor   = ActiveTheme.Instance.PrimaryTextColor;
            presetScaleMenu.MenuAsWideAsItems = false;
            presetScaleMenu.AlignToRightEdge  = true;
            //presetScaleMenu.OpenOffset = new Vector2(-50, 0);
            presetScaleMenu.HAnchor = HAnchor.AbsolutePosition;
            presetScaleMenu.VAnchor = VAnchor.AbsolutePosition;
            presetScaleMenu.Width   = 25;
            presetScaleMenu.Height  = scaleRatioControl.Height + 2;

            presetScaleMenu.AddItem("mm to in (.0393)");
            presetScaleMenu.AddItem("in to mm (25.4)");
            presetScaleMenu.AddItem("mm to cm (.1)");
            presetScaleMenu.AddItem("cm to mm (10)");
            string resetLable     = "reset".Localize();
            string resetLableFull = "{0} (1)".FormatWith(resetLable);

            presetScaleMenu.AddItem(resetLableFull);

            presetScaleMenu.SelectionChanged += (sender, e) =>
            {
                double scale = 1;
                switch (presetScaleMenu.SelectedIndex)
                {
                case 0:
                    scale = 1.0 / 25.4;
                    break;

                case 1:
                    scale = 25.4;
                    break;

                case 2:
                    scale = .1;
                    break;

                case 3:
                    scale = 10;
                    break;

                case 4:
                    scale = 1;
                    break;
                }

                scaleRatioControl.ActuallNumberEdit.Value = scale;
                ApplyScaleFromEditField();
            };

            return(presetScaleMenu);
        }
Пример #4
0
        public MenuBase(string menuName)
        {
            MenuDropList = new DropDownMenu(menuName.ToUpper(), Direction.Down, pointSize: 10);
            MenuDropList.MenuItemsPadding = new BorderDouble(0);
            MenuDropList.Margin           = new BorderDouble(0);
            MenuDropList.Padding          = new BorderDouble(0);

            MenuDropList.DrawDirectionalArrow = false;
            MenuDropList.MenuAsWideAsItems    = false;

            menuItems = GetMenuItems();
            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                MenuDropList.MenuItemsPadding = new BorderDouble(8, 6, 8, 6) * TextWidget.GlobalPointSizeScaleRatio;
                MenuDropList.AddItem(item.Item1, pointSize: 11);
            }
            MenuDropList.Padding = padding;

            AddChild(MenuDropList);
            this.Width   = GetChildrenBoundsIncludingMargins().Width;
            this.Height  = 22 * TextWidget.GlobalPointSizeScaleRatio;
            this.Margin  = new BorderDouble(0);
            this.Padding = new BorderDouble(0);
            this.VAnchor = Agg.UI.VAnchor.ParentCenter;
            this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
            this.MenuDropList.OpenOffset        = new Vector2(0, 0);
        }
Пример #5
0
        void SetMenuItems()
        {
            //Set the name and callback function of the menu items
            menuItems = new TupleList <string, Func <bool> >
            {
                { new LocalizedString("STL").Translated, null },
                { new LocalizedString(" Import from Zip").Translated, importQueueFromZipMenu_Click },
                { new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click },
                { new LocalizedString("GCode").Translated, null },
                { new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click },
                //{" Export to SD Card", exportToSDCardButton_Click},
                { new LocalizedString("Extra").Translated, null },
                { new LocalizedString(" Create Part Sheet").Translated, createPartsSheetsButton_Click },
            };

            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                if (item.Item2 == null)
                {
                    MenuDropList.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
                }
                else
                {
                    MenuDropList.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
                }

                MenuDropList.AddItem(item.Item1);
            }

            MenuDropList.Padding = padding;
        }
Пример #6
0
        private void SetMenuItems(DropDownMenu dropDownMenu)
        {
            menuItems = new TupleList <string, Func <bool> >();

            if (ActiveTheme.Instance.IsTouchScreen)
            {
                menuItems.Add(new Tuple <string, Func <bool> >("Remove All".Localize(), clearAllMenu_Select));
            }

            menuItems.Add(new Tuple <string, Func <bool> >("Send".Localize(), sendMenu_Selected));
            menuItems.Add(new Tuple <string, Func <bool> >("Add To Library".Localize(), addToLibraryMenu_Selected));

            BorderDouble padding = dropDownMenu.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                if (item.Item2 == null)
                {
                    dropDownMenu.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
                }
                else
                {
                    dropDownMenu.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
                }

                dropDownMenu.AddItem(item.Item1);
            }

            dropDownMenu.Padding = padding;
        }
Пример #7
0
        private DropDownMenu GetSliceOptionsMenuDropList()
        {
            if (sliceOptionsMenuDropList == null)
            {
                sliceOptionsMenuDropList = new DropDownMenu("Options".Localize() + "... ")
                {
                    HoverColor        = new RGBA_Bytes(0, 0, 0, 50),
                    NormalColor       = new RGBA_Bytes(0, 0, 0, 0),
                    BorderColor       = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100),
                    BackgroundColor   = new RGBA_Bytes(0, 0, 0, 0),
                    BorderWidth       = 1,
                    MenuAsWideAsItems = false,
                    AlignToRightEdge  = true,
                };
                sliceOptionsMenuDropList.VAnchor          |= VAnchor.ParentCenter;
                sliceOptionsMenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);

                //Set the name and callback function of the menu items
                slicerOptionsMenuItems = new TupleList <string, Func <bool> >
                {
                    { "Import".Localize(), ImportSettingsMenu_Click },
                    { "Export".Localize(), () => { WizardWindow.Show <ExportSettingsPage>("ExportSettingsPage", "Export Settings"); return(true); } },
                    { "Settings History".Localize(), () => { WizardWindow.Show <PrinterProfileHistoryPage>("PrinterProfileHistory", "Profile History"); return(true); } },
                    { "Reset to defaults".Localize(), () => { UiThread.RunOnIdle(ResetToDefaults); return(true); } },
                };

                //Add the menu items to the menu itself
                foreach (Tuple <string, Func <bool> > item in slicerOptionsMenuItems)
                {
                    sliceOptionsMenuDropList.AddItem(item.Item1);
                }
            }

            return(sliceOptionsMenuDropList);
        }
Пример #8
0
        private void SetMenuItems(DropDownMenu dropDownMenu)
        {
            menuItems = new List <PrintItemAction>();

            if (ActiveTheme.Instance.IsTouchScreen)
            {
                menuItems.Add(new PrintItemAction()
                {
                    Title  = "Remove All".Localize(),
                    Action = (items, queueDataView) => clearAllButton_Click(null, null)
                });
            }

            menuItems.Add(new PrintItemAction()
            {
                Title  = "Send".Localize(),
                Action = (items, queueDataView) => sendButton_Click(null, null)
            });

            menuItems.Add(new PrintItemAction()
            {
                Title  = "Add To Library".Localize(),
                Action = (items, queueDataView) => addToLibraryButton_Click(null, null)
            });

            // Extension point for plugins to hook into selected item actions
            var pluginFinder = new PluginFinder <PrintItemMenuExtension>();

            foreach (var menuExtensionPlugin in pluginFinder.Plugins)
            {
                foreach (var menuItem in menuExtensionPlugin.GetMenuItems())
                {
                    menuItems.Add(menuItem);
                }
            }

            BorderDouble padding = dropDownMenu.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (PrintItemAction item in menuItems)
            {
                if (item.Action == null)
                {
                    dropDownMenu.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
                }
                else
                {
                    if (item.SingleItemOnly)
                    {
                        singleSelectionMenuItems.Add(item.Title);
                    }
                    dropDownMenu.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
                }

                dropDownMenu.AddItem(item.Title);
            }

            dropDownMenu.Padding = padding;
        }
Пример #9
0
        private void SetMenuItems()
        {
            menuItems = new TupleList <string, Func <bool> >();

#if !__ANDROID__
            menuItems.Add(new Tuple <string, Func <bool> >("Design".Localize(), null));
            menuItems.Add(new Tuple <string, Func <bool> >(" Export to Zip".Localize(), exportQueueToZipMenu_Click));
            menuItems.Add(new Tuple <string, Func <bool> >("G-Code".Localize(), null));
            menuItems.Add(new Tuple <string, Func <bool> >(" Export to Folder or SD Card".Localize(), exportGCodeToFolderButton_Click));
            //menuItems.Add(new Tuple<string, Func<bool>>("X3G", null));
            //menuItems.Add(new Tuple<string, Func<bool>>("Export to Folder".Localize(), exportX3GButton_Click));
#endif

            if (ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.has_sd_card_reader))
            {
                menuItems.Add(new Tuple <string, Func <bool> >("SD Card".Localize(), null));
                menuItems.Add(new Tuple <string, Func <bool> >(" Load Files".Localize(), loadFilesFromSDButton_Click));
                menuItems.Add(new Tuple <string, Func <bool> >(" Eject SD Card".Localize(), ejectSDCardButton_Click));
            }

            // The pdf export library is not working on the mac at the moment so we don't include the
            // part sheet export option on mac.
            if (OsInformation.OperatingSystem == OSType.Windows)
            {
                menuItems.Add(new Tuple <string, Func <bool> >("Other".Localize(), null));
                menuItems.Add(new Tuple <string, Func <bool> >(" Create Part Sheet".Localize(), createPartsSheetsButton_Click));
                menuItems.Add(new Tuple <string, Func <bool> >(" Remove All".Localize(), removeAllFromQueueButton_Click));
            }
            else
            {
                // mac cannot export to pdf
                menuItems.Add(new Tuple <string, Func <bool> >("Other".Localize(), null));
                menuItems.Add(new Tuple <string, Func <bool> >(" Remove All".Localize(), removeAllFromQueueButton_Click));
            }

            BorderDouble padding = MenuDropList.MenuItemsPadding;
            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                if (item.Item2 == null)
                {
                    MenuDropList.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
                }
                else
                {
                    MenuDropList.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
                }

                MenuItem menuItem = MenuDropList.AddItem(item.Item1);
                if (item.Item2 == null)
                {
                    menuItem.Enabled = false;
                }
            }

            MenuDropList.Padding = padding;
        }
Пример #10
0
        void SetMenuItems()
        {
            // The pdf export library is not working on the mac at the moment so we don't include the
            // part sheet export option on mac.
            if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Mac)
            {
                //Set the name and callback function of the menu items
                menuItems = new TupleList <string, Func <bool> >
                {
                    { "STL", null },
                    { LocalizedString.Get(" Import from Zip"), importQueueFromZipMenu_Click },
                    { LocalizedString.Get(" Export to Zip"), exportQueueToZipMenu_Click },
                    { "GCode", null },
                    { LocalizedString.Get(" Export to Folder"), exportGCodeToFolderButton_Click },
                    { LocalizedString.Get("Other"), null },
                    { LocalizedString.Get(" Remove All"), removeAllFromQueueButton_Click },
                };
            }
            else
            {
                //Set the name and callback function of the menu items
                menuItems = new TupleList <string, Func <bool> >
                {
                    { "STL", null },
                    { LocalizedString.Get(" Import from Zip"), importQueueFromZipMenu_Click },
                    { LocalizedString.Get(" Export to Zip"), exportQueueToZipMenu_Click },
                    { "GCode", null },
                    { LocalizedString.Get(" Export to Folder"), exportGCodeToFolderButton_Click },
                    { LocalizedString.Get("Other"), null },
                    { LocalizedString.Get(" Create Part Sheet"), createPartsSheetsButton_Click },
                    { LocalizedString.Get(" Remove All"), removeAllFromQueueButton_Click },
                };
            }

            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                if (item.Item2 == null)
                {
                    MenuDropList.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
                }
                else
                {
                    MenuDropList.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
                }

                MenuDropList.AddItem(item.Item1);
            }

            MenuDropList.Padding = padding;
        }
Пример #11
0
        private void SetMenuItems()
        {
            //Set the name and callback function of the menu items
            slicerOptionsMenuItems = new TupleList <string, Func <bool> >
            {
                { "Import".Localize(), ImportSettingsMenu_Click },
                { "Export".Localize(), ExportSettingsMenu_Click },
                { "Restore All".Localize(), RestoreAllSettingsMenu_Click },
            };

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in slicerOptionsMenuItems)
            {
                sliceOptionsMenuDropList.AddItem(item.Item1);
            }
        }
Пример #12
0
        void SetMenuItems()
        {
            menuItems = new TupleList <string, Func <bool> >
            {
                { LocalizedString.Get("Add File"), importFile_Click },
                { LocalizedString.Get("Exit"), exit_Click },
            };

            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4);
                MenuDropList.AddItem(item.Item1, pointSize: 10);
            }
            MenuDropList.Padding = padding;
        }
Пример #13
0
        void SetMenuItems()
        {
            menuItems = new TupleList <string, Func <bool> >
            {
                { LocalizedString.Get("Layout 1"), layout1_Click },
                { LocalizedString.Get("Layout 2"), layout2_Click },
                //{LocalizedString.Get("Layout 3"), layout3_Click},
            };

            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4) * TextWidget.GlobalPointSizeScaleRatio;
                MenuDropList.AddItem(item.Item1, pointSize: 10);
            }
            MenuDropList.Padding = padding;
        }
Пример #14
0
        void SetMenuItems()
        {
            menuItems = new TupleList <string, Func <bool> >
            {
                { LocalizedString.Get("Getting Started"), gettingStarted_Click },
                { LocalizedString.Get("View Help"), help_Click },
                { LocalizedString.Get("About"), about_Click },
            };

            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4);
                MenuDropList.AddItem(item.Item1, pointSize: 10);
            }
            MenuDropList.Padding = padding;
        }
Пример #15
0
        void SetMenuItems()
        {
            string importTxt     = new LocalizedString("Import").Translated;
            string importTxtFull = string.Format("{0}", importTxt);
            string exportTxt     = new LocalizedString("Export").Translated;
            string exportTxtFull = string.Format("{0}", exportTxt);

            //Set the name and callback function of the menu items
            slicerOptionsMenuItems = new TupleList <string, Func <bool> >
            {
                { importTxtFull, ImportQueueMenu_Click },
                { exportTxtFull, ExportQueueMenu_Click },
            };

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in slicerOptionsMenuItems)
            {
                SliceOptionsMenuDropList.AddItem(item.Item1);
            }
        }
Пример #16
0
        public MenuBase(string menuName)
        {
            MenuDropList = new DropDownMenu(menuName.ToUpper(), Direction.Down, pointSize: 10);
            MenuDropList.MenuItemsPadding = new BorderDouble(0);
            MenuDropList.Margin           = new BorderDouble(0);
            MenuDropList.Padding          = new BorderDouble(0);
            MenuDropList.MenuItemsPadding = new BorderDouble(8, 4);            // 8, 6, 8, 6);

            MenuDropList.DrawDirectionalArrow = false;
            MenuDropList.MenuAsWideAsItems    = false;

            menuActions = new List <MenuItemAction>(GetMenuActions());
            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (MenuItemAction item in menuActions)
            {
                if (item.Title.StartsWith("-----"))
                {
                    MenuDropList.AddHorizontalLine();
                }
                else
                {
                    MenuItem newItem = MenuDropList.AddItem(item.Title, pointSize: 11);
                    if (item.Action == null)
                    {
                        newItem.Enabled = false;
                    }
                }
            }
            MenuDropList.Padding = padding;

            AddChild(MenuDropList);
            this.Width   = GetChildrenBoundsIncludingMargins().Width;
            this.Height  = 22 * GuiWidget.DeviceScale;
            this.Margin  = new BorderDouble(0);
            this.Padding = new BorderDouble(0);
            this.VAnchor = Agg.UI.VAnchor.ParentCenter;
            this.MenuDropList.SelectionChanged += MenuDropList_SelectionChanged;
            this.MenuDropList.OpenOffset        = new Vector2(0, 0);
        }
Пример #17
0
        void SetMenuItems()
        {
            menuItems = new TupleList <string, Func <bool> >
            {
                { LocalizedString.Get("Getting Started"), gettingStarted_Click },
                { LocalizedString.Get("View Help"), help_Click },
                { LocalizedString.Get("Report a Bug"), bug_Click },
                { LocalizedString.Get("Release Notes"), notes_Click },
                { LocalizedString.Get("About MatterControl"), about_Click },
            };

            BorderDouble padding = MenuDropList.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (Tuple <string, Func <bool> > item in menuItems)
            {
                MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4) * TextWidget.GlobalPointSizeScaleRatio;
                MenuDropList.AddItem(item.Item1, pointSize: 10);
            }
            MenuDropList.Padding = padding;
        }
Пример #18
0
        public override void Reset()
        {
            base.Reset();

            // Creating drop-down for beatmaps
            dropDownMenu = new DropDownMenu <BeatmapExample>
            {
                Width       = 150,
                Position    = new Vector2(200, 20),
                Description = @"Beatmap selector example",
                Items       = new DropDownMenuItem <BeatmapExample>[]
                {
                    new DropDownMenuHeader <BeatmapExample>("Ranked"),
                    new DropDownMenuItem <BeatmapExample>(
                        "Example",
                        new BeatmapExample
                    {
                        Name   = @"Example",
                        Mapper = @"peppy",
                        Status = BeatmapExampleStatus.Ranked,
                    }
                        ),
                    new DropDownMenuItem <BeatmapExample>(
                        "Make up!",
                        new BeatmapExample
                    {
                        Name   = @"Make up!",
                        Mapper = @"peppy",
                        Status = BeatmapExampleStatus.Ranked,
                    }
                        ),
                    new DropDownMenuItem <BeatmapExample>(
                        "Platinum",
                        new BeatmapExample
                    {
                        Name   = @"Platinum",
                        Mapper = @"arflyte",
                        Status = BeatmapExampleStatus.Ranked,
                    }
                        ),
                },
            };
            Add(dropDownMenu);

            // Adding more items after init
            dropDownMenu.AddItem(new DropDownMenuHeader <BeatmapExample>("Not submitted"));
            dropDownMenu.AddItem(new DropDownMenuItem <BeatmapExample>(
                                     "Lorem ipsum dolor sit amed",
                                     new BeatmapExample
            {
                Name   = @"Lorem ipsum dolor sit amed",
                Mapper = @"Plato",
                Status = BeatmapExampleStatus.NotSubmitted,
            })
                                 );

            // Setting default index and event handler
            dropDownMenu.SelectedIndex = 0;
            dropDownMenu.ValueChanged += DropDownBox_ValueChanged;

            labelSelectedMap = new SpriteText
            {
                Text     = @"Waiting for map...",
                Position = new Vector2(450, 20),
            };
            Add(labelSelectedMap);

            labelNewMap = new SpriteText
            {
                Text     = @"",
                Position = new Vector2(450, 60),
            };
            Add(labelNewMap);

            // Styled drop-down example
            StyledDropDownMenuItem[] testItems = new StyledDropDownMenuItem[10];
            for (int i = 0; i < 10; i++)
            {
                testItems[i] = new StyledDropDownMenuItem(@"test " + i);
            }
            styledDropDownMenu = new StyledDropDownMenu
            {
                Width         = 150,
                Position      = new Vector2(200, 70),
                Description   = @"Drop-down menu with style",
                Depth         = -1,
                Items         = testItems,
                SelectedIndex = 4,
            };
            Add(styledDropDownMenu);

            AddButton(@"+ beatmap", delegate
            {
                string[] mapNames    = { "Cool", "Stylish", "Philosofical", "Tekno" };
                string[] mapperNames = { "peppy", "arflyte", "Plato", "BanchoBot" };

                BeatmapExample newMap = new BeatmapExample
                {
                    Name   = mapNames[RNG.Next(mapNames.Length)],
                    Mapper = mapperNames[RNG.Next(mapperNames.Length)],
                    Status = BeatmapExampleStatus.NotSubmitted,
                };

                dropDownMenu.AddItem(new DropDownMenuItem <BeatmapExample>(newMap.Name, newMap));
                labelNewMap.Text = $@"Added ""{newMap.Name}"" by {newMap.Mapper} as {newMap.Status}";
            });
        }
Пример #19
0
        private void CreateActionMenuItems(DropDownMenu actionMenu)
        {
            actionMenu.SelectionChanged += (sender, e) =>
            {
                string menuSelection = ((DropDownMenu)sender).SelectedValue;
                foreach (var menuItem in menuItems)
                {
                    if (menuItem.Title == menuSelection)
                    {
                        menuItem.Action?.Invoke(null, null);
                    }
                }
            };

            // edit menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Edit".Localize(),
                Action = (s, e) => editButton_Click(s, null)
            });
            actionMenuEnableData.Add(new MenuEnableData(
                                         actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
                                         false, false, false));

            actionMenu.AddHorizontalLine();

            // rename menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Rename".Localize(),
                Action = (s, e) => renameFromLibraryButton_Click(s, null)
            });
            actionMenuEnableData.Add(new MenuEnableData(actionMenu.AddItem(menuItems[menuItems.Count - 1].Title), false, false, true));

            // move menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Move".Localize(),
                Action = (s, e) => moveInLibraryButton_Click(s, null)
            });
            //actionMenuEnableData.Add(new MenuEnableData(actionMenu.AddItem(menuItems[menuItems.Count - 1].Title), true, false, true));

            // remove menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Remove".Localize(),
                Action = (s, e) => deleteFromLibraryButton_Click(s, null)
            });
            actionMenuEnableData.Add(new MenuEnableData(
                                         actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
                                         true, false, true));

            actionMenu.AddHorizontalLine();

            // add to queue menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Add to Queue".Localize(),
                Action = (s, e) => addToQueueButton_Click(s, null)
            });
            actionMenuEnableData.Add(new MenuEnableData(
                                         actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
                                         true, true, false));

            // export menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Export".Localize(),
                Action = (s, e) => exportButton_Click(s, null)
            });
            actionMenuEnableData.Add(new MenuEnableData(
                                         actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
                                         false, false, false));

            // share menu item
            menuItems.Add(new PrintItemAction()
            {
                Title  = "Share".Localize(),
                Action = (s, e) => shareFromLibraryButton_Click(s, null)
            });
            actionMenuEnableData.Add(new MenuEnableData(
                                         actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
                                         false, false, false, true));

            SetActionMenuStates();
        }