コード例 #1
0
        private void OnAddButton(object sender, System.EventArgs e)
        {
            m_nAddedButtons++;
            SideBarButton btn = new SideBarButton();

            btn.ImageIndex = m_nAddedButtons % 5;
            btn.Text       = string.Format("Button {0}", m_nAddedButtons);
            switch (m_nAddedButtons % 5)
            {
            case 0:
                btn.ContextMenu = contextMenu1;
                btn.Click      += new System.EventHandler(OnMethod1);
                break;

            case 1:
                btn.ContextMenu = contextMenu2;
                btn.Click      += new System.EventHandler(OnMethod2);
                break;

            case 2:
                btn.ContextMenu = contextMenu3;
                btn.Click      += new System.EventHandler(OnMethod3);
                break;

            default:
                btn.Click += new System.EventHandler(OnMethod3);
                break;
            }

            sideBarTab2.Buttons.Add(btn);
            sideBar1.Invalidate();
        }
コード例 #2
0
        public Form2(ImageList largeImages, ImageList smallImages)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set properties for sidebar
            m_sideBar.ImageListLarge = largeImages;
            m_sideBar.ImageListSmall = smallImages;
            m_sideBar.Persist        = false;

            // Create first side bar tab - each button has own click handler method
            SideBarTab tab = new SideBarTab();

            m_sideBar.Tabs.Add(tab);
            tab.Title = "Tab";

            // First button on first tab
            m_btn1            = new SideBarButton();
            m_btn1.Text       = "First button";
            m_btn1.Click     += new EventHandler(OnButton1Click);
            m_btn1.ImageIndex = 1;
            tab.Buttons.Add(m_btn1);

            // Second button on first tab
            m_btn2            = new SideBarButton();
            m_btn2.Text       = "Second button";
            m_btn2.Click     += new EventHandler(OnButton2Click);
            m_btn2.ImageIndex = 2;
            tab.Buttons.Add(m_btn2);

            // Second side bar tab - one click handler method for all buttons
            // This tab supports multiple selections with an off button
            tab = new SideBarTab();
            m_sideBar.Tabs.Add(tab);
            tab.Title = "Other tab";
            tab.MultipleSelections   = true;
            tab.FirstButtonExclusive = true;
            tab.ButtonClickEvent    += new EventHandler(OnGenericButtonClick);

            // First button on second tab
            m_btn3            = new SideBarButton();
            m_btn3.Text       = "Off";
            m_btn3.ImageIndex = 3;
            tab.Buttons.Add(m_btn3);

            // Second button on second tab
            m_btn4            = new SideBarButton();
            m_btn4.Text       = "Button 2";
            m_btn4.ImageIndex = 4;
            tab.Buttons.Add(m_btn4);

            // Third button on second tab
            m_btn5            = new SideBarButton();
            m_btn5.Text       = "Button 3";
            m_btn5.ImageIndex = 5;
            tab.Buttons.Add(m_btn5);
        }
コード例 #3
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// When a sidebar button is clicked update the info bar text and info. button for
        /// the new current sidebar button.
        /// </summary>
        ///
        /// <param name='sender'>The SideBar tab button that was clicked.</param>
        /// <param name='e'>The event that caused this function to be called.</param>
        /// -----------------------------------------------------------------------------------
        private void tabButton_Click(object sender, System.EventArgs e)
        {
            SideBarButton sideBarButton = (SideBarButton)sender;
            SideBarTab    sideBarTab    = (SideBarTab)sideBarButton.Parent.Parent;

            // Update the info bar caption
            informationBar.InfoBarLabel.Text = sideBarTab.Title + ' ' + sideBarButton.Text;

            // find the info bar button associated with the sidebar tab and set the
            // button's icon to the sidebar button's icon.
            foreach (InformationBarButton button in informationBar.Buttons)
            {
                // Update the info bar button's image
                if ((SideBarTab)button.Tag == sideBarTab)
                {
                    button.ImageIndex = sideBarButton.ImageIndex;
                }
            }
        }
コード例 #4
0
        private void AddTapGestureToSideBarButton()
        {
            var tapGesture = new UITapGestureRecognizer(TapSideBarButton);

            SideBarButton.AddGestureRecognizer(tapGesture);
        }