/// <summary> /// Initialize a new instance of the ViewDrawMenuColorColumns class. /// </summary> /// <param name="provider">Reference to provider.</param> /// <param name="colorColumns">Reference to owning color columns entry.</param> public ViewDrawMenuColorColumns(IContextMenuProvider provider, KryptonContextMenuColorColumns colorColumns) { _provider = provider; _colorColumns = colorColumns; // Use separators to create space around the colors areas _innerDocker = new ViewLayoutDocker(); // Redraw when the selected color changes colorColumns.SelectedColorChanged += OnSelectedColorChanged; Color[][] colors = colorColumns.Colors; int columns = colors.Length; int rows = ((columns > 0) && (colors[0] != null) ? colors[0].Length : 0); bool enabled = provider.ProviderEnabled; // Always assume there is a first row of colors ViewLayoutStack fillStack = new ViewLayoutStack(false) { CreateColumns(provider, colorColumns, colors, 0, 1, enabled) }; // If there are other rows to show if (rows > 1) { if (_colorColumns.GroupNonFirstRows) { // Create a view to show the rest of the rows fillStack.Add(new ViewLayoutSeparator(5)); fillStack.Add(CreateColumns(provider, colorColumns, colors, 1, rows, enabled)); } else { // Otherwise show each row as separate for (int i = 1; i < rows; i++) { fillStack.Add(new ViewLayoutSeparator(5)); fillStack.Add(CreateColumns(provider, colorColumns, colors, i, i + 1, enabled)); } } } // Create a gap around the contents _innerDocker.Add(fillStack, ViewDockStyle.Fill); _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Top); _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Bottom); _innerDocker.Add(new ViewLayoutSeparator(2), ViewDockStyle.Left); _innerDocker.Add(new ViewLayoutSeparator(2), ViewDockStyle.Right); // Use outer docker so that any extra space not needed is used by the null _outerDocker = new ViewLayoutDocker { { _innerDocker, ViewDockStyle.Top }, { new ViewLayoutNull(), ViewDockStyle.Fill } }; // Add docker as the composite content Add(_outerDocker); }
private ViewLayoutStack CreateColumns(IContextMenuProvider provider, KryptonContextMenuColorColumns colorColumns, Color[][] colors, int start, int end, bool enabled) { // Create a horizontal stack of columns ViewLayoutStack columns = new ViewLayoutStack(true) { FillLastChild = false }; // Add each color column for (int i = 0; i < colors.Length; i++) { // Use a separator between each column if (i > 0) { columns.Add(new ViewLayoutSeparator(4)); } // Add container for the column, this draws the background ViewDrawMenuColorColumn colorColumn = new ViewDrawMenuColorColumn(provider, colorColumns, colors[i], start, end, enabled); columns.Add(colorColumn); } return(columns); }
private ViewLayoutStack AddColumn(ViewLayoutStack columns) { ViewLayoutStack column = new ViewLayoutStack(false); columns.Add(column); return(column); }
/// <summary> /// Create view elements appropriate for the collection items. /// </summary> /// <param name="provider">Context menu information provider.</param> /// <param name="parent">Parent object.</param> /// <param name="columns">Collection of columns to create view inside.</param> /// <param name="standardStyle">Should the standard style be applied.</param> /// <param name="imageColumn">Should the imgea column be applied.</param> public void GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { // Create the initial column ViewLayoutStack column = AddColumn(columns); // Process each item in the collection in turn foreach (KryptonContextMenuItemBase item in this) { if (item.Visible) { // Special handling of separator items if (item is KryptonContextMenuSeparator separator) { // Cast to correct type // If vertical break.... if (!separator.Horizontal) { // Add separator as next column view element provider.ProviderViewColumns.Add(separator.GenerateView(provider, this, columns, standardStyle, imageColumn)); // Start new column for subsequent child items column = AddColumn(columns); } else { // Add separator view into the current column column.Add(separator.GenerateView(provider, this, columns, standardStyle, imageColumn)); } } else { // All other items we just ask them for the view to add column.Add(item.GenerateView(provider, this, columns, standardStyle, imageColumn)); } } } }
private ViewBase AddColumn(IContextMenuProvider provider, KryptonContextMenuItems items, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { // Create a pile specific to organising menu items ViewLayoutMenuItemsPile menuItemPile = new ViewLayoutMenuItemsPile(provider, items, standardStyle, imageColumn); // The pile is the root item for the new column columns.Add(menuItemPile); // Child items are placed inside the column stack return(menuItemPile.ItemStack); }
/// <summary> /// Initialize a new instance of the ViewDrawMonth class. /// </summary> /// <param name="calendar">Reference to calendar provider.</param> /// <param name="months">Reference to months instance.</param> /// <param name="redirector">Redirector for getting values.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> public ViewDrawMonth(IKryptonMonthCalendar calendar, ViewLayoutMonths months, PaletteRedirect redirector, NeedPaintHandler needPaintDelegate) : base(false) { _calendar = calendar; _months = months; // Add a header for showing the month/year value _drawContent = new ViewDrawContent(_calendar.StateNormal.Header.Content, this, VisualOrientation.Top); _borderForced = new PaletteBorderInheritForced(_calendar.StateNormal.Header.Border); _borderForced.ForceBorderEdges(PaletteDrawBorders.None); _drawHeader = new ViewDrawDocker(_calendar.StateNormal.Header.Back, _borderForced, null) { { _drawContent, ViewDockStyle.Fill } }; Add(_drawHeader); // Create the left/right arrows for moving the months _arrowPrev = new ButtonSpecCalendar(this, PaletteButtonSpecStyle.Previous, RelativeEdgeAlign.Near); _arrowNext = new ButtonSpecCalendar(this, PaletteButtonSpecStyle.Next, RelativeEdgeAlign.Far); _arrowPrev.Click += OnPrevMonth; _arrowNext.Click += OnNextMonth; _buttonSpecs = new CalendarButtonSpecCollection(this) { _arrowPrev, _arrowNext }; // Using a button spec manager to add the buttons to the header _buttonManager = new ButtonSpecManagerDraw(_calendar.CalendarControl, redirector, null, _buttonSpecs, new ViewDrawDocker[] { _drawHeader }, new IPaletteMetric[] { _calendar.StateCommon }, new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetCalendar }, new PaletteMetricPadding[] { PaletteMetricPadding.None }, _calendar.GetToolStripDelegate, needPaintDelegate); // Create stacks for holding display items ViewLayoutStack namesStack = new ViewLayoutStack(true); ViewLayoutStack weeksStack = new ViewLayoutStack(true); ViewLayoutStack daysStack = new ViewLayoutStack(false); _numberStack = new ViewLayoutStack(false); weeksStack.Add(_numberStack); weeksStack.Add(daysStack); // Add day names _drawMonthDayNames = new ViewDrawMonthDayNames(_calendar, _months); _drawWeekCorner = new ViewLayoutWeekCorner(_calendar, _months, _calendar.StateNormal.Header.Border); namesStack.Add(_drawWeekCorner); namesStack.Add(_drawMonthDayNames); Add(namesStack); Add(weeksStack); // Add border between week numbers and days area _borderEdgeRedirect = new PaletteBorderEdgeRedirect(_calendar.StateNormal.Header.Border, null); _borderEdge = new PaletteBorderEdge(_borderEdgeRedirect, null); _drawBorderEdge = new ViewDrawBorderEdge(_borderEdge, Orientation.Vertical); _drawWeekNumbers = new ViewDrawWeekNumbers(_calendar, _months); ViewLayoutDocker borderLeftDock = new ViewLayoutDocker { { _drawWeekNumbers, ViewDockStyle.Left }, { new ViewLayoutSeparator(0, 4), ViewDockStyle.Top }, { _drawBorderEdge, ViewDockStyle.Fill }, { new ViewLayoutSeparator(0, 4), ViewDockStyle.Bottom } }; _numberStack.Add(borderLeftDock); // Add border between day names and individual days PaletteBorderEdgeRedirect borderEdgeRedirect = new PaletteBorderEdgeRedirect(_calendar.StateNormal.Header.Border, null); PaletteBorderEdge borderEdge = new PaletteBorderEdge(borderEdgeRedirect, null); ViewDrawBorderEdge drawBorderEdge = new ViewDrawBorderEdge(borderEdge, Orientation.Horizontal); ViewLayoutDocker borderTopDock = new ViewLayoutDocker { { new ViewLayoutSeparator(4, 1), ViewDockStyle.Left }, { drawBorderEdge, ViewDockStyle.Fill }, { new ViewLayoutSeparator(4, 1), ViewDockStyle.Right }, { new ViewLayoutSeparator(1, 3), ViewDockStyle.Bottom } }; daysStack.Add(borderTopDock); // Add the actual individual days ViewDrawMonthDays = new ViewDrawMonthDays(_calendar, _months); daysStack.Add(ViewDrawMonthDays); // Adding buttons manually means we have to ask for buttons to be created _buttonManager.RecreateButtons(); }