public void CommitResult()
            {
                TempNode  tempNode  = File.TempNodes[memberName];
                TempValue tempValue = tempNode?[$"{path}/{index}"];

                tempValue?.Commit(Result);
            }
Beispiel #2
0
        private void Generate_Click(object sender, EventArgs e)
        {
            string str;

            do
            {
                str = GenerateCode(Settings.Commuter);
            } while (TempValue.Contains(str));
            TempValue[listBox.SelectedIndex] = str;
            SetText(str);
        }
Beispiel #3
0
 /// <summary>
 /// Tries to get the value associated with the key
 /// </summary>
 /// <param name="key">Key value</param>
 /// <param name="value">The values getting</param>
 /// <returns>True if it was able to get the value, false otherwise</returns>
 public bool TryGetValue(TKey key, out TValue[] value)
 {
     lock (LockObject)
     {
         if (Items.TryGetValue(key, out var TempValue))
         {
             value = TempValue.ToArray();
             return(true);
         }
         value = Array.Empty <TValue>();
         return(false);
     }
 }
Beispiel #4
0
 protected override void OnLostFocus(RoutedEventArgs e)
 {
     base.OnLostFocus(e);
     if (TempValue > Maximum)
     {
         TempValue = Maximum;
     }
     if (TempValue < Minimum)
     {
         TempValue = Minimum;
     }
     Value = TempValue;
     //skipNext = true;
     Text = TempValue.ToString();
     OnValueChanged();
 }
        public override void AddCharacter(char character)
        {
            if (TempValue.Length > 16)
            {
                return;
            }

            if (character == '.' && TempValue.Contains("."))
            {
                return;
            }


            if (TempValue == "0" && character != '.')
            {
                TempValue = "";
            }

            TempValue = TempValue + character;
        }
        private void frmSettings_Load(object sender, EventArgs e)
        {
            frmSettings_Resize("", EventArgs.Empty);
            // PerformAutoScale();

            UPSPollTimer           = new System.Timers.Timer(5000);
            UPSPollTimer.Elapsed  += new ElapsedEventHandler(OnTimedEvent);
            UPSPollTimer.AutoReset = true;
            bool IsConfigurationNeeded = false;

            // Checks to see if we are in a simulation environment
            if (Backend.Background.isSimulated)
            {
                chkSimulate.Checked = true;
            }
            else
            {
                // Narrows the form and hides the simulator panel
                frmSettings._frmSettings.Width = 483;
                pnlSimulator.Visible           = false;
                chkSimulate.Checked            = false;
            }

            // Constructing notify tray icon
            ntfUPSTray              = new NotifyIcon(this.components);
            ntfUPSTray.Visible      = true;
            ntfUPSTray.DoubleClick += new System.EventHandler(this.ntfUPSTray_DoubleClick);


            // Checks settings in the registry and fills in the fields accordingly

            Tuple <IPAddress, ushort, uint> NUTConnectionSettings = Backend.NUT_Config.GetConnectionSettings();

            if (NUTConnectionSettings.Item1 != IPAddress.Parse("127.0.0.1"))
            {
                txtIPAddress.Text = NUTConnectionSettings.Item1.ToString();
                NUTServer         = IPAddress.Parse(NUTConnectionSettings.Item1.ToString());
            }
            else
            {
                IsConfigurationNeeded = true;
            }

            if (NUTConnectionSettings.Item2 != 0)
            {
                txtPort.Text = NUTConnectionSettings.Item2.ToString();
                NUTPort      = Convert.ToUInt16(NUTConnectionSettings.Item2);
            }
            else
            {
                IsConfigurationNeeded = true;
            }

            if (NUTConnectionSettings.Item3 != 0)
            {
                txtPollFrequency.Text = NUTConnectionSettings.Item3.ToString();
                UPSPollTimer.Interval = (Convert.ToUInt32(NUTConnectionSettings.Item3) * 1000);
            }
            else
            {
                IsConfigurationNeeded = true;
            }

            string TempValue;
            uint   number;

            TempValue = Backend.NUT_Config.GetConfig("Warn Threshold");
            if (uint.TryParse(TempValue, out number))
            {
                AlarmPercentage           = Convert.ToUInt16(TempValue);
                cmbBatteryPercentage.Text = TempValue;
            }
            else
            {
                cmbBatteryPercentage.Text = "20%";
                AlarmPercentage           = 20;
            }

            TempValue = Backend.NUT_Config.GetConfig("Threshold Action");
            if (TempValue == null)
            {
                cmbAlarmAction.Text = "Hibernate";
            }
            else if (TempValue.Equals(""))
            {
                cmbAlarmAction.Text = "Hibernate";
            }
            else if (TempValue.Equals("Execute Script"))
            {
                cmbAlarmAction.Text   = "Execute Script";
                txtScriptPath.Text    = Backend.NUT_Config.GetConfig("Script Path");
                txtScriptPath.Enabled = true;
                btnBrowse.Enabled     = true;
            }
            else
            {
                cmbAlarmAction.Text = TempValue;
            }

            chkNotification.Checked = Convert.ToBoolean(Backend.NUT_Config.GetConfig("Notification"));
            chkAlarm.Checked        = Convert.ToBoolean(Backend.NUT_Config.GetConfig("Alarm"));
            chkDebugLogging.Checked = Convert.ToBoolean(Backend.NUT_Config.GetConfig("Debug"));

            if (chkNotification.Checked)
            {
                Backend.NUT_Config.SetConfig("Notification", "true");
            }
            else
            {
                Backend.NUT_Config.SetConfig("Notification", "false");
            }
            // Alarm
            if (chkAlarm.Checked)
            {
                Backend.NUT_Config.SetConfig("Alarm", "true");
            }
            else
            {
                Backend.NUT_Config.SetConfig("Alarm", "false");
            }
            // Debug Logging
            if (chkDebugLogging.Checked)
            {
                Backend.NUT_Config.SetConfig("Debug", "true");
            }
            else
            {
                Backend.NUT_Config.SetConfig("Debug", "false");
            }

            UPSPoll();

            if (Backend.Background.isSimulated)
            {
                SimulatorPopulate();
            }

            if (isPollingUPS)
            {
                pnlSettings.Enabled = true;
                pnlAlarms.Enabled   = true;
            }

            btnApply.Enabled     = false;
            UPSPollTimer.Enabled = true;
            UPSPollTimer.Start();

            if (IsConfigurationNeeded)
            {
                // If this is run for the first time, or the registry keys have been cleared it will bring up the
                // settings form to make it a bit more convenient for the user.
                _frmSettings.Show();
                _frmSettings.WindowState = FormWindowState.Normal;
            }
        }
Beispiel #7
0
 public override string ToDisplayString()
 {
     return(IsLocked ? Convert.ToString(value, 16).ToUpper() : TempValue.ToUpper());
 }