コード例 #1
0
        void AppEdit()
        {
            var group_name = comboBox_Group.Text;

            if (listView_Apps.SelectedItems.Count > 0)
            {
                var item     = listView_Apps.SelectedItems[0];
                var app_name = item.Text;
                var app      = GetAppObject(group_name, app_name);
                var Form     = new AppEditorForm();
                Form.ConfigData = app;
                var result = Form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    app = Form.ConfigData;
                    //
                    // Add to UI
                    //
                    item.SubItems[0].Text = app.Name;
                    item.SubItems[1].Text = app.Target;
                    item.SubItems[2].Text = app.Args;
                }
            }
            else
            {
                MessageBox.Show("SelectedItems not found", "ERROR");
            }
        }
コード例 #2
0
        void AppAdd()
        {
            dynamic app        = new ExpandoObject();
            var     group_name = comboBox_Group.Text;

            if (listView_Apps.SelectedItems.Count > 0)
            {
                var item     = listView_Apps.SelectedItems[0];
                var app_name = item.Text;
                app = GetAppObject(group_name, app_name);
                app = DeepCopy(app);
            }

            var Form = new AppEditorForm();

            Form.ConfigData = app;
            var result = Form.ShowDialog();

            if (result == DialogResult.OK)
            {
                app = Form.ConfigData;
                var match_item = listView_Apps.FindItemWithText(app.Name);
                if (match_item == null) // Add if not found
                //
                // Add to UI
                //
                {
                    ListViewItem item = new ListViewItem(app.Name);
                    item.SubItems.Add(app.Target);
                    item.SubItems.Add(app.Args);
                    listView_Apps.Items.Add(item);
                    //
                    // Add to Config
                    //
                    string gname = comboBox_Group.Text;
                    object value;
                    bool   st;
                    var    gdict = (IDictionary <string, object>)ConfigData.Group;
                    st = gdict.TryGetValue(gname, out value);
                    List <dynamic> apps = (List <dynamic>)value;
                    apps.Add(app);
                }
                else
                {
                    MessageBox.Show("Data already exists", "ERROR");
                }
            }
        }
コード例 #3
0
        void LaunchApplication(dynamic app)
        {
            //
            // Set default data for leak fields of ConfigData
            //
            var form = new AppEditorForm();

            form.ConfigData = app;
            form.InitConfigData();
            app = form.ConfigData;
            //
            // Pre-Exec commands
            //
            if (app.PreExec != "")
            {
                ProcessStartInfo pre_exec = new ProcessStartInfo();
                pre_exec.FileName        = "cmd.exe";
                pre_exec.Arguments       = "/C " + app.PreExec;
                pre_exec.CreateNoWindow  = true;
                pre_exec.UseShellExecute = false;
                pre_exec.WindowStyle     = ProcessWindowStyle.Hidden;
                pre_exec.CreateNoWindow  = false;
                if (app.Folder != "")
                {
                    pre_exec.WorkingDirectory = app.Folder;
                }
                Process proc = Process.Start(pre_exec);
                proc.WaitForExit();
            }
            //
            // Launch Application
            //
            ProcessStartInfo start = new ProcessStartInfo();

            start.Arguments = app.Args;
            if (File.Exists((string)app.Target))
            {
                start.FileName = app.Target;
                if (app.Folder != "")
                {
                    start.WorkingDirectory = app.Folder;
                }
                switch (app.WindowMode)
                {
                case 0:
                    start.WindowStyle    = ProcessWindowStyle.Hidden;
                    start.CreateNoWindow = false;
                    break;

                case 1:
                    start.WindowStyle    = ProcessWindowStyle.Minimized;
                    start.CreateNoWindow = false;
                    break;

                case 2:
                    start.WindowStyle    = ProcessWindowStyle.Maximized;
                    start.CreateNoWindow = false;
                    break;

                default:
                    start.WindowStyle    = ProcessWindowStyle.Normal;
                    start.CreateNoWindow = true;
                    break;
                }

                Process proc = Process.Start(start);
                if (app.WaitMode == 0)
                {
                    try {
                        proc.WaitForInputIdle(); // Waiting App initialize done for TextFX.dll twice issue
                    } catch (Exception e) {
                        MessageBox.Show("Exception for WaitForInputIdle()\n Try use <don't wait>");
                    }
                }
            }
            else
            {
                MessageBox.Show("Error: Target not exists [" + app.Target + "]", "ERROR");
            }
        }