Exemplo n.º 1
0
        public static void Show(IList <IModuleDrawer> drawers, string helpTopic)
        {
            if (drawers == null)
            {
                return;
            }

            IMenu menu = Far.Api.CreateMenu();

            menu.AutoAssignHotkeys = true;
            menu.HelpTopic         = helpTopic;
            menu.Title             = Res.ModuleDrawers;

            foreach (IModuleDrawer it in drawers)
            {
                menu.Add(Utility.FormatConfigMenu(it)).Data = it;
            }

            while (menu.Show())
            {
                FarItem       mi     = menu.Items[menu.Selected];
                IModuleDrawer drawer = (IModuleDrawer)mi.Data;

                var dialog = new ConfigDrawerDialog(drawer, helpTopic);
                while (dialog.Dialog.Show())
                {
                    var mask = ConfigTool.ValidateMask(dialog.Mask.Text);
                    if (mask == null)
                    {
                        continue;
                    }

                    int    priority;
                    string priorityText = dialog.Priority.Text.Trim();
                    if (!int.TryParse(priorityText, out priority))
                    {
                        Far.Api.Message("Invalid Priority.");
                        continue;
                    }

                    // set
                    drawer.Mask     = mask;
                    drawer.Priority = priority;
                    drawer.Manager.SaveSettings();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static void Show(IList <IModuleEditor> editors, string helpTopic)
        {
            if (editors == null)
            {
                return;
            }

            IMenu menu = Far.Api.CreateMenu();

            menu.AutoAssignHotkeys = true;
            menu.HelpTopic         = helpTopic;
            menu.Title             = Res.ModuleEditors;

            foreach (IModuleEditor it in editors)
            {
                menu.Add(Utility.FormatConfigMenu(it)).Data = it;
            }

            while (menu.Show())
            {
                FarItem       mi     = menu.Items[menu.Selected];
                IModuleEditor editor = (IModuleEditor)mi.Data;

                IInputBox ib = Far.Api.CreateInputBox();
                ib.EmptyEnabled = true;
                ib.HelpTopic    = helpTopic;
                ib.History      = "Masks";
                ib.Prompt       = "Mask";
                ib.Text         = editor.Mask;
                ib.Title        = editor.Name;
                if (!ib.Show())
                {
                    continue;
                }

                var mask = ConfigTool.ValidateMask(ib.Text);
                if (mask == null)
                {
                    continue;
                }

                // set
                editor.Mask = mask;
                editor.Manager.SaveSettings();
            }
        }