Exemplo n.º 1
0
        private void InitializeComponents()
        {
            nameLabel = new Label();
              pathLabel = new Label();
              nameTextBox = new TextBox();
              pathTextBox = new TextBox();
              okButton = new Button();
              cancelButton = new Button();

              this.SuspendLayout();
              nameLabel.SuspendLayout();
              pathLabel.SuspendLayout();
              nameTextBox.SuspendLayout();
              pathTextBox.SuspendLayout();
              okButton.SuspendLayout();
              cancelButton.SuspendLayout();

              nameLabel.Text = "Name";
              nameLabel.AutoSize = true;
              nameLabel.Location = new Point(3, 3);

              pathLabel.Text = "Path";
              pathLabel.AutoSize = true;
              pathLabel.Location = new Point(3, 30);

              nameTextBox.Size = new Size(250, 19);
              nameTextBox.Location = new Point(40, 2);
              nameTextBox.BorderStyle = BorderStyle.FixedSingle;

              pathTextBox.Size = new Size(250, 19);
              pathTextBox.Location = new Point(40, 29);
              pathTextBox.BorderStyle = BorderStyle.FixedSingle;

              okButton.Text = "OK";
              okButton.Size = new Size(75, 23);
              okButton.Location = new Point((300-75)/2, 60);
              okButton.FlatStyle = FlatStyle.Flat;
              okButton.Click += delegate {
            this.DialogResult = DialogResult.OK;
            this.Close();
              };

              cancelButton.Text = "Cancel";
              cancelButton.Size = new Size(75, 23);
              cancelButton.Location = new Point(215, 60);
              cancelButton.FlatStyle = FlatStyle.Flat;
              cancelButton.Click += delegate {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
              };

              this.Size = new Size(300, 120);
              this.FormBorderStyle = FormBorderStyle.FixedSingle;
              this.Text = "Jump target";
              this.Controls.AddRange(new Control[]{
            nameLabel,
            pathLabel,
            nameTextBox,
            pathTextBox,
            okButton,
            cancelButton
              });

              nameLabel.ResumeLayout(false);
              pathLabel.ResumeLayout(false);
              nameTextBox.ResumeLayout(false);
              pathTextBox.ResumeLayout(false);
              okButton.ResumeLayout(false);
              cancelButton.ResumeLayout(false);
              this.ResumeLayout(false);
              this.PerformLayout();
        }
Exemplo n.º 2
0
 private static void _WriteLog(TextBox tb, string msg)
 {
     if (tb.InvokeRequired)
     {
         WriteLogCallback writeLog = new WriteLogCallback(_WriteLog);
         tb.Invoke(writeLog, tb, msg);
     }
     else
     {
         if (msg == null) return;
         if (tb.Lines.Length > 1000)
         {
             tb.SuspendLayout();
             string[] sLines = new string[900];
             Array.Copy(tb.Lines, tb.Lines.Length - 900, sLines, 0, 900);
             tb.Lines = sLines;
             tb.ResumeLayout();
         }
         tb.AppendText(msg);
     }
 }
Exemplo n.º 3
0
        public static TextBox Numeric(IXsdPart part, ToolTip tooltip = null)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(part.Name))
                {
                    throw new ArgumentNullException();
                }
                var numeric = new TextBox();
                numeric.SuspendLayout();
                numeric.ForeColor = System.Drawing.Color.Black;
                numeric.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                numeric.Font = Methods.BaseFont;
                numeric.Size = new System.Drawing.Size(60, 21);
                //numeric.Minimum = 0;
                //numeric.Maximum = 65000;
                numeric.Name = "n" + part.Name;
                numeric.Text = String.IsNullOrWhiteSpace(part.Value) ? "" : part.Value;
                numeric.Tag = part;
                numeric.KeyPress += new System.Windows.Forms.KeyPressEventHandler(SpecialCaseHandlers.NumericNumberFilter);
                numeric.ResumeLayout();

                if (tooltip != null)
                {
                    tooltip.SetToolTip(numeric, part.Documentation);
                }

                return numeric;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Exemplo n.º 4
0
        public static TextBox TextBox(IXsdPart part, ToolTip tooltip = null)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(part.Name))
                {
                    throw new ArgumentNullException();
                }
                var textBox = new TextBox();
                textBox.SuspendLayout();
                textBox.BackColor = System.Drawing.Color.White;
                textBox.ForeColor = System.Drawing.Color.Black;
                textBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                textBox.Font = Methods.BaseFont;
                textBox.Name = "t" + part.Name;

                if (String.IsNullOrWhiteSpace(part.Value) && !Methods.StandAloneElement(part))
                {
                    textBox.Text = (part as Parts.Attribute).Default;
                }
                else
                {
                    textBox.Text = part.Value;
                }

                //Some textboxes will be empty but need to contain long strings.
                if (part.SpecialLength)
                {
                    textBox.Size = new System.Drawing.Size(200, 21);
                }
                else
                {
                    textBox.Size = new System.Drawing.Size(Methods.Width(textBox.Text), 21);
                }

                if (tooltip != null)
                {
                    tooltip.SetToolTip(textBox, part.Documentation);
                }

                textBox.Tag = part;

                textBox.ResumeLayout();
                return textBox;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Exemplo n.º 5
0
        public static TextBox MultiLineTextBox(Element element, ToolTip tooltip = null)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(element.Name))
                {
                    throw new ArgumentNullException();
                }
                var textBox = new TextBox();
                textBox.SuspendLayout();
                textBox.BackColor = System.Drawing.Color.White;
                textBox.ForeColor = System.Drawing.Color.Black;
                textBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                textBox.Font = Methods.BaseFont;
                textBox.Name = "mlt" + element.Name;
                textBox.Multiline = true;
                textBox.ScrollBars = ScrollBars.Both;
                textBox.WordWrap = false;
                textBox.Validating += Methods.MultilineTextBox_Validating;
                textBox.KeyUp += Methods.MultilineTextBox_KeyPress;
                textBox.CausesValidationChanged += Methods.MultilineTextBox_CausesValidation;

                if (String.IsNullOrWhiteSpace(element.Value))
                {
                    //textBox.Text = (part as Attribute).Default;
                }
                else
                {
                    textBox.Text = element.Value;
                }

                textBox.Size = new System.Drawing.Size(300, 100);

                if (tooltip != null)
                {
                    tooltip.SetToolTip(textBox, element.Documentation);
                }

                textBox.Tag = element;

                textBox.ResumeLayout();
                return textBox;
            }
            catch (Exception ex)
            {
                return null;
            }
        }