/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { if (Horizontal && (parent is KryptonContextMenuItemCollection)) { // Create a stack of horizontal items inside the item ViewLayoutDocker docker = new ViewLayoutDocker(); // Take up same space as the image column, so separator starts close to actual text ViewDrawContent imageContent = new ViewDrawContent(provider.ProviderStateCommon.ItemImage.Content, new FixedContentValue(null, null, null, Color.Empty), VisualOrientation.Top); ViewDrawMenuImageCanvas imageCanvas = new ViewDrawMenuImageCanvas(provider.ProviderStateCommon.ItemImage.Back, provider.ProviderStateCommon.ItemImage.Border, 0, true); imageCanvas.Add(imageContent); docker.Add(new ViewLayoutCenter(imageCanvas), ViewDockStyle.Left); docker.Add(new ViewLayoutSeparator(1, 0), ViewDockStyle.Left); // Gap that matches left padding of text/extra text docker.Add(new ViewLayoutMenuSepGap(provider.ProviderStateCommon, standardStyle), ViewDockStyle.Left); // Separator Display ViewLayoutStack separatorStack = new ViewLayoutStack(false); separatorStack.Add(new ViewLayoutSeparator(1, 1)); separatorStack.Add(new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator)); separatorStack.Add(new ViewLayoutSeparator(1, 1)); docker.Add(separatorStack, ViewDockStyle.Fill); return(docker); } else { return(new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator)); } }
/// <summary> /// Initialize a new instance of the ContextMenuProvider class. /// </summary> /// <param name="viewManager">View manager used to organize keyboard events.</param> /// <param name="menuCollection">Top level set of menu items.</param> /// <param name="viewColumns">Stack used for adding new columns.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="needPaintDelegate">Delegate used to when paint changes occur.</param> public AppButtonMenuProvider(ViewContextMenuManager viewManager, KryptonContextMenuItemCollection menuCollection, ViewLayoutStack viewColumns, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, NeedPaintHandler needPaintDelegate) { // Store incoming state _viewManager = viewManager; _menuCollection = menuCollection; _viewColumns = viewColumns; _palette = palette; _paletteMode = paletteMode; _redirector = redirector; _needPaintDelegate = needPaintDelegate; // Create all other state _parent = null; _enabled = true; _canCloseMenu = true; _showHorz = KryptonContextMenuPositionH.After; _showVert = KryptonContextMenuPositionV.Top; _stateCommon = new PaletteContextMenuRedirect(redirector, needPaintDelegate); _stateNormal = new PaletteContextMenuItemState(_stateCommon); _stateDisabled = new PaletteContextMenuItemState(_stateCommon); _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateCommon); _stateChecked = new PaletteContextMenuItemStateChecked(_stateCommon); _redirectorImages = new PaletteRedirectContextMenu(redirector, new ContextMenuImages(needPaintDelegate)); }
/// <summary> /// Initialize a new instance of the VisualContextMenu class. /// </summary> /// <param name="provider">Original source of provider details</param> /// <param name="items">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> public VisualContextMenu(IContextMenuProvider provider, KryptonContextMenuCollection items, bool keyboardActivated) : base(true) { _redirector = provider.ProviderRedirector; // Create the view manager instance with root element ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull()); // Set the initial resolved palette to the appropriate setting if (provider.ProviderPalette != null) SetPalette(provider.ProviderPalette); else SetPalette(KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode)); // Set of context menu columns _viewColumns = new ViewLayoutStack(true); // Create provider instance _provider = new ContextMenuProvider(provider, (ViewContextMenuManager)ViewManager, _viewColumns, NeedPaintDelegate); _provider.Closing += new CancelEventHandler(OnProviderClosing); _provider.Close += new EventHandler<CloseReasonEventArgs>(OnProviderClose); _provider.Dispose += new EventHandler(OnProviderClose); Construct(items, keyboardActivated); }
/// <summary> /// Initialize a new instance of the ContextMenuProvider class. /// </summary> /// <param name="contextMenu">Originating context menu instance.</param> /// <param name="viewManager">Reference to view manager.</param> /// <param name="viewColumns">Columns view element.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> /// <param name="enabled">Enabled state of the context menu.</param> public ContextMenuProvider(KryptonContextMenu contextMenu, ViewContextMenuManager viewManager, ViewLayoutStack viewColumns, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, NeedPaintHandler needPaintDelegate, bool enabled) { ProviderShowHorz = KryptonContextMenuPositionH.Left; ProviderShowVert = KryptonContextMenuPositionV.Below; ProviderEnabled = enabled; ProviderViewManager = viewManager; ProviderViewColumns = viewColumns; ProviderStateCommon = contextMenu.StateCommon; ProviderStateDisabled = contextMenu.StateDisabled; ProviderStateNormal = contextMenu.StateNormal; ProviderStateHighlight = contextMenu.StateHighlight; ProviderStateChecked = contextMenu.StateChecked; ProviderImages = redirectorImages; ProviderPalette = palette; ProviderPaletteMode = paletteMode; ProviderRedirector = redirector; ProviderNeedPaintDelegate = needPaintDelegate; ProviderCanCloseMenu = true; }
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); columns.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); }
/// <summary> /// Initialize a new instance of the ContextMenuProvider class. /// </summary> /// <param name="viewManager">Reference to view manager.</param> /// <param name="viewColumns">Columns view element.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="stateCommon">State used to provide common palette values.</param> /// <param name="stateNormal">State used to provide normal palette values.</param> /// <param name="stateDisabled">State used to provide disabled palette values.</param> /// <param name="stateHighlight">State used to provide highlight palette values.</param> /// <param name="stateChecked">State used to provide checked palette values.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> /// <param name="enabled">Enabled state of the context menu.</param> public ContextMenuProvider(ViewContextMenuManager viewManager, ViewLayoutStack viewColumns, IPalette palette, PaletteMode paletteMode, PaletteContextMenuRedirect stateCommon, PaletteContextMenuItemState stateDisabled, PaletteContextMenuItemState stateNormal, PaletteContextMenuItemStateHighlight stateHighlight, PaletteContextMenuItemStateChecked stateChecked, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, NeedPaintHandler needPaintDelegate, bool enabled) { _showHorz = KryptonContextMenuPositionH.Left; _showVert = KryptonContextMenuPositionV.Below; _enabled = enabled; _viewManager = viewManager; _viewColumns = viewColumns; _stateCommon = stateCommon; _stateDisabled = stateDisabled; _stateNormal = stateNormal; _stateHighlight = stateHighlight; _stateChecked = stateChecked; _redirectorImages = redirectorImages; _palette = palette; _paletteMode = paletteMode; _redirector = redirector; _needPaintDelegate = needPaintDelegate; }
/// <summary> /// Initialize a new instance of the VisualContextMenu class. /// </summary> /// <param name="contextMenu">Originating context menu instance.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="items">Collection of context menu items to be displayed.</param> /// <param name="enabled">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> public VisualContextMenu(KryptonContextMenu contextMenu, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, KryptonContextMenuCollection items, bool enabled, bool keyboardActivated) : base(true) { _contextMenu = contextMenu; Redirector = redirector; // Create the view manager instance with root element ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull()); // Set the initial resolved palette to the appropriate setting SetPalette(palette ?? KryptonManager.GetPaletteForMode(paletteMode)); // Set of context menu columns _viewColumns = new ViewLayoutStack(true); // Create provider instance _provider = new ContextMenuProvider(contextMenu, (ViewContextMenuManager)ViewManager, _viewColumns, palette, paletteMode, redirector, redirectorImages, NeedPaintDelegate, enabled); _provider.Closing += OnProviderClosing; _provider.Close += OnProviderClose; _provider.Dispose += OnProviderClose; Construct(items, keyboardActivated); }
/// <summary> /// Initialize a new instance of the VisualContextMenu class. /// </summary> /// <param name="provider">Original source of provider details</param> /// <param name="items">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> public VisualContextMenu(IContextMenuProvider provider, KryptonContextMenuCollection items, bool keyboardActivated) : base(true) { _redirector = provider.ProviderRedirector; // Create the view manager instance with root element ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull()); // Set the initial resolved palette to the appropriate setting if (provider.ProviderPalette != null) { SetPalette(provider.ProviderPalette); } else { SetPalette(KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode)); } // Set of context menu columns _viewColumns = new ViewLayoutStack(true); // Create provider instance _provider = new ContextMenuProvider(provider, (ViewContextMenuManager)ViewManager, _viewColumns, NeedPaintDelegate); _provider.Closing += new CancelEventHandler(OnProviderClosing); _provider.Close += new EventHandler <CloseReasonEventArgs>(OnProviderClose); _provider.Dispose += new EventHandler(OnProviderClose); Construct(items, keyboardActivated); }
private ViewLayoutStack AddColumn(ViewLayoutStack columns) { ViewLayoutStack column = new ViewLayoutStack(false); columns.Add(column); return(column); }
/// <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); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { return(new ViewLayoutMenuItemSelect(this, provider)); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { return(new ViewDrawMenuHeading(this, provider.ProviderStateCommon.Heading)); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { return(new ViewDrawMenuLinkLabel(provider, this)); }
/// <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 += new EventHandler<ColorEventArgs>(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); fillStack.Add(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(); _outerDocker.Add(_innerDocker, ViewDockStyle.Top); _outerDocker.Add(new ViewLayoutNull(), ViewDockStyle.Fill); // Add docker as the composite content Add(_outerDocker); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { // Add child items into columns of display views ViewLayoutStack itemsColumns = new ViewLayoutStack(true); Items.GenerateView(provider, this, this, itemsColumns, StandardStyle, ImageColumn); return(itemsColumns); }
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 ViewLayoutMenuItemsPile class. /// </summary> /// <param name="provider">Provider of context menu values.</param> /// <param name="items">Reference to the owning collection.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> public ViewLayoutMenuItemsPile(IContextMenuProvider provider, KryptonContextMenuItems items, bool standardStyle, bool imageColumn) { // Cache access to the highlight item palette _paletteItemHighlight = provider.ProviderStateCommon.ItemHighlight; // Create and place an image column inside a docker so it appears on the left side _imageColumn = new ViewDrawMenuImageColumn(items, provider.ProviderStateCommon.ItemImageColumn); ViewLayoutDocker imageDocker = new ViewLayoutDocker { { _imageColumn, ViewDockStyle.Left } }; // Only show the image column when in a standard collection of items imageDocker.Visible = imageColumn; // Create a vertical stack that contains each individual menu item ItemStack = new ViewLayoutStack(false) { FillLastChild = false }; // Use a docker with the item stack as the fill ViewLayoutDocker stackDocker = new ViewLayoutDocker { { ItemStack, ViewDockStyle.Fill } }; // Grab the padding for around the item stack Padding itemsPadding = _paletteItemHighlight.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemsCollection); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Left), ViewDockStyle.Left); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Right), ViewDockStyle.Right); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Top), ViewDockStyle.Top); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Bottom), ViewDockStyle.Bottom); // The background of the pile is the image column Add(imageDocker); // The foreground of the pile is the stack of menu items Add(stackDocker); }
internal void GenerateView(IContextMenuProvider provider, KryptonContextMenuItems items, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { // Create the initial column ViewBase column = AddColumn(provider, items, columns, standardStyle, imageColumn); // 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) { // Cast to correct type KryptonContextMenuSeparator separator = (KryptonContextMenuSeparator)item; // If vertical break.... if (!separator.Horizontal) { // Add separator as next column view element columns.Add(separator.GenerateView(provider, this, columns, standardStyle, imageColumn)); // Start new column for subsequent child items column = AddColumn(provider, items, columns, standardStyle, imageColumn); } 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)); } } } }
/// <summary> /// Initialize a new instance of the ContextMenuProvider class. /// </summary> /// <param name="provider">Original provider.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> /// <param name="viewManager">Reference to view manager.</param> /// <param name="viewColumns">Columns view element.</param> public ContextMenuProvider(IContextMenuProvider provider, ViewContextMenuManager viewManager, ViewLayoutStack viewColumns, NeedPaintHandler needPaintDelegate) { _parent = provider; _enabled = provider.ProviderEnabled; _canCloseMenu = provider.ProviderCanCloseMenu; _viewManager = viewManager; _viewColumns = viewColumns; _stateCommon = provider.ProviderStateCommon; _stateDisabled = provider.ProviderStateDisabled; _stateNormal = provider.ProviderStateNormal; _stateHighlight = provider.ProviderStateHighlight; _stateChecked = provider.ProviderStateChecked; _redirectorImages = provider.ProviderImages; _palette = provider.ProviderPalette; _paletteMode = provider.ProviderPaletteMode; _redirector = provider.ProviderRedirector; _needPaintDelegate = needPaintDelegate; _showHorz = provider.ProviderShowHorz; _showVert = provider.ProviderShowVert; }
/// <summary> /// Initialize a new instance of the ContextMenuProvider class. /// </summary> /// <param name="provider">Original provider.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> /// <param name="viewManager">Reference to view manager.</param> /// <param name="viewColumns">Columns view element.</param> public ContextMenuProvider(IContextMenuProvider provider, ViewContextMenuManager viewManager, ViewLayoutStack viewColumns, NeedPaintHandler needPaintDelegate) { _parent = provider; _enabled = provider.ProviderEnabled; _canCloseMenu = provider.ProviderCanCloseMenu; _viewManager = viewManager; _viewColumns = viewColumns; _stateCommon = provider.ProviderStateCommon; _stateDisabled = provider.ProviderStateDisabled; _stateNormal = provider.ProviderStateNormal; _stateHighlight = provider.ProviderStateHighlight; _stateChecked = provider.ProviderStateChecked; _redirectorImages = provider.ProviderImages; _palette = provider.ProviderPalette; _paletteMode = provider.ProviderPaletteMode; _redirector = provider.ProviderRedirector; _needPaintDelegate = needPaintDelegate; _showHorz = provider.ProviderShowHorz; _showVert = provider.ProviderShowVert; }
/// <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); _drawHeader.Add(_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 += new EventHandler(OnPrevMonth); _arrowNext.Click += new EventHandler(OnNextMonth); _buttonSpecs = new CalendarButtonSpecCollection(this); _buttonSpecs.Add(_arrowPrev); _buttonSpecs.Add(_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(); borderLeftDock.Add(_drawWeekNumbers, ViewDockStyle.Left); borderLeftDock.Add(new ViewLayoutSeparator(0, 4), ViewDockStyle.Top); borderLeftDock.Add(_drawBorderEdge, ViewDockStyle.Fill); borderLeftDock.Add(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(); borderTopDock.Add(new ViewLayoutSeparator(4, 1), ViewDockStyle.Left); borderTopDock.Add(drawBorderEdge, ViewDockStyle.Fill); borderTopDock.Add(new ViewLayoutSeparator(4, 1), ViewDockStyle.Right); borderTopDock.Add(new ViewLayoutSeparator(1, 3), ViewDockStyle.Bottom); daysStack.Add(borderTopDock); // Add the actual individual days _drawMonthDays = new ViewDrawMonthDays(_calendar, _months); daysStack.Add(_drawMonthDays); // Adding buttons manually means we have to ask for buttons to be created _buttonManager.RecreateButtons(); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { return new ViewDrawMenuHeading(this, provider.ProviderStateCommon.Heading); }
/// <summary> /// Initialize a new instance of the ContextMenuProvider class. /// </summary> /// <param name="contextMenu">Originating context menu instance.</param> /// <param name="viewManager">Reference to view manager.</param> /// <param name="viewColumns">Columns view element.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> /// <param name="enabled">Enabled state of the context menu.</param> public ContextMenuProvider(KryptonContextMenu contextMenu, ViewContextMenuManager viewManager, ViewLayoutStack viewColumns, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, NeedPaintHandler needPaintDelegate, bool enabled) { _showHorz = KryptonContextMenuPositionH.Left; _showVert = KryptonContextMenuPositionV.Below; _enabled = enabled; _viewManager = viewManager; _viewColumns = viewColumns; _stateCommon = contextMenu.StateCommon; _stateDisabled = contextMenu.StateDisabled; _stateNormal = contextMenu.StateNormal; _stateHighlight = contextMenu.StateHighlight; _stateChecked = contextMenu.StateChecked; _redirectorImages = redirectorImages; _palette = palette; _paletteMode = paletteMode; _redirector = redirector; _needPaintDelegate = needPaintDelegate; _canCloseMenu = true; }
/// <summary> /// Initialize a new instance of the ViewDrawMenuItem class. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="menuItem">Menu item definition.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> public ViewDrawMenuItem(IContextMenuProvider provider, KryptonContextMenuItem menuItem, ViewLayoutStack columns, bool standardStyle, bool imageColumn) : base(menuItem.StateNormal.ItemHighlight.Back, menuItem.StateNormal.ItemHighlight.Border, menuItem.StateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, VisualOrientation.Top) { // Remember values _provider = provider; KryptonContextMenuItem = menuItem; _imageColumn = imageColumn; _standardStyle = standardStyle; // Give the item object the redirector to use when inheriting values KryptonContextMenuItem.SetPaletteRedirect(provider); // Create a stack of horizontal items inside the item ViewLayoutDocker docker = new ViewLayoutDocker(); // Decide on the enabled state of the display ItemEnabled = provider.ProviderEnabled && ResolveEnabled; PaletteContextMenuItemState menuItemState = (ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled); // Calculate the image to show inside in the image column Image itemColumnImage = ResolveImage; Color itemImageTransparent = ResolveImageTransparentColor; // If no image found then... if (itemColumnImage != null) { // Ensure we have a fixed size if we are showing an image column if (_imageColumn) { itemColumnImage = _empty16x16; itemImageTransparent = Color.Magenta; } switch (ResolveCheckState) { case CheckState.Checked: itemColumnImage = provider.ProviderImages.GetContextMenuCheckedImage(); itemImageTransparent = Color.Empty; break; case CheckState.Indeterminate: itemColumnImage = provider.ProviderImages.GetContextMenuIndeterminateImage(); itemImageTransparent = Color.Empty; break; } } // Column Image PaletteTripleJustImage justImage = (ResolveChecked ? KryptonContextMenuItem.StateChecked.ItemImage : menuItemState.ItemImage); _fixedImage = new FixedContentValue(null, null, itemColumnImage, itemImageTransparent); _imageContent = new ViewDrawContent(justImage.Content, _fixedImage, VisualOrientation.Top); _imageCanvas = new ViewDrawMenuImageCanvas(justImage.Back, justImage.Border, 0, false) { _imageContent }; docker.Add(new ViewLayoutCenter(_imageCanvas), ViewDockStyle.Left); _imageContent.Enabled = ItemEnabled; // Text/Extra Text PaletteContentJustText menuItemStyle = (standardStyle ? menuItemState.ItemTextStandard : menuItemState.ItemTextAlternate); _fixedTextExtraText = new FixedContentValue(ResolveText, ResolveExtraText, null, Color.Empty); _textContent = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1); docker.Add(_textContent, ViewDockStyle.Fill); _textContent.Enabled = ItemEnabled; // Shortcut if (KryptonContextMenuItem.ShowShortcutKeys) { string shortcutString = KryptonContextMenuItem.ShortcutKeyDisplayString; if (string.IsNullOrEmpty(shortcutString)) { shortcutString = (KryptonContextMenuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(KryptonContextMenuItem.ShortcutKeys) : string.Empty; } if (shortcutString.Length > 0) { _shortcutContent = new ViewDrawMenuItemContent(menuItemState.ItemShortcutText, new FixedContentValue(shortcutString, null, null, Color.Empty), 2); docker.Add(_shortcutContent, ViewDockStyle.Right); _shortcutContent.Enabled = ItemEnabled; } } // Add split item separator SplitSeparator = new ViewDrawMenuSeparator(menuItemState.ItemSplit); docker.Add(SplitSeparator, ViewDockStyle.Right); SplitSeparator.Enabled = ItemEnabled; SplitSeparator.Draw = (KryptonContextMenuItem.Items.Count > 0) && KryptonContextMenuItem.SplitSubMenu; // SubMenu Indicator HasSubMenu = (KryptonContextMenuItem.Items.Count > 0); _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!HasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (KryptonContextMenuItem.Items.Count == 0 ? Color.Magenta : Color.Empty)), 3); docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right); _subMenuContent.Enabled = ItemEnabled; Add(docker); // Add a controller for handing mouse and keyboard events MenuItemController mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate); MouseController = mic; KeyController = mic; // Want to know when a property changes whilst displayed KryptonContextMenuItem.PropertyChanged += OnPropertyChanged; // We need to know if a property of the command changes if (KryptonContextMenuItem.KryptonCommand != null) { _cachedCommand = KryptonContextMenuItem.KryptonCommand; KryptonContextMenuItem.KryptonCommand.PropertyChanged += OnCommandPropertyChanged; } }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { return new ViewLayoutMenuItemSelect(this, provider); }
/// <summary> /// Initialize a new instance of the VisualPopupAppMenu class. /// </summary> /// <param name="ribbon">Owning ribbon instance.</param> /// <param name="appButton">Originating app button instance.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="rectAppButtonTopHalf">Screen location of the upper half of the app button.</param> /// <param name="rectAppButtonBottomHalf">Screen location of the lower half of the app button.</param> /// <param name="keyboardActivated">Was the context menu activated by a keyboard action.</param> public VisualPopupAppMenu(KryptonRibbon ribbon, RibbonAppButton appButton, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, Rectangle rectAppButtonTopHalf, Rectangle rectAppButtonBottomHalf, bool keyboardActivated) : base(true) { // Remember incoming state _redirector = redirector; _ribbon = ribbon; _rectAppButtonTopHalf = rectAppButtonTopHalf; _rectAppButtonBottomHalf = rectAppButtonBottomHalf; // Create the view manager instance with root element ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull()); // Set the initial resolved palette to the appropriate setting if (palette != null) SetPalette(palette); else SetPalette(KryptonManager.GetPaletteForMode(paletteMode)); // Set of context menu columns _viewColumns = new ViewLayoutStack(true); // Create provider instance _provider = new AppButtonMenuProvider((ViewContextMenuManager)ViewManager, _ribbon.RibbonAppButton.AppButtonMenuItems, _viewColumns, palette, paletteMode, redirector, NeedPaintDelegate); _provider.Closing += new CancelEventHandler(OnProviderClosing); _provider.Close += new EventHandler<CloseReasonEventArgs>(OnProviderClose); _provider.Dispose += new EventHandler(OnProviderClose); CreateAppButtonBottom(); CreateButtonSpecView(); CreateContextMenuView(appButton); CreateRecentDocumentsView(); CreateInnerBacking(CreateInsideCanvas()); CreateOuterBacking(); CreateOutsideDocker(); CreateButtonManager(appButton); ViewManager.Root = _drawOutsideDocker; // With keyboard activate we select the first valid item if (keyboardActivated) ((ViewContextMenuManager)ViewManager).KeyDown(); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { // Add child items into columns of display views ViewLayoutStack itemsColumns = new ViewLayoutStack(true); Items.GenerateView(provider, this, this, itemsColumns, StandardStyle, ImageColumn); return itemsColumns; }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public abstract ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn);
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public abstract ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn);
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { if (Horizontal && (parent is KryptonContextMenuItemCollection)) { // Create a stack of horizontal items inside the item ViewLayoutDocker docker = new ViewLayoutDocker(); // Take up same space as the image column, so separator starts close to actual text ViewDrawContent imageContent = new ViewDrawContent(provider.ProviderStateCommon.ItemImage.Content, new FixedContentValue(null, null, null, Color.Empty), VisualOrientation.Top); ViewDrawMenuImageCanvas imageCanvas = new ViewDrawMenuImageCanvas(provider.ProviderStateCommon.ItemImage.Back, provider.ProviderStateCommon.ItemImage.Border, 0, true); imageCanvas.Add(imageContent); docker.Add(new ViewLayoutCenter(imageCanvas), ViewDockStyle.Left); docker.Add(new ViewLayoutSeparator(1, 0), ViewDockStyle.Left); // Gap that matches left padding of text/extra text docker.Add(new ViewLayoutMenuSepGap(provider.ProviderStateCommon, standardStyle), ViewDockStyle.Left); // Separator Display ViewLayoutStack separatorStack = new ViewLayoutStack(false); separatorStack.Add(new ViewLayoutSeparator(1, 1)); separatorStack.Add(new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator)); separatorStack.Add(new ViewLayoutSeparator(1, 1)); docker.Add(separatorStack, ViewDockStyle.Fill); return docker; } else return new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator); }
/// <summary> /// Returns a view appropriate for this item based on the object it is inside. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="parent">Owning object reference.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> /// <returns>ViewBase that is the root of the view hierachy being added.</returns> public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle, bool imageColumn) { return new ViewDrawMenuRadioButton(provider, this); }
public KryptonTreeView() { // Contains another control and needs marking as such for validation to work SetStyle(ControlStyles.ContainerControl, true); // Cannot select this control, only the child tree view and does not generate a click event SetStyle(ControlStyles.Selectable | ControlStyles.StandardClick, false); // Default fields _alwaysActive = true; _style = ButtonStyle.ListItem; _itemHeightDefault = true; _plusMinusImages = new TreeViewImages(); _checkBoxImages = new CheckBoxImages(); base.Padding = new Padding(1); // Create the palette storage _redirectImages = new PaletteRedirectTreeView(Redirector, _plusMinusImages, _checkBoxImages); PaletteBackInheritRedirect backInherit = new PaletteBackInheritRedirect(Redirector, PaletteBackStyle.InputControlStandalone); PaletteBorderInheritRedirect borderInherit = new PaletteBorderInheritRedirect(Redirector, PaletteBorderStyle.InputControlStandalone); PaletteBackColor1 commonBack = new PaletteBackColor1(backInherit, NeedPaintDelegate); PaletteBorder commonBorder = new PaletteBorder(borderInherit, NeedPaintDelegate); _stateCommon = new PaletteTreeStateRedirect(Redirector, commonBack, backInherit, commonBorder, borderInherit, NeedPaintDelegate); PaletteBackColor1 disabledBack = new PaletteBackColor1(_stateCommon.PaletteBack, NeedPaintDelegate); PaletteBorder disabledBorder = new PaletteBorder(_stateCommon.PaletteBorder, NeedPaintDelegate); _stateDisabled = new PaletteTreeState(_stateCommon, disabledBack, disabledBorder, NeedPaintDelegate); PaletteBackColor1 normalBack = new PaletteBackColor1(_stateCommon.PaletteBack, NeedPaintDelegate); PaletteBorder normalBorder = new PaletteBorder(_stateCommon.PaletteBorder, NeedPaintDelegate); _stateNormal = new PaletteTreeState(_stateCommon, normalBack, normalBorder, NeedPaintDelegate); PaletteBackColor1 activeBack = new PaletteBackColor1(_stateCommon.PaletteBack, NeedPaintDelegate); PaletteBorder activeBorder = new PaletteBorder(_stateCommon.PaletteBorder, NeedPaintDelegate); _stateActive = new PaletteDouble(_stateCommon, activeBack, activeBorder, NeedPaintDelegate); _stateFocus = new PaletteTreeNodeTripleRedirect(Redirector, PaletteBackStyle.ButtonListItem, PaletteBorderStyle.ButtonListItem, PaletteContentStyle.ButtonListItem, NeedPaintDelegate); _stateTracking = new PaletteTreeNodeTriple(_stateCommon.Node, NeedPaintDelegate); _statePressed = new PaletteTreeNodeTriple(_stateCommon.Node, NeedPaintDelegate); _stateCheckedNormal = new PaletteTreeNodeTriple(_stateCommon.Node, NeedPaintDelegate); _stateCheckedTracking = new PaletteTreeNodeTriple(_stateCommon.Node, NeedPaintDelegate); _stateCheckedPressed = new PaletteTreeNodeTriple(_stateCommon.Node, NeedPaintDelegate); // Create the override handling classes _overrideNormal = new PaletteTripleOverride(_stateFocus.Node, _stateNormal.Node, PaletteState.FocusOverride); _overrideTracking = new PaletteTripleOverride(_stateFocus.Node, _stateTracking.Node, PaletteState.FocusOverride); _overridePressed = new PaletteTripleOverride(_stateFocus.Node, _statePressed.Node, PaletteState.FocusOverride); _overrideCheckedNormal = new PaletteTripleOverride(_stateFocus.Node, _stateCheckedNormal.Node, PaletteState.FocusOverride); _overrideCheckedTracking = new PaletteTripleOverride(_stateFocus.Node, _stateCheckedTracking.Node, PaletteState.FocusOverride); _overrideCheckedPressed = new PaletteTripleOverride(_stateFocus.Node, _stateCheckedPressed.Node, PaletteState.FocusOverride); _overrideNormalNode = new PaletteNodeOverride(_overrideNormal); // Create the check box image drawer and place inside element so it is always centered _drawCheckBox = new ViewDrawCheckBox(_redirectImages); _layoutCheckBox = new ViewLayoutCenter(); _layoutCheckBox.Add(_drawCheckBox); // Stack used to layout the location of the node image _layoutImage = new ViewLayoutSeparator(0, 0); _layoutImageAfter = new ViewLayoutSeparator(3, 0); _layoutImageCenter = new ViewLayoutCenter(_layoutImage); _layoutImageStack = new ViewLayoutStack(true); _layoutImageStack.Add(_layoutImageCenter); _layoutImageStack.Add(_layoutImageAfter); _layoutImageState = new ViewLayoutSeparator(16, 16); _layoutImageCenterState = new ViewLayoutCenter(_layoutImageState); // Create the draw element for owner drawing individual items _contentValues = new FixedContentValue(); _drawButton = new ViewDrawButton(StateDisabled.Node, _overrideNormalNode, _overrideTracking, _overridePressed, _overrideCheckedNormal, _overrideCheckedTracking, _overrideCheckedPressed, new PaletteMetricRedirect(Redirector), _contentValues, VisualOrientation.Top, false); // Place check box on the left and the label in the remainder _layoutDocker = new ViewLayoutDocker(); _layoutDocker.Add(_layoutImageStack, ViewDockStyle.Left); _layoutDocker.Add(_layoutImageCenterState, ViewDockStyle.Left); _layoutDocker.Add(_layoutCheckBox, ViewDockStyle.Left); _layoutDocker.Add(_drawButton, ViewDockStyle.Fill); // Create the internal tree view used for containing content _treeView = new InternalTreeView(this); _treeView.TrackMouseEnter += new EventHandler(OnTreeViewMouseChange); _treeView.TrackMouseLeave += new EventHandler(OnTreeViewMouseChange); _treeView.GotFocus += new EventHandler(OnTreeViewGotFocus); _treeView.LostFocus += new EventHandler(OnTreeViewLostFocus); _treeView.KeyDown += new KeyEventHandler(OnTreeViewKeyDown); _treeView.KeyUp += new KeyEventHandler(OnTreeViewKeyUp); _treeView.KeyPress += new KeyPressEventHandler(OnTreeViewKeyPress); _treeView.PreviewKeyDown += new PreviewKeyDownEventHandler(OnTreeViewPreviewKeyDown); _treeView.Validating += new CancelEventHandler(OnTreeViewValidating); _treeView.Validated += new EventHandler(OnTreeViewValidated); _treeView.AfterCheck += new TreeViewEventHandler(OnTreeViewAfterCheck); _treeView.AfterCollapse += new TreeViewEventHandler(OnTreeViewAfterCollapse); _treeView.AfterExpand += new TreeViewEventHandler(OnTreeViewAfterExpand); _treeView.AfterLabelEdit += new NodeLabelEditEventHandler(OnTreeViewAfterLabelEdit); _treeView.AfterSelect += new TreeViewEventHandler(OnTreeViewAfterSelect); _treeView.BeforeCheck += new TreeViewCancelEventHandler(OnTreeViewBeforeCheck); _treeView.BeforeCollapse += new TreeViewCancelEventHandler(OnTreeViewBeforeCollapse); _treeView.BeforeExpand += new TreeViewCancelEventHandler(OnTreeViewBeforeExpand); _treeView.BeforeLabelEdit += new NodeLabelEditEventHandler(OnTreeViewBeforeLabelEdit); _treeView.BeforeSelect += new TreeViewCancelEventHandler(OnTreeViewBeforeSelect); _treeView.ItemDrag += new ItemDragEventHandler(OnTreeViewItemDrag); _treeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(OnTreeViewNodeMouseClick); _treeView.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(OnTreeViewNodeMouseDoubleClick); _treeView.NodeMouseHover += new TreeNodeMouseHoverEventHandler(OnTreeViewNodeMouseHover); _treeView.DrawNode += new DrawTreeNodeEventHandler(OnTreeViewDrawNode); _treeView.DrawMode = TreeViewDrawMode.OwnerDrawAll; // Create the element that fills the remainder space and remembers fill rectange _layoutFill = new ViewLayoutFill(_treeView); _layoutFill.DisplayPadding = new Padding(1); // Create inner view for placing inside the drawing docker _drawDockerInner = new ViewLayoutDocker(); _drawDockerInner.Add(_layoutFill, ViewDockStyle.Fill); // Create view for the control border and background _drawDockerOuter = new ViewDrawDocker(_stateNormal.Back, _stateNormal.Border); _drawDockerOuter.Add(_drawDockerInner, ViewDockStyle.Fill); // Create the view manager instance ViewManager = new ViewManager(this, _drawDockerOuter); // We need to create and cache a device context compatible with the display _screenDC = PI.CreateCompatibleDC(IntPtr.Zero); // Add tree view to the controls collection ((KryptonReadOnlyControls)Controls).AddInternal(_treeView); }
private void CreateRecentDocumentsView() { // Do we need to add the recent docs view? if (_ribbon.RibbonAppButton.AppButtonShowRecentDocs) { // Create a dummy vertical menu separator for separating recent documents from menu items KryptonContextMenuSeparator dummySep1 = new KryptonContextMenuSeparator(); dummySep1.Horizontal = false; _viewColumns.Add(new ViewDrawMenuSeparator(dummySep1, _provider.ProviderStateCommon.Separator)); _viewColumns.Add(new ViewLayoutSeparator(0, _ribbon.RibbonAppButton.AppButtonMinRecentSize.Height)); // Use a layout that draws the background color of the recent docs area ViewDrawRibbonAppMenuDocs recentDocsBack = new ViewDrawRibbonAppMenuDocs(_ribbon); _viewColumns.Add(recentDocsBack); // Stack the document entries vertically ViewLayoutStack documentStack = new ViewLayoutStack(false); recentDocsBack.Add(documentStack); // Use fixed width separator to enforce a minimum width to column documentStack.Add(new ViewLayoutSeparator(_ribbon.RibbonAppButton.AppButtonMinRecentSize.Width, 0)); // Add the recent document title documentStack.Add(new ViewDrawRibbonRecentDocs(_ribbon)); // Followed by a horizontal separator KryptonContextMenuSeparator dummySep2 = new KryptonContextMenuSeparator(); documentStack.Add(new ViewDrawMenuSeparator(dummySep2, _provider.ProviderStateCommon.Separator)); documentStack.Add(new ViewLayoutSeparator(2)); // Then generate an item per recent document entry int index = 1; foreach (KryptonRibbonRecentDoc recentDoc in _ribbon.RibbonAppButton.AppButtonRecentDocs) documentStack.Add(new ViewDrawRibbonAppMenuRecentDec(_ribbon, _provider, recentDoc, _ribbon.RibbonAppButton.AppButtonMaxRecentSize.Width, NeedPaintDelegate, index++)); // Add separator entry which is then used to fill remained space documentStack.Add(new ViewLayoutSeparator(1)); // Update provider with element to use as the fixed size for submenus _provider.FixedViewBase = recentDocsBack; } }
/// <summary> /// Initialize a new instance of the ViewDrawMenuItem class. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="menuItem">Menu item definition.</param> /// <param name="columns">Containing columns.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> public ViewDrawMenuItem(IContextMenuProvider provider, KryptonContextMenuItem menuItem, ViewLayoutStack columns, bool standardStyle, bool imageColumn) : base(menuItem.StateNormal.ItemHighlight.Back, menuItem.StateNormal.ItemHighlight.Border, menuItem.StateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, VisualOrientation.Top) { // Remember values _provider = provider; _menuItem = menuItem; _imageColumn = imageColumn; _standardStyle = standardStyle; // Give the item object the redirector to use when inheriting values _menuItem.SetPaletteRedirect(provider); // Create a stack of horizontal items inside the item ViewLayoutDocker docker = new ViewLayoutDocker(); // Decide on the enabled state of the display _itemEnabled = provider.ProviderEnabled && ResolveEnabled; PaletteContextMenuItemState menuItemState = (_itemEnabled ? _menuItem.StateNormal : _menuItem.StateDisabled); // Calculate the image to show inside in the image column Image itemColumnImage = ResolveImage; Color itemImageTransparent = ResolveImageTransparentColor; // If no image found then... if (itemColumnImage != null) { // Ensure we have a fixed size if we are showing an image column if (_imageColumn) { itemColumnImage = _empty16x16; itemImageTransparent = Color.Magenta; } switch (ResolveCheckState) { case CheckState.Checked: itemColumnImage = provider.ProviderImages.GetContextMenuCheckedImage(); itemImageTransparent = Color.Empty; break; case CheckState.Indeterminate: itemColumnImage = provider.ProviderImages.GetContextMenuIndeterminateImage(); itemImageTransparent = Color.Empty; break; } } // Column Image PaletteTripleJustImage justImage = (ResolveChecked ? _menuItem.StateChecked.ItemImage : menuItemState.ItemImage); _fixedImage = new FixedContentValue(null, null, itemColumnImage, itemImageTransparent); _imageContent = new ViewDrawContent(justImage.Content, _fixedImage, VisualOrientation.Top); _imageCanvas = new ViewDrawMenuImageCanvas(justImage.Back, justImage.Border, 0, false); _imageCanvas.Add(_imageContent); docker.Add(new ViewLayoutCenter(_imageCanvas), ViewDockStyle.Left); _imageContent.Enabled = _itemEnabled; // Text/Extra Text PaletteContentJustText menuItemStyle = (standardStyle ? menuItemState.ItemTextStandard : menuItemState.ItemTextAlternate); _fixedTextExtraText = new FixedContentValue(ResolveText, ResolveExtraText, null, Color.Empty); _textContent = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1); docker.Add(_textContent, ViewDockStyle.Fill); _textContent.Enabled = _itemEnabled; // Shortcut if (_menuItem.ShowShortcutKeys) { string shortcutString = _menuItem.ShortcutKeyDisplayString; if (string.IsNullOrEmpty(shortcutString)) shortcutString = (_menuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(_menuItem.ShortcutKeys) : string.Empty; if (shortcutString.Length > 0) { _shortcutContent = new ViewDrawMenuItemContent(menuItemState.ItemShortcutText, new FixedContentValue(shortcutString, null, null, Color.Empty), 2); docker.Add(_shortcutContent, ViewDockStyle.Right); _shortcutContent.Enabled = _itemEnabled; } } // Add split item separator _splitSeparator = new ViewDrawMenuSeparator(menuItemState.ItemSplit); docker.Add(_splitSeparator, ViewDockStyle.Right); _splitSeparator.Enabled = _itemEnabled; _splitSeparator.Draw = (_menuItem.Items.Count > 0) && _menuItem.SplitSubMenu; // SubMenu Indicator _hasSubMenu = (_menuItem.Items.Count > 0); _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!_hasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (_menuItem.Items.Count == 0 ? Color.Magenta : Color.Empty)), 3); docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right); _subMenuContent.Enabled = _itemEnabled; Add(docker); // Add a controller for handing mouse and keyboard events MenuItemController mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate); MouseController = mic; KeyController = mic; // Want to know when a property changes whilst displayed _menuItem.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); // We need to know if a property of the command changes if (_menuItem.KryptonCommand != null) { _cachedCommand = _menuItem.KryptonCommand; _menuItem.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged); } }
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); columns.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; }