Esempio n. 1
0
        private void trainingForm(int width, int height, Bitmap bitmapToRender, Form tempDisplay)
        {
            tempDisplay.SetBounds(10, 10, width + 360, height);
            tempDisplay.BackgroundImage = bitmapToRender;
            tempDisplay.BackgroundImageLayout = ImageLayout.Center;
            enterTheLabel.SetBounds(0, 0, 900, 30);
            segmentLabel.SetBounds(0, 30, 20, 20);

            tempDisplay.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

            Button submitLabel = new Button();
            submitLabel.Text = "Submit";
            submitLabel.SetBounds(2, 60, 60, 20);

            Button skip = new Button();
            skip.Text = "Skip";
            skip.SetBounds(64, 60, 50, 20);
            tempDisplay.Controls.Add(skip);

            tempDisplay.Controls.Add(segmentLabel);
            tempDisplay.Controls.Add(enterTheLabel);
            tempDisplay.Controls.Add(submitLabel);

            Point temp = new Point(3, 4);
            tempDisplay.Location = new Point(100, 100);

            submitLabel.Click += new System.EventHandler(submitLabel_click);
            skip.Click += new System.EventHandler(skip_click);
            tempDisplay.ShowDialog();
        }
Esempio n. 2
0
        public string InputBox(string title, string promptText)
        {
            Form form = new Form();

            System.Windows.Forms.Label   label    = new System.Windows.Forms.Label();
            System.Windows.Forms.TextBox textBox  = new System.Windows.Forms.TextBox();
            System.Windows.Forms.Button  buttonOk = new System.Windows.Forms.Button();
            form.Text             = title;
            label.Text            = promptText;
            buttonOk.Text         = "OK";
            buttonOk.DialogResult = DialogResult.OK;
            label.SetBounds(9, 10, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            label.AutoSize  = true;
            label.Anchor    = AnchorStyles.Left;
            textBox.Anchor  = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk });//Out of memory error caused on this line
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            DialogResult dialogResult = form.ShowDialog();

            return(textBox.Text);
        }
 public static DialogResult inputBox(string title, string labelText, ref string promptText)
 {
     Form form = new Form();
     Label label = new Label();
     Button buttonOk = new Button();
     Button buttonCancel = new Button();
     TextBox textBox = new TextBox();
     label.Text = labelText;
     form.Text = title;
     textBox.Text = promptText;
     buttonOk.Text = "Ok";
     buttonCancel.Text = "Cancelar";
     buttonOk.DialogResult = DialogResult.OK;
     buttonCancel.DialogResult = DialogResult.Cancel;
     form.AcceptButton = buttonOk;
     form.CancelButton = buttonCancel;
     label.SetBounds(9, 20, 372, 13);
     textBox.SetBounds(12, 36, 372, 20);
     buttonOk.SetBounds(228, 72, 75, 23);
     buttonCancel.SetBounds(309, 72, 75, 23);
     label.AutoSize = true;
     textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
     buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
     buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
     form.ClientSize = new Size(396, 107);
     form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
     form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
     form.FormBorderStyle = FormBorderStyle.FixedDialog;
     form.StartPosition = FormStartPosition.CenterScreen;
     form.MinimizeBox = false;
     form.MaximizeBox = false;
     DialogResult res = form.ShowDialog();
     promptText = textBox.Text;
     return res;
 }
Esempio n. 4
0
        /// <summary>
        /// Shows a dialog box with an input field.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="prompt"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DialogResult Show(string title, string prompt, ref string value)
        {
            Form mForm = new Form();
            Label mLabel = new Label();
            TextBox mTextBox = new TextBox();
            Button mOKButton = new Button();

            mForm.Text = title;
            mLabel.Text = prompt;
            mTextBox.Text = value;

            mOKButton.Text = "OK";
            mOKButton.DialogResult = DialogResult.OK;

            mForm.ClientSize = new Size(240, 80);
            mLabel.SetBounds(4, 4, mForm.ClientSize.Width-8, 22);
            mTextBox.SetBounds(32, 26, mForm.ClientSize.Width - 64, 24);
            mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, 54, 64, 22);

            mLabel.AutoSize = true;
            mTextBox.Anchor = AnchorStyles.Bottom;
            mOKButton.Anchor = AnchorStyles.Bottom;

            mForm.Controls.AddRange(new Control[] { mLabel, mTextBox, mOKButton });
            mForm.FormBorderStyle = FormBorderStyle.FixedDialog;
            mForm.StartPosition = FormStartPosition.CenterScreen;
            mForm.MinimizeBox = false;
            mForm.MaximizeBox = false;
            mForm.AcceptButton = mOKButton;

            DialogResult dialogResult = mForm.ShowDialog();
            value = mTextBox.Text;
            return dialogResult;
        }
Esempio n. 5
0
 private static void FixControlSizes(Label label, TextBox textBox, Button buttonOk, Button buttonCancel)
 {
     label.SetBounds(9, 20, 372, 13);
     textBox.SetBounds(12, 36, 372, 20);
     buttonOk.SetBounds(228, 72, 75, 23);
     buttonCancel.SetBounds(309, 72, 75, 23);
 }
Esempio n. 6
0
        /// <summary>
        /// Shows a dialog box with a property grid.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DialogResult Show(string title, ref Entity_cl value)
        {
            Form mForm = new Form();
            PropertyGrid mPropertyGrid = new PropertyGrid();
            Button mOKButton = new Button();

            mForm.Text = title + " Properties";
            mPropertyGrid.SelectedObject = value;
            mOKButton.Text = "OK";
            mOKButton.DialogResult = DialogResult.OK;

            mForm.ClientSize = new Size(320, 320);
            mPropertyGrid.SetBounds(4, 4, mForm.ClientSize.Width - 4, mForm.ClientSize.Height - 40);
            mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, mForm.ClientSize.Height - 36, 64, 22);

            mPropertyGrid.Anchor = AnchorStyles.Top;
            mOKButton.Anchor = AnchorStyles.Bottom;

            mForm.Controls.AddRange(new Control[] { mPropertyGrid, mOKButton });
            mForm.FormBorderStyle = FormBorderStyle.FixedSingle;
            mForm.StartPosition = FormStartPosition.CenterScreen;
            mForm.MinimizeBox = false;
            mForm.MaximizeBox = false;
            mForm.AcceptButton = mOKButton;

            DialogResult dialogResult = mForm.ShowDialog();
            return dialogResult;
        }
Esempio n. 7
0
    //UPGRADE_TODO: Class 'java.awt.Frame' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtFrame'"
    public QuitDialog(System.Windows.Forms.Form parent, bool modal)
        : base()
    {
        //UPGRADE_TODO: Constructor 'java.awt.Dialog.Dialog' was converted to 'SupportClass.DialogSupport.SetDialog' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtDialogDialog_javaawtFrame_boolean'"
        SupportClass.DialogSupport.SetDialog(this, parent);

        // This code is automatically generated by Visual Cafe when you add
        // components to the visual environment. It instantiates and initializes
        // the components. To modify the code, only use code syntax that matches
        // what Visual Cafe can generate, or Visual Cafe may be unable to back
        // parse your Java file into its visual environment.
        //{{INIT_CONTROLS
        //UPGRADE_ISSUE: Method 'java.awt.Container.setLayout' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtContainersetLayout_javaawtLayoutManager'"
        /*
        setLayout(null);*/
        //UPGRADE_TODO: Method 'java.awt.Component.setSize' was converted to 'System.Windows.Forms.Control.Size' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetSize_int_int'"
        Size = new System.Drawing.Size(SupportClass.GetInsets(this)[1] + SupportClass.GetInsets(this)[2] + 337, SupportClass.GetInsets(this)[0] + SupportClass.GetInsets(this)[3] + 135);
        System.Windows.Forms.Button temp_Button;
        temp_Button = new System.Windows.Forms.Button();
        temp_Button.Text = " Yes ";
        yesButton = temp_Button;
        yesButton.SetBounds(SupportClass.GetInsets(this)[1] + 72, SupportClass.GetInsets(this)[0] + 80, 79, 22);
        //UPGRADE_NOTE: If the given Font Name does not exist, a default Font instance is created. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1075'"
        yesButton.Font = new System.Drawing.Font("Dialog", 12, System.Drawing.FontStyle.Bold);
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
        Controls.Add(yesButton);
        System.Windows.Forms.Button temp_Button2;
        temp_Button2 = new System.Windows.Forms.Button();
        temp_Button2.Text = "  No  ";
        noButton = temp_Button2;
        noButton.SetBounds(SupportClass.GetInsets(this)[1] + 185, SupportClass.GetInsets(this)[0] + 80, 79, 22);
        //UPGRADE_NOTE: If the given Font Name does not exist, a default Font instance is created. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1075'"
        noButton.Font = new System.Drawing.Font("Dialog", 12, System.Drawing.FontStyle.Bold);
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
        Controls.Add(noButton);
        System.Windows.Forms.Label temp_Label;
        //UPGRADE_TODO: The equivalent in .NET for field 'java.awt.Label.CENTER' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
        temp_Label = new System.Windows.Forms.Label();
        temp_Label.Text = "Do you really want to quit?";
        temp_Label.TextAlign = (System.Drawing.ContentAlignment) System.Drawing.ContentAlignment.MiddleCenter;
        label1 = temp_Label;
        label1.SetBounds(78, 33, 180, 23);
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
        Controls.Add(label1);
        Text = "A Basic Application - Quit";
        FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
        //}}

        //{{REGISTER_LISTENERS
        SymWindow aSymWindow = new SymWindow(this);
        //UPGRADE_NOTE: Some methods of the 'java.awt.event.WindowListener' class are not used in the .NET Framework. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1308'"
        this.Closing += new System.ComponentModel.CancelEventHandler(aSymWindow.windowClosing);
        SymAction lSymAction = new SymAction(this);
        noButton.Click += new System.EventHandler(lSymAction.actionPerformed);
        SupportClass.CommandManager.CheckCommand(noButton);
        yesButton.Click += new System.EventHandler(lSymAction.actionPerformed);
        SupportClass.CommandManager.CheckCommand(yesButton);
        //}}
    }
Esempio n. 8
0
        public DialogResult CatBox(string promptText, double cost, DateTime dt, ref string value)
        {
            Form form = new Form();
            Label label = new Label();
            Label amount = new Label();
            Label date = new Label();
            ComboBox comboBox = new ComboBox();
            Button buttonOk = new Button();
            CheckBox checkBox = new CheckBox();
            form.Text = "Specify a Category:";
            label.Text = promptText;
            amount.Text = cost.ToString("C");
            date.Text = dt.ToString();
            checkBox.Text = "Remember this relationship?";
            buttonOk.Text = "OK";
            buttonOk.DialogResult = DialogResult.OK;
            label.SetBounds(9, 20, 172, 13);
            amount.SetBounds(273, 20, 100, 13);
            date.SetBounds(173, 20, 100, 13);
            comboBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(309, 72, 75, 23);
            checkBox.SetBounds(12, 72, 275, 24); // ???
            label.AutoSize = true;
            comboBox.Anchor = comboBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            checkBox.Anchor = checkBox.Anchor | AnchorStyles.Right;
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, amount, date, checkBox, comboBox, buttonOk });
            form.ClientSize = new Size(Math.Max(300, amount.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;

            SqlCeConnection cs = new SqlCeConnection(@"Data Source = Expenses.sdf");
            cs.Open();
            SqlCeDataReader r = null;
            SqlCeCommand getCats = new SqlCeCommand("SELECT * FROM Categories", cs);
            r = getCats.ExecuteReader();
            while (r.Read()) comboBox.Items.Add(r["Category"]);
            cs.Close();
            DialogResult dialogResult = form.ShowDialog();
            value = comboBox.Text;
            // remember relationship if option to do so is checked
            if (checkBox.Checked)
            {
                SqlCeConnection cs2 = new SqlCeConnection(@"Data Source = Expenses.sdf");
                cs2.Open();
                SqlCeCommand setCat = new SqlCeCommand("INSERT INTO CategorizedItems VALUES (@Description, @Category)", cs2);
                setCat.Parameters.AddWithValue("@Description", promptText);
                setCat.Parameters.AddWithValue("@Category", value);
                setCat.ExecuteNonQuery();
                cs2.Close();
            }
            return dialogResult;
        }
Esempio n. 9
0
 public void addButton(string name,string text, int x, int y, int w, int h)
 {
     Button button = new Button();
     button.Text = text;
     button.Name = name;
     button.SetBounds(x, y, w, h);
     button.Click += new EventHandler(buttonNext2_Click);
     Controls.Add(button);
 }
Esempio n. 10
0
        public static DialogResult Show(string title, string promptText, ref string value,
                                        InputBoxValidation validation)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;
            if (validation != null)
            {
                form.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (form.DialogResult == DialogResult.OK)
                    {
                        string errorText = validation(textBox.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(form, errorText, "Validation Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            textBox.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
Esempio n. 11
0
        /// <summary>
        /// Displays a dialog with a prompt and textbox where the user can enter information
        /// </summary>
        /// <param name="title">Dialog title</param>
        /// <param name="promptText">Dialog prompt</param>
        /// <param name="value">Sets the initial value and returns the result</param>
        /// <returns>Dialog result</returns>
        public static DialogResult Show(Form parent, string title, string promptText, string checkText, ref string value, ref bool isChecked)
        {
            // TODO: button placement/size has been hardcoded for how it is used in this app.

            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();
            CheckBox checkBox = new CheckBox();
            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;
            textBox.Multiline = true;
            textBox.Height = (int)(textBox.Height * 2);
            checkBox.Checked = isChecked;
            checkBox.Text = checkText;
            checkBox.Visible = (checkText != null);

            //form.TopLevel = true;
            //form.StartPosition = FormStartPosition.CenterParent;
            //form.Parent = parent;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 76, 372, 50);
            buttonOk.SetBounds(228, 130, 75, 23);
            buttonCancel.SetBounds(309, 130, 75, 23);
            checkBox.SetBounds(12, 60, 150, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            checkBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;

            form.ClientSize = new Size(396, 170);

            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, checkBox });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            isChecked = checkBox.Checked;
            return dialogResult;
        }
Esempio n. 12
0
        public static TDSRoom InputCreateRoomBox(TDSRoom currentRoom)
        {
            var form = new Form();
            var westRadioButton = new RadioButton {Text = "To the west", Enabled = false};
            var eastRadioButton = new RadioButton {Text = "To the east", Enabled = false};
            var northRadioButton = new RadioButton {Text = "To the north", Enabled = false};
            var southRadioButton = new RadioButton {Text = "To the south", Enabled = false};
            var isRequiredCheckBox = new CheckBox {Text = "Is required", Checked = true};
            var isSecretCheckBox = new CheckBox {Text = "Is secret", Checked = false};
            var doneButton = new Button {Text = "OK"};

            form.Text = "Create new room";

            form.ClientSize = new Size(396, 200);
            form.Controls.AddRange(new Control[]
                                   {
                                       westRadioButton, eastRadioButton, northRadioButton, southRadioButton,
                                       isRequiredCheckBox, isSecretCheckBox, doneButton
                                   });
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;

            westRadioButton.SetBounds(25, 25, 100, 25);
            eastRadioButton.SetBounds(25, 50, 100, 25);
            northRadioButton.SetBounds(25, 75, 100, 25);
            southRadioButton.SetBounds(25, 100, 100, 25);
            isRequiredCheckBox.SetBounds(125, 25, 100, 25);
            isSecretCheckBox.SetBounds(125, 50, 100, 25);
            doneButton.SetBounds(125, 100, 100, 25);

            if (currentRoom.Level.GetRoom(currentRoom.X - 1, currentRoom.Y) == null) westRadioButton.Enabled = true;
            if (currentRoom.Level.GetRoom(currentRoom.X + 1, currentRoom.Y) == null) eastRadioButton.Enabled = true;
            if (currentRoom.Level.GetRoom(currentRoom.X, currentRoom.Y - 1) == null) northRadioButton.Enabled = true;
            if (currentRoom.Level.GetRoom(currentRoom.X, currentRoom.Y + 1) == null) southRadioButton.Enabled = true;

            TDSRoom result = null;
            var resultX = 0;
            var resultY = 0;

            doneButton.Click += (e, sender) =>
                                {
                                    if (westRadioButton.Checked) resultX = -1;
                                    if (eastRadioButton.Checked) resultX = 1;
                                    if (northRadioButton.Checked) resultY = -1;
                                    if (southRadioButton.Checked) resultY = 1;

                                    result = TDSControl.CreateRoom(currentRoom.Level, currentRoom.X + resultX, currentRoom.Y + resultY, isRequiredCheckBox.Checked, isSecretCheckBox.Checked);
                                    form.Close();
                                };

            form.ShowDialog();

            return result;
        }
Esempio n. 13
0
        /// <summary>
        /// Muestra el 'InputTextBox'
        /// </summary>
        /// <param name="strTexto"> Texto a mostrar en el mensaje </param>
        /// <param name="strEncabezado"> Título del InputTextBox </param>
        /// <param name="strValor"> Texto ingresado </param>
        /// <param name="itbValidacion"> Delegado que valida lo ingresado en el InputTextBox </param>
        /// <returns>DialogResult</returns>
        public static DialogResult Show(string strTexto, string strEncabezado, ref string strValor, InputBoxValidation itbValidacion)
        {
            Form frmFormulario = new Form();
            Label lblEtiqueta = new Label();
            TextBox txtCajaTexto = new TextBox();
            Button btnOK = new Button();
            Button btnCancel = new Button();

            frmFormulario.Text = strEncabezado;
            lblEtiqueta.Text = strTexto;
            txtCajaTexto.Text = strValor;

            btnOK.Text = "OK";
            btnCancel.Text = "Cancel";
            btnOK.DialogResult = DialogResult.OK;
            btnCancel.DialogResult = DialogResult.Cancel;

            lblEtiqueta.SetBounds(9, 20, 372, 13);
            txtCajaTexto.SetBounds(12, 36, 372, 20);
            btnOK.SetBounds(228, 72, 75, 23);
            btnCancel.SetBounds(309, 72, 75, 23);

            lblEtiqueta.AutoSize = true;
            txtCajaTexto.Anchor = txtCajaTexto.Anchor | AnchorStyles.Right;
            btnOK.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            frmFormulario.ClientSize = new Size(396, 107);
            frmFormulario.Controls.AddRange(new Control[] { lblEtiqueta, txtCajaTexto, btnOK, btnCancel });
            frmFormulario.ClientSize = new Size(Math.Max(300, lblEtiqueta.Right + 10), frmFormulario.ClientSize.Height);
            frmFormulario.FormBorderStyle = FormBorderStyle.FixedDialog;
            frmFormulario.StartPosition = FormStartPosition.CenterScreen;
            frmFormulario.MinimizeBox = false;
            frmFormulario.MaximizeBox = false;
            frmFormulario.AcceptButton = btnOK;
            frmFormulario.CancelButton = btnCancel;
            if (itbValidacion != null)
            {
                frmFormulario.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (frmFormulario.DialogResult == DialogResult.OK)
                    {
                        string errorText = itbValidacion(txtCajaTexto.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(frmFormulario, errorText, "Mensaje",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtCajaTexto.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = frmFormulario.ShowDialog();
            strValor = txtCajaTexto.Text;
            return dialogResult;
        }
Esempio n. 14
0
        private void Clear_Click(object sender, EventArgs e)
        {
            Form form = new Form(); form.Text = "Clear Databases";
            CheckBox clearCategories = new CheckBox();
            clearCategories.Text = "Clear All Categories, Expenses, and Relations";
            clearCategories.Checked = false;
            clearCategories.SetBounds(9, 6, 272, 24);

            CheckBox clearLineItems = new CheckBox();
            clearLineItems.Text = "Clear Line Item Expenses Only";
            clearLineItems.Checked = false;
            clearLineItems.SetBounds(9, 30, 272, 24);

            CheckBox clearRelations = new CheckBox();
            clearRelations.Text = "Clear Saved Relations Only";
            clearRelations.Checked = false;
            clearRelations.SetBounds(9, 54, 272, 24);

            Button OK = new Button(); OK.Text = "OK";
            OK.SetBounds(9, 78, 75, 23);
            OK.DialogResult = DialogResult.OK;
            Button Cancel = new Button(); Cancel.Text = "Cancel";
            Cancel.SetBounds(100, 78, 75, 23);
            Cancel.DialogResult = DialogResult.Cancel;

            form.ClientSize = new Size(296, 107);
            form.Controls.AddRange(new Control[] { clearCategories, clearLineItems, clearRelations, OK, Cancel });
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = OK;
            form.CancelButton = Cancel;

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (clearCategories.Checked)
                {
                    File.Delete("Expenses.sdf");
                    Setup.Enabled = true; Edit.Enabled = false; Clear.Enabled = false;
                    View.Enabled = false; Import.Enabled = false; Manual.Enabled = false;
                }
                else if (clearLineItems.Checked)
                {
                    if (clearRelations.Checked) Form1_Helper.ClearRelations();
                    Form1_Helper.ClearLineItems();
                }
                else if (clearRelations.Checked) Form1_Helper.ClearRelations();
                else MessageBox.Show("No action taken.");
            }
            else MessageBox.Show("No action taken.");
        }
Esempio n. 15
0
        public static void FormWindow()
        {
            Form npcForm = new Form();
            npcForm.ShowInTaskbar = false;
            npcForm.Text = "NPCs";  //The text in the Title
            npcForm.SetBounds(12, 12, 256, 256);

            Button b1 = new Button();
            b1.Text = "Lakitu";
            npcForm.Controls.Add(b1);
            b1.SetBounds(2, 2, 16, 16);
            npcForm.Show();
        }
Esempio n. 16
0
 public PeopleForm(string title=null, IPeopleFormDelegate peopleFormDelegate = null, bool openForUpdate = false,string surname="", string firstname="", string password="", string comment="")
 {
     if (null != title) this.Text = title;
     _openForUpdate = openForUpdate;
     _peopleFormDelegate = peopleFormDelegate;
     this.SetBounds(10, 10, 200, 220);
     Label lbl1, lbl2,lbl3, lbl4;
     TextBox txt1, txt2,txt3,txt4;
     Button btn = new Button();
     this.Controls.Add(lbl1 = new Label());
     lbl1.SetBounds(5, 5, 185, 18);
     lbl1.Text = "firstname";
     this.Controls.Add(txt1 = new TextBox());
     txt1.SetBounds(5, 25, 185, 18);
     txt1.Text = firstname;
     this.Controls.Add(lbl2 = new Label());
     lbl2.Text = "surname";
     lbl2.SetBounds(5, 45, 185, 18);
     this.Controls.Add(txt2 = new TextBox());
     txt2.SetBounds(5, 65, 165, 18);
     txt2.Text = surname;
     this.Controls.Add(lbl3 = new Label());
     lbl3.SetBounds(5, 85, 185, 18);
     lbl3.Text = "password";
     this.Controls.Add(txt3 = new TextBox());
     txt3.SetBounds(5, 105, 185, 18);
     txt3.Text = password;
     this.Controls.Add(lbl4 = new Label());
     lbl4.SetBounds(5, 125, 185, 18);
     lbl4.Text = "comment";
     this.Controls.Add(txt4 = new TextBox());
     txt4.SetBounds(5, 145, 185, 18);
     txt4.Text = comment;
     this.Controls.Add(btn);
     btn.SetBounds(5, 165, 185, 18);
     ErrorProvider ep = new ErrorProvider();
     ep.SetIconAlignment(txt2, ErrorIconAlignment.MiddleRight);
     ep.SetIconPadding(txt2, 2);
     btn.Text = openForUpdate ? "Save people" : "Add people";
     btn.Click += (object sender1, EventArgs e1) =>
     {
         if (string.IsNullOrWhiteSpace(txt2.Text))
         {
             ep.SetError(txt2, "Surname must contain chars");
             return;
         }
         ep.SetError(txt2, string.Empty);
         if (null != this._peopleFormDelegate) _peopleFormDelegate.saved(txt2.Text, txt1.Text, txt3.Text, txt4.Text);
         if(openForUpdate) this.Close();
     };
 }
Esempio n. 17
0
        /// <summary>
        /// Create the buttons for formatting in FrmNewNote.
        /// </summary>
        /// <returns>A array with buttons</returns>
        public override Button[] InitNoteFormatBtns()
        {
            Button[] btns = new Button[1];

            Button btnOpenChooser = new Button();
            btnOpenChooser.Name = "smileychooser";
            btnOpenChooser.Image = global::InsertSmiley.Properties.Resources.smiley_smile;
            btnOpenChooser.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
            btnOpenChooser.SetBounds(0, 0, 26, 22);
            btnOpenChooser.FlatStyle = FlatStyle.Flat;
            btnOpenChooser.UseCompatibleTextRendering = true;
            btns[0] = btnOpenChooser;
            return btns;
        }
Esempio n. 18
0
        public Form_NPCs()
        {
            Form npcForm = new Form();
            npcForm.ShowInTaskbar = false;
            npcForm.Text = "NPCs";  //The text in the Title
            npcForm.SetBounds(12, 12, 256, 256);

            Button b1 = new Button();
            npcForm.Controls.Add(b1);
            b1.Text = "b1";
            b1.SetBounds(2, 2, 16, 16);
            b1.Click += new System.EventHandler(b_click);
            npcForm.Show();
        }
Esempio n. 19
0
        public static DialogResult InputBox(string title, string promptText, out string value)
        {
            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
                value = null;
                return DialogResult.Abort;
            }

            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();

            textBox.Width = 1000;
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
Esempio n. 20
0
 private void ajustaBotoes()
 {
     try
     {
         if (m_btAnularSelecao.Visible == false)
         {
             m_btNovo.SetBounds(m_btNovo.Location.X + 16, m_btNovo.Location.Y, m_btNovo.Width, m_btNovo.Height);
             m_btEditar.SetBounds(m_btEditar.Location.X + 16, m_btEditar.Location.Y, m_btEditar.Width, m_btEditar.Height);
             m_btExcluir.SetBounds(m_btExcluir.Location.X + 16, m_btExcluir.Location.Y, m_btExcluir.Width, m_btExcluir.Height);
         }
     }
     catch (Exception err)
     {
         Object erro = err;
         m_cls_ter_tratadorErro.trataErro(ref erro);
     }
 }
Esempio n. 21
0
        //, Point p)
        public static string InputBox(string title, string promptText, string value)
        {
            var form = new Form();
            var label = new Label();
            var textBox = new TextBox();
            var buttonOk = new Button();
            var buttonCancel = new Button();

            form.Text = promptText;
            label.Text = title;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            textBox.Text = value;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] {label, textBox, buttonOk, buttonCancel});
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            //form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;
            form.StartPosition = FormStartPosition.CenterParent;

            //form.Location = new Point(p.X,p.Y);

            var dialogResult = form.ShowDialog();

            return textBox.Text;
        }
Esempio n. 22
0
    //UPGRADE_TODO: Class 'java.awt.Frame' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtFrame'"
    public AboutDialog(System.Windows.Forms.Form parent, bool modal)
        : base()
    {
        //UPGRADE_TODO: Constructor 'java.awt.Dialog.Dialog' was converted to 'SupportClass.DialogSupport.SetDialog' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtDialogDialog_javaawtFrame_boolean'"
        SupportClass.DialogSupport.SetDialog(this, parent);

        // This code is automatically generated by Visual Cafe when you add
        // components to the visual environment. It instantiates and initializes
        // the components. To modify the code, only use code syntax that matches
        // what Visual Cafe can generate, or Visual Cafe may be unable to back
        // parse your Java file into its visual environment.

        //{{INIT_CONTROLS
        //UPGRADE_ISSUE: Method 'java.awt.Container.setLayout' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtContainersetLayout_javaawtLayoutManager'"
        /*
        setLayout(null);*/
        //UPGRADE_TODO: Method 'java.awt.Component.setSize' was converted to 'System.Windows.Forms.Control.Size' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetSize_int_int'"
        Size = new System.Drawing.Size(249, 150);
        System.Windows.Forms.Label temp_Label;
        temp_Label = new System.Windows.Forms.Label();
        temp_Label.Text = "A Basic Java  Application";
        label1 = temp_Label;
        label1.SetBounds(40, 35, 166, 21);
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
        Controls.Add(label1);
        System.Windows.Forms.Button temp_Button;
        temp_Button = new System.Windows.Forms.Button();
        temp_Button.Text = "OK";
        okButton = temp_Button;
        okButton.SetBounds(95, 85, 66, 27);
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
        Controls.Add(okButton);
        Text = "About";
        FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
        //}}

        //{{REGISTER_LISTENERS
        SymWindow aSymWindow = new SymWindow(this);
        //UPGRADE_NOTE: Some methods of the 'java.awt.event.WindowListener' class are not used in the .NET Framework. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1308'"
        this.Closing += new System.ComponentModel.CancelEventHandler(aSymWindow.windowClosing);
        SymAction lSymAction = new SymAction(this);
        okButton.Click += new System.EventHandler(lSymAction.actionPerformed);
        SupportClass.CommandManager.CheckCommand(okButton);
        //}}
    }
Esempio n. 23
0
        public GroupBoxRetractable()
        {
            InitializeComponent();

            btnFleche = new Button();
            btnFleche.Visible = true;
            btnFleche.Image = Properties.Resources.FlecheHautGris;
            btnFleche.SetBounds(this.Width - 23 - 5, 10, 23, 23);
            btnFleche.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            btnFleche.Click += new EventHandler(btnFleche_Click);
            Controls.Add(btnFleche);
            hauteurReduite = 37;
            hauteurTotale = 0;
            deploye = true;

            this.SizeChanged += new EventHandler(GroupBoxRetractable_SizeChanged);
            this.DoubleBuffered = true;
        }
Esempio n. 24
0
        public static DialogResult InputBox(string title, string promptText, ref string value, bool isPassword = false)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText ?? title;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 90, 372, 20);
            buttonOk.SetBounds(228, 122, 75, 23);
            buttonCancel.SetBounds(309, 122, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            if (isPassword)
                textBox.UseSystemPasswordChar = true;

            form.ClientSize = new Size(396, 157);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
Esempio n. 25
0
        public static DialogResult Show(string text, string caption, ref string value)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = caption;
            label.Text = text;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            textBox.MaxLength = 128;

            var dialogResult = form.ShowDialog();
            if (dialogResult == DialogResult.OK)
                value = textBox.Text;
            return dialogResult;
        }
Esempio n. 26
0
      public static DialogResult InputBox(string title, string promptText, ref string value)
      {
          Form form = new Form();

          System.Windows.Forms.Label   label        = new System.Windows.Forms.Label();
          System.Windows.Forms.TextBox textBox      = new System.Windows.Forms.TextBox();
          System.Windows.Forms.Button  buttonOk     = new System.Windows.Forms.Button();
          System.Windows.Forms.Button  buttonCancel = new System.Windows.Forms.Button();

          form.Text    = title;
          label.Text   = promptText;
          textBox.Text = value;

          buttonOk.Text             = "OK";
          buttonCancel.Text         = "Cancel";
          buttonOk.DialogResult     = DialogResult.OK;
          buttonCancel.DialogResult = DialogResult.Cancel;

          label.SetBounds(9, 20, 372, 13);
          textBox.SetBounds(12, 36, 372, 20);
          buttonOk.SetBounds(228, 72, 75, 23);
          buttonCancel.SetBounds(309, 72, 75, 23);

          label.AutoSize      = true;
          textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
          buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
          buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

          form.ClientSize = new Size(396, 107);
          form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
          form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
          form.FormBorderStyle = FormBorderStyle.FixedDialog;
          form.StartPosition   = FormStartPosition.CenterScreen;
          form.MinimizeBox     = false;
          form.MaximizeBox     = false;
          form.AcceptButton    = buttonOk;
          form.CancelButton    = buttonCancel;

          DialogResult dialogResult = form.ShowDialog();

          value = textBox.Text;
          return(dialogResult);
      }
Esempio n. 27
0
        public DialogResult InputBox(string title, string promptText, ref string value)
        {
            Form form = new Form();
            form.Font = CS410Project.Properties.Settings.Default.SysFont;
            form.BackColor = CS410Project.Properties.Settings.Default.BackgroundColor;
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            buttonOk.BackColor = CS410Project.Properties.Settings.Default.ButtonColor;
            Button buttonCancel = new Button();
            buttonCancel.BackColor = CS410Project.Properties.Settings.Default.ButtonColor;
            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;
            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
Esempio n. 28
0
        public static DialogResult Show(IWin32Window owner, string title, string promptText, ref string value)
        {
            using (Form form = new Form())
            {
                Label label = new Label();
                TextBox textBox = new TextBox();
                Button buttonOk = new Button();
                Button buttonCancel = new Button();

                form.Text = title;
                label.Text = promptText;
                textBox.Text = value;

                buttonOk.Text = "OK";
                buttonCancel.Text = "Cancel";
                buttonOk.DialogResult = DialogResult.OK;
                buttonCancel.DialogResult = DialogResult.Cancel;

                label.SetBounds(9, 20, 372, 13);
                textBox.SetBounds(12, 36, 372, 20);
                buttonOk.SetBounds(228, 72, 75, 23);
                buttonCancel.SetBounds(309, 72, 75, 23);

                label.AutoSize = true;
                textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
                buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
                buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

                form.ClientSize = new Size(396, 107);
                form.Controls.AddRange(new Control[] {label, textBox, buttonOk, buttonCancel});
                form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
                form.FormBorderStyle = FormBorderStyle.FixedDialog;
                form.StartPosition = FormStartPosition.CenterScreen;
                form.MinimizeBox = false;
                form.MaximizeBox = false;
                form.AcceptButton = buttonOk;
                form.CancelButton = buttonCancel;

                DialogResult dialogResult = owner != null ? form.ShowDialog(owner) : form.ShowDialog();
                value = textBox.Text;
                return dialogResult;
            }
        }
        internal static String CuadroDialogo(string sTitulo, string sEtiqueta, string sValor)
        {
            Form frmCuadroDialogo = new Form();
            Label lblTitulo = new Label();
            TextBox txtInput = new TextBox();
            Button btnOk = new Button();
            Button btnCancel = new Button();

            frmCuadroDialogo.Text = sTitulo;
            lblTitulo.Text = sEtiqueta;
            txtInput.Text = sValor;
            txtInput.PasswordChar = '*';

            btnOk.Text = "OK";
            btnCancel.Text = "Cancel";
            btnOk.DialogResult = DialogResult.OK;
            btnCancel.DialogResult = DialogResult.Cancel;

            lblTitulo.SetBounds(9, 20, 372, 13);
            txtInput.SetBounds(12, 36, 372, 20);
            btnOk.SetBounds(228, 72, 75, 23);
            btnCancel.SetBounds(309, 72, 75, 23);

            lblTitulo.AutoSize = true;
            txtInput.Anchor = txtInput.Anchor | AnchorStyles.Right;
            btnOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            frmCuadroDialogo.ClientSize = new Size(396, 107);
            frmCuadroDialogo.Controls.AddRange(new Control[] { lblTitulo, txtInput, btnOk, btnCancel });
            frmCuadroDialogo.ClientSize = new Size(Math.Max(300, lblTitulo.Right + 10), frmCuadroDialogo.ClientSize.Height);
            frmCuadroDialogo.FormBorderStyle = FormBorderStyle.FixedDialog;
            frmCuadroDialogo.StartPosition = FormStartPosition.CenterScreen;
            frmCuadroDialogo.MinimizeBox = false;
            frmCuadroDialogo.MaximizeBox = false;
            frmCuadroDialogo.AcceptButton = btnOk;
            frmCuadroDialogo.CancelButton = btnCancel;

            DialogResult dialogResult = frmCuadroDialogo.ShowDialog();
            sValor = txtInput.Text;
            return sValor;
        }
Esempio n. 30
0
        public static DialogResult InputBox(string title, string promptText/*, ref string value*/)
        {
            Form form = new Form();
            Label label = new Label();
            //TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText;
            //textBox.Text = value;

            buttonOk.Text = "Mêmes joueurs";
            buttonCancel.Text = "Nouveaux Joueurs";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            /*textBox.SetBounds(12, 36, 372, 20);*/
            buttonOk.SetBounds(170, 72, 115, 23);
            buttonCancel.SetBounds(250, 72, 115, 23);

            label.AutoSize = true;
            //textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, /*textBox,*/ buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            //value = textBox.Text;
            return dialogResult;
        }
Esempio n. 31
0
        /// <summary>
        /// Shows a dialog box with an input field.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="prompt"></param>
        /// <param name="options"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DialogResult Show(string title, string prompt, List<string> options, ref string value)
        {
            Form mForm = new Form();
            Label mLabel = new Label();
            ComboBox mComboBox = new ComboBox();
            Button mOKButton = new Button();

            mForm.Text = title;
            mLabel.Text = prompt;
            mComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            for (int i = 0; i < options.Count; i++)
            {
                mComboBox.Items.Add(options[i]);
            }
            mComboBox.SelectedIndex = 0;

            mOKButton.Text = "OK";
            mOKButton.DialogResult = DialogResult.OK;

            mForm.ClientSize = new Size(240, 80);
            mLabel.SetBounds(4, 4, mForm.ClientSize.Width - 8, 22);
            mComboBox.SetBounds(32, 26, mForm.ClientSize.Width - 64, 24);
            mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, 54, 64, 22);

            mLabel.AutoSize = true;
            mComboBox.Anchor = AnchorStyles.Bottom;
            mOKButton.Anchor = AnchorStyles.Bottom;

            mForm.Controls.AddRange(new Control[] { mLabel, mComboBox, mOKButton });
            mForm.FormBorderStyle = FormBorderStyle.FixedDialog;
            mForm.StartPosition = FormStartPosition.CenterScreen;
            mForm.MinimizeBox = false;
            mForm.MaximizeBox = false;
            mForm.AcceptButton = mOKButton;

            DialogResult dialogResult = mForm.ShowDialog();
            value = mComboBox.Text;
            return dialogResult;
        }
Esempio n. 32
0
        public static DialogResult InputBox(string title, string promptText, ref string value)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();

            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonOk.DialogResult = DialogResult.OK;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            if (value.Count() < 1)
            {
                value = "0";
            }
            return dialogResult;
        }
Esempio n. 33
0
        public static DialogResult YesNoBox(string title, string promptText)
        {
            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
                return DialogResult.Abort;
            }

            Form form = new Form();
            Label label = new Label();

            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText;

            buttonOk.Text = "Yes";
            buttonCancel.Text = "No";
            buttonOk.DialogResult = DialogResult.Yes;
            buttonCancel.DialogResult = DialogResult.No;

            label.SetBounds(9, 20, 372, 13);
            buttonOk.SetBounds(228, 50, 75, 23);
            buttonCancel.SetBounds(309, 50, 75, 23);

            label.AutoSize = true;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 80);
            form.Controls.AddRange(new Control[] { label, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            return dialogResult;
        }
Esempio n. 34
0
        public ThreadExceptionDialog(Exception t)
        {
            string str;
            string message;

            Button[] buttonArray;
            this.pictureBox     = new PictureBox();
            this.message        = new Label();
            this.continueButton = new Button();
            this.quitButton     = new Button();
            this.detailsButton  = new Button();
            this.helpButton     = new Button();
            this.details        = new TextBox();
            bool             flag      = false;
            WarningException exception = t as WarningException;

            if (exception != null)
            {
                str     = "ExDlgWarningText";
                message = exception.Message;
                if (exception.HelpUrl == null)
                {
                    buttonArray = new Button[] { this.continueButton };
                }
                else
                {
                    buttonArray = new Button[] { this.continueButton, this.helpButton };
                }
            }
            else
            {
                message = t.Message;
                flag    = true;
                if (Application.AllowQuit)
                {
                    if (t is SecurityException)
                    {
                        str = "ExDlgSecurityErrorText";
                    }
                    else
                    {
                        str = "ExDlgErrorText";
                    }
                    buttonArray = new Button[] { this.detailsButton, this.continueButton, this.quitButton };
                }
                else
                {
                    if (t is SecurityException)
                    {
                        str = "ExDlgSecurityContinueErrorText";
                    }
                    else
                    {
                        str = "ExDlgContinueErrorText";
                    }
                    buttonArray = new Button[] { this.detailsButton, this.continueButton };
                }
            }
            if (message.Length == 0)
            {
                message = t.GetType().Name;
            }
            if (t is SecurityException)
            {
                message = System.Windows.Forms.SR.GetString(str, new object[] { t.GetType().Name, Trim(message) });
            }
            else
            {
                message = System.Windows.Forms.SR.GetString(str, new object[] { Trim(message) });
            }
            StringBuilder builder = new StringBuilder();
            string        str3    = "\r\n";
            string        str4    = System.Windows.Forms.SR.GetString("ExDlgMsgSeperator");
            string        format  = System.Windows.Forms.SR.GetString("ExDlgMsgSectionSeperator");

            if (Application.CustomThreadExceptionHandlerAttached)
            {
                builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgHeaderNonSwitchable"));
            }
            else
            {
                builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgHeaderSwitchable"));
            }
            builder.Append(string.Format(CultureInfo.CurrentCulture, format, new object[] { System.Windows.Forms.SR.GetString("ExDlgMsgExceptionSection") }));
            builder.Append(t.ToString());
            builder.Append(str3);
            builder.Append(str3);
            builder.Append(string.Format(CultureInfo.CurrentCulture, format, new object[] { System.Windows.Forms.SR.GetString("ExDlgMsgLoadedAssembliesSection") }));
            new FileIOPermission(PermissionState.Unrestricted).Assert();
            try
            {
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    AssemblyName name        = assembly.GetName();
                    string       fileVersion = System.Windows.Forms.SR.GetString("NotAvailable");
                    try
                    {
                        if ((name.EscapedCodeBase != null) && (name.EscapedCodeBase.Length > 0))
                        {
                            Uri uri = new Uri(name.EscapedCodeBase);
                            if (uri.Scheme == "file")
                            {
                                fileVersion = FileVersionInfo.GetVersionInfo(System.Windows.Forms.NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion;
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                    }
                    builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgLoadedAssembliesEntry", new object[] { name.Name, name.Version, fileVersion, name.EscapedCodeBase }));
                    builder.Append(str4);
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }
            builder.Append(string.Format(CultureInfo.CurrentCulture, format, new object[] { System.Windows.Forms.SR.GetString("ExDlgMsgJITDebuggingSection") }));
            if (Application.CustomThreadExceptionHandlerAttached)
            {
                builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgFooterNonSwitchable"));
            }
            else
            {
                builder.Append(System.Windows.Forms.SR.GetString("ExDlgMsgFooterSwitchable"));
            }
            builder.Append(str3);
            builder.Append(str3);
            string   str7     = builder.ToString();
            Graphics graphics = this.message.CreateGraphicsInternal();
            Size     size     = Size.Ceiling(graphics.MeasureString(message, this.Font, 0x164));

            size.Height += 4;
            graphics.Dispose();
            if (size.Width < 180)
            {
                size.Width = 180;
            }
            if (size.Height > 0x145)
            {
                size.Height = 0x145;
            }
            int width = size.Width + 0x54;
            int y     = Math.Max(size.Height, 40) + 0x1a;

            System.Windows.Forms.IntSecurity.GetParent.Assert();
            try
            {
                Form activeForm = Form.ActiveForm;
                if ((activeForm == null) || (activeForm.Text.Length == 0))
                {
                    this.Text = System.Windows.Forms.SR.GetString("ExDlgCaption");
                }
                else
                {
                    this.Text = System.Windows.Forms.SR.GetString("ExDlgCaption2", new object[] { activeForm.Text });
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }
            base.AcceptButton        = this.continueButton;
            base.CancelButton        = this.continueButton;
            base.FormBorderStyle     = FormBorderStyle.FixedDialog;
            base.MaximizeBox         = false;
            base.MinimizeBox         = false;
            base.StartPosition       = FormStartPosition.CenterScreen;
            base.Icon                = null;
            base.ClientSize          = new Size(width, y + 0x1f);
            base.TopMost             = true;
            this.pictureBox.Location = new Point(0, 0);
            this.pictureBox.Size     = new Size(0x40, 0x40);
            this.pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
            if (t is SecurityException)
            {
                this.pictureBox.Image = SystemIcons.Information.ToBitmap();
            }
            else
            {
                this.pictureBox.Image = SystemIcons.Error.ToBitmap();
            }
            base.Controls.Add(this.pictureBox);
            this.message.SetBounds(0x40, 8 + ((40 - Math.Min(size.Height, 40)) / 2), size.Width, size.Height);
            this.message.Text = message;
            base.Controls.Add(this.message);
            this.continueButton.Text         = System.Windows.Forms.SR.GetString("ExDlgContinue");
            this.continueButton.FlatStyle    = FlatStyle.Standard;
            this.continueButton.DialogResult = DialogResult.Cancel;
            this.quitButton.Text             = System.Windows.Forms.SR.GetString("ExDlgQuit");
            this.quitButton.FlatStyle        = FlatStyle.Standard;
            this.quitButton.DialogResult     = DialogResult.Abort;
            this.helpButton.Text             = System.Windows.Forms.SR.GetString("ExDlgHelp");
            this.helpButton.FlatStyle        = FlatStyle.Standard;
            this.helpButton.DialogResult     = DialogResult.Yes;
            this.detailsButton.Text          = System.Windows.Forms.SR.GetString("ExDlgShowDetails");
            this.detailsButton.FlatStyle     = FlatStyle.Standard;
            this.detailsButton.Click        += new EventHandler(this.DetailsClick);
            Button detailsButton = null;
            int    num3          = 0;

            if (flag)
            {
                detailsButton    = this.detailsButton;
                this.expandImage = new Bitmap(base.GetType(), "down.bmp");
                this.expandImage.MakeTransparent();
                this.collapseImage = new Bitmap(base.GetType(), "up.bmp");
                this.collapseImage.MakeTransparent();
                detailsButton.SetBounds(8, y, 100, 0x17);
                detailsButton.Image      = this.expandImage;
                detailsButton.ImageAlign = ContentAlignment.MiddleLeft;
                base.Controls.Add(detailsButton);
                num3 = 1;
            }
            int x = (width - 8) - (((buttonArray.Length - num3) * 0x69) - 5);

            for (int i = num3; i < buttonArray.Length; i++)
            {
                detailsButton = buttonArray[i];
                detailsButton.SetBounds(x, y, 100, 0x17);
                base.Controls.Add(detailsButton);
                x += 0x69;
            }
            this.details.Text          = str7;
            this.details.ScrollBars    = ScrollBars.Both;
            this.details.Multiline     = true;
            this.details.ReadOnly      = true;
            this.details.WordWrap      = false;
            this.details.TabStop       = false;
            this.details.AcceptsReturn = false;
            this.details.SetBounds(8, y + 0x1f, width - 0x10, 0x9a);
            base.Controls.Add(this.details);
        }
Esempio n. 35
0
        private void InitializeComponent()
        {
            _btnOK     = new Button();
            _btnCancel = new Button();
            _btnHelp   = new Button();
            _btnUp     = new Button();
            _btnDown   = new Button();
            _btnAdd    = new Button();
            _btnRemove = new Button();

            _txtType           = new TextBox();
            _tvDefinedStyles   = new TreeView();
            _lvAvailableStyles = new ListView();
            _samplePreview     = new MSHTMLHost();
            _propertyBrowser   = new PropertyGrid();
            _cntxtMenuItem     = new MenuItem();
            _cntxtMenu         = new ContextMenu();

            GroupLabel grplblStyleList = new GroupLabel();

            grplblStyleList.SetBounds(6, 5, 432, 16);
            grplblStyleList.Text     = SR.GetString(SR.StylesEditorDialog_StyleListGroupLabel);
            grplblStyleList.TabStop  = false;
            grplblStyleList.TabIndex = 0;

            Label lblAvailableStyles = new Label();

            lblAvailableStyles.SetBounds(14, 25, 180, 16);
            lblAvailableStyles.Text     = SR.GetString(SR.StylesEditorDialog_AvailableStylesCaption);
            lblAvailableStyles.TabStop  = false;
            lblAvailableStyles.TabIndex = 1;

            ColumnHeader chStyleType      = new System.Windows.Forms.ColumnHeader();
            ColumnHeader chStyleNamespace = new System.Windows.Forms.ColumnHeader();

            chStyleType.Width          = 16;
            chStyleType.TextAlign      = System.Windows.Forms.HorizontalAlignment.Left;
            chStyleNamespace.Width     = 16;
            chStyleNamespace.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;

            _lvAvailableStyles.SetBounds(14, 41, 180, 95);
            _lvAvailableStyles.HeaderStyle   = System.Windows.Forms.ColumnHeaderStyle.None;
            _lvAvailableStyles.MultiSelect   = false;
            _lvAvailableStyles.HideSelection = false;
            _lvAvailableStyles.FullRowSelect = true;
            _lvAvailableStyles.View          = System.Windows.Forms.View.Details;
            _lvAvailableStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2] {
                chStyleType, chStyleNamespace
            });
            _lvAvailableStyles.SelectedIndexChanged += new EventHandler(this.OnNewStyleTypeChanged);
            _lvAvailableStyles.DoubleClick          += new EventHandler(this.OnDoubleClick);
            _lvAvailableStyles.Sorting  = SortOrder.Ascending;
            _lvAvailableStyles.TabIndex = 2;
            _lvAvailableStyles.TabStop  = true;

            _btnAdd.SetBounds(198, 77, 32, 25);
            _btnAdd.Text     = SR.GetString(SR.StylesEditorDialog_AddBtnCation);
            _btnAdd.Click   += new EventHandler(this.OnClickAddButton);
            _btnAdd.TabIndex = 3;
            _btnAdd.TabStop  = true;

            Label lblDefinedStyles = new Label();

            lblDefinedStyles.SetBounds(234, 25, 166, 16);
            lblDefinedStyles.Text     = SR.GetString(SR.StylesEditorDialog_DefinedStylesCaption);
            lblDefinedStyles.TabStop  = false;
            lblDefinedStyles.TabIndex = 4;;

            _tvDefinedStyles.SetBounds(234, 41, 166, 95);
            _tvDefinedStyles.AfterSelect    += new TreeViewEventHandler(OnStylesSelected);
            _tvDefinedStyles.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit);
            _tvDefinedStyles.LabelEdit       = true;
            _tvDefinedStyles.ShowPlusMinus   = false;
            _tvDefinedStyles.HideSelection   = false;
            _tvDefinedStyles.Indent          = 15;
            _tvDefinedStyles.ShowRootLines   = false;
            _tvDefinedStyles.ShowLines       = false;
            _tvDefinedStyles.ContextMenu     = _cntxtMenu;
            _tvDefinedStyles.TabIndex        = 5;
            _tvDefinedStyles.TabStop         = true;
            _tvDefinedStyles.KeyDown        += new KeyEventHandler(OnKeyDown);
            _tvDefinedStyles.MouseUp        += new MouseEventHandler(OnListMouseUp);
            _tvDefinedStyles.MouseDown      += new MouseEventHandler(OnListMouseDown);

            _btnUp.SetBounds(404, 41, 28, 27);
            _btnUp.Click   += new EventHandler(this.OnClickUpButton);
            _btnUp.Image    = GenericUI.SortUpIcon;
            _btnUp.TabIndex = 6;
            _btnUp.TabStop  = true;

            _btnDown.SetBounds(404, 72, 28, 27);
            _btnDown.Click   += new EventHandler(this.OnClickDownButton);
            _btnDown.Image    = GenericUI.SortDownIcon;
            _btnDown.TabIndex = 7;
            _btnDown.TabStop  = true;

            _btnRemove.SetBounds(404, 109, 28, 27);
            _btnRemove.Click   += new EventHandler(this.OnClickRemoveButton);
            _btnRemove.Image    = GenericUI.DeleteIcon;
            _btnRemove.TabIndex = 8;
            _btnRemove.TabStop  = true;

            GroupLabel grplblStyleProperties = new GroupLabel();

            grplblStyleProperties.SetBounds(6, 145, 432, 16);
            grplblStyleProperties.Text     = SR.GetString(SR.StylesEditorDialog_StylePropertiesGroupLabel);
            grplblStyleProperties.TabStop  = false;
            grplblStyleProperties.TabIndex = 9;

            Label lblType = new Label();

            lblType.SetBounds(14, 165, 180, 16);
            lblType.Text     = SR.GetString(SR.StylesEditorDialog_TypeCaption);
            lblType.TabIndex = 10;
            lblType.TabStop  = false;

            _txtType.SetBounds(14, 181, 180, 16);
            _txtType.ReadOnly = true;
            _txtType.TabIndex = 11;
            _txtType.TabStop  = true;

            Label lblSample = new Label();

            lblSample.SetBounds(14, 213, 180, 16);
            lblSample.Text     = SR.GetString(SR.StylesEditorDialog_SampleCaption);
            lblSample.TabStop  = false;
            lblSample.TabIndex = 12;

            _samplePreview.SetBounds(14, 229, 180, 76);
            _samplePreview.TabStop  = false;
            _samplePreview.TabIndex = 13;

            Label lblProperties = new Label();

            lblProperties.SetBounds(234, 165, 198, 16);
            lblProperties.Text     = SR.GetString(SR.StylesEditorDialog_PropertiesCaption);
            lblProperties.TabIndex = 14;
            lblProperties.TabStop  = false;

            _propertyBrowser.SetBounds(234, 181, 198, 178);
            _propertyBrowser.Anchor                = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
            _propertyBrowser.ToolbarVisible        = false;
            _propertyBrowser.HelpVisible           = false;
            _propertyBrowser.TabIndex              = 15;
            _propertyBrowser.TabStop               = true;
            _propertyBrowser.PropertySort          = PropertySort.Alphabetical;
            _propertyBrowser.PropertyValueChanged += new PropertyValueChangedEventHandler(this.OnPropertyValueChanged);

            _btnOK.DialogResult = DialogResult.OK;
            _btnOK.Location     = new System.Drawing.Point(201, 370);
            _btnOK.Size         = new System.Drawing.Size(75, 23);
            _btnOK.TabIndex     = 16;
            _btnOK.Text         = SR.GetString(SR.GenericDialog_OKBtnCaption);
            _btnOK.Click       += new EventHandler(this.OnClickOKButton);

            _btnCancel.DialogResult = DialogResult.Cancel;
            _btnCancel.Location     = new System.Drawing.Point(282, 370);
            _btnCancel.Size         = new System.Drawing.Size(75, 23);
            _btnCancel.TabIndex     = 17;
            _btnCancel.Text         = SR.GetString(SR.GenericDialog_CancelBtnCaption);

            _btnHelp.Click   += new EventHandler(this.OnClickHelpButton);
            _btnHelp.Location = new System.Drawing.Point(363, 370);
            _btnHelp.Size     = new System.Drawing.Size(75, 23);
            _btnHelp.TabIndex = 18;
            _btnHelp.Text     = SR.GetString(SR.GenericDialog_HelpBtnCaption);

            _cntxtMenuItem.Text = SR.GetString(SR.EditableTreeList_Rename);
            _cntxtMenu.MenuItems.Add(_cntxtMenuItem);
            _cntxtMenu.Popup     += new EventHandler(OnPopup);
            _cntxtMenuItem.Click += new EventHandler(OnContextMenuItemClick);

            GenericUI.InitDialog(this, _styleSheet.Site);

            this.Text           = _styleSheet.ID + " - " + SR.GetString(SR.StylesEditorDialog_Title);
            this.ClientSize     = new Size(444, 401);
            this.AcceptButton   = _btnOK;
            this.CancelButton   = _btnCancel;
            this.Activated     += new System.EventHandler(StylesEditorDialog_Activated);
            this.HelpRequested += new HelpEventHandler(this.OnHelpRequested);
            this.Controls.AddRange(new Control[]
            {
                grplblStyleList,
                lblAvailableStyles,
                _lvAvailableStyles,
                _btnAdd,
                lblDefinedStyles,
                _tvDefinedStyles,
                _btnUp,
                _btnDown,
                _btnRemove,
                grplblStyleProperties,
                lblType,
                _txtType,
                lblSample,
                _samplePreview,
                lblProperties,
                _propertyBrowser,
                _btnOK,
                _btnCancel,
                _btnHelp
            });
        }
Esempio n. 36
0
        /// <summary>
        ///    Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class.
        /// </summary>
        public ThreadExceptionDialog(Exception t)
        {
            if (DpiHelper.IsScalingRequirementMet)
            {
                scaledMaxWidth                        = LogicalToDeviceUnits(MAXWIDTH);
                scaledMaxHeight                       = LogicalToDeviceUnits(MAXHEIGHT);
                scaledPaddingWidth                    = LogicalToDeviceUnits(PADDINGWIDTH);
                scaledPaddingHeight                   = LogicalToDeviceUnits(PADDINGHEIGHT);
                scaledMaxTextWidth                    = LogicalToDeviceUnits(MAXTEXTWIDTH);
                scaledMaxTextHeight                   = LogicalToDeviceUnits(MAXTEXTHEIGHT);
                scaledButtonTopPadding                = LogicalToDeviceUnits(BUTTONTOPPADDING);
                scaledButtonDetailsLeftPadding        = LogicalToDeviceUnits(BUTTONDETAILS_LEFTPADDING);
                scaledMessageTopPadding               = LogicalToDeviceUnits(MESSAGE_TOPPADDING);
                scaledHeightPadding                   = LogicalToDeviceUnits(HEIGHTPADDING);
                scaledButtonWidth                     = LogicalToDeviceUnits(BUTTONWIDTH);
                scaledButtonHeight                    = LogicalToDeviceUnits(BUTTONHEIGHT);
                scaledButtonAlignmentWidth            = LogicalToDeviceUnits(BUTTONALIGNMENTWIDTH);
                scaledButtonAlignmentPadding          = LogicalToDeviceUnits(BUTTONALIGNMENTPADDING);
                scaledDetailsWidthPadding             = LogicalToDeviceUnits(DETAILSWIDTHPADDING);
                scaledDetailsHeight                   = LogicalToDeviceUnits(DETAILSHEIGHT);
                scaledPictureWidth                    = LogicalToDeviceUnits(PICTUREWIDTH);
                scaledPictureHeight                   = LogicalToDeviceUnits(PICTUREHEIGHT);
                scaledExceptionMessageVerticalPadding = LogicalToDeviceUnits(EXCEPTIONMESSAGEVERTICALPADDING);
            }

            string messageFormat;
            string messageText;

            Button[] buttons;
            bool     detailAnchor = false;

            WarningException w = t as WarningException;

            if (w != null)
            {
                messageFormat = SR.ExDlgWarningText;
                messageText   = w.Message;
                if (w.HelpUrl == null)
                {
                    buttons = new Button[] { continueButton };
                }
                else
                {
                    buttons = new Button[] { continueButton, helpButton };
                }
            }
            else
            {
                messageText = t.Message;

                detailAnchor = true;

                if (Application.AllowQuit)
                {
                    if (t is System.Security.SecurityException)
                    {
                        messageFormat = SR.ExDlgSecurityErrorText;
                    }
                    else
                    {
                        messageFormat = SR.ExDlgErrorText;
                    }
                    buttons = new Button[] { detailsButton, continueButton, quitButton };
                }
                else
                {
                    if (t is System.Security.SecurityException)
                    {
                        messageFormat = SR.ExDlgSecurityContinueErrorText;
                    }
                    else
                    {
                        messageFormat = SR.ExDlgContinueErrorText;
                    }
                    buttons = new Button[] { detailsButton, continueButton };
                }
            }

            if (messageText.Length == 0)
            {
                messageText = t.GetType().Name;
            }
            if (t is System.Security.SecurityException)
            {
                messageText = string.Format(messageFormat, t.GetType().Name, Trim(messageText));
            }
            else
            {
                messageText = string.Format(messageFormat, Trim(messageText));
            }

            StringBuilder detailsTextBuilder = new StringBuilder();
            string        newline            = "\r\n";
            string        separator          = SR.ExDlgMsgSeperator;
            string        sectionseparator   = SR.ExDlgMsgSectionSeperator;

            if (Application.CustomThreadExceptionHandlerAttached)
            {
                detailsTextBuilder.Append(SR.ExDlgMsgHeaderNonSwitchable);
            }
            else
            {
                detailsTextBuilder.Append(SR.ExDlgMsgHeaderSwitchable);
            }
            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgExceptionSection));
            detailsTextBuilder.Append(t.ToString());
            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgLoadedAssembliesSection));

            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                AssemblyName name    = asm.GetName();
                string       fileVer = SR.NotAvailable;

                try {
                    if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0)
                    {
                        Uri codeBase = new Uri(name.EscapedCodeBase);
                        if (codeBase.Scheme == "file")
                        {
                            fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion;
                        }
                    }
                }
                catch (System.IO.FileNotFoundException) {
                }
                detailsTextBuilder.Append(string.Format(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase));
                detailsTextBuilder.Append(separator);
            }

            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgJITDebuggingSection));
            if (Application.CustomThreadExceptionHandlerAttached)
            {
                detailsTextBuilder.Append(SR.ExDlgMsgFooterNonSwitchable);
            }
            else
            {
                detailsTextBuilder.Append(SR.ExDlgMsgFooterSwitchable);
            }

            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(newline);

            string detailsText = detailsTextBuilder.ToString();

            Graphics g = message.CreateGraphicsInternal();

            Size textSize = new Size(scaledMaxWidth - scaledPaddingWidth, int.MaxValue);

            if (DpiHelper.IsScalingRequirementMet && Label.UseCompatibleTextRenderingDefault == false)
            {
                // we need to measure string using API that matches the rendering engine - TextRenderer.MeasureText for GDI
                textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak));
            }
            else
            {
                // if HighDpi improvements are not enabled, or rendering mode is GDI+, use Graphics.MeasureString
                textSize = Size.Ceiling(g.MeasureString(messageText, Font, textSize.Width));
            }

            textSize.Height += scaledExceptionMessageVerticalPadding;
            g.Dispose();

            if (textSize.Width < scaledMaxTextWidth)
            {
                textSize.Width = scaledMaxTextWidth;
            }
            if (textSize.Height > scaledMaxHeight)
            {
                textSize.Height = scaledMaxHeight;
            }

            int width     = textSize.Width + scaledPaddingWidth;
            int buttonTop = Math.Max(textSize.Height, scaledMaxTextHeight) + scaledPaddingHeight;

            Form activeForm = Form.ActiveForm;

            if (activeForm == null || activeForm.Text.Length == 0)
            {
                Text = SR.ExDlgCaption;
            }
            else
            {
                Text = string.Format(SR.ExDlgCaption2, activeForm.Text);
            }

            AcceptButton    = continueButton;
            CancelButton    = continueButton;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox     = false;
            MinimizeBox     = false;
            StartPosition   = FormStartPosition.CenterScreen;
            Icon            = null;
            ClientSize      = new Size(width, buttonTop + scaledButtonTopPadding);
            TopMost         = true;

            pictureBox.Location = new Point(scaledPictureWidth / 8, scaledPictureHeight / 8);
            pictureBox.Size     = new Size(scaledPictureWidth * 3 / 4, scaledPictureHeight * 3 / 4);
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            if (t is System.Security.SecurityException)
            {
                pictureBox.Image = SystemIcons.Information.ToBitmap();
            }
            else
            {
                pictureBox.Image = SystemIcons.Error.ToBitmap();
            }
            Controls.Add(pictureBox);
            message.SetBounds(scaledPictureWidth,
                              scaledMessageTopPadding + (scaledMaxTextHeight - Math.Min(textSize.Height, scaledMaxTextHeight)) / 2,
                              textSize.Width, textSize.Height);
            message.Text = messageText;
            Controls.Add(message);

            continueButton.Text         = SR.ExDlgContinue;
            continueButton.FlatStyle    = FlatStyle.Standard;
            continueButton.DialogResult = DialogResult.Cancel;

            quitButton.Text         = SR.ExDlgQuit;
            quitButton.FlatStyle    = FlatStyle.Standard;
            quitButton.DialogResult = DialogResult.Abort;

            helpButton.Text         = SR.ExDlgHelp;
            helpButton.FlatStyle    = FlatStyle.Standard;
            helpButton.DialogResult = DialogResult.Yes;

            detailsButton.Text      = SR.ExDlgShowDetails;
            detailsButton.FlatStyle = FlatStyle.Standard;
            detailsButton.Click    += new EventHandler(DetailsClick);

            Button b          = null;
            int    startIndex = 0;

            if (detailAnchor)
            {
                b = detailsButton;

                expandImage   = DpiHelper.GetBitmapFromIcon(GetType(), DownBitmapName);
                collapseImage = DpiHelper.GetBitmapFromIcon(GetType(), UpBitmapName);

                if (DpiHelper.IsScalingRequirementMet)
                {
                    ScaleBitmapLogicalToDevice(ref expandImage);
                    ScaleBitmapLogicalToDevice(ref collapseImage);
                }

                b.SetBounds(scaledButtonDetailsLeftPadding, buttonTop, scaledButtonWidth, scaledButtonHeight);
                b.Image      = expandImage;
                b.ImageAlign = ContentAlignment.MiddleLeft;
                Controls.Add(b);
                startIndex = 1;
            }

            int buttonLeft = (width - scaledButtonDetailsLeftPadding - ((buttons.Length - startIndex) * scaledButtonAlignmentWidth - scaledButtonAlignmentPadding));

            for (int i = startIndex; i < buttons.Length; i++)
            {
                b = buttons[i];
                b.SetBounds(buttonLeft, buttonTop, scaledButtonWidth, scaledButtonHeight);
                Controls.Add(b);
                buttonLeft += scaledButtonAlignmentWidth;
            }

            details.Text          = detailsText;
            details.ScrollBars    = ScrollBars.Both;
            details.Multiline     = true;
            details.ReadOnly      = true;
            details.WordWrap      = false;
            details.TabStop       = false;
            details.AcceptsReturn = false;

            details.SetBounds(scaledButtonDetailsLeftPadding, buttonTop + scaledButtonTopPadding, width - scaledDetailsWidthPadding, scaledDetailsHeight);
            details.Visible = detailsVisible;
            Controls.Add(details);
            if (DpiHelper.IsScalingRequirementMet)
            {
                DpiChanged += ThreadExceptionDialog_DpiChanged;
            }
        }
Esempio n. 37
0
        public void PaletteCcommands()
        {
            if (_ps == null)
            {
                var doc = Application.DocumentManager.MdiActiveDocument;
                if (doc == null)
                {
                    return;
                }
                var ed = doc.Editor;

                // We're going to take a look at the various methods in this module
                var asm  = Assembly.GetExecutingAssembly();
                var type = asm.GetType("ModelessDialogs.Commands");
                if (type == null)
                {
                    ed.WriteMessage("\nCould not find the command class.");
                    return;
                }

                // We'll create a sequence of buttons for each callable method
                var bs = new List <WinForms.Button>();
                var i  = 1;

                // Loop over each method
                foreach (var m in type.GetMethods())
                {
                    var cmdName = "";
                    var palette = false;
                    // And then all of its attributes
                    foreach (var a in m.CustomAttributes)
                    {
                        // Check whether we have a command and/or a "palette" attb
                        if (a.AttributeType.Name == "CommandMethodAttribute")
                        {
                            cmdName = (string)a.ConstructorArguments[0].Value;
                        }
                        else if (a.AttributeType.Name == "PaletteMethod")
                        {
                            palette = true;
                        }
                    }

                    // If we have a palette attb, then one way or another it'll be
                    // added to the palette
                    if (palette)
                    {
                        // Create our button and give it a position
                        var b = new WinForms.Button();
                        b.SetBounds(50, 40 * i, 100, 30);
                        // If no command name was found, use the method name and call the
                        // function directly in the session context
                        if (String.IsNullOrEmpty(cmdName))
                        {
                            b.Text   = m.Name;
                            b.Click +=
                                (s, e) =>
                            {
                                var b2 = (WinForms.Button)s;
                                var mi = type.GetMethod(b2.Text);

                                if (mi != null)
                                {
                                    // Use reflection to call the method with no arguments
                                    mi.Invoke(this, null);
                                }
                            };
                        }
                        else
                        {
                            // Otherwise we use the command name as the button text and
                            // execute the command in the command context asynchronously
                            b.Text   = cmdName;
                            b.Click +=
                                async(s, e) =>
                            {
                                var dm   = Application.DocumentManager;
                                var doc2 = dm.MdiActiveDocument;
                                if (doc2 == null)
                                {
                                    return;
                                }

                                // We could also use SendStringToExecute for older versions
                                // doc2.SendStringToExecute(
                                //   "_." + cmdName + " ", false, false, true
                                // );
                                var ed2 = doc2.Editor;
                                await dm.ExecuteInCommandContextAsync(
                                    async (obj) =>
                                {
                                    await ed2.CommandAsync("_." + cmdName);
                                },
                                    null
                                    );
                            };
                        }
                        bs.Add(b);
                        i++;
                    }
                }
                // Create a user control and add all our buttons to it
                var uc = new WinForms.UserControl();
                uc.Controls.AddRange(bs.ToArray());

                // Create a palette set and add a palette containing our control
                _ps = new PaletteSet("PC", new Guid("87374E16-C0DB-4F3F-9271-7A71ED921566"));
                _ps.Add("CMDPAL", uc);
                _ps.MinimumSize = new Size(200, (i + 1) * 40);
                _ps.DockEnabled = (DockSides)(DockSides.Left | DockSides.Right);
            }
            _ps.Visible = true;
        }
Esempio n. 38
0
        static DialogResult ShowUI(string title, string promptText, string value, bool password = false)
        {
            Form form = new Form();

            System.Windows.Forms.Label label = new System.Windows.Forms.Label();
            TextBox textBox = new TextBox();

            if (password)
            {
                textBox.UseSystemPasswordChar = true;
            }
            System.Windows.Forms.Button buttonOk     = new System.Windows.Forms.Button();
            System.Windows.Forms.Button buttonCancel = new System.Windows.Forms.Button();
            //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2));
            //form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            form.TopMost  = true;
            form.TopLevel = true;

            form.Text    = title;
            label.Text   = promptText;
            textBox.Text = value;

            buttonOk.Text             = "OK";
            buttonCancel.Text         = "Cancel";
            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize      = true;
            textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedSingle;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;

            if (ApplyTheme != null)
            {
                ApplyTheme(form);
            }

            DialogResult dialogResult = DialogResult.Cancel;

            Console.WriteLine("Input Box " + System.Threading.Thread.CurrentThread.Name);

            Application.DoEvents();

            form.ShowDialog();

            Console.WriteLine("Input Box 2 " + System.Threading.Thread.CurrentThread.Name);

            dialogResult = form.DialogResult;

            if (dialogResult == DialogResult.OK)
            {
                value          = textBox.Text;
                InputBox.value = value;
            }

            form.Dispose();

            form = null;

            return(dialogResult);
        }
        /// <include file='doc\ThreadExceptionDialog.uex' path='docs/doc[@for="ThreadExceptionDialog.ThreadExceptionDialog"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class.
        ///
        ///    </para>
        /// </devdoc>
        public ThreadExceptionDialog(Exception t)
        {
            if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements)
            {
                scaledMaxWidth                        = DpiHelper.LogicalToDeviceUnitsX(MAXWIDTH);
                scaledMaxHeight                       = DpiHelper.LogicalToDeviceUnitsY(MAXHEIGHT);
                scaledPaddingWidth                    = DpiHelper.LogicalToDeviceUnitsX(PADDINGWIDTH);
                scaledPaddingHeight                   = DpiHelper.LogicalToDeviceUnitsY(PADDINGHEIGHT);
                scaledMaxTextWidth                    = DpiHelper.LogicalToDeviceUnitsX(MAXTEXTWIDTH);
                scaledMaxTextHeight                   = DpiHelper.LogicalToDeviceUnitsY(MAXTEXTHEIGHT);
                scaledButtonTopPadding                = DpiHelper.LogicalToDeviceUnitsY(BUTTONTOPPADDING);
                scaledButtonDetailsLeftPadding        = DpiHelper.LogicalToDeviceUnitsX(BUTTONDETAILS_LEFTPADDING);
                scaledMessageTopPadding               = DpiHelper.LogicalToDeviceUnitsY(MESSAGE_TOPPADDING);
                scaledHeightPadding                   = DpiHelper.LogicalToDeviceUnitsY(HEIGHTPADDING);
                scaledButtonWidth                     = DpiHelper.LogicalToDeviceUnitsX(BUTTONWIDTH);
                scaledButtonHeight                    = DpiHelper.LogicalToDeviceUnitsY(BUTTONHEIGHT);
                scaledButtonAlignmentWidth            = DpiHelper.LogicalToDeviceUnitsX(BUTTONALIGNMENTWIDTH);
                scaledButtonAlignmentPadding          = DpiHelper.LogicalToDeviceUnitsX(BUTTONALIGNMENTPADDING);
                scaledDetailsWidthPadding             = DpiHelper.LogicalToDeviceUnitsX(DETAILSWIDTHPADDING);
                scaledDetailsHeight                   = DpiHelper.LogicalToDeviceUnitsY(DETAILSHEIGHT);
                scaledPictureWidth                    = DpiHelper.LogicalToDeviceUnitsX(PICTUREWIDTH);
                scaledPictureHeight                   = DpiHelper.LogicalToDeviceUnitsY(PICTUREHEIGHT);
                scaledExceptionMessageVerticalPadding = DpiHelper.LogicalToDeviceUnitsY(EXCEPTIONMESSAGEVERTICALPADDING);
            }

            string messageRes;
            string messageText;

            Button[] buttons;
            bool     detailAnchor = false;

            WarningException w = t as WarningException;

            if (w != null)
            {
                messageRes  = SR.ExDlgWarningText;
                messageText = w.Message;
                if (w.HelpUrl == null)
                {
                    buttons = new Button[] { continueButton };
                }
                else
                {
                    buttons = new Button[] { continueButton, helpButton };
                }
            }
            else
            {
                messageText = t.Message;

                detailAnchor = true;

                if (Application.AllowQuit)
                {
                    if (t is SecurityException)
                    {
                        messageRes = "ExDlgSecurityErrorText";
                    }
                    else
                    {
                        messageRes = "ExDlgErrorText";
                    }
                    buttons = new Button[] { detailsButton, continueButton, quitButton };
                }
                else
                {
                    if (t is SecurityException)
                    {
                        messageRes = "ExDlgSecurityContinueErrorText";
                    }
                    else
                    {
                        messageRes = "ExDlgContinueErrorText";
                    }
                    buttons = new Button[] { detailsButton, continueButton };
                }
            }

            if (messageText.Length == 0)
            {
                messageText = t.GetType().Name;
            }
            if (t is SecurityException)
            {
                messageText = SR.GetString(messageRes, t.GetType().Name, Trim(messageText));
            }
            else
            {
                messageText = SR.GetString(messageRes, Trim(messageText));
            }

            StringBuilder detailsTextBuilder = new StringBuilder();
            string        newline            = "\r\n";
            string        separator          = SR.GetString(SR.ExDlgMsgSeperator);
            string        sectionseparator   = SR.GetString(SR.ExDlgMsgSectionSeperator);

            if (Application.CustomThreadExceptionHandlerAttached)
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderNonSwitchable));
            }
            else
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderSwitchable));
            }
            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgExceptionSection)));
            detailsTextBuilder.Append(t.ToString());
            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgLoadedAssembliesSection)));
            new FileIOPermission(PermissionState.Unrestricted).Assert();
            try {
                foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    AssemblyName name    = asm.GetName();
                    string       fileVer = SR.GetString(SR.NotAvailable);

                    try {
                        // bug 113573 -- if there's a path with an escaped value in it
                        // like c:\temp\foo%2fbar, the AssemblyName call will unescape it to
                        // c:\temp\foo\bar, which is wrong, and this will fail.   It doesn't look like the
                        // assembly name class handles this properly -- even the "CodeBase" property is un-escaped
                        // so we can't circumvent this.
                        //
                        if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0)
                        {
                            Uri codeBase = new Uri(name.EscapedCodeBase);
                            if (codeBase.Scheme == "file")
                            {
                                fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion;
                            }
                        }
                    }
                    catch (System.IO.FileNotFoundException) {
                    }
                    detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase));
                    detailsTextBuilder.Append(separator);
                }
            }
            finally {
                CodeAccessPermission.RevertAssert();
            }

            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgJITDebuggingSection)));
            if (Application.CustomThreadExceptionHandlerAttached)
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterNonSwitchable));
            }
            else
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterSwitchable));
            }

            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(newline);

            string detailsText = detailsTextBuilder.ToString();

            Graphics g = message.CreateGraphicsInternal();

            Size textSize = new Size(scaledMaxWidth - scaledPaddingWidth, int.MaxValue);

            if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements && (Label.UseCompatibleTextRenderingDefault == false))
            {
                // we need to measure string using API that matches the rendering engine - TextRenderer.MeasureText for GDI
                textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak));
            }
            else
            {
                // if HighDpi improvements are not enabled, or rendering mode is GDI+, use Graphics.MeasureString
                textSize = Size.Ceiling(g.MeasureString(messageText, Font, textSize.Width));
            }

            textSize.Height += scaledExceptionMessageVerticalPadding;
            g.Dispose();

            if (textSize.Width < scaledMaxTextWidth)
            {
                textSize.Width = scaledMaxTextWidth;
            }
            if (textSize.Height > scaledMaxHeight)
            {
                textSize.Height = scaledMaxHeight;
            }

            int width     = textSize.Width + scaledPaddingWidth;
            int buttonTop = Math.Max(textSize.Height, scaledMaxTextHeight) + scaledPaddingHeight;

            // SECREVIEW : We must get a hold of the parent to get at it's text
            //           : to make this dialog look like the parent.
            //
            IntSecurity.GetParent.Assert();
            try {
                Form activeForm = Form.ActiveForm;
                if (activeForm == null || activeForm.Text.Length == 0)
                {
                    Text = SR.GetString(SR.ExDlgCaption);
                }
                else
                {
                    Text = SR.GetString(SR.ExDlgCaption2, activeForm.Text);
                }
            }
            finally {
                CodeAccessPermission.RevertAssert();
            }
            AcceptButton    = continueButton;
            CancelButton    = continueButton;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox     = false;
            MinimizeBox     = false;
            StartPosition   = FormStartPosition.CenterScreen;
            Icon            = null;
            ClientSize      = new Size(width, buttonTop + scaledButtonTopPadding);
            TopMost         = true;

            pictureBox.Location = new Point(0, 0);
            pictureBox.Size     = new Size(scaledPictureWidth, scaledPictureHeight);
            pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
            if (t is SecurityException)
            {
                pictureBox.Image = SystemIcons.Information.ToBitmap();
            }
            else
            {
                pictureBox.Image = SystemIcons.Error.ToBitmap();
            }
            Controls.Add(pictureBox);
            message.SetBounds(scaledPictureWidth,
                              scaledMessageTopPadding + (scaledMaxTextHeight - Math.Min(textSize.Height, scaledMaxTextHeight)) / 2,
                              textSize.Width, textSize.Height);
            message.Text = messageText;
            Controls.Add(message);

            continueButton.Text         = SR.GetString(SR.ExDlgContinue);
            continueButton.FlatStyle    = FlatStyle.Standard;
            continueButton.DialogResult = DialogResult.Cancel;

            quitButton.Text         = SR.GetString(SR.ExDlgQuit);
            quitButton.FlatStyle    = FlatStyle.Standard;
            quitButton.DialogResult = DialogResult.Abort;

            helpButton.Text         = SR.GetString(SR.ExDlgHelp);
            helpButton.FlatStyle    = FlatStyle.Standard;
            helpButton.DialogResult = DialogResult.Yes;

            detailsButton.Text      = SR.GetString(SR.ExDlgShowDetails);
            detailsButton.FlatStyle = FlatStyle.Standard;
            detailsButton.Click    += new EventHandler(DetailsClick);

            Button b          = null;
            int    startIndex = 0;

            if (detailAnchor)
            {
                b = detailsButton;

                expandImage = new Bitmap(this.GetType(), "down.bmp");
                expandImage.MakeTransparent();
                collapseImage = new Bitmap(this.GetType(), "up.bmp");
                collapseImage.MakeTransparent();

                if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements)
                {
                    DpiHelper.ScaleBitmapLogicalToDevice(ref expandImage);
                    DpiHelper.ScaleBitmapLogicalToDevice(ref collapseImage);
                }

                b.SetBounds(scaledButtonDetailsLeftPadding, buttonTop, scaledButtonWidth, scaledButtonHeight);
                b.Image      = expandImage;
                b.ImageAlign = ContentAlignment.MiddleLeft;
                Controls.Add(b);
                startIndex = 1;
            }

            int buttonLeft = (width - scaledButtonDetailsLeftPadding - ((buttons.Length - startIndex) * scaledButtonAlignmentWidth - scaledButtonAlignmentPadding));

            for (int i = startIndex; i < buttons.Length; i++)
            {
                b = buttons[i];
                b.SetBounds(buttonLeft, buttonTop, scaledButtonWidth, scaledButtonHeight);
                Controls.Add(b);
                buttonLeft += scaledButtonAlignmentWidth;
            }

            details.Text          = detailsText;
            details.ScrollBars    = ScrollBars.Both;
            details.Multiline     = true;
            details.ReadOnly      = true;
            details.WordWrap      = false;
            details.TabStop       = false;
            details.AcceptsReturn = false;

            details.SetBounds(scaledButtonDetailsLeftPadding, buttonTop + scaledButtonTopPadding, width - scaledDetailsWidthPadding, scaledDetailsHeight);
            Controls.Add(details);
        }
Esempio n. 40
0
        public static DialogResult InputBox(string title, string promptText, ref string value, ref int maxStep)
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Label   label   = new Label();
            TextBox textBox = new TextBox();

            System.Windows.Forms.Button buttonOk     = new System.Windows.Forms.Button();
            System.Windows.Forms.Button buttonCancel = new System.Windows.Forms.Button();
            System.Windows.Forms.Button buttonAbort  = new System.Windows.Forms.Button();

            form.Text           = title;
            label.Text          = promptText;
            label.BackColor     = System.Drawing.Color.Transparent;
            textBox.Text        = value;
            textBox.BorderStyle = BorderStyle.FixedSingle;
            textBox.KeyPress   += new System.Windows.Forms.KeyPressEventHandler(WinComponent.txtStep_Keypress);

            buttonOk.Text             = "Kjør til trinn";
            buttonCancel.Text         = "Fortsett";
            buttonAbort.Text          = "Avbryt";
            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;
            buttonAbort.DialogResult  = DialogResult.Abort;

            label.SetBounds(9, 18, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(147, 72, 75, 23);
            buttonCancel.SetBounds(228, 72, 75, 23);
            buttonAbort.SetBounds(309, 72, 75, 23);

            label.AutoSize      = true;
            textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonAbort.Anchor  = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new System.Windows.Forms.Control[] { label, textBox, buttonOk, buttonCancel, buttonAbort });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;
            form.TopMost         = true;

            if (Int16.Parse(value) == maxStep)
            {
                buttonOk.Enabled    = false;
                buttonAbort.Enabled = false;
                textBox.Text        = (maxStep - 1).ToString();
                textBox.Enabled     = false;
                label.Text          = "Du har nå kommet til det siste trinnet";
            }

            DialogResult dialogResult = form.ShowDialog();

            value = textBox.Text;
            return(dialogResult);
        }
        /// <include file='doc\ThreadExceptionDialog.uex' path='docs/doc[@for="ThreadExceptionDialog.ThreadExceptionDialog"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class.
        ///
        ///    </para>
        /// </devdoc>
        public ThreadExceptionDialog(Exception t)
        {
            string messageRes;
            string messageText;

            Button[] buttons;
            bool     detailAnchor = false;

            WarningException w = t as WarningException;

            if (w != null)
            {
                messageRes  = SR.ExDlgWarningText;
                messageText = w.Message;
                if (w.HelpUrl == null)
                {
                    buttons = new Button[] { continueButton };
                }
                else
                {
                    buttons = new Button[] { continueButton, helpButton };
                }
            }
            else
            {
                messageText = t.Message;

                detailAnchor = true;

                if (Application.AllowQuit)
                {
                    if (t is SecurityException)
                    {
                        messageRes = "ExDlgSecurityErrorText";
                    }
                    else
                    {
                        messageRes = "ExDlgErrorText";
                    }
                    buttons = new Button[] { detailsButton, continueButton, quitButton };
                }
                else
                {
                    if (t is SecurityException)
                    {
                        messageRes = "ExDlgSecurityContinueErrorText";
                    }
                    else
                    {
                        messageRes = "ExDlgContinueErrorText";
                    }
                    buttons = new Button[] { detailsButton, continueButton };
                }
            }

            if (messageText.Length == 0)
            {
                messageText = t.GetType().Name;
            }
            if (t is SecurityException)
            {
                messageText = SR.GetString(messageRes, t.GetType().Name, Trim(messageText));
            }
            else
            {
                messageText = SR.GetString(messageRes, Trim(messageText));
            }

            StringBuilder detailsTextBuilder = new StringBuilder();
            string        newline            = "\r\n";
            string        separator          = SR.GetString(SR.ExDlgMsgSeperator);
            string        sectionseparator   = SR.GetString(SR.ExDlgMsgSectionSeperator);

            if (Application.CustomThreadExceptionHandlerAttached)
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderNonSwitchable));
            }
            else
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderSwitchable));
            }
            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgExceptionSection)));
            detailsTextBuilder.Append(t.ToString());
            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgLoadedAssembliesSection)));
            new FileIOPermission(PermissionState.Unrestricted).Assert();
            try {
                foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    AssemblyName name    = asm.GetName();
                    string       fileVer = SR.GetString(SR.NotAvailable);

                    try {
                        // bug 113573 -- if there's a path with an escaped value in it
                        // like c:\temp\foo%2fbar, the AssemblyName call will unescape it to
                        // c:\temp\foo\bar, which is wrong, and this will fail.   It doesn't look like the
                        // assembly name class handles this properly -- even the "CodeBase" property is un-escaped
                        // so we can't circumvent this.
                        //
                        if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0)
                        {
                            Uri codeBase = new Uri(name.EscapedCodeBase);
                            if (codeBase.Scheme == "file")
                            {
                                fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion;
                            }
                        }
                    }
                    catch (System.IO.FileNotFoundException) {
                    }
                    detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase));
                    detailsTextBuilder.Append(separator);
                }
            }
            finally {
                CodeAccessPermission.RevertAssert();
            }

            detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgJITDebuggingSection)));
            if (Application.CustomThreadExceptionHandlerAttached)
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterNonSwitchable));
            }
            else
            {
                detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterSwitchable));
            }

            detailsTextBuilder.Append(newline);
            detailsTextBuilder.Append(newline);

            string detailsText = detailsTextBuilder.ToString();

            Graphics g = message.CreateGraphicsInternal();

            Size textSize = Size.Ceiling(g.MeasureString(messageText, Font, MAXWIDTH - 84));

            textSize.Height += 4;
            g.Dispose();

            if (textSize.Width < 180)
            {
                textSize.Width = 180;
            }
            if (textSize.Height > MAXHEIGHT)
            {
                textSize.Height = MAXHEIGHT;
            }

            int width     = textSize.Width + 84;
            int buttonTop = Math.Max(textSize.Height, 40) + 26;

            // SECREVIEW : We must get a hold of the parent to get at it's text
            //           : to make this dialog look like the parent.
            //
            IntSecurity.GetParent.Assert();
            try {
                Form activeForm = Form.ActiveForm;
                if (activeForm == null || activeForm.Text.Length == 0)
                {
                    Text = SR.GetString(SR.ExDlgCaption);
                }
                else
                {
                    Text = SR.GetString(SR.ExDlgCaption2, activeForm.Text);
                }
            }
            finally {
                CodeAccessPermission.RevertAssert();
            }
            AcceptButton    = continueButton;
            CancelButton    = continueButton;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox     = false;
            MinimizeBox     = false;
            StartPosition   = FormStartPosition.CenterScreen;
            Icon            = null;
            ClientSize      = new Size(width, buttonTop + 31);
            TopMost         = true;

            pictureBox.Location = new Point(0, 0);
            pictureBox.Size     = new Size(64, 64);
            pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
            if (t is SecurityException)
            {
                pictureBox.Image = SystemIcons.Information.ToBitmap();
            }
            else
            {
                pictureBox.Image = SystemIcons.Error.ToBitmap();
            }
            Controls.Add(pictureBox);
            message.SetBounds(64,
                              8 + (40 - Math.Min(textSize.Height, 40)) / 2,
                              textSize.Width, textSize.Height);
            message.Text = messageText;
            Controls.Add(message);

            continueButton.Text         = SR.GetString(SR.ExDlgContinue);
            continueButton.FlatStyle    = FlatStyle.Standard;
            continueButton.DialogResult = DialogResult.Cancel;

            quitButton.Text         = SR.GetString(SR.ExDlgQuit);
            quitButton.FlatStyle    = FlatStyle.Standard;
            quitButton.DialogResult = DialogResult.Abort;

            helpButton.Text         = SR.GetString(SR.ExDlgHelp);
            helpButton.FlatStyle    = FlatStyle.Standard;
            helpButton.DialogResult = DialogResult.Yes;

            detailsButton.Text      = SR.GetString(SR.ExDlgShowDetails);
            detailsButton.FlatStyle = FlatStyle.Standard;
            detailsButton.Click    += new EventHandler(DetailsClick);

            Button b          = null;
            int    startIndex = 0;

            if (detailAnchor)
            {
                b = detailsButton;

                expandImage = new Bitmap(this.GetType(), "down.bmp");
                expandImage.MakeTransparent();
                collapseImage = new Bitmap(this.GetType(), "up.bmp");
                collapseImage.MakeTransparent();

                b.SetBounds(8, buttonTop, 100, 23);
                b.Image      = expandImage;
                b.ImageAlign = ContentAlignment.MiddleLeft;
                Controls.Add(b);
                startIndex = 1;
            }

            int buttonLeft = (width - 8 - ((buttons.Length - startIndex) * 105 - 5));

            for (int i = startIndex; i < buttons.Length; i++)
            {
                b = buttons[i];
                b.SetBounds(buttonLeft, buttonTop, 100, 23);
                Controls.Add(b);
                buttonLeft += 105;
            }

            details.Text          = detailsText;
            details.ScrollBars    = ScrollBars.Both;
            details.Multiline     = true;
            details.ReadOnly      = true;
            details.WordWrap      = false;
            details.TabStop       = false;
            details.AcceptsReturn = false;

            details.SetBounds(8, buttonTop + 31, width - 16, 154);
            Controls.Add(details);
        }