Example #1
0
        /// <summary>
        /// Renders a MenuItem.
        /// </summary>
        protected virtual void RenderItem(Ribbon control, RibbonTabPage tabPage, RibbonItemGroup group, MenuItem item, PaintEventArgs e)
        {
            var canvas           = e.Canvas;
            var padding          = e.LogicalToDeviceUnits(item.Padding);
            var background_color = item.Selected ? Theme.ItemSelectedColor : item.Hovered ? Theme.ItemHighlightColor : Theme.NeutralGray;

            canvas.FillRectangle(item.Bounds, background_color);

            var image_area_bounds  = new Rectangle(item.Bounds.Left + padding.Left, item.Bounds.Top + padding.Top, item.Bounds.Width - padding.Horizontal, e.LogicalToDeviceUnits(MINIMUM_ITEM_SIZE));
            var final_image_bounds = DrawingExtensions.CenterSquare(image_area_bounds, e.LogicalToDeviceUnits(IMAGE_SIZE));

            if (item.Image != null)
            {
                canvas.DrawBitmap(item.Image, final_image_bounds, !item.Enabled);
            }

            if (!string.IsNullOrWhiteSpace(item.Text))
            {
                var font_size = e.LogicalToDeviceUnits(Theme.ItemFontSize);

                canvas.Save();
                canvas.Clip(item.Bounds);

                var text_bounds = new Rectangle(item.Bounds.Left, image_area_bounds.Bottom, item.Bounds.Width, item.Bounds.Bottom - image_area_bounds.Bottom);
                canvas.DrawText(item.Text, Theme.UIFont, font_size, text_bounds, item.Enabled ? Theme.PrimaryTextColor : Theme.DisabledTextColor, ContentAlignment.MiddleCenter);

                canvas.Restore();
            }
        }
Example #2
0
        public RibbonPanel()
        {
            var ribbon = new Ribbon();

            var home_tab = ribbon.TabPages.Add("Home");

            var group1 = new RibbonItemGroup {
                Text = "Home"
            };

            group1.Items.Add(new RibbonItem("Parent Folder", ImageLoader.Get("folder-up.png")));

            var group2 = new RibbonItemGroup {
                Text = "Actions"
            };

            group2.Items.Add(new RibbonItem("New Folder", ImageLoader.Get("folder-add.png")));
            group2.Items.Add(new RibbonItem("Search", ImageLoader.Get("search.png")));
            group2.Items.Add(new RibbonItem("Delete", ImageLoader.Get("delete-red.png")));

            home_tab.Groups.Add(group1);
            home_tab.Groups.Add(group2);

            var share_tab   = ribbon.TabPages.Add("Share");
            var share_group = new RibbonItemGroup {
                Text = "Send"
            };

            share_group.Items.Add(new RibbonItem("Email", ImageLoader.Get("mail.png")));
            share_group.Items.Add(new RibbonItem("Zip", ImageLoader.Get("compress.png")));
            share_group.Items.Add(new RibbonItem("Burn DVD", ImageLoader.Get("cd-burn.png")));
            share_group.Items.Add(new RibbonItem("Print", ImageLoader.Get("print.png")));

            share_tab.Groups.Add(share_group);

            var view_tab = ribbon.TabPages.Add("View");
            var group3   = new RibbonItemGroup {
                Text = "Themes"
            };

            group3.Items.Add(new RibbonItem("Default", ImageLoader.Get("swatches.png")));
            group3.Items.Add(new RibbonItem("Green", ImageLoader.Get("swatches.png")));
            group3.Items.Add(new RibbonItem("Orange", ImageLoader.Get("swatches.png")));
            group3.Items.Add(new RibbonItem("Purple", ImageLoader.Get("swatches.png")));
            group3.Items.Add(new RibbonItem("Hotdog Stand", ImageLoader.Get("swatches.png")));

            view_tab.Groups.Add(group3);

            Controls.Add(ribbon);
        }
Example #3
0
        private void InitHomeTab()
        {
            //Clipboard panel
            RibbonButton btnPaste = new RibbonButton("Paste");

            btnPaste.Image  = Resources.paste_32;
            btnPaste.Click += new EventHandler(pasteRibbonButton_Click);

            RibbonButton btnCut = new RibbonButton("Cut");

            btnCut.MaxSizeMode = RibbonElementSizeMode.Medium;
            btnCut.SmallImage  = Resources.cut_16;
            btnCut.Click      += new EventHandler(cutRibbonButton_Click);

            RibbonButton btnCopy = new RibbonButton("Copy");

            btnCopy.MaxSizeMode = RibbonElementSizeMode.Medium;
            btnCopy.SmallImage  = Resources.copy_16;
            btnCopy.Click      += new EventHandler(copyRibbonButton_Click);

            RibbonButton btnDelete = new RibbonButton("Delete");

            btnDelete.MaxSizeMode = RibbonElementSizeMode.Medium;
            btnDelete.SmallImage  = Resources.delete_16;
            btnDelete.Click      += new EventHandler(deleteRibbonButton_Click);

            panelClipboard = new RibbonPanel("Clipboard");
            panelClipboard.Items.Add(btnPaste);
            panelClipboard.Items.Add(btnCut);
            panelClipboard.Items.Add(btnCopy);
            panelClipboard.Items.Add(btnDelete);

            //Arrange
            RibbonButton btnAlignHorizontally = new RibbonButton();

            btnAlignHorizontally.SmallImage  = Resources.align_horizontally_16;
            btnAlignHorizontally.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnAlignHorizontally.Click      += new EventHandler(alignHorizontallyRibbonButton_Click);

            RibbonButton btnAlignVertically = new RibbonButton();

            btnAlignVertically.SmallImage  = Resources.align_vertically_16;
            btnAlignVertically.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnAlignVertically.Click      += new EventHandler(alignVerticallyRibbonButton_Click);

            RibbonButton btnSpaceHorizontally = new RibbonButton();

            btnSpaceHorizontally.SmallImage  = Resources.space_horizontally_16;
            btnSpaceHorizontally.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnSpaceHorizontally.Click      += new EventHandler(spaceHorizontallyRibbonButton_Click);

            RibbonButton btnSpaceVertically = new RibbonButton();

            btnSpaceVertically.SmallImage  = Resources.space_vertically_16;
            btnSpaceVertically.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnSpaceVertically.Click      += new EventHandler(spaceVerticallyRibbonButton_Click);

            RibbonItemGroup itemgroupAlignment = new RibbonItemGroup();

            itemgroupAlignment.Items.Add(btnAlignHorizontally);
            itemgroupAlignment.Items.Add(btnAlignVertically);
            itemgroupAlignment.Items.Add(btnSpaceHorizontally);
            itemgroupAlignment.Items.Add(btnSpaceVertically);

            RibbonButton btnFlipHorizontally = new RibbonButton();

            btnFlipHorizontally.SmallImage  = Resources.flip_horizontally_16;
            btnFlipHorizontally.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnFlipHorizontally.Click      += new EventHandler(flipHorizontallyRibbonButton_Click);

            RibbonButton btnFlipVertically = new RibbonButton();

            btnFlipVertically.SmallImage  = Resources.flip_vertically_16;
            btnFlipVertically.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnFlipVertically.Click      += new EventHandler(flipVerticallyRibbonButton_Click);

            RibbonItemGroup itemgroupTransform = new RibbonItemGroup();

            itemgroupTransform.Items.Add(btnFlipHorizontally);
            itemgroupTransform.Items.Add(btnFlipVertically);

            RibbonButton btnRotateAntiClockwise = new RibbonButton();

            btnRotateAntiClockwise.SmallImage  = Resources.rotate_acw_16;
            btnRotateAntiClockwise.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnRotateAntiClockwise.Click      += new EventHandler(rotateACwRibbonButton_Click);

            RibbonButton btnRotateClockwise = new RibbonButton();

            btnRotateClockwise.SmallImage  = Resources.rotate_cw_16;
            btnRotateClockwise.MaxSizeMode = RibbonElementSizeMode.Compact;
            btnRotateClockwise.Click      += new EventHandler(rotateCwRibbonButton_Click);

            RibbonItemGroup itemgroupRotatation = new RibbonItemGroup();

            itemgroupRotatation.Items.Add(btnRotateAntiClockwise);
            itemgroupRotatation.Items.Add(btnRotateClockwise);

            panelAlignment         = new RibbonPanel("Alignment");
            panelAlignment.FlowsTo = RibbonPanelFlowDirection.Right;
            panelAlignment.Items.Add(itemgroupAlignment);
            panelAlignment.Items.Add(itemgroupTransform);
            panelAlignment.Items.Add(itemgroupRotatation);

            RibbonButton btnBringForward = new RibbonButton("Bring Forwards");

            btnBringForward.Image  = Resources.bring_forward_32;
            btnBringForward.Click += new EventHandler(bringForwardRibbonButton_Click);

            RibbonButton btnSendBackward = new RibbonButton("Send Backwards");

            btnSendBackward.Image  = Resources.send_backward_32;
            btnSendBackward.Click += new EventHandler(sendBackwardRibbonButton_Click);

            RibbonButton btnBringToFront = new RibbonButton("Bring to Front");

            btnBringToFront.Image  = Resources.bring_to_front_32;
            btnBringToFront.Click += new EventHandler(bringToFrontRibbonButton_Click);

            RibbonButton btnSendToBack = new RibbonButton("Send to Back");

            btnSendToBack.Image  = Resources.send_to_back_32;
            btnSendToBack.Click += new EventHandler(sendToBackRibbonButton_Click);

            panelZOrder = new RibbonPanel("Z Order");
            panelZOrder.Items.Add(btnBringForward);
            panelZOrder.Items.Add(btnSendBackward);
            panelZOrder.Items.Add(btnBringToFront);
            panelZOrder.Items.Add(btnSendToBack);

            RibbonButton btnLaunchPeggleNights = new RibbonButton("Nights");

            btnLaunchPeggleNights.Image  = Resources.PeggleNights_32;
            btnLaunchPeggleNights.Click += new EventHandler(peggleNightsRibbonButton_Click);

            RibbonPanel panelPeggle = new RibbonPanel("Launch Peggle");

            panelPeggle.Items.Add(btnLaunchPeggleNights);

            RibbonTab tabHome = new RibbonTab(mRibbon, "Home");

            tabHome.Panels.Add(panelClipboard);
            tabHome.Panels.Add(panelAlignment);
            tabHome.Panels.Add(panelZOrder);
            tabHome.Panels.Add(panelPeggle);

            mRibbon.Tabs.Add(tabHome);
        }
Example #4
0
        private void InitializeComponent()
        {
            //SuspendLayout ();

            // ListView
            view = new ListView {
                Dock = DockStyle.Fill
            };

            view.ItemDoubleClicked += View_ItemDoubleClicked;
            Controls.Add(view);

            // TreeControl
            tree = new TreeView {
                Dock = DockStyle.Left
            };

            tree.Style.Border.Top.Width    = 0;
            tree.Style.Border.Left.Width   = 0;
            tree.Style.Border.Bottom.Width = 0;

            tree.ItemSelected += Tree_ItemSelected;
            Controls.Add(tree);

            // RibbonControl
            ribbon = new Ribbon();

            var home_tab = ribbon.TabPages.Add("Home");

            var group1 = new RibbonItemGroup {
                Text = "Home"
            };

            group1.Items.Add(new RibbonItem("Parent Folder", ImageLoader.Get("folder-up.png"), new EventHandler(ParentFolder_Clicked)));

            var group2 = new RibbonItemGroup {
                Text = "Actions"
            };

            group2.Items.Add(new RibbonItem("New Folder", ImageLoader.Get("folder-add.png"), new EventHandler(NotImplemented_Clicked)));
            group2.Items.Add(new RibbonItem("Search", ImageLoader.Get("search.png"), new EventHandler(NotImplemented_Clicked)));
            group2.Items.Add(new RibbonItem("Delete", ImageLoader.Get("delete-red.png"), new EventHandler(ShowButtonForm_Clicked)));

            home_tab.Groups.Add(group1);
            home_tab.Groups.Add(group2);

            var share_tab   = ribbon.TabPages.Add("Share");
            var share_group = new RibbonItemGroup {
                Text = "Send"
            };

            share_group.Items.Add(new RibbonItem("Email", ImageLoader.Get("mail.png"), new EventHandler(NotImplemented_Clicked)));
            share_group.Items.Add(new RibbonItem("Zip", ImageLoader.Get("compress.png"), new EventHandler(NotImplemented_Clicked)));
            share_group.Items.Add(new RibbonItem("Burn DVD", ImageLoader.Get("cd-burn.png"), new EventHandler(NotImplemented_Clicked)));
            share_group.Items.Add(new RibbonItem("Print", ImageLoader.Get("print.png"), new EventHandler(NotImplemented_Clicked)));

            share_tab.Groups.Add(share_group);

            var view_tab = ribbon.TabPages.Add("View");
            var group3   = new RibbonItemGroup {
                Text = "Themes"
            };

            group3.Items.Add(new RibbonItem("Default", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked)));
            group3.Items.Add(new RibbonItem("Green", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked)));
            group3.Items.Add(new RibbonItem("Orange", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked)));
            group3.Items.Add(new RibbonItem("Purple", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked)));
            group3.Items.Add(new RibbonItem("Hotdog Stand", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked)));

            view_tab.Groups.Add(group3);

            Controls.Add(ribbon);

            // StatusBar
            statusbar = new StatusBar();

            Controls.Add(statusbar);

            // TitleBar
            titlebar = new FormTitleBar {
                Text  = "Explore Sample",
                Image = ImageLoader.Get("layout-folder-pane.png")
            };

            Controls.Add(titlebar);

            //ResumeLayout ();
        }
Example #5
0
        /// <summary>
        /// Renders a RibbonItemGroup.
        /// </summary>
        protected virtual void RenderItemGroup(Ribbon control, RibbonTabPage tabPage, RibbonItemGroup group, PaintEventArgs e)
        {
            // Draw each ribbon item
            foreach (var item in group.Items)
            {
                if (item is MenuSeparatorItem msi)
                {
                    RenderMenuSeparatorItem(control, tabPage, group, msi, e);
                }
                else
                {
                    RenderItem(control, tabPage, group, item, e);
                }
            }

            // Right border (group separator)
            e.Canvas.DrawLine(group.Bounds.Right - 1, group.Bounds.Top + 4, group.Bounds.Right - 1, group.Bounds.Bottom - 4, Theme.BorderGray);
        }
Example #6
0
        /// <summary>
        /// Renders a MenuSeparatorItem.
        /// </summary>
        protected virtual void RenderMenuSeparatorItem(Ribbon control, RibbonTabPage tabPage, RibbonItemGroup group, MenuSeparatorItem item, PaintEventArgs e)
        {
            // Background
            e.Canvas.FillRectangle(item.Bounds, Theme.NeutralGray);

            var center    = item.Bounds.GetCenter();
            var thickness = e.LogicalToDeviceUnits(1);
            var padding   = e.LogicalToDeviceUnits(item.Padding);

            e.Canvas.DrawLine(center.X, item.Bounds.Y + padding.Top, center.X, item.Bounds.Bottom - padding.Bottom, item.Enabled ? Theme.ItemHighlightColor : Theme.DisabledTextColor, thickness);
        }
 /// <param name="ownerGroup">Group that this collection belongs to</param>
 internal RibbonItemGroupItemCollection(RibbonItemGroup ownerGroup)
 {
     _ownerGroup = ownerGroup;
 }
 /// <summary>
 /// Sets the value of the OwnerList property
 /// </summary>
 internal virtual void SetOwnerGroup(RibbonItemGroup ownerGroup)
 {
     _ownerItem = ownerGroup;
 }
        /// <summary>
        /// Draws the background of the specified  RibbonItemGroup
        /// </summary>
        /// <param name="e"></param>
        /// <param name="?"></param>
        public void DrawItemGroupBorder(RibbonItemRenderEventArgs e, RibbonItemGroup grp)
        {
            Rectangle outerR = Rectangle.FromLTRB(
                grp.Bounds.Left,
                grp.Bounds.Top,
                grp.Bounds.Right - 1,
                grp.Bounds.Bottom - 1);

            Rectangle innerR = Rectangle.FromLTRB(
                outerR.Left + 1,
                outerR.Top + 1,
                outerR.Right - 1,
                outerR.Bottom - 1);

            GraphicsPath outer = RoundRectangle(outerR, 2);
            GraphicsPath inner = RoundRectangle(innerR, 2);

            using (Pen dark = new Pen(ColorTable.ItemGroupSeparatorDark))
            {
                using (Pen light = new Pen(ColorTable.ItemGroupSeparatorLight))
                {
                    foreach (RibbonItem item in grp.Items)
                    {
                        if (item == grp.LastItem) break;

                        e.Graphics.DrawLine(dark,
                            new Point(item.Bounds.Right, item.Bounds.Top),
                            new Point(item.Bounds.Right, item.Bounds.Bottom));

                        e.Graphics.DrawLine(light,
                            new Point(item.Bounds.Right + 1, item.Bounds.Top),
                            new Point(item.Bounds.Right + 1, item.Bounds.Bottom));
                    }
                }
            }

            using (Pen p = new Pen(ColorTable.ItemGroupOuterBorder))
            {
                e.Graphics.DrawPath(p, outer);
            }

            using (Pen p = new Pen(ColorTable.ItemGroupInnerBorder))
            {
                e.Graphics.DrawPath(p, inner);
            }

            outer.Dispose();
            inner.Dispose();
        } 
        /// <summary>
        /// Draws the background of the specified  RibbonItemGroup
        /// </summary>
        /// <param name="e"></param>
        /// <param name="?"></param>
        public void DrawItemGroup(RibbonItemRenderEventArgs e, RibbonItemGroup grp)
        {
            Rectangle outerR = Rectangle.FromLTRB(
                grp.Bounds.Left,
                grp.Bounds.Top,
                grp.Bounds.Right - 1,
                grp.Bounds.Bottom - 1);

            Rectangle innerR = Rectangle.FromLTRB(
                outerR.Left + 1,
                outerR.Top + 1,
                outerR.Right - 1,
                outerR.Bottom - 1);

            Rectangle glossyR = Rectangle.FromLTRB(
                outerR.Left + 1,
                outerR.Top + outerR.Height / 2 + 1,
                outerR.Right - 1,
                outerR.Bottom - 1);

            GraphicsPath outer = RoundRectangle(outerR, 2);
            GraphicsPath inner = RoundRectangle(innerR, 2);
            GraphicsPath glossy = RoundRectangle(glossyR, 2);

            using (LinearGradientBrush b = new LinearGradientBrush(
                innerR, ColorTable.ItemGroupBgNorth, ColorTable.ItemGroupBgSouth, 90))
            {
                e.Graphics.FillPath(b, inner);
            }

            using (LinearGradientBrush b = new LinearGradientBrush(
                glossyR, ColorTable.ItemGroupBgGlossy, Color.Transparent, 90))
            {
                e.Graphics.FillPath(b, glossy);
            }

            outer.Dispose();
            inner.Dispose();
        }
Example #11
0
 /// <summary>
 ///     Sets the value of the OwnerList property
 /// </summary>
 /// <param name="ownerList"></param>
 internal virtual void SetOwnerGroup(RibbonItemGroup ownerGroup)
 {
     _ownerItem = ownerGroup;
 }
        public static RibbonButtonEx AddButton(RibbonItemGroup rig, AbstractCommand command)
        {
            var button = new RibbonButtonEx(command);
            rig.Items.Add(button);

            CommandManager.Instance.Register(command);

            return button;
        }
 public static void AddGroup(RibbonPanel panel, RibbonItemGroup rig)
 {
     panel.Items.Add(rig);
 }
        public static RibbonComboBoxEx AddComboBox(RibbonItemGroup rig, AbstractCommand command, Type t)
        {
            RibbonComboBoxEx cb = null;

            if (t == typeof(FontNameComboBox))
            {
                cb = new FontNameComboBox(command);
            }

            if (t == typeof(FontSizeComboBox))
            {
                cb = new FontSizeComboBox(command);
            }
            
            if (t == typeof(HintFontNameComboBox))
            {
                cb = new HintFontNameComboBox(command);
            }

            if (t == typeof(HintFontSizeComboBox))
            {
                cb = new HintFontSizeComboBox(command);
            }

            rig.Items.Add(cb);

            CommandManager.Instance.Register(command);

            return cb;
        }