コード例 #1
0
        }//button_Click

        protected void button_Mouseup(object sender, EventArgs e)
        {
            RemoteButton button = sender as RemoteButton;

            buttonlist.SelectedIndex = buttonlist.FindStringExact(button.Name);
            UpdateButtondata();
        }//button_Mouseup
コード例 #2
0
        }//New_Click

        private void Duplicate_Click(object sender, EventArgs e)
        {
            int pos = ListofButtons.IndexOf(buttonlist.Text);

            if (pos < 0)
            {
                return;
            }

            RemoteButton button = new RemoteButton();

            button.Click   += new EventHandler(button_Click);
            button.MouseUp += new MouseEventHandler(button_Mouseup);
            string newbutton     = buttonlist.Text;
            string newremote     = ListofRemotes[pos];
            string newbuttonname = ListofButtonNames[pos];

            while (ListofButtons.Contains(newbutton))
            {
                newbutton = newbutton + "1";
            }
            button.Name = newbutton;

            foreach (Control test in remoteimage.Controls)
            {
                if (test is RemoteButton)
                {
                    if (test.Name == buttonlist.Text)
                    {
                        test.Left     = (int)posx.Value;
                        button.Top    = test.Top;
                        button.Left   = test.Left;
                        button.Width  = test.Width;
                        button.Height = test.Height;
                    }
                }
            }

            remoteimage.Controls.Add(button);
            ListofButtons.Add(newbutton);
            ListofRemotes.Add(newremote);
            ListofButtonNames.Add(newbuttonname);

            buttonlist.Items.Clear();
            foreach (string test in ListofButtons)
            {
                buttonlist.Items.Add(test);
            }
            buttonlist.SelectedIndex = buttonlist.Items.IndexOf(button.Name);
        }//Duplicate_Click
コード例 #3
0
        }//button_Mouseup

        private void New_Click(object sender, EventArgs e)
        {
            RemoteButton button = new RemoteButton();

            button.Click   += new EventHandler(button_Click);
            button.MouseUp += new MouseEventHandler(button_Mouseup);
            string newbutton     = "newbutton";
            string newremote     = "change";
            string newbuttonname = "change";


            while (ListofButtons.Contains(newbutton))
            {
                newbutton = newbutton + "1";
            }

            button.Name      = newbutton;
            button.Top       = 0;
            button.Left      = 0;
            button.Width     = 30;
            button.Height    = 30;
            button.BackColor = Color.Red;
            button.TabStop   = false;

            remoteimage.Controls.Add(button);
            ListofButtons.Add(newbutton);
            ListofRemotes.Add(newremote);
            ListofButtonNames.Add(newbuttonname);

            buttonlist.Items.Clear();
            foreach (string test in ListofButtons)
            {
                buttonlist.Items.Add(test);
            }
            buttonlist.SelectedIndex = buttonlist.Items.IndexOf(button.Name);
        }//New_Click
コード例 #4
0
        }//newconfig_Click

        private void loadconfig_Click(object sender, EventArgs e)
        {
            buttonlist.Items.Clear();
            ListofButtons.Clear();
            ListofRemotes.Clear();
            ListofButtonNames.Clear();
            foreach (Control test in remoteimage.Controls)
            {
                if (test is RemoteButton)
                {
                    remoteimage.Controls.Remove(test);
                }
            }//foreach
            remoteimage.Image = null;
            buttonlist.Text   = "";
            posx.Value        = 0;
            posy.Value        = 0;
            width.Value       = 0;
            height.Value      = 0;
            name.Text         = "";
            remote.Text       = "";
            button.Text       = "";


            OpenFileDialog getconfig = new OpenFileDialog();

            getconfig.Title       = "Open Remote Defination";
            getconfig.Filter      = "Remotes|*.remote";
            getconfig.FilterIndex = 1;
            getconfig.Multiselect = false;
            ;

            if (getconfig.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(getconfig.FileName);
                try
                {
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(getconfig.FileName))
                    {
                        string line;
                        int    lineNumber = 0;
                        while ((line = reader.ReadLine()) != null)
                        {
                            lineNumber++;
                            string[] tokens = Regex.Split(line, ",,");
                            if (tokens.Length > 1)
                            {
                                if (tokens[0] == "imagefile")
                                {
                                    if (File.Exists(tokens[1]))
                                    {
                                        ImagePath = tokens[1];
                                        Image thepicture = new Bitmap(tokens[1]);
                                        remoteimage.Image  = thepicture;
                                        remoteimage.Width  = thepicture.Width;
                                        remoteimage.Height = thepicture.Height;
                                        if (Form1.ActiveForm.Width < (remoteimage.Width + 6))
                                        {
                                            Form1.ActiveForm.Width = remoteimage.Width + 6;
                                        }
                                        if (Form1.ActiveForm.Height < (remoteimage.Height + 50))
                                        {
                                            Form1.ActiveForm.Height = remoteimage.Height + 50;
                                        }
                                    }
                                }//imagefile
                                if (tokens[0] == "button" && tokens.Length > 7)
                                {
                                    RemoteButton newremotebutton = new RemoteButton();
                                    newremotebutton.Click   += new EventHandler(button_Click);
                                    newremotebutton.MouseUp += new MouseEventHandler(button_Mouseup);
                                    string newbutton     = tokens[1];
                                    string newremote     = tokens[2];
                                    string newbuttonname = tokens[3];
                                    while (ListofButtons.Contains(newbutton))
                                    {
                                        newbutton = newbutton + "1";
                                    }
                                    newremotebutton.Name      = newbutton;
                                    newremotebutton.Left      = int.Parse(tokens[4]);
                                    newremotebutton.Top       = int.Parse(tokens[5]);
                                    newremotebutton.Width     = int.Parse(tokens[6]);
                                    newremotebutton.Height    = int.Parse(tokens[7]);
                                    newremotebutton.BackColor = Color.Red;
                                    remoteimage.Controls.Add(newremotebutton);
                                    ListofButtons.Add(newbutton);
                                    ListofRemotes.Add(newremote);
                                    ListofButtonNames.Add(newbuttonname);
                                } //button
                            }
                        }         //while

                        buttonlist.Items.Clear();
                        foreach (string test in ListofButtons)
                        {
                            buttonlist.Items.Add(test);
                        }
                        buttonlist.SelectedIndex = buttonlist.Items.Count - 1;
                    }//using
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file.");
                }
            } //ok clicked
        }     //loadconfig_Click