Пример #1
0
        ///// <summary>
        ///// A handler to deal with the case of an entered panel
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private void PanelEnteredHandler(object sender, EventArgs e)
        //{
        //    _firstControl.Focus();
        //}

        ///// <summary>
        ///// A handler to deal with the press of an Enter key when the control
        ///// is an up-down object
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private static void UpDownEnterHandler(object sender, EventArgs e)
        //{
        //    INumericUpDown upDown = (INumericUpDown) sender;
        //    upDown.Select(0, upDown.Text.Length);
        //}
        ///// <summary>
        ///// A handler to deal with the press of an Enter key when the control
        ///// is a date-time picker
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private static void DateTimePickerEnterHandler(object sender, EventArgs e)
        //{
        //}

        ///// A handler to deal with a double-click on an email textbox, which
        ///// causes the default mail client on the user system to be opened
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private static void EmailTextBoxDoubleClickedHandler(object sender, EventArgs e)
        //{
        //    ITextBox tb = (ITextBox) sender;
        //    if (tb.Text.IndexOf("@") != -1)
        //    {
        //        string comm = "mailto:" + tb.Text;
        //        Process.Start(comm);
        //    }
        //}

        /// <summary>
        /// Creates the appropriate control for the given field element.
        /// Preference is given to a specific type over the type and assembly names.
        /// </summary>
        private static IControlHabanero CreateControl(UIFormField field, IControlFactory factory)
        {
            if (field.ControlType != null)
            {
                return(factory.CreateControl(field.ControlType));
            }
            return(factory.CreateControl(field.ControlTypeName, field.ControlAssemblyName));
        }
            public void ShouldCreateCorrectWinControl <T>()
            {
                var controlType = typeof(T);

                using (var controlHabanero = _factoryUnderTest.CreateControl(controlType))
                {
                    Assert.IsNotNull(controlHabanero);
                    Assert.AreEqual(controlType.Name + "Win", controlHabanero.GetType().Name);
                }
            }
Пример #3
0
 public ControlManagerStub(IControlFactory controlFactory)
 {
     _controlFactory = controlFactory;
     _control = _controlFactory.CreateControl();
 }
Пример #4
0
        ///// <summary>
        ///// A handler to deal with the case of an entered panel
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private void PanelEnteredHandler(object sender, EventArgs e)
        //{
        //    _firstControl.Focus();
        //}

        ///// <summary>
        ///// A handler to deal with the press of an Enter key when the control
        ///// is an up-down object
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private static void UpDownEnterHandler(object sender, EventArgs e)
        //{
        //    INumericUpDown upDown = (INumericUpDown) sender;
        //    upDown.Select(0, upDown.Text.Length);
        //}
        ///// <summary>
        ///// A handler to deal with the press of an Enter key when the control
        ///// is a date-time picker
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private static void DateTimePickerEnterHandler(object sender, EventArgs e)
        //{
        //}

        ///// A handler to deal with a double-click on an email textbox, which
        ///// causes the default mail client on the user system to be opened
        ///// </summary>
        ///// <param name="sender">The object that notified of the event</param>
        ///// <param name="e">Attached arguments regarding the event</param>
        //private static void EmailTextBoxDoubleClickedHandler(object sender, EventArgs e)
        //{
        //    ITextBox tb = (ITextBox) sender;
        //    if (tb.Text.IndexOf("@") != -1)
        //    {
        //        string comm = "mailto:" + tb.Text;
        //        Process.Start(comm);
        //    }
        //}

        /// <summary>
        /// Creates the appropriate control for the given field element.
        /// Preference is given to a specific type over the type and assembly names.
        /// </summary>
        private static IControlHabanero CreateControl(UIFormField field, IControlFactory factory)
        {
            if (field.ControlType != null)
            {
                return factory.CreateControl(field.ControlType);
            }
            return factory.CreateControl(field.ControlTypeName, field.ControlAssemblyName);
        }
Пример #5
0
 public ControlManagerStub(IControlFactory controlFactory)
 {
     _controlFactory = controlFactory;
     _control        = _controlFactory.CreateControl();
 }
        private void SetupGridAndBOEditorControlWin(IControlFactory controlFactory, IBOEditorControl iboEditorControl, IClassDef classDef, string gridUiDefName)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            if (iboEditorControl == null)
            {
                throw new ArgumentNullException("iboEditorControl");
            }
            _controlFactory   = controlFactory;
            _iboEditorControl = iboEditorControl;

            SetupReadOnlyGridControl(classDef, gridUiDefName);
            SetupButtonGroupControl();
            UpdateControlEnabledState();

            this.FilterControl = controlFactory.CreateGenericGridFilter(this.GridControl.Grid);
            this.FilterControl.FilterStarted   += (sender, e) => { this.SetFilteringUIState(true); };
            this.FilterControl.FilterCompleted += (sender, e) => { this.SetFilteringUIState(false); };

            var grid = new GridLayoutManager(this, _controlFactory);

            grid.SetGridSize(3, 4);
            grid.FixRow(2, _buttonGroupControl.Height);
            grid.FixRow(0, this.FilterControl.Height + 5);
            grid.FixColumn(0, this.FilterControl.Width);

            var leftMost   = this.Width;
            var rightMost  = 0;
            var bottomMost = 0;

            foreach (var control in this._iboEditorControl.Controls)
            {
                var ctl = control as Control;
                if (ctl == null)
                {
                    continue;
                }
                if (ctl.Left < leftMost)
                {
                    leftMost = ctl.Left;
                }
                if (ctl.Right > rightMost)
                {
                    rightMost = ctl.Right;
                }
                if (ctl.Bottom > bottomMost)
                {
                    bottomMost = ctl.Bottom;
                }
            }
            var editorWidth = rightMost - leftMost;

            grid.FixColumn(3, editorWidth);

            grid.AddControl(this.FilterControl, 1, 3);
            grid.AddControl(controlFactory.CreateControl());
            grid.AddControl(_readOnlyGridControl, 1, 3);
            grid.AddControl(_iboEditorControl);
            grid.AddControl(_buttonGroupControl, 1, 4);

            this.MinimumSize = new Size(editorWidth, bottomMost);

            _readOnlyGridControl.BusinessObjectSelected +=
                ((sender, e) => FireBusinessObjectSelected(e.BusinessObject));

            _readOnlyGridControl.Grid.SelectionChanged += GridSelectionChanged;
        }