// Debug: Currently not used
//    private void TextBox_TextChanged(object sender, System.EventArgs e)
//    {
//      TextFormat format;
//      TextBoxEx textBox;
//
//      if (sender.GetType().Name == "TextBoxEx")
//      {
//        textBox = sender as TextBoxEx;
//        format = (textBox.Tag as RespondentInfo).Formatting;
//
//        int selStart = textBox.SelectionStart;
//        textBox.Text = textBox.Text.ToUpper();
//        textBox.SelectionStart = selStart;
//      }
//    }


        /// <summary>
        /// This event is fired when the user leaves a textbox.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBox_LostFocus(object sender, System.EventArgs e)
        {
            TextBoxEx      textBox  = sender as TextBoxEx;
            RespondentInfo respInfo = textBox.Tag as RespondentInfo;
            TextFormat     format   = respInfo.Formatting;

            switch (format)
            {
            case TextFormat.NumericOnly:
                // Do nothing, because this was handled in the KeyPress event
                break;

            case TextFormat.LowerCase:
                textBox.Text = textBox.Text.ToLower().Trim();
                break;

            case TextFormat.UpperCase:
                textBox.Text = textBox.Text.ToUpper().Trim();
                break;

            case TextFormat.ProperCase:
                textBox.Text = Tools.ProperCase(textBox.Text).Trim();
                break;

            case TextFormat.None:
                textBox.Text = textBox.Text.Trim();
                break;

            default:
                Debug.Fail("Unknown formatting code: " + format.ToString(), "frmRespondent.TextBox_LostFocus");
                break;
            }
        }
Ejemplo n.º 2
0
 public static void CrossThreadInvoke(TextBoxEx t, MethodInvoker m)
 {
     if (t.InvokeRequired)
     {
         t.Invoke(m);
     }
 }
Ejemplo n.º 3
0
    private static void CallConverter(object sender, RoutedEventArgs e)
    {
        TextBoxEx textBoxEx = sender as TextBoxEx;

        if (textBoxEx.Style == null)
        {
            return;
        }
        if (textBoxEx.SourceType == null)
        {
        }
        foreach (Setter setter in textBoxEx.Style.Setters)
        {
            if (setter.Property.ToString() == "Text")
            {
                if (!(setter.Value is Binding))
                {
                    return;
                }
                Binding binding = setter.Value as Binding;
                if (binding.Converter == null)
                {
                    return;
                }
                object value = binding.Converter.ConvertBack(textBoxEx.Text, textBoxEx.SourceType, binding.ConverterParameter, System.Globalization.CultureInfo.CurrentCulture);
                value = binding.Converter.Convert(value, typeof(string), binding.ConverterParameter, System.Globalization.CultureInfo.CurrentCulture);
                if (!(value is string))
                {
                    return;
                }
                textBoxEx.Text = (string)value;
            }
        }
    }
        protected override void InitializeControls()
        {
            flexChart1 = new FlexChart();
            this.Chart = flexChart1;

            _lHeader = new LabelEx("Header:");
            _tHeader = new TextBoxEx {
                ForeColor = Color.DimGray, AutoSize = false
            };
            _tHeader.TextChanged += (s, e) => { flexChart1.Header.Content = _tHeader.Text; };

            _lFooter = new LabelEx("Footer:");
            _tFooter = new TextBoxEx {
                AutoSize = false, ForeColor = Color.DimGray
            };
            _tFooter.TextChanged += (s, e) => { flexChart1.Footer.Content = _tFooter.Text; };

            _cbAlignment = ControlFactory.EnumBasedCombo(typeof(HorizontalAlignment), "Alignment");
            _cbAlignment.SelectedIndexChanged += (s, e) =>
            {
                flexChart1.Header.HorizontalAlignment = flexChart1.Footer.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), _cbAlignment.SelectedItem.ToString());
            };

            _chbBorder = new CheckBoxEx("Border");
            _chbBorder.CheckedChanged += (s, e) => { flexChart1.Header.Border = flexChart1.Footer.Border = _chbBorder.Checked; };

            this.pnlControls.Controls.Add(_lHeader);
            this.pnlControls.Controls.Add(_tHeader);
            this.pnlControls.Controls.Add(_lFooter);
            this.pnlControls.Controls.Add(_tFooter);
            this.pnlControls.Controls.Add(_cbAlignment);
            this.pnlControls.Controls.Add(_chbBorder);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 手机号输入限制-只能输入数字并且可以实现组合件功能如:Ctrl+A,Ctrl+C,Ctrl+V等
        /// </summary>
        /// <param name="txt">文本框</param>
        public static void TextForPhone(TextBoxEx txt)
        {
            txt.KeyPress += delegate(object sender, KeyPressEventArgs e)
            {
                if (nonNumberEntered)
                {
                    e.Handled = true;
                }
            };
            txt.KeyDown += delegate(object sender, KeyEventArgs e)
            {
                nonNumberEntered = false;
                //组合键
                if (e.KeyData == (Keys.C | Keys.Control) || e.KeyData == (Keys.A | Keys.Control) || e.KeyData == (Keys.V | Keys.Control) || e.KeyData == (Keys.X | Keys.Control))
                {
                    return;
                }
                //数字
                if (!e.Shift && e.KeyValue >= '0' && e.KeyValue <= '9')
                {
                    return;
                }
                if (e.KeyData == Keys.NumPad0 || e.KeyData == Keys.NumPad1 || e.KeyData == Keys.NumPad2 || e.KeyData == Keys.NumPad3 || e.KeyData == Keys.NumPad4 || e.KeyData == Keys.NumPad5 || e.KeyData == Keys.NumPad6 || e.KeyData == Keys.NumPad7 || e.KeyData == Keys.NumPad8 || e.KeyData == Keys.NumPad9)
                {
                    return;
                }
                //操作键
                if (e.KeyData == Keys.Back || e.KeyData == Keys.Delete || e.KeyData == Keys.Left || e.KeyData == Keys.Right)
                {
                    return;
                }

                nonNumberEntered = true;
            };
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Эту процедуру нужно привязать к событию GotFocus для всех TextBox, в которых используются Binding и StrToIntConverter, StrToFloatConverter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void txt_GotFocus(object sender, RoutedEventArgs e)
        {
            TextBoxEx txt = sender as TextBoxEx;

            if (txt != null && txt.Modified && txt.IsRightInput)
            {
                BindingBase bindBase = BindingOperations.GetBindingBase(txt, TextBox.TextProperty);

                if (bindBase != null)
                {
                    Binding bind = bindBase as Binding;
                    if (bind != null)
                    {
                        if (bind.Converter is StrToIntConverter)
                        {
                            ((StrToIntConverter)bind.Converter).m_PrevVal = int.Parse(txt.Text);
                        }
                        else
                        if (bind.Converter is StrToFloatConverter)
                        {
                            ((StrToFloatConverter)bind.Converter).m_PrevVal = float.Parse(txt.Text);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected virtual bool SaveData()
        {
            if (m_boId == BOIDEnum.Invalid)
            {
                return(true);
            }

            bool result = true;

            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is TextBoxEx)
                {
                    TextBoxEx txtBox = (TextBoxEx)ctrl;
                    if (txtBox.BOID == m_boId)
                    {
                        result = SetFieldData(txtBox.BOField, txtBox.Text);
                    }
                }
                else if (ctrl is ComboBoxEx)
                {
                    ComboBoxEx cmb = (ComboBoxEx)ctrl;
                    if (cmb.BOID == m_boId)
                    {
                        result = SetFieldData(cmb.BOField, cmb.SelectedValue);
                    }
                }
                if (!result)
                {
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && (this.m_TextBox != null))
     {
         this.m_TextBox.Dispose();
         this.m_TextBox = null;
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 9
0
        private void InitializeComponent()
        {
            SuspendLayout();

            tbNewScript        = new ButtonToolItem();
            tbNewScript.Click += tbNewScript_Click;
            tbNewScript.Image  = Bitmap.FromResource("Resources.btn_create_new.gif");

            tbLoadScript        = new ButtonToolItem();
            tbLoadScript.Click += tbLoadScript_Click;
            tbLoadScript.Image  = Bitmap.FromResource("Resources.btn_load.gif");

            tbSaveScript        = new ButtonToolItem();
            tbSaveScript.Click += tbSaveScript_Click;
            tbSaveScript.Image  = Bitmap.FromResource("Resources.btn_save.gif");

            tbRun        = new ButtonToolItem();
            tbRun.Click += tbRun_Click;
            tbRun.Image  = Bitmap.FromResource("Resources.btn_start.gif");

            ToolBar1           = new ToolBar();
            ToolBar1.TextAlign = ToolBarTextAlign.Right;
            ToolBar1.Items.AddRange(new ToolItem[] {
                tbNewScript,
                tbLoadScript,
                tbSaveScript,
                new SeparatorToolItem(),
                tbRun
            });

            txtScriptText              = new TextBoxEx();
            txtScriptText.TextChanged += mmScriptText_TextChanged;

            txtDebugOutput          = new GKUI.Components.TextBoxEx();
            txtDebugOutput.ReadOnly = true;

            splitContainer1             = new Splitter();
            splitContainer1.Orientation = Orientation.Vertical;
            splitContainer1.Panel1      = txtScriptText;
            splitContainer1.Panel2      = txtDebugOutput;
            splitContainer1.FixedPanel  = SplitterFixedPanel.Panel2;
            splitContainer1.Position    = 300;

            Content = splitContainer1;
            ToolBar = ToolBar1;

            ClientSize    = new Size(710, 430);
            Resizable     = true;
            ShowInTaskbar = true;
            Title         = "ScriptEditWin";
            Closing      += ScriptEditWin_Closing;
            KeyDown      += ScriptEditWin_KeyDown;

            UIHelper.SetPredefProperties(this, 710, 430);
            ResumeLayout();
        }
Ejemplo n.º 10
0
        public FrameworkElement CreateStringEditor()
        {
            NodePropertyPort port = ViewModel.Model as NodePropertyPort;

            TextBoxEx textBox = new TextBoxEx();

            textBox.Text = port.Value.ToString();
            textBox.SetBinding(TextBox.TextProperty, CreateBinding(port, "Value", null));
            return(textBox);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="textBox"></param>
        public KeyMacro(TextBoxEx textBox)
        {
            _textBox = textBox;

            //イベントの設定
            _textBox.ImeConverted += TextBoxEx_ImeConverted; //IMEで漢字変換が確定した時のイベント
            _textBox.KeyDown      += this.TextBoxEx_KeyDown;
            _textBox.KeyPress     += this.TextBoxEx_KeyPress;
            _textBox.KeyUp        += this.TextBoxEx_KeyUp;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取查询条件
        /// </summary>
        /// <returns></returns>
        protected string GetWhere()
        {
            StringBuilder sbWhere = new StringBuilder();

            sbWhere.Append("1=1");
            foreach (Control ctr in pnlSearch.Controls)
            {
                if (ctr.Tag == null)
                {
                    continue;
                }
                if (ctr.Tag.ToString().Length == 0)
                {
                    continue;
                }
                if (ctr is TextBoxEx)
                {
                    TextBoxEx txt    = (TextBoxEx)ctr;
                    string    strTxt = txt.Caption.Trim();
                    if (strTxt.Length > 0)
                    {
                        sbWhere.AppendFormat(" and {0} like '%{1}%'", txt.Tag, strTxt);
                    }
                }
                else if (ctr is ComboBoxEx)
                {
                    ComboBoxEx cbo    = (ComboBoxEx)ctr;
                    string     strCbo = CommonCtrl.IsNullToString(cbo.SelectedValue);
                    if (strCbo.Length > 0)
                    {
                        sbWhere.AppendFormat(" and {0}='{1}'", cbo.Tag, strCbo);
                    }
                }
                else if (ctr is TextChooser)
                {
                    TextChooser txtc    = (TextChooser)ctr;
                    string      strTxtc = txtc.Text.Trim();
                    if (strTxtc.Length > 0)
                    {
                        sbWhere.AppendFormat(" and {0}='{1}'", txtc.Tag, strTxtc);
                    }
                }
                else if (ctr is DateInterval)
                {
                    DateInterval di = (DateInterval)ctr;
                    if (!string.IsNullOrEmpty(di.StartDate) && !string.IsNullOrEmpty(di.EndDate))
                    {
                        sbWhere.AppendFormat(" and {0} between {1} and {2}", di.Tag,
                                             Common.LocalDateTimeToUtcLong(Convert.ToDateTime(di.StartDate).Date),
                                             Common.LocalDateTimeToUtcLong(Convert.ToDateTime(di.EndDate).Date.AddDays(1).AddMilliseconds(-1)));
                    }
                }
            }
            return(sbWhere.ToString());
        }
Ejemplo n.º 13
0
 public Cell(int number, Cell block, Control playingArea)
     : this(number)
 {
     txt = new TextBoxEx()
     {
         Left = block.X * (Sq * Grid + InterGap) + X * Grid,
         Top = block.Y * (Sq * Grid + InterGap) + Y * Grid
     };
     txt.ValueChanged += new EventHandler(txt_ValueChanged);
     playingArea.Controls.Add(txt);
 }
Ejemplo n.º 14
0
 public Cell(int number, Cell block, Control playingArea)
     : this(number)
 {
     txt = new TextBoxEx()
     {
         Left = block.X * (Sq * Grid + InterGap) + X * Grid,
         Top  = block.Y * (Sq * Grid + InterGap) + Y * Grid
     };
     txt.ValueChanged += new EventHandler(txt_ValueChanged);
     playingArea.Controls.Add(txt);
 }
Ejemplo n.º 15
0
        void TextBoxEx_UInt16Validating(object sender, CancelEventArgs e)
        {
            TextBoxEx textBox = sender as TextBoxEx;

            UInt16 numberEntered;

            if (!UInt16.TryParse(textBox.Text, out numberEntered))
            {
                MessageBox.Show("You need to enter an UInt16 number.");
                textBox.Text = textBox.LastValidText;
            }
        }
Ejemplo n.º 16
0
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ComboBoxEx));
     this.listBox  = new CtrlControls.ExListBox.ListBoxEx();
     this.BaseText = new CtrlControls.ExTextBox.TextBoxEx();
     this.SuspendLayout();
     //
     // listBox
     //
     this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                 | System.Windows.Forms.AnchorStyles.Right)));
     this.listBox.DrawMode          = System.Windows.Forms.DrawMode.OwnerDrawFixed;
     this.listBox.Font              = new System.Drawing.Font("宋体", 11F);
     this.listBox.FormattingEnabled = true;
     this.listBox.ItemHeight        = 35;
     this.listBox.Location          = new System.Drawing.Point(0, 20);
     this.listBox.Name              = "listBox";
     this.listBox.Size              = new System.Drawing.Size(200, 4);
     this.listBox.TabIndex          = 3;
     //
     // BaseText
     //
     this.BaseText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                   | System.Windows.Forms.AnchorStyles.Left)
                                                                  | System.Windows.Forms.AnchorStyles.Right)));
     this.BaseText.Border            = false;
     this.BaseText.BorderNormalColor = System.Drawing.Color.RoyalBlue;
     this.BaseText.BorderNormalImage = ((System.Drawing.Image)(resources.GetObject("BaseText.BorderNormalImage")));
     this.BaseText.BorderOverColor   = System.Drawing.Color.BlueViolet;
     this.BaseText.BorderOverImage   = ((System.Drawing.Image)(resources.GetObject("BaseText.BorderOverImage")));
     this.BaseText.BorderStyle       = System.Windows.Forms.BorderStyle.None;
     this.BaseText.BorderWeight      = 1F;
     this.BaseText.Font       = new System.Drawing.Font("宋体", 11F);
     this.BaseText.Location   = new System.Drawing.Point(0, 1);
     this.BaseText.Name       = "BaseText";
     this.BaseText.Size       = new System.Drawing.Size(169, 17);
     this.BaseText.TabIndex   = 2;
     this.BaseText.WaterColor = System.Drawing.Color.DarkGray;
     this.BaseText.WaterText  = "";
     //
     // ComboBoxEx
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.Controls.Add(this.listBox);
     this.Controls.Add(this.BaseText);
     this.Name = "ComboBoxEx";
     this.Size = new System.Drawing.Size(200, 19);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Ejemplo n.º 17
0
 protected void ChangeComponentSource()
 {
     foreach (Control ctrl in this.Controls)
     {
         if (ctrl is ComboBoxEx)
         {
             ComboBoxEx comb = (ComboBoxEx)ctrl;
             comb.BOID = m_boId;
         }
         else if (ctrl is TextBoxEx)
         {
             TextBoxEx txt = (TextBoxEx)ctrl;
             txt.TableSource = m_tableSource;
         }
     }
 }
Ejemplo n.º 18
0
        public HexToStrMenu(string text, TextBoxEx textbox, Encoding encoding)
        {
            this.Text = text;

            //16進数 -> 文字列
            this.Click += (sender, e) => {
                try {
                    byte[] byteArray = BinaryUtils.HexToByteArray(textbox.SelectedText);
                    textbox.SelectionStart  = textbox.SelectionStart + textbox.SelectionLength;
                    textbox.SelectionLength = 0;
                    textbox.SelectedText    = " " + encoding.GetString(byteArray);
                } catch (Exception) {
                    __.ShowErrorMsgBox("変換できませんでした。");
                }
            };
        }
//    private string GetRespondentValue(_Respondent respondent, string propName)
//    {
//      object val = null;
//      object[] indexer = new object[0];
//
//      PropertyInfo propInfo = respondent.GetType().GetProperty(propName);
//
//      if (propInfo != null)
//        val = propInfo.GetValue(respondent, indexer);
//
//      if (val != null)
//        return val.ToString();
//
//      return "";
//    }



        // Note: So far we've only figured out how to handle NumericOnly on-the-fly.
        private void TextBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            TextBoxEx  textBox = sender as TextBoxEx;
            TextFormat format  = (textBox.Tag as RespondentInfo).Formatting;

            if (format == TextFormat.NumericOnly)
            {
                char c = e.KeyChar;
                int  i = (int)c;

                if ((i == 8) || (i == 46) || char.IsNumber(c))
                {
                    // Do nothing because the character is valid
                }
                else
                {
                    e.Handled = true; // This will cancel the character input
                }
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="dbPath"></param>
        public FileInfoEditorControl(IPlugin plugin, string dbPath, string id = "")
        {
            InitializeComponent();

            //プラグインを保持します
            _plugin = plugin;

            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //DB接続用オブジェクトを生成します
            _db = new FileDB(dbPath);

            _txtMemo        = new TextBoxEx();
            _txtMemo.Parent = this;
            _txtMemo.Dock   = DockStyle.Fill;
            _txtMemo.BringToFront();
            _txtMemo.Initialize();
            _txtMemo.TextChanged += _txtMemo_TextChanged;
        }
Ejemplo n.º 21
0
        private void CreateInputString(string value, bool isPassword)
        {
            TextBoxEx textBox = new TextBoxEx();

            textBox.Parent            = this;
            textBox.Left              = 200;
            textBox.Top               = 1;
            textBox.Height            = 20;
            textBox.Width             = this.Width = textBox.Left;
            textBox.Anchor            = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            textBox.Text              = value;
            textBox.MaxLength         = _serverSetting.MaximumLength;
            textBox.AllowedCharacters = _serverSetting.AllowedCharacters;
            textBox.TextChanged      += TextBox_TextChanged;

            if (isPassword)
            {
                textBox.PasswordChar = '*';
            }
        }
Ejemplo n.º 22
0
 //清空查询
 private void btnClear_Click(object sender, EventArgs e)
 {
     foreach (Control ctr in pnlSearch.Controls)
     {
         if (ctr is TextBoxEx)
         {
             TextBoxEx txt = (TextBoxEx)ctr;
             txt.Caption = string.Empty;
         }
         else if (ctr is ComboBoxEx)
         {
             ComboBoxEx cbo = (ComboBoxEx)ctr;
             if (cbo.Items.Count > 0)
             {
                 cbo.SelectedIndex = 0;
             }
             else
             {
                 cbo.SelectedItem = null;
             }
         }
         else if (ctr is TextChooser)
         {
             TextChooser txtc = (TextChooser)ctr;
             txtc.Text = string.Empty;
             txtc.Tag  = null;
         }
         else if (ctr is CheckBox)
         {
             CheckBox cb = (CheckBox)ctr;
             cb.Checked = false;
         }
         else if (ctr is DateInterval)
         {
             DateInterval di = (DateInterval)ctr;
             di.Empty();
             di.StartDate = DateTime.Now.ToString("yyyy-MM-01");
             di.EndDate   = DateTime.Now.ToString("yyyy-MM-dd");
         }
     }
 }
        /// <summary>
        /// Examine every TextBox & ComboBox that the user could have entered data
        /// into and store this information in the module-level mRespInfoArray object.
        /// </summary>
        private void SaveUserInput()
        {
            foreach (Control ctrl in panelTopics.Contents.Controls)
            {
                bool   possValToSave = true;
                string propName;
                string newval = null;
                int    idx    = -1;

                if (ctrl.GetType().Name == "TextBoxEx")
                {
                    TextBoxEx textBox = ctrl as TextBoxEx;
                    propName = (textBox.Tag as RespondentInfo).PropName;
                    idx      = (textBox.Tag as RespondentInfo).Index;
                    newval   = textBox.Text;
                }
                else if (ctrl.GetType().Name == "ComboBoxEx")
                {
                    ComboBoxEx comboBox = ctrl as ComboBoxEx;
                    propName = (comboBox.Tag as RespondentInfo).PropName;
                    idx      = (comboBox.Tag as RespondentInfo).Index;
                    newval   = comboBox.Text;
                }
                else
                {
                    // A label, so just ignore
                    possValToSave = false;
                }

                if (possValToSave)
                {
                    // See if we have a new value to store
                    string oldval = (mRespInfoArray[idx] as RespondentInfo).Value;
                    if (oldval != newval)
                    {
                        (mRespInfoArray[idx] as RespondentInfo).Value = newval;
                        IsDirty = true;
                    }
                }
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// TextBoxEx中只能输入数字和小数点
 /// </summary>
 /// <param name="txt"></param>
 public static void TextToDecimal(TextBoxEx txt)
 {
     //键盘按下事件KeyPress
     txt.KeyPress += delegate(object sender, KeyPressEventArgs e)
     {
         if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != 13 && e.KeyChar != 46)
         {
             e.Handled = true;
         }
         if (e.KeyChar == 46 && txt.Caption.Contains("."))
         {
             e.Handled = true;
         }
     };
     //textbox失去焦点事件leave
     txt.Leave += delegate(object sender, EventArgs e)
     {
         string Money = txt.Caption.Trim();
         Regex  regex = new Regex(@"^([1-9][0-9]*|0)(\.[0-9]+)?$");
         if (Money == "")
         {
             txt.Caption = "0";
         }
         if (!regex.Match(Money).Success)
         {
             txt.Caption = "0";
         }
         else
         {
             if (Money.IndexOf(".") == 0)
             {
                 txt.Caption = "0";
             }
             if (txt.Caption != "0")
             {
                 txt.Caption = Math.Round(Convert.ToDecimal(Money), 2).ToString("0.##");
             }
         }
     };
 }
        protected override void InitializeControls()
        {
            flexChart1 = new FlexChart();
            this.Chart = flexChart1;

            _lXTitle  = new LabelEx("X-Axis Title:");
            _tbXTitle = new TextBoxEx {
                ForeColor = Color.DimGray, AutoSize = false
            };
            _tbXTitle.TextChanged += (s, e) => { flexChart1.AxisX.Title = _tbXTitle.Text; };

            _lYTitle  = new LabelEx("Y-Axis Title:");
            _tbYTitle = new TextBoxEx {
                ForeColor = Color.DimGray, AutoSize = false
            };
            _tbYTitle.TextChanged += (s, e) => { flexChart1.AxisY.Title = _tbYTitle.Text; };

            this.pnlControls.Controls.Add(_lXTitle);
            this.pnlControls.Controls.Add(_tbXTitle);
            this.pnlControls.Controls.Add(_lYTitle);
            this.pnlControls.Controls.Add(_tbYTitle);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// 清除查询面板
 /// </summary>
 /// <param name="pnlSearch">查询面板</param>
 public void ClearSearch(Panel pnlSearch)
 {
     foreach (Control ctr in pnlSearch.Controls)
     {
         if (ctr is TextBoxEx)
         {
             TextBoxEx txt = (TextBoxEx)ctr;
             txt.Caption = string.Empty;
         }
         else if (ctr is ComboBoxEx)
         {
             ComboBoxEx cbo = (ComboBoxEx)ctr;
             if (cbo.Items.Count > 0)
             {
                 cbo.SelectedIndex = 0;
             }
             else
             {
                 cbo.SelectedItem = null;
             }
         }
         else if (ctr is TextChooser)
         {
             TextChooser txtc = (TextChooser)ctr;
             txtc.Text = string.Empty;
             txtc.Tag  = null;
         }
         else if (ctr is CheckBox)
         {
             CheckBox cb = (CheckBox)ctr;
             cb.Checked = false;
         }
         else if (ctr is DateInterval)
         {
             DateInterval di = (DateInterval)ctr;
             di.Empty();
         }
     }
 }
    static public TextBoxEx GetTextBoxAndFocus(object sender, bool doFocus = true)
    {
        TextBoxEx control = sender as TextBoxEx;

        if (control is null)
        {
            if (sender is ContextMenuStrip menuContext)
            {
                control = menuContext.SourceControl as TextBoxEx;
            }
            else
            if (sender is ToolStripMenuItem menuItem)
            {
                control = (menuItem.GetCurrentParent() as ContextMenuStrip)?.SourceControl as TextBoxEx;
            }
        }
        if (control is null)
        {
            var form = FormsHelper.GetActiveForm();
            if (form is not null)
            {
                if (form.ActiveControl is TextBoxEx)
                {
                    control = form.ActiveControl as TextBoxEx;
                }
                else
                if (form.ActiveControl is UserControl)
                {
                    control = (form.ActiveControl as UserControl)?.ActiveControl as TextBoxEx;
                }
            }
        }
        if (doFocus && control?.Enabled == true && !control.Focused)
        {
            control.Focus();
        }
        return(control);
    }
Ejemplo n.º 28
0
        protected override void OnLoad(EventArgs e)
        {
            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is ComboBoxEx)
                {
                    ComboBoxEx comb = (ComboBoxEx)ctrl;
                    comb.DefineNewProc = new DeleDefineNewProc(ComboBoxDefineNewProc);
                    comb.InitSource();
                }
            }

            base.OnLoad(e);

            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is ObjectGrid)
                {
                    ObjectGrid objGrid = (ObjectGrid)ctrl;
                    objGrid.ItemsChanged += new EventHandler <BrightIdeasSoftware.ItemsChangedEventArgs>(objGrid_ItemsChanged);
                }
                else if (ctrl is ComboBoxEx)
                {
                    ComboBoxEx comb = (ComboBoxEx)ctrl;
                    comb.SelectedValueChanged += new EventHandler(comb_SelectedIndexChanged);
                }
                else if (ctrl is TextBoxEx)
                {
                    TextBoxEx txt = (TextBoxEx)ctrl;
                    txt.TextChanged += new EventHandler(txt_TextChanged);
                }
                else if (ctrl is RichTextBoxEx)
                {
                    RichTextBoxEx rtxt = (RichTextBoxEx)ctrl;
                    rtxt.TextChanged += new EventHandler(rtxt_TextChanged);
                }
            }
        }
    private static void AddTab(TabControl tabcontrol, DataFile file)
    {
        if (!File.Exists(file.FilePath))
        {
            DisplayManager.ShowError(SysTranslations.FileNotFound.GetLang(file.FilePath));
            return;
        }
        var textbox = new TextBoxEx
        {
            Font       = new Font("Consolas", 9.75F),
            Multiline  = true,
            WordWrap   = false,
            ScrollBars = ScrollBars.Both,
            Dock       = DockStyle.Fill,
            Text       = File.ReadAllText(file.FilePath)
        };
        var tabpage = new TabPage(Path.GetFileName(file.FilePath).Replace(".txt", string.Empty))
        {
            Tag = file
        };

        tabpage.Controls.Add(textbox);
        tabcontrol.TabPages.Add(tabpage);
    }
Ejemplo n.º 30
0
        IPlugin _plugin; //操作対象プラグイン。改行コードを持つプラグインの場合に、改行コードを取得するのに使用。

        public StrToHexMenu(string text, IPlugin plugin, TextBoxEx textbox, Encoding encoding)
        {
            this.Text = text;
            _plugin   = plugin;

            //文字列 -> 16進数
            this.Click += (sender, e) => {
                try {
                    //改行コードを変更します
                    string newLineCode = "\r\n";
                    if (_plugin is INewLinePlugin)
                    {
                        newLineCode = ((INewLinePlugin)_plugin).NewLineCode;
                    }
                    string targetText = textbox.SelectedText.Replace("\n", newLineCode);

                    byte[] byteArray = encoding.GetBytes(targetText);
                    textbox.SelectionStart  = textbox.SelectionStart + textbox.SelectionLength;
                    textbox.SelectionLength = 0;

                    textbox.SelectedText = " " + BinaryUtils.ByteArrayToHex(byteArray);
                } catch (Exception) { }
            };
        }
Ejemplo n.º 31
0
        public Form BuildForm(String title = "")
        {
            UI.SaveConfigurationTemplateForm ret = new UI.SaveConfigurationTemplateForm();
            DataFieldControl.Clear();
            ToolTip tip = new ToolTip();

            this.Value = IniReader.Deserialize <T>(this.TargetFileName, HandleDeserializeField);
            List <GroupBox> groupBoxs = new List <GroupBox>();

            if (String.IsNullOrEmpty(title))
            {
                title = this.TargetFileName;
            }
            ret.Text    = title;
            ret.TipText = "設定(點選欄位/標籤可以看到欄位敘述)";


            foreach (String g in FieldCategoryMap.Keys)
            {
                GroupBox gbox = new GroupBox();
                groupBoxs.Add(gbox);
                gbox.Margin = new Padding(3);
                List <String>    names       = FieldCategoryMap[g];
                TableLayoutPanel tablelayout = new TableLayoutPanel();
                tablelayout.RowCount    = names.Count;
                tablelayout.ColumnCount = 2;
                tablelayout.AutoScroll  = true;
                for (int i = 0; i < 2; ++i)
                {
                    ColumnStyle rs = new ColumnStyle();
                    tablelayout.ColumnStyles.Add(rs);
                    tablelayout.ColumnStyles[i].SizeType = SizeType.Percent;
                    tablelayout.ColumnStyles[i].Width    = 0.5f;
                }

                if (String.IsNullOrEmpty(g))
                {
                    gbox.Text = "Default";
                }
                else
                {
                    gbox.Text = g;
                }

                int row = 0;

                foreach (String name in names)
                {
                    IniReader.OnSerializeNotificationEventArgs arg = FieldDeserializeMap[name];
                    if (arg.Field.FieldType.IsClass)
                    {
                        if (arg.Field.FieldType != typeof(String) &&
                            arg.Field.FieldType != typeof(Rectangle) &&
                            arg.Field.FieldType != typeof(Size) &&
                            arg.Field.FieldType != typeof(Point) &&
                            arg.Field.FieldType != typeof(Color) &&
                            arg.Field.FieldType != typeof(int[]))
                        {
                            continue;
                        }
                    }

                    FieldDisplayNameAttribute   displayName = (FieldDisplayNameAttribute)arg.Field.GetCustomAttribute(typeof(FieldDisplayNameAttribute), true);
                    DescriptionAttribute        description = (DescriptionAttribute)arg.Field.GetCustomAttribute(typeof(DescriptionAttribute), true);
                    CategoryAttribute           category    = (CategoryAttribute)arg.Field.GetCustomAttribute(typeof(CategoryAttribute), true);
                    AttributeConfigureUIVisible visible     = (AttributeConfigureUIVisible)arg.Field.GetCustomAttribute(typeof(AttributeConfigureUIVisible), true);

                    RowStyle rs = new RowStyle();
                    if (ShowAll || visible == null || visible.Visible)
                    {
                        tablelayout.RowStyles.Add(rs);
                        rs.SizeType = SizeType.Absolute;
                        rs.Height   = 30;
                    }
                    String descriptionTxt = "";
                    if (description != null)
                    {
                        descriptionTxt = description.Description;
                    }
                    else
                    {
                        descriptionTxt = name;
                    }
                    EventHandler focusHandler = new EventHandler((object s, EventArgs e) =>
                    {
                        ret.TipText = descriptionTxt;
                    });
                    Panel left  = new Panel();
                    Panel right = new Panel();
                    left.Dock    = DockStyle.Fill;
                    right.Dock   = DockStyle.Fill;
                    left.Margin  = new Padding(0);
                    right.Margin = new Padding(0);
                    Label  nameLabel = new Label();
                    String strname   = GetPropertyDisplayName(arg.Field);
                    if (String.IsNullOrEmpty(strname))
                    {
                        strname = arg.FullName;
                    }
                    if (displayName != null)
                    {
                        nameLabel.Text = String.Format("{0}({1})", displayName.DisplayName, strname);
                    }
                    else
                    {
                        nameLabel.Text = strname;
                    }
                    nameLabel.Dock      = DockStyle.Fill;
                    nameLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
                    nameLabel.Click    += focusHandler;
                    left.Controls.Add(nameLabel);
                    IniReader reader              = arg.Reader;
                    Type      fieldType           = arg.Field.FieldType;
                    bool      customEditorHandled = false;
                    if (OnCustomEditorNeeded != null)
                    {
                        CustomFormEditEventArg args = new CustomFormEditEventArg();
                        args.FieldName    = name;
                        args.DisplayName  = strname;
                        args.Description  = descriptionTxt;
                        args.Value.Value  = arg.FieldValue;
                        args.SerializeArg = arg;
                        OnCustomEditorNeeded(this, args);
                        if (args.Handled)
                        {
                            if (args.CustomControl != null)
                            {
                                Control ctrl = args.CustomControl;
                                ctrl.Size      = new Size(100, (int)(rs.Height));
                                ctrl.Dock      = DockStyle.Fill;
                                ctrl.Tag       = arg.FullName;
                                ctrl.GotFocus += focusHandler;
                                right.Controls.Add(ctrl);
                                customEditorHandled = true;
                            }
                        }
                    }
                    if (!customEditorHandled)
                    {
                        if (fieldType == typeof(Color))
                        {
                            Button btn = new Button();
                            btn.Size      = new Size(100, (int)(rs.Height));
                            btn.BackColor = (Color)arg.FieldValue;
                            btn.Dock      = DockStyle.Fill;
                            btn.Click    += btn_colorPickerClick;
                            right.Controls.Add(btn);
                            btn.Tag       = arg.FullName;
                            btn.GotFocus += focusHandler;
                            this.DataFieldControl.Add(btn);
                        }
                        else if (fieldType == typeof(bool))
                        {
                            ComboBox cbox = new ComboBox();
                            cbox.DropDownStyle = ComboBoxStyle.DropDownList;
                            cbox.Items.Add("false");
                            cbox.Items.Add("true");
                            cbox.Dock = DockStyle.Fill;
                            cbox.Text = (String)arg.FieldValue.ToString().ToLower();
                            right.Controls.Add(cbox);
                            cbox.Tag       = arg.FullName;
                            cbox.GotFocus += focusHandler;
                            this.DataFieldControl.Add(cbox);
                        }
                        else
                        {
                            if (fieldType.IsEnum)
                            {
                                ComboBox cbox = new ComboBox();
                                cbox.DropDownStyle = ComboBoxStyle.DropDownList;
                                var enumNames = fieldType.GetEnumNames();
                                cbox.Items.AddRange(enumNames);
                                cbox.Dock = DockStyle.Fill;
                                String val = "";
                                if (arg.FieldValue != null)
                                {
                                    val = arg.FieldValue.ToString();
                                }
                                cbox.Text = val;
                                right.Controls.Add(cbox);
                                cbox.Tag       = arg.FullName;
                                cbox.GotFocus += focusHandler;
                                this.DataFieldControl.Add(cbox);
                            }
                            else
                            {
                                TextBoxEx tbox = new TextBoxEx();
                                tbox.Size            = new Size(100, (int)(rs.Height));
                                tbox.Dock            = DockStyle.Fill;
                                tbox.IsChangeTracked = true;
                                right.Controls.Add(tbox);
                                tbox.Tag       = arg.FullName;
                                tbox.Text      = (String)arg.FieldValue.ToString();
                                tbox.GotFocus += focusHandler;
                                tbox.Click    += (s, e) =>
                                {
                                    if (OnCustomForm != null)
                                    {
                                        CustomFormEditEventArg args = new CustomFormEditEventArg();
                                        args.FieldName    = name;
                                        args.DisplayName  = strname;
                                        args.Description  = descriptionTxt;
                                        args.Value        = tbox.Text;
                                        args.SerializeArg = arg;
                                        OnCustomForm(this, args);
                                        if (args.Handled)
                                        {
                                            tbox.Text = args.Value.ToString();
                                        }
                                    }
                                };
                                this.DataFieldControl.Add(tbox);
                            }
                        }
                    }
                    if (ShowAll || visible == null || visible.Visible)
                    {
                        tablelayout.Height += ((int)(rs.Height));

                        tablelayout.Controls.Add(left);
                        tablelayout.Controls.Add(right);

                        tablelayout.SetCellPosition(left, new TableLayoutPanelCellPosition(0, row));
                        tablelayout.SetCellPosition(right, new TableLayoutPanelCellPosition(1, row));
                        ++row;
                    }
                }
                tablelayout.Dock = DockStyle.Fill;
                gbox.Height      = tablelayout.Height;
                gbox.Controls.Add(tablelayout);
            }

            foreach (var g in groupBoxs)
            {
                if (ret.MainPanel.Controls.Count == 0)
                {
                    g.Location = new Point(0, 0);
                }
                else
                {
                    Control lastCtrl = ret.MainPanel.Controls[ret.MainPanel.Controls.Count - 1];
                    g.Location = new Point(0, lastCtrl.Bottom);
                }
                g.Width  = ret.MainPanel.Width;
                g.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

                ret.MainPanel.Controls.Add(g);
            }
            ret.OKClicked += ret_OKClicked;
            return(ret);
        }
Ejemplo n.º 32
0
        protected override void CreateChildControls()
        {
            Controls.Clear();

            _txtBox = new TextBoxEx();
            _txtBox.ID = "TB";
            _txtBox.TextChanged += new EventHandler(_txtBox_TextChanged);

            _img = new Image();
            _img.ID = "CDD";

            this.Controls.Add(_txtBox);
            this.Controls.Add(_img);
        }