void Add_event(string value)
        {
            ini           ireader       = new ini();
            List <string> getAllSection = ireader.GetAllSection(ininame);

            for (int i = 0; i < getAllSection.Count; i++)
            {
                if (value.Contains(string.Format("pin{0}=", getAllSection[i])))
                {
                    string pins     = getAllSection[i];
                    string Status   = ireader.IniReadValue(getAllSection[i], "Status", ininame);
                    string IO       = ireader.IniReadValue(getAllSection[i], "IO", ininame);
                    string Function = ireader.IniReadValue(getAllSection[i], "Function", ininame);
                    string Returns  = ireader.IniReadValue(getAllSection[i], "Returns", ininame);
                    Slide  slide    = new Slide(pins, Status, IO, Function, Returns);
                    if (slide.Check())
                    {
                        if (slide.Returns.Contains("[time]"))
                        {
                            slide.Returns = slide.Returns.Replace("[time]", "[" + DateTime.Now.ToString() + "]");
                        }
                        string[] var = value.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                        if (slide.Returns.Contains("[var]"))
                        {
                            slide.Returns = slide.Returns.Replace("[var]", "[" + var[var.Length - 1].Trim('\r') + "]");
                        }
                        Pin_Queue.Add(slide);
                        if (quecount > 0)
                        {
                            quecount--;
                        }
                    }
                }
            }
        }
        public SerialPortWindows()
        {
            InitializeComponent();
            ini ireader = new ini();

            Baud       = ireader.IniReadValue("SystemInfo", "Baud", Systemini);
            SerialPort = ireader.IniReadValue("SystemInfo", "SerialPort", Systemini);
            IFTTT_path = ireader.IniReadValue("SystemInfo", "IFTTT", Systemini);
            delaytime  = ireader.IniReadValue("SystemInfo", "SendMilliSecond", Systemini);
        }
示例#3
0
        public void refreshAdding(TextBox tb)
        {
            ini    ireader = new ini();
            string ininame = @"Pins.ini";
            string get     = string.Empty;

            for (int i = 0; i < this.bunifuDropdown1.Items.Length; i++)
            {
                string status = ireader.IniReadValue(this.bunifuDropdown1.Items[i], "Status", ininame);
                string IO     = ireader.IniReadValue(this.bunifuDropdown1.Items[i], "IO", ininame);
                if ((status != null && IO != null) && (status != string.Empty && IO != string.Empty))
                {
                    get += string.Format("腳位:{0} , 腳位狀態:{1} , I/O狀態:{2}\r\n", this.bunifuDropdown1.Items[i], status, IO);
                }
            }
            tb.Text = get;
        }
示例#4
0
        void Refresh_dt()
        {
            ini    ireader = new ini();
            string str     = ireader.IniReadValue("SystemInfo", "SendMilliSecond", Systemini);

            if (str != string.Empty && str != null)
            {
                bunifuMaterialTextbox1.Text = str;
            }
        }
        void Refresh_Serial()
        {
            ini ireader = new ini();

            Baud       = ireader.IniReadValue("SystemInfo", "Baud", Systemini);
            SerialPort = ireader.IniReadValue("SystemInfo", "SerialPort", Systemini);
            IFTTT_path = ireader.IniReadValue("SystemInfo", "IFTTT", Systemini);
            if (SerialPort != string.Empty && Baud != string.Empty)
            {
                try
                {
                    serialPort = new System.IO.Ports.SerialPort(SerialPort, Convert.ToInt32(Baud));
                    serialPort.Open();
                    serialPort.DataReceived += new SerialDataReceivedEventHandler(MyDataReceived);
                }
                catch (System.IO.IOException)
                {
                    MessageBox.Show("ComPort被其他程序占走了哦!", "ComPort Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        int getEvent()
        {
            int           p             = 0;
            ini           ireader       = new ini();
            List <string> getAllSection = ireader.GetAllSection(ininame);

            for (int i = 0; i < getAllSection.Count; i++)
            {
                string pins     = getAllSection[i];
                string Status   = ireader.IniReadValue(getAllSection[i], "Status", ininame);
                string IO       = ireader.IniReadValue(getAllSection[i], "IO", ininame);
                string Function = ireader.IniReadValue(getAllSection[i], "Function", ininame);
                string Returns  = ireader.IniReadValue(getAllSection[i], "Returns", ininame);
                Slide  slide    = new Slide(pins, Status, IO, Function, Returns);
                if (slide.Check())
                {
                    p++;
                }
            }
            return(p);
        }
示例#7
0
        private List <Slide> refreshSlideView()
        {
            List <Slide> slide = new List <Slide>();

            ini           ireader = new ini();
            List <string> getAll  = ireader.GetAllSection(ininame);

            for (int i = 0; i < getAll.Count; i++)
            {
                Slide  newslide;
                string pins     = getAll[i];
                string Status   = ireader.IniReadValue(getAll[i], "Status", ininame);
                string IO       = ireader.IniReadValue(getAll[i], "IO", ininame);
                string Function = ireader.IniReadValue(getAll[i], "Function", ininame);
                string Returns  = ireader.IniReadValue(getAll[i], "Returns", ininame);
                newslide = new Slide(pins, Status, IO, Function, Returns);
                if (newslide.Check())
                {
                    slide.Add(newslide);
                }
            }
            return(slide);
        }
示例#8
0
        public void refreshdeletekey()
        {
            List <string> keys    = new List <string>();
            ini           ireader = new ini();
            string        ininame = @"Pins.ini";

            for (int i = 0; i < this.bunifuDropdown1.Items.Length; i++)
            {
                string receive = ireader.IniReadValue(this.bunifuDropdown1.Items[i], "Status", ininame);
                if (receive != null && receive != string.Empty)
                {
                    keys.Add(this.bunifuDropdown1.Items[i]);
                }
            }
            this.bunifuDropdown5.Items = keys.ToArray();
        }
        private void UpdateUI(string value, Control ctl)
        {
            if (this.InvokeRequired)
            {
                UpdateUICallBack uu = new UpdateUICallBack(UpdateUI);
                this.Invoke(uu, value, ctl);
            }
            else
            {
                ctl.Text += value;

                ini ireader = new ini();
                delaytime = ireader.IniReadValue("SystemInfo", "SendMilliSecond", Systemini);
                TimeSpan ts = DateTime.Now - previous;
                if (delaytime != null && delaytime != string.Empty)
                {
                    if (ts.TotalMilliseconds >= Convert.ToInt32(delaytime) || quecount > 0)
                    {
                        if (quecount == 0)
                        {
                            quecount = getEvent();
                        }
                        Add_event(value);
                        previous = DateTime.Now;
                    }
                    label1.ForeColor = Color.Green;
                    label1.Text      = "已依照已設置的傳送間距秒數傳送(LineNotify)";
                }
                else
                {
                    if (ts.TotalMilliseconds >= 1000 || quecount > 0)
                    {
                        if (quecount == 0)
                        {
                            quecount = getEvent();
                        }
                        Add_event(value);
                        previous = DateTime.Now;
                    }
                    label1.ForeColor = Color.Red;
                    label1.Text      = "依預設傳送間距秒數傳送,請到-設定-設置間距";
                }
            }
        }
示例#10
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            if (Code != string.Empty && path != string.Empty)
            {
                List <string> codeSTR = Code.Split(new string[] { "\n", "\r\n", "\r" }, StringSplitOptions.None).ToList <string>();
                for (int i = 0; i < codeSTR.Count; i++)
                {
                    if (codeSTR[i].ToLower().Contains("void") && codeSTR[i].ToLower().Contains("setup"))
                    {
                        int  countdown = 0, j = i;
                        bool flag = false;
                        while (j != codeSTR.Count - 1)
                        {
                            if (codeSTR[j].ToLower().Contains("{"))
                            {
                                countdown++;
                            }
                            if (codeSTR[j].ToLower().Contains("}") && countdown > 0)
                            {
                                countdown--;
                            }
                            if (codeSTR[j].ToLower().Contains("}") && countdown == 0)
                            {
                                break;
                            }

                            if (codeSTR[j].ToLower().Contains("serial.begin"))
                            {
                                ini          inireader = new ini();
                                string       Baud      = inireader.IniReadValue("SystemInfo", "Baud", Systemini);
                                DialogResult result    = MessageBox.Show("已存在Serial.begin語法,繼續添加的話可能會影響到傳送的訊息,是否繼續添加?", "Adding Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                if (result == DialogResult.Yes)
                                {
                                    if (Baud != string.Empty && Baud != null)
                                    {
                                        codeSTR.Insert(i + 1, string.Format("Serial.begin({0});", Baud));
                                        MessageBox.Show(string.Format("添加成功,您的鮑率已設置成{0}", Baud), "Done", MessageBoxButtons.OK);
                                    }
                                    else
                                    {
                                        codeSTR.Insert(i + 1, string.Format("Serial.begin(9600);"));
                                        MessageBox.Show(string.Format("添加成功,您的鮑率已設置成{0}", "9600"), "Done", MessageBoxButtons.OK);
                                    }
                                }
                                flag = true;
                                break;
                            }
                            j++;
                        }
                        if (!flag)
                        {
                            codeSTR.Insert(i + 1, string.Format("Serial.begin(9600);"));
                        }
                    }
                }

                ini    ireader             = new ini();
                string ininame             = @"Pins.ini";
                string get                 = string.Empty;
                List <PinAndStatus> pinadd = new List <PinAndStatus>();
                for (int i = 0; i < this.bunifuDropdown1.Items.Length; i++)
                {
                    string status = ireader.IniReadValue(this.bunifuDropdown1.Items[i], "Status", ininame);
                    string IO     = ireader.IniReadValue(this.bunifuDropdown1.Items[i], "IO", ininame);
                    if ((status != null && IO != null) && (status != string.Empty && IO != string.Empty))
                    {
                        PinAndStatus pas = new PinAndStatus();
                        if (status == "數位Digital")
                        {
                            pas.Status = "digitalRead";
                        }
                        else
                        {
                            pas.Status = "analogRead";
                        }
                        pas.Pin = this.bunifuDropdown1.Items[i];
                        pinadd.Add(pas);
                    }
                }

                int index = -1;
                for (int i = 0; i < codeSTR.Count; i++)
                {
                    if (codeSTR[i].ToLower().Contains("void") && codeSTR[i].ToLower().Contains("loop"))
                    {
                        index = i;
                    }
                }

                for (int i = 0; i < pinadd.Count; i++)
                {
                    codeSTR.Insert(index + 1, string.Format(@"Serial.println(""pin{0}="" + String({1}({2})));", pinadd[i].Pin, pinadd[i].Status, pinadd[i].Pin));
                }

                SaveFileDialog save = new SaveFileDialog();
                save.Title           = "儲存Ino檔案";
                save.Filter          = "ino Files|*.ino";
                save.CheckPathExists = true;
                if (save.ShowDialog() == DialogResult.OK)
                {
                    if (save.FileName != null && save.FileName != string.Empty)
                    {
                        InsertText(codeSTR, save.FileName);
                    }
                }
                MessageBox.Show("注意,如果您Serial或訊息傳送速度太快,傳送會失敗哦!", "Done", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MessageBox.Show("現在請打開您的ArduinoIDE上傳剛才儲存的程式碼哦!", "Done", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MessageBox.Show("請上傳ino檔案哦!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }