Esempio n. 1
0
        private void Input_UserTimeout_TextChanged(object sender, EventArgs e)
        {
            string xxx = Input_UserTimeout.Text.ToString();

            Debug.WriteLine("" + xxx);
            ACConfigManager.AddUpdateAppSettings("consideroff", xxx);
        }
Esempio n. 2
0
        /// <summary>
        /// Au clic on corrige le format, on "try" la requête http, si la requête est différente de null (souvent 404, mauvais input / htaccess)
        /// on vérifie si un domaine a déjà été enregistré, si oui on fait rien, si la variable est à "none" on l'enregistre
        /// </summary>
        private async void BtnVerifyUsrUrl_Click(object sender, EventArgs e)
        {
            if (Uri.IsWellFormedUriString(userDomain, UriKind.Absolute))
            {
                //corrige le format
                var _domain         = new Uri(userDomain);
                var _domfinaloutput = new Uri(_domain, txtloc);
                OutToRichLog("TEST", "Trying to connect...  \n" + _domfinaloutput);

                try
                {
                    HttpClient client = new HttpClient();
                    string     result = await client.GetStringAsync(_domfinaloutput);

                    if (result != null)
                    {
                        // on regarde si y'a déjà quelque chose d'enregistré
                        string _domValid = _domfinaloutput.ToString();

                        ACConfigManager.AddUpdateAppSettings("userdomain", _domValid);
                        DisableInputURLctrls();
                        OutToRichLog("HTTP", "everything is fine, saving domain...  \nYou can now starts the loop !" + _domfinaloutput);
                        UnlockButton(LaBouleMagique);
                    }
                }
                catch
                {
                    OutToRichLog("SETUP", "404 :  " + userDomain + txtloc);
                }
            }
        }
Esempio n. 3
0
        private void Btn_serielConnect_Click(object sender, EventArgs e)
        {
            // TODO IMPORTANT : trouver un moyen de disconnect proprement
            // selectedPort = listPort.GetItemText(listPort.SelectedItem);
            port = new SerialPort(selectedPort, 9600, Parity.None, 8, StopBits.One);

            port.ReadTimeout  = 500;
            port.WriteTimeout = 500;

            port.DtrEnable = true;
            port.RtsEnable = true;
            //port.DtrEnable = true;
            //  port.RtsEnable = true;
            text_iSconnected.Text = isConnected.ToString();
            text_iSconnected.Text = port.IsOpen.ToString();

            if (isConnected == true)
            {
                try
                {
                    port.DtrEnable = false;
                    port.RtsEnable = false;
                    port.DiscardInBuffer();
                    port.DiscardOutBuffer();
                    port.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                // passer la value disconneced à l'arduino

                isConnected = false;
                OutToRichLog("Com", "Closing " + port.PortName);
            }
            else if (isConnected == false)
            {
                btn_serielConnect.Text = "Disconnect";
                try
                {
                    port.Open();
                    AllowComControls();
                    string isThereADomain = ACConfigManager.getValue("userdomain");
                    if (isThereADomain != "none")
                    {
                        UnlockButton(LaBouleMagique);
                    }
                    OutToRichLog("Com", "Opening " + port.PortName + "...");
                    isConnected = true;
                    //    OutToRichLog("HTTP", "Trying to read txt file.. ");
                }
                catch (UnauthorizedAccessException unauth)
                {
                    OutToRichLog("Com", "Port is open somewhere else \n" + unauth);
                }
            }

            text_iSconnected.Text = port.IsOpen.ToString();
        }
Esempio n. 4
0
        private void DisableInputURLctrls()
        {
            string rawDomain = ACConfigManager.getValue("userdomain");
            //  string trimmDomain = rawDomain;

            Uri    myUri       = new Uri(rawDomain);
            string trimmDomain = myUri.Host;  // host is "www.contoso.com"

            Inp_Domain.Enabled = false;
            Inp_Domain.Text    = trimmDomain;
        }
Esempio n. 5
0
        /// <summary> Inp_NumericHours_ValueChanged
        /// C'est juste matrixant
        /// </summary>

        private void InputServerTime_TextChanged(object sender, EventArgs e)
        {
            var actualH  = InputServerTime.Text;
            var todouble = Int16.Parse(actualH);

            secondstoadd = TimeSpan.FromHours(todouble).TotalSeconds;
            ACConfigManager.AddUpdateAppSettings("servertime", secondstoadd.ToString());

            OutToRichLog("TEST", "customUserHours " + secondstoadd);
            Debug.WriteLine("timespantimespantimespan: " + secondstoadd);
        }
Esempio n. 6
0
        public MainWindow()
        {
            InitializeComponent();
            (new Arduistats.DropShadow()).ApplyShadows(this);
            OutToRichLog("Frame", "Starting engine...");
            InitBase();
            InitData();
            LockButton(LaBouleMagique);

            this.FormClosing += new FormClosingEventHandler(MainWindow_FormClosing);
            Debug.WriteLine(ACConfigManager.CheckIfValueExists());
        }
Esempio n. 7
0
        async Task <string> GetTxt()
        {
            //  string tamereee = userDomain;
            HttpClient client  = new HttpClient();
            string     _domain = ACConfigManager.getValue("userdomain");
            string     result  = await client.GetStringAsync(_domain);

            if (result != null)
            {
                //   ishttpConnected = true;
                // OutToRichLog("HTTP", "ITS OKAY FROM TASK : ");
            }
            return(result);
        }
Esempio n. 8
0
        private void InitData()
        {
            bool isDomainHere = ACConfigManager.CheckIfValueExists();

            if (isDomainHere == true)
            {
                UnlockButton(LaBouleMagique);
                btn_serielConnect.Enabled = true;
                string _serverTime = ACConfigManager.getValue("servertime");
                int    servtimeInt = Int16.Parse(_serverTime);
                int    hours       = servtimeInt / 3600;
                InputServerTime.Text = hours.ToString();
                //_servertime > convert hours > covert decimal
                // Inp_NumericHours.Value = _serverTime;
                string _consideroff = ACConfigManager.getValue("consideroff");
                string _timertick   = ACConfigManager.getValue("timertick");
                OutToRichLog("HTTP", "Get Config servertime : " + _serverTime);
                DisableInputURLctrls();
            }
            else
            {
                //DisableConnection();
            }
        }