/// <summary>
        /// Constructs a <see cref="MainTitleIconControlWin"/>
        /// </summary>
        public MainTitleIconControlWin(IControlFactory controlFactory)
        {
            if (controlFactory == null) throw new ArgumentNullException("controlFactory");
            _controlFactory = controlFactory;
            _panel = _controlFactory.CreatePanel();
            ((PanelWin)_panel).BackgroundImage = CollapsiblePanelResource.headergradient;
            _panel.BackColor = Color.Transparent;
            _panel.Dock = Habanero.Faces.Base.DockStyle.Top;

            _panel.Height = 23;

            _icon = _controlFactory.CreateLabel();
            ((LabelWin)_icon).BackgroundImage = CollapsiblePanelResource.headergradient;
            _icon.BackColor = Color.Transparent;
            ((LabelWin)_icon).BackgroundImageLayout = ImageLayout.Center;
            _icon.Dock = Habanero.Faces.Base.DockStyle.Left;
            _icon.Size = new Size(20, 20);

            _title = _controlFactory.CreateLabel();
            _title.Dock = Habanero.Faces.Base.DockStyle.Fill;
            _title.BackColor = Color.Transparent;
            _title.TextAlign = ContentAlignment.MiddleLeft;
            _title.ForeColor = Color.White;

            _panel.Controls.Add(_title);
            _panel.Controls.Add(_icon);
            _panel.MaximumSize = new Size(2000, 23);
            this.Dock = DockStyleWin.GetDockStyle(DockStyle.Top);
            this.Controls.Add((PanelWin)_panel);
            this.Height = 23;
        }
Beispiel #2
0
        /// <summary>
        /// Constructs a <see cref="MainTitleIconControlWin"/>
        /// </summary>
        public MainTitleIconControlWin(IControlFactory controlFactory)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            _controlFactory = controlFactory;
            _panel          = _controlFactory.CreatePanel();
            ((PanelWin)_panel).BackgroundImage = CollapsiblePanelResource.headergradient;
            _panel.BackColor = Color.Transparent;
            _panel.Dock      = Habanero.Faces.Base.DockStyle.Top;

            _panel.Height = 23;

            _icon = _controlFactory.CreateLabel();
            ((LabelWin)_icon).BackgroundImage = CollapsiblePanelResource.headergradient;
            _icon.BackColor = Color.Transparent;
            ((LabelWin)_icon).BackgroundImageLayout = ImageLayout.Center;
            _icon.Dock = Habanero.Faces.Base.DockStyle.Left;
            _icon.Size = new Size(20, 20);

            _title           = _controlFactory.CreateLabel();
            _title.Dock      = Habanero.Faces.Base.DockStyle.Fill;
            _title.BackColor = Color.Transparent;
            _title.TextAlign = ContentAlignment.MiddleLeft;
            _title.ForeColor = Color.White;

            _panel.Controls.Add(_title);
            _panel.Controls.Add(_icon);
            _panel.MaximumSize = new Size(2000, 23);
            this.Dock          = DockStyleWin.GetDockStyle(DockStyle.Top);
            this.Controls.Add((PanelWin)_panel);
            this.Height = 23;
        }
        /// <summary>
        /// Creates the panel on the form
        /// </summary>
        /// <returns>Returns the panel created</returns>
        public IPanel CreateControlPanel()
        {
            IPanel panel = _controlFactory.CreatePanel();
            ILabel label = _controlFactory.CreateLabel(_message, false);
            ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(panel, _controlFactory);

            columnLayoutManager.AddControl(label);
            columnLayoutManager.AddControl(_comboBox);
            panel.Height = _comboBox.Height + label.Height + columnLayoutManager.BorderSize + columnLayoutManager.VerticalGapSize;
            int preferredWidth          = label.PreferredWidth + 20;
            int preferredWidthFromCombo = GetLongestComboText() + 40;

            if (preferredWidthFromCombo > preferredWidth)
            {
                preferredWidth = preferredWidthFromCombo;
            }
            if (preferredWidth < 200)
            {
                preferredWidth = 200;
            }
            panel.Width       = preferredWidth;
            _comboBox.Width   = panel.Width - 30;
            panel.MinimumSize = panel.Size;
            return(panel);
        }
        /// <summary>
        /// Constructs a <see cref="MainTitleIconControlVWG"/>
        /// </summary>
        public MainTitleIconControlVWG(IControlFactory controlFactory)
        {
            if (controlFactory == null) throw new ArgumentNullException("controlFactory");
            _controlFactory = controlFactory;
            _panel = _controlFactory.CreatePanel();
            ((PanelVWG)_panel).BackgroundImage = @"Images.headergradient.png";
            
            _panel.BackColor = Color.Transparent;
            _panel.Dock = Habanero.Faces.Base.DockStyle.Top;
            
            _panel.Height = 23;
            this.Size = new Size(_panel.Width,_panel.Height);
            _icon = _controlFactory.CreateLabel();
            ((LabelVWG)_icon).BackgroundImage = "";
            _icon.BackColor = Color.Transparent;
            ((LabelVWG)_icon).BackgroundImageLayout = ImageLayout.Center;
            _icon.Dock = Habanero.Faces.Base.DockStyle.Left;
            _icon.Size = new Size(20, 20);

            _title = _controlFactory.CreateLabel();
            _title.Font = new Font("Verdana", 10);
            _title.Dock = Habanero.Faces.Base.DockStyle.Fill;
            _title.BackColor = Color.Transparent;
            _title.TextAlign = ContentAlignment.MiddleLeft;
            _title.ForeColor = Color.White;

            _panel.Controls.Add(_title);
            _panel.Controls.Add(_icon);

            this.Dock = DockStyleVWG.GetDockStyle(DockStyle.Top);
            this.Controls.Add((PanelVWG)_panel);
            this.Height = 23;
        }
Beispiel #5
0
        /// <summary>
        /// Creates the panel on the form
        /// </summary>
        /// <returns>Returns the panel created</returns>
        public IPanel createControlPanel()
        {
            IPanel            panel             = _controlFactory.CreatePanel();
            ILabel            label             = _controlFactory.CreateLabel(_message, false);
            FlowLayoutManager flowLayoutManager = new FlowLayoutManager(panel, _controlFactory);

            flowLayoutManager.AddControl(label);
            flowLayoutManager.AddControl(_dateTimePicker);
            panel.Height = _dateTimePicker.Height + label.Height;
            panel.Width  = _controlFactory.CreateLabel(_message, true).PreferredWidth + 20;
            return(panel);
        }
        ///<summary>
        /// Constructor for the <see cref="HelpAboutBoxManager"/>
        ///</summary>
        ///<param name="controlFactory"></param>
        ///<param name="formHabanero"></param>
        ///<param name="programName"></param>
        ///<param name="producedForName"></param>
        ///<param name="producedByName"></param>
        ///<param name="versionNumber"></param>
        public HelpAboutBoxManager(IControlFactory controlFactory, IFormHabanero formHabanero, string programName, string producedForName, string producedByName, string versionNumber)
        {
            _FormHabanero = formHabanero;
            _mainPanel    = controlFactory.CreatePanel();
            GridLayoutManager mainPanelManager = new GridLayoutManager(_mainPanel, controlFactory);

            mainPanelManager.SetGridSize(4, 2);
            mainPanelManager.FixAllRowsBasedOnContents();
            mainPanelManager.FixColumnBasedOnContents(0);
            mainPanelManager.FixColumnBasedOnContents(1);
            mainPanelManager.AddControl(controlFactory.CreateLabel("Programme Name:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(programName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Produced For:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(producedForName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Produced By:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(producedByName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Version:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(versionNumber, false));

            IButtonGroupControl buttons = controlFactory.CreateButtonGroupControl();

            buttons.AddButton("OK", new EventHandler(OKButtonClickHandler));

            BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(formHabanero);

            manager.AddControl(_mainPanel, BorderLayoutManager.Position.Centre);
            manager.AddControl(buttons, BorderLayoutManager.Position.South);
            formHabanero.Width  = 300;
            formHabanero.Height = 200;
            formHabanero.Text   = "About";
        }
        ///<summary>
        /// Constructor for the <see cref="HelpAboutBoxManager"/>
        ///</summary>
        ///<param name="controlFactory"></param>
        ///<param name="formHabanero"></param>
        ///<param name="programName"></param>
        ///<param name="producedForName"></param>
        ///<param name="producedByName"></param>
        ///<param name="versionNumber"></param>
        public HelpAboutBoxManager(IControlFactory controlFactory, IFormHabanero formHabanero, string programName, string producedForName, string producedByName, string versionNumber)
        {
            _FormHabanero = formHabanero;
            _mainPanel = controlFactory.CreatePanel();
            GridLayoutManager mainPanelManager = new GridLayoutManager(_mainPanel, controlFactory);
            mainPanelManager.SetGridSize(4, 2);
            mainPanelManager.FixAllRowsBasedOnContents();
            mainPanelManager.FixColumnBasedOnContents(0);
            mainPanelManager.FixColumnBasedOnContents(1);
            mainPanelManager.AddControl(controlFactory.CreateLabel("Programme Name:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(programName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Produced For:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(producedForName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Produced By:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(producedByName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Version:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(versionNumber, false));

            IButtonGroupControl buttons = controlFactory.CreateButtonGroupControl();
            buttons.AddButton("OK", new EventHandler(OKButtonClickHandler));

            BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(formHabanero);
            manager.AddControl(_mainPanel, BorderLayoutManager.Position.Centre);
            manager.AddControl(buttons, BorderLayoutManager.Position.South);
            formHabanero.Width = 300;
            formHabanero.Height = 200;
            formHabanero.Text = "About";
        }
 private void SetupNullDisplayBox()
 {
     //ControlsHelper.SafeGui(_dateTimePicker, delegate()
     //{
     _nullDisplayBox = _controlFactory.CreateLabel();     //_controlFactory.CreatePanel();
     //_displayBox.BorderStyle = BorderStyle.None;
     _nullDisplayBox.AutoSize = false;
     _nullDisplayBox.Location = new Point(2, 2);
     _nullDisplayBox.Click   += delegate { ChangeToValueMode(); };
     ResizeNullDisplayBox();
     _nullDisplayBox.BackColor = _dateTimePicker.BackColor;
     _nullDisplayBox.ForeColor = _dateTimePicker.ForeColor;
     //_displayBox.MouseUp += DateTimePicker_MouseUp;
     //_displayBox.KeyDown += DateTimePicker_KeyDown;
     //_displayText = _controlFactory.CreateLabel();
     //_displayText.Location = new Point(0, 0);
     //_displayText.AutoSize = true;
     //_displayText.Text = "";
     //_displayText.MouseUp += DateTimePicker_MouseUp;
     //_displayText.KeyDown += DateTimePicker_KeyDown;
     //_displayBox.Controls.Add(_displayText);
     _dateTimePicker.Controls.Add(_nullDisplayBox);
     _nullDisplayBox.Visible = false;
     //});
 }
        ///<summary>
        /// A constructor for the <see cref="ErrorDescriptionForm"/>
        ///</summary>
        public ErrorDescriptionForm()
        {
            IControlFactory controlFactory = GlobalUIRegistry.ControlFactory;
            ILabel          label          = controlFactory.CreateLabel("Please enter further details regarding the error : ");

            _errorDescriptionTextBox          = controlFactory.CreateTextBox();
            ErrorDescriptionTextBox.Multiline = true;
            IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();

            buttonGroupControl.AddButton("OK", delegate { this.Close(); });
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

            layoutManager.AddControl(label, BorderLayoutManager.Position.North);
            layoutManager.AddControl(ErrorDescriptionTextBox, BorderLayoutManager.Position.Centre);
            layoutManager.AddControl(buttonGroupControl, BorderLayoutManager.Position.South);
            this.Text     = "Error Description";
            this.Width    = 500;
            this.Height   = 400;
            this.Closing += delegate(object sender, CancelEventArgs e)
            {
                if (ErrorDescriptionFormClosing == null)
                {
                    return;
                }
                ErrorDescriptionFormClosing(sender, e);
            };
        }
 private static IPanel CreateColoredPanel(IControlFactory controlFactory, string labelPrefix)
 {
     System.Windows.Forms.Panel panel = (System.Windows.Forms.Panel)controlFactory.CreatePanel();
     ILabel label = controlFactory.CreateLabel(labelPrefix);
     label.Height = 15;
     label.BackColor = Color.White;
     panel.Controls.Add((System.Windows.Forms.Control)label);
     panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     panel.BackColor = Color.FromArgb(TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255));
     return (IPanel)panel;
 }
        private static IPanel CreateColoredPanel(IControlFactory controlFactory, string labelPrefix)
        {
            System.Windows.Forms.Panel panel = (System.Windows.Forms.Panel)controlFactory.CreatePanel();
            ILabel label = controlFactory.CreateLabel(labelPrefix);

            label.Height    = 15;
            label.BackColor = Color.White;
            panel.Controls.Add((System.Windows.Forms.Control)label);
            panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            panel.BackColor   = Color.FromArgb(TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255));
            return((IPanel)panel);
        }
Beispiel #12
0
/*
 *      ///<summary>
 *      /// Construct the Dialog form for any situation e.g. where the Form being closed has
 *      /// Mutliple Business Objects is a wizard etc.
 *      ///</summary>
 *      /// <param name="controlFactory">The control Factory used to construct buttons, labels etc by ths control</param>
 *      ///<param name="fullDisplayName">Full display name for the BusienssObject(s)</param>
 *      ///<param name="isInValidState">Are the BusinessObject(s) in a valid state</param>
 *      ///<param name="isDirty"></param>
 *      ///<exception cref="ArgumentNullException">control Factory must not be null</exception>
 *      public CloseBOEditorDialogWin(IControlFactory controlFactory, string fullDisplayName, bool isInValidState, bool isDirty)
 *      {
 *          if (controlFactory == null) throw new ArgumentNullException("controlFactory");
 *          ConstructControl(controlFactory, fullDisplayName, isInValidState, isDirty);
 *          SetSize();
 *      }*/



        private void ConstructControl(IControlFactory controlFactory)
        {
            IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();

            CancelCloseBtn        = buttonGroupControl.AddButton("CancelClose", "Cancel Close", ButtonClick);
            CloseWithoutSavingBtn = buttonGroupControl.AddButton("CloseWithoutSaving", "&Close without saving", ButtonClick);
            SaveAndCloseBtn       = buttonGroupControl.AddButton("SaveAndClose", "&Save & Close", ButtonClick);

            _label = controlFactory.CreateLabel();
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

            layoutManager.AddControl(_label, BorderLayoutManager.Position.Centre);
            layoutManager.AddControl(buttonGroupControl, BorderLayoutManager.Position.South);
        }
Beispiel #13
0
        /// <summary>
        /// Constructs a <see cref="MainTitleIconControlVWG"/>
        /// </summary>
        public MainTitleIconControlVWG(IControlFactory controlFactory)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            _controlFactory = controlFactory;
            _panel          = _controlFactory.CreatePanel();
            ((PanelVWG)_panel).BackgroundImage = @"Images.headergradient.png";

            _panel.BackColor = Color.Transparent;
            _panel.Dock      = Habanero.Faces.Base.DockStyle.Top;

            _panel.Height = 23;
            this.Size     = new Size(_panel.Width, _panel.Height);
            _icon         = _controlFactory.CreateLabel();
            ((LabelVWG)_icon).BackgroundImage = "";
            _icon.BackColor = Color.Transparent;
            ((LabelVWG)_icon).BackgroundImageLayout = ImageLayout.Center;
            _icon.Dock = Habanero.Faces.Base.DockStyle.Left;
            _icon.Size = new Size(20, 20);

            _title           = _controlFactory.CreateLabel();
            _title.Font      = new Font("Verdana", 10);
            _title.Dock      = Habanero.Faces.Base.DockStyle.Fill;
            _title.BackColor = Color.Transparent;
            _title.TextAlign = ContentAlignment.MiddleLeft;
            _title.ForeColor = Color.White;

            _panel.Controls.Add(_title);
            _panel.Controls.Add(_icon);

            this.Dock = DockStyleVWG.GetDockStyle(DockStyle.Top);
            this.Controls.Add((PanelVWG)_panel);
            this.Height = 23;
        }
 private static IPanel CreateColoredPanel(IControlFactory controlFactory, string labelPrefix)
 {
     System.Windows.Forms.Panel panel = (System.Windows.Forms.Panel)controlFactory.CreatePanel();
     ILabel label = controlFactory.CreateLabel(labelPrefix + "Left-Click to grow, Right-Click to shrink.");
     label.Height = 15;
     label.BackColor = Color.White;
     panel.Controls.Add((System.Windows.Forms.Control)label);
     panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     panel.MouseDown += (sender, e) =>
                            {
                                if (e.Button == System.Windows.Forms.MouseButtons.Left) panel.Height += 5;
                                if (e.Button == System.Windows.Forms.MouseButtons.Right) panel.Height -= 5;
                            };
     panel.BackColor = Color.FromArgb(TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255));
     return (IPanel)panel;
 }
        /// <summary>
        /// Recalculates the button sizes of the given collection of buttons.
        /// </summary>
        /// <param name="buttonCollection"></param>
        public void RecalcButtonSizes(IControlCollection buttonCollection)
        {
            int maxButtonWidth = 0;

            foreach (IButton btn in buttonCollection)
            {
                ILabel lbl = _controlFactory.CreateLabel(btn.Text);
                if (lbl.PreferredWidth + 10 > maxButtonWidth)
                {
                    maxButtonWidth = lbl.PreferredWidth + 10;
                }
            }
            foreach (IButton btn in buttonCollection)
            {
                btn.Width = maxButtonWidth;
            }
        }
Beispiel #16
0
 public Label Label(int x, int y,
                    int sizeX, int sizeY,
                    string text,
                    SpriteFont font,
                    Color textColor,
                    IColorPattern pattern,
                    IHorizontalAlignable horizontalAlignment = null,
                    IVerticalAlignable verticalAlignment     = null,
                    IAlignmentTransition alignmentTransition = null)
 {
     return(controlFactory.CreateLabel(text,
                                       font,
                                       textColor,
                                       GetTexture(sizeX, sizeY, pattern),
                                       new Region(new Vector2(x, y),
                                                  new Vector2(sizeX, sizeY)),
                                       horizontalAlignment ?? HorizontalAlignment.Left,
                                       verticalAlignment ?? VerticalAlignment.Center,
                                       alignmentTransition ?? AlignmentTransition.Instant));
 }
Beispiel #17
0
        /// <summary>
        /// See <see cref="IFilterControl.AddCustomFilter(string,ICustomFilter)"/>
        /// </summary>
        public void AddCustomFilter(string labelText, ICustomFilter customFilter)
        {
            ILabel           label   = _controlFactory.CreateLabel(labelText);
            IControlHabanero control = customFilter.Control;

            if (control != null)
            {
                AddControlToLayoutManager(label, control);
            }
            _filterControls.Add(customFilter);
            var chk = control as ICheckBox;

            if (chk != null)
            {
                label.Click += (sender, e) =>
                {
                    chk.Checked = !chk.Checked;
                };
            }
        }
Beispiel #18
0
        /// <summary>
        /// Recalculates the button sizes of the given collection of buttons.
        /// </summary>
        /// <param name="buttonCollection"></param>
        public void RecalcButtonSizes(IControlCollection buttonCollection)
        {
            int maxButtonWidth = 0;

            foreach (IButton btn in buttonCollection)
            {
                ILabel lbl = _controlFactory.CreateLabel(btn.Text);
                if (lbl.PreferredWidth + 15 > maxButtonWidth)
                {
                    maxButtonWidth = lbl.PreferredWidth + 15;
                }
            }
            if (maxButtonWidth < Screen.PrimaryScreen.Bounds.Width / 24)
            {
                maxButtonWidth = Screen.PrimaryScreen.Bounds.Width / 24;
            }
            foreach (IButton btn in buttonCollection)
            {
                btn.Width = maxButtonWidth;
            }
        }
        /// <summary>
        /// Set the list of objects in the ComboBox to a specific collection of
        /// business objects.<br/>
        /// NOTE: If you are changing the business object collection,
        /// use the SetBusinessObjectCollection method instead, which will call this method
        /// automatically.
        /// </summary>
        /// <param name="cbx">The ComboBox being mapped</param>
        /// <param name="col">The business object collection being represented</param>
        /// <param name="includeBlank">Whether to include a blank item at the
        /// top of the list</param>
        public void SetComboBoxCollection(IComboBox cbx, IBusinessObjectCollection col, bool includeBlank)
        {
            int width = cbx.Width;

            ILabel lbl = _controlFactory.CreateLabel("", false);

            cbx.Items.Clear();
            if (includeBlank)
            {
                cbx.Items.Add("");
            }
            foreach (IBusinessObject businessObjectBase in col)
            {
                lbl.Text = businessObjectBase.ToString();
                if (lbl.PreferredWidth > width)
                {
                    width = lbl.PreferredWidth;
                }
                cbx.Items.Add(businessObjectBase);
            }
            cbx.DropDownWidth = width;
        }
Beispiel #20
0
        private static IPanel CreateColoredPanel(IControlFactory controlFactory, string labelPrefix)
        {
            System.Windows.Forms.Panel panel = (System.Windows.Forms.Panel)controlFactory.CreatePanel();
            ILabel label = controlFactory.CreateLabel(labelPrefix + "Left-Click to grow, Right-Click to shrink.");

            label.Height    = 15;
            label.BackColor = Color.White;
            panel.Controls.Add((System.Windows.Forms.Control)label);
            panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            panel.MouseDown  += (sender, e) =>
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    panel.Height += 5;
                }
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    panel.Height -= 5;
                }
            };
            panel.BackColor = Color.FromArgb(TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255), TestUtil.GetRandomInt(255));
            return((IPanel)panel);
        }
/*
        ///<summary>
        /// Construct the Dialog form for any situation e.g. where the Form being closed has 
        /// Mutliple Business Objects is a wizard etc.
        ///</summary>
        /// <param name="controlFactory">The control Factory used to construct buttons, labels etc by ths control</param>
        ///<param name="fullDisplayName">Full display name for the BusienssObject(s)</param>
        ///<param name="isInValidState">Are the BusinessObject(s) in a valid state</param>
        ///<param name="isDirty"></param>
        ///<exception cref="ArgumentNullException">control Factory must not be null</exception>
        public CloseBOEditorDialogWin(IControlFactory controlFactory, string fullDisplayName, bool isInValidState, bool isDirty)
        {
            if (controlFactory == null) throw new ArgumentNullException("controlFactory");
            ConstructControl(controlFactory, fullDisplayName, isInValidState, isDirty);
            SetSize();
        }*/



        private void ConstructControl(IControlFactory controlFactory)
        {
            IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();
            CancelCloseBtn = buttonGroupControl.AddButton("CancelClose", "Cancel Close", ButtonClick);
            CloseWithoutSavingBtn = buttonGroupControl.AddButton("CloseWithoutSaving", "&Close without saving", ButtonClick);
            SaveAndCloseBtn = buttonGroupControl.AddButton("SaveAndClose","&Save & Close", ButtonClick);
            
            _label = controlFactory.CreateLabel();
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);
            layoutManager.AddControl(_label, BorderLayoutManager.Position.Centre);
            layoutManager.AddControl(buttonGroupControl, BorderLayoutManager.Position.South);
        }
Beispiel #22
0
        /// <summary>
        /// Set the list of objects in the ComboBox to a specific collection of
        /// business objects.<br/>
        /// Important: If you are changing the business object collection,
        /// use the SetBusinessObjectCollection method instead, which will call this method
        /// automatically.
        /// </summary>
        /// <param name="cbx">The ComboBox being controlled</param>
        /// <param name="col">The business object collection used to populate the items list</param>
        private void SetComboBoxCollectionInternal(IComboBox cbx, IBusinessObjectCollection col)
        {
            int width = cbx.Width;

            IBusinessObject selectedBusinessObject = SelectedBusinessObject;

            _logger.Log("Start SetComboBoxCollectionInternal Combo : " + cbx.Name + " SelectedBO : (" + SelectedBusinessObject + ")", LogCategory.Debug);
            // _logger.Log(GetStackTrace(), LogCategory.Debug);
            if (this.PreserveSelectedItem && this.AutoSelectFirstItem)
            {
                _logger.Log("Start SetComboBoxCollectionInternal Combo : " + cbx.Name + " for BOCol of " + col.ClassDef + " has PreserveSelectedItem and AutoSelectFirstItem. These are mutually exclusive settings", LogCategory.Warn);
            }

/*			_logger.Log("Start SetComboBoxCollectionInternal SelectedBO : (" + SelectedBusinessObject + ")", LogCategory.Debug);
 *                      _logger.Log("Start SetComboBoxCollectionInternal PreserveSelectedItem : (" + PreserveSelectedItem + ")", LogCategory.Debug);
 *                      _logger.Log("Start SetComboBoxCollectionInternal AutoSelectFirstItem : (" + AutoSelectFirstItem + ")", LogCategory.Debug);*/

            try
            {
                //cbx.MustRaiseSelectionChangedEvents = false;
                cbx.SelectedIndex = -1;
                cbx.Text          = null;
                cbx.Items.Clear();
            }
            finally
            {
                //cbx.MustRaiseSelectionChangedEvents = true;
            }
            var numBlankItems = 0;

            if (this.IncludeBlankItem)
            {
                cbx.Items.Add("");
                numBlankItems++;                //The some purpose of this is to set the selected item later if AutoSelectFirstItem is true.
            }

            if (col == null)
            {
                return;
            }
            //This is a bit of a hack but is used to get the
            //width of the dropdown list when it drops down
            // uses the preferedwith calculation on the
            //Label to do this. Makes drop down width equal to the
            // width of the longest name shown.
            ILabel lbl = _controlFactory.CreateLabel("", false);

            foreach (IBusinessObject businessObject in col)
            {
                lbl.Text = businessObject.ToString();
                if (lbl.PreferredWidth > width)
                {
                    width = lbl.PreferredWidth;
                }
                cbx.Items.Add(businessObject);
            }
            if (PreserveSelectedItem && selectedBusinessObject != null)
            {
                var objectToSelect = (col.Contains(selectedBusinessObject) ? selectedBusinessObject : null);
                if (objectToSelect != null)
                {
                    SelectedBusinessObject = objectToSelect;
                }
            }
            else if (col.Count > 0 && AutoSelectFirstItem && selectedBusinessObject == null)
            {
                cbx.SelectedIndex = numBlankItems;
            }
            if (width == 0)
            {
                width = 1;
            }
            cbx.DropDownWidth = width > cbx.Width ? width : cbx.Width;
        }
Beispiel #23
0
        /// <summary>
        /// Creates a panel with the controls and dimensions as prescribed
        /// </summary>
        /// <param name="uiFormTab">The UIFormTab object</param>
        /// <returns>Returns the object containing the new panel</returns>
        private IPanelFactoryInfo CreateOnePanel(IUIFormTab uiFormTab)
        {
            if (uiFormTab.UIFormGrid != null)
            {
                return(CreatePanelWithGrid(uiFormTab.UIFormGrid));
            }
            IPanel            panel   = _controlFactory.CreatePanel(_controlFactory);
            IToolTip          toolTip = _controlFactory.CreateToolTip();
            GridLayoutManager manager = new GridLayoutManager(panel, _controlFactory);
            int rowCount = 0;
            int colCount = 0;

            colCount += uiFormTab.Count;
            foreach (UIFormColumn uiFormColumn in uiFormTab)
            {
                if (uiFormColumn.Count > rowCount)
                {
                    rowCount = uiFormColumn.Count;
                }
            }
            const int intNoOfLayoutGridColumnsPerPanel = 3;

            manager.SetGridSize(rowCount, colCount * intNoOfLayoutGridColumnsPerPanel);
            for (int col = 0; col < colCount; col++)
            {
                //Fixing the labels column widths
                manager.FixColumnBasedOnContents(col * intNoOfLayoutGridColumnsPerPanel);
            }

            ControlMapperCollection controlMappers = new ControlMapperCollection();

            controlMappers.BusinessObject = _currentBusinessObject;
            ITextBox temptb = _controlFactory.CreateTextBox();

            for (int row = 0; row < rowCount; row++)
            {
                manager.FixRow(row, temptb.Height);
            }
            manager.FixAllRowsBasedOnContents();
            GridLayoutManager.ControlInfo[,] controls =
                new GridLayoutManager.ControlInfo[rowCount, colCount *intNoOfLayoutGridColumnsPerPanel];
            int currentColumn = 0;

            foreach (UIFormColumn uiFormColumn in uiFormTab)
            {
                int currentRow = 0;
                foreach (UIFormField field in uiFormColumn)
                {
                    bool     isCompulsory;
                    ClassDef classDef = _currentBusinessObject.ClassDef;
                    PropDef  propDef  = (PropDef)field.GetPropDefIfExists(classDef);
                    if (propDef != null)
                    {
                        isCompulsory = propDef.Compulsory;
                    }
                    else
                    {
                        isCompulsory = false;
                    }
                    string labelCaption = field.GetLabel(classDef);
                    //                    BOPropCol boPropCol = _currentBusinessObject.Props;
                    //                    if (boPropCol.Contains(field.PropertyName))
                    //                    {
                    //                        IBOProp boProp = boPropCol[field.PropertyName];
                    //                        if (!boProp.HasDisplayName())
                    //                        {
                    //                            boProp.DisplayName = labelCaption;
                    //                        }
                    //                    }

                    IControlHabanero ctl          = CreateControl(field, _controlFactory);
                    bool             editable     = CheckIfEditable(field, ctl);
                    ILabel           labelControl = _controlFactory.CreateLabel(labelCaption, isCompulsory && editable);
                    controls[currentRow, currentColumn + 0] = new GridLayoutManager.ControlInfo(labelControl);

                    if (ctl is ITextBox && propDef != null)
                    {
                        if (propDef.PropertyType == typeof(bool))
                        {
                            ctl = _controlFactory.CreateCheckBox();
                        }
                        else if (propDef.PropertyType == typeof(string) && propDef.KeepValuePrivate)
                        {
                            ctl = _controlFactory.CreatePasswordTextBox();
                        }
                        else if (field.GetParameterValue("numLines") != null)
                        {
                            int numLines;
                            try
                            {
                                numLines = Convert.ToInt32(field.GetParameterValue("numLines"));
                            }
                            catch (Exception)
                            {
                                throw new InvalidXmlDefinitionException
                                          ("An error " + "occurred while reading the 'numLines' parameter "
                                          + "from the class definitions.  The 'value' "
                                          + "attribute must be a valid integer.");
                            }
                            if (numLines > 1)
                            {
                                ctl = _controlFactory.CreateTextBoxMultiLine(numLines);
                            }
                        }
                    }


                    if (ctl is ITextBox)
                    {
                        if (field.GetParameterValue("isEmail") != null)
                        {
                            string isEmailValue = (string)field.GetParameterValue("isEmail");
                            if (isEmailValue != "true" && isEmailValue != "false")
                            {
                                throw new InvalidXmlDefinitionException
                                          ("An error " + "occurred while reading the 'isEmail' parameter "
                                          + "from the class definitions.  The 'value' "
                                          + "attribute must hold either 'true' or 'false'.");
                            }

                            //bool isEmail = Convert.ToBoolean(isEmailValue);
                            //if (isEmail)
                            //{
                            //    ITextBox tb = (ITextBox) ctl;
                            //    tb.DoubleClick += _emailTextBoxDoubleClickedHandler;
                            //}
                        }
                    }
                    //if (ctl is IDateTimePicker)
                    //{
                    //    IDateTimePicker editor = (IDateTimePicker) ctl;
                    //    editor.Enter += DateTimePickerEnterHandler;
                    //}
                    //if (ctl is INumericUpDown)
                    //{
                    //    INumericUpDown upDown = (INumericUpDown) ctl;
                    //    upDown.Enter += UpDownEnterHandler;
                    //}



                    CheckGeneralParameters(field, ctl);

                    IControlMapper ctlMapper =
                        ControlMapper.Create
                            (field.MapperTypeName, field.MapperAssembly, ctl, field.PropertyName, !editable,
                            _controlFactory);
                    if (ctlMapper is ControlMapper)
                    {
                        ControlMapper controlMapper = (ControlMapper)ctlMapper;
                        controlMapper.SetPropertyAttributes(field.Parameters);
                    }
                    controlMappers.Add(ctlMapper);
                    ctlMapper.BusinessObject = _currentBusinessObject;

                    int colSpan = 1;
                    if (field.GetParameterValue("colSpan") != null)
                    {
                        try
                        {
                            colSpan = Convert.ToInt32(field.GetParameterValue("colSpan"));
                        }
                        catch (Exception)
                        {
                            throw new InvalidXmlDefinitionException
                                      ("An error " + "occurred while reading the 'colSpan' parameter "
                                      + "from the class definitions.  The 'value' " + "attribute must be a valid integer.");
                        }
                    }
                    colSpan = (colSpan - 1) * intNoOfLayoutGridColumnsPerPanel + 1; // must span label columns too

                    int rowSpan = 1;
                    if (field.GetParameterValue("rowSpan") != null)
                    {
                        try
                        {
                            rowSpan = Convert.ToInt32(field.GetParameterValue("rowSpan"));
                        }
                        catch (Exception)
                        {
                            throw new InvalidXmlDefinitionException
                                      ("An error " + "occurred while reading the 'rowSpan' parameter "
                                      + "from the class definitions.  The 'value' " + "attribute must be a valid integer.");
                        }
                    }
                    if (rowSpan == 1)
                    {
                        manager.FixRow(currentRow, ctl.Height);
                    }
                    controls[currentRow, currentColumn + 1] = new GridLayoutManager.ControlInfo(ctl, rowSpan, colSpan);
                    currentRow++;
                    string toolTipText = field.GetToolTipText(classDef);
                    if (!String.IsNullOrEmpty(toolTipText))
                    {
                        toolTip.SetToolTip(labelControl, toolTipText);
                        toolTip.SetToolTip(ctl, toolTipText);
                    }
                    //Hack brett trying to fix prob with dynamic properties
                    ctl.Width = 100;
                }

                currentColumn += 3;
            }
            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < colCount * intNoOfLayoutGridColumnsPerPanel; j++)
                {
                    if (controls[i, j] == null)
                    {
                        manager.AddControl(null);
                    }
                    else
                    {
                        manager.AddControl(controls[i, j]);
                        controls[i, j].Control.TabIndex = rowCount * j + i;
                    }
                }
            }
            for (int col = 0; col < colCount; col++)
            {
                if (uiFormTab[col].Width > -1)
                {
                    //Fix width of the control column e.g. textbox or combobox.
                    manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 1, uiFormTab[col].Width - manager.GetFixedColumnWidth(col * intNoOfLayoutGridColumnsPerPanel));
                }
                manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 2, 15);
            }

            panel.Height = manager.GetFixedHeightIncludingGaps();
            panel.Width  = manager.GetFixedWidthIncludingGaps();
            IPanelFactoryInfo panelFactoryInfo = new PanelFactoryInfo(panel, controlMappers, _uiDefName, _firstControl);

            panelFactoryInfo.MinimumPanelHeight = panel.Height;
            panelFactoryInfo.MinumumPanelWidth  = panel.Width;
            panelFactoryInfo.ToolTip            = toolTip;
            panelFactoryInfo.PanelTabText       = uiFormTab.Name;
            panelFactoryInfo.UIForm             = _uiForm;
            panelFactoryInfo.UiFormTab          = uiFormTab;
            return(panelFactoryInfo);
        }