Exemplo n.º 1
0
 /// <summary>
 /// Called when the behavior is being detached from its AssociatedObject, but
 /// before it has actually occurred.
 /// </summary>
 /// <remarks>
 /// Override this to unhook functionality from the AssociatedObject.
 /// </remarks>
 protected override void OnDetaching()
 {
     ClearHighlight();
     _textChangeEventSource.ValueChanged -= TextChanged;
     _textChangeEventSource = null;
     base.OnDetaching();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Called after the behavior is attached to an AssociatedObject.
 /// </summary>
 /// <remarks>
 /// Override this to hook up functionality to the AssociatedObject.
 /// </remarks>
 protected override void OnAttached()
 {
     UpdateHighlight();
     _textChangeEventSource = new PropertyChangeEventSource <string>(this.AssociatedObject, "Text", BindingMode.OneWay);
     _textChangeEventSource.ValueChanged += TextChanged;
     base.OnAttached();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus            += OnGotFocus;
            this.LostFocus           += OnLostFocus;
            this.PointerWheelChanged += OnPointerWheelChanged;
            _valueTextBox             = GetTemplateChild(ValueTextBoxName) as TextBlock;
            _dragOverlay              = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton          = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton          = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;

            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus     += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus      += OnValueTextBoxGotFocus;
                _valueTextBox.Text           = Value.ToString();
                _valueTextBox.KeyDown       += OnValueTextBoxKeyDown;
                _valueTextBox.PointerExited += OnValueTextBoxPointerExited;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource <bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource <bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }
Exemplo n.º 4
0
        //private readonly PropertyChangeEventSource<DataTemplate> _contentTemplateChangeHandler;
        //private readonly PropertyChangeEventSource<DataTemplateSelector> _contentTemplateSelectorChangeHandler;

        public EditableListBoxItem()
        {
            DefaultStyleKey          = typeof(EditableListBoxItem);
            this.Loaded             += OnLoaded;
            this.Unloaded           += OnUnloaded;
            _isSelectedChangeHandler =
                new PropertyChangeEventSource <bool>(
                    this,
                    "IsSelected",
                    BindingMode.OneWay);
            //_contentTemplateChangeHandler =
            //    new PropertyChangeEventSource<DataTemplate>(
            //        this,
            //        "ContentTemplate",
            //        BindingMode.OneWay);
            //_contentTemplateSelectorChangeHandler =
            //    new PropertyChangeEventSource<DataTemplateSelector>(
            //        this,
            //        "ContentTemplateSelector",
            //        BindingMode.OneWay);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus            += this.OnGotFocus;
            this.LostFocus           += this.OnLostFocus;
            this.PointerWheelChanged += this.OnPointerWheelChanged;
            _valueTextBox             = this.GetTemplateChild(ValueTextBoxName) as UpDownTextBox;
            _dragOverlay              = this.GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton          = this.GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton          = this.GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = this.GetTemplateChild(ValueBarName) as FrameworkElement;

            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus     += this.OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus      += this.OnValueTextBoxGotFocus;
                _valueTextBox.Text           = this.Value.ToString(CultureInfo.CurrentCulture);
                _valueTextBox.TextChanged   += this.OnValueTextBoxTextChanged;
                _valueTextBox.KeyDown       += this.OnValueTextBoxKeyDown;
                _valueTextBox.UpPressed     += (s, e) => this.Increment();
                _valueTextBox.DownPressed   += (s, e) => this.Decrement();
                _valueTextBox.PointerExited += this.OnValueTextBoxPointerExited;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped             += this.OnDragOverlayTapped;
                _dragOverlay.ManipulationMode    = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed     += this.OnDragOverlayPointerPressed;
                _dragOverlay.PointerReleased    += this.OnDragOverlayPointerReleased;
                _dragOverlay.PointerCaptureLost += this.OnDragOverlayPointerCaptureLost;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += this.OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource <bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += this.OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += this.OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource <bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += this.OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += this.OnValueBarSizeChanged;

                this.UpdateValueBar();
            }

            this.UpdateIsReadOnlyDependants();
            this.SetValidIncrementDirection();
        }
        private void SubscribeToTransformPropertyChanges(Transform transform)
        {
            var transformGroup = transform as TransformGroup;

            if (transformGroup != null)
            {
                foreach (var childTransform in transformGroup.Children)
                {
                    SubscribeToTransformPropertyChanges(childTransform);
                }

                return;
            }

            var propertyChangeEventSources =
                new List<PropertyChangeEventSource<double>>();
            _transformPropertyChangeEventSources.Add(transform, propertyChangeEventSources);
            var rotateTransform = transform as RotateTransform;

            if (rotateTransform != null)
            {
                var anglePropertyChangeEventSource =
                    new PropertyChangeEventSource<double>(
                        rotateTransform,
                        "Angle");
                anglePropertyChangeEventSource.ValueChanged +=
                    OnTransformPropertyChanged;
                propertyChangeEventSources.Add(anglePropertyChangeEventSource);
                return;
            }

            var scaleTransform = transform as ScaleTransform;

            if (scaleTransform != null)
            {
                var scaleXPropertyChangeEventSource =
                    new PropertyChangeEventSource<double>(
                        scaleTransform,
                        "ScaleX");
                scaleXPropertyChangeEventSource.ValueChanged +=
                    OnTransformPropertyChanged;
                propertyChangeEventSources.Add(scaleXPropertyChangeEventSource);
                var scaleYPropertyChangeEventSource =
                    new PropertyChangeEventSource<double>(
                        scaleTransform,
                        "ScaleY");
                scaleYPropertyChangeEventSource.ValueChanged +=
                    OnTransformPropertyChanged;
                propertyChangeEventSources.Add(scaleYPropertyChangeEventSource);
                return;
            }

            var skewTransform = transform as SkewTransform;

            if (skewTransform != null)
            {
                var angleXPropertyChangeEventSource =
                    new PropertyChangeEventSource<double>(
                        skewTransform,
                        "AngleX");
                angleXPropertyChangeEventSource.ValueChanged +=
                    OnTransformPropertyChanged;
                propertyChangeEventSources.Add(angleXPropertyChangeEventSource);
                var angleYPropertyChangeEventSource =
                    new PropertyChangeEventSource<double>(
                        skewTransform,
                        "AngleY");
                angleYPropertyChangeEventSource.ValueChanged +=
                    OnTransformPropertyChanged;
                propertyChangeEventSources.Add(angleYPropertyChangeEventSource);
                return;
            }

            var matrixTransform = transform as MatrixTransform;

            if (matrixTransform != null)
            {
                var matrixPropertyChangeEventSource =
                    new PropertyChangeEventSource<double>(
                        matrixTransform,
                        "Matrix");
                matrixPropertyChangeEventSource.ValueChanged +=
                    OnTransformPropertyChanged;
                propertyChangeEventSources.Add(matrixPropertyChangeEventSource);
            }
        } 
Exemplo n.º 7
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus += OnGotFocus;
            this.LostFocus += OnLostFocus;
            this.PointerWheelChanged += OnPointerWheelChanged;
            _valueTextBox = GetTemplateChild(ValueTextBoxName) as TextBlock;
            _dragOverlay = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;

            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += OnValueTextBoxGotFocus;
                _valueTextBox.Text = Value.ToString();
                _valueTextBox.KeyDown += OnValueTextBoxKeyDown;
                _valueTextBox.PointerExited += OnValueTextBoxPointerExited;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:WinRTXamlToolkit.Controls.TreeView" /> class.
 /// </summary>
 public TreeView()
 {
     var pcc = new PropertyChangeEventSource<Style>(this, "ItemContainerStyle");
     pcc.ValueChanged += OnItemContainerStylePropertyChanged;
     DefaultStyleKey = typeof(TreeView);
     ItemsControlHelper = new ItemsControlHelper(this);
     Interaction = new InteractionHelper(this);
 }
 /// <summary>
 /// Initializes event handling to coerce Minimum and Maximum properties to the 0..360 range.
 /// </summary>
 private void InitializeMinMaxCoercion()
 {
     this.Minimum = 0.0;
     this.Maximum = 360.0;
     var minimumChangedEventSource = new PropertyChangeEventSource<double>(
         this, "Minimum");
     minimumChangedEventSource.ValueChanged += OnMinimumChanged;
     var maximumChangedEventSource = new PropertyChangeEventSource<double>(
         this, "Maximum");
     maximumChangedEventSource.ValueChanged += OnMaximumChanged;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus += this.OnGotFocus;
            this.LostFocus += this.OnLostFocus;
            this.PointerWheelChanged += this.OnPointerWheelChanged;
            _valueTextBox = this.GetTemplateChild(ValueTextBoxName) as UpDownTextBox;
            _dragOverlay = this.GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = this.GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = this.GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = this.GetTemplateChild(ValueBarName) as FrameworkElement;
            
            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += this.OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += this.OnValueTextBoxGotFocus;
                _valueTextBox.Text = this.Value.ToString(CultureInfo.CurrentCulture);
                _valueTextBox.TextChanged += this.OnValueTextBoxTextChanged;
                _valueTextBox.KeyDown += this.OnValueTextBoxKeyDown;
                _valueTextBox.UpPressed += (s, e) => this.Increment();
                _valueTextBox.DownPressed += (s, e) => this.Decrement();
                _valueTextBox.PointerExited += this.OnValueTextBoxPointerExited;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped += this.OnDragOverlayTapped;
                _dragOverlay.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed += this.OnDragOverlayPointerPressed;
                _dragOverlay.PointerReleased += this.OnDragOverlayPointerReleased;
                _dragOverlay.PointerCaptureLost += this.OnDragOverlayPointerCaptureLost;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += this.OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += this.OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += this.OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += this.OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += this.OnValueBarSizeChanged;

                this.UpdateValueBar();
            }

            this.UpdateIsReadOnlyDependants();
            this.SetValidIncrementDirection();
        }
        //private readonly PropertyChangeEventSource<DataTemplate> _contentTemplateChangeHandler;
        //private readonly PropertyChangeEventSource<DataTemplateSelector> _contentTemplateSelectorChangeHandler;

        public EditableListBoxItem()
        {
            DefaultStyleKey = typeof (EditableListBoxItem);
            this.Loaded += OnLoaded;
            this.Unloaded += OnUnloaded;
            _isSelectedChangeHandler =
                new PropertyChangeEventSource<bool>(
                    this,
                    "IsSelected",
                    BindingMode.OneWay);
            //_contentTemplateChangeHandler =
            //    new PropertyChangeEventSource<DataTemplate>(
            //        this,
            //        "ContentTemplate",
            //        BindingMode.OneWay);
            //_contentTemplateSelectorChangeHandler =
            //    new PropertyChangeEventSource<DataTemplateSelector>(
            //        this,
            //        "ContentTemplateSelector",
            //        BindingMode.OneWay);
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _valueTextBox = GetTemplateChild(ValueTextBoxName) as TextBox;
            _dragOverlay = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;
            
            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += OnValueTextBoxGotFocus;
                _valueTextBox.Text = Value.ToString();
                _valueTextBox.TextChanged += OnValueTextBoxTextChanged;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped += OnDragOverlayTapped;
                _dragOverlay.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed += OnDragOverlayPointerPressed;
                _dragOverlay.ManipulationDelta += OnDragOverlayManipulationDelta;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus += OnGotFocus;
            this.LostFocus += OnLostFocus;
            this.PointerWheelChanged += OnPointerWheelChanged;
            _valueTextBox = GetTemplateChild(ValueTextBoxName) as TextBox;
            _dragOverlay = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;
            
            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += OnValueTextBoxGotFocus;
                _valueTextBox.Text = Value.ToString();
                _valueTextBox.TextChanged += OnValueTextBoxTextChanged;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped += OnDragOverlayTapped;
                _dragOverlay.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed += OnDragOverlayPointerPressed;
                Window.Current.CoreWindow.PointerReleased += CoreWindowOnPointerReleased;
                Window.Current.CoreWindow.VisibilityChanged += OnCoreWindowVisibilityChanged;
                _dragOverlay.PointerReleased += OnDragOverlayPointerReleased;
                _dragOverlay.PointerCaptureLost += OnDragOverlayPointerCaptureLost;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }