Example #1
1
 public Form1()
 {
     InitializeComponent();
     ribbonDropDown = new RibbonDropDown(button1);
 }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            #region create organisations for dropdown
            //Get Organisations from Textfile
            OrganisationHandler           OrgHandler           = new OrganisationHandler();
            ObservableCollection <string> OrganisationList     = new ObservableCollection <string>();
            ObservableCollection <string> OrganisationListMail = new ObservableCollection <string>();
            OrgHandler.createFile();
            OrganisationList     = OrgHandler.GetOrganisations();
            OrganisationListMail = OrgHandler.GetOrganisations();

            RibbonDropDown DropdownOrganisations      = Globals.Ribbons.RibbonMenu.dropDownOrg;
            RibbonDropDown DropdownOrganisationsEmail = Globals.Ribbons.RibbonMail.dropDownOrg;


            foreach (string Organisation in OrganisationList)
            {
                RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                item.Label = Organisation;
                DropdownOrganisations.Items.Add(item);
            }

            foreach (string Organisation in OrganisationListMail)
            {
                RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                item.Label = Organisation;
                DropdownOrganisationsEmail.Items.Add(item);
            }
            #endregion
        }
 public RibbonDropDownRenderEventArgs(
     Graphics g, RibbonDropDown dropDown
     )
 {
     Graphics = g;
     DropDown = dropDown;
 }
Example #4
0
        void IniDropDownItems(RibbonDropDown dropdown, int min, int max, int selectedValue)
        {
            var items = GenIntDropdownItems(min, max - min + 1).CheapToArray();

            items.ForEach(dropdown.Items.Add);
            dropdown.SelectedItem = items.FirstOrDefault(i => (int)i.Tag == selectedValue);
            if (dropdown.SelectedItem == null)
            {
                dropdown.SelectedItemIndex = (max - min + 1) / 2;
            }
        }
        AddRibbonDropDownItems
        (
            RibbonDropDown ribbonDropDown
        )
        {
            Debug.Assert(ribbonDropDown != null);
            Debug.Assert(m_oRibbonDropDown == null);
            AssertValid();

            m_oRibbonDropDown = ribbonDropDown;

            IList <RibbonDropDownItem> oItems = m_oRibbonDropDown.Items;
            Int32 iIndexToSelect = -1;

            // Add an item for each available layout.

            foreach (LayoutInfo oLayoutInfo in AllLayouts.GetAllLayouts())
            {
                // Note: Separators cannot be added to the RibbonDropDown class.

                if (oLayoutInfo != AllLayouts.LayoutGroupSeparator)
                {
                    LayoutType eLayout = oLayoutInfo.Layout;

                    if (eLayout == base.Layout)
                    {
                        iIndexToSelect = oItems.Count;
                    }

                    RibbonDropDownItem oItem =
                        Globals.Factory.GetRibbonFactory()
                        .CreateRibbonDropDownItem();

                    oItem.Label    = oItem.ScreenTip = oLayoutInfo.Text;
                    oItem.SuperTip = oLayoutInfo.Description;
                    oItem.Tag      = eLayout;

                    oItems.Add(oItem);
                }
            }

            Debug.Assert(oItems.Count ==
                         Enum.GetValues(typeof(LayoutType)).Length);

            Debug.Assert(iIndexToSelect != -1);

            m_oRibbonDropDown.SelectedItemIndex = iIndexToSelect;

            m_oRibbonDropDown.SelectionChanged += new RibbonControlEventHandler(
                this.RibbonDropDown_SelectionChanged);
        }
Example #6
0
        private static void LoadDropDownItems(RibbonFactory factory, RibbonDropDown dropDown, IEnumerable <string> itemLabels, string savedItemLabel = null)
        {
            RibbonDropDownItem savedItem = null;

            foreach (var label in itemLabels)
            {
                var item = factory.CreateRibbonDropDownItem();
                item.Label = label;
                if (label == savedItemLabel)
                {
                    savedItem = item;
                }
                dropDown.Items.Add(item);
            }
            if (savedItem != null)
            {
                dropDown.SelectedItem = savedItem;
            }
        }
Example #7
0
 static void DropDownIntSetter(RibbonDropDown ribbonDropDown, int value)
 {
     ribbonDropDown.SelectedItem
         = ribbonDropDown.Items.FirstOrDefault(i => (int)i.Tag >= value)
           ?? ribbonDropDown.SelectedItem;
 }
Example #8
0
 /// <summary>
 /// Creates the DropDown menu
 /// </summary>
 protected virtual void CreateDropDown()
 {
     _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
 }
    AddRibbonDropDownItems
    (
        RibbonDropDown ribbonDropDown
    )
    {
        Debug.Assert(ribbonDropDown != null);
        Debug.Assert(m_oRibbonDropDown == null);
        AssertValid();

        m_oRibbonDropDown = ribbonDropDown;

        IList<RibbonDropDownItem> oItems = m_oRibbonDropDown.Items;
        Int32 iIndexToSelect = -1;

        // Add an item for each available layout.

        foreach ( LayoutInfo oLayoutInfo in AllLayouts.GetAllLayouts() )
        {
            // Note: Separators cannot be added to the RibbonDropDown class.

            if (oLayoutInfo != AllLayouts.LayoutGroupSeparator)
            {
                LayoutType eLayout = oLayoutInfo.Layout;

                if (eLayout == base.Layout)
                {
                    iIndexToSelect = oItems.Count;
                }

                RibbonDropDownItem oItem =
					Globals.Factory.GetRibbonFactory()
					.CreateRibbonDropDownItem();

                oItem.Label = oItem.ScreenTip = oLayoutInfo.Text;
                oItem.SuperTip = oLayoutInfo.Description;
                oItem.Tag = eLayout;

                oItems.Add(oItem);
            }
        }

        Debug.Assert(oItems.Count ==
            Enum.GetValues( typeof(LayoutType) ).Length);

        Debug.Assert(iIndexToSelect != -1);

        m_oRibbonDropDown.SelectedItemIndex = iIndexToSelect;

        m_oRibbonDropDown.SelectionChanged += new RibbonControlEventHandler(
			this.RibbonDropDown_SelectionChanged);
    }
Example #10
0
 private void fillRibonDropDown(ref RibbonDropDown rbControl, string query, string col)
 {
     rbControl.Items.Clear();
     using (var connection = new MySqlConnection(Properties.Settings.Default.pandidConnectionString))
     {
         connection.Open();
         using (var command = new MySqlCommand(query, connection))
         {
             using (var reader = command.ExecuteReader())
             {
                 //Iterate through the rows and add it to the combobox's items
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                         try
                         {
                             item.Label = reader.GetString(col);
                             rbControl.Items.Add(item);
                         }
                         catch (System.Data.SqlTypes.SqlNullValueException ex)
                         {
                             //item.Label = "None";
                         }
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public void ShowDropDown()
        {
            OnDropDownShowing(EventArgs.Empty);

            AssignHandlers();

            var dd = new RibbonDropDown(this, DropDownItems, Owner)
                         {
                             ShowSizingGrip = DropDownResizable
                         };
            dd.Closed += DropDown_Closed;
            dd.Show(Owner.PointToScreen(new Point(TextBoxBounds.Left, Bounds.Bottom)));
        }
Example #12
0
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public void ShowDropDown()
        {

            Console.WriteLine(" click item set text111");
            OnDropDownShowing(EventArgs.Empty);

            AssignHandlers();

            RibbonDropDown dd = new RibbonDropDown(this, DropDownItems, Owner);
            dd.ShowSizingGrip = DropDownResizable;
            dd.Closed += new EventHandler(DropDown_Closed);
            dd.Show(Owner.PointToScreen(new Point(TextBoxBounds.Left, Bounds.Bottom)));
        }
        //*************************************************************************
        //  Constructor: LayoutManagerForRibbonDropDown()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="LayoutManagerForRibbonDropDown" /> class.
        /// </summary>
        //*************************************************************************
        public LayoutManagerForRibbonDropDown()
        {
            m_oRibbonDropDown = null;

            AssertValid();
        }
        /// <summary>
        /// Shows the drop down items of the button, as if the dropdown part has been clicked
        /// </summary>
        public void ShowDropDown()
        {
            if (DropDownItems.Count == 0)
            {
                SetPressed(false);
                return;
            }

            IgnoreDeactivation();

            _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
            //_dropDown.FormClosed += new FormClosedEventHandler(dropDown_FormClosed);
            //_dropDown.StartPosition = FormStartPosition.Manual;
            _dropDown.ShowSizingGrip = true;
            Point location = Canvas.PointToScreen(new Point(Bounds.Left, Bounds.Top));
            

            SetDropDownVisible(true);
            _dropDown.Show(location);

        }
        public static void ListProjectsMail(Connection con, AuthenticationHeaderValue head)
        {
            //Lists for Items recieved from AzureDevOps
            ObservableCollection <ProjectVM> ProjectList = new ObservableCollection <ProjectVM>();
            //RibbonDropDownItem DropdownOrganisationsMenu = Globals.Ribbons.RibbonMenu.dropDownOrg.SelectedItem;
            RibbonDropDown DropdownOrganisationsMail = Globals.Ribbons.RibbonMail.dropDownOrg;

            //DropdownOrganisationsEmail.SelectedItem = DropdownOrganisationsMenu;

            //Get Data from AzureDevOps
            try
            {
                ProjectList = con.GetProjects(DropdownOrganisationsMail.SelectedItem.ToString(), head);
                Functions.enableBtn();
            }
            catch
            {
                MessageBox.Show("The Organisation is not existing", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            #region Project Dropdown Ribbons
            RibbonDropDown DropdownProjectsMail = Globals.Ribbons.RibbonMail.dropDownProj;

            foreach (var Project in ProjectList)
            {
                RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                item.Label = Project.name;
                DropdownProjectsMail.Items.Add(item);
            }
            #endregion

            //Lists for Items recieved from AzureDevOps
            ObservableCollection <BoardColumnVM> BoardColumnList  = new ObservableCollection <BoardColumnVM>();
            ObservableCollection <WorkItemVM>    WorkItemListMail = new ObservableCollection <WorkItemVM>();
            //Initalize Dropdowns in Ribbons
            RibbonDropDown DropdownWorkItemsMail = Globals.Ribbons.RibbonMail.dropDownType;
            RibbonDropDown DropdownBoardColumns  = Globals.Ribbons.RibbonMail.dropDownCol;
            try
            {
                WorkItemListMail = con.GetWorkItems(head, DropdownOrganisationsMail.SelectedItem.ToString(), DropdownProjectsMail.SelectedItem.ToString());
                BoardColumnList  = con.GetBoardColumns(DropdownOrganisationsMail.SelectedItem.ToString(), DropdownProjectsMail.SelectedItem.ToString());
                Functions.enableBtn();
            }
            catch
            {
                DropdownWorkItemsMail.Enabled = false;
                DropdownBoardColumns.Enabled  = false;
                Globals.Ribbons.RibbonMail.addItemBtn.Enabled = false;
                MessageBox.Show("The Organisation is not existing", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            #region Type, Columns RibbonDropdowns
            if (BoardColumnList != null)
            {
                //Fill Ribbon DropDowns with Data
                foreach (var Column in BoardColumnList)
                {
                    RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                    item.Label = Column.name;
                    DropdownBoardColumns.Items.Add(item);
                }
            }
            if (WorkItemListMail != null)
            {
                foreach (var WorkItem in WorkItemListMail)
                {
                    RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                    item.Label = WorkItem.name;
                    DropdownWorkItemsMail.Items.Add(item);
                }
            }
            #endregion
        }