コード例 #1
0
        private void MenuGroup_Rename_Click(object sender, EventArgs e)
        {
            ImageLabel senderLabel = MenuGroup.SourceControl as ImageLabel;

            if (senderLabel == null)
            {
                return;
            }

            ShipGroupData group = KCDatabase.Instance.ShipGroup[(int)senderLabel.Tag];

            if (group != null && group.GroupID >= 0)
            {
                using (var dialog = new DialogTextInput("グループ名の変更", "グループ名を入力してください:")) {
                    dialog.InputtedText = group.Name;

                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        group.Name = senderLabel.Text = dialog.InputtedText.Trim();
                    }
                }
            }
            else
            {
                MessageBox.Show("このグループの名前を変更することはできません。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
        private void MenuGroup_Add_Click(object sender, EventArgs e)
        {
            using (var dialog = new DialogTextInput("グループを追加", "グループ名を入力してください:")) {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var group = KCDatabase.Instance.ShipGroup.Add();

                    group.Name         = dialog.InputtedText.Trim();
                    group.ColumnFilter = ShipView.Columns.OfType <DataGridViewColumn>().Select(c => c.Visible).ToList();
                    if (group.ColumnFilter.All(f => !f))
                    {
                        group.ColumnFilter = Enumerable.Repeat <bool>(true, ShipView.Columns.Count).ToList();
                    }
                    group.ColumnWidth    = ShipView.Columns.OfType <DataGridViewColumn>().Select(c => c.Width).ToList();
                    group.ColumnAutoSize = MenuMember_ColumnAutoSize.Checked;

                    TabPanel.Controls.Add(CreateTabLabel(group.GroupID));
                }
            }
        }
コード例 #3
0
        private void MenuMember_CreateGroup_Click(object sender, EventArgs e)
        {
            using (var dialog = new DialogTextInput("グループの追加", "追加するグループの名前を入力してください:")) {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var group = KCDatabase.Instance.ShipGroup.Add();

                    group.Name = dialog.InputtedText.Trim();
                    foreach (DataGridViewRow row in ShipView.SelectedRows.OfType <DataGridViewRow>().OrderBy(r => r.Tag))
                    {
                        group.Members.Add((int)row.Cells[ShipView_ID.Index].Value);
                    }
                    group.ColumnFilter   = ShipView.Columns.OfType <DataGridViewColumn>().Select(c => c.Visible).ToList();
                    group.ColumnWidth    = ShipView.Columns.OfType <DataGridViewColumn>().Select(c => c.Width).ToList();
                    group.ColumnAutoSize = MenuMember_ColumnAutoSize.Checked;

                    ImageLabel il = CreateTabLabel(group.GroupID);
                    TabPanel.Controls.Add(il);

                    ChangeShipView(il);
                }
            }
        }
コード例 #4
0
        protected override void Construct()
        {
            Tuple <float, float> cpos = GetCenterOfParent();

            int width  = ((int)cpos.Item2 * 5 / 3);
            int height = 400;

            Width  = width;
            Height = height;

            Panel = new UIPanel(cpos.Item1 - width / 2, cpos.Item2 - height / 2, width, height,
                                hastitle: !string.IsNullOrEmpty(Title), title: Title, titlesize: TitleFontSize);
            Panel.LockFocus = true;

            UIAutoList tops = new UIAutoList(eUIOrientation.HORIZONTAL, width - 10, 40)
            {
                HasBorder      = false,
                HasOuterBorder = false,
                MarginX        = 0,
                MarginY        = 0,
            };

            Panel.AddAuto(tops);

            UIButton upbtn = new UIButton(0, 0, 50, 30, "Up");

            upbtn.EventFocused += (sender, args) =>
            {
                var eargs = args as UITextField.EventFocusedHandlerArgs;
                try
                {
                    DisplayFolder(Directory.GetParent(FolderText.Text).FullName, eargs.ElapsedMS, eargs.Input);
                }
                catch
                {
                    // just don't do anything
                }

                if (ParentSystem != null)
                {
                    ParentSystem.ProposedFocus = FileListPanel;
                }
            };
            tops.AddAuto(upbtn);

            FolderText = new UITextField(0, 0, width - 50 - 10, 30, DefaultFolderPath, fontsize: 12, autoheight: false);
            FolderText.EventEnterPressed += (sender, args) =>
            {
                var eargs = args as UITextField.EventEnterPressedHandlerArgs;
                DisplayFolder(FolderText.Text, eargs.ElapsedMS, eargs.Input);
            };
            tops.AddAuto(FolderText);

            FileListPanel = new UIPanel(0, 5, width - 10, height - 35 - 110, hasscrolling: true, scrollh: height - 30 - 110);
            Panel.AddAuto(FileListPanel);

            FileText = new UITextField(0, 5, width - 10, 30, DefaultFileName, fontsize: 12, autoheight: false);
            FileText.EventEnterPressed += (sender, args) =>
            {
                var eargs = args as UITextField.EventEnterPressedHandlerArgs;
                OKResult(eargs.ElapsedMS, eargs.Input);
            };
            if (Mode != eMode.SELECT_FOLDER)
            {
                Panel.AddAuto(FileText);
            }

            UIAutoList bottomButtons = new UIAutoList(eUIOrientation.HORIZONTAL, width - 10, 50)
            {
                LeftAlign      = true,
                HasBorder      = false,
                HasOuterBorder = false,
                MarginX        = 10,
                MarginY        = 5,
                y = 5,
            };

            Panel.AddAuto(bottomButtons);

            NewFolderButton = new UIButton(0, 5, 100, 35, "New Folder");
            bottomButtons.AddAuto(NewFolderButton);
            SelectButton = new UIButton(0, 5, 100, 35, SelectNames[Mode]);
            bottomButtons.AddAuto(SelectButton);
            CancelButton = new UIButton(0, 5, 100, 35, "Cancel");
            bottomButtons.AddAuto(CancelButton);

            NewFolderButton.EventFocused += (sender, e) =>
            {
                UIComponent.EventFocusedHandlerArgs eargs = e as UIComponent.EventFocusedHandlerArgs;
                DialogTextInput dialogTextInput           = new DialogTextInput("New Folder", "Name the new folder:", "", "Folder Name...");
                dialogTextInput.Popup(ParentSystem);

                dialogTextInput.EventClosedHandler += (innersender, innerargs) =>
                {
                    var innereargs = innerargs as DialogBase.EventClosedHandlerArgs;
                    // only process if OK was selected
                    if (dialogTextInput.Result)
                    {
                        string folderName = dialogTextInput.ResultText;
                        string folderPath = string.Empty;
                        bool   failed     = false;
                        // try to create this folder
                        try
                        {
                            folderPath = Path.Combine(FolderText.Text, folderName);
                            Directory.CreateDirectory(folderPath);
                        }
                        catch (Exception ex)
                        {
                            failed = true;
                            DialogPopup errorPopup = new DialogPopup("Failed to Create Folder", "Folder could not be created: " + ex.Message);
                            errorPopup.Popup(ParentSystem);
                        }

                        if (!failed)
                        {
                            DisplayFolder(folderPath, innereargs.ElapsedMS, innereargs.Input);
                        }
                    }
                };
            };
            SelectButton.EventFocused += (sender, e) =>
            {
                UIComponent.EventFocusedHandlerArgs eargs = e as UIComponent.EventFocusedHandlerArgs;
                OKResult(eargs.ElapsedMS, eargs.Input);
            };
            CancelButton.EventFocused += (sender, e) =>
            {
                UIComponent.EventFocusedHandlerArgs eargs = e as UIComponent.EventFocusedHandlerArgs;
                CancelResult(eargs.ElapsedMS, eargs.Input);
            };

            DisplayFolder(DefaultFolderPath, 0, null, skipinit: true);

            if (ParentSystem != null)
            {
                ParentSystem.ProposedFocus = FileListPanel;
            }
        }