コード例 #1
0
ファイル: Form1.cs プロジェクト: KapuKapu/Lightpack
 public Form1()
 {
     InitializeComponent();
     api = new ApiLightpack();
     api.LogEvent += new EventHandler<LogEventArgs>(api_LogEvent);
     DrawArea = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height);
     pictureBox1.Image = DrawArea;
     DrawScreen = new Bitmap(pictureBox2.Size.Width, pictureBox2.Size.Height);
     pictureBox2.Image = DrawScreen;
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: Gimazov/Lightpack
        /// <summary>
        /// Метод события до загрузки формы
        /// </summary>
        /// <param name="sender">отправитель</param>
        /// <param name="e">параметры</param>
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

            #region Инициализация переменных и чтение параметров из конфигурационного файла

                this.Text = "VolumeLight " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                connected = false;

                states = new List<State>(10);

                for (int i = 0; i < 10; i++)
                {
                    states.Add(new State(i + 1, Color.Black));
                }

                period = 1;
                start = 5;
                end = 105;
                host = "127.0.0.1";
                port = 3636;

                System.IO.StreamReader sr = new System.IO.StreamReader("config");
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    if (line.IndexOf("led") > -1)
                    {
                        int lednumber = Int32.Parse(line.Substring(3, line.IndexOf("=") - 3));
                        line = line.Substring(line.IndexOf("=") + 1);
                        int position = Int32.Parse(line.Substring(0, line.IndexOf("|")));
                        string color = line.Substring(line.IndexOf("|") + 1, line.Length - line.IndexOf("|") - 1);

                        states[lednumber - 1] = new State(position, color);
                    }
                    if (line.IndexOf("period") > -1)
                    {
                        period = Int32.Parse(line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1));
                    }
                    if (line.IndexOf("start") > -1)
                    {
                        start = Int32.Parse(line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1));
                    }
                    if (line.IndexOf("end") > -1)
                    {
                        end = Int32.Parse(line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1));
                    }
                    if (line.IndexOf("host") > -1)
                    {
                        host = line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1);
                    }
                    if (line.IndexOf("port") > -1)
                    {
                        port = Int32.Parse(line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1));
                    }
                }
                sr.Close();

                en = new NAudio.CoreAudioApi.MMDeviceEnumerator();
                mmdevice = en.GetDefaultAudioEndpoint(NAudio.CoreAudioApi.DataFlow.Render, NAudio.CoreAudioApi.Role.Multimedia);
                api = new ApiLightpack();

                numericUpDown2.Value = period;
                numericUpDown3.Value = start;
                numericUpDown4.Value = end;
                textBox1.Text = host;
                numericUpDown1.Value = port;

                label_1.Text = states[0].Position.ToString();
                label_2.Text = states[1].Position.ToString();
                label_3.Text = states[2].Position.ToString();
                label_4.Text = states[3].Position.ToString();
                label_5.Text = states[4].Position.ToString();
                label_6.Text = states[5].Position.ToString();
                label_7.Text = states[6].Position.ToString();
                label_8.Text = states[7].Position.ToString();
                label_9.Text = states[8].Position.ToString();
                label_10.Text = states[9].Position.ToString();

                timer1.Interval = period;

            #endregion

                //Запуск таймера
                timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Сообщение: " + ex.Message + Environment.NewLine + "StackTrace: " + Environment.NewLine + ex.StackTrace, "Произошла ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Gimazov/Lightpack
 public Form1()
 {
     InitializeComponent();
     api = new ApiLightpack();
 }