Пример #1
0
        private void DigitClickHandler(object sender, FrequencyEditDigitClickEventArgs args)
        {
            if (this._currentEntryMode != EntryMode.None)
            {
                this.LeaveEntryMode();
                return;
            }
            FrequencyEditDigit frequencyEditDigit = (FrequencyEditDigit)sender;

            if (frequencyEditDigit != null)
            {
                this._newFrequency = this._frequency;
                if (args.Button == MouseButtons.Right)
                {
                    this.ZeroDigits(frequencyEditDigit.DigitIndex);
                }
                else if (args.IsUpperHalf && this._frequency >= 0L)
                {
                    this.IncrementDigit(frequencyEditDigit.DigitIndex, true);
                }
                else
                {
                    this.DecrementDigit(frequencyEditDigit.DigitIndex, true);
                }
                if (this._newFrequency != this._frequency)
                {
                    this._frequencyChangingEventArgs.Accept    = true;
                    this._frequencyChangingEventArgs.Frequency = this._newFrequency;
                    if (!this._disableFrequencyEvents && this.FrequencyChanging != null)
                    {
                        this.FrequencyChanging(this, this._frequencyChangingEventArgs);
                    }
                    if (this._frequencyChangingEventArgs.Accept)
                    {
                        this._frequency = this._frequencyChangingEventArgs.Frequency;
                        this.UpdateDigitsValues();
                        if (!this._disableFrequencyEvents && this.FrequencyChanged != null)
                        {
                            this.FrequencyChanged(this, EventArgs.Empty);
                            return;
                        }
                    }
                    else
                    {
                        this.UpdateDigitsValues();
                    }
                }
            }
        }
Пример #2
0
        private void DecrementDigit(int index, bool updateDigit)
        {
            FrequencyEditDigit frequencyEditDigit = this._digitControls[index];

            if (frequencyEditDigit != null)
            {
                int  displayedDigit = frequencyEditDigit.DisplayedDigit;
                int  num            = (frequencyEditDigit.DisplayedDigit == 0) ? 9 : (frequencyEditDigit.DisplayedDigit - 1);
                long newFrequency   = this._newFrequency - (long)displayedDigit * frequencyEditDigit.Weight + (long)num * frequencyEditDigit.Weight;
                if (updateDigit)
                {
                    frequencyEditDigit.DisplayedDigit = num;
                }
                this._newFrequency = newFrequency;
                if (displayedDigit == 0 && index < 11 && (double)this._newFrequency > Math.Pow(10.0, (double)(index + 1)))
                {
                    this.DecrementDigit(index + 1, updateDigit);
                }
            }
        }
Пример #3
0
        private void IncrementDigit(int index, bool updateDigit)
        {
            FrequencyEditDigit frequencyEditDigit = this._digitControls[index];

            if (frequencyEditDigit != null)
            {
                int  displayedDigit = frequencyEditDigit.DisplayedDigit;
                int  num            = (frequencyEditDigit.DisplayedDigit == 9) ? 0 : (frequencyEditDigit.DisplayedDigit + 1);
                long newFrequency   = this._newFrequency - (long)displayedDigit * frequencyEditDigit.Weight + (long)num * frequencyEditDigit.Weight;
                if (updateDigit)
                {
                    frequencyEditDigit.DisplayedDigit = num;
                }
                this._newFrequency = newFrequency;
                if (displayedDigit == 9 && index < 11)
                {
                    this.IncrementDigit(index + 1, updateDigit);
                }
            }
        }
Пример #4
0
        private void ConfigureComponent()
        {
            BackColor = Color.Transparent;

            if (_digitImages != null)
            {
                for (var i = 0; i < DigitCount; i++)
                {
                    if (_digitControls[i] != null && Controls.Contains(_digitControls[i]))
                    {
                        Controls.Remove(_digitControls[i]);
                        _digitControls[i] = null;
                    }
                }
                for (var i = 0; i < DigitSeperatorCount; i++)
                {
                    if (_separatorControls[i] != null && Controls.Contains(_separatorControls[i]))
                    {
                        Controls.Remove(_separatorControls[i]);
                        _separatorControls[i] = null;
                    }
                }

                SplitDigitImages();
            }

            if (_imageList.Images.Count == 0)
            {
                return;
            }

            var xPos = 0;
            var yPos = 0;

            var digitWidth  = _imageList.ImageSize.Width + _imageList.ImageSize.Width / 10;
            var digitHeight = _imageList.ImageSize.Height + _imageList.ImageSize.Height / 10;

            for (var i = DigitCount - 1; i >= 0; i--)
            {
                if ((i + 1) % 3 == 0 && i != DigitCount - 1)
                {
                    var separator      = new FrequencyEditSeparator();
                    var seperatorWidth = digitWidth / 2;
                    var seperatorIndex = i / 3;

                    separator.Image    = _imageList.Images[11];
                    separator.Width    = seperatorWidth;
                    separator.Height   = digitHeight;
                    separator.Location = new Point(xPos, yPos);
                    Controls.Add(separator);

                    _separatorControls[seperatorIndex] = separator;

                    xPos += seperatorWidth + 2;
                }

                var frequencyEditDigit = new FrequencyEditDigit(i);

                frequencyEditDigit.Location      = new Point(xPos, yPos);
                frequencyEditDigit.OnDigitClick += DigitClickHandler;
                frequencyEditDigit.MouseLeave   += DigitMouseLeave;

                frequencyEditDigit.Width     = digitWidth;
                frequencyEditDigit.Height    = digitHeight;
                frequencyEditDigit.ImageList = _imageList;

                Controls.Add(frequencyEditDigit);
                _digitControls[i] = frequencyEditDigit;

                xPos += digitWidth + 2;
            }

            long weight = 1L;

            for (var i = 0; i < DigitCount; i++)
            {
                _digitControls[i].Weight = weight;
                weight *= 10;
            }
            Height = digitHeight;

            UpdateDigitMask();
        }
        private void ConfigureComponent()
        {
            BackColor = Color.Transparent;

            if (_digitImages != null)
            {
                for(var i = 0 ; i < DigitCount ; i++)
                {
                    if (_digitControls[i] != null && Controls.Contains(_digitControls[i]))
                    {
                        Controls.Remove(_digitControls[i]);
                        _digitControls[i] = null;
                    }
                }
                for(var i = 0 ; i < DigitSeperatorCount; i++)
                {
                    if(_separatorControls[i] != null && Controls.Contains(_separatorControls[i]))
                    {
                        Controls.Remove(_separatorControls[i]);
                        _separatorControls[i] = null;
                    }
                }

                SplitDigitImages();
            }

            if (_imageList.Images.Count == 0)
            {
                return;
            }

            var xPos = 0;
            var yPos = 0;

            var digitWidth = _imageList.ImageSize.Width;
            var digitHeight = _imageList.ImageSize.Height;

            for (var i = DigitCount-1; i >= 0; i--)
            {
                if ((i + 1) % 3 == 0 && i != DigitCount - 1)
                {
                    var separator = new FrequencyEditSeparator();
                    var seperatorWidth = digitWidth / 2;
                    var seperatorIndex = i / 3;

                    separator.Image = _imageList.Images[11];
                    separator.Width = seperatorWidth;
                    separator.Height = digitHeight;
                    separator.Location = new Point(xPos, yPos);
                    Controls.Add(separator);

                    _separatorControls[seperatorIndex] = separator;

                    xPos += seperatorWidth + 2;
                }

                var frequencyEditDigit = new FrequencyEditDigit(i);

                frequencyEditDigit.Location = new Point(xPos, yPos);
                frequencyEditDigit.OnDigitClick += DigitClickHandler;
                frequencyEditDigit.MouseLeave += DigitMouseLeave;

                frequencyEditDigit.Width = digitWidth;
                frequencyEditDigit.Height = digitHeight;
                frequencyEditDigit.ImageList = _imageList;

                Controls.Add(frequencyEditDigit);
                _digitControls[i] = frequencyEditDigit;

                xPos += digitWidth + 2;
            }

            long weight = 1L;
            for (var i = 0; i < DigitCount; i++)
            {
                _digitControls[i].Weight = weight;
                weight *= 10;
            }
            Height = digitHeight;

            UpdateDigitMask();
        }
Пример #6
0
 private void ConfigureComponent()
 {
     this.BackColor = Color.Transparent;
       if (this._digitImages != null)
       {
     for (int index = 0; index < 12; ++index)
     {
       if (this._digitControls[index] != null && this.Controls.Contains((Control) this._digitControls[index]))
       {
     this.Controls.Remove((Control) this._digitControls[index]);
     this._digitControls[index] = (FrequencyEditDigit) null;
       }
     }
     for (int index = 0; index < 12; ++index)
     {
       if (this._separatorControls[index] != null && this.Controls.Contains((Control) this._separatorControls[index]))
       {
     this.Controls.Remove((Control) this._separatorControls[index]);
     this._separatorControls[index] = (FrequencyEditSeparator) null;
       }
     }
     this.SplitDigitImages();
       }
       if (this._imageList.Images.Count == 0)
     return;
       int x = 0;
       int y = 0;
       int width = this._imageList.ImageSize.Width;
       int height = this._imageList.ImageSize.Height;
       for (int digitIndex = 11; digitIndex >= 0; --digitIndex)
       {
     if ((digitIndex + 1) % 3 == 0 && digitIndex != 11)
     {
       FrequencyEditSeparator frequencyEditSeparator = new FrequencyEditSeparator();
       int num = width / 2;
       int index = digitIndex / 3;
       frequencyEditSeparator.Image = this._imageList.Images[11];
       frequencyEditSeparator.Width = num;
       frequencyEditSeparator.Height = height;
       frequencyEditSeparator.Location = new Point(x, y);
       this.Controls.Add((Control) frequencyEditSeparator);
       this._separatorControls[index] = frequencyEditSeparator;
       x += num + 2;
     }
     FrequencyEditDigit frequencyEditDigit = new FrequencyEditDigit(digitIndex);
     frequencyEditDigit.Location = new Point(x, y);
     frequencyEditDigit.OnDigitClick += new OnDigitClickDelegate(this.DigitClickHandler);
     frequencyEditDigit.MouseLeave += new EventHandler(this.DigitMouseLeave);
     frequencyEditDigit.Width = width;
     frequencyEditDigit.Height = height;
     frequencyEditDigit.ImageList = this._imageList;
     this.Controls.Add((Control) frequencyEditDigit);
     this._digitControls[digitIndex] = frequencyEditDigit;
     x += width + 2;
       }
       long num1 = 1L;
       for (int index = 0; index < 12; ++index)
       {
     this._digitControls[index].Weight = num1;
     num1 *= 10L;
       }
       this.Height = height;
       this.UpdateDigitMask();
 }
Пример #7
0
        private void ConfigureComponent()
        {
            this.BackColor = Color.Transparent;
            if (this._digitImages != null)
            {
                for (int i = 0; i < 12; i++)
                {
                    if (this._digitControls[i] != null && base.Controls.Contains(this._digitControls[i]))
                    {
                        base.Controls.Remove(this._digitControls[i]);
                        this._digitControls[i] = null;
                    }
                }
                for (int j = 0; j < 12; j++)
                {
                    if (this._separatorControls[j] != null && base.Controls.Contains(this._separatorControls[j]))
                    {
                        base.Controls.Remove(this._separatorControls[j]);
                        this._separatorControls[j] = null;
                    }
                }
                this.SplitDigitImages();
            }
            if (this._imageList.Images.Count == 0)
            {
                return;
            }
            int num    = 0;
            int y      = 0;
            int width  = this._imageList.ImageSize.Width;
            int height = this._imageList.ImageSize.Height;

            for (int k = 11; k >= 0; k--)
            {
                if ((k + 1) % 3 == 0 && k != 11)
                {
                    FrequencyEditSeparator frequencyEditSeparator = new FrequencyEditSeparator();
                    int num2 = width / 2;
                    int num3 = k / 3;
                    frequencyEditSeparator.Image    = this._imageList.Images[11];
                    frequencyEditSeparator.Width    = num2;
                    frequencyEditSeparator.Height   = height;
                    frequencyEditSeparator.Location = new Point(num, y);
                    base.Controls.Add(frequencyEditSeparator);
                    this._separatorControls[num3] = frequencyEditSeparator;
                    num += num2 + 2;
                }
                FrequencyEditDigit frequencyEditDigit = new FrequencyEditDigit(k);
                frequencyEditDigit.Location      = new Point(num, y);
                frequencyEditDigit.OnDigitClick += this.DigitClickHandler;
                frequencyEditDigit.MouseLeave   += this.DigitMouseLeave;
                frequencyEditDigit.Width         = width;
                frequencyEditDigit.Height        = height;
                frequencyEditDigit.ImageList     = this._imageList;
                base.Controls.Add(frequencyEditDigit);
                this._digitControls[k] = frequencyEditDigit;
                num += width + 2;
            }
            long num4 = 1L;

            for (int l = 0; l < 12; l++)
            {
                this._digitControls[l].Weight = num4;
                num4 *= 10L;
            }
            base.Height = height;
            this.UpdateDigitMask();
        }