Пример #1
0
 public void ChooseModuleClose(object sender, FormClosingEventArgs e)
 {
     if (cm.open == true)
     {
         for (int i = 0; i < modules.Length; i++)
         {
             if (modules[i].Text == "")
             {
                 modulesCounter++;
                 modules[i]              = new FormC();
                 modules[i]              = Func.Constructor(cm.Text, modules[i]);
                 modules[i].FormClosing += ModuleClose;
                 modules[i].Show();
                 modules[i].Left = this.Left; modules[i].Top = this.Top + 481;
                 break;
             }
         }
     }
 }
Пример #2
0
        public static FormC Constructor(String path, FormC result)
        {
            String[] file = File.ReadAllText(path).Split(';');
            for (int i = 0; i < file.Length; i++)
            {
                if (file[i] != "")
                {
                    if (file[i].Substring(0, 2) == "\r\n")
                    {
                        file[i] = file[i].Substring(2, file[i].Length - 2);
                    }
                }
            }
            foreach (String Line in file)
            {
                try
                {
                    String[] SLine  = Line.Split(' ');
                    int      ccount = 0;
                    switch (SLine[ccount])
                    {
                    case "name":
                        result.Text = SLine[++ccount];
                        break;

                    case "btn":
                        Button btn = new Button();
                        btn.ForeColor = Color.Black;
                        btn           = (ControlConstr(btn, SLine[++ccount], Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount])) as Button);
                        while (ccount + 1 < SLine.Length)
                        {
                            switch (SLine[++ccount])
                            {
                            case "fontsize":
                                btn.Font = new Font(btn.Font.Name, Convert.ToInt32(SLine[++ccount]));
                                break;

                            case "text":
                                btn.Text = SLine[++ccount];
                                break;
                            }
                        }
                        result.Controls.Add(btn);
                        break;

                    case "cmb":
                        ComboBox cmb = new ComboBox();
                        cmb.ForeColor = Color.Black;
                        cmb           = (ControlConstr(cmb, SLine[++ccount], Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount])) as ComboBox);
                        while (ccount + 1 < SLine.Length)
                        {
                            switch (SLine[++ccount])
                            {
                            case "fontsize":
                                cmb.Font = new Font(cmb.Font.Name, Convert.ToInt32(SLine[++ccount]));
                                break;

                            case "text":
                                cmb.Text = SLine[++ccount];
                                break;

                            case "collection":
                                String[] Collection = SLine[++ccount].Split('&');
                                foreach (String str in Collection)
                                {
                                    cmb.Items.Add(str);
                                }
                                break;
                            }
                        }
                        result.Controls.Add(cmb);
                        break;

                    case "lbl":
                        Label lbl = new Label();
                        lbl.ForeColor = Color.Black;
                        lbl           = (ControlConstr(lbl, SLine[++ccount], Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount])) as Label);
                        while (ccount + 1 < SLine.Length)
                        {
                            switch (SLine[++ccount])
                            {
                            case "fontsize":
                                lbl.Font = new Font(lbl.Font.Name, Convert.ToInt32(SLine[++ccount]));
                                break;

                            case "text":
                                lbl.Text = SLine[++ccount];
                                break;
                            }
                        }
                        result.Controls.Add(lbl);
                        break;

                    case "txt":
                        TextBox txt = new TextBox();
                        txt = (ControlConstr(txt, SLine[++ccount], Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount])) as TextBox);
                        while (ccount + 1 < SLine.Length)
                        {
                            switch (SLine[++ccount])
                            {
                            case "fontsize":
                                txt.Font = new Font(txt.Font.Name, Convert.ToInt32(SLine[++ccount]));
                                break;

                            case "readonly":
                                txt.ReadOnly = true;
                                break;

                            case "text":
                                txt.Text = SLine[++ccount];
                                break;
                            }
                        }
                        result.Controls.Add(txt);
                        break;

                    case "about":
                        for (int i = 1; i < SLine.Length; i++)
                        {
                            result.about = result.about + SLine[i] + " ";
                        }
                        break;

                    case "form":
                        result.Size = new Size(Convert.ToInt32(SLine[++ccount]), Convert.ToInt32(SLine[++ccount]));
                        break;

                    case "for":
                        break;
                    }
                }
                catch (Exception)
                {
                }
            }

            return(result);
        }
Пример #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            modules = new FormC[6];
            for (int i = 0; i < 6; i++)
            {
                modules[i] = new FormC();
            }
            ToolTip t = new ToolTip(); t.SetToolTip(addmodb3, "Добавить подключённый модуль"); t.SetToolTip(colorb, "Выбрать цвета подсветки");

            MyDialog = new ColorDialog();
            MyDialog.AllowFullOpen = true;
            MyDialog.ShowHelp      = true;
            SerialTask             = new Thread(SerialTaskR);
            com = new SerialPort(); com.DtrEnable = true;
            Directory.CreateDirectory("c:\\ProgramData\\PorMIDITool\\profiles");
            conf = new FileStream("c:\\ProgramData\\PorMIDITool\\conf.pmt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            by   = new byte[conf.Length]; conf.Read(by, 0, by.Length); conf.Close();
            string fstr = Encoding.UTF7.GetString(by);//.Split(new char[] { ' ' });

            try
            {
                if (Convert.ToInt32(fstr) < 1 || Convert.ToInt32(fstr) > 12)
                {
                    fstr = "1";
                }
            }
            catch (Exception) { fstr = "1"; }
            profile = Convert.ToInt16(fstr);


            try
            {
                profstr = File.ReadAllLines("c:\\ProgramData\\PorMIDITool\\profiles\\profile" + fstr + ".pmt")[0].Split(' ');
                for (int i = 1; i < 27; i++)
                {
                    if (Convert.ToInt32(profstr[i]) > 127 || Convert.ToInt32(profstr[i]) < 0)
                    {
                        profstr[i] = i.ToString();
                    }
                }
            }
            catch (Exception)
            {
                repair(fstr);
            }
            octave = Convert.ToInt32(profstr[0]);
            профильToolStripMenuItem.Text = "Профиль (" + profile.ToString() + ")";
            tb = new TextBox[4, 4];
            ////////////////////////////////////k=0////////////////////////
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    tb[j, i]           = new TextBox();
                    tb[j, i].Tag       = k++;
                    tb[j, i].Name      = "tb" + k;
                    tb[j, i].Size      = new System.Drawing.Size(30, 8);
                    tb[j, i].Text      = profstr[k];
                    tb[j, i].KeyPress += new KeyPressEventHandler(tb_Press);
                    tb[j, i].Location  = new Point(j * 68 + 45, i * 73 + 75);
                    Controls.Add(tb[j, i]);
                    tb[j, i].BringToFront();
                }
            }

            b = new Button[4, 4];
            ////////////////////////////////////k=15////////////////////////
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    b[j, i]            = new Button();
                    b[j, i].Tag        = k++;
                    b[j, i].Name       = "button" + (k - 16).ToString();
                    b[j, i].Size       = new System.Drawing.Size(65, 70);
                    b[j, i].Location   = new Point(j * 68 + 30, i * 73 + 30);
                    b[j, i].MouseDown += new MouseEventHandler(this.button_MouseDown);
                    b[j, i].MouseUp   += new MouseEventHandler(this.button_MouseUp);
                    Func.button_update(i * 4 + j, b[j, i], fstr);
                    Controls.Add(b[j, i]);
                }
            }
            Label[,] addpl = new Label[2, 5];
            {
                int col = 0;
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        col++;
                        addpl[i, j]          = new Label();
                        addpl[i, j].Name     = "button" + (k - 32).ToString();
                        addpl[i, j].Size     = new System.Drawing.Size(56, 20);
                        addpl[i, j].Font     = new Font(addpl[i, j].Font.Name, 14, addpl[i, j].Font.Style);
                        addpl[i, j].Text     = col.ToString() + "CC";
                        addpl[i, j].Location = new Point(330 + j * 60, i * 55 + 150);
                        Controls.Add(addpl[i, j]);
                    }
                }
            }
            ////////////////////////////////////k=32////////////////////////
            addptb = new TextBox[2, 5];
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    addptb[i, j]          = new TextBox();
                    addptb[i, j].Tag      = k++;
                    addptb[i, j].Name     = "addtb" + (k - 32).ToString();
                    addptb[i, j].Size     = new System.Drawing.Size(sleepTime, 20);
                    addptb[i, j].Text     = profstr[k - 16];
                    addptb[i, j].Location = new Point(335 + j * 60, i * 55 + 180);
                    Controls.Add(addptb[i, j]);
                }
            }
            RadioButton[] oct = new RadioButton[11];
            gb          = new GroupBox();
            gb.Location = new System.Drawing.Point(0, -10);
            gb.Size     = new System.Drawing.Size(20, 150);
            for (int j = 0; j < 11; j++)
            {
                oct[j]          = new RadioButton();
                oct[j].Text     = (j - 1).ToString();
                oct[j].Name     = "octrb" + (j + 1).ToString();
                oct[j].Click   += new EventHandler(oct_Click);
                oct[j].Location = new System.Drawing.Point(10, j * 20 + 10);
                if (octave == (j - 1))
                {
                    oct[j].Checked = true;
                }
                gb.Controls.Add(oct[j]);
            }
            октаваToolStripMenuItem.DropDownItems.Insert(0, new ToolStripControlHost(gb));
            sd = new RadioButton();
            oct[octave + 1].Checked = true;
            ToolStripMenuItem[] prof = new ToolStripMenuItem[12];
            for (int j = 0; j < 12; j++)
            {
                prof[j]              = new ToolStripMenuItem();
                prof[j].Text         = (j + 1).ToString();
                prof[j].Click       += new EventHandler(prof_Click);
                prof[j].ShortcutKeys = ((Keys)(Keys.Control | (Keys)j + 49));
                профильToolStripMenuItem.DropDownItems.Add(prof[j]);
            }
            prof[9].ShortcutKeys  = ((Keys)(Keys.Control | (Keys)48));
            prof[10].ShortcutKeys = ((Keys)(Keys.Control | (Keys)189));
            prof[11].ShortcutKeys = ((Keys)(Keys.Control | (Keys)187));
            //prof_Click();
        }