public void Clear() { _childControl = new Panel(); _childControl.Parent = this; _childControl.Dock = DockStyle.Fill; _childControl.BringToFront(); }
public static void ShowControl(System.Windows.Forms.Control control, System.Windows.Forms.Control content) { content.Controls.Clear(); control.Dock = DockStyle.Fill; control.BringToFront(); content.Controls.Add(control); }
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(); }
private static bool m_IsSimpleDrag = false; // Is this a simple drag? #endregion Fields #region Methods /// <summary> /// Returns the DataObject needed for a DoDragDrop, from a specified Control /// Used with controls that implement IDragDropEnabled (recommended usage) /// </summary> /// <param name="_ctrl">Control to get DataObject for</param> /// <param name="_invalidate">Invalidate the control or not? /// (Set to true if you need to change the appearance of the control during a DragDrop)</param> /// <returns>Control converted to a DataObject ready for dragging</returns> public static DataObject BeginDrag(Control _ctrl, bool _invalidate) { // If not initialized then throw an Exception if (!m_Initialized) throw new Exception(string.Format("{0} not initialized.", "EIBFormDesigner.Event.DragDropHandler"), null); // If this is not a valid control to be dragged, throw an exception if (!(_ctrl is IDragDropEnabled)) throw new ControlInterfaceException( string.Format("[{0}] only accepts controls that implement\n[{1}] for drag operations.\n\nUse {2} instead.", "EIBFormDesigner.Event", "IDragDropEnabled", "BeginSimpleDrag")); DataObject doControlToDrag = StoreControl(_ctrl, false); // Inform the control that it has begun a drag operation ((IDragDropEnabled)_ctrl).StoreLocation(); ((IDragDropEnabled)_ctrl).IsDragging = true; // Set the control up to be in the foreground and invalidate it // incase it needs redrawing if (_invalidate) { _ctrl.BringToFront(); _ctrl.Invalidate(); } // return the converted control as a DataObject return doControlToDrag; }
public void AddSleepingDetailsPanel(Control c) { this.panelWizardSteps.Controls.Add(c); c.Dock = DockStyle.Fill; c.BringToFront(); c.Visible = false; }
public static Image GetImage(Control c_) { Graphics g = null; Image ret = null; try { if (c_ is Form) c_.BringToFront(); else c_.FindForm().BringToFront(); Application.DoEvents(); g = c_.CreateGraphics(); ret = new Bitmap(c_.ClientRectangle.Width, c_.ClientRectangle.Height, g); Graphics g2 = Graphics.FromImage(ret); IntPtr dc1 = g.GetHdc(); IntPtr dc2 = g2.GetHdc(); BitBlt(dc2, 0, 0, c_.ClientRectangle.Width, c_.ClientRectangle.Height, dc1, 0, 0, 13369376); g.ReleaseHdc(dc1); g2.ReleaseHdc(dc2); } finally { if (g != null) g.Dispose(); } return ret; }
public static void showControl(System.Windows.Forms.Control control, System.Windows.Forms.Control panel) { panel.Controls.Clear(); control.Dock = DockStyle.Fill; control.BringToFront(); control.Focus(); panel.Controls.Add(control); }
public void DispayControl(Control childControl) { childControl.Parent = this; childControl.Dock = DockStyle.Fill; _childControl = childControl; _childControl.BringToFront(); }
/// <summary> /// Init for basic panebar. /// </summary> /// <param name="mediator"></param> /// <param name="mainControl"></param> public void Init(Mediator mediator, Control mainControl) { m_mediator = mediator; m_paneBar = CreatePaneBar(); Controls.Add(m_paneBar as Control); mainControl.Dock = DockStyle.Fill; Controls.Add(mainControl); mainControl.BringToFront(); }
private static void Control_MouseDown(object sender, MouseEventArgs e) { System.Windows.Forms.Control suruklenen = sender as System.Windows.Forms.Control; if (suruklenen != null) { suruklenen.BringToFront(); Point pt = suruklenen.Parent.PointToClient(Cursor.Position); farkNokta = new Point(suruklenen.Left - pt.X, suruklenen.Top - pt.Y); } }
public void CargarControl(Control oControl) { if (!this.panelContenedor.Controls.Contains(oControl)) { oControl.Dock = DockStyle.Fill; this.panelContenedor.Controls.Add(oControl); } this.panelContenedor.Tag = oControl; oControl.BringToFront(); oControl.Show(); }
public static Control Show(Control parent) { Control o = new Control(); o.Location = Point.Empty; o.Size = parent.ClientSize; o.Parent = parent; o.BackgroundImage = Resources.ExpirationHS; o.BackgroundImageLayout = ImageLayout.Center; o.BackColor = Color.WhiteSmoke; o.Show(); o.BringToFront(); return o; }
/// <summary> /// Dynamically adds a control to the Mainform /// </summary> /// <param name="controlInstance"></param> /// <param name="layoutPanelName"></param> private void LoadControlToView(Control controlInstance, int tableLayoutPosition) { if (!this.Controls.Contains(controlInstance)) { //this.Visible = false; ((TableLayoutPanel)this.Controls["tableLayoutPanel1"]).Controls.Add(controlInstance, tableLayoutPosition, 0); controlInstance.Dock = DockStyle.Fill; controlInstance.BringToFront(); } else { QAControl.Instance.BringToFront(); } }
/// <summary> /// This method will fill the content of the form with a given usercontrol /// </summary> /// <param name="control">The user control to fill the content</param> /// <param name="content">A content panel that holds the work area</param> public static void ShowControl(System.Windows.Forms.Control control, System.Windows.Forms.Control content) { try { content.Controls.Clear(); control.Dock = DockStyle.Fill; content.BringToFront(); control.Focus(); content.Controls.Add(control); } catch (Exception ex) { MessageBox.Show(ex.ToString()); System.Environment.Exit(1); } }
public CollapsibleControl AddCollapsibleControlFor(Control control, int expandedHeight = 50, string label = "Collapsible Control") { if (expandedHeight == -1) { expandedHeight = control.Height; } CollapsibleControl newControl = AddCollapsibleControl(expandedHeight); newControl.SuspendLayout(); newControl.Label = label; newControl.Controls.Add(control); control.Dock = DockStyle.Fill; control.BringToFront(); int m = 3; newControl.ResumeLayout(); return newControl; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct an SimpleExplorerBar /// </summary> /// ------------------------------------------------------------------------------------ public ExplorerBarItem(string text, Control hostedControl) { m_button = new Button(); m_button.Text = text; m_button.Dock = DockStyle.Top; m_button.Height = 13 + m_button.Font.Height; m_button.Cursor = Cursors.Hand; m_button.Click += m_button_Click; m_button.Paint += m_button_Paint; m_button.MouseEnter += m_button_MouseEnter; m_button.MouseLeave += m_button_MouseLeave; Controls.Add(m_button); m_control = hostedControl; SetHostedControlHeight(m_control.Height); m_control.Dock = DockStyle.Fill; Controls.Add(m_control); m_control.BringToFront(); // Make the expand/collapse glyph width the height of // one line of button text plus the fudge factor. m_glyphButtonWidth = 13 + Font.Height; }
/// <summary> /// Actives the specified pseudo-dialog within the parent window. /// The operation includes centering, z-order manipulation, and /// focus changes. /// </summary> private void ShowPanel(Control panel, Control focus) { // Recenter and show a child panel this.CenterPanel(panel); panel.BringToFront(); panel.Visible = true; (focus ?? panel).Focus(); }
private void ShowFakeControl(Control control) { if (m_listViewSubItem != null) // Check if an actual item was clicked { var ClickedItem = m_listViewSubItem.Bounds; // Get the bounds of the item clicked // Adjust the top and left of the control ClickedItem.X += listView1.Left; ClickedItem.Y += listView1.Top; control.Bounds = ClickedItem; // Set Control bounds to match calculation control.Text = m_listViewSubItem.Text; // Set the default text for the Control to be the clicked item's text control.Show(); // Show the Control control.BringToFront(); // Make sure it is on top control.Focus(); // Give focus to the Control } }
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"); }
private void ResetControl(SplitterPanel panel, Control newControl) { panel.SuspendLayout(); if (!panel.Controls.Contains(newControl)) panel.Controls.Add(newControl); newControl.BringToFront(); if (Panel1 == panel) m_firstFrontedControl = newControl; else m_secondFrontedControl = newControl; panel.ResumeLayout(); }
protected virtual void ShowControl(Control editorControl) { editorControl.Show(); editorControl.BringToFront(); editorControl.Focus(); }
void BringViewControlToFront(Control control) { if (control != null && control.Parent != null) control.BringToFront(); else if (control != null) control.ParentChanged += control_ParentChanged; }
public static Control add_Control(this IStep step, Control control) { if (step.UI == null) return null; return (Control) step.UI.invokeOnThread( () => { step.UI.Controls.Add(control); control.BringToFront(); return control; }); }
private void bringContainedControlToFront(Control control) { control.BringToFront(); // Ensure scrollbars are at the top if (hScrollBar != null) hScrollBar.BringToFront(); if (vScrollBar != null) vScrollBar.BringToFront(); }
/// <summary> /// Begin in-place editing of given cell /// </summary> /// <param name="c">Control used as cell editor</param> /// <param name="Item">ListViewItem to edit</param> /// <param name="SubItem">SubItem index to edit</param> public void StartEditing(Control c, ListViewItem Item, int SubItem) { OnSubItemBeginEditing(new SubItemEventArgs(Item, SubItem)); Rectangle rcSubItem = GetSubItemBounds(Item, SubItem); if (rcSubItem.X < 0) { // Left edge of SubItem not visible - adjust rectangle position and width rcSubItem.Width += rcSubItem.X; rcSubItem.X = 0; } if (rcSubItem.X + rcSubItem.Width > this.Width) { // Right edge of SubItem not visible - adjust rectangle width rcSubItem.Width = this.Width - rcSubItem.Left; } // Subitem bounds are relative to the location of the ListView! rcSubItem.Offset(Left, Top); // In case the editing control and the listview are on different parents, // account for different origins Point origin = new Point(0, 0); Point lvOrigin = this.Parent.PointToScreen(origin); Point ctlOrigin = c.Parent.PointToScreen(origin); rcSubItem.Offset(lvOrigin.X - ctlOrigin.X, lvOrigin.Y - ctlOrigin.Y); // Position and show editor c.Bounds = rcSubItem; c.Text = Item.SubItems[SubItem].Text; c.Visible = true; c.BringToFront(); c.Focus(); _editingControl = c; _editingControl.Leave += new EventHandler(_editControl_Leave); _editingControl.KeyPress += new KeyPressEventHandler(_editControl_KeyPress); _editItem = Item; _editSubItem = SubItem; }
public void StartEditing(Control editor, ListViewItem item, int subItem) { OnSubItemBeginEditing(new SubItemEventArgs(item, subItem)); Rectangle rectSubItem = GetSubItemBounds(item, subItem); if (rectSubItem.X < 0) { rectSubItem.Width += rectSubItem.X; rectSubItem.X = 0; } if (rectSubItem.X + rectSubItem.Width > Width) { rectSubItem.Width = Width - rectSubItem.Left; } rectSubItem.Offset(Left + 4, Top + 1); rectSubItem.Width -= 4; rectSubItem.Height -= 1; Point origin = new Point(0, 0); Point controlOrigin = Parent.PointToScreen(origin); Point editorOrigin = editor.Parent.PointToScreen(origin); rectSubItem.Offset(controlOrigin.X - editorOrigin.X, controlOrigin.Y - editorOrigin.Y); editor.Bounds = rectSubItem; editor.Text = item.SubItems[subItem].Text; editor.Visible = true; editor.BringToFront(); editor.Focus(); _editControl = editor; _editControl.Leave += EditControlLeaveHandler; _editControl.KeyPress += EditControlKeyPressHandler; _editControl.KeyDown += EditControlKeyDownHandler; _editControl.PreviewKeyDown += EditControlPreviewKeyDownHandler; _editItem = item; _editSubItem = subItem; }
/// Не надо ничего оптимизировать!!! /// Это не работает !!! //protected override void SetColumnValueAtRow (CurrencyManager source, int rowNum, object value) //{ // string oldValue =GetColumnValueAtRow(source,rowNum) as string; // string newValue=value as string; // if (!oldValue.Equals(newValue)) // { // base.SetColumnValueAtRow(source, rowNum, newValue); // getRowView.EndEdit(); // } //} protected override void ColumnStartedEditing(Control editingControl) { base.ColumnStartedEditing (editingControl); try { editingControl.Visible=true; editingControl.BringToFront(); editingControl.Focus(); } catch {} }
public void StartEditing(Control c, ListViewItem Item, int SubItem) { this.OnSubItemBeginEditing(new SubItemEventArgs(Item, SubItem)); Rectangle subItemBounds = this.GetSubItemBounds(Item, SubItem); if (subItemBounds.X < 0) { subItemBounds.Width += subItemBounds.X; subItemBounds.X = 0; } if ((subItemBounds.X + subItemBounds.Width) > base.Width) { subItemBounds.Width = base.Width - subItemBounds.Left; } subItemBounds.Offset(base.Left, base.Top); Point p = new Point(0, 0); Point point2 = base.Parent.PointToScreen(p); Point point3 = c.Parent.PointToScreen(p); subItemBounds.Offset(point2.X - point3.X, point2.Y - point3.Y); c.Bounds = subItemBounds; c.Text = Item.SubItems[SubItem].Text; c.Visible = true; c.BringToFront(); c.Focus(); this._editingControl = c; this._editingControl.Leave += new EventHandler(this._editControl_Leave); this._editingControl.KeyPress += new KeyPressEventHandler(this._editControl_KeyPress); this._editItem = Item; this._editSubItem = SubItem; }
static void BringToFrontHack(Control c, Control top) { c.Click += (o, e) => top.BringToFront(); if (c.HasChildren) foreach (Control cc in c.Controls) BringToFrontHack(cc, top); }
/// <summary> /// Procesar la Localizacion y tamaños del Control a mostrar. /// </summary> /// <param name="ctl">Control a Mostrar para la edicion.</param> /// <param name="cell">Celda donde se posicionara el Control.</param> private void ShowControl(Control ctl, DataGridViewCell cell) { var rect = customDataGridView.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, false); ctl.Left = rect.Left + customDataGridView.Left; ctl.Top = rect.Top + customDataGridView.Top; ctl.Width = rect.Width; ctl.Height = rect.Height; ctl.BringToFront(); ctl.Visible = true; ctl.Focus(); }
private async void render(Control c, int y) { if (!thumbs.ContainsKey(c.Name)) { await Task.Delay(100); render(c, y); return; } Controls.Find("console", true)[0].Text += "\n[ -> ] rendering " + c.Name; c.Visible = true; ((FancyLabel)c).Image = thumbs[c.Name]; c.BringToFront(); c.Size = new Size(100, 100); if (!((FancyLabel)c).Text.Equals("")) { ((FancyLabel)c).ImageAlign = ContentAlignment.TopCenter; } }
private static string GuiApplyStyles(Control control, string styles) { bool first = control.Parent.Controls.Count == 1, dx = false, dy = false, sec = false; if (first) control.Location = new Point(control.Parent.Margin.Left, control.Parent.Margin.Top); control.Font = GuiAssociatedInfo(control).Font; #region Default sizing float dw = control.Font.SizeInPoints * 15; float w = 0; int r = 0; if (control is ComboBox || control is ListBox || control is HotkeyBox || control is TextBox) w = dw; else if (control is ListView || control is TreeView || control is DateTimePicker) w = dw * 2; else if (control is NumericUpDown) w = dw; else if (control is TrackBar) w = dw; else if (control is ProgressBar) w = dw; else if (control is GroupBox) w = dw + 2 * control.Parent.Margin.Left; else if (control is TabPage) w = 2 * dw + 3 * control.Parent.Margin.Left; if (control is ComboBox) r = 2; else if (control is ListBox) r = 3; else if (control is ListView || control is TreeView) r = 5; else if (control is GroupBox) r = 2; else if (control is TextBox) r = ((TextBox) control).Multiline ? 3 : 1; else if (control is DateTimePicker || control is HotkeyBox) r = 1; else if (control is TabPage) r = 10; control.Size = new Size(Math.Max((int) w, control.PreferredSize.Width), ++r > 2 ? (int) (r * control.Parent.Font.Height) : control.PreferredSize.Height); #endregion Default sizing #region Options string[] opts = ParseOptions(styles), excess = new string[opts.Length]; for (int i = 0; i < opts.Length; i++) { string mode = opts[i].ToLowerInvariant(); bool append = false; bool on = mode[0] != '-'; if (!on || mode[0] == '+') mode = mode.Substring(1); if (mode.Length == 0) continue; string arg = mode.Substring(1); int n; switch (mode) { case Keyword_Left: SafeSetProperty(control, "TextAlign", ContentAlignment.MiddleLeft); break; case Keyword_Center: SafeSetProperty(control, "TextAlign", ContentAlignment.MiddleCenter); break; case Keyword_Right: SafeSetProperty(control, "TextAlign", ContentAlignment.MiddleRight); break; case Keyword_AltSubmit: break; case Keyword_Background: break; case Keyword_Border: SafeSetProperty(control, "BorderStyle", on ? BorderStyle.FixedSingle : BorderStyle.None); break; case Keyword_Enabled: control.Enabled = on; break; case Keyword_Disabled: control.Enabled = !on; break; case Keyword_HScroll: break; case Keyword_VScroll: break; case Keyword_TabStop: control.TabStop = on; break; case Keyword_Theme: break; case Keyword_Transparent: control.BackColor = Color.Transparent; break; case Keyword_Visible: case Keyword_Vis: control.Visible = on; break; case Keyword_Wrap: break; case Keyword_Section: sec = true; break; default: switch (mode[0]) { case 'x': dx = true; dy = dy || (mode[1] == 'm' || mode[1] == 'M'); goto case 'h'; case 'y': dy = true; dx = dx || (mode[1] == 'm' || mode[1] == 'M'); goto case 'h'; case 'w': case 'h': GuiControlMove(mode, control); break; case 'r': if (int.TryParse(arg, out n)) { if (control.Parent != null && control.Parent.Font != null) { var h = (int) (n * control.Parent.Font.GetHeight()); if (control is GroupBox) h += control.ClientSize.Height; control.Size = new Size(control.Size.Width, h); } if (control is TextBox) ((TextBox) control).Multiline = true; } else append = true; break; case 'c': if (arg.Length != 0 && !mode.StartsWith(Keyword_Check, StringComparison.OrdinalIgnoreCase) && !mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase)) control.ForeColor = ParseColor(arg); else append = true; break; case 'v': control.Name = arg; break; case 'g': if (control is Button) control.Tag = true; control.Click += delegate { SafeInvoke(arg); }; break; default: append = true; break; } break; } if (append) excess[i] = opts[i]; } #endregion Options #region Secondary controls if (!first) { var last = GuiAssociatedInfo(control).LastControl; if (last is MonthCalendar && !last.Parent.Visible) // strange bug { last.Parent.Show(); last.Parent.Hide(); } var loc = new Point(last.Location.X + last.Size.Width + last.Margin.Right + control.Margin.Left, last.Location.Y + last.Size.Height + last.Margin.Bottom + control.Margin.Top); if (!dx && !dy) control.Location = new Point(last.Location.X, loc.Y); else if (!dy) control.Location = new Point(control.Location.X, loc.Y); else if (!dx) control.Location = new Point(loc.X, control.Location.Y); } #endregion Secondary controls if (sec) GuiAssociatedInfo(control).Section = control.Location; control.BringToFront(); return string.Join(Keyword_Spaces[1].ToString(), excess).Trim(); }
void BringViewControlToFront(Control control) { if (control != null) control.BringToFront(); }
/// <summary> /// Creates one control of the selected type for each chunk in the reflexive. /// Idents will have the tag types filled in & tag names will be auto filled when /// the tag type is selected. /// String IDs will have the strings list populated here. /// </summary> private void GenerateFields(int progressBarStart, int progressBarEnd) { this.SuspendLayout(); this.progressBar1.Value = progressBarStart; try { pnlAutoFill.Visible = false; ToolTip t = new ToolTip(); this.pnlFieldControls.Controls.Clear(); this.Size = new Size(400, 500); pnlFieldControls.AutoScroll = true; //pnlFieldControls.AutoScrollMargin = new Size(20, pnlFieldControls.Height); pnlFieldControls.AutoScrollMinSize = new Size(20, pnlFieldControls.Height); int StartChunk = int.Parse(cbStartChunk.Text); int EndChunk = int.Parse(cbEndChunk.Text); StartOffset = RD.baseOffset + FieldControl.chunkOffset - (RD.chunkSelected * RD.reflexive.chunkSize); switch (FieldControl.GetType().ToString()) { case "entity.MetaEditor2.DataValues": try { Control c = FieldControl.Controls[1]; for (int x = StartChunk; x <= EndChunk; x++) { // Update progress bar this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk)); this.progressBar1.Refresh(); Control Casing = new Control(); Casing.Dock = DockStyle.Top; Casing.Padding = new Padding(4); Casing.Size = new Size(this.Width, 31); Label LBL = new Label(); LBL.Dock = DockStyle.Left; LBL.Location = new Point(10, 4); LBL.Size = new Size(140, 23); LBL.Text = FieldControl.EntName + " #" + x.ToString(); LBL.TextAlign = ContentAlignment.MiddleLeft; TextBox TB = new TextBox(); TB.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; TB.Location = new Point(150, 5); TB.Height = c.Height; TB.Width = c.Width; TB.Tag = StartOffset + x * RD.reflexive.chunkSize; TB.Leave += new EventHandler(Field_Leave); TB.TextChanged += new EventHandler(Field_TextChanged); t.SetToolTip(TB, TB.Tag.ToString()); Casing.Controls.Add(TB); Casing.Controls.Add(LBL); pnlFieldControls.Controls.Add(Casing); Casing.BringToFront(); } pnlAutoFill.Visible = true; } catch { MessageBox.Show("An error occured reading DataValues fields"); } break; case "entity.MetaEditor2.EntStrings": try { Control c = FieldControl.Controls[1]; for (int x = StartChunk; x <= EndChunk; x++) { // Update progress bar this.progressBar1.Value = (x-StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk)); this.progressBar1.Refresh(); Control Casing = new Control(); Casing.Dock = DockStyle.Top; Casing.Padding = new Padding(4); Casing.Size = new Size(this.Width, 31); Label LBL = new Label(); LBL.Dock = DockStyle.Left; LBL.Location = new Point(10, 4); LBL.Size = new Size(140, 23); LBL.Text = FieldControl.EntName + " #" + x.ToString(); LBL.TextAlign = ContentAlignment.MiddleLeft; TextBox TB = new TextBox(); TB.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; TB.Location = new Point(150, 5); TB.Height = c.Height; TB.MaxLength = ((EntStrings)FieldControl).length; TB.Width = Casing.Width - TB.Left - 30; TB.Tag = StartOffset + x * RD.reflexive.chunkSize; TB.Leave += new EventHandler(Field_Leave); t.SetToolTip(TB, TB.Tag.ToString()); Casing.Controls.Add(TB); Casing.Controls.Add(LBL); pnlFieldControls.Controls.Add(Casing); Casing.BringToFront(); } } catch { MessageBox.Show("An error occured reading EntStrings fields"); } break; case "entity.MetaEditor2.Ident": try { Control c = FieldControl.Controls[1]; this.Size = new Size(FieldControl.Width, 500); System.Collections.IEnumerator i = FieldControl.map.MetaInfo.TagTypes.Keys.GetEnumerator(); List<string> TagTypes = new List<string>(); while (i.MoveNext()) { TagTypes.Add((string)i.Current); } TagTypes.Sort(); TagTypes.Add((string)"null"); for (int x = StartChunk; x <= EndChunk; x++) { // Update progress bar this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk)); this.progressBar1.Refresh(); Control Casing = new Control(); Casing.Dock = DockStyle.Top; Casing.Padding = new Padding(4); Casing.Size = new Size(this.Width, 31); Label LBL = new Label(); LBL.Dock = DockStyle.Left; LBL.Location = new Point(10, 4); LBL.Size = new Size(140, 23); LBL.Text = FieldControl.EntName + " #" + x.ToString(); LBL.TextAlign = ContentAlignment.MiddleLeft; ComboBox FieldTagType = new ComboBox(); FieldTagType.Anchor = AnchorStyles.Left | AnchorStyles.Top; FieldTagType.DropDownStyle = ComboBoxStyle.DropDownList; FieldTagType.Location = new Point(150, 5); FieldTagType.Height = c.Height; FieldTagType.Items.AddRange(TagTypes.ToArray()); FieldTagType.Width = FieldControl.Controls[2].Width; FieldTagType.Tag = StartOffset + x * RD.reflexive.chunkSize; FieldTagType.SelectedIndexChanged += new EventHandler(FieldTagType_SelectedIndexChanged); FieldTagType.Leave += new EventHandler(Field_Leave); FieldTagType.TextChanged += new EventHandler(Field_TextChanged); t.SetToolTip(FieldTagType, FieldTagType.Tag.ToString()); ComboBox FieldIdent = new ComboBox(); FieldIdent.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; FieldIdent.DropDownStyle = ComboBoxStyle.DropDownList; FieldIdent.Location = new Point(250, 5); FieldIdent.Height = c.Height; FieldIdent.Width = FieldControl.Controls[1].Width; if (((Ident)FieldControl).HasTagType) FieldIdent.Tag = StartOffset + x * RD.reflexive.chunkSize + 4; else FieldIdent.Tag = StartOffset + x * RD.reflexive.chunkSize; FieldIdent.Leave += new EventHandler(Field_Leave); t.SetToolTip(FieldIdent, FieldIdent.Tag.ToString()); Casing.Controls.Add(FieldTagType); Casing.Controls.Add(FieldIdent); Casing.Controls.Add(LBL); pnlFieldControls.Controls.Add(Casing); Casing.BringToFront(); } } catch { MessageBox.Show("An error occured reading Tag/Ident fields"); } break; case "entity.MetaEditor2.SID": try { Control c = FieldControl.Controls[1]; this.Size = new Size(FieldControl.Width, 500); List<SIDData> SIDs = new List<SIDData>(); SIDs.AddRange(SIDData.CreateArray(FieldControl.map.Strings.Name)); SortStringIDs(ref SIDs); for (int x = StartChunk; x <= EndChunk; x++) { // Update progress bar this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk)); this.progressBar1.Refresh(); Control Casing = new Control(); Casing.Dock = DockStyle.Top; Casing.Padding = new Padding(4); Casing.Size = new Size(this.Width, 31); Label LBL = new Label(); LBL.Dock = DockStyle.Left; LBL.Location = new Point(10, 4); LBL.Size = new Size(140, 23); LBL.Text = FieldControl.EntName + " #" + x.ToString(); LBL.TextAlign = ContentAlignment.MiddleLeft; ComboBox SIDBox = new ComboBox(); SIDBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; SIDBox.DropDownStyle = ComboBoxStyle.DropDownList; SIDBox.Location = new Point(150, 5); SIDBox.Height = c.Height; SIDBox.Items.AddRange(SIDs.ToArray()); SIDBox.DisplayMember = "Name"; SIDBox.Width = FieldControl.Controls[1].Width; SIDBox.Tag = StartOffset + x * RD.reflexive.chunkSize; SIDBox.Leave += new EventHandler(Field_Leave); t.SetToolTip(SIDBox, SIDBox.Tag.ToString()); Casing.Controls.Add(SIDBox); Casing.Controls.Add(LBL); pnlFieldControls.Controls.Add(Casing); Casing.BringToFront(); } } catch { MessageBox.Show("An error occured reading String ID fields"); } break; case "entity.MetaEditor2.Enums": try { ComboBox c = (ComboBox)FieldControl.Controls[1]; for (int x = StartChunk; x <= EndChunk; x++) { // Update progress bar this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk)); this.progressBar1.Refresh(); Control Casing = new Control(); Casing.Dock = DockStyle.Top; Casing.Padding = new Padding(4); Casing.Size = new Size(this.Width, 31); Label LBL = new Label(); LBL.Dock = DockStyle.Left; LBL.Location = new Point(10, 4); LBL.Size = new Size(140, 23); LBL.Text = FieldControl.EntName + " #" + x.ToString(); LBL.TextAlign = ContentAlignment.MiddleLeft; ComboBox EnumsBox = new ComboBox(); EnumsBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; EnumsBox.Location = new Point(150, 5); EnumsBox.Height = c.Height; object[] objs = new object[c.Items.Count]; c.Items.CopyTo(objs, 0); EnumsBox.Items.AddRange(objs); EnumsBox.Width = FieldControl.Controls[1].Width; EnumsBox.Tag = StartOffset + x * RD.reflexive.chunkSize; EnumsBox.Leave += new EventHandler(Field_Leave); t.SetToolTip(EnumsBox, EnumsBox.Tag.ToString()); Casing.Controls.Add(EnumsBox); Casing.Controls.Add(LBL); pnlFieldControls.Controls.Add(Casing); Casing.BringToFront(); } pnlAutoFill.Visible = true; } catch { MessageBox.Show("An error occured reading Enums fields"); } break; case "entity.MetaEditor2.Indices": try { Control c = FieldControl.Controls[1]; this.Size = new Size(FieldControl.Width, 500); Indices indices = ((Indices)FieldControl); // Make sure all values have been added to combobox (happens on dropdown) indices.UpdateSelectionList(true); for (int x = StartChunk; x <= EndChunk; x++) { // Update progress bar this.progressBar1.Value = (x - StartChunk) * (progressBarEnd - progressBarStart) / Math.Max(1, (EndChunk - StartChunk)); this.progressBar1.Refresh(); Control Casing = new Control(); Casing.Dock = DockStyle.Top; Casing.Padding = new Padding(4); Casing.Size = new Size(this.Width, 31); Label LBL = new Label(); LBL.Dock = DockStyle.Left; LBL.Location = new Point(10, 4); LBL.Size = new Size(140, 23); LBL.Text = FieldControl.EntName + " #" + x.ToString(); LBL.TextAlign = ContentAlignment.MiddleLeft; ComboBox Indices = new ComboBox(); Indices.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; Indices.DropDownStyle = ComboBoxStyle.DropDownList; Indices.Location = new Point(150, 5); Indices.Height = c.Height; Indices.Items.AddRange( indices.IndicesList.ToArray()); Indices.DisplayMember = "Name"; Indices.Width = Casing.Width - Indices.Left - 50; Indices.Tag = StartOffset + x * RD.reflexive.chunkSize; Indices.Leave += new EventHandler(Field_Leave); t.SetToolTip(Indices, Indices.Tag.ToString()); Casing.Controls.Add(Indices); Casing.Controls.Add(LBL); pnlFieldControls.Controls.Add(Casing); Casing.BringToFront(); } } catch { MessageBox.Show("An error occured reading Indices/Block Index fields"); } break; default: MessageBox.Show(FieldControl.GetType().ToString() + " fields are currently Unsupported."); this.Close(); break; } } finally { this.ResumeLayout(true); } }
/// <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); } } }