void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.name = ((System.Windows.Controls.Label)(target)); return; case 2: this.last_seen_container = ((System.Windows.Controls.StackPanel)(target)); return; case 3: this.last_seen_label = ((System.Windows.Controls.Label)(target)); return; case 4: this.last_seen = ((System.Windows.Controls.Label)(target)); return; case 5: this.now_online = ((System.Windows.Controls.Label)(target)); return; case 6: this.PART_Track = ((System.Windows.Controls.Primitives.Track)(target)); return; case 7: this.textBox = ((System.Windows.Controls.TextBox)(target)); return; } this._contentLoaded = true; }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Style style = null; if (SystemParameters.IsGlassEnabled) { style = (Style)Resources["WindowStyle"]; } Style = style; _track = (Track)TrackSlider.Template.FindName("PART_Track", TrackSlider); }
public void PartBounds () { Window w = new Window (); Track s = new Track (); s.Thumb = new Thumb (); w.Content = s; w.Show (); s.Value = s.Maximum; w.Width = 100; w.Height = 100; Assert.AreEqual (s.Thumb.ActualWidth, 4, "Thumb.ActualWidth"); Assert.AreEqual (s.Thumb.ActualHeight, s.ActualHeight, "Thumb.ActualHeight"); }
public void Creation () { Track t = new Track (); Assert.AreEqual (t.Value, 0, "Value"); Assert.AreEqual (t.Maximum, 1, "Maximum"); Assert.AreEqual (t.Minimum, 0, "Minimum"); Assert.AreEqual (t.Orientation, Orientation.Horizontal, "Orientation"); Assert.IsNull (t.Thumb, "Thumb"); Assert.IsNull (t.IncreaseRepeatButton, "Thumb"); Assert.IsNull (t.DecreaseRepeatButton, "Thumb"); Assert.IsNaN (t.ViewportSize, "ViewportSize"); Assert.IsFalse (t.IsDirectionReversed, "IsDirectionReversed"); t.Thumb = new Thumb (); Assert.AreEqual (t.Orientation, Orientation.Horizontal, "Orientation"); Assert.IsFalse (t.SnapsToDevicePixels, "SnapsToDevicePixels"); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); track = Template.FindName("PART_Track", this) as Track; }
public override void OnApplyTemplate () { base.OnApplyTemplate (); track = (Track)GetTemplateChild ("PART_Track"); if (track == null) return; track.in_scroll_bar = true; //FIXME: Move binding to Track. Utility.SetBinding (track, Track.MaximumProperty, this, "Maximum"); Utility.SetBinding (track, Track.MinimumProperty, this, "Minimum"); Utility.SetBinding (track, Track.ValueProperty, this, "Value"); Utility.SetBinding (track, Track.OrientationProperty, this, "Orientation"); Utility.SetBinding (track, Track.ViewportSizeProperty, this, "ViewportSize"); track.Thumb.DragDelta += delegate (object sender, DragDeltaEventArgs e) { double value_from_distance = track.ValueFromDistance (e.HorizontalChange, e.VerticalChange); if (double.IsNaN (value_from_distance)) return; Value += value_from_distance; }; }
public void SettingThumbTwice () { Thread runner = new Thread (delegate () { Track s = new Track (); Window w = new Window (); w.Content = s; w.Show (); s.Thumb = new Thumb (); Thread current = Thread.CurrentThread; Thread killer = new Thread (delegate () { Thread.Sleep (5000); current.Abort (); }); killer.Start (); s.Thumb = new Thumb (); killer.Abort (); Assert.Fail (); }); runner.SetApartmentState (ApartmentState.STA); runner.Start (); }
public void ThumbLargerThanTrack () { Track track = new Track (); track.Width = 100; track.Height = 100; Thumb thumb = new Thumb (); thumb.Width = 200; thumb.Height = 200; track.Thumb = thumb; track.Measure (new Size (double.PositiveInfinity, double.PositiveInfinity)); Assert.AreEqual (track.DesiredSize.Width, 100, "track.DesiredSize.Width"); Assert.AreEqual (thumb.DesiredSize.Width, 100, "thumb.DesiredSize.Width"); Assert.AreEqual (VisualTreeHelper.GetContentBounds (thumb), Rect.Empty, "VisualTreeHelper.GetContentBounds(thumb)"); }
/// <summary> /// Find important parts of the template and bind some events. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); if (this.Template != null) { ItemsControl newPreviews = this.Template.FindName("PART_Previews", this) as ItemsControl; if (newPreviews != this.previews) { if (this.previews != null) { this.previews.SizeChanged -= PreviewsSizeChanged; } this.previews = newPreviews; if (this.previews != null) { this.previews.SizeChanged += PreviewsSizeChanged; this.previews.ItemsSource = this.previewImages; RecreatePreviews(); } } Track newTrack = this.Template.FindName("PART_Track", this) as Track; if (newTrack != this.track) { if (this.track != null) { this.track.Thumb.MouseEnter -= Thumb_MouseEnter; } this.track = newTrack; if (this.track != null) { this.track.Thumb.MouseEnter += Thumb_MouseEnter; } } } }
public void ValueAdjustments() { Track t = new Track(); t.Value = -1; Assert.AreEqual(t.Value, -1, "1"); t.Value = 2; Assert.AreEqual(t.Value, 2, "2"); ScrollBar s = new ScrollBar(); Window w = new Window(); w.Content = s; w.Show(); s.Track.Value = 2; Assert.AreEqual(s.Track.Value, 2, "3"); s.Track.Value = -1; Assert.AreEqual(s.Track.Value, -1, "4"); }
public void ArrangeOnThumbMaximumEqualMinimum () { Track t = new Track (); t.Maximum = 2; t.Minimum = 2; t.Thumb = new ArrangeOnThumbMaximumEqualMinimumThumb (); ArrangeOnThumbMaximumEqualMinimumThumb.ShouldLog = true; t.Arrange (new Rect (0, 0, 100, 100)); Assert.AreEqual (ArrangeOnThumbMaximumEqualMinimumThumb.ArrangeBounds.Width, 4, "Width"); Assert.AreEqual (ArrangeOnThumbMaximumEqualMinimumThumb.ArrangeBounds.Height, 100, "Height"); Rect b = VisualTreeHelper.GetContentBounds (t.Thumb); Assert.IsTrue (double.IsPositiveInfinity (b.Left), "Left"); Assert.IsTrue (double.IsPositiveInfinity (b.Top), "Top"); }
public void MeasureOnThumbMaximumEqualMinimum () { Track t = new Track (); t.Maximum = 2; t.Minimum = 2; t.Thumb = new MeasureOnThumbMaximumEqualMinimumThumb (); MeasureOnThumbMaximumEqualMinimumThumb.ShouldLog = true; t.Measure (new Size (100, 100)); Assert.AreEqual (MeasureOnThumbMaximumEqualMinimumThumb.Constraint.Width, 100, "Width"); Assert.AreEqual (MeasureOnThumbMaximumEqualMinimumThumb.Constraint.Height, 100, "Height"); }
public void ArrangeOnThumb () { Track t = new Track (); t.Thumb = new ArrangeOnThumbThumb (); ArrangeOnThumbThumb.ShouldLog = true; t.Arrange (new Rect (0, 0, 100, 100)); Assert.AreEqual (ArrangeOnThumbThumb.ArrangeBounds.Width, 4, "Width"); Assert.AreEqual (ArrangeOnThumbThumb.ArrangeBounds.Height, 100, "Height"); }
private void DetachFromVisualTree() { if (_zoomTrack != null) { DependencyPropertyDescriptor dpdActualWidth = DependencyPropertyDescriptor.FromProperty(ActualWidthProperty, typeof(FrameworkElement)); dpdActualWidth.RemoveValueChanged(_zoomTrack, actualWidthChangedHandler); _zoomTrack = null; } }
private void AttachToVisualTree() { DetachFromVisualTree(); _zoomTrack = GetTemplateChild("PART_Track") as Track; if (_zoomTrack != null) { DependencyPropertyDescriptor dpdActualWidth = DependencyPropertyDescriptor.FromProperty(ActualWidthProperty, typeof(FrameworkElement)); dpdActualWidth.AddValueChanged(_zoomTrack, actualWidthChangedHandler); } }
public void Simple () { Track t = new Track (); t.ValueFromDistance (0, 0); Canvas c = new Canvas (); c.Children.Add (t); Window w = new Window (); w.Content = c; w.Show (); }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { DecreaseLineButton = Template.FindName("PART_DecreaseButton", this) as ButtonBase; IncreaseLineButton = Template.FindName("PART_IncreaseButton", this) as ButtonBase; Track = Template.FindName("PART_Track", this) as Track; } else { DecreaseLineButton = null; IncreaseLineButton = null; Track = null; } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); var partTrack = (Track)this.GetTemplateChild(AbcSlider.TrackName); if (partTrack != null) { this.track = partTrack; this.track.Minimum = this.Minimum; this.track.Maximum = this.Maximum; this.track.Value = this.Value; } }