Exemple #1
0
        Button newButton(XmlNode xelem, EventHandler evHdlr)
        {
            actionBtn actBtn;

            actBtn                         = new actionBtn();
            actBtn.AutoSize                = true;
            actBtn.BackColor               = (xelem.Attributes["bColor"] != null? Color.FromName(xelem.Attributes["bColor"].Value) : Color.LightGray);
            actBtn.FlatStyle               = System.Windows.Forms.FlatStyle.Flat;
            actBtn.Font                    = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            actBtn.ForeColor               = (xelem.Attributes["fColor"] != null ? Color.FromName(xelem.Attributes["fColor"].Value) : Color.Black);
            actBtn.Location                = new System.Drawing.Point(6, 6);
            actBtn.Name                    = xelem.Attributes["title"].Value;
            actBtn.MaximumSize             = new System.Drawing.Size(150, 25);
            actBtn.MinimumSize             = new System.Drawing.Size(150, 25);
            actBtn.TabIndex                = 0;
            actBtn.Text                    = xelem.Attributes["text"].Value;
            actBtn.UseVisualStyleBackColor = false;
            actBtn.Click                  += new System.EventHandler(evHdlr);
            actBtn.Command                 = xelem.Attributes["cmd"].Value;
            actBtn.args                    = (xelem.Attributes["args"] != null ? xelem.Attributes["args"].Value : "");
            return(actBtn);
        }
Exemple #2
0
        private void buttonClick(object sender, EventArgs e)
        {
            actionBtn x = ((actionBtn)sender);

            if (c == null)
            {
                if (x.process == null)
                {
                    System.Diagnostics.ProcessStartInfo pS = new System.Diagnostics.ProcessStartInfo(x.Command, x.args);
                    pS.UseShellExecute = true;
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo = pS;
                    x.process      = proc;
                }
                try
                {
                    if (x.process.StartTime == null)
                    {
                        x.process.Start();
                        x.Text = "> " + x.Text.Replace(">", "").Replace("<", "") + " <";
                    }
                    else
                    {
                        x.process.Kill();
                        x.Text = x.Text.Replace(">", "").Replace("<", "");
                    }
                }
                catch (Exception ex)
                {
                    x.process.Start();
                    x.Text = "> " + x.Text.Replace(">", "").Replace("<", "") + " <";
                }
            }
            else
            {
                c.RunAs(x.Command, x.args);
            }
        }