Select() private method

private Select ( Control control ) : bool
control Control
return bool
Example #1
0
        private void EditItem(int index, ListViewItem.ListViewSubItem sb)
        {
            if (this.SelectedItems.Count <= 0)
            {
                return;
            }
            int currentSelectColumnIndex = _mCtrls.IndexOfKey(index);

            if (currentSelectColumnIndex == -1)
            {
                return;
            }
            _currentCtrl = (System.Windows.Forms.Control)_mCtrls.Values[currentSelectColumnIndex];
            ListViewItem item  = this.SelectedItems[0];
            Rectangle    rect  = sb.Bounds;
            Rectangle    _rect = new Rectangle(rect.Right - this.Columns[index].Width, rect.Top, this.Columns[index].Width, rect.Height);

            _currentCtrl.Bounds = _rect;
            _currentCtrl.BringToFront();
            _currentCtrl.Text         = item.SubItems[index].Text;
            _currentCtrl.TextChanged += CtrTextChanged;
            _currentCtrl.Leave       += CtrLeave;

            _currentCtrl.Visible = true;
            _currentCtrl.Tag     = item;
            _currentCtrl.Select();
        }
Example #2
0
        public bool ActivateControl(Control ctrl)
        {
            if (Controls.Contains(ctrl))
            {
                ctrl.Select();
                activeControl = ctrl;
                return true;
            }

            return false;
        }
Example #3
0
 public static void AfterAllClear(Control rate, Control pokemonNames)
 {
     if (Settings.Default.NoInputRate) {
         pokemonNames.BeginInvoke((MethodInvoker)(() => {
             pokemonNames.Select();
         }));
     } else {
         rate.BeginInvoke((MethodInvoker)(() => {
             rate.Select();
         }));
     }
 }
        /// <summary>
        /// 检查文件输入框中的文件是否存在
        /// </summary>
        /// <param name="txt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool CheckFileNameTextBox(System.Windows.Forms.Control txt, string msg)
        {
            var fn = txt.Text.Trim();

            if (fn == null || fn.Length == 0 || File.Exists(fn) == false)
            {
                MessageBox.Show(this, msg);
                txt.Focus();
                txt.Select();
                return(false);
            }
            return(true);
        }
Example #5
0
        /// <summary>
        /// Focuses on the setting control at the specified <paramref name="location"/>.
        /// </summary>
        /// <param name="location">Location of the config control to focus.</param>
        private void FocusControl(string location)
        {
            string section = GetSectionPath(_treeSections.SelectedNode);

            if (section.Length >= location.Length)
            {
                return;
            }
            location = location.Substring(section.Length);
            FormControl control = GetFormControl(location);

            if (control.CanSelect)
            {
                control.Select();
            }
        }
Example #6
0
        /// <summary>
        /// 判断字符串是否为空
        /// </summary>
        /// <param name="Control">输入控件</param>
        /// <param name="message">提示信息</param>
        /// <returns>是否为空</returns>
        public static bool CheckEmpty(System.Windows.Forms.Control Control, string message)
        {
            // 返回值
            bool returnValue = true;

            if (Control.Text.Length == 0)
            {
                returnValue = false;
                Control.Focus();
                Control.Select();
                if (message.Length > 0)
                {
                    System.Windows.Forms.MessageBox.Show(message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            return(returnValue);
        }
Example #7
0
 internal static bool FileExists(Control tb) {
     if (File.Exists(tb.Text))
         return true;
     tb.Select();
     return false;
 }
Example #8
0
 internal static bool IsCommand(Control tb) {
     if (tb.Text.Trim().Length != 0)
         return true;
     tb.Select();
     return false;
 }
 private static void SelectNextActiveControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
 {
     ContainerControl control = ctl as ContainerControl;
     if (control != null)
     {
         bool flag = true;
         if (control.ParentInternal != null)
         {
             IContainerControl containerControlInternal = control.ParentInternal.GetContainerControlInternal();
             if (containerControlInternal != null)
             {
                 containerControlInternal.ActiveControl = control;
                 flag = containerControlInternal.ActiveControl == control;
             }
         }
         if (flag)
         {
             ctl.SelectNextControl(null, forward, tabStopOnly, nested, wrap);
         }
     }
     else
     {
         ctl.Select();
     }
 }
Example #10
0
		public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
			Control c;

#if DebugFocus
			Console.WriteLine("{0}", this.FindForm());
			printTree(this, "\t");
#endif

			if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
				ctl = null;
			}
			c = ctl;
			do {
				c = GetNextControl(c, forward);
				if (c == null) {
					if (wrap) {
						wrap = false;
						continue;
					}
					break;
				}

#if DebugFocus
				Console.WriteLine("{0} {1}", c, c.CanSelect);
#endif
				if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
					c.Select (true, true);
					return true;
				}
			} while (c != ctl); // If we wrap back to ourselves we stop

			return false;
		}
Example #11
0
		/// <summary>
		/// Create and install an object to fill the content area of the window, after asking the current
		/// content object if it is willing to go away.
		/// </summary>
		protected void ChangeContentObjectIfPossible(string contentAssemblyPath, string contentClass, XmlNode contentClassNode)
		{
			// This message often gets sent twice with the same values during startup. We save a LOT of time if
			// we don't throw one copy away and make another.
			if (m_mainContentControl != null && contentAssemblyPath == m_lastContentAssemblyPath
				&& contentClass == m_lastContentClass && contentClassNode == m_lastContentClassNode)
			{
				return;
			}


			if (m_mainContentControl != null)
			{
				// First, see if the existing content object is ready to go away.
				if (!MainContentControlAsIxCoreContentControl.PrepareToGoAway())
					return;

				PropertyTable.SetProperty("currentContentControlObject", null, false);
				PropertyTable.SetPropertyPersistence("currentContentControlObject", false);

				m_mediator.RemoveColleague(MainContentControlAsIxCoreColleague);
				foreach (IxCoreColleague icc in MainContentControlAsIxCoreColleague.GetMessageTargets())
					m_mediator.RemoveColleague(icc);

				// Dispose the current content object.
				//m_mainContentControl.Hide();
				//m_secondarySplitContainer.SecondControl = m_mainContentPlaceholderPanel;
				// Hide the first pane for sure so that MultiPane's internal splitter will be set
				// correctly.  See LT-6515.
				m_mediator.PropertyTable.SetProperty("ShowRecordList", false, false);
				m_secondarySplitContainer.Panel1Collapsed = true;
				m_mainContentControl.Dispose(); // before we create the new one, it inactivates the Clerk, which the new one may want active.
				m_mainContentControl = null;
			}

			m_lastContentAssemblyPath = contentAssemblyPath;
			m_lastContentClass = contentClass;
			m_lastContentClassNode = contentClassNode;

			if (contentAssemblyPath != null)
			{
				// create the new content object
				try
				{
					m_secondarySplitContainer.Panel2.SuspendLayout();
					Control mainControl = (Control)DynamicLoader.CreateObject(contentAssemblyPath, contentClass);
					if (!(mainControl is IxCoreContentControl))
					{
						m_mainSplitContainer.SecondControl = m_mainContentPlaceholderPanel;
						throw new ApplicationException("XCore can only handle main controls which implement IxCoreContentControl. " + contentClass + " does not.");
					}
					mainControl.SuspendLayout();
					m_mainContentControl = mainControl;
					m_mainContentControl.Dock = System.Windows.Forms.DockStyle.Fill;
					m_mainContentControl.AccessibleDescription = "XXXXXXXXXXXX";
					m_mainContentControl.AccessibleName = contentClass;
					m_mainContentControl.TabStop = true;
					m_mainContentControl.TabIndex = 1;
					XmlNode parameters = null;
					if (contentClassNode != null)
						parameters = contentClassNode.SelectSingleNode("parameters");
					m_secondarySplitContainer.SetSecondCollapseZone(parameters);
					MainContentControlAsIxCoreColleague.Init(m_mediator, parameters);
					// We don't want it or any part of it drawn until we're done laying out.
					// Also, layout tends not to actually happen until we make it visible, which further helps avoid duplication,
					// and makes sure the user doesn't see any intermediate state.
					m_mainContentControl.Visible = false;
					m_secondarySplitContainer.SecondControl = m_mainContentControl;
					mainControl.ResumeLayout(false);
					var mainContentAsPostInit = m_mainContentControl as IPostLayoutInit;

					//this was added because the user may switch to a control through some UI vector that does not
					//first set the appropriate area. Doing this will lead to the appropriate area button being highlighted, and also
					//help other things which depend on the accuracy of this "areaChoice" property.
					PropertyTable.SetProperty("currentContentControlObject", m_mainContentControl);
					PropertyTable.SetPropertyPersistence("currentContentControlObject", false);
					PropertyTable.SetProperty("areaChoice", MainContentControlAsIxCoreContentControl.AreaName);

					if (contentClassNode != null && contentClassNode.ParentNode != null)
						SetToolDefaultProperties(contentClassNode.ParentNode.SelectSingleNode("defaultProperties"));

					m_mainContentControl.BringToFront();
					m_secondarySplitContainer.Panel2.ResumeLayout();
					if (mainContentAsPostInit != null)
						mainContentAsPostInit.PostLayoutInit();
					m_mainContentControl.Visible = true;
					m_mainContentControl.Select();
				}
				catch (Exception error)
				{
					m_mainContentControl = null;
					m_secondarySplitContainer.SecondControl = m_mainContentPlaceholderPanel;
					m_secondarySplitContainer.Panel2.ResumeLayout();
					string s = "Something went wrong trying to create a " + contentClass + ".";
					ErrorReporter.ReportException(new ApplicationException(s, error),
						ApplicationRegistryKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress);
				}
			}
		}
Example #12
0
		public void EnterLeaveFocusEventTest ()
		{
			if (TestHelper.RunningOnUnix) {
				Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE");
			}

			Form f = new Form();
			f.ShowInTaskbar = false;

			f.Name = "Form1";
			ContainerControl cc0 = new ContainerControl();
			cc0.Name = "ContainerControl 0";
			ContainerControl cc1 = new ContainerControl();
			cc1.Name = "ContainerControl 1";
			ContainerControl cc2 = new ContainerControl();
			cc2.Name = "ContainerControl 2";
			Control c1 = new Control();
			c1.Name = "Control 1";
			Control c2 = new Control();
			c2.Name = "Control 2";

			connect(f);
			connect(cc0);
			connect(cc1);
			connect(cc2);
			connect(c1);
			connect(c2);

			cc0.Controls.Add(cc1);
			cc0.Controls.Add(cc2);
			cc1.Controls.Add(c1);
			cc2.Controls.Add(c2);

			f.Controls.Add(cc0);

			sb = new StringBuilder ();
			f.Show ();
			c1.Select();

			Assert.AreEqual (@"OnEnter: ContainerControl 0 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
OnEnter: Control 1 System.Windows.Forms.Control
OnGotFocus: Control 1 System.Windows.Forms.Control
",
					 sb.ToString (), "1");

			sb.Length = 0;
			c2.Select();
			Assert.AreEqual (@"OnLeave: Control 1 System.Windows.Forms.Control
OnLeave: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidating: Control 1 System.Windows.Forms.Control
OnValidated: Control 1 System.Windows.Forms.Control
OnValidating: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 1 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 2 System.Windows.Forms.ContainerControl
OnEnter: Control 2 System.Windows.Forms.Control
OnLostFocus: Control 1 System.Windows.Forms.Control
OnGotFocus: Control 2 System.Windows.Forms.Control
",
					 sb.ToString (), "2");

			sb.Length = 0;
			cc1.Select();
			Assert.AreEqual (@"OnLeave: Control 2 System.Windows.Forms.Control
OnLeave: ContainerControl 2 System.Windows.Forms.ContainerControl
OnValidating: Control 2 System.Windows.Forms.Control
OnValidated: Control 2 System.Windows.Forms.Control
OnValidating: ContainerControl 2 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 2 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
OnLostFocus: Control 2 System.Windows.Forms.Control
OnGotFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
",
					 sb.ToString (), "3");

			sb.Length = 0;
			cc2.Select();
			Assert.AreEqual (@"OnLeave: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidating: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 1 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 2 System.Windows.Forms.ContainerControl
OnLostFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
OnGotFocus: ContainerControl 2 System.Windows.Forms.ContainerControl
",
					 sb.ToString (), "4");

			Assert.IsNull (cc2.ActiveControl, "5");

			sb.Length = 0;
			c2.Select();
			Assert.AreEqual (@"OnEnter: Control 2 System.Windows.Forms.Control
OnLostFocus: ContainerControl 2 System.Windows.Forms.ContainerControl
OnGotFocus: Control 2 System.Windows.Forms.Control
",
					 sb.ToString (), "6");

			sb.Length = 0;
			cc1.Select();
			Assert.AreEqual (@"OnLeave: Control 2 System.Windows.Forms.Control
OnLeave: ContainerControl 2 System.Windows.Forms.ContainerControl
OnValidating: Control 2 System.Windows.Forms.Control
OnValidated: Control 2 System.Windows.Forms.Control
OnValidating: ContainerControl 2 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 2 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
OnLostFocus: Control 2 System.Windows.Forms.Control
OnGotFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
",
					 sb.ToString (), "7");

			sb.Length = 0;
			f.Select();
			Assert.AreEqual ("", sb.ToString (), "8");

			f.Dispose ();
		}
Example #13
0
        private void gdiControlGrid_MouseWheel(object sender, MouseEventArgs e)
        {
            if (!String.IsNullOrEmpty(gdiControlGrid.ActiveControl.AccessibleName))
            {
                float val;
                System.Windows.Forms.Control c = gdiControlGrid.ActiveControl;
                switch (gdiControlGrid.ActiveControl.AccessibleName.Replace("\t", ""))
                {
                case "X":
                case "Y":
                case "Start Angle":
                case "Sweep Angle":
                case "Starting X":
                case "Starting Y":
                case "Control Point One X":
                case "Control Point One Y":
                case "Control Point Two X":
                case "Control Point Two Y":
                case "Ending X":
                case "Ending Y":
                    if (float.TryParse(gdiControlGrid.ActiveControl.Text, out val))
                    {
                        if (e.Delta > 0)
                        {
                            val += .1f;
                        }
                        else
                        {
                            val -= .1f;
                        }
                        c.AccessibilityObject.Value = val.ToString();
                        gdiControlGrid.Refresh();
                        c.Select();
                    }
                    break;

                case "X-Axis Grid Multiple":
                case "Y-Axis Grid Multiple":
                case "Pen Width":
                case "Width":
                case "Height":
                    if (float.TryParse(gdiControlGrid.ActiveControl.Text, out val))
                    {
                        if (e.Delta > 0)
                        {
                            val += .1f;
                        }
                        else
                        {
                            if (val > 1)
                            {
                                val -= .1f;
                            }
                        }
                        c.AccessibilityObject.Value = val.ToString();
                        gdiControlGrid.Refresh();
                        c.Select();
                    }
                    break;

                case "PNG Size Multiple":
                case "Display Size Multiple":
                case "Point Size Multiple":
                    if (float.TryParse(gdiControlGrid.ActiveControl.Text, out val))
                    {
                        if (e.Delta > 0)
                        {
                            val += 1;
                        }
                        else
                        {
                            if (val > 1)
                            {
                                val -= 1;
                            }
                        }
                        c.AccessibilityObject.Value = val.ToString();
                        gdiControlGrid.Refresh();
                        c.Select();
                    }
                    break;

                case "Point Index":
                    if (float.TryParse(gdiControlGrid.ActiveControl.Text, out val))
                    {
                        if (e.Delta > 0)
                        {
                            val += 1;
                        }
                        else
                        {
                            if (val >= 1)
                            {
                                val -= 1;
                            }
                        }
                        c.AccessibilityObject.Value = val.ToString();
                        gdiControlGrid.Refresh();
                        c.Select();
                    }
                    break;
                }
            }
        }
Example #14
0
        /// <summary>
        /// Validates user input
        /// </summary>
        /// <param name="control">The control to be validated</param>
        /// <returns>Returns true or false is the input is valid</returns>
        public bool IsValidData(Control control)
        {
            #region Input Validation
            if (control == null)
            {
                throw new ArgumentNullException("Control");
            }
            #endregion  //Input Validation

            // Prevents the 'Invalid data' warning from showing up if the user selects 'No' to saving the record
            if (mainForm == null || mainForm.FormClosed)
            {
                return true;
            }

            ControlFactory factory = ControlFactory.Instance;
            Field field = factory.GetAssociatedField(control);
            bool isValid = true;

            if (field is NumberField)
            {
                ((MaskedTextBox)control).TextMaskFormat = MaskFormat.IncludeLiterals;

                string decimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

                if (!String.IsNullOrEmpty(control.Text) && !control.Text.Trim().Equals(decimalSeparator))
                {
                    if (field is IPatternable)
                    {
                        string pattern = ((IPatternable)field).Pattern;
                        if (control.Text.Length > 39 && pattern == "None")
                        {
                            MsgBox.ShowWarning(SharedStrings.MAX_NONE_MASK_DIGITS_EXCEEDED);
                            control.Select();
                            isValid = false;
                        }
                        else
                        {
                            try
                            {
                                // Test what is in the box. If we catch a format exception then the
                                // user entered something bad, like -- or just a decimal point. They
                                // may also have entered some text if the field doesn't have a pattern.                               // doesn't have a pattern.
                                string TestNumber = control.Text.Replace(" ", "");

                                //!float.TryParse(TestNumber, out temp)

                                float temp;
                                if (float.TryParse(TestNumber, out temp))
                                {
                                    temp = float.Parse(TestNumber, System.Globalization.NumberStyles.Any);
                                    ((MaskedTextBox)control).Text = FormatNumberInput(TestNumber, ((MaskedTextBox)control).Mask);
                                    ((MaskedTextBox)control).TextMaskFormat = MaskFormat.IncludeLiterals;
                                    string format = AppData.Instance.DataPatternsDataTable.GetExpressionByMask(((MaskedTextBox)(control)).Mask.ToString(), ((IPatternable)field).Pattern);
                                    bool result;
                                    double doubleNumber;
                                    result = Double.TryParse(((MaskedTextBox)control).Text, out doubleNumber);
                                    if (result)
                                    {
                                        NumberField checkedField = (NumberField)field;
                                        if (!string.IsNullOrEmpty(checkedField.Lower) && !string.IsNullOrEmpty(checkedField.Upper))
                                        {
                                            if ((double.Parse(checkedField.Lower) > doubleNumber) || (doubleNumber > double.Parse(checkedField.Upper)))
                                            {
                                                //FIX for DEFECT 1080
                                                MsgBox.ShowWarning(String.Format(SharedStrings.VALUE_NOT_IN_RANGE, checkedField.Lower, checkedField.Upper));
                                                control.Select();
                                                isValid = false;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    MsgBox.ShowInformation(SharedStrings.ENTER_VALID_NUMBER);
                                    control.Select();
                                    isValid = false;
                                }
                            }
                            catch (FormatException)
                            {
                                MsgBox.ShowWarning(SharedStrings.ENTER_VALID_NUMBER);
                                control.Text = string.Empty;
                                control.Select();
                                isValid = false;
                            }
                        }
                    }
                }
            }
            else if (field is DateField)
            {
                DateTime dateTime;
                bool canParse = DateTime.TryParse(control.Text, out dateTime);

                if (string.IsNullOrEmpty(control.Text)) return true;

                DateTimeFormatInfo formatInfo = DateTimeFormatInfo.CurrentInfo;
                string pattern = formatInfo.ShortDatePattern.ToUpper();

                if (control.Text.Equals(pattern)) return true;

                if (canParse == false)
                {
                    ShowValidationError(control);
                    control.Select();
                    return false;
                }

                if (dateTime < new DateTime(1800, 1, 1))
                {
                    ShowValidationError(control);
                  control.Select();
                    return false;
                }

                if (((DateField)field).IsInRange(dateTime) == false)
                {
                    control.Select();
                    isValid = false;
                }
            }
            else
            {
                //Ensure text entered in combobox text exists within the combobox's items
                if (control is ComboBox)
                {
                    if (!string.IsNullOrEmpty(control.Text.Trim()))
                    {
                        int index = ((ComboBox)control).FindStringExact(control.Text.Trim(), -1);
                        bool bdoit = false;
                        if (index == -1)
                        {
                            if (field is YesNoField)
                            {

                                MsgBox.ShowInformation(String.Format(SharedStrings.INVALID_YES_NO_VALUE, config.Settings.RepresentationOfYes, config.Settings.RepresentationOfNo));
                                //EpiMessages msgs;
                                //msgs.Caption = String.Format(SharedStrings.INVALID_YES_NO_VALUE_CAPTION, config.Settings.RepresentationOfYes, config.Settings.RepresentationOfNo);
                                //msgs.Message = String.Format(SharedStrings.INVALID_YES_NO_VALUE, config.Settings.RepresentationOfYes, config.Settings.RepresentationOfNo);
                                //bdoit = this.MainForm.Module.Processor.onCommunicateUI(msgs, MessageType.OkOnly);

                                //if (bdoit)
                                {
                                    ((ComboBox)control).SelectedIndex = -1;
                                    control.Text = String.Empty;
                                    control.Focus();
                                    isValid = false;
                                }
                            }
                            else
                            {
                                if (((ComboBox)control).FindString(control.Text) != -1)
                                {
                                    ((ComboBox)control).SelectedIndex = ((ComboBox)control).FindString(((ComboBox)control).Text);
                                    isValid = true;
                                }
                                else
                                {
                                    MsgBox.ShowInformation(SharedStrings.INVALID_DROPDOWN_VALUE);
                                    //EpiMessages msgs;
                                    //msgs.Caption = SharedStrings.INVALID_DROPDOWN_VALUE_CAPTION;
                                    //msgs.Message = SharedStrings.INVALID_DROPDOWN_VALUE;
                                    //bdoit = this.MainForm.Module.Processor.onCommunicateUI(msgs, MessageType.OkOnly);

                                    //if (bdoit)
                                    {
                                        if (!String.IsNullOrEmpty(((IDataField)field).CurrentRecordValueString))
                                        {
                                            ((ComboBox)control).SelectedIndex = ((ComboBox)control).FindString(((IDataField)field).CurrentRecordValueString);
                                        }
                                        else
                                        {
                                            ((ComboBox)control).SelectedIndex = -1;
                                            control.Text = String.Empty;
                                        }
                                        control.Focus();
                                        isValid = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (mainForm != null)
            {
                ((EnterMainForm)mainForm).ContinueChangeRecord = isValid;
            }

            return isValid;
        }
Example #15
0
	// Select the next control.
	public bool SelectNextControl
		(Control ctl, bool forward, bool tabStopOnly,
		bool nested, bool wrap)
			{
				if (!Contains(ctl) || !nested && ctl.parent != this)
					ctl = null;

				Control control = ctl;
				// Look for the next control we can select.
				do
				{
					ctl = GetNextControl(ctl, forward);
					if (ctl == null)
					{
						if (!wrap)
							break;
						continue;
					}
					if (ctl.CanSelect && (ctl.TabStop || !tabStopOnly) && (nested || ctl.parent == this))
					{
						// Found a control.
						ctl.Select(true, forward);
						return true;
					}
				}
				while (ctl != control);
				// Did not find a control.
				return false;
			}
Example #16
0
        void ListViewEditable_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                ListViewItem lvi = this.GetItemAt(1, e.Y);
                if (lvi == null) return;
                // Find which column.
                mSubItemColumn = 0;
                int sum = 0;
                if (this.Columns.Count > 1)
                {
                    for (int i = 0; i < Columns.Count; i++)
                    {
                        sum += Columns[i].Width;
                        if (e.X < sum) { mSubItemColumn = i; break; }
                    }
                }
                editingSubItem = lvi.SubItems[mSubItemColumn];
                editingItem = lvi;
                bool change = (editingSubItem == previousItem);
                previousItem = editingSubItem;
                lvi.Selected = true;
                if (change)
                {

                    mEditor = GetControlAtIndex(mSubItemColumn,editingItem.Index);
                    if (mEditor != null)
                    {
                        Rectangle bounds = editingSubItem.Bounds;
                        //if (this.CheckBoxes && mSubItemColumn == 0)
                        //    bounds.Offset(new Point(22, 0));
                        mEditor.Bounds = bounds;
                        mEditor.Text = editingSubItem.Text;

                        mEditor.Visible = true;
                        mEditor.BringToFront();
                        //mEditor.Focus();
                        mEditor.Select();
                    }
                }
            }
        }
Example #17
0
        private void EditItem(int index, ListViewItem.ListViewSubItem sb)
        {
            if (this.SelectedItems.Count <= 0)
            {
                return;
            }
            int currentSelectColumnIndex = _mCtrls.IndexOfKey(index);
            if (currentSelectColumnIndex == -1)
            {
                return;
            }
            _currentCtrl = (System.Windows.Forms.Control)_mCtrls.Values[currentSelectColumnIndex];
            ListViewItem item = this.SelectedItems[0];
            Rectangle rect = sb.Bounds;
            Rectangle _rect = new Rectangle(rect.Right - this.Columns[index].Width, rect.Top, this.Columns[index].Width, rect.Height);
            _currentCtrl.Bounds = _rect;
            _currentCtrl.BringToFront();
            _currentCtrl.Text = item.SubItems[index].Text;
            _currentCtrl.TextChanged += CtrTextChanged;
            _currentCtrl.Leave += CtrLeave;

            _currentCtrl.Visible = true;
            _currentCtrl.Tag = item;
            _currentCtrl.Select();
        }
Example #18
0
 public static string Show(Control owner)
 {
     if (owner == null)
         throw new Exception("owner is null!");
     Self._owner = owner;
     int xPos = owner.RectangleToScreen(Rectangle.Empty).X;
     int yPos = owner.RectangleToScreen(Rectangle.Empty).Y + Self._owner.Height + 5;
     Self.TopMost = true;
     if (!Self.Visible)
         Self.Show();
     Self.Location = new Point(xPos, yPos);
     owner.Select();
     return string.Empty;
 }
Example #19
0
    /// <summary>
    /// Force un contrôle et tous ses conteneurs à être visibles, puis sélectionne le contrôle.
    /// </summary>
    /// <remarks>
    /// Cette méthode prend en charge tous les classeurs à onglets qui sont les conteneurs
    /// directs ou indirects du contrôle de manière à forcer la sélection de la page concernée
    /// au sein de chaque classeur à onglets.
    /// </remarks>
    /// <param name="control">contrôle à rendre effectivement visible et sélectionné</param>
    public static void ForceShowAndSelect( Control control ) {

      // contrôle de l'argument : ignorer si null
      if ( control == null ) return;

      // remontée récursive frontale jusqu'au conteneur top-level
      Control parent = control.Parent;
      if ( parent != null ) ForceShowAndSelect( parent );

      // descente de la récursion : traiter le cas des pages des classeurs à onglets
      TabPage controlAsTabPage = control as TabPage;
      TabControl parentAsTabControl = parent as TabControl;

      // le contrôle n'est pas une page, ou n'est pas hébergé par un classeur à onglets
      if ( controlAsTabPage == null || parentAsTabControl == null ) {
        control.Show();
        control.Select();
        return;
      }

      // le contrôle est une page hébergée par un classeur à onglets : sélectionner la page
      parentAsTabControl.SelectedTab = controlAsTabPage;
      control.Select();
    }
Example #20
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateControl ()
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			Control c = new Control ();
			
			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			c.Contains (new Control ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			c.CreateControl ();
			Assert.IsTrue (c.IsHandleCreated, "A3");
			c = new Control ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c = new Control ();
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Control ();
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.GetContainerControl ();
			c = new Control ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c = new Control ();
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c = new Control ();
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c = new Control ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c = new Control ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
			c.Select ();
			Assert.IsFalse (c.IsHandleCreated, "A34");
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
		}
Example #21
0
        ///// <summary>
        ///// Displays error message for masked input textboxes, if validation failed
        ///// </summary>
        ///// <param name="control">The control that failed validation</param>
        private void ShowValidationError(Control control)
        {
            #region Input Validation
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }
            #endregion  //Input Validation

            ControlFactory factory = ControlFactory.Instance;
            Field field = factory.GetAssociatedField(control);
            if (field is DateTimeField)
            {
                if (field is DateField)
                {
                    MsgBox.ShowWarning(SharedStrings.ENTER_VALID_DATE);
                }
                else if (field is TimeField)
                {
                    MsgBox.ShowWarning(SharedStrings.ENTER_VALID_TIME);
                }
                else
                {
                    MsgBox.ShowWarning(SharedStrings.ENTER_VALID_DATE_AND_TIME);
                }
            }

            control.Text = string.Empty;
            control.Select();
        }
Example #22
0
        private void setFocusOnError(Control controlInError)
        {
            // 1. Ensure the proper page is shown
            Control parentTabPage = controlInError.Parent;
            while (parentTabPage != null && parentTabPage.GetType() != typeof(TabPage))
            {
                parentTabPage = parentTabPage.Parent;
            }
            if (parentTabPage != null && parentTabPage.GetType() == typeof(TabPage))
            {
                m_gui.getTabControl().SelectedTab = (TabPage)parentTabPage;
            }

            // 2. Put the keyboard focus within the control in error
            controlInError.Select();
        }
Example #23
0
 void SelectControlInTabs(Control ctrl)
 {
     int ntabs = this.tc.TabPages.Count;
     for (int itab = 0; itab < ntabs; itab++)
     {
         if (_findingcontrol(this.tc.TabPages[itab], ctrl))
         {
             this.tc.SelectedIndex = itab;
             break;
         }
     }
     ctrl.Select();
 }
Example #24
0
 /*
 public void sleep(int dwMilliseconds) {
     SubSleep(dwMilliseconds);
 }
 */
 public static void setFocusControl(Control ctl)
 {
     ctl.Select();
 }
 // This will select the correct active control in the containerControl (if the passed in control is a containerControl)
 private static void SelectNextActiveControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
 {
     ContainerControl container = ctl as ContainerControl;
     if (container != null)
     {
         bool correctParentActiveControl = true;
         if (container.ParentInternal != null)
         {
             IContainerControl c = container.ParentInternal.GetContainerControlInternal();
             if (c != null)
             {
                 c.ActiveControl = container;
                 correctParentActiveControl = (c.ActiveControl == container);
             }
         }
         if (correctParentActiveControl)
         {
             ctl.SelectNextControl(null, forward, tabStopOnly, nested, wrap);
         }
     }
     else
     {
         ctl.Select();
     }
 }
Example #26
0
 public static void Show(Control control, string text)
 {
     if (text == string.Empty)
     {
         HideSelf();
     }
     else
     {
         if (Self == null)
         {
             Self = new ChooseList(control);
             control.GotFocus -= new EventHandler(control_GotFocus);
             control.GotFocus += new EventHandler(control_GotFocus);
             control.LostFocus -= new EventHandler(control_LostFocus);
             control.LostFocus += new EventHandler(control_LostFocus);
             Self.ShowIcon = false;
             Self.ShowInTaskbar = false;
             Self.TopMost = true;
             Self.Visible = false;
         }
         Owner = control;
         Self.Size = new Size(control.Width, 200);
         if (!Self.Visible)
             Self.Show();
         Point point = control.PointToScreen(Point.Empty);
         Self.Location = new Point(point.X, point.Y + control.Height);
         Self.Search(text);
     }
     Form form = control.FindForm();
     if (form != null)
     {
         form.Activate();
         control.Select();
     }
 }