internal static Control FindHittestControl(Control parent, int x, int y) { Control child; Point_ child_point; Point_ hittest_point; hittest_point = new Point_(x, y); child_point = parent.PointToClient(hittest_point); if (parent.ClientRectangle.Contains(child_point)) { return(parent); } for (int i = 0; i < parent.Controls.Count; i++) { child = parent.Controls[i]; child_point = child.PointToClient(hittest_point); if (child.ClientRectangle.Contains(child_point)) { return(child); } if (child.Controls.Count > 0) { Control result; result = FindHittestControl(child, x, y); if (result != null) { return(result); } } } return(null); }
protected override void HandleWindowMove(Message m) { Point_ pos = Cursor.Position; Point_ move = MouseMove(pos); if (move.X == 0 && move.Y == 0) { return; } int x = virtual_position.X + move.X; int y = virtual_position.Y + move.Y; Rectangle_ client = mdi_container.ClientRectangle; if (mdi_container.VerticalScrollbarVisible) { client.Width -= SystemInformation.VerticalScrollBarWidth; } if (mdi_container.HorizontalScrollbarVisible) { client.Height -= SystemInformation.HorizontalScrollBarHeight; } UpdateVP(x, y, form.Width, form.Height); start = pos; }
public HtmlElement GetElementFromPoint(Point_ point) { Mono.WebBrowser.DOM.IElement elem = document.GetElement (point.X, point.Y); if (elem != null) return new HtmlElement(owner, webHost, elem); return null; }
internal override void PaintPartContent(Graphics graphics, Rectangle_ cellBounds, int rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, object formattedValue) { CheckBoxState state; CheckState value = GetCurrentValue(); if ((CheckState)value == CheckState.Unchecked) { state = (CheckBoxState)check_state; } else if ((CheckState)value == CheckState.Checked) { state = (CheckBoxState)((int)check_state + 4); } else if (threeState) { state = (CheckBoxState)((int)check_state + 8); } else { state = (CheckBoxState)check_state; } Point_ p = new Point_(cellBounds.X + (Size.Width - 13) / 2, cellBounds.Y + (Size.Height - 13) / 2); CheckBoxRenderer.DrawCheckBox(graphics, p, state); }
public bool HandleMenuMouseDown(MainMenu menu, int x, int y) { Point_ pt = MenuTracker.ScreenToMenu(menu, new Point_(x, y)); HandleTitleBarDown(pt.X, pt.Y); return(TitleButtons.AnyPushedTitleButtons); }
internal void UpdateSizeGripVisible() { if (!IsHandleCreated) { return; } sizegrip.CapturedControl = Parent; // This is really wierd, the Size_ grip is only showing up // if the bottom right corner of the scrollable control is within // two pixels from the bottom right corner of its parent. bool show_sizegrip = hscrollbar.VisibleInternal && vscrollbar.VisibleInternal; bool enable_sizegrip = false; if (show_sizegrip && Parent != null) { Point_ diff = new Point_(Parent.ClientRectangle.Bottom - Bottom, Parent.ClientRectangle.Right - Right); enable_sizegrip = diff.X <= 2 && diff.X >= 0 && diff.Y <= 2 && diff.Y >= 0; } sizegrip.Visible = show_sizegrip; sizegrip.Enabled = enable_sizegrip || sizegrip.Capture; if (sizegrip.Visible) { XplatUI.SetZOrder(sizegrip.Handle, vscrollbar.Handle, false, false); } }
// // AddBezier // public void AddBezier(Point_ pt1, Point_ pt2, Point_ pt3, Point_ pt4) { Status status = GDIPlus.GdipAddPathBezierI(nativePath, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y); GDIPlus.CheckStatus(status); }
public virtual void UpdateWindowState(FormWindowState old_window_state, FormWindowState new_window_state, bool force) { if (old_window_state == FormWindowState.Normal) { NormalBounds = form.Bounds; } else if (old_window_state == FormWindowState.Minimized) { IconicBounds = form.Bounds; } switch (new_window_state) { case FormWindowState.Minimized: if (IconicBounds == Rectangle_.Empty) { Size_ size = IconicSize; Point_ location = new Point_(0, Form.Parent.ClientSize.Height - size.Height); IconicBounds = new Rectangle_(location, size); } form.Bounds = IconicBounds; break; case FormWindowState.Maximized: form.Bounds = MaximizedBounds; break; case FormWindowState.Normal: form.Bounds = NormalBounds; break; } UpdateWindowDecorations(new_window_state); form.ResetCursor(); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); last_click = e.Location; if (this.RootGridItem == null) { return; } if (e.X > SplitterLocation - RESIZE_WIDTH && e.X < SplitterLocation + RESIZE_WIDTH) { resizing_grid = true; } else { int offset = -vbar.Value * row_height; GridItem foundItem = GetSelectedGridItem(this.RootGridItem.GridItems, e.Y, ref offset); if (foundItem != null) { if (foundItem.Expandable && ((GridEntry)foundItem).PlusMinusBounds.Contains(e.X, e.Y)) { foundItem.Expanded = !foundItem.Expanded; } this.SelectedGridItem = (GridEntry)foundItem; if (!GridLabelHitTest(e.X)) { // send mouse down so we get the carret under cursor grid_textbox.SendMouseDown(PointToScreen(e.Location)); } } } }
MenuItem FindItemByCoords(Menu menu, Point_ pt) { if (menu is MainMenu) { pt = ScreenToMenu(menu, pt); } else { if (menu.Wnd == null) { return(null); } pt = menu.Wnd.PointToClient(pt); } foreach (MenuItem item in menu.MenuItems) { Rectangle_ rect = item.bounds; if (rect.Contains(pt)) { return(item); } } return(null); }
private static void PaintOverflowArrow(ToolStripItemRenderEventArgs e, Rectangle_ paint_here) { if (e.ToolStrip.Orientation == Orientation.Horizontal) { // Paint down arrow Point_ arrow_loc = new Point_(paint_here.X + 2, paint_here.Bottom - 9); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 1, arrow_loc.Y + 1, arrow_loc.X + 5, arrow_loc.Y + 1); e.Graphics.DrawLine(Pens.Black, arrow_loc.X, arrow_loc.Y, arrow_loc.X + 4, arrow_loc.Y); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 3, arrow_loc.Y + 4, arrow_loc.X + 5, arrow_loc.Y + 4); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 3, arrow_loc.Y + 5, arrow_loc.X + 4, arrow_loc.Y + 5); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 3, arrow_loc.Y + 4, arrow_loc.X + 3, arrow_loc.Y + 6); e.Graphics.DrawLine(Pens.Black, arrow_loc.X, arrow_loc.Y + 3, arrow_loc.X + 4, arrow_loc.Y + 3); e.Graphics.DrawLine(Pens.Black, arrow_loc.X + 1, arrow_loc.Y + 4, arrow_loc.X + 3, arrow_loc.Y + 4); e.Graphics.DrawLine(Pens.Black, arrow_loc.X + 2, arrow_loc.Y + 4, arrow_loc.X + 2, arrow_loc.Y + 5); } else { Point_ arrow_loc = new Point_(paint_here.Right - 9, paint_here.Y + 2); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 1, arrow_loc.Y + 1, arrow_loc.X + 1, arrow_loc.Y + 5); e.Graphics.DrawLine(Pens.Black, arrow_loc.X, arrow_loc.Y, arrow_loc.X, arrow_loc.Y + 4); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 4, arrow_loc.Y + 3, arrow_loc.X + 4, arrow_loc.Y + 5); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 5, arrow_loc.Y + 3, arrow_loc.X + 5, arrow_loc.Y + 4); e.Graphics.DrawLine(Pens.White, arrow_loc.X + 4, arrow_loc.Y + 3, arrow_loc.X + 6, arrow_loc.Y + 3); e.Graphics.DrawLine(Pens.Black, arrow_loc.X + 3, arrow_loc.Y, arrow_loc.X + 3, arrow_loc.Y + 4); e.Graphics.DrawLine(Pens.Black, arrow_loc.X + 4, arrow_loc.Y + 1, arrow_loc.X + 4, arrow_loc.Y + 3); e.Graphics.DrawLine(Pens.Black, arrow_loc.X + 4, arrow_loc.Y + 2, arrow_loc.X + 5, arrow_loc.Y + 2); } }
MenuItem FindSubItemByCoord(Menu menu, Point_ pnt) { foreach (MenuItem item in menu.MenuItems) { if (item.IsPopup && item.Wnd != null && item.Wnd.Visible && item == menu.SelectedItem) { MenuItem result = FindSubItemByCoord(item, pnt); if (result != null) { return(result); } } if (menu.Wnd == null || !menu.Wnd.Visible) { continue; } Rectangle_ rect = item.bounds; Point_ pnt_client = menu.Wnd.PointToScreen(new Point_(item.X, item.Y)); rect.X = pnt_client.X; rect.Y = pnt_client.Y; if (rect.Contains(pnt) == true) { return(item); } } return(null); }
internal ResXDataNode(string name, object value, Point_ position) { if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw new ArgumentException("name"); } Type type = (value == null) ? typeof(object) : value.GetType(); if ((value != null) && !type.GetTypeInfo().IsSerializable) { throw new InvalidOperationException(String.Format("'{0}' of type '{1}' cannot be added" + " because it is not serializable", name, type)); } this.name = name; this.pos = position; handler = new InMemoryHandler(value); }
public TabControlPainter() { defaultItemSize = new Size_(42, 16); defaultPadding = new Point_(6, 3); selectedTabDelta = new Rectangle_(2, 2, 4, 3); selectedSpacing = 0; rowSpacingNormal = new Size_(0, 0); rowSpacingButtons = new Size_(3, 3); rowSpacingFlatButtons = new Size_(9, 3); colSpacing = 0; minimumTabWidth = 42; scrollerWidth = 17; focusRectSpacing = new Point_(2, 2); tabPanelOffset = new Point_(4, 0); flatButtonSpacing = 8; tabPageSpacing = new Rectangle_(4, 2, 3, 4); imagePadding = new Point_(2, 3); defaultFormatting = new StringFormat(); // Horizontal Alignment is handled in the Draw method defaultFormatting.Alignment = StringAlignment.Near; defaultFormatting.LineAlignment = StringAlignment.Center; defaultFormatting.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.NoClip; defaultFormatting.HotkeyPrefix = HotkeyPrefix.Show; borderThickness = new Rectangle_(1, 1, 2, 2); }
internal void ShowPopup(Point_ pnt) { // If we are using MainMenuStrip, display that menu instead if (form.WindowState == FormWindowState.Maximized && form.MdiParent.MainMenuStrip != null) { if (form.MdiParent.MainMenuStrip.Items.Count > 0) { ToolStripItem tsi = form.MdiParent.MainMenuStrip.Items[0]; if (tsi is MdiControlStrip.SystemMenuItem) { (tsi as MdiControlStrip.SystemMenuItem).ShowDropDown(); return; } } } icon_popup_menu.MenuItems[0].Enabled = form.window_state != FormWindowState.Normal; // restore icon_popup_menu.MenuItems[1].Enabled = form.window_state != FormWindowState.Maximized; // move icon_popup_menu.MenuItems[2].Enabled = form.window_state != FormWindowState.Maximized; // size icon_popup_menu.MenuItems[3].Enabled = form.window_state != FormWindowState.Minimized; // minimize icon_popup_menu.MenuItems[4].Enabled = form.window_state != FormWindowState.Maximized; // maximize icon_popup_menu.MenuItems[5].Enabled = true; // close icon_popup_menu.MenuItems[6].Enabled = true; // next icon_popup_menu.Show(form, pnt); }
private void ParseDataNode(bool meta) { Hashtable hashtable = ((meta && !useResXDataNodes) ? hashtm : hasht); Point_ pos = new Point_(((IXmlLineInfo)xmlReader).LineNumber, ((IXmlLineInfo)xmlReader).LinePosition); string name = GetAttribute("name"); string type_name = GetAttribute("type"); string mime_type = GetAttribute("mimetype"); string comment = null; string value = GetDataValue(meta, out comment); ResXDataNode node = new ResXDataNode(name, mime_type, type_name, value, comment, pos, BasePath); if (useResXDataNodes) { hashtable [name] = node; return; } if (name == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Could not find a name for a resource. The resource value was '{0}'.", node.GetValue((AssemblyName [])null).ToString())); } // useResXDataNodes is false, add to dictionary of values if (assemblyNames != null) { try { hashtable [name] = node.GetValue(assemblyNames); } catch (TypeLoadException ex) { // different error messages depending on type of resource, hacky solution if (node.handler is TypeConverterFromResXHandler) { hashtable [name] = null; } else { throw ex; } } } else // there is a typeresolver or its null { try { hashtable [name] = node.GetValue(typeresolver); } catch (TypeLoadException ex) { if (node.handler is TypeConverterFromResXHandler) { hashtable [name] = null; } else { throw ex; } } } }
protected virtual void HandleWindowMove(Message m) { Point_ move = MouseMove(Cursor.Position); UpdateVP(virtual_position.X + move.X, virtual_position.Y + move.Y, virtual_position.Width, virtual_position.Height); }
public override void DrawMaximizedButtons(object sender, PaintEventArgs pe) { Size_ bs = ThemeEngine.Current.ManagedWindowGetMenuButtonSize(this); Point_ pnt = XplatUI.GetMenuOrigin(mdi_container.ParentForm.Handle); int bw = ThemeEngine.Current.ManagedWindowBorderWidth(this); TitleButtons buttons = MaximizedTitleButtons; buttons.Visible = true; TitleButtons.Visible = false; buttons.CloseButton.Rectangle = new Rectangle_(mdi_container.ParentForm.Size.Width - 1 - bw - bs.Width - 2, pnt.Y + 2, bs.Width, bs.Height); buttons.RestoreButton.Rectangle = new Rectangle_(buttons.CloseButton.Rectangle.Left - 2 - bs.Width, pnt.Y + 2, bs.Width, bs.Height); buttons.MinimizeButton.Rectangle = new Rectangle_(buttons.RestoreButton.Rectangle.Left - bs.Width, pnt.Y + 2, bs.Width, bs.Height); DrawTitleButton(pe.Graphics, buttons.MinimizeButton, pe.ClipRectangle); DrawTitleButton(pe.Graphics, buttons.RestoreButton, pe.ClipRectangle); DrawTitleButton(pe.Graphics, buttons.CloseButton, pe.ClipRectangle); buttons.MinimizeButton.Rectangle.Y -= pnt.Y; buttons.RestoreButton.Rectangle.Y -= pnt.Y; buttons.CloseButton.Rectangle.Y -= pnt.Y; }
protected override void OnMouseMove(MouseEventArgs args) { base.OnMouseMove(args); if (resizing) { Point_ mouse_loc = Control.MousePosition; Point_ ctrl_loc = PointToScreen(Point_.Empty); Size_ new_size = new Size_(mouse_loc.X - ctrl_loc.X, mouse_loc.Y - ctrl_loc.Y); if (new_size.Height < item_height) { new_size.Height = item_height; } if (new_size.Width < item_height) { new_size.Width = item_height; } Size = new_size; return; } Cursor = resizer_bounds.Contains(args.Location) ? Cursors.SizeNWSE : Cursors.Default; int item_idx = GetItemAt(args.Location); if (item_idx != -1) { HighlightedIndex = item_idx; } }
private bool MouseInControl(Control control, bool fuzzy) { Point_ m; Point_ c; Size_ cw; if (control == null) { return(false); } m = Control.MousePosition; c = new Point_(control.Bounds.X, control.Bounds.Y); if (control.Parent != null) { c = control.Parent.PointToScreen(c); } cw = control.ClientSize; Rectangle_ rect = new Rectangle_(c, cw); // // We won't get mouse move events on all platforms with the exact same // frequency, so cheat a bit. if (fuzzy) { rect.Inflate(2, 2); } return(rect.Contains(m)); }
public void FocusAt(Point_ location) { _focusing = true; Point_ pnt = PointToClient(location); XplatUI.SendMessage(Handle, Msg.WM_LBUTTONDOWN, new IntPtr((int)MsgButtons.MK_LBUTTON), Control.MakeParam(pnt.X, pnt.Y)); }
internal void SendMouseDown(Point_ screenLocation) { Point_ clientLocation = PointToClient(screenLocation); XplatUI.SendMessage(Handle, Msg.WM_LBUTTONDOWN, new IntPtr((int)MsgButtons.MK_LBUTTON), Control.MakeParam(clientLocation.X, clientLocation.Y)); textbox.FocusAt(screenLocation); }
internal static Point_ ScreenToMenu(Menu menu, Point_ pnt) { int x = pnt.X; int y = pnt.Y; XplatUI.ScreenToMenu(menu.Wnd.window.Handle, ref x, ref y); return(new Point_(x, y)); }
public void AddString(string s, FontFamily family, int style, float emSize, Point_ origin, StringFormat format) { Rectangle_ layout = new Rectangle_(); layout.X = origin.X; layout.Y = origin.Y; AddString(s, family, style, emSize, layout, format); }
public LinearGradientBrush(Point_ point1, Point_ point2, Color_ color1, Color_ color2) { Status status = GDIPlus.GdipCreateLineBrushI(ref point1, ref point2, color1.ToArgb(), color2.ToArgb(), WrapMode.Tile, out nativeObject); GDIPlus.CheckStatus(status); status = GDIPlus.GdipGetLineRect(nativeObject, out rectangle); GDIPlus.CheckStatus(status); }
internal override Rectangle_ CalculateConnectedArea() { if (this.OwnerItem != null && !this.OwnerItem.IsOnDropDown && !(this.OwnerItem is MdiControlStrip.SystemMenuItem)) { Point_ owner_screen_loc = OwnerItem.GetCurrentParent().PointToScreen(OwnerItem.Location); return(new Rectangle_(owner_screen_loc.X - Left, 0, this.OwnerItem.Width - 1, 2)); } return(base.CalculateConnectedArea()); }
public void Show(Control control, Point_ position, ToolStripDropDownDirection direction) { if (control == null) { throw new ArgumentNullException("control"); } XplatUI.SetOwner(Handle, control.Handle); Show(control.PointToScreen(position), direction); }
public static Screen FromPoint(Point_ point) { for (int i = 0; i < all_screens.Length; i++) { if (all_screens[i].Bounds.Contains(point)) { return(all_screens[i]); } } return(Screen.PrimaryScreen); }
private bool SplitterHitTest(Point_ location) { if (location.X >= splitter_rectangle.X && location.X <= splitter_rectangle.X + splitter_rectangle.Width && location.Y >= splitter_rectangle.Y && location.Y <= splitter_rectangle.Y + splitter_rectangle.Height) { return(true); } return(false); }
internal void Draw(Rectangle_ rect) { if (Wnd.IsHandleCreated) { Point_ pt = XplatUI.GetMenuOrigin(Wnd.window.Handle); Message m = Message.Create(Wnd.window.Handle, (int)Msg.WM_PAINT, IntPtr.Zero, IntPtr.Zero); PaintEventArgs pevent = XplatUI.PaintEventStart(ref m, Wnd.window.Handle, false); pevent.Graphics.SetClip(new Rectangle_(rect.X + pt.X, rect.Y + pt.Y, rect.Width, rect.Height)); Draw(pevent, Rect); XplatUI.PaintEventEnd(ref m, Wnd.window.Handle, false); } }