Exemple #1
0
        private void Btn_AddExecutable_Click(object sender, EventArgs e)
        {
            ChooseExecutables executableChooser = new ChooseExecutables(Txt_ProgramLocation.Text, Executables);

            if (executableChooser.ShowDialog() == DialogResult.Yes)
            {
                ExecutableData executable = executableChooser.NewExecutable;
                Executables.Add(executable);

                Panel newPanel = new Panel
                {
                    Dock   = DockStyle.Top,
                    Height = 25
                };
                Label shortcutLabel = new Label
                {
                    Text         = executable.ShortcutName,
                    TextAlign    = ContentAlignment.MiddleLeft,
                    Dock         = DockStyle.Left,
                    Width        = 175,
                    AutoEllipsis = true
                };
                Label pathLabel = new Label
                {
                    Text         = executable.ExecutablePath,
                    TextAlign    = ContentAlignment.MiddleLeft,
                    Dock         = DockStyle.Fill,
                    AutoEllipsis = true
                };
                CheckBox onDesktop = new CheckBox
                {
                    Enabled = false,
                    Checked = executable.OnDesktop,
                    Dock    = DockStyle.Right,
                    Width   = 75
                };
                Button changeButton = new Button
                {
                    Text  = "Change",
                    Name  = Pnl_Executables.Controls.Count.ToString(),
                    Dock  = DockStyle.Right,
                    Width = 100
                };
                changeButton.Click += ChangeButton_Click;

                newPanel.Controls.Add(pathLabel);
                newPanel.Controls.Add(shortcutLabel);
                newPanel.Controls.Add(onDesktop);
                newPanel.Controls.Add(changeButton);

                Pnl_Executables.Controls.Insert(0, newPanel);
            }
            ChangeInstallText();
        }
Exemple #2
0
        private void ChangeButton_Click(object sender, EventArgs e)
        {
            Button            changeButton      = (Button)sender;
            int               index             = Convert.ToInt32(changeButton.Name);
            int               panelIndex        = Pnl_Executables.Controls.Count - index - 1;
            ChooseExecutables executableChooser = new ChooseExecutables(Txt_ProgramLocation.Text, Executables, Executables[index]);

            executableChooser.ShowDialog();
            if (executableChooser.DialogResult == DialogResult.Yes)
            {
                ExecutableData executable = executableChooser.NewExecutable;
                Executables[index] = executable;
                Pnl_Executables.Controls[panelIndex].Controls[1].Text = executable.ShortcutName;
                Pnl_Executables.Controls[panelIndex].Controls[0].Text = executable.ExecutablePath;
                ((CheckBox)Pnl_Executables.Controls[panelIndex].Controls[2]).Checked = executable.OnDesktop;
            }
            else if (executableChooser.DialogResult == DialogResult.No)
            {
                Executables.RemoveAt(index);
                Pnl_Executables.Controls.RemoveAt(panelIndex);
            }
        }