protected override void OnMouseDown(MouseEventArgs args) { base.OnMouseDown(args); if (!resizer_bounds.Contains(args.Location)) { return; } user_defined_size = true; resizing = true; Capture = true; }
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); }
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); }
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)); }
internal void HandleMouseMove(object sender, MouseEventArgs e) { Control ctrl = (Control)sender; Rectangle_ rect = GetDefaultRectangle(ctrl); if (rect.Contains(e.X, e.Y)) { ctrl.Cursor = Cursors.SizeNWSE; } else { ctrl.Cursor = Cursors.Default; } if (captured) { int delta_x; int delta_y; Point_ current_point; current_point = Control.MousePosition; delta_x = current_point.X - capture_point.X; delta_y = current_point.Y - capture_point.Y; Control parent = CapturedControl; Form form_parent = parent as Form; Size_ new_size = new Size_(window_w + delta_x, window_h + delta_y); Size_ max_size = form_parent != null ? form_parent.MaximumSize : Size_.Empty; Size_ min_size = form_parent != null ? form_parent.MinimumSize : Size_.Empty; if (new_size.Width > max_size.Width && max_size.Width > 0) { new_size.Width = max_size.Width; } else if (new_size.Width < min_size.Width) { new_size.Width = min_size.Width; } if (new_size.Height > max_size.Height && max_size.Height > 0) { new_size.Height = max_size.Height; } else if (new_size.Height < min_size.Height) { new_size.Height = min_size.Height; } if (new_size != parent.Size) { parent.Size = new_size; } } }
public bool IconRectangleContains(int x, int y) { if (!ShowIcon) { return(false); } Rectangle_ icon = ThemeEngine.Current.ManagedWindowGetTitleBarIconArea(this); return(icon.Contains(x, y)); }
public void AddInvalidArea(Rectangle_ rect) { ArrayList tmp = new ArrayList(); foreach (Rectangle_ r in invalid_list) { if (!rect.Contains(r)) { tmp.Add(r); } } tmp.Add(rect); invalid_list = tmp; }
private void RepositionInScreenWorkingArea(Form form) { Rectangle_ workingArea = Screen.FromControl(form).WorkingArea; if (!workingArea.Contains(form.Bounds)) { int x, y; x = form.Location.X; y = form.Location.Y; if (form.Location.X < workingArea.X) { x = workingArea.X; } if (form.Location.Y + form.Size.Height > workingArea.Height) { Point_ aboveTextBox = PointToScreen(new Point_(grid_textbox.Right - form.Width, grid_textbox.Location.Y)); y = aboveTextBox.Y - form.Size.Height; } form.Location = new Point_(x, y); } }
private void redraw(Graphics graphics) { VisualStyles.PushButtonState top_button_state = VisualStyles.PushButtonState.Normal; VisualStyles.PushButtonState bottom_button_state = VisualStyles.PushButtonState.Normal; if (owner.Enabled) { if (mouse_pressed != 0) { if (mouse_pressed == 1 && top_button_rect.Contains(mouse_x, mouse_y)) { top_button_state = VisualStyles.PushButtonState.Pressed; } if (mouse_pressed == 2 && bottom_button_rect.Contains(mouse_x, mouse_y)) { bottom_button_state = VisualStyles.PushButtonState.Pressed; } } else { if (top_button_entered) { top_button_state = VisualStyles.PushButtonState.Hot; } if (bottom_button_entered) { bottom_button_state = VisualStyles.PushButtonState.Hot; } } } else { top_button_state = VisualStyles.PushButtonState.Disabled; bottom_button_state = VisualStyles.PushButtonState.Disabled; } ThemeEngine.Current.UpDownBaseDrawButton(graphics, top_button_rect, true, top_button_state); ThemeEngine.Current.UpDownBaseDrawButton(graphics, bottom_button_rect, false, bottom_button_state); }
public void ScrollControlIntoView(Control activeControl) { int corner_x; int corner_y; Rectangle_ within = new Rectangle_(); within.Size = ClientSize; if (!AutoScroll || (!hscrollbar.VisibleInternal && !vscrollbar.VisibleInternal)) { return; } if (!Contains(activeControl)) { return; } if (vscrollbar.Visible) { within.Width -= vscrollbar.Width; } if (hscrollbar.Visible) { within.Height -= hscrollbar.Height; } // Don't scroll if already visible if (within.Contains(activeControl.Location) && within.Contains(activeControl.Right, activeControl.Bottom)) { return; } // If the control is above the top or the left, move it down and right until it aligns // with the top/left. // If the control is below the bottom or to the right, move it up/left until it aligns // with the bottom/right, but do never move it further than the top/left side. int x_diff = 0, y_diff = 0; if (activeControl.Top <= 0 || activeControl.Height >= within.Height) { y_diff = -activeControl.Top; } else if (activeControl.Bottom > within.Height) { y_diff = within.Height - activeControl.Bottom; } if (activeControl.Left <= 0 || activeControl.Width >= within.Width) { x_diff = -activeControl.Left; } else if (activeControl.Right > within.Width) { x_diff = within.Width - activeControl.Right; } corner_x = hscrollbar.Value - x_diff; corner_y = vscrollbar.Value - y_diff; if (hscrollbar.VisibleInternal) { if (corner_x > hscrollbar.Maximum) { corner_x = hscrollbar.Maximum; } else if (corner_x < hscrollbar.Minimum) { corner_x = hscrollbar.Minimum; } if (corner_x != hscrollbar.Value) { hscrollbar.Value = corner_x; } } if (vscrollbar.VisibleInternal) { if (corner_y > vscrollbar.Maximum) { corner_y = vscrollbar.Maximum; } else if (corner_y < vscrollbar.Minimum) { corner_y = vscrollbar.Minimum; } if (corner_y != vscrollbar.Value) { vscrollbar.Value = corner_y; } } }
private void OnMouseDownTB(object sender, MouseEventArgs e) { if (!Enabled) { return; } mouse_moved = false; bool fire_timer = false; Point_ point = new Point_(e.X, e.Y); if (orientation == Orientation.Horizontal) { if (thumb_pos.Contains(point)) { this.Capture = true; thumb_pressed = true; thumb_mouseclick = e.X; mouse_down_x_offset = e.X - thumb_pos.X; Invalidate(thumb_area); } else { if (thumb_area.Contains(point)) { is_moving_right = e.X > thumb_pos.X + thumb_pos.Width; if (is_moving_right) { LargeIncrement(); } else { LargeDecrement(); } Invalidate(thumb_area); fire_timer = true; mouse_clickmove = true; } } } else { Rectangle_ vertical_thumb_pos = thumb_pos; vertical_thumb_pos.Width = thumb_pos.Height; vertical_thumb_pos.Height = thumb_pos.Width; if (vertical_thumb_pos.Contains(point)) { this.Capture = true; thumb_pressed = true; thumb_mouseclick = e.Y; mouse_down_x_offset = e.Y - thumb_pos.Y; Invalidate(thumb_area); } else { if (thumb_area.Contains(point)) { is_moving_right = e.Y > thumb_pos.Y + thumb_pos.Width; if (is_moving_right) { LargeDecrement(); } else { LargeIncrement(); } Invalidate(thumb_area); fire_timer = true; mouse_clickmove = true; } } } if (fire_timer) { holdclick_timer.Interval = 300; holdclick_timer.Enabled = true; } }