Exemplo n.º 1
0
        private void addBut_Click(object sender, EventArgs e)
        {
            UserButton button = new UserButton();

            button.TabIndex = 100;
            while (programsList.Find(x => x.id == button.TabIndex) != null)
            {
                button.TabIndex = button.TabIndex + 1;
            }
            SettingBut form = new SettingBut();

            form.setButton(button.TabIndex);
            if (form.ShowDialog() == DialogResult.OK)
            {
                UserButton tmp = form.getButtonSetting();
                tmp.Parent = pnContents;
                tmp.Top    = 0;
                tmp.Left   = (pnContents.Controls.Count - 3) * 75;
                (sender as Button).Left += 75;
                programsList.Add(form.getSetting());
                update();
            }
            else
            {
                Controls.Remove(button);
            }
        }
Exemplo n.º 2
0
 private void standartButt_Click(object sender, EventArgs e)
 {
     if (isSetting)
     {
         SettingBut form = new SettingBut();
         form.setButton(sender as UserButton);
         if (form.ShowDialog() == DialogResult.OK)
         {
             UserButton tmp = form.getButtonSetting();
             (sender as UserButton).image     = tmp.image;
             (sender as UserButton).path      = tmp.path;
             (sender as UserButton).isVisible = tmp.isVisible;
             (sender as UserButton).SetText   = tmp.SetText;
         }
     }
     else
     {
         try
         {
             Process.Start((sender as UserButton).path);
         }
         catch (Exception)
         {
             MessageBox.Show("Файл " + (sender as UserButton).path + " не найден!");
         }
     }
 }
Exemplo n.º 3
0
 private void button_Click(object sender, EventArgs e)
 {
     if (isSetting)
     {
         SettingBut form = new SettingBut();
         if (sender is UserButton)
         {
             form.setButton(sender as UserButton);
         }
         else
         {
             form.setButton(sender as ButtonApp);
         }
         DialogResult dr = form.ShowDialog();
         if (dr == DialogResult.Abort)
         {
             UserButton tmp = form.getButtonSetting();
             programsList.RemoveAll(x => x.id == tmp.id);
             update();
         }
         else
         if (dr == DialogResult.OK)
         {
             UserButton tmp = form.getButtonSetting();
             programsList.Find(x => x.id == tmp.id).image     = tmp.image;
             programsList.Find(x => x.id == tmp.id).path      = tmp.path;
             programsList.Find(x => x.id == tmp.id).isVisible = tmp.isVisible;
             programsList.Find(x => x.id == tmp.id).name      = tmp.SetText;
             update();
         }
     }
     else
     {
         string path = "";
         if (sender is UserButton)
         {
             path = (sender as UserButton).path;
         }
         else
         {
             path = (sender as ButtonApp).path;
         }
         try
         {
             Process.Start(path);
         }
         catch (Exception err)
         {
             if (err.Message != "The operation was canceled by the user")
             {
                 MessageBox.Show("Файл " + path + " не найден!");
             }
         }
     }
 }
Exemplo n.º 4
0
 private void standartButt_Click(object sender, EventArgs e)
 {
     if (isSetting)
     {
         SettingBut form = new SettingBut();
         form.setButton(sender as UserButton);
         if (form.ShowDialog() == DialogResult.OK)
         {
             UserButton tmp = form.getButtonSetting();
             (sender as UserButton).image     = tmp.image;
             (sender as UserButton).path      = tmp.path;
             (sender as UserButton).isVisible = tmp.isVisible;
             (sender as UserButton).SetText   = tmp.SetText;
         }
     }
     else
     {
         try
         {
             string file  = (sender as UserButton).path.Trim();
             int    index = file.IndexOf(".exe ");
             if (index != -1)
             {
                 Process.Start(file.Remove(index + 4, file.Length - index - 4), file.Remove(0, index + 1 + 4));
             }
             else
             {
                 Process.Start((sender as UserButton).path);
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Файл " + (sender as UserButton).path + " не найден!");
         }
     }
 }
Exemplo n.º 5
0
 private void button_Click(object sender, EventArgs e)
 {
     try
     {
         if (isSetting)
         {
             SettingBut form = new SettingBut();
             if (sender is UserButton)
             {
                 form.setButton(sender as UserButton);
             }
             else
             {
                 form.setButton(sender as ButtonApp);
             }
             DialogResult dr = form.ShowDialog();
             if (dr == DialogResult.Abort)
             {
                 UserButton tmp = form.getButtonSetting();
                 programsList.RemoveAll(x => x.id == tmp.id);
                 update();
             }
             else
             if (dr == DialogResult.OK)
             {
                 UserButton tmp = form.getButtonSetting();
                 programsList.Find(x => x.id == tmp.id).image     = tmp.image;
                 programsList.Find(x => x.id == tmp.id).path      = tmp.path;
                 programsList.Find(x => x.id == tmp.id).isVisible = tmp.isVisible;
                 if (tmp.id != 95)
                 {
                     programsList.Find(x => x.id == tmp.id).name = tmp.SetText;
                 }
                 update();
             }
         }
         else
         {
             string path = "";
             if (sender is UserButton)
             {
                 path = (sender as UserButton).path.Trim();
             }
             else
             {
                 path = (sender as ButtonApp).path.Trim();
             }
             try
             {
                 string file  = path;
                 int    index = file.IndexOf(".exe ");
                 if (index != -1)
                 {
                     Process.Start(file.Remove(index + 4, file.Length - index - 4), file.Remove(0, index + 1 + 4));
                 }
                 else
                 {
                     Process.Start(path);
                 }
             }
             catch (Exception err)
             {
                 if (err.Message != "The operation was canceled by the user")
                 {
                     MessageBox.Show("Файл " + path + " не найден!");
                 }
             }
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }