예제 #1
0
 public void UpdateAutoBinding(GuiControl ctrl)
 {
     if (ctrl is IGuiBindableListControl)
     {
         BindMyMetaControl(ctrl as IGuiBindableListControl);
     }
 }
예제 #2
0
        /// <summary>
        /// Adds a GuiControl to the GuiController collection.
        /// </summary>
        /// <param name="control">A control to add to the form.</param>
        protected void AddGuiControl(IGuiControl control)
        {
            if (!controls.ContainsKey(control.ID))
            {
                int tabIndex = 0;
                control.Left = 10;

                control.Width = this._width;
                if (FORM_WIDTH_OFFSET < control.Width)
                {
                    control.Width = control.Width - FORM_WIDTH_OFFSET;
                }

                // If there are tabs, add this to the current tab
                if (this._tabs.Count > 0)
                {
                    tabIndex = (this._tabs.Count - 1);
                    if (TAB_WIDTH_OFFSET < control.Width)
                    {
                        control.Width = control.Width - TAB_WIDTH_OFFSET;
                    }
                }
                ((GuiControl)control).TabStripIndex = tabIndex;

                GuiControl lastControl = getLastControlForTab(tabIndex);
                if (lastControl != null)
                {
                    control.Top = lastControl.Top + lastControl.Height + 10;
                }
                else
                {
                    control.Top = 10;
                }

                if (control is GuiLabel || control is GuiButton)
                {
                    if (this.ForeColor != string.Empty)
                    {
                        control.ForeColor = this.ForeColor;
                    }
                    if (this.BackColor != string.Empty)
                    {
                        control.BackColor = this.BackColor;
                    }
                }

                controls[control.ID] = control;
                orderedControls.Add(control);
            }
            else
            {
                throw new Exception("The control ID " + control.ID + " has already been taken by another control on the form.");
            }
        }
예제 #3
0
		private void addControl(GuiControl gctrl, Control c) 
		{
			if (tabs == null) 
			{
				form.Controls.Add(c);
			}
			else 
			{
				tabs.TabPages[gctrl.TabStripIndex].Controls.Add(c);
			}
			win32Controls[gctrl.ID] = c;
		}
예제 #4
0
        private GuiControl getLastControlForTab(int tabIndex)
        {
            GuiControl cntrl = null;

            if (orderedControls.Count > 0)
            {
                cntrl = orderedControls[(orderedControls.Count - 1)] as GuiControl;
                if (cntrl.TabStripIndex != tabIndex)
                {
                    cntrl = null;
                }
            }
            return(cntrl);
        }
예제 #5
0
 public void UpdateAutoBinding(GuiControl ctrl)
 {
     if (ctrl is IGuiBindableListControl)
     {
         BindMyMetaControl(ctrl as IGuiBindableListControl);
     }
 }
예제 #6
0
        private void BindMyMetaControl(IGuiBindableListControl ctrl)
        {
            string     parentControlId = ctrl.AutoBindingControlParentID;
            char       entityType      = ctrl.BindingTag[0];
            GuiControl parent          = null;

            if (parentControlId != null && this.controls.ContainsKey(parentControlId))
            {
                parent = this[parentControlId];

                if (!parent.AutoBindingChildControls.Contains(ctrl as GuiControl))
                {
                    parent.AutoBindingChildControls.Add(ctrl as GuiControl);
                }
            }

            dbRoot mymeta = this._context.Objects["MyMeta"] as dbRoot;

            if (mymeta.IsConnected)
            {
                object entities = null;
                if (entityType == 'd')
                {
                    if (parent == null)
                    {
                        entities = mymeta.Databases;
                    }
                    else
                    {
                        // may address changing connections at some point - not now!
                        entities = mymeta.Databases;
                    }
                }
                else
                {
                    IDatabase db = null;

                    if (parent == null)
                    {
                        db = mymeta.DefaultDatabase;
                    }
                    else
                    {
                        if (mymeta.Databases.Count == 1 || string.IsNullOrEmpty(parent.Value as String))
                        {
                            db = mymeta.DefaultDatabase;
                        }
                        else if (mymeta.Databases[parent.Value] != null)
                        {
                            db = mymeta.Databases[parent.Value];
                        }
                    }

                    if (db != null)
                    {
                        switch (entityType)
                        {
                        case 't':
                            entities = db.Tables;
                            break;

                        case 'v':
                            entities = db.Views;
                            break;

                        case 'p':
                            entities = db.Procedures;
                            break;
                        }
                    }
                }

                if (entities != null)
                {
                    ctrl.BindData(entities);
                    if (ctrl.Items.Count > 0)
                    {
                        ctrl.SelectAtIndex(0);
                    }
                }
                else
                {
                    ctrl.Items.Clear();
                }
            }
        }
예제 #7
0
		public void AddToForm(GuiControl control) 
		{
			guiControls.Add(control.ID, control);
			orderedGuiControls.Add(control);

            if (control is GuiLabel) 
			{
				GuiLabel guiLabel = control as GuiLabel;

				Label l = new Label();

				l.Left = guiLabel.Left;
				l.Top = guiLabel.Top;
				l.Width = guiLabel.Width;
				l.Height = guiLabel.Height;
				l.Visible = guiLabel.Visible;
				l.Enabled = guiLabel.Enabled;
				l.Enabled = guiLabel.Enabled;

				l.ForeColor = Color.FromName(guiLabel.ForeColor);
				if (guiLabel.BackColor != string.Empty)
				{
					l.BackColor = Color.FromName(guiLabel.BackColor);
				}

				l.TextAlign = ContentAlignment.BottomLeft;

				l.Name = guiLabel.ID;
				l.Text = guiLabel.Text;
				tooltip.SetToolTip(l, guiLabel.ToolTip);

				Font font = l.Font;
				FontStyle style = FontStyle.Regular;
				if (guiLabel.Bold) 
				{
					style = style | FontStyle.Bold;
				}
				if (guiLabel.Underline) 
				{
					style = style | FontStyle.Underline;
				}
				if (guiLabel.Strikeout) 
				{
					style = style | FontStyle.Strikeout;
				}
				if (guiLabel.Italic) 
				{
					style = style | FontStyle.Italic;
				}
				l.Font = new Font(font, style);

                l.LostFocus += new EventHandler(ControlLostFocus);
                l.Enter += new EventHandler(ControlEnter);

				addControl(control, l);
			}
			else if (control is GuiButton) 
			{
				GuiButton guiButton = control as GuiButton;

				Button b = new Button();

                b.Click += new EventHandler(OnButtonClick);
                b.LostFocus += new EventHandler(ControlLostFocus);
                b.Enter += new EventHandler(ControlEnter);
				
				if (guiButton.ClosesForm) 
				{
					b.Click += new EventHandler(OnButtonOkClick);
				}
				else if (guiButton.CancelGeneration) 
				{
					b.Click += new EventHandler(OnButtonCancelClick);
				}

				b.Text = guiButton.Text;
				b.Left = guiButton.Left;
				b.Top = guiButton.Top;
				b.Width = guiButton.Width;
				b.Height = guiButton.Height;
				b.Name = guiButton.ID;
				b.Visible = guiButton.Visible;
				b.Enabled = guiButton.Enabled;

				b.ForeColor = Color.FromName(guiButton.ForeColor);
				if (guiButton.BackColor != string.Empty)
				{
					b.BackColor = Color.FromName(guiButton.BackColor);
				}

				tooltip.SetToolTip(b, guiButton.ToolTip);

				addControl(control, b);
			}
			else if (control is GuiCheckBox) 
			{
				GuiCheckBox guiCheckBox = control as GuiCheckBox;

				CheckBox cb = new CheckBox();
				
				cb.Checked = guiCheckBox.Checked;

                cb.CheckedChanged += new EventHandler(OnCheckBoxClick);
                cb.LostFocus += new EventHandler(ControlLostFocus);
                cb.Enter += new EventHandler(ControlEnter);

				cb.Text = guiCheckBox.Text;
				cb.Left = guiCheckBox.Left;
				cb.Top = guiCheckBox.Top;
				cb.Width = guiCheckBox.Width;
				cb.Height = guiCheckBox.Height;
				cb.Name = guiCheckBox.ID;
				cb.Visible = guiCheckBox.Visible;
				cb.Enabled = guiCheckBox.Enabled;

				cb.ForeColor = Color.FromName(guiCheckBox.ForeColor);
				if (guiCheckBox.BackColor != string.Empty)
				{
					cb.BackColor = Color.FromName(guiCheckBox.BackColor);
				}

				tooltip.SetToolTip(cb, guiCheckBox.ToolTip);

				addControl(control, cb);
			}
			else if (control is GuiFilePicker) 
			{
				GuiFilePicker guiPicker = control as GuiFilePicker;

				Button b = new Button();
				
				if (guiPicker.PicksFolder)
				{
					b.Click += new EventHandler(OnFolderSelectorClick);
				}
				else
				{
					b.Click += new EventHandler(OnFileSelectorClick);
				}

				b.Text = guiPicker.Text;
				b.Left = guiPicker.Left;
				b.Top = guiPicker.Top;
				b.Width = guiPicker.Width;
				b.Height = guiPicker.Height;
				b.Name = guiPicker.ID;
				b.Visible = guiPicker.Visible;
				b.Enabled = guiPicker.Enabled;

				b.ForeColor = Color.FromName(guiPicker.ForeColor);
				if (guiPicker.BackColor != string.Empty)
				{
					b.BackColor = Color.FromName(guiPicker.BackColor);
				}

				tooltip.SetToolTip(b, guiPicker.ToolTip);

                b.LostFocus += new EventHandler(ControlLostFocus);
                b.Enter += new EventHandler(ControlEnter);

				addControl(control, b);
			}
			else if (control is GuiTextBox) 
			{
				GuiTextBox guiTextBox = control as GuiTextBox;

				TextBox tb = new TextBox();

				tb.Left = guiTextBox.Left;
				tb.Top = guiTextBox.Top;
				tb.Width = guiTextBox.Width;
				tb.Height = guiTextBox.Height;
				tb.Visible = guiTextBox.Visible;
				tb.Enabled = guiTextBox.Enabled;
				tb.Multiline = guiTextBox.Multiline;
				tb.WordWrap = guiTextBox.WordWrap;

				if (guiTextBox.VerticalScroll && guiTextBox.HorizontalScroll)	tb.ScrollBars = ScrollBars.Both;
				else if (guiTextBox.VerticalScroll)								tb.ScrollBars = ScrollBars.Vertical;
				else if (guiTextBox.HorizontalScroll)							tb.ScrollBars = ScrollBars.Horizontal;
				else															tb.ScrollBars = ScrollBars.None;

				tb.ForeColor = Color.FromName(guiTextBox.ForeColor);
				if (guiTextBox.BackColor != string.Empty)
				{
					tb.BackColor = Color.FromName(guiTextBox.BackColor);
				}

				tb.Name = guiTextBox.ID;
				tb.Text = guiTextBox.Text;
				tooltip.SetToolTip(tb, guiTextBox.ToolTip);

                tb.KeyPress += new KeyPressEventHandler(OnTextBoxKeyPress);
                tb.LostFocus += new EventHandler(ControlLostFocus);
                tb.Enter += new EventHandler(ControlEnter);

				addControl(control, tb);
			}
			else if (control is GuiComboBox) 
			{
				GuiComboBox guiComboBox = control as GuiComboBox;

				ComboBox cb = new ComboBox();
				cb.DropDownStyle = ComboBoxStyle.DropDownList;
				cb.Sorted = guiComboBox.Sorted;

				foreach (string val in guiComboBox.Items) 
				{
					ListControlItem item = new ListControlItem(val, guiComboBox[val]);
					cb.Items.Add(item);

					if (val == guiComboBox.SelectedValue) 
					{
						cb.SelectedItem = item;
					}
				}

				cb.SelectedValueChanged += new EventHandler(OnComboBoxChange);
                cb.LostFocus += new EventHandler(ControlLostFocus);
                cb.Enter += new EventHandler(ControlEnter);

				cb.Left = guiComboBox.Left;
				cb.Top = guiComboBox.Top;
				cb.Width = guiComboBox.Width;
				cb.Height = guiComboBox.Height;
				cb.Visible = guiComboBox.Visible;
				cb.Enabled = guiComboBox.Enabled;

				cb.ForeColor = Color.FromName(guiComboBox.ForeColor);
				if (guiComboBox.BackColor != string.Empty)
				{
					cb.BackColor = Color.FromName(guiComboBox.BackColor);
				}

				cb.Name = guiComboBox.ID;

				tooltip.SetToolTip(cb, guiComboBox.ToolTip);

				addControl(control, cb);
			}
			else if (control is GuiListBox) 
			{
				GuiListBox guiListBox = control as GuiListBox;

				ListBox lb = new ListBox();
				if (guiListBox.IsMultiSelect) 
				{
					lb.SelectionMode = SelectionMode.MultiExtended;
				}
				else 
				{
					lb.SelectionMode = SelectionMode.One;
				}
				lb.Sorted = guiListBox.Sorted;

				lb.Left = guiListBox.Left;
				lb.Top = guiListBox.Top;
				lb.Width = guiListBox.Width;
				lb.Height = guiListBox.Height;
				lb.Visible = guiListBox.Visible;
				lb.Enabled = guiListBox.Enabled;

				lb.ForeColor = Color.FromName(guiListBox.ForeColor);
				if (guiListBox.BackColor != string.Empty)
				{
					lb.BackColor = Color.FromName(guiListBox.BackColor);
				}

				lb.Name = guiListBox.ID;

				tooltip.SetToolTip(lb, guiListBox.ToolTip);

				foreach (string val in guiListBox.Items) 
				{
					ListControlItem item = new ListControlItem(val, guiListBox[val]);
					int index = lb.Items.Add(item);

					if (guiListBox.SelectedItems.Contains(val)) 
					{
						lb.SetSelected(index, true);
					}
				}

				// For some reason this fixes all of my timing issues!
				object s;
				foreach (object o in lb.SelectedIndices) s = o;

				lb.KeyUp += new KeyEventHandler(OnListBoxKeyUp);
                lb.SelectedValueChanged += new EventHandler(OnListBoxChange);
                lb.LostFocus += new EventHandler(ControlLostFocus);
                lb.Enter += new EventHandler(ControlEnter);

				addControl(control, lb);
			}
			else if (control is GuiGrid) 
			{
				GuiGrid guiGrid = control as GuiGrid;

				DataGrid dg = new DataGrid();

				dg.Left = guiGrid.Left;
				dg.Top = guiGrid.Top;
				dg.Width = guiGrid.Width;
				dg.Height = guiGrid.Height;
				dg.Visible = guiGrid.Visible;
				dg.Enabled = guiGrid.Enabled;

				if (guiGrid.ForeColor != string.Empty)
				{
					dg.ForeColor = Color.FromName(guiGrid.ForeColor);
				}
				else if (guiGrid.BackColor != string.Empty)
				{
					dg.BackColor = Color.FromName(guiGrid.BackColor);
				}

				dg.Name = guiGrid.ID;
				dg.DataSource = SimpleTableTools.ConvertToDataTable(guiGrid.DataSource);

				tooltip.SetToolTip(dg, guiGrid.ToolTip);

                dg.LostFocus += new EventHandler(ControlLostFocus);
                dg.Enter += new EventHandler(ControlEnter);

				addControl(control, dg);
			}
			else if (control is GuiCheckBoxList) 
			{
				GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList;

				CheckedListBox lb = new CheckedListBox();
				lb.Sorted = guiCheckBoxList.Sorted;
				lb.CheckOnClick = true;
				lb.Left = guiCheckBoxList.Left;
				lb.Top = guiCheckBoxList.Top;
				lb.Width = guiCheckBoxList.Width;
				lb.Height = guiCheckBoxList.Height;
				lb.Visible = guiCheckBoxList.Visible;
				lb.Enabled = guiCheckBoxList.Enabled;

				lb.ForeColor = Color.FromName(guiCheckBoxList.ForeColor);
				if (guiCheckBoxList.BackColor != string.Empty)
				{
					lb.BackColor = Color.FromName(guiCheckBoxList.BackColor);
				}

				lb.Name = guiCheckBoxList.ID;
				tooltip.SetToolTip(lb, guiCheckBoxList.ToolTip);

				foreach (string val in guiCheckBoxList.Items) 
				{
					ListControlItem item = new ListControlItem(val, guiCheckBoxList[val]);
					int index = lb.Items.Add(item);

					if (guiCheckBoxList.SelectedItems.Contains(val)) 
					{
						lb.SetItemChecked(index, true);
					}
				}

				// For some reason this fixes all of my timing issues!
				object s;
				foreach (object o in lb.CheckedItems) s = o;

				lb.KeyUp += new KeyEventHandler(OnCheckedListBoxKeyUp);
				lb.SelectedValueChanged += new EventHandler(OnCheckedListBoxChange);
                lb.LostFocus += new EventHandler(ControlLostFocus);
                lb.Enter += new EventHandler(ControlEnter);

				addControl(control, lb);
			}
		}
예제 #8
0
 private void UpdateAutoBinding(GuiControl gcb)
 {
     foreach (GuiControl abc in gcb.AutoBindingChildControls)
     {
         if (abc is IGuiBindableListControl)
         {
             guiController.UpdateAutoBinding(abc);
         }
     }
 }