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--;
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void bunifuFlatButton4_Click(object sender, EventArgs e)
        {
            ini    ireader = new ini();
            string ininame = @"Pins.ini";

            ireader.IniWriteValue(this.bunifuDropdown5.selectedValue, null, null, ininame);
            refreshAdding(Ms);
            refreshdeletekey();
        }
Exemple #3
0
 private void RefreshPins()
 {
     try
     {
         ini           ireader = new ini();
         List <string> Get     = ireader.GetAllSection(ininame);
         bunifuDropdown3.Items = Get.ToArray();
     }
     catch { }
 }
Exemple #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;
            }
        }
        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);
        }
Exemple #6
0
 private void bunifuFlatButton3_Click(object sender, EventArgs e)
 {
     if (function.Text != string.Empty && returns.Text != string.Empty && bunifuDropdown3.selectedIndex != -1)
     {
         ini ireader = new ini();
         ireader.IniWriteValue(bunifuDropdown3.selectedValue, "Function", function.Text, ininame);
         ireader.IniWriteValue(bunifuDropdown3.selectedValue, "Returns", returns.Text, ininame);
         slideView1.Refreshes();
     }
     else
     {
         MessageBox.Show("請填入相關資訊", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #7
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();
        }
Exemple #8
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;
        }
        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      = "依預設傳送間距秒數傳送,請到-設定-設置間距";
                }
            }
        }
Exemple #10
0
        private async void RefreshLineStatus(string path)
        {
            Line = new LineNotify(path);
            bool Service = await Line.CheckStatus();

            if (Service)
            {
                label4.Text      = "已連線";
                label4.ForeColor = Color.Green;
            }
            else
            {
                label4.Text      = "尚未連線";
                label4.ForeColor = Color.Red;
            }
            ini ireader = new ini();

            ireader.IniWriteValue("SystemInfo", "IFTTT", path, Systemini);
        }
        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);
        }
        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);
        }
Exemple #14
0
        private void bunifuDropdown2_onItemSelected(object sender, EventArgs e)
        {
            ini ireader = new ini();

            ireader.IniWriteValue("SystemInfo", "Baud", bunifuDropdown2.selectedValue, Systemini);
        }
Exemple #15
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);
            }
        }
Exemple #16
0
        private void selected(object sender, EventArgs e)
        {
            ini ireader = new ini();

            ireader.IniWriteValue("SystemInfo", "SerialPort", bunifuDropdown1.selectedValue, Systemini);
        }
Exemple #17
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            ini ireader = new ini();

            ireader.IniWriteValue("SystemInfo", "SendMilliSecond", bunifuMaterialTextbox1.Text, Systemini);
        }