private void AddMyFun()
        {
            Action act = delegate()
            {
                if (this.flpMyFun.Controls.Count > 0)
                {
                    this.flpMyFun.Controls.Clear();
                }
                foreach (var mylove in mylovelis)
                {
                    if (!mylove.oper_type.Substring(2, 2).Equals("00"))
                    {
                        MyIconButton btn = new MyIconButton();
                        btn.Width                 = 100;
                        btn.Height                = 100;
                        btn.ContextMenuStrip      = this.cms;
                        btn.Text                  = Appsetting.oper_types[mylove.oper_type].type_name;
                        btn.Margin                = new Padding(5, 10, 0, 3);
                        btn.MoveColor             = Color.Red;
                        btn.BackgroundImage       = (Image)Properties.Resources.ResourceManager.GetObject("_" + mylove.oper_type);
                        btn.BackgroundImageLayout = ImageLayout.Center;
                        btn.MouseDown            += myIconButton_MouseDown;
                        btn.Click                += tsmiOperFnc_Click;
                        this.flpMyFun.Controls.Add(btn);
                    }
                }
            };

            this.Invoke(act);
        }
Exemple #2
0
    public MyApplication()
    {
        try
        {
            // Create the button with the default icon.
            myIconButton = new MyIconButton(new Icon(Application.StartupPath + "\\Default.ico"));
        }
        catch (Exception ex)
        {
            // If the default icon does not exist, create the button without an icon.
            myIconButton = new MyIconButton();
            Debug.WriteLine(ex.ToString());
        }
        finally
        {
            stdButton = new Button();

            // Add the Click event handlers.
            myIconButton.Click += new EventHandler(this.myIconButton_Click);
            stdButton.Click    += new EventHandler(this.stdButton_Click);

            // Set the location, text and width of the standard button.
            stdButton.Location = new Point(myIconButton.Location.X, myIconButton.Location.Y + myIconButton.Height + 20);
            stdButton.Text     = "Change Icon";
            stdButton.Width    = 100;

            // Add the buttons to the Form.
            this.Controls.Add(stdButton);
            this.Controls.Add(myIconButton);
        }
    }
 private void myIconButton_MouseDown(object sender, MouseEventArgs e)
 {
     if (sender is MyIconButton)
     {
         MyIconButton btn = sender as MyIconButton;
         oper_type = btn.Text;
     }
     else if (sender is Label)
     {
         Label lbl = sender as Label;
         oper_type = lbl.Text.Trim();
     }
 }