Beispiel #1
0
        private void appButton()
        {
            if (InvokeRequired)
            {
                Invoke(new appButtonInvoke(appButton));
            }
            try
            {
                ribbon.ApplicationButtonDropDownControl = applicationMenu1;
                applicationMenu1.ShowRightPane          = true;
                //applicationMenu1.RightPaneControlContainer = popupControlContainer1;

                AppMenuFileLabel label1 = new AppMenuFileLabel();
                //Image labelUncheckedImage = imageCollection3.Images[1];
                //Image labelCheckedImage = imageCollection3.Images[0];
                label1.Dock            = DockStyle.Top;
                label1.AutoHeight      = true;
                label1.Caption         = "Document1.rtf";
                label1.ShowCheckButton = true;
                //label1.Image = labelUncheckedImage;
                //label1.SelectedImage = labelCheckedImage;
                // Fires when the label is clicked
                label1.LabelClick += new EventHandler(label1_LabelClick);
                //label1.Tag = "c:\\My Documents\\Document1.rtf";

                // Add the label to the container.
                //popupControlContainer1.Controls.Add(label1);
            }
            catch (Exception ex)
            {
            }
        }
        public static void AddSeparator(this AppMenuFileLabel fileLabel)
        {
            LabelControl l = new LabelControl();

            l.AutoSizeMode    = LabelAutoSizeMode.None;
            l.Text            = string.Empty;
            l.Height          = 10;
            l.LineOrientation = LabelLineOrientation.Horizontal;
            l.LineVisible     = true;
            fileLabel.Parent.Controls.Add(l);
            l.Dock = DockStyle.Top;
        }
Beispiel #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     for (int i = 0; i < 10; i++)
     {
         AppMenuFileLabel f = new AppMenuFileLabel();
         popupControlContainer1.Controls.Add(f);
         f.Dock = DockStyle.Top;
         f.Text = "Document " + i.ToString();
         if ((i + 1) % 3 == 0)
         {
             f.AddSeparator();
         }
     }
 }
Beispiel #4
0
        void SetElementsRange()
        {
            int i = 0;

            foreach (Control c in container.Controls)
            {
                AppMenuFileLabel ml = c as AppMenuFileLabel;
                if (ml == null)
                {
                    continue;
                }
                ml.Caption = string.Format("&{0}", container.Controls.Count - i);
                i++;
            }
        }
Beispiel #5
0
 public bool RemoveLastElement()
 {
     for (int i = 0; i < container.Controls.Count; i++)
     {
         AppMenuFileLabel ml = container.Controls[i] as AppMenuFileLabel;
         if (ml != null && !ml.Checked)
         {
             base.Remove(ml.Tag);
             ml.LabelClick -= new EventHandler(OnLabelClick);
             ml.Dispose();
             return(true);
         }
     }
     return(false);
 }
Beispiel #6
0
 public bool GetLabelChecked(string name)
 {
     foreach (Control c in container.Controls)
     {
         AppMenuFileLabel ml = c as AppMenuFileLabel;
         if (ml == null)
         {
             continue;
         }
         if (ml.Tag.Equals(name))
         {
             return(ml.Checked);
         }
     }
     return(false);
 }
Beispiel #7
0
        public void InsertElement(IMenuBarItem menuBarItem)
        {
            var ml = new AppMenuFileLabel {
                ShowCheckButton = false
            };

            _container.Controls.Add(ml);
            ml.Appearance.TextOptions.HotkeyPrefix = HKeyPrefix.None;
            ml.Text        = menuBarItem.Caption;
            ml.Tag         = menuBarItem;
            ml.SuperTip    = _toolTipCreator.CreateToolTip(menuBarItem.Description, Captions.FilePath);
            ml.AutoHeight  = true;
            ml.Dock        = DockStyle.Top;
            ml.LabelClick += menuClicked;
            setElementsRange();
        }
Beispiel #8
0
            public void InsertElement(object value)
            {
                string[] names        = value.ToString().Split(',');
                string   name         = names[0];
                bool     checkedLabel = false;

                if (names.Length > 1)
                {
                    checkedLabel = names[1].ToLower().Equals("true");
                }
                foreach (AppMenuFileLabel ml in container.Controls)
                {
                    if (ml.Tag.Equals(name))
                    {
                        checkedLabel = ml.Checked;
                        base.Remove(name);
                        ml.LabelClick -= new EventHandler(OnLabelClick);
                        ml.Dispose();
                        break;
                    }
                }
                bool access = true;

                if (base.Count >= maxRecentFiles)
                {
                    access = RemoveLastElement();
                }
                if (access)
                {
                    base.Insert(0, name);
                    AppMenuFileLabel ml = new AppMenuFileLabel();
                    container.Controls.Add(ml);
                    ml.Tag           = name;
                    ml.Text          = GetFileName(name);
                    ml.Checked       = checkedLabel;
                    ml.AutoHeight    = true;
                    ml.Dock          = DockStyle.Top;
                    ml.Image         = imgUncheked;
                    ml.SelectedImage = imgChecked;
                    ml.LabelClick   += new EventHandler(OnLabelClick);
                    SetElementsRange();
                }
            }
Beispiel #9
0
        public void InsertElement(object value)
        {
            string[] names        = value.ToString().Split(',');
            string   name         = names[0];
            bool     checkedLabel = false;

            if (names.Length > 1)
            {
                checkedLabel = names[1].ToLower().Equals("true");
            }
            foreach (Control c in container.Controls)
            {
                AppMenuFileLabel ml = c as AppMenuFileLabel;
                if (ml == null)
                {
                    continue;
                }
                if (ml.Tag.Equals(name))
                {
                    checkedLabel = ml.Checked;
                    base.Remove(name);
                    ml.LabelClick -= new EventHandler(OnLabelClick);
                    ml.Dispose();
                    break;
                }
            }
            bool access = true;

            if (base.Count >= maxRecentFiles)
            {
                access = RemoveLastElement();
            }
            if (access)
            {
                base.Insert(0, name);
                AppMenuFileLabel ml = new AppMenuFileLabel();
                int index           = GetLastAppMenuFileLabelIndex();
                container.Controls.Add(ml);
                container.Controls.SetChildIndex(ml, index);
                ml.Tag = name;
                if (showDescription)
                {
                    ml.Text        = GetFileName(name);
                    ml.Description = name;
                }
                else
                {
                    ml.Text = GetFileName(name);
                }
                ml.Glyph         = glyph;
                ml.Checked       = checkedLabel;
                ml.AutoHeight    = true;
                ml.Dock          = DockStyle.Top;
                ml.Image         = imgUncheked;
                ml.SelectedImage = imgChecked;
                ml.LabelClick   += new EventHandler(OnLabelClick);
                if (indexedList)
                {
                    SetElementsRange();
                }
            }
        }
 public void InsertElement(object value)
 {
     string[] names = value.ToString().Split(',');
     string name = names[0];
     bool checkedLabel = false;
     if (names.Length > 1) checkedLabel = names[1].ToLower().Equals("true");
     foreach (AppMenuFileLabel ml in container.Controls)
     {
         if (ml.Tag.Equals(name))
         {
             checkedLabel = ml.Checked;
             base.Remove(name);
             ml.LabelClick -= new EventHandler(OnLabelClick);
             ml.Dispose();
             break;
         }
     }
     bool access = true;
     if (base.Count >= maxRecentJobs)
         access = RemoveLastElement();
     if (access)
     {
         base.Insert(0, name);
         AppMenuFileLabel ml = new AppMenuFileLabel();
         container.Controls.Add(ml);
         ml.Tag = name;
         ml.Text = GetFileName(name);
         ml.Checked = checkedLabel;
         ml.AutoHeight = true;
         ml.Dock = DockStyle.Top;
         ml.Image = imgUncheked;
         ml.SelectedImage = imgChecked;
         ml.LabelClick += new EventHandler(OnLabelClick);
         SetElementsRange();
     }
 }