/// <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));
            }
        }
        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 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);
        }
示例#4
0
        private ViewLayoutStack AddColumn(ViewLayoutStack columns)
        {
            ViewLayoutStack column = new ViewLayoutStack(false);

            columns.Add(column);
            return(column);
        }
示例#5
0
        /// <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)
                    {
                        // Cast to correct type
                        KryptonContextMenuSeparator separator = (KryptonContextMenuSeparator)item;

                        // 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));
                    }
                }
            }
        }
示例#6
0
        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);
        }
示例#7
0
        /// <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();
        }