コード例 #1
0
        public UiEncodingLabeledNumber(string label, int width, int minValue, int maxValue, RoutedPropertyChangedEventHandler <object> onValueChanged)
        {
            _onValueChanged = onValueChanged;

            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            ColumnDefinitions.Add(new ColumnDefinition());

            Margin = new Thickness(5);

            UiTextBlock labelControl = UiTextBlockFactory.Create(label);

            {
                labelControl.Margin            = new Thickness(5, 5, 2, 5);
                labelControl.VerticalAlignment = VerticalAlignment.Center;
                AddUiElement(labelControl, 0, 0);
            }

            NumberControl = UiIntegerUpDownFactory.Create(minValue, maxValue);
            {
                NumberControl.Width         = width;
                NumberControl.Margin        = new Thickness(2, 5, 5, 5);
                NumberControl.ValueChanged += OnValueChanged;
                AddUiElement(NumberControl, 0, 1);
            }
        }
コード例 #2
0
        private void OnValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            int?newValue = (int?)e.NewValue;

            if (newValue == null)
            {
                UiIntegerUpDown control = (UiIntegerUpDown)sender;
                control.Value = (int?)e.OldValue ?? Math.Max((control.Minimum ?? 0), 0);
                return;
            }

            _onValueChanged?.Invoke(this, e);
        }
コード例 #3
0
        private void OnColValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (_source == null)
            {
                return;
            }

            int?newValue = (int?)e.NewValue;

            if (newValue == null)
            {
                UiIntegerUpDown control = (UiIntegerUpDown)sender;
                control.Value = (int?)e.OldValue ?? (control.Minimum ?? 0);
                return;
            }

            _source.Info.AdditionalTable[_index] = (short)((_source.Info.AdditionalTable[_index] & 0xFF00) | ((int)e.NewValue & 0x000000FF));
            DrawEvent.NullSafeSet();
        }
コード例 #4
0
        public UiEncodingLabeledNumber(string label, int width, int minValue, int maxValue, RoutedPropertyChangedEventHandler<object> onValueChanged)
        {
            _onValueChanged = onValueChanged;

            ColumnDefinitions.Add(new ColumnDefinition() {Width = GridLength.Auto});
            ColumnDefinitions.Add(new ColumnDefinition());

            Margin = new Thickness(5);

            UiTextBlock labelControl = UiTextBlockFactory.Create(label);
            {
                labelControl.Margin = new Thickness(5, 5, 2, 5);
                labelControl.VerticalAlignment = VerticalAlignment.Center;
                AddUiElement(labelControl, 0, 0);
            }

            NumberControl = UiIntegerUpDownFactory.Create(minValue, maxValue);
            {
                NumberControl.Width = width;
                NumberControl.Margin = new Thickness(2, 5, 5, 5);
                NumberControl.ValueChanged += OnValueChanged;
                AddUiElement(NumberControl, 0, 1);
            }
        }
コード例 #5
0
        public UiEncodingAdditionalCharacterControl()
        {
            Orientation       = Orientation.Horizontal;
            VerticalAlignment = VerticalAlignment.Center;

            #region Construct

            _indexLabel = UiTextBlockFactory.Create("#");
            {
                _indexLabel.Margin            = new Thickness(5);
                _indexLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(_indexLabel);
            }

            UiTextBlock rowLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.Row);
            {
                rowLabel.Margin            = new Thickness(5, 5, 2, 5);
                rowLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(rowLabel);
            }

            _rowNumber = UiIntegerUpDownFactory.Create(0, byte.MaxValue);
            {
                _rowNumber.Width         = 50;
                _rowNumber.Margin        = new Thickness(2, 5, 5, 5);
                _rowNumber.ValueChanged += OnRowValueChanged;
                Children.Add(_rowNumber);
            }

            UiTextBlock colLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.Column);
            {
                colLabel.Margin            = new Thickness(5, 5, 2, 5);
                colLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(colLabel);
            }

            _colNumber = UiIntegerUpDownFactory.Create(0, byte.MaxValue);
            {
                _colNumber.Width         = 50;
                _colNumber.Margin        = new Thickness(2, 5, 5, 5);
                _colNumber.ValueChanged += OnColValueChanged;
                Children.Add(_colNumber);
            }

            UiTextBlock outputLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.ToText);
            {
                outputLabel.Margin            = new Thickness(5, 5, 2, 5);
                outputLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(outputLabel);
            }

            _output = UiWatermarkTextBoxFactory.Create("0x31->\"1\"");
            {
                _output.Width        = 60;
                _output.Margin       = new Thickness(2, 5, 5, 5);
                _output.TextChanged += OnOutputTextChanged;
                Children.Add(_output);
            }

            UiTextBlock inputLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.FromText);
            {
                inputLabel.Margin            = new Thickness(5, 5, 2, 5);
                inputLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(inputLabel);
            }

            _input = UiWatermarkTextBoxFactory.Create("0x31<-\"1\"");
            {
                _input.Width        = 100;
                _input.Margin       = new Thickness(2, 5, 5, 5);
                _input.TextChanged += OnInputTextChanged;
                Children.Add(_input);
            }

            #endregion
        }
コード例 #6
0
        public UiEncodingAdditionalCharacterControl()
        {
            Orientation = Orientation.Horizontal;
            VerticalAlignment = VerticalAlignment.Center;

            #region Construct

            _indexLabel = UiTextBlockFactory.Create("#");
            {
                _indexLabel.Margin = new Thickness(5);
                _indexLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(_indexLabel);
            }

            UiTextBlock rowLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.Row);
            {
                rowLabel.Margin = new Thickness(5, 5, 2, 5);
                rowLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(rowLabel);
            }

            _rowNumber = UiIntegerUpDownFactory.Create(0, byte.MaxValue);
            {
                _rowNumber.Width = 50;
                _rowNumber.Margin = new Thickness(2, 5, 5, 5);
                _rowNumber.ValueChanged += OnRowValueChanged;
                Children.Add(_rowNumber);
            }

            UiTextBlock colLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.Column);
            {
                colLabel.Margin = new Thickness(5, 5, 2, 5);
                colLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(colLabel);
            }

            _colNumber = UiIntegerUpDownFactory.Create(0, byte.MaxValue);
            {
                _colNumber.Width = 50;
                _colNumber.Margin = new Thickness(2, 5, 5, 5);
                _colNumber.ValueChanged += OnColValueChanged;
                Children.Add(_colNumber);
            }

            UiTextBlock outputLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.ToText);
            {
                outputLabel.Margin = new Thickness(5, 5, 2, 5);
                outputLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(outputLabel);
            }

            _output = UiWatermarkTextBoxFactory.Create("0x31->\"1\"");
            {
                _output.Width = 60;
                _output.Margin = new Thickness(2, 5, 5, 5);
                _output.TextChanged += OnOutputTextChanged;
                Children.Add(_output);
            }

            UiTextBlock inputLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.FromText);
            {
                inputLabel.Margin = new Thickness(5, 5, 2, 5);
                inputLabel.VerticalAlignment = VerticalAlignment.Center;
                Children.Add(inputLabel);
            }

            _input = UiWatermarkTextBoxFactory.Create("0x31<-\"1\"");
            {
                _input.Width = 100;
                _input.Margin = new Thickness(2, 5, 5, 5);
                _input.TextChanged += OnInputTextChanged;
                Children.Add(_input);
            }

            #endregion
        }