Esempio n. 1
0
        public UpdateView(Rectangle position, string msg, string comPortName, SketchVersion oldVersion)
        {
            _parentWindowsPosition = position;

            InitializeComponent();

            _sketchList.ReadSketchList();
            _latestVersion = _sketchList.GetLatestVersion(oldVersion);

            MessageLbl.Text = "";

            if (oldVersion != null)
            {
                OldVersion.Text = $"{oldVersion.DisplayName} Tapecart Flasher v{oldVersion.VerStr}";
            }
            else
            {
                OldVersion.Text = "---";
            }

            if (_latestVersion != null)
            {
                NewVersion.Text = $"{_latestVersion.DisplayName} Tapecart Flasher v{_latestVersion.VerStr}";
            }
            else
            {
                NewVersion.Text = "---";
                _latestVersion  = _sketchList.GetLatestVersion(oldVersion, true);
            }

            UpdateProgress(0.0);

            // die Zuweisung an DataSource löst SelectedIndexChanged aus und überschreibt _latestVersion
            // work around:
            BoardTypeCb.Items.Clear();
            foreach (SketchVersion f in _sketchList.SketchVersions)
            {
                BoardTypeCb.Items.Add(f);
            }

            BoardTypeCb.SelectedItem  = _latestVersion;
            BoardTypeCb.DisplayMember = "DisplayName";
            if (oldVersion != null)
            {
                BoardTypeCb.Enabled = false;
            }

            _comPortName = comPortName;
        }
Esempio n. 2
0
        private async void ConnectBtn_Click(object sender, EventArgs e)
        {
            if (_selectedComPort == null)
            {
                return;
            }

            _logging.Info(MODUL_NAME, "ConnectBtn_Click", $"Connecting to {_arduinoComm.CurrentParameter}");

            FlasherVersionTb.Text  = "";
            TapecartVersionTb.Text = "";

            if (_arduinoComm.Connected)
            {
                _arduinoComm.DeInit();
                ConnectBtn.Text      = "Connect";
                ConnectBtn.ForeColor = Color.Black;
                SetButtonStatus();
                DetectBtn.Enabled  = true;
                ConnectBtn.Enabled = true;
                return;
            }

            DetectBtn.Enabled  = false;
            ConnectBtn.Enabled = false;

            string btnText = ConnectBtn.Text;

            ConnectBtn.Text      = "Connecting...";
            ConnectStateLbl.Text = "";
            ConnectBtn.Refresh();

            bool success = false;
            await Task.Run(() => {
                success = Connect();
            });

            if (success)
            {
                _logging.Info(MODUL_NAME, "ConnectBtn_Click", $"Connected");
            }
            else
            {
                _arduinoComm.DeInit();
            }

            SetButtonStatus();

            SketchVersion latest = _sketchList.GetLatestVersion(_currentSketchVersion);

            if (latest != null)
            {
                AskForSketchUpdate(latest);
            }
        }