/// <summary> /// Initialize a new instance of the ViewManager class. /// </summary> /// <param name="control">Owning control.</param> /// <param name="root">Root of the view hierarchy.</param> public ViewManager(Control control, ViewBase root) { _root = root; _root.OwningControl = control; _control = control; _alignControl = control; }
/// <summary> /// Construct the view appropriate for this builder. /// </summary> /// <param name="navigator">Reference to navigator instance.</param> /// <param name="manager">Reference to current manager.</param> /// <param name="redirector">Palette redirector.</param> public override void Construct(KryptonNavigator navigator, ViewManager manager, PaletteRedirect redirector) { // Let base class perform common operations base.Construct(navigator, manager, redirector); // Get the current root element _oldRoot = ViewManager.Root; // Create a canvas for the border and background using current enabled state _drawCanvas = new ViewDrawCanvas(Navigator.StateNormal.HeaderGroup.Back, Navigator.StateNormal.HeaderGroup.Border, VisualOrientation.Top); // Put the exising root into the canvas _drawCanvas.Add(_oldRoot); // Set the correct palettes based on enabled state and selected page UpdateStatePalettes(); // Canvas becomes the new root ViewManager.Root = _drawCanvas; // Need to monitor changes in the enabled state Navigator.EnabledChanged += new EventHandler(OnEnabledChanged); }
/// <summary> /// Initialize a new instance of the ViewLayoutControl class. /// </summary> /// <param name="viewControl">View control to use as child.</param> /// <param name="rootControl">Top level visual control.</param> /// <param name="viewChild">View used to size and position the child control.</param> public ViewLayoutControl(ViewControl viewControl, VisualControl rootControl, ViewBase viewChild) { Debug.Assert(viewControl != null); Debug.Assert(rootControl != null); Debug.Assert(viewChild != null); // Default values _layoutOffset = Point.Empty; // Remember the view _viewChild = viewChild; // Ensure the child is hooked into the hierarchy of elements _viewChild.Parent = this; // Create the view control instance _viewControl = viewControl; // Back reference hookup _viewControl.ViewLayoutControl = this; // Start off invisible until first layed out _viewControl.Visible = false; // Ensure that all view elements inside here use our control OwningControl = _viewControl; // Add our new control to the provided parent collection CommonHelper.AddControlToParent(rootControl, _viewControl); }
/// <summary> /// Construtor /// </summary> public LegendView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.LegendView.glade", "hbox1"); gxml.Autoconnect(this); _mainWidget = hbox1; combobox1.Model = comboModel; combobox1.PackStart(comboRender, false); combobox1.AddAttribute(comboRender, "text", 0); combobox1.Changed += OnPositionComboChanged; combobox1.Focused += OnTitleTextBoxEnter; listview.Model = listModel; TreeViewColumn column = new TreeViewColumn(); column.Title = "Series name"; column.PackStart(listToggle, false); listRender.Editable = false; column.PackStart(listRender, true); column.SetAttributes(listToggle, "active", 0); column.SetAttributes(listRender, "text", 1); listview.AppendColumn(column); listToggle.Activatable = true; listToggle.Toggled += OnItemChecked; _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary> /// Initializes a new instance of the <see cref="GraphView" /> class. /// </summary> public GraphView(ViewBase owner = null) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.GraphView.glade", "vbox1"); gxml.Autoconnect(this); _mainWidget = vbox1; plot1 = new PlotView(); plot1.Model = new PlotModel(); plot1.SetSizeRequest(-1, 100); vbox2.PackStart(plot1, true, true, 0); smallestDate = DateTime.MaxValue; largestDate = DateTime.MinValue; this.LeftRightPadding = 40; expander1.Visible = false; captionEventBox.Visible = true; plot1.Model.MouseDown += OnChartClick; captionLabel.Text = null; captionEventBox.ButtonPressEvent += OnCaptionLabelDoubleClick; _mainWidget.Destroyed += _mainWidget_Destroyed; BackColor = OxyPlot.OxyColors.White; }
public void configure(int controllerID, ControllerBase controller, ModelBase model, ViewBase view) { addControllerRoute(new RouteBase(controllerID, controller)); controller.configure(view, model); model.configure(); view.configure(model); }
private void drawLine(Point p1, Point p2, ViewBase view) { TSD.Line newLine = new TSD.Line(view, p1, p2); LineTypeAttributes lineParams = new LineTypeAttributes(LineTypes.SolidLine, DrawingColors.Black); newLine.Attributes.Line = lineParams; newLine.Insert(); }
/// <summary> /// Construct the view appropriate for this builder. /// </summary> /// <param name="navigator">Reference to navigator instance.</param> /// <param name="manager">Reference to current manager.</param> /// <param name="redirector">Palette redirector.</param> public override void Construct(KryptonNavigator navigator, ViewManager manager, PaletteRedirect redirector) { // Let base class perform common operations base.Construct(navigator, manager, redirector); // Get the current root element _oldRoot = ViewManager.Root; // Create a canvas for the background _drawPanel = new ViewDrawPanel(Navigator.StateNormal.Back); // Put the exisint root into the canvas _drawPanel.Add(_oldRoot); // Update the child panel to have panel appearance Navigator.ChildPanel.PanelBackStyle = Navigator.Panel.PanelBackStyle; // Set the correct palettes based on enabled state and selected page UpdateStatePalettes(); // Canvas becomes the new root ViewManager.Root = _drawPanel; // Need to monitor changes in the enabled state Navigator.EnabledChanged += new EventHandler(OnEnabledChanged); }
private void Dodaj_Click(object sender, RoutedEventArgs e) { ViewBase vb = new ViewBase(1); vb.AddItemCallback = new AddItemDelegate(this.AddItemCallbackFn); vb.ShowDialog(); }
/// <summary>Initializes a new instance of the <see cref="SeriesView" /> class</summary> public SeriesView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.SeriesView.glade", "vbox1"); gxml.Autoconnect(this); _mainWidget = vbox1; graphView1 = new GraphView(this); vbox1.PackStart(graphView1.MainWidget, true, true, 0); dropDownView1 = new DropDownView(this); dropDownView2 = new DropDownView(this); dropDownView3 = new DropDownView(this); dropDownView4 = new DropDownView(this); dropDownView5 = new DropDownView(this); dropDownView6 = new DropDownView(this); dropDownView7 = new DropDownView(this); dropDownView8 = new DropDownView(this); dropDownView9 = new ColourDropDownView(this); dropDownView10 = new DropDownView(this); dropDownView11 = new DropDownView(this); checkBoxView1 = new CheckBoxView(this); checkBoxView1.TextOfLabel = "on top?"; checkBoxView2 = new CheckBoxView(this); checkBoxView2.TextOfLabel = "on right?"; checkBoxView3 = new CheckBoxView(this); checkBoxView3.TextOfLabel = "cumulative?"; checkBoxView4 = new CheckBoxView(this); checkBoxView4.TextOfLabel = "cumulative?"; checkBoxView5 = new CheckBoxView(this); checkBoxView5.TextOfLabel = "Show in legend?"; checkBoxView6 = new CheckBoxView(this); checkBoxView6.TextOfLabel = "Include series name in legend?"; editView1 = new EditView(this); table1.Attach(dropDownView1.MainWidget, 1, 2, 0, 1, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView2.MainWidget, 1, 2, 1, 2, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView3.MainWidget, 1, 2, 2, 3, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView5.MainWidget, 1, 2, 3, 4, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView4.MainWidget, 1, 2, 4, 5, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView6.MainWidget, 1, 2, 5, 6, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView7.MainWidget, 1, 2, 6, 7, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView8.MainWidget, 1, 2, 7, 8, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView9.MainWidget, 1, 2, 8, 9, AttachOptions.Fill, 0, 10, 2); table1.Attach(editView1.MainWidget, 1, 2, 9, 10, AttachOptions.Fill, 0, 10, 2); table1.Attach(checkBoxView1.MainWidget, 2, 3, 1, 2, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView2.MainWidget, 2, 3, 2, 3, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView3.MainWidget, 3, 4, 1, 2, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView4.MainWidget, 3, 4, 2, 3, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView5.MainWidget, 2, 4, 8, 9, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView6.MainWidget, 2, 4, 9, 10, AttachOptions.Fill, 0, 0, 0); table1.Attach(dropDownView10.MainWidget, 3, 4, 6, 7, AttachOptions.Fill, 0, 0, 5); table1.Attach(dropDownView11.MainWidget, 3, 4, 7, 8, AttachOptions.Fill, 0, 0, 5); }
/// <summary> /// Initialize a new instance of the ButtonSpecEventArgs class. /// </summary> /// <param name="target">Reference to view element that requires tooltip.</param> /// <param name="screenPt">Screen location of mouse when tooltip was required.</param> public ToolTipEventArgs(ViewBase target, Point screenPt) { Debug.Assert(target != null); // Remember parameter details _target = target; _screenPt = screenPt; }
/// <summary>Constructor</summary> public EditView(ViewBase owner) : base(owner) { textentry1 = new Entry(); _mainWidget = textentry1; textentry1.FocusOutEvent += OnSelectionChanged; _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary> /// Initialize a new instance of the OutlookMiniController class. /// </summary> /// <param name="target">Target for state changes.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public OutlookMiniController(ViewBase target, NeedPaintHandler needPaint) { Debug.Assert(needPaint != null); _target = target; NeedPaint = needPaint; }
/// <summary> /// Construtor /// </summary> public TitleView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.TitleView.glade", "hbox1"); gxml.Autoconnect(this); _mainWidget = hbox1; entry1.Changed += OnPositionComboChanged; _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary>Constructor</summary> public ButtonView(ViewBase owner) : base(owner) { button = new Button(); _mainWidget = button; button.Clicked += OnButtonClick; button.SetSizeRequest(80, 36); _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonAppMenu class. /// </summary> /// <param name="paletteBack">Palette source for the background.</param> /// <param name="paletteBorder">Palette source for the border.</param> /// <param name="fixedElement">Element to display at provided screen rect.</param> /// <param name="fixedScreenRect">Screen rectangle for showing the element at.</param> public ViewDrawRibbonAppMenu(IPaletteBack paletteBack, IPaletteBorder paletteBorder, ViewBase fixedElement, Rectangle fixedScreenRect) : base(paletteBack, paletteBorder) { _fixedElement = fixedElement; _fixedScreenRect = fixedScreenRect; }
public FolderView(ViewBase owner) : base(owner) { scroller = new ScrolledWindow(); scroller.SetPolicy(PolicyType.Automatic, PolicyType.Automatic); table = new Table(1, 1, false); scroller.AddWithViewport(table); _mainWidget = scroller; }
/// <summary> /// Initialize a new instance of the ViewHightlightController class. /// </summary> /// <param name="target">Target for state changes.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewHightlightController(ViewBase target, NeedPaintHandler needPaint) { Debug.Assert(target != null); Debug.Assert(needPaint != null); _target = target; NeedPaint = needPaint; }
private void button1_Click(object sender, RoutedEventArgs e) { AptekaDataDataContext con = new AptekaDataDataContext(); ViewBase viewbase = new ViewBase(); List<Lek> lek = (from l in con.Leks where l.Nazwa.StartsWith(textBox1.Text) || l.M_nazwa.StartsWith(textBox2.Text) select l).ToList(); viewbase.LekGird.ItemsSource = lek; viewbase.search = 1; viewbase.ShowDialog(); }
/// <summary> /// Initialize a new instance of the DragViewController class. /// </summary> /// <param name="target">Target for state changes.</param> public DragViewController(ViewBase target) { Debug.Assert(target != null); _mousePoint = CommonHelper.NullPoint; _allowDragging = true; _dragging = false; _target = target; _lastClick = DateTime.Now.AddDays(-1); }
/// <summary> /// Initializes a new instance of the <see cref="InitialWaterView" /> class. /// </summary> public XYPairsView(ViewBase owner) : base(owner) { vpaned = new VPaned(); _mainWidget = vpaned; gridView = new GridView(this); graphView = new GraphView(this); vpaned.Pack1(gridView.MainWidget, true, false); vpaned.Pack2(graphView.MainWidget, true, false); }
/// <summary>Constructor</summary> public DropDownView(ViewBase owner) : base(owner) { combobox1 = new ComboBox(comboModel); _mainWidget = combobox1; combobox1.PackStart(comboRender, false); combobox1.AddAttribute(comboRender, "text", 0); combobox1.Changed += OnSelectionChanged; _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary> /// Constructor /// </summary> public ManagerView(ViewBase owner) : base(owner) { notebook = new Notebook(); _mainWidget = notebook; Grid = new GridView(this); ScriptEditor = new EditorView(this); notebook.AppendPage(Grid.MainWidget, new Label("Properties")); notebook.AppendPage(ScriptEditor.MainWidget, new Label("Script")); }
/// <summary> /// Gets the ButtonSpec associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to ButtonSpec; otherwise null.</returns> public override ButtonSpec ButtonSpecFromView(ViewBase element) { // Check base class for page specific button specs ButtonSpec bs = base.ButtonSpecFromView(element); // Delegate lookup to the viewlet that has the button spec manager if (bs == null) bs = _headerGroup.ButtonSpecFromView(element); return bs; }
/// <summary>Constructor</summary> public ColourDropDownView(ViewBase owner) : base(owner) { combobox1 = new ComboBox(comboModel); _mainWidget = combobox1; combobox1.PackStart(comboRender, true); combobox1.AddAttribute(comboRender, "text", 0); combobox1.SetCellDataFunc(comboRender, OnDrawColourCombo); combobox1.Changed += OnChanged; _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary> /// Gets the ButtonSpec associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to ButtonSpec; otherwise null.</returns> public override ButtonSpec ButtonSpecFromView(ViewBase element) { // Always check base class first ButtonSpec bs = base.ButtonSpecFromView(element); // Call onto the contained header group implementation if (bs == null) bs = _headerGroup.ButtonSpecFromView(element); return bs; }
/// <summary>Initializes a new instance of the <see cref="SummaryView"/> class.</summary> public SummaryView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.SummaryView.glade", "vbox1"); gxml.Autoconnect(this); _mainWidget = vbox1; combobox1.PackStart(comboRender, false); combobox1.AddAttribute(comboRender, "text", 0); combobox1.Model = comboModel; htmlview = new HTMLView(this); vbox1.PackEnd(htmlview.MainWidget, true, true, 0); }
/// <summary> /// Initialize an instance of the TooltipController class. /// </summary> /// <param name="manager">Reference to manager of all tooltip functionality.</param> /// <param name="targetElement">Target element that controller is for.</param> /// <param name="targetController">Target controller that we are snooping.</param> public ToolTipController(ToolTipManager manager, ViewBase targetElement, IMouseController targetController) { Debug.Assert(manager != null); Debug.Assert(targetElement != null); // Remember incoming references _manager = manager; _targetElement = targetElement; _targetController = targetController; }
/// <summary> /// Initialize a new instance of the ViewRibbonPopupGroupManager class. /// </summary> /// <param name="ribbon">Reference to original ribbon instance.</param> /// <param name="control">Owning control.</param> /// <param name="qatContents">View that will handle focus requests.</param> /// <param name="root">View for group we are tracking.</param> public ViewRibbonQATOverflowManager(KryptonRibbon ribbon, Control control, ViewLayoutRibbonQATContents qatContents, ViewBase root) : base(control, root) { Debug.Assert(ribbon != null); Debug.Assert(qatContents != null); _ribbon = ribbon; _qatContents = qatContents; }
public FolderView(ViewBase owner) : base(owner) { scroller = new ScrolledWindow(); scroller.SetPolicy(PolicyType.Automatic, PolicyType.Automatic); table = new Table(1, 1, false); Viewport vport = new Viewport(); vport.Add(table); vport.ShadowType = ShadowType.None; scroller.Add(vport); _mainWidget = scroller; }
public static void Init() { PageEx.MajorVersion = 2013; // Use the CRM2013/2015 styles vm = new HelloWorldViewModel(); ViewBase.RegisterViewModel(vm); }
/// <summary> /// Gets the KryptonPage associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to KryptonPage; otherwise null.</returns> public abstract KryptonPage PageFromView(ViewBase element);
/// <summary> /// Key has been pressed down. /// </summary> /// <param name="c">Reference to the source control instance.</param> /// <param name="e">A KeyEventArgs that contains the event data.</param> public override void KeyDown(Control c, KeyEventArgs e) { ViewBase newView = null; KryptonRibbon ribbon = (KryptonRibbon)c; // Get the button spec associated with this controller ViewDrawButton viewButton = (ViewDrawButton)Target; ButtonSpec buttonSpec = ribbon.TabsArea.ButtonSpecManager.GetButtonSpecFromView(viewButton); // Note if we are on the near edge bool isNear = (buttonSpec.Edge == PaletteRelativeEdgeAlign.Near); switch (e.KeyData) { case Keys.Tab: case Keys.Right: // Logic depends on the edge this button is on if (isNear) { // Try getting the previous near edge button (previous on near gets the next right hand side!) newView = ribbon.TabsArea.ButtonSpecManager.GetPreviousVisibleViewButton(PaletteRelativeEdgeAlign.Near, viewButton); if (newView == null) { if ((e.KeyData == Keys.Tab) && (ribbon.SelectedTab != null)) { // Get the currently selected tab page newView = ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab); } else { // Get the first visible tab page newView = ribbon.TabsArea.LayoutTabs.GetViewForFirstRibbonTab(); } } // Get the first far edge button if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Far); } // Get the first inherit edge button if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Inherit); } // Rotate around to application button if (newView == null) { if (ribbon.TabsArea.LayoutAppButton.Visible) { newView = ribbon.TabsArea.LayoutAppButton.AppButton; } else if (ribbon.TabsArea.LayoutAppTab.Visible) { newView = ribbon.TabsArea.LayoutAppTab.AppTab; } } } else { // Try using the next far edge button newView = ribbon.TabsArea.ButtonSpecManager.GetNextVisibleViewButton(PaletteRelativeEdgeAlign.Far, viewButton) ?? ribbon.TabsArea.ButtonSpecManager.GetNextVisibleViewButton(PaletteRelativeEdgeAlign.Inherit, viewButton); // Try using the next inherit edge button // Rotate around to application button if (newView == null) { if (ribbon.TabsArea.LayoutAppButton.Visible) { newView = ribbon.TabsArea.LayoutAppButton.AppButton; } else if (ribbon.TabsArea.LayoutAppTab.Visible) { newView = ribbon.TabsArea.LayoutAppTab.AppTab; } } } break; case Keys.Tab | Keys.Shift: case Keys.Left: // Logic depends on the edge this button is on if (isNear) { // Try using the previous near edge button (next for a near edge is the left hand side!) newView = ribbon.TabsArea.ButtonSpecManager.GetNextVisibleViewButton(PaletteRelativeEdgeAlign.Near, viewButton) ?? ribbon.GetLastQATView(); // Get the last qat button // Rotate around to application button if (newView == null) { if (ribbon.TabsArea.LayoutAppButton.Visible) { newView = ribbon.TabsArea.LayoutAppButton.AppButton; } else if (ribbon.TabsArea.LayoutAppTab.Visible) { newView = ribbon.TabsArea.LayoutAppTab.AppTab; } } } else { // Try getting the previous far edge button newView = ribbon.TabsArea.ButtonSpecManager.GetPreviousVisibleViewButton(PaletteRelativeEdgeAlign.Far, viewButton) ?? ribbon.TabsArea.ButtonSpecManager.GetPreviousVisibleViewButton(PaletteRelativeEdgeAlign.Inherit, viewButton); // Try getting the previous inherit edge button if (newView == null) { if (e.KeyData != Keys.Left) { // Get the last control on the selected tab newView = ribbon.GroupsArea.ViewGroups.GetLastFocusItem() ?? (ribbon.SelectedTab != null // Get the currently selected tab page ? ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab) : ribbon.TabsArea.LayoutTabs.GetViewForLastRibbonTab()); } else { // Get the last visible tab page newView = ribbon.TabsArea.LayoutTabs.GetViewForLastRibbonTab(); } } // Get the last near edge button if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near); } // Get the last qat button if (newView == null) { newView = ribbon.GetLastQATView(); } // Rotate around to application button if (newView == null) { if (ribbon.TabsArea.LayoutAppButton.Visible) { newView = ribbon.TabsArea.LayoutAppButton.AppButton; } else if (ribbon.TabsArea.LayoutAppTab.Visible) { newView = ribbon.TabsArea.LayoutAppTab.AppTab; } } } break; case Keys.Space: case Keys.Enter: // Exit keyboard mode when you click the button spec ribbon.KillKeyboardMode(); // Generate a click event OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; } // If we have a new view to focus and it is not ourself... if ((newView != null) && (newView != Target)) { // If the new view is a tab then select that tab unless in minimized mode if (!ribbon.RealMinimizedMode && (newView is ViewDrawRibbonTab tab)) { ribbon.SelectedTab = tab.RibbonTab; } // Finally we switch focus to new view ribbon.FocusView = newView; } }
/// <summary> /// Gets the KryptonPage associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to KryptonPage; otherwise null.</returns> public override KryptonPage PageFromView(ViewBase element) { // There is no view for the page return(null); }
/// <summary> /// Gets the next focus item based on the current item as provided. /// </summary> /// <param name="current">The view that is currently focused.</param> /// <param name="matched">Has the current focus item been matched yet.</param> /// <returns>ViewBase of item; otherwise false.</returns> public ViewBase GetNextFocusItem(ViewBase current, ref bool matched) { // Do we match the current item? matched = current == this; return(null); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Start laying out children from the top left Point pt = ClientLocation; // Nothing to calculate if there are no children if (Count > 0) { // Default to no space between each child item // If we have a metric provider then get the child gap to use int gap = _paletteMetric?.GetMetricInt(State, _metricGap) ?? context.Renderer.RenderTabBorder.GetTabBorderSpacingGap(TabBorderStyle); // Line spacing gap can never be less than zero int lineGap = (gap < 0 ? 0 : gap); bool reverseAccess = false; bool reversePosition = false; // Do we need to apply right to left by positioning children in reverse order? if (!BarVertical && (context.Control.RightToLeft == RightToLeft.Yes)) { if (IsOneLine) { reverseAccess = true; } else { reversePosition = true; } } if (BarVertical) { int xPos; // Ensure the left orientation is aligned towards right of bar area if (Orientation == VisualOrientation.Left) { xPos = ClientLocation.X + Math.Max(0, ClientWidth - _preferredOrientLength); } else { xPos = ClientLocation.X; } // Layout each line of buttons in turn foreach (LineDetails lineDetails in _lineDetails) { // Get starting position for first button on the line int yPos = FindStartingYPosition(context, lineDetails, reversePosition); // Layout each button on the line for (int i = 0; i < lineDetails.ItemCount; i++) { // Get the actual child index to use int itemIndex = lineDetails.StartIndex + i; // Ignore invisible items, which are zero sized if (!_childSizes[itemIndex].IsEmpty) { // Get access to the indexed child ViewBase child = this[(reverseAccess ? (lineDetails.StartIndex + lineDetails.ItemCount) - 1 - i : lineDetails.StartIndex + i)]; // Add on the height of the child int yAdd = _childSizes[itemIndex].Height; int xPosition = xPos; int yPosition = (reversePosition ? yPos - _childSizes[itemIndex].Height : yPos); // At the left edge, we need to ensure buttons are align by there right edges if (Orientation == VisualOrientation.Left) { xPosition = (xPos + lineDetails.CrossLength) - _childSizes[itemIndex].Width; } // Create the rectangle that shows all of the check button context.DisplayRectangle = new Rectangle(new Point(xPosition, yPosition), _childSizes[itemIndex]); // Ask the child to layout child.Layout(context); // Move to next child position if (reversePosition) { yPos -= (yAdd + gap); } else { yPos += (yAdd + gap); } } } // Move across to the next line xPos += (lineGap + lineDetails.CrossLength); } } else { int yPos; // Ensure the top orientation is aligned towards bottom of bar area if (Orientation == VisualOrientation.Top) { yPos = ClientLocation.Y + Math.Max(0, ClientHeight - _preferredOrientLength); } else { yPos = ClientLocation.Y; } // Layout each line of buttons in turn foreach (LineDetails lineDetails in _lineDetails) { // Get starting position for first button on the line int xPos = FindStartingXPosition(context, lineDetails, reversePosition); // Layout each button on the line for (int i = 0; i < lineDetails.ItemCount; i++) { // Get the actual child index to use int itemIndex = lineDetails.StartIndex + i; // Ignore invisible items, which are zero sized if (!_childSizes[itemIndex].IsEmpty) { // Get access to the indexed child ViewBase child = this[(reverseAccess ? (lineDetails.StartIndex + lineDetails.ItemCount) - 1 - i : lineDetails.StartIndex + i)]; // Add on the width of the child int xAdd = _childSizes[itemIndex].Width; int yPosition = yPos; int xPosition = (reversePosition ? xPos - _childSizes[itemIndex].Width : xPos); // At the top edge, we need to ensure buttons are align by there bottom edges if (Orientation == VisualOrientation.Top) { yPosition = (yPos + lineDetails.CrossLength) - _childSizes[itemIndex].Height; } // Create the rectangle that shows all of the check button context.DisplayRectangle = new Rectangle(new Point(xPosition, yPosition), _childSizes[itemIndex]); // Ask the child to layout child.Layout(context); // Move to next child position if (reversePosition) { xPos -= (xAdd + gap); } else { xPos += (xAdd + gap); } } } // Move down to the next line yPos += (lineGap + lineDetails.CrossLength); } } } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Gets the ButtonSpec associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to ButtonSpec; otherwise null.</returns> public override ButtonSpec ButtonSpecFromView(ViewBase element) { // Check base class for page specific button specs return(base.ButtonSpecFromView(element)); }
/// <summary> /// Mouse has left the view. /// </summary> /// <param name="c">Reference to the source control instance.</param> /// <param name="next">Reference to view that is next to have the mouse.</param> public virtual void MouseLeave(Control c, ViewBase next) { // Mouse is no longer over the target _mouseOver = false; }
/// <summary> /// Key has been pressed down. /// </summary> /// <param name="c">Reference to the source control instance.</param> /// <param name="e">A KeyEventArgs that contains the event data.</param> public void KeyDown(Control c, KeyEventArgs e) { ViewBase newView = null; Keys keyData = e.KeyData; // When there is no selected tab then tab and shift+tab become right and left if (_ribbon.SelectedTab == null) { if (keyData == Keys.Tab) { keyData = Keys.Right; } if (keyData == (Keys.Tab | Keys.Shift)) { keyData = Keys.Left; } } switch (keyData) { case Keys.Right: // Get the next visible tab page newView = (_target.ViewLayoutRibbonTabs.GetViewForNextRibbonTab(_target.RibbonTab) ?? (ViewBase)_ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Far)) ?? _ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Inherit); // Move across to any far defined buttons // Move across to any inherit defined buttons // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Left: // Get the previous visible tab page newView = (_target.ViewLayoutRibbonTabs.GetViewForPreviousRibbonTab(_target.RibbonTab) ?? (ViewBase)_ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near)) ?? _ribbon.GetLastQATView(); // Move across to any near defined buttons // Get the last qat button // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Tab | Keys.Shift: // Move across to any near defined buttons newView = _ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near) ?? _ribbon.GetLastQATView(); // Get the last qat button // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Down: // Get the first focus item for the currently selected page newView = _ribbon.GroupsArea.ViewGroups.GetFirstFocusItem(); break; case Keys.Tab: // Get the first focus item for the currently selected page newView = (_ribbon.GroupsArea.ViewGroups.GetFirstFocusItem() ?? _ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near)) ?? _ribbon.GetLastQATView(); // Move across to any near defined buttons // Get the last qat button // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Enter: case Keys.Space: // When minimize, pressing enter will select the tab and pop it up if ((_ribbon.RealMinimizedMode) && (_ribbon.SelectedTab != _target.RibbonTab)) { // Select the tab will automatically create a popup for it _ribbon.SelectedTab = _target.RibbonTab; // Get access to the popup for the group if ((VisualPopupManager.Singleton.CurrentPopup != null) && (VisualPopupManager.Singleton.CurrentPopup is VisualPopupMinimized)) { // Cast to correct type VisualPopupMinimized popupMinimized = (VisualPopupMinimized)VisualPopupManager.Singleton.CurrentPopup; popupMinimized.SetFirstFocusItem(); } } break; } // If we have a new view to focus and it is not ourself... if ((newView != null) && (newView != _target)) { // If the new view is a tab then select that tab if (!_ribbon.RealMinimizedMode && (newView is ViewDrawRibbonTab tab)) { _ribbon.SelectedTab = tab.RibbonTab; } // Finally we switch focus to new view _ribbon.FocusView = newView; } }
/// <summary> /// Initialize a new instance of the ButtonSpecRibbonController class. /// </summary> /// <param name="target">Target for state changes.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ButtonSpecRibbonController(ViewBase target, NeedPaintHandler needPaint) : base(target, needPaint) { }
private void KeyDownRibbon(KryptonRibbon ribbon, KeyEventArgs e) { ViewBase newView = null; switch (e.KeyData) { case Keys.Tab | Keys.Shift: case Keys.Left: // Get the previous focus item for the currently selected page newView = ribbon.GroupsArea.ViewGroups.GetPreviousFocusItem(_target); // Got to the actual tab header if (newView == null) { newView = ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab); } break; case Keys.Tab: case Keys.Right: // Get the next focus item for the currently selected page newView = ribbon.GroupsArea.ViewGroups.GetNextFocusItem(_target); // Move across to any far defined buttons if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Far); } // Move across to any inherit defined buttons if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Inherit); } // Rotate around to application button if (newView == null) { if (ribbon.TabsArea.LayoutAppButton.Visible) { newView = ribbon.TabsArea.LayoutAppButton.AppButton; } else if (ribbon.TabsArea.LayoutAppTab.Visible) { newView = ribbon.TabsArea.LayoutAppTab.AppTab; } } break; } // If we have a new view to focus and it is not ourself... if ((newView != null) && (newView != _target)) { // If the new view is a tab then select that tab unless in minimized mode if ((newView is ViewDrawRibbonTab) && !ribbon.RealMinimizedMode) { ribbon.SelectedTab = ((ViewDrawRibbonTab)newView).RibbonTab; } // Finally we switch focus to new view ribbon.FocusView = newView; } }
/// <summary> /// Gets the previous focus item based on the current item as provided. /// </summary> /// <param name="current">The view that is currently focused.</param> /// <param name="matched">Has the current focus item been matched yet.</param> /// <returns>ViewBase of item; otherwise false.</returns> public ViewBase GetPreviousFocusItem(ViewBase current, ref bool matched) { // Do we match the current item? matched = (current == this); return(null); }
/// This binding will add or remove views based on an element/viewmodel collection. public virtual void EnemiesRemoved(ViewBase item) { }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Out enabled state is the same as that of the ribbon itself Enabled = _ribbon.Enabled; // We take on all the available display area ClientRectangle = context.DisplayRectangle; Rectangle layoutRect = ClientRectangle; Rectangle controlRect = new Rectangle(Point.Empty, ClientSize); // Reset the the view control layout offset to be zero again _viewControl.LayoutOffset = Point.Empty; // Ask the view control the size it would like to be, this is the requested filler // size of the control. If it wants more than we can give then scroll buttons are // needed, otherwise we can give it the requested size and any extra available. _ribbon.GetViewManager().DoNotLayoutControls = true; _viewControl.GetPreferredSize(context); // Ensure context has the correct control if ((_viewControl.ChildControl != null) && !_viewControl.ChildControl.IsDisposed) { using (CorrectContextControl ccc = new CorrectContextControl(context, _viewControl.ChildControl)) _viewFiller.Layout(context); } _ribbon.GetViewManager().DoNotLayoutControls = false; Size fillerSize = _viewFiller.ClientSize; // Limit check the scroll offset _scrollOffset = Math.Max(_scrollOffset, 0); // Did it fit fully into our space? if (((Orientation == Orientation.Horizontal) && (fillerSize.Width <= ClientWidth)) || ((Orientation == Orientation.Vertical) && (fillerSize.Height <= ClientHeight))) { // Filler rectangle is used for clipping _viewClipRect = controlRect; // Default back to left hand scroll position _scrollOffset = 0; // Then make the scrollers invisible and nothing more to do _nearScroller.Visible = false; _farScroller.Visible = false; // We need to layout again but this time we do layout the actual children _viewControl.Layout(context); } else { // We only need the near scroller if we are not at the left scroll position if (_scrollOffset > 0) { _nearScroller.Visible = true; // Find size requirements of the near scroller Size nearSize = _nearScroller.GetPreferredSize(context); // Find layout position of the near scroller if (Orientation == Orientation.Horizontal) { context.DisplayRectangle = new Rectangle(layoutRect.X, layoutRect.Y, nearSize.Width, layoutRect.Height); layoutRect.Width -= nearSize.Width; layoutRect.X += nearSize.Width; controlRect.Width -= nearSize.Width; controlRect.X += nearSize.Width; } else { context.DisplayRectangle = new Rectangle(layoutRect.X, layoutRect.Y, layoutRect.Width, nearSize.Height); layoutRect.Height -= nearSize.Height; layoutRect.Y += nearSize.Height; controlRect.Height -= nearSize.Height; controlRect.Y += nearSize.Height; } _nearScroller.Layout(context); } else { _nearScroller.Visible = false; } int maxOffset = 0; // Work out the maximum scroll offset needed to show all of the filler if (Orientation == Orientation.Horizontal) { maxOffset = fillerSize.Width - layoutRect.Width; } else { maxOffset = fillerSize.Height - layoutRect.Height; } // We only need the far scroller if we are not at the right scroll position if (_scrollOffset < maxOffset) { _farScroller.Visible = true; // Find size requirements of the near scroller Size farSize = _nearScroller.GetPreferredSize(context); // Find layout position of the far scroller if (Orientation == Orientation.Horizontal) { context.DisplayRectangle = new Rectangle(layoutRect.Right - farSize.Width, layoutRect.Y, farSize.Width, layoutRect.Height); layoutRect.Width -= farSize.Width; controlRect.Width -= farSize.Width; } else { context.DisplayRectangle = new Rectangle(layoutRect.X, layoutRect.Bottom - farSize.Height, layoutRect.Width, farSize.Height); layoutRect.Height -= farSize.Height; controlRect.Height -= farSize.Height; } _farScroller.Layout(context); } else { _farScroller.Visible = false; } // Calculate the maximum offset again with all scrollers positioned if (Orientation == Orientation.Horizontal) { maxOffset = fillerSize.Width - layoutRect.Width; } else { maxOffset = fillerSize.Height - layoutRect.Height; } // Limit check the current offset _scrollOffset = Math.Min(_scrollOffset, maxOffset); // Filler rectangle is used for clipping _viewClipRect = controlRect; // Apply the offset to the display of the view filler if (Orientation == Orientation.Horizontal) { _viewControl.LayoutOffset = new Point(-_scrollOffset, 0); } else { _viewControl.LayoutOffset = new Point(0, -_scrollOffset); } // Position the filler in the remaining space context.DisplayRectangle = layoutRect; _viewControl.GetPreferredSize(context); _viewControl.Layout(context); } // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; // If we are the scroller for the tab headers if (_ribbon.InKeyboardMode && (_viewFiller is ViewLayoutRibbonTabs)) { // Cast to correct type ViewLayoutRibbonTabs layoutTabs = (ViewLayoutRibbonTabs)_viewFiller; // If we have a selected tab, then ensure it is visible if (_ribbon.SelectedTab != null) { // Cast to correct type ViewBase viewTab = layoutTabs.GetViewForRibbonTab(_ribbon.SelectedTab); // If a scroll change is required to bring it into view if (ScrollIntoView(viewTab.ClientRectangle, false)) { // Call ourself again to take change into account Layout(context); } } } }
/// This binding will add or remove views based on an element/viewmodel collection. public virtual void EnemiesAdded(ViewBase item) { }
public CallBinding(TriggerCall call, Action onUnbind, Action onRebind = null) { _onUnbind = onUnbind; _onRebind = onRebind; View = call._view; }
/// <summary> /// Key has been pressed down. /// </summary> /// <param name="c">Reference to the source control instance.</param> /// <param name="e">A KeyEventArgs that contains the event data.</param> public void KeyDown(Control c, KeyEventArgs e) { ViewBase newView = null; KryptonRibbon ribbon = (KryptonRibbon)c; switch (e.KeyData) { case Keys.Tab: case Keys.Right: // Ask the ribbon to get use the first view for the qat newView = ribbon.GetFirstQATView() ?? ribbon.TabsArea.ButtonSpecManager.GetLastVisibleViewButton(PaletteRelativeEdgeAlign.Near); // Get the first near edge button (the last near button is the leftmost one!) if (newView == null) { if ((e.KeyData == Keys.Tab) && (ribbon.SelectedTab != null)) { // Get the currently selected tab page newView = ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab); } else { // Get the first visible tab page newView = ribbon.TabsArea.LayoutTabs.GetViewForFirstRibbonTab(); } } // Move across to any far defined buttons if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Far); } // Move across to any inherit defined buttons if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Inherit); } break; case Keys.Tab | Keys.Shift: case Keys.Left: // Move across to any far defined buttons newView = ribbon.TabsArea.ButtonSpecManager.GetLastVisibleViewButton(PaletteRelativeEdgeAlign.Far) ?? ribbon.TabsArea.ButtonSpecManager.GetLastVisibleViewButton(PaletteRelativeEdgeAlign.Inherit); // Move across to any inherit defined buttons if (newView == null) { if (e.KeyData != Keys.Left) { // Get the last control on the selected tab newView = ribbon.GroupsArea.ViewGroups.GetLastFocusItem() ?? (ribbon.SelectedTab != null // Get the currently selected tab page ? ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab) : ribbon.TabsArea.LayoutTabs.GetViewForLastRibbonTab()); } else { // Get the last visible tab page newView = ribbon.TabsArea.LayoutTabs.GetViewForLastRibbonTab(); } } // Get the last near edge button (the first near button is the rightmost one!) if (newView == null) { newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near); } // Get the last qat button if (newView == null) { newView = ribbon.GetLastQATView(); } break; case Keys.Space: case Keys.Enter: case Keys.Down: // Show the button as pressed, until told otherwise _fixedPressed = true; // Mouse is being pressed UpdateTargetState(); // Generate a click event Keyboard = true; OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; } // If we have a new view to focus and it is not ourself... if ((newView != null) && (newView != Target1) && ((newView != Target2) && (newView != Target3))) { // If the new view is a tab then select that tab unless in minimized mode if (!ribbon.RealMinimizedMode && (newView is ViewDrawRibbonTab tab)) { ribbon.SelectedTab = tab.RibbonTab; } // Finally we switch focus to new view ribbon.FocusView = newView; } }
/// <summary> /// Gets the previous focus item based on the current item as provided. /// </summary> /// <param name="current">The view that is currently focused.</param> /// <param name="matched">Has the current focus item been matched yet.</param> /// <returns>ViewBase of item; otherwise false.</returns> public ViewBase GetPreviousFocusItem(ViewBase current, ref bool matched) { // We have nothing to provide even if we are the selected item return(null); }
/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // Reset the largest child size to empty _maximumItem = Size.Empty; // Keep track of the total preferred size Size preferredSize = Size.Empty; // Nothing to calculate if there are no children if (Count > 0) { // Default to no space between each child item // If we have a metric provider then get the child gap to use int gap = _paletteMetric?.GetMetricInt(State, _metricGap) ?? context.Renderer.RenderTabBorder.GetTabBorderSpacingGap(TabBorderStyle); // Line spacing gap can never be less than zero int lineGap = (gap < 0 ? 0 : gap); // Do we need to apply right to left by positioning children in reverse order? bool reversed = (IsOneLine && !BarVertical && (context.Control.RightToLeft == RightToLeft.Yes)); // Allocate caching for size of each child element _childSizes = new Size[Count]; // Find the child index of the selected page int selectedChildIndex = -1; // Find the size of each child in turn for (int i = 0; i < Count; i++) { // Get access to the indexed child ViewBase child = this[reversed ? (Count - i - 1) : i]; INavCheckItem checkItem = (INavCheckItem)child; // Only examine visible children if (child.Visible) { // Cache child index of the selected page if (checkItem.Navigator.SelectedPage == checkItem.Page) { selectedChildIndex = i; } // Ask child for it's own preferred size _childSizes[i] = child.GetPreferredSize(context); // Enfore the minimum and maximum sizes if (ItemVertical) { _childSizes[i].Width = Math.Max(Math.Min(_childSizes[i].Width, ItemMaximumSize.Height), ItemMinimumSize.Height); _childSizes[i].Height = Math.Max(Math.Min(_childSizes[i].Height, ItemMaximumSize.Width), ItemMinimumSize.Width); } else { _childSizes[i].Width = Math.Max(Math.Min(_childSizes[i].Width, ItemMaximumSize.Width), ItemMinimumSize.Width); _childSizes[i].Height = Math.Max(Math.Min(_childSizes[i].Height, ItemMaximumSize.Height), ItemMinimumSize.Height); } // Remember the largest child encountered _maximumItem.Width = Math.Max(_childSizes[i].Width, _maximumItem.Width); _maximumItem.Height = Math.Max(_childSizes[i].Height, _maximumItem.Height); } } // Apply the item sizing method switch (BarItemSizing) { case BarItemSizing.Individual: // Do nothing, each item can be its own size break; case BarItemSizing.SameHeight: if (!BarVertical) { for (int i = 0; i < _childSizes.Length; i++) { if (!_childSizes[i].IsEmpty) { _childSizes[i].Height = _maximumItem.Height; } } } else { for (int i = 0; i < _childSizes.Length; i++) { if (!_childSizes[i].IsEmpty) { _childSizes[i].Width = _maximumItem.Width; } } } break; case BarItemSizing.SameWidth: if (!BarVertical) { for (int i = 0; i < _childSizes.Length; i++) { if (!_childSizes[i].IsEmpty) { _childSizes[i].Width = _maximumItem.Width; } } } else { for (int i = 0; i < _childSizes.Length; i++) { if (!_childSizes[i].IsEmpty) { _childSizes[i].Height = _maximumItem.Height; } } } break; case BarItemSizing.SameWidthAndHeight: for (int i = 0; i < _childSizes.Length; i++) { if (!_childSizes[i].IsEmpty) { _childSizes[i] = _maximumItem; } } break; default: // Should never happen! Debug.Assert(false); break; } // Store a list of the individual line vectors (height or width depending on orientation) _lineDetails = new List <LineDetails>(); int itemCount = 0; int startIndex = 0; int visibleItems = 0; if (BarVertical) { int yPos = 0; int yMaxPos = 0; int lineWidth = 0; _preferredOrientLength = 0; for (int i = 0; i < _childSizes.Length; i++) { // Ignore invisible items, which are zero sized if (!_childSizes[i].IsEmpty) { // If not the first visible item on line, then need a spacing gap int yAdd = (visibleItems > 0) ? gap : 0; // Add on the heght of the child yAdd += _childSizes[i].Height; // Does this item extend beyond visible line? // (unless first item, we always have at least one item on a line) if (!IsOneLine && (yPos > 0) && ((yPos + yAdd) > context.DisplayRectangle.Height)) { // Remember the line metrics _lineDetails.Add(new LineDetails(yPos, lineWidth, startIndex, itemCount)); // Track the widest line encountered yMaxPos = Math.Max(yPos, yMaxPos); // Reset back to start of the next line yPos = 0; itemCount = 0; startIndex = i; _preferredOrientLength += (lineGap + lineWidth); lineWidth = 0; // First item on new line does not need a spacing gap yAdd = _childSizes[i].Height; } // Add on to the current line yPos += yAdd; visibleItems++; // Track the tallest item on this line if (lineWidth < _childSizes[i].Width) { lineWidth = _childSizes[i].Width; } } // Visible and Invisible items are added to the item count itemCount++; } // Add the last line to the height _preferredOrientLength += lineWidth; // Check if the last line is the tallest line yMaxPos = Math.Max(yPos, yMaxPos); // If we extended past end of the line if (yMaxPos > context.DisplayRectangle.Height) { // If the mode requires we do not extend over the line if ((BarMultiline == BarMultiline.Shrinkline) || (BarMultiline == BarMultiline.Exactline)) { bool changed; // Keep looping to reduce item sizes until all are zero sized or finished removing extra space do { changed = false; // Are there any items avaiable for reducing? if (visibleItems > 0) { // How much do we need to shrink each item by? int shrink = Math.Max(1, (yMaxPos - context.DisplayRectangle.Height) / visibleItems); // Reduce size of each item for (int i = 0; i < _childSizes.Length; i++) { // Cannot make smaller then zero height if (_childSizes[i].Height > 0) { // Reduce size int tempHeight = _childSizes[i].Height; _childSizes[i].Height -= shrink; // Prevent going smaller then zero if (_childSizes[i].Height <= 0) { _childSizes[i].Height = 0; visibleItems--; } // Reduce total width by the height removed from item yMaxPos -= (tempHeight - _childSizes[i].Height); // All reduction made, exit the loop if (yMaxPos <= context.DisplayRectangle.Height) { break; } changed = true; } } } } while (changed && (yMaxPos > context.DisplayRectangle.Height)); } } // If we are shorter than the available height if (yMaxPos < context.DisplayRectangle.Height) { // If the mode requires we extend to the end of the line if ((BarMultiline == BarMultiline.Expandline) || (BarMultiline == BarMultiline.Exactline)) { bool changed; // Keep looping to expand item sizes until all extra space is allocated do { changed = false; // Are there any items avaiable for expanding? if (visibleItems > 0) { // How much do we need to expand each item by? int expand = Math.Max(1, (context.DisplayRectangle.Height - yMaxPos) / visibleItems); // Expand size of each item for (int i = 0; i < _childSizes.Length; i++) { // Expand size _childSizes[i].Height += expand; // Reduce free space by that allocated yMaxPos += expand; changed = true; // All expansion made, exit the loop if (yMaxPos >= context.DisplayRectangle.Height) { break; } } } } while (changed && (yMaxPos < context.DisplayRectangle.Height)); } } // Remember the line metrics _lineDetails.Add(new LineDetails(yMaxPos, lineWidth, startIndex, itemCount)); // Our preferred size is tall enough to show the longest line and total width preferredSize.Width = _preferredOrientLength; preferredSize.Height = yMaxPos; } else { int xPos = 0; int xMaxPos = 0; int lineHeight = 0; _preferredOrientLength = 0; for (int i = 0; i < _childSizes.Length; i++) { // Ignore invisible items, which are zero sized if (!_childSizes[i].IsEmpty) { // If not the first item on line, then need a spacing gap int xAdd = (visibleItems > 0) ? gap : 0; // Add on the width of the child xAdd += _childSizes[i].Width; // Does this item extend beyond visible line? // (unless first item, we always have at least one item on a line) if (!IsOneLine && (xPos > 0) && ((xPos + xAdd) > context.DisplayRectangle.Width)) { // Remember the line metrics _lineDetails.Add(new LineDetails(xPos, lineHeight, startIndex, itemCount)); // Track the widest line encountered xMaxPos = Math.Max(xPos, xMaxPos); // Reset back to start of the next line xPos = 0; itemCount = 0; startIndex = i; _preferredOrientLength += (lineGap + lineHeight); lineHeight = 0; // First item on new line does not need a spacing gap xAdd = _childSizes[i].Width; } // Add on to the current line xPos += xAdd; visibleItems++; // Track the tallest item on this line if (lineHeight < _childSizes[i].Height) { lineHeight = _childSizes[i].Height; } } // Visible and Invisible items are added to the item count itemCount++; } // Add the last line to the height _preferredOrientLength += lineHeight; // Check if the last line is the widest line xMaxPos = Math.Max(xPos, xMaxPos); // If we extended past end of the line if (xMaxPos > context.DisplayRectangle.Width) { // If the mode requires we do not extend over the line if ((BarMultiline == BarMultiline.Shrinkline) || (BarMultiline == BarMultiline.Exactline)) { bool changed; // Keep looping to reduce item sizes until all are zero sized or finished removing extra space do { changed = false; // Are there any items avaiable for reducing? if (visibleItems > 0) { // How much do we need to shrink each item by? int shrink = Math.Max(1, (xMaxPos - context.DisplayRectangle.Width) / visibleItems); // Reduce size of each item for (int i = 0; i < _childSizes.Length; i++) { // Cannot make smaller then zero width if (_childSizes[i].Width > 0) { // Reduce size int tempWidth = _childSizes[i].Width; _childSizes[i].Width -= shrink; // Prevent going smaller then zero if (_childSizes[i].Width <= 0) { _childSizes[i].Width = 0; visibleItems--; } // Reduce total width by the width removed from item xMaxPos -= (tempWidth - _childSizes[i].Width); // All reduction made, exit the loop if (xMaxPos <= context.DisplayRectangle.Width) { break; } changed = true; } } } } while (changed && (xMaxPos > context.DisplayRectangle.Width)); } } // If we are shorter than the line width if (xMaxPos < context.DisplayRectangle.Width) { // If the mode requires we extend to the end of the line if ((BarMultiline == BarMultiline.Expandline) || (BarMultiline == BarMultiline.Exactline)) { bool changed; // Keep looping to expand item sizes until all the extra space is removed do { changed = false; // Are there any items avaiable for reducing? if (visibleItems > 0) { // How much do we need to expand each item by? int expand = Math.Max(1, (context.DisplayRectangle.Width - xMaxPos) / visibleItems); // Expand size of each item for (int i = 0; i < _childSizes.Length; i++) { // Expand size _childSizes[i].Width += expand; // Increase total width taken up by items xMaxPos += expand; changed = true; // All expansion made, exit the loop if (xMaxPos >= context.DisplayRectangle.Width) { break; } } } } while (changed && (xMaxPos < context.DisplayRectangle.Width)); } } // Remember the line metrics _lineDetails.Add(new LineDetails(xMaxPos, lineHeight, startIndex, itemCount)); // Our preferred size is tall enough to show the widest line and total height preferredSize.Width = xMaxPos; preferredSize.Height = _preferredOrientLength; } // Reverse the order of the lines when at top or left edge, as the // items should be positioned from the inside edge moving outwards if ((Orientation == VisualOrientation.Top) || (Orientation == VisualOrientation.Left)) { _lineDetails.Reverse(); } // If we are using tabs then we need to move the line with the selection if (ReorderSelectedLine) { // Did we find a selected child index? if (selectedChildIndex >= 0) { // Find the line details that contains this child index for (int i = 0; i < _lineDetails.Count; i++) { // Is the selected item in the range of items for this line? if ((selectedChildIndex >= _lineDetails[i].StartIndex) && (selectedChildIndex < (_lineDetails[i].StartIndex + _lineDetails[i].ItemCount))) { // Remove the line details LineDetails ld = _lineDetails[i]; _lineDetails.RemoveAt(i); if ((Orientation == VisualOrientation.Top) || (Orientation == VisualOrientation.Left)) { // Move to end of the list _lineDetails.Add(ld); } else { // Move to start of the list _lineDetails.Insert(0, ld); } } } } } } // Enfore the minimum height of the bar if (BarVertical) { preferredSize.Width = Math.Max(preferredSize.Width, BarMinimumHeight); } else { preferredSize.Height = Math.Max(preferredSize.Height, BarMinimumHeight); } return(preferredSize); }
/// <summary> /// Mouse has left the view. /// </summary> /// <param name="c">Reference to the source control instance.</param> /// <param name="next">Reference to view that is next to have the mouse.</param> public virtual void MouseLeave(Control c, ViewBase next) { }
/// <summary> /// Gets the ButtonSpec associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to ButtonSpec; otherwise null.</returns> public override ButtonSpec ButtonSpecFromView(ViewBase element) { // There is no view for the page return(null); }
/// <summary> /// Should this element cause the navigator to gain the focus. /// </summary> /// <param name="element">Element that is being activated.</param> /// <returns>True to give navigator the focus; otherwise false.</returns> public virtual bool GiveNavigatorFocus(ViewBase element) { return(false); }
/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Sync to represent the current ribbon QAT buttons SyncChildren(true); // We take on all the available display area ClientRectangle = context.DisplayRectangle; int x = ClientLocation.X; int right = ClientRectangle.Right; // If we need to show the extra button if (_extraButton != null) { // Find size of the extra button Size childSize = _extraButton.GetPreferredSize(context); // Make sure there is always enough room for it at the right hand side right -= childSize.Width; } int y = ClientLocation.Y; int height = ClientHeight; _overflow = false; // Are there any children to layout? if (this.Count > 0) { // Position each item from left to right taking up entire height for (int i = 0; i < this.Count; i++) { ViewBase child = this[i]; // We only position visible items and we always ignore the extra button if (child != _extraButton) { if (child.Visible) { // Cache preferred size of the child Size childSize = this[i].GetPreferredSize(context); // Is there enough width for this item to be displayed if ((childSize.Width + x) <= right) { // Define display rectangle for the group context.DisplayRectangle = new Rectangle(x, y, childSize.Width, height); // Position the element this[i].Layout(context); // Move across to next position x += childSize.Width; } else { // Hide the child, not enough for it child.Visible = false; // Need to use the extra button as an overflow button _overflow = true; } } else { // Cast child to correct type ViewDrawRibbonQATButton view = (ViewDrawRibbonQATButton)child; // If the quick access toolbar button wants to be visible if (view.QATButton.GetVisible() || _ribbon.InDesignHelperMode) { _overflow = true; } } } } } // Do we need to position the extra button? if (_extraButton != null) { // Cache preferred size of the child Size childSize = _extraButton.GetPreferredSize(context); // Is there enough width for this item to be displayed if ((childSize.Width + x) <= ClientRectangle.Right) { // Define display rectangle for the group context.DisplayRectangle = new Rectangle(x, y, childSize.Width, height); // Position the element _extraButton.Layout(context); // Move across to next position x += childSize.Width; } // Should button show as overflow or customization _extraButton.Overflow = _overflow; } // Update our own size to reflect how wide we actually need to be for all the children ClientRectangle = new Rectangle(ClientLocation, new Size(x - ClientLocation.X, ClientHeight)); // Update the display rectangle we allocated for use by parent context.DisplayRectangle = new Rectangle(ClientLocation, new Size(x - ClientLocation.X, ClientHeight)); }
/// <summary> /// Gets the previous focus item based on the current item as provided. /// </summary> /// <param name="current">The view that is currently focused.</param> /// <param name="matched">Has the current focus item been matched yet.</param> /// <returns>ViewBase of item; otherwise false.</returns> public ViewBase GetPreviousFocusItem(ViewBase current, ref bool matched) { // Do we match the current item? matched = (current == _viewLarge) || (current == _viewMediumSmall); return(null); }
/// <summary> /// Resets the PlacementTarget property to its default value. /// </summary> public void ResetPlacementTarget() { PlacementTarget = null; }
/// This binding will add or remove views based on an element/viewmodel collection. public virtual void WeaponsRemoved(ViewBase item) { }
/// <summary> /// Gets the ButtonSpec associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to ButtonSpec; otherwise null.</returns> public abstract ButtonSpec ButtonSpecFromView(ViewBase element);
/// This binding will add or remove views based on an element/viewmodel collection. public virtual void WeaponsAdded(ViewBase item) { }
/// <summary> /// Gets the ButtonSpec associated with the provided view element. /// </summary> /// <param name="element">Element to search against.</param> /// <returns>Reference to ButtonSpec; otherwise null.</returns> public ButtonSpec ButtonSpecFromView(ViewBase element) { // Ask the button manager for the button spec for this element return(_buttonManager.ButtonSpecFromView(element)); }
/// <summary> /// Initialize a new instance of the PageButtonController class. /// </summary> /// <param name="target">Target for state changes.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PageButtonController(ViewBase target, NeedPaintHandler needPaint) : base(target, needPaint) { }