Ejemplo n.º 1
0
        private bool uploadSettingsAdv()
        {
            int count = 0;
            var cmd   = new SetRegistersCommand(_appState, _commsPort);

            foreach (CustomRegisterSettingControl control in _customSettings)
            {
                if (control.RegisterEnabled)
                {
                    if (!cmd.Register.ContainsKey(control.Register))
                    {
                        cmd.Register.Add(control.Register, control.Value);
                        count++;
                    }
                    else
                    {
                        MessageBox.Show(this,
                                        string.Format("Register {0} is included more than once.  Upload aborted",
                                                      control.Register), ProductName, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        return(false);
                    }
                }
            }
            if (count <= 0)
            {
                MessageBox.Show(this, "No registers are checked.  Nothing to upload.", ProductName,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            btnUploadRegistersAdv.Enabled = false;
            btnUploadRegistersAdv.Refresh();
            lbMessageAdv.Text      = "Uploading settings";
            lbMessageAdv.ForeColor = Color.Black;
            lbMessageAdv.Refresh();

            cmd.Execute();

            bool isOk = cmd.IsSuccessful;

            if (isOk)
            {
                //save the settings
                var settings = new List <string>();
                foreach (CustomRegisterSettingControl control in _customSettings)
                {
                    settings.Add(control.GetConfigSetting());
                }
                Settings.Default.CustomRegisters = string.Join(":", settings.ToArray());
            }

            lbMessageAdv.Text             = isOk ? "Upload succeeded" : cmd.ErrorDescription;
            lbMessageAdv.ForeColor        = isOk ? Color.Black : Color.Red;
            _isChangeUploadedAdv          = isOk;
            btnUploadRegistersAdv.Enabled = true;
            return(isOk);
        }
Ejemplo n.º 2
0
        private bool sendSetRegisterCommand(out string error)
        {
            SetRegistersCommand cmd = new SetRegistersCommand(_appState, _commsPort);

            cmd.IsAutoWhiteBalance        = cbUseAutoWhiteBalance.Checked;
            cmd.IsAutoAdjustMode          = cbUseAutoAdjust.Checked;
            cmd.HasFlourescentLightFilter = cbUseFlourescentLightFilter.Checked;
            cmd.Execute();

            bool isOk = cmd.IsSuccessful;

            if (isOk)
            {
                //save the settings
                Settings settings = Settings.Default;
                settings.AutoWhiteBalance       = cbUseAutoWhiteBalance.Checked;
                settings.AutoAdjustMode         = cbUseAutoAdjust.Checked;
                settings.FlourescentLightFilter = cbUseFlourescentLightFilter.Checked;
                settings.Save();
            }
            error = cmd.ErrorDescription;
            return(isOk);
        }