Inheritance: INotifyPropertyChanged
示例#1
0
文件: Input.cs 项目: ValdimarThor/X
        protected override void OnApplyTemplate()
        {
            if (_model == null)
            {
                _model = new InputModel();
            }

            if (_grdRoot == null) {
                _grdRoot = GetTemplateChild("grdRoot") as Grid;
                _grdRoot.DataContext = _model;
            }

            if (_GeneralTextBoxStyle == null)
            {
                _GeneralTextBoxStyle = (Style)_grdRoot.Resources["GeneralTextBoxStyle"];
            }

            if (_GeneralPasswordBoxStyle == null)
            {
                _GeneralPasswordBoxStyle = (Style)_grdRoot.Resources["GeneralPasswordBoxStyle"];
            }

            if (_GeneralCheckBoxStyle == null)
            {
                _GeneralCheckBoxStyle = (Style)_grdRoot.Resources["GeneralCheckBoxStyle"];
            }

            if (_GeneralRadioButtonStyle == null)
            {
                _GeneralRadioButtonStyle = (Style)_grdRoot.Resources["GeneralRadioButtonStyle"];
            }

            if (_ccInput == null) {
                _ccInput = GetTemplateChild("ccInput") as ContentControl;
                
                BuildControl(Type, Label, PlaceholderText, LabelFontSize, LabelTranslateY, GroupName, _ccInput);
                SetColors(FocusColor, FocusHoverColor, FocusForegroundColor, _model);
            }
            
            base.OnApplyTemplate();
        }
示例#2
0
        protected override void OnApplyTemplate()
        {
            if (_model == null)
            {
                _model = new InputModel();
            }

            if (_grdRoot == null)
            {
                _grdRoot = GetTemplateChild("grdRoot") as Grid;
                _grdRoot.DataContext = _model;
            }

            if (_GeneralComboBoxItemStyle == null)
            {
                _GeneralComboBoxItemStyle = (Style)_grdRoot.Resources["GeneralComboBoxItemStyle"];
            }

            this.Style = _GeneralComboBoxItemStyle;


            base.OnApplyTemplate();
        }
示例#3
0
文件: Input.cs 项目: ValdimarThor/X
        private void UnloadControl(InputType type)
        {

            if (type == InputType.text)
            {
                var gd = (Grid)_ccInput.Content;
                var tb = (TextBox)gd.Children[1];
                tb.KeyUp -= ittext_KeyUp;
            }
            else if (type == InputType.password)
            {
                var gd = (Grid)_ccInput.Content;
                var tb = (PasswordBox)gd.Children[1];
                tb.PasswordChanged -= itpassword_PasswordChanged;
            }
            else if (type == InputType.checkbox)
            {
                var sp = (StackPanel)_ccInput.Content;
                var cb = (CheckBox)sp.Children[0];
                cb.Checked -= itcheckbox_Checked;
            }
            else if (type == InputType.radio)
            {
                var sp = (StackPanel)_ccInput.Content;
                var cb = (RadioButton)sp.Children[0];
                cb.Checked -= itradio_Checked;
            }

            if (_udfg1 != null)
            {
                _udfg1 = null;
                _udfg1.Children.Clear();
            }
            

            _udfTB1 = null;
            _udfTBL1 = null;
            

            _ccInput.Content = null;

            _model = null;

        }
示例#4
0
文件: Input.cs 项目: ValdimarThor/X
        private void SetColors(Color focusColor, Color focusHoverColor, Color focusForegroundColor, InputModel model) {

            model.FocusColor = focusColor;
            model.FocusHoverColor = focusHoverColor;
            model.FocusForegroundColor = focusForegroundColor;

            if (_udfg1 != null) {
                _udfg1.Background = new SolidColorBrush(focusColor);
                if (_udfTBL1 != null) _udfTBL1.Foreground = new SolidColorBrush(focusForegroundColor);
            }
        }
示例#5
0
文件: Input.cs 项目: liquidboy/X
        private void UnloadControl(InputType type)
        {

            if (type == InputType.text)
            {
                _udfTB1.KeyUp -= ittext_KeyUp;
                
            }
            else if (type == InputType.password)
            {
                _udfPB1.PasswordChanged -= itpassword_PasswordChanged;
            }
            else if (type == InputType.checkbox)
            {

            }
            else if (type == InputType.radio)
            {

            }
            else if (type == InputType.combobox)
            {
                if (_ccInput != null) {
                    var sp = (Grid)_ccInput.Content;
                    var cb = (ComboBox)sp.Children[1];
                    cb.SelectionChanged -= itcombobox_SelectionChanged;
                    Value2 = null;
                    //if (cb.Items != null && cb.Items.Count > 0) cb.Items.Clear();
                    //if (cb.ItemsSource != null) cb.ItemsSource = null;
                }
            }
            if (_udfTS1 != null) {
                _udfTS1.Toggled -= ittoggleswitch_Toggled;
            }
            if (_udfProgBr1 != null)
            {
                _udfProgBr1.ValueChanged -= itProgBr_ValueChanged;
            }
            if (_udfSl1 != null)
            {
                _udfSl1.ValueChanged -= itSl_ValueChanged;
            }
            if (_udfRB1 != null)
            {
                _udfRB1.Checked -= itradio_Changed;
                _udfRB1.Unchecked -= itradio_Changed;
            }
            if (_udfChkB1 != null)
            {
                _udfChkB1.Checked -= itcheckbox_Changed;
                _udfChkB1.Unchecked -= itcheckbox_Changed;
            }
            if (_udfTBut1 != null)
            {
                _udfTBut1.Checked -= ittogglebutton_changed;
                _udfTBut1.Unchecked -= ittogglebutton_changed;
            }
            if (_udfProgRn1 != null)
            {
                _udfProgRn1.IsActive = false;
            }
            if (_udfg1 != null)
            {
                _udfg1.Children.Clear();
                _udfg1 = null;
            }

            if (dtInvalidate != null) {
                dtInvalidate.Stop();
                dtInvalidate.Tick += DtInvalidate_Tick;
            }

            _sbHideBgLayer?.Stop();
            _sbHideBgLayer = null;
            _sbShowBgLayer?.Stop();
            _sbShowBgLayer = null;

            _udfProgBr1 = null;
            _udfPB1 = null;
            _udfTB1 = null;
            _udfTBL1 = null;
            _udfCB1 = null;
            _udfChkB1 = null;
            _udfRB1 = null;
            _udfTS1 = null;
            _udfProgRn1 = null;
            _udfTBut1 = null;
            dtInvalidate = null;
            if (_ccInput != null && _ccInput.Content != null) _ccInput.Content = null;
            if (_ccInput != null) _ccInput = null;
            _grdContainer = null;
            if (_grdRoot != null) { _grdRoot.DataContext = null; _grdRoot = null; }
            _model = null;
            hasInitialized = false;
        }
示例#6
0
文件: Input.cs 项目: liquidboy/X
        private async void SetColors(Color focusColor, Color focusHoverColor, Color focusForegroundColor, InputModel model) 
        {
            try {
                model.FocusColor = focusColor;
                model.FocusHoverColor = focusHoverColor;
                model.FocusForegroundColor = focusForegroundColor;

                if (_udfg1 != null) _udfg1.Background = new SolidColorBrush(focusColor);
                if (_udfCB1 != null)
                {
                    _udfCB1.BorderBrush = new SolidColorBrush(focusColor);
                    _udfCB1.Foreground = new SolidColorBrush(focusColor);
                    //var border = _udfCB1.FindName("PopupBorder") as Border;
                    //if (border != null) {
                    //    border.Background = new SolidColorBrush(focusColor);
                    //    border.BorderBrush = new SolidColorBrush(focusColor);
                    //}                
                }

                if (_udfTB1 != null)
                {
                    _udfTB1.Foreground = new SolidColorBrush(focusColor);
                    _udfTB1.BorderBrush = new SolidColorBrush(focusColor);
                }

                if (_udfPB1 != null)
                {
                    _udfPB1.Foreground = new SolidColorBrush(focusColor);
                    _udfPB1.BorderBrush = new SolidColorBrush(focusColor);
                }

                if (_udfChkB1 != null)
                {
                    _udfChkB1.Foreground = new SolidColorBrush(focusColor);
                }

                if (_udfRB1 != null)
                {
                    _udfRB1.Foreground = new SolidColorBrush(focusColor);
                }

                if (_udfProgBr1 != null)
                {
                    _udfProgBr1.Foreground = new SolidColorBrush(focusColor);
                    _udfProgBr1.Background = new SolidColorBrush(focusHoverColor);
                }
                if (_udfTBut1 != null)
                {
                    _udfTBut1.Foreground = new SolidColorBrush(focusForegroundColor);
                    _udfTBut1.Background = new SolidColorBrush(focusColor);
                }
                if (_udfTS1 != null)
                {
                    _udfTS1.Foreground = new SolidColorBrush(focusColor);
                    _udfTS1.Background = new SolidColorBrush(focusHoverColor);
                }
                if (_udfSl1 != null)
                {
                    _udfSl1.Foreground = new SolidColorBrush(focusColor);
                    _udfSl1.Background = new SolidColorBrush(focusHoverColor);
                }

                if (_udfProgRn1 != null)
                {
                    _udfProgRn1.Foreground = new SolidColorBrush(focusColor);
                }

                if (Type == InputType.text || Type == InputType.password || Type == InputType.combobox)
                {
                    if (_udfTBL1 != null) _udfTBL1.Foreground = new SolidColorBrush(focusForegroundColor);
                }

                //if (_udfg1 != null) _udfg1.SetBinding(Grid.BackgroundProperty, new Binding() { Path = new PropertyPath("FocusColor") });
                //if (_udfCB1 != null) _udfCB1.SetBinding(ComboBox.ForegroundProperty , new Binding() { Path = new PropertyPath("FocusColor") });

                //if (Type == InputType.text || Type == InputType.password || Type == InputType.combobox)
                //{
                //    if (_udfTBL1 != null) _udfTBL1.SetBinding(TextBlock.ForegroundProperty, new Binding() { Path = new PropertyPath("FocusForegroundColor") });
                //}
            }
            catch (Exception ex){

            }
            
        }
示例#7
0
文件: Input.cs 项目: liquidboy/X
        private void oneTimeInit() {
            if (hasInitialized) return;
            if (_model == null) _model = new InputModel();

            //if (_bkgLayer == null) _bkgLayer = GetTemplateChild("bkgLayer") as EffectLayer.EffectLayer;
            if (_grdContainer == null) _grdContainer = GetTemplateChild("grdContainer") as Grid;

            if (_grdRoot == null) _grdRoot = GetTemplateChild("grdRoot") as Grid;

            if (_grdRoot != null) { 
                _grdRoot.DataContext = _model;
            
                if (_GeneralTextBoxStyle == null) _GeneralTextBoxStyle = (Style)_grdRoot.Resources["GeneralTextBoxStyle"];
                if (_GeneralPasswordBoxStyle == null) _GeneralPasswordBoxStyle = (Style)_grdRoot.Resources["GeneralPasswordBoxStyle"];
                if (_GeneralCheckBoxStyle == null) _GeneralCheckBoxStyle = (Style)_grdRoot.Resources["GeneralCheckBoxStyle"];
                if (_GeneralRadioButtonStyle == null) _GeneralRadioButtonStyle = (Style)_grdRoot.Resources["GeneralRadioButtonStyle"];
                if (_GeneralComboBoxStyle == null) _GeneralComboBoxStyle = (Style)_grdRoot.Resources["GeneralComboBoxStyle"];
                if (_GeneralToggleSwitchStyle == null) _GeneralToggleSwitchStyle = (Style)_grdRoot.Resources["GeneralToggleSwitchStyle"];
                if (_GeneralProgressBarStyle == null) _GeneralProgressBarStyle = (Style)_grdRoot.Resources["GeneralProgressBarStyle"];
                if (_GeneralProgressRingStyle == null) _GeneralProgressRingStyle = (Style)_grdRoot.Resources["GeneralProgressRingStyle"];
                if (_GeneralSliderStyle == null) _GeneralSliderStyle = (Style)_grdRoot.Resources["GeneralSliderStyle"];
                if (_GeneralToggleButtonStyle == null) _GeneralToggleButtonStyle = (Style)_grdRoot.Resources["GeneralToggleButtonStyle"];
            }

            if (_sbHideBgLayer == null & _grdContainer != null)
            {
                _sbHideBgLayer = (Storyboard)_grdContainer.Resources["sbHideBgLayer"];
                _sbShowBgLayer = (Storyboard)_grdContainer.Resources["sbShowBgLayer"];
            }
            
            if (_ccInput == null)
            {
                _ccInput = GetTemplateChild("ccInput") as ContentControl;

                if (_ccInput != null) BuildControl(Type, Label, PlaceholderText, LabelFontSize, LabelTranslateY, GroupName, _ccInput);
                SetColors(FocusColor, FocusHoverColor, FocusForegroundColor, _model);
                //SetColors();
            }

            if (Type == InputType.toggleSwitch || Type == InputType.toggleButton || Type == InputType.progress || Type == InputType.progressRing || Type == InputType.slider || Type == InputType.progressRing)
            {
                dtInvalidate = new DispatcherTimer();
                dtInvalidate.Interval = TimeSpan.FromMilliseconds(InvalidateUpdateInterval);
                dtInvalidate.Tick += DtInvalidate_Tick;
            }

            //var effectType = EffectLayer.EffectGraphType.Glow;
            //if (Type == InputType.radio || Type == InputType.checkbox)
            //{
            //    bkgOffsetY = 2;
            //    bkgOffsetX = 0;
            //}
            //else if (Type == InputType.toggleButton)
            //{
            //    bkgOffsetY = 1;
            //    bkgOffsetX = 1;
            //}

            //if (_bkgLayer != null && _grdRoot != null && _grdRoot.ActualWidth != 0) _bkgLayer.InitLayer(_grdRoot.ActualWidth, _grdRoot.ActualHeight, bkgOffsetX, bkgOffsetY, effectType);

            if (_grdContainer != null) hasInitialized = true;
        }