コード例 #1
0
ファイル: InfoForm.cs プロジェクト: ndefilippis/EDDiscovery
        public void Info(string title, Icon ic, string info, Font fnt, int[] array, bool themeit = false)
        {
            Icon = ic;
            Text = title;
            textBoxInfo.SetTabs(array);
            textBoxInfo.ReadOnly = true;
            textBoxInfo.Text     = info;
            textBoxInfo.Select(0, 0);

            ThemeableForms theme = ThemeableFormsInstance.Instance;

            if (themeit && theme != null)
            {
                if (fnt == null)
                {
                    fnt = new Font(theme.FontName, 12.0F);
                }
                theme.ApplyToForm(this, fnt);
            }

            textBoxInfo.Font = fnt;
        }
コード例 #2
0
        public void Info(string title, Icon ic, string info, Font fnt, int[] array, bool themeit = false)
        {
            Icon = ic;
            Text = title;
            textBoxInfo.SetTabs(array);
            textBoxInfo.ReadOnly = true;
            textBoxInfo.Text     = info;
            textBoxInfo.Select(0, 0);

            labelCaption.Text = title;

            ThemeableForms theme = ThemeableFormsInstance.Instance;

            if (themeit && theme != null)
            {
                if (fnt == null)
                {
                    fnt = new Font(theme.FontName, 12.0F);
                }
                bool winborder = theme.ApplyToForm(this, fnt);
                if (winborder)
                {
                    panelTop.Visible = false;
                }
            }
            else
            {
                panelTop.Visible = false;
                if (fnt == null)
                {
                    fnt = new Font(Font.SystemFontName, 12.0F);
                }
            }

            textBoxInfo.Font = fnt;
        }
コード例 #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            switch (buttons)
            {
            case null:
                buttonExt1.Visible = buttonExt2.Visible = buttonExt3.Visible = false;
                break;

            case MessageBoxButtons.AbortRetryIgnore:
                buttonExt1.DialogResult = DialogResult.Ignore; buttonExt1.Text = "Ignore";
                buttonExt2.DialogResult = DialogResult.Retry; buttonExt2.Text = "Retry";
                buttonExt3.DialogResult = DialogResult.Abort; buttonExt3.Text = "Abort";
                this.AcceptButton       = buttonExt2;
                this.CancelButton       = buttonExt3;
                break;

            case MessageBoxButtons.OKCancel:
                buttonExt1.DialogResult = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.DialogResult = DialogResult.OK; buttonExt2.Text = "OK";
                buttonExt3.Visible      = false;
                this.AcceptButton       = buttonExt2;
                this.CancelButton       = buttonExt1;
                break;

            case MessageBoxButtons.RetryCancel:
                buttonExt1.DialogResult = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.DialogResult = DialogResult.OK; buttonExt2.Text = "Retry";
                buttonExt3.Visible      = false;
                this.AcceptButton       = buttonExt2;
                this.CancelButton       = buttonExt1;
                break;

            case MessageBoxButtons.YesNo:
                buttonExt1.DialogResult = DialogResult.No; buttonExt1.Text = "No";
                buttonExt2.DialogResult = DialogResult.Yes; buttonExt2.Text = "Yes";
                buttonExt3.Visible      = false;
                break;

            case MessageBoxButtons.YesNoCancel:
                buttonExt1.DialogResult = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.DialogResult = DialogResult.No; buttonExt2.Text = "No";
                buttonExt3.DialogResult = DialogResult.Yes; buttonExt3.Text = "Yes";
                this.AcceptButton       = this.CancelButton = buttonExt1;
                break;

            case MessageBoxButtons.OK:
            default:
                buttonExt1.DialogResult = DialogResult.OK; buttonExt1.Text = "OK";
                buttonExt2.Visible      = false;
                buttonExt3.Visible      = false;
                this.AcceptButton       = this.CancelButton = buttonExt1;
                break;
            }

            switch (mbIcon)
            {
            // case MessageBoxIcon.Information:
            case MessageBoxIcon.Asterisk:
                panelIcon = SystemIcons.Asterisk.ToBitmap();
                break;

            // case MessageBoxIcon.Exclamation:
            case MessageBoxIcon.Warning:
                panelIcon = SystemIcons.Warning.ToBitmap();
                break;

            // case MessageBoxIcon.Error:
            // case MessageBoxIcon.Stop:
            case MessageBoxIcon.Hand:
                panelIcon = SystemIcons.Hand.ToBitmap();
                break;

            case MessageBoxIcon.Question:
                panelIcon = SystemIcons.Question.ToBitmap();
                break;

            case MessageBoxIcon.None:
            default:
                break;
            }

            bool           framed = !(FormBorderStyle == FormBorderStyle.None);
            ThemeableForms theme  = ThemeableFormsInstance.Instance;

            if (theme != null)  // paranoid
            {
                this.Font      = new Font(theme.FontName, 12.0F);
                this.ForeColor = theme.TextBlockColor;
                framed         = theme.ApplyToForm(this, this.Font);
                if (theme.MessageBoxWindowIcon != null)
                {
                    this.Icon = theme.MessageBoxWindowIcon;
                }
            }
            else
            {
                this.Font      = new Font("MS Sans Serif", 12.0F);
                this.ForeColor = Color.Black;
            }

            labelCaption.Visible = !framed;
            ystart = framed ? 30 : 50;

            SetText(msgText);
        }
コード例 #4
0
        public void Init(string ptext, string caption, MessageBoxButtons buttons, MessageBoxIcon ic, System.Drawing.Icon windowicon)
        {
            if (buttons == MessageBoxButtons.AbortRetryIgnore)
            {
                buttonExt1.Tag = DialogResult.Ignore; buttonExt1.Text = "Ignore";
                buttonExt2.Tag = DialogResult.Retry; buttonExt2.Text = "Retry";
                buttonExt3.Tag = DialogResult.Abort; buttonExt3.Text = "Abort";
            }
            else if (buttons == MessageBoxButtons.OK)
            {
                buttonExt1.Tag     = DialogResult.OK; buttonExt1.Text = "OK";
                buttonExt2.Visible = false;
                buttonExt3.Visible = false;
                this.AcceptButton  = this.CancelButton = buttonExt1;
            }
            else if (buttons == MessageBoxButtons.OKCancel)
            {
                buttonExt1.Tag     = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.Tag     = DialogResult.OK; buttonExt2.Text = "OK";
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.RetryCancel)
            {
                buttonExt1.Tag     = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.Tag     = DialogResult.OK; buttonExt2.Text = "Retry";
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.YesNo)
            {
                buttonExt1.Tag     = DialogResult.No; buttonExt1.Text = "No";
                buttonExt2.Tag     = DialogResult.Yes; buttonExt2.Text = "Yes";
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.YesNoCancel)
            {
                buttonExt1.Tag = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.Tag = DialogResult.No; buttonExt2.Text = "No";
                buttonExt3.Tag = DialogResult.Yes; buttonExt3.Text = "Yes";
            }

            labelCaption.Text = this.Text = caption;
            text = ptext;

            if (ic == MessageBoxIcon.Asterisk)
            {
                icon = SystemIcons.Asterisk;
            }
            if (ic == MessageBoxIcon.Error)
            {
                icon = SystemIcons.Error;
            }
            if (ic == MessageBoxIcon.Exclamation)
            {
                icon = SystemIcons.Exclamation;
            }
            if (ic == MessageBoxIcon.Information)
            {
                icon = SystemIcons.Information;
            }
            if (ic == MessageBoxIcon.Question)
            {
                icon = SystemIcons.Question;
            }
            if (ic == MessageBoxIcon.Warning)
            {
                icon = SystemIcons.Warning;
            }

            int ystart = 30;

            ThemeableForms theme = ThemeableFormsInstance.Instance;

            if (theme != null)  // paranoid
            {
                fnt        = new Font(theme.FontName, 12.0F);
                forecolour = theme.TextBlockColor;
                bool border = theme.ApplyToForm(this, fnt);
                if (!border)
                {
                    labelCaption.Visible = true;
                    ystart += 20;
                }
            }
            else
            {
                fnt        = new Font("MS Sans Serif", 12.0F);
                forecolour = Color.Red;
            }

            if (windowicon != null)
            {
                this.Icon = windowicon;
            }

            int bordery = Bounds.Height - ClientRectangle.Height;
            int borderx = Bounds.Width - ClientRectangle.Width;

            int left = (ic != MessageBoxIcon.None) ? 80 : 20;

            using (Graphics g = CreateGraphics())
            {
                SizeF sizeftext    = g.MeasureString(text, fnt);
                SizeF sizefcaption = g.MeasureString(caption, fnt);

                Height = (int)sizeftext.Height + ystart + 50 + bordery;
                Width  = Math.Min(Math.Max(300, left + (int)Math.Max(sizeftext.Width, sizefcaption.Width) + 20), 1800) + borderx;

                textarea = new Rectangle(left, ystart, (int)(sizeftext.Width + 1), (int)(sizeftext.Height + 1));
            }
        }
コード例 #5
0
        public void Init(string ptext, string caption, MessageBoxButtons?buttons, MessageBoxIcon ic, System.Drawing.Icon windowicon)
        {
            if (buttons == null)
            {
                buttonExt1.Visible = false;
                buttonExt2.Visible = false;
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.AbortRetryIgnore)
            {
                buttonExt1.Tag = DialogResult.Ignore; buttonExt1.Text = "Ignore";
                buttonExt2.Tag = DialogResult.Retry; buttonExt2.Text = "Retry";
                buttonExt3.Tag = DialogResult.Abort; buttonExt3.Text = "Abort";
            }
            else if (buttons == MessageBoxButtons.OK)
            {
                buttonExt1.Tag     = DialogResult.OK; buttonExt1.Text = "OK";
                buttonExt2.Visible = false;
                buttonExt3.Visible = false;
                this.AcceptButton  = this.CancelButton = buttonExt1;
            }
            else if (buttons == MessageBoxButtons.OKCancel)
            {
                buttonExt1.Tag     = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.Tag     = DialogResult.OK; buttonExt2.Text = "OK";
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.RetryCancel)
            {
                buttonExt1.Tag     = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.Tag     = DialogResult.OK; buttonExt2.Text = "Retry";
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.YesNo)
            {
                buttonExt1.Tag     = DialogResult.No; buttonExt1.Text = "No";
                buttonExt2.Tag     = DialogResult.Yes; buttonExt2.Text = "Yes";
                buttonExt3.Visible = false;
            }
            else if (buttons == MessageBoxButtons.YesNoCancel)
            {
                buttonExt1.Tag = DialogResult.Cancel; buttonExt1.Text = "Cancel";
                buttonExt2.Tag = DialogResult.No; buttonExt2.Text = "No";
                buttonExt3.Tag = DialogResult.Yes; buttonExt3.Text = "Yes";
            }

            labelCaption.Text = this.Text = caption;

            if (ic == MessageBoxIcon.Asterisk)
            {
                icon = SystemIcons.Asterisk;
            }
            else if (ic == MessageBoxIcon.Error)
            {
                icon = SystemIcons.Error;
            }
            else if (ic == MessageBoxIcon.Exclamation)
            {
                icon = SystemIcons.Exclamation;
            }
            else if (ic == MessageBoxIcon.Information)
            {
                icon = SystemIcons.Information;
            }
            else if (ic == MessageBoxIcon.Question)
            {
                icon = SystemIcons.Question;
            }
            else if (ic == MessageBoxIcon.Warning)
            {
                icon = SystemIcons.Warning;
            }

            ThemeableForms theme = ThemeableFormsInstance.Instance;

            if (theme != null)  // paranoid
            {
                fnt        = new Font(theme.FontName, 12.0F);
                forecolour = theme.TextBlockColor;
                bool border = theme.ApplyToForm(this, fnt);
                if (!border)
                {
                    labelCaption.Visible = true;
                }
                ystart = 30 + (!border ? 20 : 0);
                if (windowicon != null)
                {
                    this.Icon = windowicon;
                }
                else if (theme.MessageBoxWindowIcon != null)
                {
                    this.Icon = theme.MessageBoxWindowIcon;
                }
            }
            else
            {
                fnt        = new Font("MS Sans Serif", 12.0F);
                forecolour = Color.Black;
                if (windowicon != null)
                {
                    this.Icon = windowicon;
                }
                ystart = 30;
            }

            SetText(ptext);
        }
コード例 #6
0
        }                                                               // Tell dragger no resizing.

        public void Init(Icon i, bool showprocess, string separ, string keystring = "", string process = "",
                         List <string> additionalkeys = null, int defdelay = 50, bool allowkeysedit = false)
        {
            if (i != null)
            {
                Icon = i;
            }

            seperator = separ;

            textBoxKeys.Text = keystring;
            curinsertpoint   = keystring.Length;

            textBoxSendTo.Text       = process.Alt(BaseUtils.EnhancedSendKeys.CurrentWindow);
            textBoxDelay.Text        = textBoxNextDelay.Text = defdelay.ToStringInvariant();
            radioButtonPress.Checked = true;

            if (additionalkeys != null)
            {
                comboBoxKeySelector.Items.AddRange(additionalkeys);
            }
            comboBoxKeySelector.Items.AddRange(KeyObjectExtensions.KeyListString());
            //System.Diagnostics.Debug.WriteLine(String.Join(",",KeyObjectExtensions.VKeyList()));
            comboBoxKeySelector.Text = "";
            comboBoxKeySelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxKeySelector_SelectedIndexChanged);

            if (!showprocess)
            {
                textBoxNextDelay.Visible = panelRadio.Visible = labelNextDelay.Visible = labelDelay.Visible = textBoxDelay.Visible = labelSendTo.Visible = textBoxSendTo.Visible = buttonTest.Visible = false;

                int d = textBoxKeys.Top - textBoxDelay.Top;
                foreach (Control c in new Control[] { buttonReset, buttonDelete, buttonNext, textBoxKeys, labelKeys })
                {
                    c.Top -= d; // shift down
                }
                d += 40;        // cause of the Send
                foreach (Control c in new Control[] { buttonOK, buttonCancel })
                {
                    c.Top -= d;
                }
                panelOuter.Height -= d;
                this.Height       -= d;
            }

            //System.Diagnostics.Debug.WriteLine("T" + textBoxKeys.Text + " at " + curinsertpoint + " >" + textBoxSendTo.Text);

            bool           border = true;
            ThemeableForms theme  = ThemeableFormsInstance.Instance;

            if (theme != null)  // paranoid
            {
                border = theme.ApplyToForm(this);
            }

            labelCaption.Visible = !border;

            AddMF();

            if (allowkeysedit)
            {
                textBoxKeys.ReadOnly = false;
            }

            DisplayKeyString();
        }
コード例 #7
0
        public void Show(Form p, string lname, Icon icon, System.Drawing.Size size, System.Drawing.Point pos, string caption, Entry[] e, Object t)
        {
            logicalname = lname; // passed back to caller via trigger
            entries     = e;
            callertag   = t;     // passed back to caller via trigger

            ThemeableForms theme = ThemeableFormsInstance.Instance;

            FormBorderStyle = FormBorderStyle.FixedDialog;

            if (theme.WindowsFrame)
            {
                size.Height += 50;
            }

            Size = size;

            if (pos.X == -999)
            {
                StartPosition = FormStartPosition.CenterScreen;
            }
            else
            {
                Location      = pos;
                StartPosition = FormStartPosition.Manual;
            }

            Panel outer = new Panel()
            {
                Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle
            };

            outer.MouseDown += FormMouseDown;
            outer.MouseUp   += FormMouseUp;

            Controls.Add(outer);

            this.Text = caption;

            Label textLabel = new Label()
            {
                Left = 4, Top = 8, Width = Width - 50, Text = caption
            };

            textLabel.MouseDown += FormMouseDown;
            textLabel.MouseUp   += FormMouseUp;

            if (!theme.WindowsFrame)
            {
                outer.Controls.Add(textLabel);
            }

            ToolTip tt = new ToolTip(components);

            tt.ShowAlways = true;
            for (int i = 0; i < entries.Length; i++)
            {
                Entry   ent = entries[i];
                Control c   = (Control)Activator.CreateInstance(ent.controltype);
                ent.control = c;
                c.Size      = ent.size;
                c.Location  = ent.pos;
                if (!(c is ExtendedControls.ComboBoxCustom))        // everything but get text
                {
                    c.Text = ent.text;
                }
                c.Tag = ent;     // point control tag at ent structure
                outer.Controls.Add(c);
                if (ent.tooltip != null)
                {
                    tt.SetToolTip(c, ent.tooltip);
                }

                if (c is ExtendedControls.ButtonExt)
                {
                    ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt;
                    b.Click += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        Trigger?.Invoke(logicalname, en.name, callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }

                if (c is ExtendedControls.TextBoxBorder)
                {
                    ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder;
                    tb.Multiline = tb.WordWrap = ent.textboxmultiline;
                }

                if (c is ExtendedControls.CheckBoxCustom)
                {
                    ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom;
                    cb.Checked = ent.checkboxchecked;
                    cb.Click  += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        Trigger?.Invoke(logicalname, en.name, callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }

                if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    cb.Items.AddRange(ent.comboboxitems.Split(','));
                    if (cb.Items.Contains(ent.text))
                    {
                        cb.SelectedItem = ent.text;
                    }
                    cb.SelectedIndexChanged += (sender, ev) =>
                    {
                        Control ctr = (Control)sender;
                        if (ctr.Enabled)
                        {
                            Entry en = (Entry)(ctr.Tag);
                            Trigger?.Invoke(logicalname, en.name, callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
            }

            ShowInTaskbar = false;

            this.Icon = icon;

            theme.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont);

            Show(p);
        }
コード例 #8
0
        // lab sets the items, def can be less or null
        public static List <string> ShowDialog(Form p, string caption, Icon ic, string[] lab, string[] def, bool multiline = false, string[] tooltips = null)
        {
            ThemeableForms theme = ThemeableFormsInstance.Instance;

            int vstart   = theme.WindowsFrame ? 20 : 40;
            int vspacing = multiline ? 60 : 40;
            int lw       = 100;
            int lx       = 10;
            int tx       = 10 + lw + 8;

            Form prompt = new Form()
            {
                Width           = 600,
                Height          = 90 + vspacing * lab.Length + (theme.WindowsFrame ? 20 : 0),
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = caption,
                StartPosition   = FormStartPosition.CenterScreen,
                Icon            = ic
            };

            Panel outer = new Panel()
            {
                Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle
            };

            prompt.Controls.Add(outer);

            Label textLabel = new Label()
            {
                Left = lx, Top = 8, Width = prompt.Width - 50, Text = caption
            };

            if (!theme.WindowsFrame)
            {
                outer.Controls.Add(textLabel);
            }

            Label[] lbs = new Label[lab.Length];
            ExtendedControls.TextBoxBorder[] tbs = new ExtendedControls.TextBoxBorder[lab.Length];

            ToolTip tt = new ToolTip();

            tt.ShowAlways = true;

            int y = vstart;

            for (int i = 0; i < lab.Length; i++)
            {
                lbs[i] = new Label()
                {
                    Left = lx, Top = y, Width = lw, Text = lab[i]
                };
                tbs[i] = new ExtendedControls.TextBoxBorder()
                {
                    Left       = tx,
                    Top        = y,
                    Width      = prompt.Width - 50 - tx,
                    Text       = (def != null && i < def.Length) ? def[i] : "",
                    Height     = vspacing - 20,
                    Multiline  = multiline,
                    ScrollBars = (multiline) ? ScrollBars.Vertical : ScrollBars.None,
                    WordWrap   = multiline
                };
                outer.Controls.Add(lbs[i]);
                outer.Controls.Add(tbs[i]);

                if (tooltips != null && i < tooltips.Length)
                {
                    tt.SetToolTip(lbs[i], tooltips[i]);
                    tbs[i].SetTipDynamically(tt, tooltips[i]);      // no container here, set tool tip on text boxes using this
                }

                y += vspacing;
            }

            ExtendedControls.ButtonExt confirmation = new ExtendedControls.ButtonExt()
            {
                Text = "Ok", Left = tbs[0].Right - 80, Width = 80, Top = y, DialogResult = DialogResult.OK
            };
            outer.Controls.Add(confirmation);
            confirmation.Click += (sender, e) => { prompt.Close(); };

            ExtendedControls.ButtonExt cancel = new ExtendedControls.ButtonExt()
            {
                Text = "Cancel", Left = confirmation.Location.X - 90, Width = 80, Top = confirmation.Top, DialogResult = DialogResult.Cancel
            };
            outer.Controls.Add(cancel);
            cancel.Click += (sender, e) => { prompt.Close(); };

            if (!multiline)
            {
                prompt.AcceptButton = confirmation;
            }

            prompt.CancelButton  = cancel;
            prompt.ShowInTaskbar = false;

            theme.ApplyToForm(prompt, System.Drawing.SystemFonts.DefaultFont);

            if (prompt.ShowDialog(p) == DialogResult.OK)
            {
                var r = (from ExtendedControls.TextBoxBorder t in tbs select t.Text).ToList();
                return(r);
            }
            else
            {
                return(null);
            }
        }