FolderWidget/frmMain.cs
/// <summary>
/// initilize a button icon, events properties and context menu
/// </summary>
initilize a button icon, events properties and context menu
initilize a button icon events properties and context menu
private Button MakeDynamicButton(DataRow dr)
        {
            Button btn = new Button();
            #region Button Properties
            btn.Tag = dr["Path"].ToString();
            btn.FlatStyle = FlatStyle.Flat;
            btn.FlatAppearance.BorderSize = 0;
            btn.Size = new Size(41, 41);
            btn.Margin = new Padding(3);
            btn.TabStop = false;
            #endregion
            #region Button Events
            btn.MouseHover += Btn_MouseHover;
            btn.MouseEnter += Btn_MouseHover;
            btn.MouseLeave += Btn_MouseLeave;
            btn.Click += Btn_Click;
            #endregion
            #region Context Menu for Button
            ContextMenu cm = new ContextMenu();
            cm.MenuItems.Add("Change Icon");
            cm.MenuItems[0].Click += ChangeIcon_Click;
            cm.MenuItems.Add("Delete");
            cm.MenuItems[1].Click += DeleteItem_Click;
            cm.MenuItems.Add("Run as Different User");
            cm.MenuItems[2].Click += StartProcessAsDifferentUser;
            btn.ContextMenu = cm;
            #endregion
            #region Button Image and ToolTip
            string strForToolTip = string.Empty;
            btn.BackgroundImage = GetIcon(dr);
            btn.BackgroundImageLayout = ImageLayout.Stretch;
            btn.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); 
            ToolTip tp = new ToolTip();
            foreach (var item in dr["Path"].ToString().Split(','))
            {
                strForToolTip = strForToolTip + "• " + item.ToString() + Environment.NewLine;
            }
            tp.SetToolTip(btn, string.IsNullOrEmpty(strForToolTip) ? "• " + dr["Path"].ToString() : strForToolTip);
            #endregion
            return btn;
        }
private Button MakeDynamicButton ( DataRow dr ) { Button btn = new Button ( ) ; region  Button Properties btn . Tag = dr [ " " ] . ToString ( ) ; btn . FlatStyle = FlatStyle . Flat ; btn . FlatAppearance . BorderSize = 0 ; btn . Size = new Size ( 41 , 41 ) ; btn . Margin = new Padding ( 3 ) ; btn . TabStop = false ; endregion region  Button Events btn . MouseHover += Btn_MouseHover ; btn . MouseEnter += Btn_MouseHover ; btn . MouseLeave += Btn_MouseLeave ; btn . Click += Btn_Click ; endregion region  Context Menu for Button ContextMenu cm = new ContextMenu ( ) ; cm . MenuItems . Add ( " " ) ; cm . MenuItems [ 0 ] . Click += ChangeIcon_Click ; cm . MenuItems . Add ( " " ) ; cm . MenuItems [ 1 ] . Click += DeleteItem_Click ; cm . MenuItems . Add ( " " ) ; cm . MenuItems [ 2 ] . Click += StartProcessAsDifferentUser ; btn . ContextMenu = cm ; endregion region  Button Image and ToolTip string strForToolTip = string . Empty ; btn . BackgroundImage = GetIcon ( dr ) ; btn . BackgroundImageLayout = ImageLayout . Stretch ; btn . FlatAppearance . BorderColor = Color . FromArgb ( 0 , 255 , 255 , 255 ) ; ToolTip tp = new ToolTip ( ) ; foreach ( var item in dr [ " " ] . ToString ( ) . Split ( ' ' ) ) { strForToolTip = strForToolTip + " + i em.T o String() + E vironment.N e wLine; } tp . SetToolTip ( btn , string . IsNullOrEmpty ( strForToolTip ) ? " + d [" P a . T o String() : s rForToolTip); endregion return btn ; }
initilize a button icon, events properties and context menu
initilize a button icon events properties and context menu
//transparent
dr
DataRow