/// <summary>
        /// フォームロードイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormKeySettings_Load(object sender, EventArgs e)
        {
            tabControlCommands.TabPages.Clear();

            var settings = ShortcutKeyManager.ShortcutKeyManager.LoadSettings("shortcutkeys.xml");

            if (settings == null)
            {
                settings = new Dictionary <string, ShortcutKeyManager.ShortcutKeyManager.KeyParam>();
            }

            var layout = LayoutLoader.Load(@".\layout.xml");

            foreach (var layoutTab in layout.Tabs)
            {
                var listview = new ListView();
                listview.Dock          = DockStyle.Fill;
                listview.HideSelection = false;
                listview.FullRowSelect = true;
                listview.View          = View.Details;

                var columnsHeaderCommands = new ColumnHeader();
                columnsHeaderCommands.Text  = "Commands";
                columnsHeaderCommands.Width = 300;
                listview.Columns.Add(columnsHeaderCommands);
                var columnsHeaderShortcutKeys = new ColumnHeader();
                columnsHeaderShortcutKeys.Text  = "Shortcut Key(s)";
                columnsHeaderShortcutKeys.Width = 140;
                listview.Columns.Add(columnsHeaderShortcutKeys);

                foreach (var layoutKeySet in layoutTab.KeySets)
                {
                    var settingsId = layoutTab.Id + SettingsIdNameSeparator + layoutKeySet.Id;
                    var item       = new ListViewItem(layoutKeySet.Label);
                    var subItem    = new ListViewItem.ListViewSubItem();
                    if (settings.ContainsKey(settingsId))
                    {
                        subItem.Text = string.Join(", ", settings[settingsId].KeyTexts);
                    }
                    else
                    {
                        subItem.Text = string.Join(", ", layoutKeySet.KeyTexts);
                    }
                    item.SubItems.Add(subItem);
                    item.Tag = layoutKeySet;
                    listview.Items.Add(item);
                    listview.SelectedIndexChanged += listViewCommands_SelectedIndexChanged;
                }

                var tabPage = new TabPage();
                tabPage.Name = layoutTab.Id;
                tabPage.Text = layoutTab.Label;
                tabPage.Controls.Add(listview);
                tabPage.Tag = listview;

                tabControlCommands.TabPages.Add(tabPage);
            }

            LocalizeUtil.Localized(this);
        }
Beispiel #2
0
        /// <summary>
        /// フォームのロードイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormKeyEditor_Load(object sender, EventArgs e)
        {
            var layout = LayoutLoader.Load(@".\EditorLayout.xml");

            if (!CheckLayoutParam(layout))
            {
                Close();
                return;
            }

            var settings = ShortcutKeyManager.LoadSettings(@".\shortcutkeys.xml");

            if (settings == null)
            {
                settings = new Dictionary <string, ShortcutKeyManager.KeySet>();
            }

            foreach (var layoutTab in layout.Tabs)
            {
                var tabPage = new TabPage();
                tabPage.Text       = layoutTab.Label;
                tabPage.AutoScroll = true;
                tabPage.BackColor  = layout.Skin.PanelColor.Background;

                var flowPanel = new FlowLayoutPanel();
                flowPanel.Dock       = DockStyle.Fill;
                flowPanel.AutoScroll = true;
                flowPanel.BackColor  = layout.Skin.PanelColor.Background;
                int labelMaxWidth = 0;
                foreach (var layoutKeySet in layoutTab.KeySets)
                {
                    var keySetName = layoutTab.Name + "_" + layoutKeySet.Name;

                    var keyset = new KeySetControl();
                    keyset.KeySetName = keySetName;
                    keyset.SetLabelText(layoutKeySet.Label);
                    keyset.SetKeyText(settings.ContainsKey(keySetName) ? settings[keySetName].KeyText : layoutKeySet.KeyText);
                    keyset.LabelColor   = layout.Skin.KeyColor.Label;
                    keyset.TextColor    = layout.Skin.KeyColor.Text;
                    keyset.TextboxColor = layout.Skin.KeyColor.Textbox;
                    keyset.BackColor    = layout.Skin.KeyColor.Background;
                    keyset.Tag          = layoutKeySet;
                    flowPanel.Controls.Add(keyset);

                    labelMaxWidth = Math.Max(keyset.LabelWidth, labelMaxWidth);
                }
                tabPage.Controls.Add(flowPanel);
                tabControlMain.TabPages.Add(tabPage);

                // 表示幅の調整
                foreach (var control in flowPanel.Controls)
                {
                    if (control is KeySetControl)
                    {
                        var keyset = control as KeySetControl;
                        keyset.Width = keyset.Width + labelMaxWidth;
                    }
                }
            }
        }