예제 #1
0
        /// <summary>
        /// Load the raw favorites document; use for Settings
        /// </summary>
        /// <returns></returns>
        public XElement LoadFavoritesMenu()
        {
            XElement root = null;

            if (File.Exists(path))
            {
                root = UpgradeFavoritesMenu(XElement.Load(path, LoadOptions.None));
            }
            else
            {
                root = MakeMenuRoot();
            }

            var kbdshorts = new Settings.SettingsProvider()
                            .GetCollection("FavoritesSheet")?
                            .Get <bool>("kbdshorts") == true;

            var button = root.Elements(ns + "button")
                         .FirstOrDefault(e => e.Attribute("id").Value == KbdShortcutsId);

            if (kbdshorts && button == null)
            {
                root.Add(MakeKeyboardShortcutsButton());
            }
            else if (!kbdshorts && button != null)
            {
                button.Remove();
            }

            return(root);
        }
예제 #2
0
        public FavoritesSheet(SettingsProvider provider, IRibbonUI ribbon)
            : base(provider)
        {
            InitializeComponent();

            Name  = "FavoritesSheet";
            Title = Resx.FavoritesSheet_Text;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introLabel",
                    "optionsBox",
                    "shortcutsBox",
                    "sortButton",
                    "upButton",
                    "downButton",
                    "deleteLabel",
                    "deleteButton",
                    "okButton",
                    "cancelButton"
                });

                nameColumn.HeaderText     = Resx.FavoritesSheet_nameColumn_HeaderText;
                locationColumn.HeaderText = Resx.FavoritesSheet_locationColumn_HeaderText;
            }

            toolStrip.Rescale();

            gridView.AutoGenerateColumns         = false;
            gridView.Columns[0].DataPropertyName = "Name";
            gridView.Columns[1].DataPropertyName = "Location";

            this.ribbon = ribbon;

            shortcuts            = provider.GetCollection(Name).Get <bool>("kbdshorts");
            shortcutsBox.Checked = shortcuts;

            favorites = new BindingList <Favorite>(LoadFavorites());

            gridView.DataSource = favorites;
        }
예제 #3
0
        public ContextMenuSheet(SettingsProvider provider) : base(provider)
        {
            InitializeComponent();

            Name  = "ContextMenuSheet";
            Title = Resx.ContextMenuSheet_Title;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introBox"
                });
            }

            var langs   = Office.GetEditingLanguages();
            var noproof = langs == null || langs.Length < 2;

            commandsBox.DisplayMember = "Text";

            commandsBox.Items.Clear();
            foreach (var key in keys)
            {
                if (key == "ribProofingMenu" && noproof)
                {
                    continue;
                }

                var text = Resx.ResourceManager.GetString($"{Name}_{key}") ?? key;
                commandsBox.Items.Add(new MenuItem(key, text));
            }

            var settings = provider.GetCollection(Name);

            for (var i = 0; i < keys.Length; i++)
            {
                if (settings.Get <bool>(keys[i]))
                {
                    commandsBox.SetItemChecked(i, true);
                }
            }
        }
예제 #4
0
        public GeneralSheet(SettingsProvider provider) : base(provider)
        {
            InitializeComponent();

            Name  = "GeneralSheet";
            Title = Resx.GeneralSheet_Title;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introBox",
                    "enablersBox"
                });
            }

            var settings = provider.GetCollection(Name);

            enablersBox.Checked = settings.Get("enablers", true);
        }
예제 #5
0
        public SearchEngineSheet(SettingsProvider provider) : base(provider)
        {
            InitializeComponent();

            Name  = "SearchEngineSheet";
            Title = Resx.SearchEngineDialog_Text;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introLabel",
                    "upButton",
                    "downButton",
                    "refreshButton",
                    "deleteLabel",
                    "deleteButton",
                    "okButton",
                    "cancelButton"
                });

                iconColumn.HeaderText = Resx.SearchEngineDialog_iconColumn_HeaderText;
                nameColumn.HeaderText = Resx.SearchEngineDialog_nameColumn_HeaderText;
                urlColumn.HeaderText  = Resx.SearchEngineDialog_urlColumn_HeaderText;
            }

            // prevent VS designer from overriding
            toolStrip.ImageScalingSize = new Size(16, 16);

            gridView.AutoGenerateColumns         = false;
            gridView.Columns[0].DataPropertyName = "Image";
            gridView.Columns[1].DataPropertyName = "Name";
            gridView.Columns[2].DataPropertyName = "Uri";

            engines = new BindingList <SearchEngine>(LoadSettings());

            gridView.DataSource = engines;

            RefreshImages();
        }
예제 #6
0
        public LinesSheet(SettingsProvider provider) : base(provider)
        {
            InitializeComponent();

            Name  = "LinesSheet";
            Title = Resx.LinesSheet_Title;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introBox",
                    "colorLabel",
                    "clickLabel",
                    "lengthLabel"
                });
            }

            var settings = provider.GetCollection(Name);

            colorBox.BackColor = settings.Get <Color>("color", Color.Black);
            lengthBox.Value    = settings.Get <decimal>("length", 100);
        }
예제 #7
0
        public SearchEngineSheet(SettingsProvider provider) : base(provider)
        {
            InitializeComponent();

            Name  = "SearchEngineSheet";
            Title = Resx.SearchEngineDialog_Text;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introLabel",
                    "upButton",
                    "downButton",
                    "refreshButton=word_Refresh",
                    "deleteLabel",
                    "deleteButton=word_Delete"
                });

                iconColumn.HeaderText = Resx.SearchEngineDialog_iconColumn_HeaderText;
                nameColumn.HeaderText = Resx.word_Name;
                urlColumn.HeaderText  = Resx.SearchEngineDialog_urlColumn_HeaderText;
            }

            toolStrip.Rescale();

            gridView.AutoGenerateColumns         = false;
            gridView.Columns[0].DataPropertyName = "Image";
            gridView.Columns[1].DataPropertyName = "Name";
            gridView.Columns[2].DataPropertyName = "Uri";

            engines = new BindingList <SearchEngine>(LoadSettings());

            gridView.DataSource = engines;

            RefreshImages();
        }
예제 #8
0
        public SettingsDialog(IRibbonUI ribbon)
        {
            InitializeComponent();

            VerticalOffset = 4;

            if (NeedsLocalizing())
            {
                Text = Resx.SettingsDialog_Text;

                Localize(new string[]
                {
                    "okButton=word_OK",
                    "cancelButton=word_Cancel"
                });

                navTree.Nodes["generalNode"].Text   = Resx.SettingsDialog_generalNode_Text;
                navTree.Nodes["contextNode"].Text   = Resx.SettingsDialog_contextNode_Text;
                navTree.Nodes["favoritesNode"].Text = Resx.SettingsDialog_favoritesNode_Text;
                navTree.Nodes["highlightNode"].Text = Resx.SettingsDialog_highlightNode_Text;
                navTree.Nodes["keyboardNode"].Text  = Resx.SettingsDialog_keyboardNode_Text;
                navTree.Nodes["linesNode"].Text     = Resx.SettingsDialog_linesNode_Text;
                navTree.Nodes["pluginsNode"].Text   = Resx.SettingsDialog_pluginsNode_Text;
                navTree.Nodes["ribbonNode"].Text    = Resx.SettingsDialog_ribbonNode_Text;
                navTree.Nodes["searchNode"].Text    = Resx.SettingsDialog_searchNode_Text;
                navTree.Nodes["snippetsNode"].Text  = Resx.SettingsDialog_snippetshNode_Text;
            }

            this.ribbon = ribbon;
            provider    = new SettingsProvider();
            sheets      = new Dictionary <int, SheetBase>();

            navTree.SelectedNode = navTree.Nodes[0];
            navTree.Focus();

            restart = false;
        }
예제 #9
0
        public GeneralSheet(SettingsProvider provider) : base(provider)
        {
            InitializeComponent();

            LoadLanguages();

            Name  = "GeneralSheet";
            Title = Resx.GeneralSheet_Title;

            if (NeedsLocalizing())
            {
                Localize(new string[]
                {
                    "introBox",
                    "enablersBox",
                    "checkUpdatesBox",
                    "langLabel"
                });
            }

            var settings = provider.GetCollection(Name);

            enablersBox.Checked     = settings.Get("enablers", true);
            checkUpdatesBox.Checked = settings.Get("checkUpdates", false);

            var lang = settings.Get("language", "en-US");

            foreach (CultureInfo info in langBox.Items)
            {
                if (info.Name == lang)
                {
                    langBox.SelectedItem = info;
                    break;
                }
            }
        }