public override bool OnMouseUp(Glyph g, MouseButtons button) { if ((button != MouseButtons.Left) || (this.ParentUI == null)) { return true; } bool flag = true; if (this.ParentUI.IsDesignerActionPanelVisible) { this.HideUI(); } else if (!this.ignoreNextMouseUp) { if (this.serviceProvider != null) { ISelectionService service = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService)); if ((service != null) && (service.PrimarySelection != this.RelatedComponent)) { List<IComponent> components = new List<IComponent> { this.RelatedComponent }; service.SetSelectedComponents(components, SelectionTypes.Click); } } this.ShowUI(g); } else { flag = false; } this.ignoreNextMouseUp = false; return flag; }
private bool CheckAssociatedControl(Component c, Glyph childGlyph, GlyphCollection glyphs) { bool flag = false; ToolStripDropDownItem dropDownItem = c as ToolStripDropDownItem; if (dropDownItem != null) { flag = this.CheckDropDownBounds(dropDownItem, childGlyph, glyphs); } if (flag) { return flag; } Control associatedControl = this.GetAssociatedControl(c); if (((associatedControl == null) || (associatedControl == this.toolStripContainer)) || System.Design.UnsafeNativeMethods.IsChild(new HandleRef(this.toolStripContainer, this.toolStripContainer.Handle), new HandleRef(associatedControl, associatedControl.Handle))) { return flag; } Rectangle bounds = childGlyph.Bounds; Rectangle rect = base.BehaviorService.ControlRectInAdornerWindow(associatedControl); if ((c == this.designerHost.RootComponent) || !bounds.IntersectsWith(rect)) { glyphs.Insert(0, childGlyph); } return true; }
public void AddRange(Glyph[] value) { for (int i = 0; i < value.Length; i++) { this.Add(value[i]); } }
public void SetDesignerActionPanel(DesignerActionPanel panel, Glyph relatedGlyph) { if ((this._panel == null) || (panel != ((DesignerActionPanel) this._panel.Control))) { this.relatedGlyph = relatedGlyph; panel.SizeChanged += new EventHandler(this.PanelResized); if (this._panel != null) { this.Items.Remove(this._panel); this._panel.Dispose(); this._panel = null; } this._panel = new ToolStripControlHost(panel); this._panel.Margin = Padding.Empty; this._panel.Size = panel.Size; base.SuspendLayout(); base.Size = panel.Size; this.Items.Add(this._panel); base.ResumeLayout(); if (base.Visible) { this.CheckFocusIsRight(); } } }
internal BehaviorService(IServiceProvider serviceProvider, Control windowFrame) { this.serviceProvider = serviceProvider; this.adornerWindow = new AdornerWindow(this, windowFrame); IOverlayService service = (IOverlayService) serviceProvider.GetService(typeof(IOverlayService)); if (service != null) { this.adornerWindowIndex = service.PushOverlay(this.adornerWindow); } this.dragEnterReplies = new Hashtable(); this.adorners = new BehaviorServiceAdornerCollection(this); this.behaviorStack = new ArrayList(); this.hitTestedGlyph = null; this.validDragArgs = null; this.actionPointer = null; this.trackMouseEvent = null; this.trackingMouseEvent = false; IMenuCommandService menuService = serviceProvider.GetService(typeof(IMenuCommandService)) as IMenuCommandService; IDesignerHost host = serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; if ((menuService != null) && (host != null)) { this.menuCommandHandler = new MenuCommandHandler(this, menuService); host.RemoveService(typeof(IMenuCommandService)); host.AddService(typeof(IMenuCommandService), this.menuCommandHandler); } this.useSnapLines = false; this.queriedSnapLines = false; WM_GETALLSNAPLINES = System.Design.SafeNativeMethods.RegisterWindowMessage("WM_GETALLSNAPLINES"); WM_GETRECENTSNAPLINES = System.Design.SafeNativeMethods.RegisterWindowMessage("WM_GETRECENTSNAPLINES"); SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged); }
/// <summary> /// Called when any mouse-enter message enters the adorner window of the BehaviorService. /// </summary> /// <param name="g">A Glyph.</param> /// <returns>true if the message was handled; otherwise, false.</returns> public override bool OnMouseEnter(Glyph g) { // Notify the split container so it can track mouse message if (_splitContainer != null) _splitContainer.DesignMouseEnter(); return base.OnMouseEnter(g); }
public override bool OnMouseDown(System.Windows.Forms.Design.Behavior.Glyph g, MouseButtons button, Point mouseLoc) { CCTabControlDesigner tcd = _designer as CCTabControlDesigner; int index = ((CCTabControlDesigner)_designer).GetTabIndex(g); ((CCTabControl)_designer.Control).SelectedIndex = index; return(base.OnMouseDown(g, button, mouseLoc)); }
public virtual void OnDragLeave(Glyph g, EventArgs e) { if (this.callParentBehavior && (this.GetNextBehavior != null)) { this.GetNextBehavior.OnDragLeave(g, e); } else if (this.GlyphIsValid(g)) { g.Behavior.OnDragLeave(g, e); } }
public override void OnLoseCapture(Glyph g, EventArgs e) { this.captureLost = true; if (this.pushedBehavior) { this.pushedBehavior = false; if (this.BehaviorService != null) { if (this.dragging) { this.dragging = false; for (int i = 0; !this.captureLost && (i < this.resizeComponents.Length); i++) { Control resizeControl = this.resizeComponents[i].resizeControl as Control; Rectangle rect = this.BehaviorService.ControlRectInAdornerWindow(resizeControl); if (!rect.IsEmpty) { using (Graphics graphics = this.BehaviorService.AdornerWindowGraphics) { graphics.SetClip(rect); using (Region region = new Region(rect)) { region.Exclude(Rectangle.Inflate(rect, -2, -2)); this.BehaviorService.Invalidate(region); } graphics.ResetClip(); } } } this.BehaviorService.EnableAllAdorners(true); } this.BehaviorService.PopBehavior(this); if (this.lastResizeRegion != null) { this.BehaviorService.Invalidate(this.lastResizeRegion); this.lastResizeRegion.Dispose(); this.lastResizeRegion = null; } } } if (this.resizeTransaction != null) { DesignerTransaction resizeTransaction = this.resizeTransaction; this.resizeTransaction = null; using (resizeTransaction) { resizeTransaction.Cancel(); } } }
private bool CheckDropDownBounds(ToolStripDropDownItem dropDownItem, Glyph childGlyph, GlyphCollection glyphs) { if (dropDownItem == null) { return false; } Rectangle bounds = childGlyph.Bounds; Rectangle rect = base.BehaviorService.ControlRectInAdornerWindow(dropDownItem.DropDown); if (!bounds.IntersectsWith(rect)) { glyphs.Insert(0, childGlyph); } return true; }
public virtual void OnDragOver(Glyph g, DragEventArgs e) { if (this.callParentBehavior && (this.GetNextBehavior != null)) { this.GetNextBehavior.OnDragOver(g, e); } else if (this.GlyphIsValid(g)) { g.Behavior.OnDragOver(g, e); } else if (e.Effect != DragDropEffects.None) { e.Effect = (Control.ModifierKeys == Keys.Control) ? DragDropEffects.Copy : DragDropEffects.Move; } }
/// <summary> /// Called when any mouse-down message enters the adorner window of the BehaviorService. /// </summary> /// <param name="g">A Glyph.</param> /// <param name="button">A MouseButtons value indicating which button was clicked.</param> /// <param name="pt">The location at which the click occurred.</param> /// <returns>true if the message was handled; otherwise, false.</returns> public override bool OnMouseDown(Glyph g, MouseButtons button, Point pt) { if (_splitContainer != null) { // Convert the adorner coordinate to the split container client coordinate Point splitPt = PointToSplitContainer(g, pt); // Notify the split container so it can track mouse message if (_splitContainer.DesignMouseDown(splitPt, button)) { // Splitter is starting to be moved, we need to capture mouse input _splitContainer.Capture = true; } } return base.OnMouseDown(g, button, pt); }
public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) { if (button == MouseButtons.Left) { ISelectionService service = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService)); if ((service != null) && !this.containerControl.Equals(service.PrimarySelection as Control)) { service.SetSelectedComponents(new object[] { this.containerControl }, SelectionTypes.Toggle | SelectionTypes.Click); ContainerSelectorGlyph glyph = g as ContainerSelectorGlyph; if (glyph == null) { return false; } using (BehaviorServiceAdornerCollectionEnumerator enumerator = this.behaviorService.Adorners.GetEnumerator()) { while (enumerator.MoveNext()) { foreach (Glyph glyph2 in enumerator.Current.Glyphs) { ContainerSelectorGlyph glyph3 = glyph2 as ContainerSelectorGlyph; if ((glyph3 != null) && !glyph3.Equals(glyph)) { ContainerSelectorBehavior relatedBehavior = glyph3.RelatedBehavior as ContainerSelectorBehavior; ContainerSelectorBehavior behavior2 = glyph.RelatedBehavior as ContainerSelectorBehavior; if (((relatedBehavior != null) && (behavior2 != null)) && behavior2.ContainerControl.Equals(relatedBehavior.ContainerControl)) { relatedBehavior.OkToMove = true; relatedBehavior.InitialDragPoint = this.DetermineInitialDragPoint(mouseLoc); continue; } } } } goto Label_0167; } } this.InitialDragPoint = this.DetermineInitialDragPoint(mouseLoc); this.OkToMove = true; } Label_0167: return false; }
public virtual void OnDragOver (Glyph g, DragEventArgs e) { throw new NotImplementedException (); }
internal void ShowUI(Glyph g) { DesignerActionGlyph glyph = g as DesignerActionGlyph; if (glyph != null) { DesignerActionPanel panel = this.CreateDesignerActionPanel(this.RelatedComponent); this.ParentUI.ShowDesignerActionPanel(this.RelatedComponent, panel, glyph); } }
public virtual bool OnMouseMove (Glyph g, MouseButtons button, Point mouseLoc) { throw new NotImplementedException (); }
public virtual void OnQueryContinueDrag (Glyph g, QueryContinueDragEventArgs e) { throw new NotImplementedException (); }
public virtual void OnDragOver(Glyph g, DragEventArgs e) { throw new NotImplementedException(); }
/// <summary> /// QueryContinueDrag can be overridden so that a Behavior can specify its own Drag/Drop rules. /// </summary> public virtual void OnQueryContinueDrag(Glyph g, QueryContinueDragEventArgs e) => throw new NotImplementedException(SR.NotImplementedByDesign);
/// <summary> /// In response to a MouseDown, the SelectionBehavior will push (initiate) a dragBehavior by alerting the SelectionMananger that a new control has been selected and the mouse is down. Note that this is only if we find the related control's Dock property == none. /// </summary> public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) { //we only care about the right mouse button for resizing if (button != MouseButtons.Left) { //pass any other mouse click along - unless we've already started our resize in which case we'll ignore it return(_pushedBehavior); } //start with no selection rules and try to obtain this info from the glyph _targetResizeRules = SelectionRules.None; if (g is SelectionGlyphBase sgb) { _targetResizeRules = sgb.SelectionRules; _cursor = sgb.HitTestCursor; } if (_targetResizeRules == SelectionRules.None) { return(false); } ISelectionService selSvc = (ISelectionService)_serviceProvider.GetService(typeof(ISelectionService)); if (selSvc == null) { return(false); } _initialPoint = mouseLoc; _lastMouseLoc = mouseLoc; //build up a list of our selected controls _primaryControl = selSvc.PrimarySelection as Control; // Since we don't know exactly how many valid objects we are going to have we use this temp ArrayList components = new ArrayList(); foreach (object o in selSvc.GetSelectedComponents()) { if (o is Control) { //don't drag locked controls PropertyDescriptor prop = TypeDescriptor.GetProperties(o)["Locked"]; if (prop != null) { if ((bool)prop.GetValue(o)) { continue; } } components.Add(o); } } if (components.Count == 0) { return(false); } _resizeComponents = new ResizeComponent[components.Count]; for (int i = 0; i < components.Count; i++) { _resizeComponents[i].resizeControl = components[i]; } //push this resizebehavior _pushedBehavior = true; BehaviorService.PushCaptureBehavior(this); return(false); }
/// <summary> /// When any MouseUp message enters the BehaviorService's AdornerWindow /// (nclbuttonupown, lbuttonup, rbuttonup, nclrbuttonup) it is first /// passed here, to the top-most Behavior in the BehaviorStack. Returning /// 'true' from this function signifies that the Message was 'handled' by /// the Behavior and should not continue to be processed. /// </summary> public virtual bool OnMouseUp(Glyph g, MouseButtons button) => throw new NotImplementedException(SR.NotImplementedByDesign);
/// <summary> /// When the mouse pointer leaves a positively hit-tested Glyph with a valid Behavior, this method is invoked. /// </summary> public virtual bool OnMouseLeave(Glyph g) => throw new NotImplementedException(SR.NotImplementedByDesign);
public virtual void OnLoseCapture(Glyph g, EventArgs e) { throw new NotImplementedException(); }
/// <summary> /// When a MouseHover message enters the BehaviorService's AdornerWindow it is first passed here, to the /// top-most Behavior in the BehaviorStack. Returning 'true' from this function signifies that the Message /// was 'handled' by the Behavior and should not continue to be processed. /// </summary> public virtual bool OnMouseHover(Glyph g, Point mouseLoc) => throw new NotImplementedException(SR.NotImplementedByDesign);
/// <summary> /// When any MouseDown message enters the BehaviorService's AdornerWindow (nclbuttondown, lbuttondown, /// rbuttondown, nclrbuttondown) it is first passed here, to the top-most Behavior in the BehaviorStack. /// Returning 'true' from this function signifies that the Message was 'handled' by the Behavior and /// should not continue to be processed. /// </summary> public virtual bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) => throw new NotImplementedException(SR.NotImplementedByDesign);
/// <summary> /// A behavior can request mouse capture through the behavior service by pushing itself with /// PushCaptureBehavior. If it does so, it will be notified through OnLoseCapture when capture is lost. /// Generally the behavior pops itself at this time. Capture is lost when one of the following occurs: /// /// 1. Someone else requests capture. /// 2. Another behavior is pushed. /// 3. This behavior is popped. /// /// In each of these cases OnLoseCapture on the behavior will be called. /// </summary> public virtual void OnLoseCapture(Glyph g, EventArgs e) => throw new NotImplementedException(SR.NotImplementedByDesign);
/// <summary> /// OnDragLeave can be overridden so that a Behavior can specify its own /// Drag/Drop rules. /// </summary> public virtual void OnDragLeave(Glyph g, EventArgs e) { throw new NotImplementedException(SR.NotImplementedByDesign); }
public virtual void OnQueryContinueDrag(Glyph g, QueryContinueDragEventArgs e) { throw new NotImplementedException(); }
public virtual bool OnMouseHover(Glyph g, Point mouseLoc) { throw new NotImplementedException(); }
public virtual bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) { throw new NotImplementedException(); }
public virtual void OnGiveFeedback(Glyph g, GiveFeedbackEventArgs e) { throw new NotImplementedException(); }
/// <summary> /// OnDragOver can be overridden so that a Behavior can specify its own Drag/Drop rules. /// </summary> public virtual void OnDragOver(Glyph g, DragEventArgs e) => throw new NotImplementedException(SR.NotImplementedByDesign);
/// <summary> /// This method will either initiate a new resize operation or continue with an existing one. If we're currently dragging (i.e. resizing) then we look at the resize rules and set the bounds of each control to the new location of the mouse pointer. /// </summary> public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) { if (!_pushedBehavior) { return(false); } bool altKeyPressed = Control.ModifierKeys == Keys.Alt; if (altKeyPressed && _dragManager != null) { //erase any snaplines (if we had any) _dragManager.EraseSnapLines(); } if (!altKeyPressed && mouseLoc.Equals(_lastMouseLoc)) { return(true); } // When DesignerWindowPane has scrollbars and we resize, shrinking the the DesignerWindowPane makes it look like the mouse has moved to the BS. To compensate for that we keep track of the mouse's previous position in screen coordinates, and use that to compare if the mouse has really moved. if (_lastMouseAbs != null) { NativeMethods.POINT mouseLocAbs = new NativeMethods.POINT(mouseLoc.X, mouseLoc.Y); UnsafeNativeMethods.ClientToScreen(new HandleRef(this, _behaviorService.AdornerWindowControl.Handle), mouseLocAbs); if (mouseLocAbs.x == _lastMouseAbs.x && mouseLocAbs.y == _lastMouseAbs.y) { return(true); } } if (!_dragging) { if (Math.Abs(_initialPoint.X - mouseLoc.X) > DesignerUtils.MinDragSize.Width / 2 || Math.Abs(_initialPoint.Y - mouseLoc.Y) > DesignerUtils.MinDragSize.Height / 2) { InitiateResize(); _dragging = true; } else { return(false); } } if (_resizeComponents == null || _resizeComponents.Length == 0) { return(false); } // we do these separately so as not to disturb the cached sizes for values we're not actually changing. For example, if a control is docked top and we modify the height, the width shouldn't be modified. PropertyDescriptor propWidth = null; PropertyDescriptor propHeight = null; PropertyDescriptor propTop = null; PropertyDescriptor propLeft = null; // We do this to make sure that Undo works correctly. if (_initialResize) { propWidth = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Width"]; propHeight = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Height"]; propTop = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Top"]; propLeft = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Left"]; // validate each of the property descriptors. if (propWidth != null && !typeof(int).IsAssignableFrom(propWidth.PropertyType)) { propWidth = null; } if (propHeight != null && !typeof(int).IsAssignableFrom(propHeight.PropertyType)) { propHeight = null; } if (propTop != null && !typeof(int).IsAssignableFrom(propTop.PropertyType)) { propTop = null; } if (propLeft != null && !typeof(int).IsAssignableFrom(propLeft.PropertyType)) { propLeft = null; } } Control targetControl = _resizeComponents[0].resizeControl as Control; _lastMouseLoc = mouseLoc; _lastMouseAbs = new NativeMethods.POINT(mouseLoc.X, mouseLoc.Y); UnsafeNativeMethods.ClientToScreen(new HandleRef(this, _behaviorService.AdornerWindowControl.Handle), _lastMouseAbs); int minHeight = Math.Max(targetControl.MinimumSize.Height, MINSIZE); int minWidth = Math.Max(targetControl.MinimumSize.Width, MINSIZE); if (_dragManager != null) { bool shouldSnap = true; bool shouldSnapHorizontally = true; //if the targetcontrol is at min-size then we do not want to offer up snaplines if ((((_targetResizeRules & SelectionRules.BottomSizeable) != 0) || ((_targetResizeRules & SelectionRules.TopSizeable) != 0)) && (targetControl.Height == minHeight)) { shouldSnap = false; } else if ((((_targetResizeRules & SelectionRules.RightSizeable) != 0) || ((_targetResizeRules & SelectionRules.LeftSizeable) != 0)) && (targetControl.Width == minWidth)) { shouldSnap = false; } //if the targetControl has IntegralHeight turned on, then don't snap if the control can be resized vertically PropertyDescriptor propIntegralHeight = TypeDescriptor.GetProperties(targetControl)["IntegralHeight"]; if (propIntegralHeight != null) { object value = propIntegralHeight.GetValue(targetControl); if (value is bool && (bool)value == true) { shouldSnapHorizontally = false; } } if (!altKeyPressed && shouldSnap) { //here, ask the snapline engine to suggest an offset during our resize // Remembering the last snapoffset allows us to correctly erase snaplines, if the user subsequently holds down the Alt-Key. Remember that we don't physically move the mouse, we move the control. So if we didn't remember the last snapoffset and the user then hit the Alt-Key, we would actually redraw the control at the actual mouse location, which would make the control "jump" which is not what the user would expect. Why does the control "jump"? Because when a control is snapped, we have offset the control relative to where the mouse is, but we have not update the physical mouse position. // When the user hits the Alt-Key they expect the control to be where it was (whether snapped or not). we can't rely on lastSnapOffset to check whether we snapped. We used to check if it was empty, but it can be empty and we still snapped (say the control was snapped, as you continue to move the mouse, it will stay snapped for a while. During that while the snapoffset will got from x to -x (or vice versa) and a one point hit 0. // Since we have to calculate the new size/location differently based on whether we snapped or not, we have to know for sure if we snapped. We do different math because of bug 264996: // - if you snap, we want to move the control edge. // - otherwise, we just want to change the size by the number of pixels moved. _lastSnapOffset = _dragManager.OnMouseMove(targetControl, GenerateSnapLines(_targetResizeRules, mouseLoc), ref _didSnap, shouldSnapHorizontally); } else { _dragManager.OnMouseMove(new Rectangle(-100, -100, 0, 0)); /*just an invalid rect - so we won't snap*///); } // If there's a line to snap to, the offset will come back non-zero. In that case we should adjust the mouse position with the offset such that the size calculation below takes that offset into account. If there's no line, then the offset is 0, and there's no harm in adding the offset. mouseLoc.X += _lastSnapOffset.X; mouseLoc.Y += _lastSnapOffset.Y; } // IF WE ARE SNAPPING TO A CONTROL, then we also need to adjust for the offset between the initialPoint (where the MouseDown happened) and the edge of the control otherwise we would be those pixels off when resizing the control. Remember that snaplines are based on the targetControl, so we need to use the targetControl to figure out the offset. Rectangle controlBounds = new Rectangle(_resizeComponents[0].resizeBounds.X, _resizeComponents[0].resizeBounds.Y, _resizeComponents[0].resizeBounds.Width, _resizeComponents[0].resizeBounds.Height); if ((_didSnap) && (targetControl.Parent != null)) { controlBounds.Location = _behaviorService.MapAdornerWindowPoint(targetControl.Parent.Handle, controlBounds.Location); if (targetControl.Parent.IsMirrored) { controlBounds.Offset(-controlBounds.Width, 0); } } Rectangle newBorderRect = Rectangle.Empty; Rectangle targetBorderRect = Rectangle.Empty; bool drawSnapline = true; Color backColor = targetControl.Parent != null ? targetControl.Parent.BackColor : Color.Empty; for (int i = 0; i < _resizeComponents.Length; i++) { Control control = _resizeComponents[i].resizeControl as Control; Rectangle bounds = control.Bounds; Rectangle oldBounds = bounds; // We need to compute the offset beased on the original cached Bounds ... ListBox doesnt allow drag on the top boundary if this is not done when it is "IntegralHeight" Rectangle baseBounds = _resizeComponents[i].resizeBounds; Rectangle oldBorderRect = BehaviorService.ControlRectInAdornerWindow(control); bool needToUpdate = true; // The ResizeBehavior can easily get into a situation where we are fighting with a layout engine. E.g., We resize control to 50px, LayoutEngine lays out and finds 50px was too small and resized back to 100px. This is what should happen, but it looks bad in the designer. To avoid the flicker we temporarily turn off painting while we do the resize. UnsafeNativeMethods.SendMessage(control.Handle, NativeMethods.WM_SETREDRAW, false, /* unused = */ 0); try { bool fRTL = false; // If the container is mirrored the control origin is in upper-right, so we need to adjust our math for that. Remember that mouse coords have origin in upper left. if (control.Parent != null && control.Parent.IsMirrored) { fRTL = true; } // figure out which ones we're actually changing so we don't blow away the controls cached sizing state. This is important if things are docked we don't want to destroy their "pre-dock" size. BoundsSpecified specified = BoundsSpecified.None; // When we check if we should change height, width, location, we first have to check if the targetControl allows resizing, and then if the control we are currently resizing allows it as well. SelectionRules resizeRules = _resizeComponents[i].resizeRules; if (((_targetResizeRules & SelectionRules.BottomSizeable) != 0) && ((resizeRules & SelectionRules.BottomSizeable) != 0)) { int pixelHeight; if (_didSnap) { pixelHeight = mouseLoc.Y - controlBounds.Bottom; } else { pixelHeight = AdjustPixelsForIntegralHeight(control, mouseLoc.Y - _initialPoint.Y); } bounds.Height = Math.Max(minHeight, baseBounds.Height + pixelHeight); specified |= BoundsSpecified.Height; } if (((_targetResizeRules & SelectionRules.TopSizeable) != 0) && ((resizeRules & SelectionRules.TopSizeable) != 0)) { int yOffset; if (_didSnap) { yOffset = controlBounds.Y - mouseLoc.Y; } else { yOffset = AdjustPixelsForIntegralHeight(control, _initialPoint.Y - mouseLoc.Y); } specified |= BoundsSpecified.Height; bounds.Height = Math.Max(minHeight, baseBounds.Height + yOffset); if ((bounds.Height != minHeight) || ((bounds.Height == minHeight) && (oldBounds.Height != minHeight))) { specified |= BoundsSpecified.Y; //if you do it fast enough, we actually could end up placing the control off the parent (say off the form), so enforce a "minimum" location bounds.Y = Math.Min(baseBounds.Bottom - minHeight, baseBounds.Y - yOffset); } } if (((((_targetResizeRules & SelectionRules.RightSizeable) != 0) && ((resizeRules & SelectionRules.RightSizeable) != 0)) && (!fRTL)) || ((((_targetResizeRules & SelectionRules.LeftSizeable) != 0) && ((resizeRules & SelectionRules.LeftSizeable) != 0)) && (fRTL))) { specified |= BoundsSpecified.Width; int xOffset = _initialPoint.X; if (_didSnap) { xOffset = !fRTL ? controlBounds.Right : controlBounds.Left; } bounds.Width = Math.Max(minWidth, baseBounds.Width + (!fRTL ? (mouseLoc.X - xOffset) : (xOffset - mouseLoc.X))); } if (((((_targetResizeRules & SelectionRules.RightSizeable) != 0) && ((resizeRules & SelectionRules.RightSizeable) != 0)) && (fRTL)) || ((((_targetResizeRules & SelectionRules.LeftSizeable) != 0) && ((resizeRules & SelectionRules.LeftSizeable) != 0)) && (!fRTL))) { specified |= BoundsSpecified.Width; int xPos = _initialPoint.X; if (_didSnap) { xPos = !fRTL ? controlBounds.Left : controlBounds.Right; } int xOffset = !fRTL ? (xPos - mouseLoc.X) : (mouseLoc.X - xPos); bounds.Width = Math.Max(minWidth, baseBounds.Width + xOffset); if ((bounds.Width != minWidth) || ((bounds.Width == minWidth) && (oldBounds.Width != minWidth))) { specified |= BoundsSpecified.X; //if you do it fast enough, we actually could end up placing the control off the parent (say off the form), so enforce a "minimum" location bounds.X = Math.Min(baseBounds.Right - minWidth, baseBounds.X - xOffset); } } if (!_parentGridSize.IsEmpty) { bounds = AdjustToGrid(bounds, _targetResizeRules); } // Checking specified (check the diff) rather than bounds.<foo> != resizeBounds[i].<foo> also handles the following corner cases: // 1. Create a form and add 2 buttons. Make sure that they are snapped to the left edge. Now grab the left edge of button 1, and start resizing to the left, past the snapline you will initially get, and then back to the right. What you would expect is to get the left edge snapline again. But without the specified check you wouldn't. This is because the bounds.<foo> != resizeBounds[i].<foo> checks would fail, since the new size would now be the original size. We could probably live with that, except that we draw the snapline below, since we correctly identified one. We could hack it so that we didn't draw the snapline, but that would confuse the user even more. // 2. Create a form and add a single button. Place it at 100,100. Now start resizing it to the left and then back to the right. Note that with the original check (see diff), you would never be able to resize it back to position 100,100. You would get to 99,100 and then to 101,100. if (((specified & BoundsSpecified.Width) == BoundsSpecified.Width) && _dragging && _initialResize && propWidth != null) { propWidth.SetValue(_resizeComponents[i].resizeControl, bounds.Width); } if (((specified & BoundsSpecified.Height) == BoundsSpecified.Height) && _dragging && _initialResize && propHeight != null) { propHeight.SetValue(_resizeComponents[i].resizeControl, bounds.Height); } if (((specified & BoundsSpecified.X) == BoundsSpecified.X) && _dragging && _initialResize && propLeft != null) { propLeft.SetValue(_resizeComponents[i].resizeControl, bounds.X); } if (((specified & BoundsSpecified.Y) == BoundsSpecified.Y) && _dragging && _initialResize && propTop != null) { propTop.SetValue(_resizeComponents[i].resizeControl, bounds.Y); } // We check the dragging bit here at every turn, because if there was a popup we may have lost capture and we are terminated. At that point we shouldn't make any changes. if (_dragging) { control.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height, specified); //Get the new resize border newBorderRect = BehaviorService.ControlRectInAdornerWindow(control); if (control.Equals(targetControl)) { Debug.Assert(i == 0, "The first control in the Selection should be the target control"); targetBorderRect = newBorderRect; } //Check that the control really did resize itself. Some controls (like ListBox, MonthCalendar) might adjust to a slightly different size than the one we pass in SetBounds. If if didn't size, then there's no need to invalidate anything if (control.Bounds == oldBounds) { needToUpdate = false; } // We would expect the bounds now to be what we set it to above, but this might not be the case. If the control is hosted with e.g. a FLP, then setting the bounds above actually might force a re-layout, and the control will get moved to another spot. In this case, we don't really want to draw a snapline. Even if we snapped to a snapline, if the control got moved, the snapline would be in the wrong place. if (control.Bounds != bounds) { drawSnapline = false; } } if (control == _primaryControl && _statusCommandUI != null) { _statusCommandUI.SetStatusInformation(control as Component); } } finally { // While we were resizing we discarded painting messages to reduce flicker. We now turn painting back on and manually refresh the controls. UnsafeNativeMethods.SendMessage(control.Handle, NativeMethods.WM_SETREDRAW, true, /* unused = */ 0); //update the control if (needToUpdate) { Control parent = control.Parent; if (parent != null) { control.Invalidate(/* invalidateChildren = */ true); parent.Invalidate(oldBounds, /* invalidateChildren = */ true); parent.Update(); } else { control.Refresh(); } } //render the resize border if (!newBorderRect.IsEmpty) { using (Region newRegion = new Region(newBorderRect)) { newRegion.Exclude(Rectangle.Inflate(newBorderRect, -BorderSize, -BorderSize)); //No reason to get smart about only invalidating part of the border. Thought we could be but no.The reason is the order: ... the new border is drawn (last resize) On next mousemove, the control is resized which redraws the control AND ERASES THE BORDER Then we draw the new border - flash baby. Thus this will always flicker. if (needToUpdate) { using (Region oldRegion = new Region(oldBorderRect)) { oldRegion.Exclude(Rectangle.Inflate(oldBorderRect, -BorderSize, -BorderSize)); BehaviorService.Invalidate(oldRegion); } } //draw the new border captureLost could be true if a popup came up and caused a lose focus if (!_captureLost) { using (Graphics graphics = BehaviorService.AdornerWindowGraphics) { if (_lastResizeRegion != null) { if (!_lastResizeRegion.Equals(newRegion, graphics)) { _lastResizeRegion.Exclude(newRegion); //we don't want to invalidate this region. BehaviorService.Invalidate(_lastResizeRegion); //might be the same, might not. _lastResizeRegion.Dispose(); _lastResizeRegion = null; } } DesignerUtils.DrawResizeBorder(graphics, newRegion, backColor); } if (_lastResizeRegion == null) { _lastResizeRegion = newRegion.Clone(); //we will need to dispose it later. } } } } } } if ((drawSnapline) && (!altKeyPressed) && (_dragManager != null)) { _dragManager.RenderSnapLinesInternal(targetBorderRect); } _initialResize = false; return(true); }
/// <summary> /// OnGiveFeedback can be overridden so that a Behavior can specify its own Drag/Drop rules. /// </summary> public virtual void OnGiveFeedback(Glyph g, GiveFeedbackEventArgs e) => throw new NotImplementedException(SR.NotImplementedByDesign);
public virtual bool OnMouseUp(Glyph g, MouseButtons button) { throw new NotImplementedException(); }
/// <summary> /// This ends the Behavior by popping itself from the BehaviorStack. Also, all Adorners are re-enabled at the end of a successful drag. /// </summary> public override bool OnMouseUp(Glyph g, MouseButtons button) { try { if (_dragging) { if (_dragManager != null) { _dragManager.OnMouseUp(); _dragManager = null; _lastSnapOffset = Point.Empty; _didSnap = false; } if (_resizeComponents != null && _resizeComponents.Length > 0) { // we do these separately so as not to disturb the cached sizes for values we're not actually changing. For example, if a control is docked top and we modify the height, the width shouldn't be modified. PropertyDescriptor propWidth = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Width"]; PropertyDescriptor propHeight = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Height"]; PropertyDescriptor propTop = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Top"]; PropertyDescriptor propLeft = TypeDescriptor.GetProperties(_resizeComponents[0].resizeControl)["Left"]; for (int i = 0; i < _resizeComponents.Length; i++) { if (propWidth != null && ((Control)_resizeComponents[i].resizeControl).Width != _resizeComponents[i].resizeBounds.Width) { propWidth.SetValue(_resizeComponents[i].resizeControl, ((Control)_resizeComponents[i].resizeControl).Width); } if (propHeight != null && ((Control)_resizeComponents[i].resizeControl).Height != _resizeComponents[i].resizeBounds.Height) { propHeight.SetValue(_resizeComponents[i].resizeControl, ((Control)_resizeComponents[i].resizeControl).Height); } if (propTop != null && ((Control)_resizeComponents[i].resizeControl).Top != _resizeComponents[i].resizeBounds.Y) { propTop.SetValue(_resizeComponents[i].resizeControl, ((Control)_resizeComponents[i].resizeControl).Top); } if (propLeft != null && ((Control)_resizeComponents[i].resizeControl).Left != _resizeComponents[i].resizeBounds.X) { propLeft.SetValue(_resizeComponents[i].resizeControl, ((Control)_resizeComponents[i].resizeControl).Left); } if (_resizeComponents[i].resizeControl == _primaryControl && _statusCommandUI != null) { _statusCommandUI.SetStatusInformation(_primaryControl as Component); } } } } if (_resizeTransaction != null) { DesignerTransaction t = _resizeTransaction; _resizeTransaction = null; using (t) { t.Commit(); } } } finally { // This pops us off the stack, re-enables adorners and clears the "dragging" flag. OnLoseCapture(g, EventArgs.Empty); } return(false); }
public virtual bool OnMouseLeave(Glyph g) { throw new NotImplementedException(); }
public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) { return !this.ParentUI.IsDesignerActionPanelVisible; }
public virtual bool OnMouseLeave (Glyph g) { throw new NotImplementedException (); }
public override void OnDragLeave(Glyph g, EventArgs e) { this.controlRect = Rectangle.Empty; this.designer.OnDragLeave(e); }
public virtual bool OnMouseUp (Glyph g, MouseButtons button) { throw new NotImplementedException (); }
public override void OnGiveFeedback(Glyph g, GiveFeedbackEventArgs e) { this.designer.OnGiveFeedback(e); }
public virtual void OnDragLeave (Glyph g, EventArgs e) { throw new NotImplementedException (); }
public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) { if (button != MouseButtons.Left) { return this.pushedBehavior; } this.targetResizeRules = SelectionRules.None; SelectionGlyphBase base2 = g as SelectionGlyphBase; if (base2 != null) { this.targetResizeRules = base2.SelectionRules; this.cursor = base2.HitTestCursor; } if (this.targetResizeRules != SelectionRules.None) { ISelectionService service = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService)); if (service == null) { return false; } this.initialPoint = mouseLoc; this.lastMouseLoc = mouseLoc; this.primaryControl = service.PrimarySelection as Control; ArrayList list = new ArrayList(); foreach (object obj2 in service.GetSelectedComponents()) { if (obj2 is Control) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(obj2)["Locked"]; if ((descriptor == null) || !((bool) descriptor.GetValue(obj2))) { list.Add(obj2); } } } if (list.Count == 0) { return false; } this.resizeComponents = new ResizeComponent[list.Count]; for (int i = 0; i < list.Count; i++) { this.resizeComponents[i].resizeControl = list[i]; } this.pushedBehavior = true; this.BehaviorService.PushCaptureBehavior(this); } return false; }
public virtual void OnGiveFeedback (Glyph g, GiveFeedbackEventArgs e) { throw new NotImplementedException (); }
public override bool OnMouseUp(Glyph g, MouseButtons button) { try { if (this.dragging) { if (this.dragManager != null) { this.dragManager.OnMouseUp(); this.dragManager = null; this.lastSnapOffset = Point.Empty; this.didSnap = false; } if ((this.resizeComponents != null) && (this.resizeComponents.Length > 0)) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Width"]; PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Height"]; PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Top"]; PropertyDescriptor descriptor4 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Left"]; for (int i = 0; i < this.resizeComponents.Length; i++) { if ((descriptor != null) && (((Control) this.resizeComponents[i].resizeControl).Width != this.resizeComponents[i].resizeBounds.Width)) { descriptor.SetValue(this.resizeComponents[i].resizeControl, ((Control) this.resizeComponents[i].resizeControl).Width); } if ((descriptor2 != null) && (((Control) this.resizeComponents[i].resizeControl).Height != this.resizeComponents[i].resizeBounds.Height)) { descriptor2.SetValue(this.resizeComponents[i].resizeControl, ((Control) this.resizeComponents[i].resizeControl).Height); } if ((descriptor3 != null) && (((Control) this.resizeComponents[i].resizeControl).Top != this.resizeComponents[i].resizeBounds.Y)) { descriptor3.SetValue(this.resizeComponents[i].resizeControl, ((Control) this.resizeComponents[i].resizeControl).Top); } if ((descriptor4 != null) && (((Control) this.resizeComponents[i].resizeControl).Left != this.resizeComponents[i].resizeBounds.X)) { descriptor4.SetValue(this.resizeComponents[i].resizeControl, ((Control) this.resizeComponents[i].resizeControl).Left); } if ((this.resizeComponents[i].resizeControl == this.primaryControl) && (this.statusCommandUI != null)) { this.statusCommandUI.SetStatusInformation(this.primaryControl); } } } } if (this.resizeTransaction != null) { DesignerTransaction resizeTransaction = this.resizeTransaction; this.resizeTransaction = null; using (resizeTransaction) { resizeTransaction.Commit(); } } } finally { this.OnLoseCapture(g, EventArgs.Empty); } return false; }
public override bool OnMouseDoubleClick(Glyph g, MouseButtons button, Point mouseLoc) { this.ignoreNextMouseUp = true; return true; }
/// <summary> /// When the mouse pointer's location is positively hit-tested with a /// different Glyph than previous hit-tests, this event is fired on the /// Behavior associated with the Glyph. /// </summary> public virtual bool OnMouseEnter(Glyph g) { throw new NotImplementedException(SR.NotImplementedByDesign); }
public override void OnDragEnter(Glyph g, DragEventArgs e) { if ((this.designer != null) && (this.designer.Control != null)) { this.controlRect = this.designer.Control.RectangleToScreen(this.designer.Control.ClientRectangle); } this.designer.OnDragEnter(e); }
public int IndexOf(Glyph value) { return(InnerList.IndexOf(value)); }
public override void OnDragOver(Glyph g, DragEventArgs e) { if (((e != null) && (this.controlRect != Rectangle.Empty)) && !this.controlRect.Contains(new Point(e.X, e.Y))) { e.Effect = DragDropEffects.None; } else { this.designer.OnDragOver(e); } }
public void Insert(int index, Glyph value) { InnerList.Insert(index, value); }
public override bool OnMouseUp(Glyph g, MouseButtons button) { _designer.AddPanel(this, EventArgs.Empty); return base.OnMouseUp(g, button); }
public void Remove(Glyph value) { InnerList.Remove(value); }
public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) { if (!this.pushedBehavior) { return false; } bool flag = Control.ModifierKeys == Keys.Alt; if (flag && (this.dragManager != null)) { this.dragManager.EraseSnapLines(); } if (flag || !mouseLoc.Equals(this.lastMouseLoc)) { if (this.lastMouseAbs != null) { System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(mouseLoc.X, mouseLoc.Y); System.Design.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, this.behaviorService.AdornerWindowControl.Handle), pt); if ((pt.x == this.lastMouseAbs.x) && (pt.y == this.lastMouseAbs.y)) { return true; } } if (!this.dragging) { if ((Math.Abs((int) (this.initialPoint.X - mouseLoc.X)) <= (DesignerUtils.MinDragSize.Width / 2)) && (Math.Abs((int) (this.initialPoint.Y - mouseLoc.Y)) <= (DesignerUtils.MinDragSize.Height / 2))) { return false; } this.InitiateResize(); this.dragging = true; } if ((this.resizeComponents == null) || (this.resizeComponents.Length == 0)) { return false; } PropertyDescriptor descriptor = null; PropertyDescriptor descriptor2 = null; PropertyDescriptor descriptor3 = null; PropertyDescriptor descriptor4 = null; if (this.initialResize) { descriptor = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Width"]; descriptor2 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Height"]; descriptor3 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Top"]; descriptor4 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Left"]; if ((descriptor != null) && !typeof(int).IsAssignableFrom(descriptor.PropertyType)) { descriptor = null; } if ((descriptor2 != null) && !typeof(int).IsAssignableFrom(descriptor2.PropertyType)) { descriptor2 = null; } if ((descriptor3 != null) && !typeof(int).IsAssignableFrom(descriptor3.PropertyType)) { descriptor3 = null; } if ((descriptor4 != null) && !typeof(int).IsAssignableFrom(descriptor4.PropertyType)) { descriptor4 = null; } } Control resizeControl = this.resizeComponents[0].resizeControl as Control; this.lastMouseLoc = mouseLoc; this.lastMouseAbs = new System.Design.NativeMethods.POINT(mouseLoc.X, mouseLoc.Y); System.Design.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, this.behaviorService.AdornerWindowControl.Handle), this.lastMouseAbs); int num = Math.Max(resizeControl.MinimumSize.Height, 10); int num2 = Math.Max(resizeControl.MinimumSize.Width, 10); if (this.dragManager != null) { bool flag2 = true; bool shouldSnapHorizontally = true; if ((((this.targetResizeRules & SelectionRules.BottomSizeable) != SelectionRules.None) || ((this.targetResizeRules & SelectionRules.TopSizeable) != SelectionRules.None)) && (resizeControl.Height == num)) { flag2 = false; } else if ((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) || ((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && (resizeControl.Width == num2)) { flag2 = false; } PropertyDescriptor descriptor5 = TypeDescriptor.GetProperties(resizeControl)["IntegralHeight"]; if (descriptor5 != null) { object obj2 = descriptor5.GetValue(resizeControl); if ((obj2 is bool) && ((bool) obj2)) { shouldSnapHorizontally = false; } } if (!flag && flag2) { this.lastSnapOffset = this.dragManager.OnMouseMove(resizeControl, this.GenerateSnapLines(this.targetResizeRules, mouseLoc), ref this.didSnap, shouldSnapHorizontally); } else { this.dragManager.OnMouseMove(new Rectangle(-100, -100, 0, 0)); } mouseLoc.X += this.lastSnapOffset.X; mouseLoc.Y += this.lastSnapOffset.Y; } Rectangle rectangle = new Rectangle(this.resizeComponents[0].resizeBounds.X, this.resizeComponents[0].resizeBounds.Y, this.resizeComponents[0].resizeBounds.Width, this.resizeComponents[0].resizeBounds.Height); if (this.didSnap && (resizeControl.Parent != null)) { rectangle.Location = this.behaviorService.MapAdornerWindowPoint(resizeControl.Parent.Handle, rectangle.Location); if (resizeControl.Parent.IsMirrored) { rectangle.Offset(-rectangle.Width, 0); } } Rectangle empty = Rectangle.Empty; Rectangle dragRect = Rectangle.Empty; bool flag4 = true; Color backColor = (resizeControl.Parent != null) ? resizeControl.Parent.BackColor : Color.Empty; for (int i = 0; i < this.resizeComponents.Length; i++) { Control c = this.resizeComponents[i].resizeControl as Control; Rectangle bounds = c.Bounds; Rectangle rc = bounds; Rectangle resizeBounds = this.resizeComponents[i].resizeBounds; Rectangle rect = this.BehaviorService.ControlRectInAdornerWindow(c); bool flag5 = true; System.Design.UnsafeNativeMethods.SendMessage(c.Handle, 11, false, 0); try { bool flag6 = false; if ((c.Parent != null) && c.Parent.IsMirrored) { flag6 = true; } BoundsSpecified none = BoundsSpecified.None; SelectionRules resizeRules = this.resizeComponents[i].resizeRules; if (((this.targetResizeRules & SelectionRules.BottomSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.BottomSizeable) != SelectionRules.None)) { int num4; if (this.didSnap) { num4 = mouseLoc.Y - rectangle.Bottom; } else { num4 = AdjustPixelsForIntegralHeight(c, mouseLoc.Y - this.initialPoint.Y); } bounds.Height = Math.Max(num, resizeBounds.Height + num4); none |= BoundsSpecified.Height; } if (((this.targetResizeRules & SelectionRules.TopSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.TopSizeable) != SelectionRules.None)) { int num5; if (this.didSnap) { num5 = rectangle.Y - mouseLoc.Y; } else { num5 = AdjustPixelsForIntegralHeight(c, this.initialPoint.Y - mouseLoc.Y); } none |= BoundsSpecified.Height; bounds.Height = Math.Max(num, resizeBounds.Height + num5); if ((bounds.Height != num) || ((bounds.Height == num) && (rc.Height != num))) { none |= BoundsSpecified.Y; bounds.Y = Math.Min((int) (resizeBounds.Bottom - num), (int) (resizeBounds.Y - num5)); } } if (((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.RightSizeable) != SelectionRules.None)) && !flag6) || ((((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && flag6)) { none |= BoundsSpecified.Width; int x = this.initialPoint.X; if (this.didSnap) { x = !flag6 ? rectangle.Right : rectangle.Left; } bounds.Width = Math.Max(num2, resizeBounds.Width + (!flag6 ? (mouseLoc.X - x) : (x - mouseLoc.X))); } if (((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.RightSizeable) != SelectionRules.None)) && flag6) || ((((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && !flag6)) { none |= BoundsSpecified.Width; int num7 = this.initialPoint.X; if (this.didSnap) { num7 = !flag6 ? rectangle.Left : rectangle.Right; } int num8 = !flag6 ? (num7 - mouseLoc.X) : (mouseLoc.X - num7); bounds.Width = Math.Max(num2, resizeBounds.Width + num8); if ((bounds.Width != num2) || ((bounds.Width == num2) && (rc.Width != num2))) { none |= BoundsSpecified.X; bounds.X = Math.Min((int) (resizeBounds.Right - num2), (int) (resizeBounds.X - num8)); } } if (!this.parentGridSize.IsEmpty) { bounds = this.AdjustToGrid(bounds, this.targetResizeRules); } if ((((none & BoundsSpecified.Width) == BoundsSpecified.Width) && this.dragging) && (this.initialResize && (descriptor != null))) { descriptor.SetValue(this.resizeComponents[i].resizeControl, bounds.Width); } if ((((none & BoundsSpecified.Height) == BoundsSpecified.Height) && this.dragging) && (this.initialResize && (descriptor2 != null))) { descriptor2.SetValue(this.resizeComponents[i].resizeControl, bounds.Height); } if ((((none & BoundsSpecified.X) == BoundsSpecified.X) && this.dragging) && (this.initialResize && (descriptor4 != null))) { descriptor4.SetValue(this.resizeComponents[i].resizeControl, bounds.X); } if ((((none & BoundsSpecified.Y) == BoundsSpecified.Y) && this.dragging) && (this.initialResize && (descriptor3 != null))) { descriptor3.SetValue(this.resizeComponents[i].resizeControl, bounds.Y); } if (this.dragging) { c.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height, none); empty = this.BehaviorService.ControlRectInAdornerWindow(c); if (c.Equals(resizeControl)) { dragRect = empty; } if (c.Bounds == rc) { flag5 = false; } if (c.Bounds != bounds) { flag4 = false; } } if ((c == this.primaryControl) && (this.statusCommandUI != null)) { this.statusCommandUI.SetStatusInformation(c); } } finally { System.Design.UnsafeNativeMethods.SendMessage(c.Handle, 11, true, 0); if (flag5) { Control parent = c.Parent; if (parent != null) { c.Invalidate(true); parent.Invalidate(rc, true); parent.Update(); } else { c.Refresh(); } } if (!empty.IsEmpty) { using (Region region = new Region(empty)) { region.Exclude(Rectangle.Inflate(empty, -2, -2)); if (flag5) { using (Region region2 = new Region(rect)) { region2.Exclude(Rectangle.Inflate(rect, -2, -2)); this.BehaviorService.Invalidate(region2); } } if (!this.captureLost) { using (Graphics graphics = this.BehaviorService.AdornerWindowGraphics) { if ((this.lastResizeRegion != null) && !this.lastResizeRegion.Equals(region, graphics)) { this.lastResizeRegion.Exclude(region); this.BehaviorService.Invalidate(this.lastResizeRegion); this.lastResizeRegion.Dispose(); this.lastResizeRegion = null; } DesignerUtils.DrawResizeBorder(graphics, region, backColor); } if (this.lastResizeRegion == null) { this.lastResizeRegion = region.Clone(); } } } } } } if ((flag4 && !flag) && (this.dragManager != null)) { this.dragManager.RenderSnapLinesInternal(dragRect); } this.initialResize = false; } return true; }
public int Add(Glyph value) { return(InnerList.Add(value)); }
public bool Contains(Glyph value) { return(InnerList.Contains(value)); }
public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) { bool altKeyPressed = Control.ModifierKeys == Keys.Alt; if (altKeyPressed && dragManager != null) { //erase any snaplines (if we had any) dragManager.EraseSnapLines(); } //call base bool retValue = base.OnMouseMove(g, button, mouseLoc); //identify where the new box should be... Rectangle newRectangle = new Rectangle(mouseLoc.X - DesignerUtils.BOXIMAGESIZE / 2, mouseLoc.Y - DesignerUtils.BOXIMAGESIZE / 2, DesignerUtils.BOXIMAGESIZE, DesignerUtils.BOXIMAGESIZE); //don't do anything if the loc is the same if (newRectangle != lastRectangle) { if (dragManager != null && targetAllowsSnapLines && !altKeyPressed) { lastOffset = dragManager.OnMouseMove(newRectangle, GenerateNewToolSnapLines(newRectangle)); newRectangle.Offset(lastOffset.X, lastOffset.Y); } //erase old if (!lastRectangle.IsEmpty) { //build up the invalid region using (Region invalidRegion = new Region(lastRectangle)) { invalidRegion.Exclude(newRectangle); behaviorService.Invalidate(invalidRegion); } } if (targetAllowsDragBox) { using (Graphics graphics = behaviorService.AdornerWindowGraphics) { graphics.DrawImage(DesignerUtils.BoxImage, newRectangle.Location); } } //offset the mouse loc to screen coords for calculations on drops IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); if (host != null) { Control baseControl = host.RootComponent as Control; if (baseControl != null) { Point adornerServiceOrigin = behaviorService.MapAdornerWindowPoint(baseControl.Handle, new Point(0, 0)); Rectangle statusRect = new Rectangle(newRectangle.X - adornerServiceOrigin.X, newRectangle.Y - adornerServiceOrigin.Y, 0, 0); if (statusCommandUI != null) { statusCommandUI.SetStatusInformation(statusRect); } } } if (dragManager != null && targetAllowsSnapLines && !altKeyPressed) { dragManager.RenderSnapLinesInternal(); } //store this off for the next time around lastRectangle = newRectangle; } return(retValue); }