示例#1
0
        public static DialogResult Show(string caption, string label, out string text)
        {
            InputQuery dialog = new InputQuery();

            dialog.label.Text = label;
            dialog.Text       = caption;
            DialogResult result;

            if ((result = dialog.ShowDialog()) == DialogResult.OK)
            {
                text = dialog.textBox.Text;
            }
            else
            {
                text = string.Empty;
            }
            return(result);
        }
示例#2
0
        private void ActionGenerateResourceIDsExecute(object sender, EventArgs e)
        {
            int autoID;

            void SetID(TRibbonString rs)
            {
                if (!string.IsNullOrEmpty(rs.Content))
                {
                    rs.Id = autoID;
                    autoID++;
                }
            }

            void SetImageID(TRibbonList <TRibbonImage> rl)
            {
                for (int i1 = 0; i1 < rl.Count; i1++)
                {
                    rl[i1].Id = autoID;
                    autoID++;
                }
            }

            TRibbonCommand command;
            int            i, maxID;
            string         s;

            //
            // First work out the maximum no of command ids that will be required
            maxID = _commandsFrame.ListViewCommands.Items.Count; //@ bugfix
            for (i = 0; i < _commandsFrame.ListViewCommands.Items.Count; i++)
            {
                command = (TRibbonCommand)_commandsFrame.ListViewCommands.Items[i].Tag;
                {
                    if (!string.IsNullOrEmpty(command.LabelTitle.Content))
                    {
                        maxID++;
                    }
                    if (!string.IsNullOrEmpty(command.LabelDescription.Content))
                    {
                        maxID++;
                    }
                    if (!string.IsNullOrEmpty(command.TooltipTitle.Content))
                    {
                        maxID++;
                    }
                    if (!string.IsNullOrEmpty(command.TooltipDescription.Content))
                    {
                        maxID++;
                    }
                    if (!string.IsNullOrEmpty(command.Keytip.Content))
                    {
                        maxID++;
                    }
                    maxID += command.SmallImages.Count + command.LargeImages.Count
                             + command.SmallHighContrastImages.Count + command.LargeHighContrastImages.Count;
                }
            }

            if (InputQuery.Show(this, "ID Number", "Enter the starting ID number between 2 & " + (59999 - maxID).ToString(), out s) == DialogResult.OK)
            {
                if (!int.TryParse(s, out autoID))
                {
                    throw new ArgumentException("Invalid integer value");
                }
            }
            else
            {
                return;
            }

            if ((autoID < 2) || (autoID + maxID > 59999))
            {
                throw new ArgumentException(autoID.ToString() + "is an invalid starting ID. "
                                            + "Must be a number between 2 && < " + (59999 - maxID).ToString(), nameof(autoID));
            }

            for (i = 0; i < _commandsFrame.ListViewCommands.Items.Count; i++)
            {
                command = (TRibbonCommand)_commandsFrame.ListViewCommands.Items[i].Tag;

                {
                    SetID(command.LabelTitle);
                    SetID(command.LabelDescription);
                    SetID(command.TooltipTitle);
                    SetID(command.TooltipDescription);
                    SetID(command.Keytip);

                    SetImageID(command.SmallImages);
                    SetImageID(command.LargeImages);
                    SetImageID(command.SmallHighContrastImages);
                    SetImageID(command.LargeHighContrastImages);
                }
            }
            _commandsFrame.RefreshSelection();
        }