Beispiel #1
0
        void Read_Ini_File()
        {
            IniFile ini = new IniFile(IniFilePath);

            FRAME_LED_LEFT = ini.IniReadInt("MAIN", "FRAME_LED_LEFT");
            FRAME_LED_TOP = ini.IniReadInt("MAIN", "FRAME_LED_TOP");
            FRAME_LED_RIGHT = ini.IniReadInt("MAIN", "FRAME_LED_RIGHT");
            FRAME_LED_BOTTOM_LEFT = ini.IniReadInt("MAIN", "FRAME_LED_BOTTOM_LEFT");
            FRAME_LED_BOTTOM_RIGHT = ini.IniReadInt("MAIN", "FRAME_LED_BOTTOM_RIGHT");
            FRAME_LED_GAP = ini.IniReadInt("MAIN", "FRAME_LED_GAP");

            HOTKEY_PSEUDO_FULL_SCREEN = ini.IniReadInt("MAIN", "HOTKEY_PSEUDO_FULL_SCREEN");
            HOTKEY_SET_RATIO = ini.IniReadInt("MAIN", "HOTKEY_SET_RATIO");

            TOTAL_LED_COUNT = FRAME_LED_LEFT + FRAME_LED_TOP + FRAME_LED_RIGHT + FRAME_LED_BOTTOM_LEFT + FRAME_LED_BOTTOM_RIGHT;

            UpDown_Left.Value = FRAME_LED_LEFT;
            UpDown_Top.Value = FRAME_LED_TOP;
            UpDown_Right.Value = FRAME_LED_RIGHT;
            UpDown_BottomLeft.Value = FRAME_LED_BOTTOM_LEFT;
            UpDown_BottomRight.Value = FRAME_LED_BOTTOM_RIGHT;
            UpDown_Gap.Value = FRAME_LED_GAP;

            Refresh_Interval = ini.IniReadInt("MAIN", "Refresh_Interval");
            Power_Level =  ini.IniReadInt("MAIN", "Power_Level");
            SerialPortName = ini.IniReadValue("MAIN", "PortName");

            if (ini.IniReadValue("MAIN", "STRIP_DIRECTION") != "COUNTERCLOCKWISE") inverted_strip = true; //Special for Clockwise strip installations.

            DelayBar.Value = Refresh_Interval;

            if (SerialPortName == "COM0") // If com port didnt set
                {
                // Get a list of serial port names.
                string[] ports = SerialPort.GetPortNames();

                // Display each port name to the console.
                foreach (string port in ports)
                    {
                        try
                        {   //TEST com port
                            serialPort1.PortName = port;
                            serialPort1.Open();
                            serialPort1.Close();
                            SerialPortName = port; //Set if it's working.
                        }
                        catch
                        {
                        }

                    }
                }

            if (SerialPortName != "COM0")
                {
                serialPort1.PortName = SerialPortName;
                serialPort1.BaudRate = 115200;

                serialPort1.Open();
                serialPort1.Encoding = System.Text.Encoding.UTF8;
                ComPortCombo.Text = SerialPortName;
                }

            CaptureTimer.Interval = Refresh_Interval;

            POWER_LEVEL = (float)Power_Level / 100;

            mode_select(1);
        }
Beispiel #2
0
        private void buttonSave_Click_1(object sender, EventArgs e)
        {
            IniFile ini = new IniFile(IniFilePath);
            //Write to INI
            ini.IniWriteValue("MAIN", "FRAME_LED_LEFT", Left_Textbox.Text.ToString());
            ini.IniWriteValue("MAIN", "FRAME_LED_RIGHT", Right_Textbox.Text.ToString());
            ini.IniWriteValue("MAIN", "FRAME_LED_TOP", Top_Textbox.Text.ToString());
            ini.IniWriteValue("MAIN", "FRAME_LED_BOTTOM_LEFT", BottomLeft_Textbox.Text.ToString());
            ini.IniWriteValue("MAIN", "FRAME_LED_BOTTOM_RIGHT", BottomRight_Textbox.Text.ToString());
            ini.IniWriteValue("MAIN", "FRAME_LED_GAP", Gap_Textbox.Text.ToString());
            // Read and refresh from INI
            FRAME_LED_LEFT = ini.IniReadInt("MAIN", "FRAME_LED_LEFT");
            FRAME_LED_TOP = ini.IniReadInt("MAIN", "FRAME_LED_TOP");
            FRAME_LED_RIGHT = ini.IniReadInt("MAIN", "FRAME_LED_RIGHT");
            FRAME_LED_BOTTOM_LEFT = ini.IniReadInt("MAIN", "FRAME_LED_BOTTOM_LEFT");
            FRAME_LED_BOTTOM_RIGHT = ini.IniReadInt("MAIN", "FRAME_LED_BOTTOM_RIGHT");
            FRAME_LED_GAP = ini.IniReadInt("MAIN", "FRAME_LED_GAP");

            TOTAL_LED_COUNT = FRAME_LED_LEFT + FRAME_LED_TOP + FRAME_LED_RIGHT + FRAME_LED_BOTTOM_LEFT + FRAME_LED_BOTTOM_RIGHT;
            // Refresh default full screen settigns.
            fullScreenToolStripMenuItem.PerformClick();
            // Clear the Strip buffer
            COM_Tx_Buffer[512 * 3] = (byte)252; //Clear LED buffer and read the color sensor.(the sensor read is not important now, just for clear)
            if ((SerialPortName != "COM0") && (Monitor_Sleeping == false))
                serialPort1.Write(COM_Tx_Buffer, 0, (512 * 3) + 3);
        }