Beispiel #1
0
            public RecentDocumentList(
                RibbonItemCollection rightPaneItems,
                StringCollection files,
                LoadDocumentDelegate loadDocument)
            {
                this.rightPaneItems = rightPaneItems;
                this.files          = files;
                this.loadDocument   = loadDocument;

                // first create a header and make sure it's not selectable
                RibbonListItem listItem = new RibbonListItem(new RibbonLabel("Recent Documents"));

                listItem.AllowSelection = false;
                rightPaneItems.Add(listItem);
                rightPaneItems.Add(new RibbonListItem(new RibbonSeparator()));

                this.listTopIndex = rightPaneItems.Count;

                // create the recently used document list
                foreach (string document in this.files)
                {
                    RecentDocumentItem item = new RecentDocumentItem(document, false, loadDocument);
                    rightPaneItems.Add(item);

                    string d = document;
                }
            }
Beispiel #2
0
        private void RefreshMdiWindowList()
        {
            RibbonItemCollection items = switchWindowsToggleGroup.Items;

            for (int i = 0; i < items.Count; i++)
            {
                items[i].Dispose();
            }
            items.Clear();
            Form[] forms       = MdiChildren;
            Form   activeChild = ActiveMdiChild;

            for (int i = 0; i < forms.Length; i++)
            {
                frmList f = forms[i] as frmList;
                if (f != null && !f.BeingDisposed)
                {
                    RibbonToggleButton tb = new RibbonToggleButton();
                    tb.Pressed = object.ReferenceEquals(f, activeChild);
                    tb.Text    = f.Text;
                    tb.Tag     = f;
                    items.Add(tb);
                }
            }
            switchWindowsMenu.Enabled = items.Count > 0;
        }
Beispiel #3
0
        RibbonListItem AppendListItem(RibbonItemCollection ribbonItems, int num, string path)
        {
            var rli = new C1.Win.Ribbon.RibbonListItem();

            var sb = new StringBuilder();

            if (num < 10)
            {
                sb.Append('&').Append(num).Append("  ");
            }
            else
            {
                sb.Append(num).Append(' ');
            }
            sb.Append(Path.GetFileNameWithoutExtension(path));
            rli.Items.Add(new RibbonLabel(sb.ToString()));

            var delButton = new C1.Win.Ribbon.RibbonButton();

            if (num < 10)
            {
                delButton.KeyTip = "Y" + num.ToString();
            }
            delButton.SelectableInListItem = true;
            delButton.SmallImage           = Properties.Resources.Delete16x16;
            delButton.ToolTip = "Remove from list";
            delButton.Click  += new System.EventHandler(this.DelButton_Click);
            rli.Items.Add(delButton);

            ribbonItems.Add(rli);

            rli.ToolTip = path;
            rli.Click  += RibbonListItem_Click;
            return(rli);
        }
Beispiel #4
0
        private void CreateOrbItem(string collectionName, RibbonItemCollection collection, Type t)
        {
            if (Ribbon == null)
            {
                return;
            }

            var host                = GetService(typeof(IDesignerHost)) as IDesignerHost;
            var transaction         = host.CreateTransaction("AddRibbonOrbItem_" + Component.Site.Name);
            MemberDescriptor member = TypeDescriptor.GetProperties(Ribbon.OrbDropDown)[collectionName];

            RaiseComponentChanging(member);

            var item = host.CreateComponent(t) as RibbonItem;

            if (!(item is RibbonSeparator))
            {
                item.Text = item.Site.Name;
            }

            collection.Add(item);
            Ribbon.OrbDropDown.OnRegionsChanged();

            RaiseComponentChanged(member, null, null);
            transaction.Commit();

            Ribbon.OrbDropDown.SelectOnDesigner(item);
            Ribbon.OrbDropDown.WrappedDropDown.Size = Ribbon.OrbDropDown.Size;
        }
Beispiel #5
0
        public virtual void CreateItem(Ribbon ribbon, RibbonItemCollection collection, Type t)
        {
            var host = GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (host != null && collection != null && ribbon != null)
            {
                var transaction = host.CreateTransaction("AddRibbonItem_" + Component.Site.Name);

                MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Items"];
                base.RaiseComponentChanging(member);

                var item = host.CreateComponent(t) as RibbonItem;

                if (!(item is RibbonSeparator))
                {
                    item.Text = item.Site.Name;
                }

                collection.Add(item);
                ribbon.OnRegionsChanged();

                base.RaiseComponentChanged(member, null, null);
                transaction.Commit();
            }
        }
Beispiel #6
0
        void AddThemeColor(RibbonItemCollection items, ThemeColor themeColor)
        {
            RibbonToggleButton tb = new RibbonToggleButton();

            tb.Text            = themeColor.ToString();
            tb.Tag             = themeColor;
            tb.ToggleGroupName = "Theme";
            tb.CanDepress      = false;
            items.Add(tb);
        }
Beispiel #7
0
        // initialize main menu
        void InitApplicationMenu()
        {
            // initialize menu
            RibbonApplicationMenu menu = this.ApplicationMenu;

            menu.DropDownWidth     = 370;
            menu.AllowImageScaling = false;
            menu.SmallImage        = Resources.AppMenuArrow;
            menu.Appearance        = AppMenuAppearance.WholeForm;
            menu.DropDown         += Menu_DropDown;

            // left menu items
            RibbonItemCollection items = menu.LeftPaneItems;

            items.ClearAndDisposeItems();
            items.Add(CreateButton("New"));
            items.Add(CreateTab("OpenTab"));
            ((AppMenuTabs.OpenTab)((RibbonAppMenuTab)items["OpenTab"]).Control).RibbonApplicationMenu = menu;
            items.Add(CreateButton("Save"));
            items["Save"].SmallImage = null;
            items.Add(CreateTab("SaveAsTab"));
            ((AppMenuTabs.SaveAsTab)((RibbonAppMenuTab)items["SaveAsTab"]).Control).RibbonApplicationMenu = menu;
            items.Add(new RibbonSeparator());
            items.Add(CreateTab("PrintTab"));

            _printTab                 = (AppMenuTabs.PrintTab)((RibbonAppMenuTab)items["PrintTab"]).Control;
            _printTab.Ribbon          = this;
            _printTab.VisibleChanged += _printTab_VisibleChanged;

            //items.Add(CreateSplitButton("Print",
            //    CreateHeaderLabel("PreviewAndPrint"),
            //    CreateButton("Print"),
            //    CreateButton("QuickPrint"),
            //    CreateButton("PrintPreview")));
            items.Add(CreateButton("ExportPdf"));
            items.Add(new RibbonSeparator());
            items.Add(CreateButton("Exit"));

            _mruOpened = new RecentDocumentList(Settings.Default.OpenedFiles);
            _mruSaved  = new RecentDocumentList(Settings.Default.SavedFiles);
        }
Beispiel #8
0
        // adds a list of items to a RibbonItemCollection.
        // items must be strings or RibbonItem objects.
        static void AddSubItems(RibbonItemCollection ric, object[] items)
        {
            foreach (object item in items)
            {
                // convert text into buttons
                string text = item as string;
                if (text != null)
                {
                    ric.Add(CreateButton(text));
                    continue;
                }

                // paste items
                RibbonItem ribbonItem = item as RibbonItem;
                if (ribbonItem != null)
                {
                    ric.Add(ribbonItem);
                    continue;
                }

                // oops
                Debug.Assert(false, "AddSubItems expected string or RibbonItem");
            }
        }
Beispiel #9
0
        public void UpdateRecentPackFiles()
        {
            RibbonItemCollection collection = mRibbon.OrbDropDown.RecentItems;

            collection.Clear();
            for (int i = 0; i < Settings.RecentPackFiles.Count; i++)
            {
                RibbonButton item = new RibbonButton();
                item.Text = PathShortener(Settings.RecentPackFiles[i], 40);
                item.Tag  = Settings.RecentPackFiles[i];

                item.Click += new EventHandler(recentItem_Click);

                collection.Add(item);
            }
        }
Beispiel #10
0
        private void BorderWidthSetup()
        {
            const string Sample     = "Hairline"; // should be not smaller than the biggest text
            const int    PadX       = 4;
            const int    PadY       = 3;
            const int    Gap        = 8; // gap between text and line
            const int    LineLength = 64;

            RibbonItemCollection items = rcmbBorderWidth.Items;

            items.BeginUpdate();
            foreach (BordersForm.BorderWidthItem bwi in BordersForm.s_borderWidths)
            {
                RibbonButton item = new RibbonButton(bwi.Width.ToString());
                item.OwnerDraw    = true;
                item.MeasureItem += (ss, ee) =>
                {
                    SizeF s = ee.Graphics.MeasureString(Sample, this.Font, PointF.Empty, StringFormat.GenericDefault);
                    ee.ItemHeight = (int)Math.Round(s.Height + PadY * 2);
                    ee.ItemWidth  = (int)Math.Round(s.Width + LineLength + PadX * 2 + Gap);
                };
                item.DrawItem += (ss, ee) =>
                {
                    ee.DrawBackground();
                    using (Pen p = new Pen(ee.ForeColor, ((float)bwi.Width / 1440f) * ee.Graphics.DpiY))
                        using (SolidBrush b = new SolidBrush(ee.ForeColor))
                            using (var sf = new StringFormat(StringFormat.GenericDefault))
                            {
                                var offset = ee.Graphics.MeasureString(Sample, this.Font, PointF.Empty, StringFormat.GenericDefault).Width + PadX + Gap / 2;

                                sf.Alignment     = StringAlignment.Far;
                                sf.LineAlignment = StringAlignment.Center;
                                ee.Graphics.DrawString(bwi.Text, this.Font, b, ee.Bounds.Left + offset - Gap / 2, ee.Bounds.Top + ee.Bounds.Height / 2, sf);
                                if (bwi.Width > 0)
                                {
                                    ee.Graphics.DrawLine(p, ee.Bounds.Left + offset + Gap / 2, ee.Bounds.Top + ee.Bounds.Height / 2, ee.Bounds.Right - PadX, ee.Bounds.Top + ee.Bounds.Height / 2);
                                }
                            }
                };
                items.Add(item);
            }
            items.EndUpdate();
        }
Beispiel #11
0
        public static void AddItem(this RibbonItemCollection items, RibbonCommandItem item, string text, ICommand command, Bitmap smallImage, Bitmap largeImage)
        {
            item.Text      = text;
            item.ShowText  = true;
            item.ShowImage = false;
            if ((smallImage != null) || (largeImage != null))
            {
                item.ShowImage = true;
                if (largeImage == null)
                {
                    largeImage = smallImage;
                }
                item.Image      = GetImage(smallImage);
                item.LargeImage = GetImage(largeImage);
            }
            item.Size           = RibbonItemSize.Standard;
            item.CommandHandler = command;

            items.Add(item);
        }
Beispiel #12
0
        private void UpdateRecentLocations(string address)
        {
            // Get the collection of recent locations (right pane)
            RibbonItemCollection mru = c1Ribbon.ApplicationMenu.RightPaneItems;

            // Add the specified address if not already present
            if (address.Length > 0 && !mru.Contains(address))
            {
                // Create a list item containing a label
                RibbonLabel    label = new RibbonLabel(address);
                RibbonListItem item  = new RibbonListItem(label);

                // Add a handler for the Click event
                item.Click += new EventHandler(recentLocation_Click);

                // Must set the ID for subsequent calls to mru.Contains(address)
                item.ID = address;

                // Add the new item to the collection
                mru.Add(item);
            }
        }
Beispiel #13
0
        private void CreateOrbItem(string collectionName, RibbonItemCollection collection, Type t)
        {
            if (Ribbon == null) return;

            IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;
            DesignerTransaction transaction = host.CreateTransaction("AddRibbonOrbItem_" + Component.Site.Name);
            MemberDescriptor member = TypeDescriptor.GetProperties(Ribbon.OrbDropDown)[collectionName];
            RaiseComponentChanging(member);

            RibbonItem item = host.CreateComponent(t) as RibbonItem;

            if (!(item is RibbonSeparator)) item.Text = item.Site.Name;

            collection.Add(item);
            Ribbon.OrbDropDown.OnRegionsChanged();

            RaiseComponentChanged(member, null, null);
            transaction.Commit();

            Ribbon.OrbDropDown.SelectOnDesigner(item);
            Ribbon.OrbDropDown.WrappedDropDown.Size = Ribbon.OrbDropDown.Size;
        }
Beispiel #14
0
 public static void AddSeparator(this RibbonItemCollection items)
 {
     items.Add(new RibbonSeparator());
 }
 private RibbonCheckBox AddCheckBox(RibbonItemCollection collection, string text, string msoCommandName)
 {
     RibbonCheckBox checkbox = new RibbonCheckBox();
     checkbox.Text = text;
     collection.Add(checkbox);
     AssignAction(checkbox, msoCommandName);
     return checkbox;
 }
Beispiel #16
0
        public virtual void CreateItem(Ribbon ribbon, RibbonItemCollection collection, Type t)
        {
            IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (host != null && collection != null && ribbon != null)
            {
                DesignerTransaction transaction = host.CreateTransaction("AddRibbonItem_" + Component.Site.Name);

                MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Items"];
                base.RaiseComponentChanging(member);

                RibbonItem item = host.CreateComponent(t) as RibbonItem;

                if (!(item is RibbonSeparator)) item.Text = item.Site.Name;

                collection.Add(item);
                ribbon.OnRegionsChanged();

                base.RaiseComponentChanged(member, null, null);
                transaction.Commit();
            }
        }
 private RibbonLabel AddLabel(RibbonItemCollection collection, string text)
 {
     RibbonLabel label = new RibbonLabel();
     label.Text = text;
     collection.Add(label);
     return label;
 }
 private RibbonSeparator AddSeparator(RibbonItemCollection collection)
 {
     RibbonSeparator separator = new RibbonSeparator();
     collection.Add(separator);
     return separator;
 }
        private RibbonUpDown AddUpDown(RibbonItemCollection collection, string label, string msoImageName,
				DocumentEventHandler getValue, string suffix, decimal increment, decimal min = 0, decimal max = 100, EventHandler changed = null)
        {
            RibbonUpDown updown = new RibbonUpDown();
            updown.Text = label;
            updown.LabelWidth = 50;
            AssignImage(updown, msoImageName);
            decimal currentValue = 0;
            updown.TextBoxText = currentValue + suffix;
            updown.AllowTextEdit = true;
            updown.Enabled = true;
            updown.UpButtonClicked += new MouseEventHandler(delegate(object sender, MouseEventArgs e) {
                currentValue = Math.Min(currentValue + increment, max);
                updown.TextBoxText = currentValue + suffix;
            });
            updown.DownButtonClicked += new MouseEventHandler(delegate(object sender, MouseEventArgs e) {
                currentValue = Math.Max(currentValue - increment, min);
                updown.TextBoxText = currentValue + suffix;
            });
            m_WordInstance.Application.WindowActivate += new Word.ApplicationEvents4_WindowActivateEventHandler(delegate(Word.Document doc, Word.Window win) {
                currentValue = Math.Min(max, Math.Max(min, getValue(doc)));
                updown.TextBoxText = currentValue + suffix;
            });
            // TODO: Uncommenting this causes serious issues. Figure out later if necessary.
            //updown.TextBoxTextChanged += changed;
            collection.Add(updown);
            return updown;
        }
Beispiel #20
0
 public static void AddRowBreak(this RibbonItemCollection items)
 {
     items.Add(new RibbonRowBreak());
 }
        private RibbonButton AddButton(RibbonItemCollection collection, RibbonButtonStyle style, string label, string msoImageName,
			string msoCommandName, RibbonElementSizeMode maxSizeMode = RibbonElementSizeMode.None, Action customAction = null)
        {
            RibbonButton button = new RibbonButton();
            button.Style = style;
            button.MaxSizeMode = maxSizeMode;
            button.Text = label;
            AssignImage(button, msoImageName);
            if (customAction == null) {
                AssignAction(button, msoCommandName);
            } else {
                EventHandler handler = new EventHandler(delegate(object sender, EventArgs ea) {
                    RunCommand(customAction);
                });
                button.Click += handler;
                button.DoubleClick += handler;
            }
            collection.Add(button);
            return button;
        }