Esempio n. 1
0
        public Sidebar(T _Parent, Panel _Panel, ListView _ListView, ImageList _imagelist, List <SidebarItem> _sitems)
        {
            parent    = _Parent;
            imglist   = _imagelist;
            sidebar   = _Panel;
            listView1 = _ListView;
            sitems    = _sitems;
            int           tabcnt  = 0;
            List <Button> temp_li = new List <Button>();

            IteratorSidebarItem(temp_li, sitems, ref tabcnt);
            for (int i = temp_li.Count - 1; i > -1; i--)
            {
                temp_li[i].Dock = DockStyle.Top;
                sidebar.Controls.Add(temp_li[i]);
            }
            listView1.SelectedIndexChanged += (sender, e) =>
            {
                if (listView1.SelectedIndices.Count > 0)
                {
                    SidebarItem        si  = null;
                    SidebarItem_Struct sis = IteratorSelectedSidebarItem_Struct(listView1.SelectedItems[0].Text, sitems, ref si);
                    if (sis.icontab > -1)
                    {
                        Type t = si.atype;
                        System.Reflection.MethodInfo mi = t.GetMethod(sis.fun);
                        if (mi != null)
                        {
                            object[] args = new object[2];
                            args[0] = this;
                            args[1] = new EventArgs();
                            mi.Invoke(si.t, args);
                        }
                        else
                        {
                            MessageBox.Show("未登記!");
                        }
                    }
                }
            };
        }
Esempio n. 2
0
 public SidebarItem_Struct IteratorSelectedSidebarItem_Struct(String SelectedItemText, List <SidebarItem> sitems, ref SidebarItem curr_SI)
 {
     foreach (SidebarItem si in sitems)
     {
         if (si.subitems != null)
         {
             foreach (SidebarItem_Struct sis in si.subitems)
             {
                 if (sis.title.Equals(SelectedItemText))
                 {
                     curr_SI = si;
                     return(sis);   //Type t = Type.GetType(si.typestring);
                 }
             }
         }
         if (si.next != null)
         {
             SidebarItem_Struct ret = IteratorSelectedSidebarItem_Struct(SelectedItemText, si.next, ref curr_SI);
             if (ret.icontab > -1)
             {
                 return(ret);
             }
         }
     }
     return(new SidebarItem_Struct(null, null, -1));
 }