Exemple #1
0
        public void AddContextVerb(object sender, EventArgs e)
        {
            Ribbon r = Control as Ribbon;

            if (r != null)
            {
                IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (host == null)
                {
                    return;
                }

                RibbonContext context = host.CreateComponent(typeof(RibbonContext)) as RibbonContext;

                if (context == null)
                {
                    return;
                }

                context.Text = context.Site.Name;
                Random rnd1 = new Random();

                context.GlowColor = Color.FromArgb(rnd1.Next(155, 255), rnd1.Next(155, 255), rnd1.Next(155, 255));

                Ribbon.Contexts.Add(context);

                r.Refresh();
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets or sets the context this tab belongs to
        /// </summary>
        /// <remarks>Tabs on a context are highlighted with a special glow color</remarks>
        /// <param name="context"></param>
        public void SetContext(RibbonContext context)
        {
            bool trigger = !context.Equals(context);

            if (trigger)
            {
                OnContextChanged(EventArgs.Empty);
            }

            _context = context;
        }
Exemple #3
0
        /// <summary>
        /// Sets the context of the tab
        /// </summary>
        /// <param name="context"></param>
        public void SetContext(RibbonContext context)
        {
            bool trigger = !context.Equals(context);

            if (trigger)
            {
                OnContextChanged(EventArgs.Empty);
            }

            _context = context;

            throw new NotImplementedException();
        }
Exemple #4
0
        /// <summary>
        /// Catches the event of a component on the ribbon being removed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void changeService_ComponentRemoved(object sender, ComponentEventArgs e)
        {
            RibbonTab     tab     = e.Component as RibbonTab;
            RibbonContext context = e.Component as RibbonContext;
            RibbonPanel   panel   = e.Component as RibbonPanel;
            RibbonItem    item    = e.Component as RibbonItem;

            IDesignerHost designerService = GetService(typeof(IDesignerHost)) as IDesignerHost;

            RemoveRecursive(e.Component as IContainsRibbonComponents, designerService);

            if (tab != null && Ribbon != null)
            {
                Ribbon.Tabs.Remove(tab);
            }
            else if (context != null)
            {
                Ribbon.Contexts.Remove(context);
            }
            else if (panel != null)
            {
                panel.OwnerTab.Panels.Remove(panel);
            }
            else if (item != null)
            {
                if (item.Canvas is RibbonOrbDropDown)
                {
                    Ribbon.OrbDropDown.HandleDesignerItemRemoved(item);
                }
                else if (item.OwnerItem is RibbonItemGroup)
                {
                    (item.OwnerItem as RibbonItemGroup).Items.Remove(item);
                }
                else if (item.OwnerPanel != null)
                {
                    item.OwnerPanel.Items.Remove(item);
                }
                else if (Ribbon != null && Ribbon.QuickAccessToolbar.Items.Contains(item))
                {
                    Ribbon.QuickAccessToolbar.Items.Remove(item);
                }
            }

            SelectedElement = null;

            if (Ribbon != null)
            {
                Ribbon.OnRegionsChanged();
            }
        }
        /// <summary>
        /// Sets the context of the tab
        /// </summary>
        /// <param name="context"></param>
        public void SetContext(RibbonContext context)
        {
            bool trigger = !context.Equals(context);

            if (trigger)
                OnContextChanged(EventArgs.Empty);

            _context = context;

            throw new NotImplementedException();
        }
Exemple #6
0
 public RibbonContextRenderEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonContext context)
     : base(owner, g, clip)
 {
     Context = context;
 }
 public RibbonContextRenderEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonContext context)
     : base(owner, g, clip)
 {
     Context = context;
 }
        /// <summary>
        /// Gets or sets the context this tab belongs to
        /// </summary>
        /// <remarks>Tabs on a context are highlighted with a special glow color</remarks>
        /// <param name="context"></param>
		public void SetContext(RibbonContext context)
		{
			bool trigger = !context.Equals(context);

			if (trigger)
				OnContextChanged(EventArgs.Empty);

			_context = context;
        }
Exemple #9
0
        protected override void OnPaintAdornments(PaintEventArgs pe)
        {
            base.OnPaintAdornments(pe);

            using (Pen p = new Pen(Color.Black))
            {
                p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

                ISelectionService host = GetService(typeof(ISelectionService)) as ISelectionService;

                if (host != null)
                {
                    foreach (IComponent comp in host.GetSelectedComponents())
                    {
                        if (comp is RibbonContext)
                        {
                            RibbonContext item = comp as RibbonContext;
                            if (item != null)
                            {
                                Rectangle selection = (item.ContextualTabsCount > 0) ? item.HeaderBounds : item.Bounds;
                                selection.Inflate(-1, -1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                        else if (comp is RibbonTab)
                        {
                            RibbonTab item = comp as RibbonTab;
                            if (item != null)
                            {
                                Rectangle selection = item.Bounds;
                                selection.Inflate(-1, -1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                        else if (comp is RibbonPanel)
                        {
                            RibbonPanel item = comp as RibbonPanel;
                            if (item != null)
                            {
                                Rectangle selection = item.Bounds;
                                selection.Inflate(-1, -1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                        else if (comp is RibbonItem)
                        {
                            RibbonItem item = comp as RibbonItem;
                            if (item != null && !Ribbon.OrbDropDown.AllItems.Contains(item))
                            {
                                Rectangle selection = item.Bounds;
                                selection.Inflate(1, 1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                    }
                }
            }
        }