/// <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); }
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(); }
/// <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; }
/// <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(); }
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); } }
/// <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(); }