Ejemplo n.º 1
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 + " не найден!");
         }
     }
 }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public void setButton(UserButton button)
        {
            this.button = button;
            if (button.image != null)
            {
                imgButtom.Image = button.image;
            }
            if (button.path != null)
            {
                tbPath.Text = button.path;
            }
            if (button.SetText != null)
            {
                tbName.Text = button.SetText;
            }
            btnVis.Visible = !button.isVisible;
            if (button.id == 95 || button.id == 100)
            {
                button1.Visible = false;
                btnVis.Visible  = false;
                button2.Visible = false;
            }
            if (button.id == 100)
            {
                panel3.Visible = true;
                Height         = 270;
                string file  = button.path;
                int    index = file.IndexOf(".exe ");
                if (index != -1)
                {
                    button.path = file.Remove(index + 4, file.Length - index - 4);
                    tbPath.Text = button.path;
                    string[] keys = file.Remove(0, index + 1 + 4).Split(' ');
                    foreach (string key in keys)
                    {
                        switch (key)
                        {
                        case "-POCKET":
                            cbPOCKET.Checked = true;
                            break;

                        case "-HIDETITLEBAR":
                            cbHIDETITLEBAR.Checked = true;
                            break;

                        case "-HIDESTATUSBAR":
                            cbHIDESTATUSBAR.Checked = true;
                            break;

                        case "-DISABLEAUTOLOGIN":
                            cbDISABLEAUTOLOGIN.Checked = true;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void setSetting(UserButton button)
 {
     id        = button.id;
     path      = button.path;
     name      = button.SetText;
     image     = button.image;
     isVisible = button.isVisible;
 }
Ejemplo n.º 5
0
 public UserButton loadButton(ProgramSetting setting, UserButton button)
 {
     button.isVisible = setting.isVisible;
     button.SetText   = setting.name;
     button.image     = setting.image;
     button.path      = setting.path;
     return(button);
 }
Ejemplo n.º 6
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 + " не найден!");
             }
         }
     }
 }
Ejemplo n.º 7
0
        public UserButton getButton()
        {
            UserButton button = new UserButton();

            button.id        = id;
            button.path      = path;
            button.image     = image;
            button.SetText   = name;
            button.isVisible = isVisible;
            return(button);
        }
Ejemplo n.º 8
0
        public void update()
        {
            pnContents.Controls.Clear();
            ToolTip hint = new ToolTip();
            int     i    = 0;

            foreach (ProgramSetting item in programsList)
            {
                if (item.id == 95)
                {
                    btnTeamViewer.path = item.path;
                    continue;
                }
                UserButton tmp = new UserButton();
                tmp        = item.getButton();
                tmp.Click += button_Click;
                if (isSetting || item.isVisible)
                {
                    tmp.Left = (i % 7) * 76 + 3;
                    tmp.Top  = i / 7 * 93 + 3;
                    pnContents.Controls.Add(tmp);
                    i++;
                }
            }
            if (isSetting)
            {
                Button add = new Button();
                add.Name   = "addBut";
                add.Width  = 51;
                add.Height = 51;
                add.Top    = 20;
                hint.SetToolTip(add, "Добавить кнопку");
                add.Left                      = (i % 7) * 76 + 14;
                add.Top                       = i / 7 * 93 + 14;
                add.BackgroundImage           = Properties.Resources.add_1078;
                add.BackgroundImageLayout     = ImageLayout.Stretch;
                add.FlatStyle                 = FlatStyle.Flat;
                add.FlatAppearance.BorderSize = 0;
                add.Click                    += addBut_Click;
                add.Visible                   = isSetting;
                pnContents.Controls.Add(add);
                Height = max + i / 7 * 93;
            }
            else
            {
                Height = min + (i - 1) / 7 * 93;
            }
        }
Ejemplo n.º 9
0
 public UserButton loadButton(ProgramSetting setting, UserButton button)
 {
     try
     {
         button.isVisible = setting.isVisible;
         button.SetText   = setting.name;
         button.image     = setting.image;
         button.path      = setting.path;
         return(button);
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
     return(null);
 }
Ejemplo n.º 10
0
 public void setButton(UserButton button)
 {
     this.button = button;
     if (button.image != null)
     {
         imgButtom.Image = button.image;
     }
     if (button.path != null)
     {
         tbPath.Text = button.path;
     }
     if (button.SetText != null)
     {
         tbName.Text = button.SetText;
     }
     btnVis.Visible = !button.isVisible;
     if (button.id == 95 || button.id == 100)
     {
         button1.Visible = false;
         btnVis.Visible  = false;
         button2.Visible = false;
     }
 }
Ejemplo n.º 11
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 + " не найден!");
         }
     }
 }
Ejemplo n.º 12
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);
     }
 }
Ejemplo n.º 13
0
 public void update()
 {
     try
     {
         pnContents.Controls.Clear();
         ToolTip hint = new ToolTip();
         int     i    = 0;
         foreach (ProgramSetting item in programsList)
         {
             if (item.id == 95)
             {
                 btnTeamViewer.path = item.path;
                 continue;
             }
             else
             if (item.id < 100)
             {
                 continue;
             }
             UserButton tmp = new UserButton();
             tmp        = item.getButton();
             tmp.Click += button_Click;
             if (isSetting || item.isVisible)
             {
                 tmp.Left = (i % 8) * 76 + 3;
                 tmp.Top  = i / 8 * 93 + 3;
                 pnContents.Controls.Add(tmp);
                 i++;
             }
         }
         if (isSetting)
         {
             Button add = new Button();
             add.Name   = "addBut";
             add.Width  = 51;
             add.Height = 51;
             add.Top    = 20;
             hint.SetToolTip(add, "Добавить кнопку");
             add.Left                      = (i % 8) * 76 + 14;
             add.Top                       = i / 8 * 93 + 14;
             add.BackgroundImage           = Properties.Resources.add_1078;
             add.BackgroundImageLayout     = ImageLayout.Stretch;
             add.FlatStyle                 = FlatStyle.Flat;
             add.FlatAppearance.BorderSize = 0;
             add.Click                    += addBut_Click;
             add.Visible                   = isSetting;
             pnContents.Controls.Add(add);
             Height              = max + i / 8 * 93;
             btnLogout.Enabled   = true;
             btnPowerOff.Enabled = true;
             btnRestart.Enabled  = true;
         }
         else
         {
             Height = min + (i - 1) / 8 * 93;
             setButtonEnable(btnLogout);
             setButtonEnable(btnPowerOff);
             setButtonEnable(btnRestart);
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }