Esempio n. 1
0
 public void setText(String textset)
 {
     if (textset.Equals("clear")) //If the user hits the clear button
     {
         txtResult.Text = "";     //Clear the text and reset the boolean variables.
         isDone         = false;
         isSecond       = false;
         isDecimal      = false;
     }
     else
     {
         if (isSecond)                 //Determine if the number being entered is the begining of the second number. If it is:
         {
             txtResult.Text = textset; //Start the text over and set the first # to what the user enters
             isSecond       = false;   //So Calculator knows to continue the # rather than making a new one.
             isDecimal      = false;
         }
         else
         {
             if (isDone) //isDone lets the program know that the user just hit "=" and if they press another # to start a new number.
             {
                 txtResult.Text = textset;
                 isDone         = false; //Set isDone to false so that the number just started is added on to and a new # is not started.
             }
             else
             {
                 txtResult.Text += textset; //Simply add on to the existing #.
             }
         }
     }
     btnEquals.Select(); //Set the focus back to the "=" button.
 }
Esempio n. 2
0
        private void AllowClose(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (tbflname.ReadOnly)
            {
                if ((lblist.SelectedItems.Count == 0) && (ok))
                {
                    MessageBox.Show("You have to select at Least one Package");
                    btadd.Select();
                    e.Cancel = true;
                }
            }
            else
            {
                if ((tbflname.Text.Trim() == "") && (ok))
                {
                    MessageBox.Show("You have to specify a Filename for the Sims2Community Pack File.");
                    this.tbflname.Select();
                    e.Cancel = true;
                }

                if ((lblist.Items.Count == 0) && (ok))
                {
                    MessageBox.Show("You have to add at least one Package.");
                    btadd.Select();
                    e.Cancel = true;
                }
            }
        }
Esempio n. 3
0
        private void editEngineconf_Click(object sender, EventArgs e)
        {
            // Neues Fenster öffnen
            Form newWindow = new Form();
            newWindow.Size = new System.Drawing.Size(800, 600);

            // Property Grid erstellen
            PropertyGrid newWin = new PropertyGrid();
            newWin.Top = 25;
            newWin.Size = new System.Drawing.Size(800, 600);

            Button saveButton = new Button();
            saveButton.Select();
            saveButton.Text = "Speichern";
            saveButton.Click += new System.EventHandler(saveButton_Click);

            // Füge Property Grid in neues Fenster ein
            newWindow.Controls.Add(newWin);
            newWindow.Controls.Add(saveButton);

            // Wir lesen zuerst die Config Datei ein
            // Dateipfad
            string path = "../Common/engine.conf";

            // Alles in einen string packen
            string text = File.ReadAllText(path);

            dynamic stuff = JsonConvert.DeserializeObject(text);

            Settings conf = new Settings(stuff);

            newWin.SelectedObject = conf;

            newWindow.Show();
        }
Esempio n. 4
0
        public MessageForm(string caption, string message, string[] buttons, Icon icon)
        {
            InitializeComponent();

            int width = icon.Width;
            if (icon != null)
            {
                image_box.Image = (Image)icon.ToBitmap();
                int w = image_box.Image.Width - width;
                if (w > 0)
                {
                    this.Width += w;
                    this.message.Left += w;
                }
            }

            this.Text = caption;
            this.message.Text = message;

            for (int i = buttons.Length - 1; i >= 0; i--)
            {
                Button b = new Button();
                b.Tag = i;
                b.Text = buttons[i];
                b.Click += b_Click;
                flowLayoutPanel1.Controls.Add(b);
                if (i == 0)
                    b.Select();
            }
        }
Esempio n. 5
0
    // This routine handles the Form Load event. It calls another routine to create the
    // original XML data document, reads in the XML, displays it in the large TextBox,
    // and then calls a function to generate an MD5 hash digest to display in the upper
    // left TextBox.

    private void frmMain_Load(object sender, System.EventArgs e)
    {
        // Create the XML data document simulating the original products list
        // held by the Northwind Company.

        CreateOriginalProductsList();

        // Open the XML data document and convert to a string. This simulates the
        // the product listing being transferred over the wire to a client.

        StreamReader sr = new StreamReader(@"..\products.xml");

        strOriginalXML = sr.ReadToEnd();
        sr.Close();

        // Display the "transmitted" XML and the hash digest that is used for
        // authenticating the transmitted XML. This digest is generated from the
        // contents of the original document, not the XML displayed in the
        // TextBox.

        txtXML.Text            = strOriginalXML;
        txtHashOriginal.Text   = GenerateHashDigest(strOriginalXML);
        txtHashForCompare.Text = COMPARE_INSTRUCTIONS;

        // Call Select() to put focus on the "Compare!" button and prevent the XML
        // in the TextBox from being automatically highlighted.

        btnCompare.Select();

        // This is used to prevent the code in the CheckedChanged event handler from
        // running prior to the Form being loaded.

        FormHasLoaded = true;
    }
Esempio n. 6
0
    // This routine handles the Form's Load event, setting up the sample.

    private void frmMain_Load(object sender, System.EventArgs e)
    {
        // Set the default crypto type.

        crpSample = new SampleCrypto("Rijndael");

        // Set the path to save the key file to the Solution root folder by stripping

        // "bin" from the current directory.

        string strCurrentDirectory = Environment.CurrentDirectory.Substring(
            Environment.CurrentDirectory.Length - 2);

        // Initialize paths for both types of key files.

        strRijndaelSaltIVFile  = strCurrentDirectory + "RijndaelSaltIV.dat";
        strTripleDESSaltIVFile = strCurrentDirectory + "TripleDESSaltIV.dat";

        // Set the current key file path to the key for default crypto type.

        strCurrentKeyFile = strRijndaelSaltIVFile;

        // Call Select() to put focus on the "Encrypt" button and prevent the text in
        // the TextBox from being automatically highlighted.

        btnEncrypt.Select();
        FormHasLoaded = true;
    }
Esempio n. 7
0
 private void txtAddress_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (GoButtonPressed != null)
         {
             GoButtonPressed(sender, e);
         }
         btnGo.Select();
     }
 }
        public void SetActive(string workStationName)
        {
            SetInactiveLine();

            _currActiveWorkStation = _HH02_WSTs.Find(c => (c.Name == workStationName.Trim()));

            if (_currActiveWorkStation != null)
            {
                _currActiveWorkStation.BackColor = _activeColor;
                _currActiveWorkStation.Select();
                _blinkingTime = 10;
                _tmr.Start();
            }
        }
        protected void valePromocion_BajarControl(object sender, EventArgs e)
        {
            int index = _listaVales.IndexOf((ValePromocional)sender);

            index += 1;
            if (index <= _listaVales.Count - 1)
            {
                ((ValePromocional)_listaVales[index]).Select();
            }
            else
            {
                btnAceptar.Select();
            }
        }
Esempio n. 10
0
        public GotoForm(CameraManager cameraManager)
        {
            m_cameraManager = cameraManager;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            waypointTypeComboBox.Items.Add("user waypoint");
            waypointTypeComboBox.Items.Add("geocache");
            waypointTypeComboBox.Items.Add("geocache found");
            waypointTypeComboBox.SelectedIndex = 0;

            moveCameraCheckBox.Checked = true;

            setCoordTextBoxes();

            goButton.Select();
            goButton.Focus();
            Project.setDlgIcon(this);
        }
Esempio n. 11
0
        public MessageForm(string caption, Icon icon, string message, string[] buttons, int default_button, Form owner, bool button_auto_size = false)
        {
            InitializeComponent();

            this.MaximizeBox = true;

            Owner = owner;

            int width = icon.Width;
            if (icon != null)
            {
                image_box.Image = (Image)icon.ToBitmap();
                int w = image_box.Image.Width - width;
                if (w > 0)
                {
                    this.Width += w;
                    this.message.Left += w;
                }
            }

            this.Text = caption;
            this.message.Text = message;

            for (int i = buttons.Length - 1; i >= 0; i--)
            {
                Button b = new Button();
                b.Tag = i;
                b.AutoSize = button_auto_size;
                b.Text = buttons[i];
                b.Click += b_Click;
                flowLayoutPanel1.Controls.Add(b);
                if (i == default_button)
                    b.Select();
            }

            //Size s = this.message.GetPreferredSize(new Size(Screen.PrimaryScreen.WorkingArea.Width * 3 / 4, Screen.PrimaryScreen.WorkingArea.Height * 3 / 4));
            //this.Width = this.Width + s.Width - this.message.Width;
            //this.Height = this.Height + s.Height - this.message.Height;
        }         
Esempio n. 12
0
        private void CreateControls(DataTable dtPivot, BrowserState tag)
        {
            tag.Panel.Controls.Clear();

            switch (tag.Mode)
            {
                case BrowseMode.Media:
                    flpMediaTop.Controls.Clear();
                    switch (tag.Level)
                    {
                        case 1:
                            scMedia.SplitterDistance = 1;

                            if (tag.Panel.Controls.Count > 0)
                                tag.Panel.Controls[0].Select();

                            break;
                        case 2:
                            scMedia.SplitterDistance = 100;

                            Button btnBack = new Button();
                            btnBack.Width = flpMediaTop.Width / 8 - 10;
                            btnBack.Text = "Back";
                            btnBack.Height = flpMediaTop.Height - 10;
                            btnBack.Click += new EventHandler(btnBack_Click);
                            btnBack.Tag = BrowseMode.Media;
                            btnBack.Name = BUTTON_BACK;
                            btnBack.GotFocus += new EventHandler(b_GotFocus);
                            btnBack.LostFocus += new EventHandler(b_LostFocus); 
                            flpMediaTop.Controls.Add(btnBack);
                            break;
                    }
                    break;
                case BrowseMode.Recordings:
                    flpRecordingTop.Controls.Clear();
                    switch (tag.Level)
                    {
                        case 1:
                            scRecording.SplitterDistance = 1;

                            if (tag.Panel.Controls.Count > 0)
                                tag.Panel.Controls[0].Select();

                            break;
                        case 2:
                            scRecording.SplitterDistance = 100;

                            Button btnBack = new Button();
                            btnBack.Width = flpRecordingTop.Width / 8 - 10;
                            btnBack.Text = "Back";
                            btnBack.Height = flpRecordingTop.Height - 10;
                            btnBack.Click += new EventHandler(btnBack_Click);
                            btnBack.ForeColor = System.Drawing.Color.Black;
                            btnBack.Tag = BrowseMode.Recordings;
                            btnBack.Name = BUTTON_BACK;
                            btnBack.GotFocus += new EventHandler(b_GotFocus);
                            btnBack.LostFocus += new EventHandler(b_LostFocus); 
                            flpRecordingTop.Controls.Add(btnBack);

                            Label lblTitle = new Label();
                            lblTitle.Text = EscapeControlText(tag.Value);
                            lblTitle.Width = flpRecordingTop.Width / 2 - 10;
                            lblTitle.Height = flpRecordingTop.Height - 10;
                            lblTitle.TextAlign = ContentAlignment.MiddleCenter;
                            lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                            flpRecordingTop.Controls.Add(lblTitle);

                            break;
                    }
                    break;
            }

            for (int i = 0; i < dtPivot.Rows.Count; i++)
            {
                DataRow dr = dtPivot.Rows[i];
                BrowserState nBs = new BrowserState(tag.Sort, tag.Filter, tag.Level, tag.Mode, tag.Panel);


                StringBuilder sbText = new StringBuilder();
                Control b = null;

                switch (tag.Mode)
                {
                    case BrowseMode.Recordings:
                        b = new Button();
                        switch (tag.Level)
                        {
                            case 1:
                                sbText.AppendFormat("{0} - ", dr["title"]);
                                nBs.Value = dr["title"].ToString();
                                b.Size = new Size(tag.Panel.Width / 4 - 10, mfOwner.ps.MBButtonHeight);
                                break;
                            case 2:
                                if (dtPivot.Columns.Contains("episode") && !string.IsNullOrEmpty(dr["episode"].ToString()))
                                    sbText.AppendFormat("{0} - ", dr["episode"]);
                                if (dtPivot.Columns.Contains("description") && !string.IsNullOrEmpty(dr["description"].ToString()))
                                    sbText.AppendFormat("{0} - ", dr["description"]);
                                if (sbText.Length == 0)
                                {
                                    sbText.AppendFormat("{0} - ", dr["title"]);
                                    DataRow[] drs = data.Data.Tables["show"].Select(string.Format("epgId = '{0}'", dr["epgId"]));

                                    if (drs.Length > 0)
                                    {
                                        DataRow[] sa = drs[0].GetChildRows("show_airing");
                                        if (sa.Length > 0)
                                        {
                                            sbText.AppendFormat("{0} - ", sa[0]["startTime"]);
                                        }
                                    }
                                }
                                nBs.Filter = "epgId";
                                nBs.Value = dr["epgId"].ToString();
                                b.Size = new Size(tag.Panel.Width / 2 - 10, mfOwner.ps.MBButtonHeight);
                                break;
                        }
                        b.Click += new EventHandler(b_Click);
                        b.GotFocus += new EventHandler(b_GotFocus);
                        b.LostFocus += new EventHandler(b_LostFocus);  
                        break;
                    case BrowseMode.Media:
                        switch (tag.Level)
                        {
                            case 1:
                                b = new Button();

                                sbText.AppendFormat("{0} - ", dr["episode"]);
                                nBs.Value = dr["episode"].ToString();
                                b.Size = new Size(tag.Panel.Width / 4 - 10, mfOwner.ps.MBButtonHeight);
                                b.Click += new EventHandler(b_Click);
                                break;
                            case 2:
                                nBs.Filter = "epgId";
                                nBs.Value = dr["epgId"].ToString();

                                Button btnPlay = new Button();
                                btnPlay.Width = flpMediaTop.Width / 8 - 10;
                                btnPlay.Text = "Watch";
                                btnPlay.Click += new EventHandler(b_Click);
                                btnPlay.Height = flpMediaTop.Height - 10;
                                btnPlay.Tag = nBs;
                                btnPlay.Name = "btnPlay";
                                btnPlay.GotFocus += new EventHandler(b_GotFocus);
                                btnPlay.LostFocus += new EventHandler(b_LostFocus); 
                                flpMediaTop.Controls.Add(btnPlay);
                                btnPlay.Select();

                                Label lblTitle = new Label();
                                lblTitle.Text = EscapeControlText(tag.Value);
                                lblTitle.Width = flpMediaTop.Width / 2 - 10;
                                lblTitle.Height = flpMediaTop.Height - 10;
                                lblTitle.TextAlign = ContentAlignment.MiddleCenter;

                                lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                flpMediaTop.Controls.Add(lblTitle);

                                try
                                {
                                    List<string> fPath = GetSegmentValue(nBs.Filter, nBs.Value, "filePath");
                                    if (fPath.Count > 0)
                                    {
                                        string imgPath = Regex.Replace(mfOwner.ps.SageWebserver, "/sage/home", string.Format(@"/sage/MediaFileThumbnail?FileName={0}", fPath[0]), RegexOptions.IgnoreCase);
                                        byte[] imgBytes = DownloadFile(imgPath);

                                        if (imgBytes != null && imgBytes.Length > 0)
                                        {
                                            PictureBox pb = new PictureBox();
                                            //pb.ImageLocation = imgPath;
                                            //pb.Height = flpMediaTop.Height - 10;
                                            using (MemoryStream ms = new MemoryStream(imgBytes))
                                            {
                                                //using (Bitmap bmp = new Bitmap(ms))
                                                //{
                                                Bitmap bmp = new Bitmap(ms);
                                                pb.Image = bmp;
                                                pb.Height = bmp.Height;
                                                pb.Width = bmp.Width;
                                                //b.Name = string.Format("{0}_{1}", tag.Panel.Name, tag.Panel.Controls.Count);
                                                tag.Panel.Controls.Add(pb);
                                                //}
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    FileLogger.Log(string.Format("Error: {0}", ex.Message));
                                }

                                b = new Label();

                                if (dtPivot.Columns.Contains("episode") && !string.IsNullOrEmpty(dr["episode"].ToString()))
                                    sbText.AppendFormat("{0} - ", dr["episode"]);
                                if (dtPivot.Columns.Contains("description") && !string.IsNullOrEmpty(dr["description"].ToString()))
                                    sbText.AppendFormat("{0} - ", dr["description"].ToString());

                                b.Size = new Size(tag.Panel.Width - 50, tag.Panel.Height - 20);
                                break;
                        }
                        break;
                }

                if (sbText.Length > 0)
                    b.Text = EscapeControlText(sbText.ToString().Substring(0, sbText.Length - 3));
                b.Tag = nBs;

                b.ForeColor = SystemColors.ControlText;
                b.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                b.Name = string.Format("{0}_{1}", tag.Panel.Name, tag.Panel.Controls.Count);
                b.GotFocus += new EventHandler(b_GotFocus);
                b.LostFocus += new EventHandler(b_LostFocus);        
                tag.Panel.Controls.Add(b);
            }

            switch (tag.Mode)
            {
                case BrowseMode.Media:
                    this.ActiveControl = scMedia;
                    switch (tag.Level)
                    {
                        case 1:
                            if (tag.Panel.Controls.Count > 0)
                            {
                                tag.Panel.Controls[0].Select();
                            }
                            break;
                        case 2:

                            break;
                    }
                    
                    break;
                case BrowseMode.Recordings:
                    this.ActiveControl = scRecording;
                    scRecording.Select();
                    tag.Panel.Focus();
                    //switch (tag.Level)
                    //{
                    //    case 1:
                            if (tag.Panel.Controls.Count > 0)
                                tag.Panel.Controls[0].Select();

                    //        break;
                    //    case 2:

                    //        break;
                    //}
                    
                    break;
            }
            //this.Focus();
            //tag.Panel.Focus();
        }
Esempio n. 13
0
        private void initControls()
        {
            RichTextBox rtb = new RichTextBox();

            rtb.AppendText("DrawEA\n");
            rtb.SelectAll();
            rtb.SelectionFont = new Font(Font.FontFamily, Font.Size*2, FontStyle.Bold);

            rtb.SelectionLength = 0;
            rtb.SelectionStart = rtb.Text.Length;
            rtb.AppendText("Version " + Application.ProductVersion);
            rtb.SelectionLength = rtb.Text.Length - rtb.SelectionStart;
            rtb.SelectionFont = new Font(Font, FontStyle.Italic);

            rtb.ReadOnly = true;
            rtb.BackColor = Color.White;
            rtb.BorderStyle = BorderStyle.None;
            rtb.Location = new Point(50, 10);
            rtb.Size = new Size(200, 50);

            Controls.Add(rtb);

            Button close = new Button();

            close.Text = "x";
            close.Size = new Size(20, 20);
            close.Location = new Point(275, 5);

            close.Click += delegate { Close(); };

            Controls.Add(close);

            LinkLabel lblMail = new LinkLabel();

            lblMail.Text = "© 2006-2008 Andreas K.";
            lblMail.LinkArea = new LinkArea(12, 10);
            lblMail.LinkBehavior = LinkBehavior.HoverUnderline;
            lblMail.LinkClicked += delegate { System.Diagnostics.Process.Start("mailto:\"Andreas Krohn\"<*****@*****.**>?subject=DrawEA%20Version%20"+Application.ProductVersion); };

            lblMail.AutoSize = true;
            lblMail.Dock = DockStyle.Bottom;

            Controls.Add(lblMail);

            Bitmap bmp = new Bitmap(300, 190);
            Graphics g = Graphics.FromImage(bmp);

            int oldSize = State.STATE_SIZE;
            State.STATE_SIZE = 40;

            State A = new State("A", false, true);
            State B = new State("B", true, false);
            State C = new State("C", false, false);

            A.Destinations.Add(new Switch(A, B, "1", "done"));
            A.Destinations.Add(new Switch(A, C, "0", string.Empty));
            B.Destinations.Add(new Switch(B, B, "0", string.Empty));
            B.Destinations.Add(new Switch(B, B, "1", string.Empty));
            C.Destinations.Add(new Switch(C, A, "1", string.Empty));
            C.Destinations.Add(new Switch(C, C, "0", string.Empty));

            A.Location = new Point(40, 40);
            B.Location = new Point(230, 60);
            C.Location = new Point(160, 140);

            A.CalculateSwitchPoints();
            B.CalculateSwitchPoints();
            C.CalculateSwitchPoints();

            StringFormat sf = new StringFormat {Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center};

            using (Pen borderPen = new Pen(ForeColor, 4f))
            using (Pen switchOutline = new Pen(Color.FromArgb(220, BackColor), 5f))
            using (Pen switchPen = new Pen(ForeColor, 4f)
                                       {
                                           EndCap = LineCap.Custom,
                                           CustomEndCap = new AdjustableArrowCap(3, 3, true)
                                       })
            {
                g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);

                g.CompositingQuality = CompositingQuality.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBilinear;
                g.SmoothingMode = SmoothingMode.HighQuality;

                A.Draw(g, Brushes.White, borderPen, switchPen, Font, sf);
                B.Draw(g, Brushes.White, borderPen, switchPen, Font, sf);
                C.Draw(g, Brushes.White, borderPen, switchPen, Font, sf);
                A.DrawAllSwitches(g, A.CenterPoint(), switchPen, switchOutline, Font, sf, false);
                B.DrawAllSwitches(g, B.CenterPoint(), switchPen, switchOutline, Font, sf, true);
                C.DrawAllSwitches(g, C.CenterPoint(), switchPen, switchOutline, Font, sf, false);
            }

            State.STATE_SIZE = oldSize;

            PictureBox pb = new PictureBox();
            pb.SizeMode = PictureBoxSizeMode.AutoSize;
            pb.Image = bmp;
            pb.Location = new Point(0,60);

            Controls.Add(pb);

            close.Select();
        }