/// <summary> /// Gets the view element group that the provided point is inside. /// </summary> /// <param name="pt">Mouse point.</param> /// <returns>Reference if inside a group; otherwise null.</returns> public ViewDrawRibbonGroup ViewGroupFromPoint(Point pt) { // Parent element should be a view layout ViewLayoutControl layoutControl = (ViewLayoutControl)Parent; // Get the location of the child control it contains Point layoutLocation = layoutControl.ChildControl.Location; // Adjust the incoming point for the location of the child control pt.X -= layoutLocation.X; pt.Y -= layoutLocation.Y; // Search the child collection for matching group elements foreach (ViewBase child in this) { // Ignore hidden elements if (child.Visible) { ViewDrawRibbonGroup group = child as ViewDrawRibbonGroup; // Only interested in group instances (not separators or others) if (group != null) { // Does this group match? if (group.ClientRectangle.Contains(pt)) { return(group); } } } } return(null); }
/// <summary> /// Initialize a new instance of the ViewLayoutRibbonScrollPort class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="orientation">Viewport orientation.</param> /// <param name="viewFiller">View to size and position.</param> /// <param name="insetForTabs">Should scoller be inset for use in tabs area.</param> /// <param name="scrollSpeed">Scrolling speed.</param> /// <param name="needPaintDelegate">Delegate for notifying paint/layout requests.</param> public ViewLayoutRibbonScrollPort(KryptonRibbon ribbon, Orientation orientation, ViewBase viewFiller, bool insetForTabs, int scrollSpeed, NeedPaintHandler needPaintDelegate) { Debug.Assert(ribbon != null); Debug.Assert(viewFiller != null); Debug.Assert(needPaintDelegate != null); // Remember initial settings _ribbon = ribbon; _orientation = orientation; _viewFiller = viewFiller; _needPaintDelegate = needPaintDelegate; _scrollSpeed = scrollSpeed; _ribbonTabs = viewFiller as ViewLayoutRibbonTabs; // Default to left hand scroll position _scrollOffset = 0; // Place the child view inside a actual control, so that the contents of the // filler are clipped to the control size. This is needed if the child view // contains controls and need clipping inside this area and so prevent them // from drawing over the end scrollers. _viewControlContent = new RibbonViewControl(ribbon); _viewControlContent.PaintBackground += OnViewControlPaintBackground; ViewLayoutControl = new ViewLayoutControl(_viewControlContent, ribbon, _viewFiller); // Removed because of this // https://github.com/Krypton-Suite/Standard-Toolkit/issues/372 // And the statement below does not make sense, and it didn;t do what it states ! //// For ribbon tabs we want to monitor and intercept the WM_NCHITTEST so that the remainder of the //// tabs area acts like the application title bar and can be used to manipulate the application //if (_ribbonTabs != null) //{ // ViewLayoutControl.ChildControl.WndProcHitTest += OnChildWndProcHitTest; //} // Create the two scrollers used when not enough space for filler _nearScroller = new ViewLayoutRibbonScroller(ribbon, NearOrientation, insetForTabs, needPaintDelegate); _farScroller = new ViewLayoutRibbonScroller(ribbon, FarOrientation, insetForTabs, needPaintDelegate); // Hook into scroller events _nearScroller.Click += OnNearClick; _farScroller.Click += OnFarClick; // Add elements in correct order Add(ViewLayoutControl); Add(_nearScroller); Add(_farScroller); }
/// <summary> /// Initialize a new instance of the ViewLayoutRibbonScrollPort class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="orientation">Viewport orientation.</param> /// <param name="viewFiller">View to size and position.</param> /// <param name="insetForTabs">Should scoller be inset for use in tabs area.</param> /// <param name="scrollSpeed">Scrolling speed.</param> /// <param name="needPaintDelegate">Delegate for notifying paint/layout requests.</param> public ViewLayoutRibbonScrollPort(KryptonRibbon ribbon, Orientation orientation, ViewBase viewFiller, bool insetForTabs, int scrollSpeed, NeedPaintHandler needPaintDelegate) { Debug.Assert(ribbon != null); Debug.Assert(viewFiller != null); Debug.Assert(needPaintDelegate != null); // Remember initial settings _ribbon = ribbon; _orientation = orientation; _viewFiller = viewFiller; _needPaintDelegate = needPaintDelegate; _scrollSpeed = scrollSpeed; _ribbonTabs = viewFiller as ViewLayoutRibbonTabs; // Default to left hand scroll position _scrollOffset = 0; // Place the child view inside a actual control, so that the contents of the // filler are clipped to the control size. This is needed if the child view // contains controls and need clipping inside this area and so prevent them // from drawing over the end scrollers. _viewControlContent = new RibbonViewControl(ribbon); _viewControlContent.PaintBackground += new PaintEventHandler(OnViewControlPaintBackground); _viewControl = new ViewLayoutControl(_viewControlContent, ribbon, _viewFiller); // For ribbon tabs we want to monitor and intercept the WM_NCHITTEST so that the remainder of the // tabs area acts like the application title bar and can be used to manipulate the application if (_ribbonTabs != null) { _viewControl.ChildControl.WndProcHitTest += new EventHandler <ViewControlHitTestArgs>(OnChildWndProcHitTest); } // Create the two scrollers used when not enough space for filler _nearScroller = new ViewLayoutRibbonScroller(ribbon, NearOrientation, insetForTabs, needPaintDelegate); _farScroller = new ViewLayoutRibbonScroller(ribbon, FarOrientation, insetForTabs, needPaintDelegate); // Hook into scroller events _nearScroller.Click += new EventHandler(OnNearClick); _farScroller.Click += new EventHandler(OnFarClick); // Add elements in correct order Add(_viewControl); Add(_nearScroller); Add(_farScroller); }
/// <summary> /// Gets the view element group that the provided point is inside. /// </summary> /// <param name="pt">Mouse point.</param> /// <returns>Reference if inside a group; otherwise null.</returns> public ViewDrawRibbonGroup ViewGroupFromPoint(Point pt) { // There can only be groups showing for the currently selected tab if (Ribbon.SelectedTab != null) { // Get the scroll port for this tab ViewLayoutRibbonScrollPort viewScrollPort = _tabToView[Ribbon.SelectedTab]; // The first child of the scroll port is always the view control ViewLayoutControl viewControl = viewScrollPort[0] as ViewLayoutControl; // The first child of the view control is always the ribbon groups ViewLayoutRibbonGroups viewGroups = viewControl.ChildView as ViewLayoutRibbonGroups; // Ask the view groups to find a matching group return viewGroups.ViewGroupFromPoint(pt); } return null; }
/// <summary> /// Initialize a new instance of the ViewLayoutScrollViewport class. /// </summary> /// <param name="rootControl">Top level visual control.</param> /// <param name="viewportFiller">View element to place inside viewport.</param> /// <param name="paletteBorderEdge">Palette for use with the border edge.</param> /// <param name="paletteMetrics">Palette source for metrics.</param> /// <param name="metricPadding">Metric used to get view padding.</param> /// <param name="metricOvers">Metric used to get overposition.</param> /// <param name="orientation">Orientation for the viewport children.</param> /// <param name="alignment">Alignment of the children within the viewport.</param> /// <param name="animateChange">Animate changes in the viewport.</param> /// <param name="vertical">Is the viewport vertical.</param> /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param> public ViewLayoutScrollViewport(VisualControl rootControl, ViewBase viewportFiller, PaletteBorderEdge paletteBorderEdge, IPaletteMetric paletteMetrics, PaletteMetricPadding metricPadding, PaletteMetricInt metricOvers, VisualOrientation orientation, RelativePositionAlign alignment, bool animateChange, bool vertical, NeedPaintHandler needPaintDelegate) { Debug.Assert(rootControl != null); Debug.Assert(viewportFiller != null); Debug.Assert(needPaintDelegate != null); // We need a way to notify changes in layout _needPaintDelegate = needPaintDelegate; // By default we are showing the contained viewport in vertical scrolling _viewportVertical = vertical; // Our initial visual orientation should match the parameter Orientation = orientation; // Create the child viewport Viewport = new ViewLayoutViewport(paletteMetrics, metricPadding, metricOvers, ViewportOrientation(_viewportVertical), alignment, animateChange) { // Default to same alignment for both directions CounterAlignment = alignment, // We always want the viewport to fill any remainder space FillSpace = true }; // Put the provided element inside the viewport Viewport.Add(viewportFiller); // Hook into animation step events Viewport.AnimateStep += OnAnimateStep; // To prevent the contents of the viewport from being able to draw outside // the viewport (such as having child controls) we use a ViewLayoutControl // that uses a child control to restrict the drawing region. ViewControl = new ViewLayoutControl(rootControl, Viewport) { InDesignMode = rootControl.InDesignMode }; // Create the scrollbar and matching border edge ScrollbarV = new ViewDrawScrollBar(true); ScrollbarH = new ViewDrawScrollBar(false); BorderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical); BorderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal); // Hook into scroll position changes ScrollbarV.ScrollChanged += OnScrollVChanged; ScrollbarH.ScrollChanged += OnScrollHChanged; // Add with appropriate docking style Add(ViewControl, ViewDockStyle.Fill); Add(BorderEdgeV, ViewDockStyle.Right); Add(BorderEdgeH, ViewDockStyle.Bottom); Add(ScrollbarV, ViewDockStyle.Right); Add(ScrollbarH, ViewDockStyle.Bottom); }