private void ArrangeLabel(ContentPresenter label, Size finalSize, double currentTickAngle, double radiusScale) { Size desiredSize = label.DesiredSize; double radius = Math.Min(finalSize.Width, finalSize.Height) / 2; Point center = GetIndicatorOffset(desiredSize, finalSize); var gauge = this.OwnerGauge as RadRadialGauge; double angle = 0; if (this.sweepDir == SweepDirection.Clockwise) { angle = RadialGaugePanel.ConvertDegreesToRadians(gauge.MinAngle) + RadialGaugePanel.ConvertDegreesToRadians(currentTickAngle); } else { angle = RadialGaugePanel.ConvertDegreesToRadians(gauge.MaxAngle) - RadialGaugePanel.ConvertDegreesToRadians(currentTickAngle); } Point labelPosition = CreateRotatedPoint(angle, radius, center, radiusScale); if ((TickType)label.GetValue(RadGauge.TickTypeProperty) == TickType.Label) { labelPosition.X -= desiredSize.Width * Math.Cos(angle) / 3; } label.Arrange(new Rect(labelPosition, desiredSize)); }
/// <summary> /// Defines the arrange logic for the ticks. /// </summary> /// <param name="finalSize">The size in which the ticks can be arranged.</param> internal override void ArrangeTicksOverride(Size finalSize) { int tickCount = this.TickCount; for (int i = 0; i < tickCount; ++i) { ContentPresenter tick = this.GetTick(i); this.ArrangeTick(tick, (double)tick.GetValue(RadGauge.TickValueProperty)); } }
/// <summary> /// Defines the arrange logic for the labels. /// </summary> /// <param name="finalSize">The size in which the labels can be arranged.</param> internal override void ArrangeLabelsOverride(Size finalSize) { int labelCount = this.LabelCount; double offset = (this.OwnerGauge as RadLinearGauge).LabelOffset; for (int i = 0; i < labelCount; ++i) { ContentPresenter label = this.GetLabel(i); this.ArrangeLabel(label, (double)label.GetValue(RadGauge.TickValueProperty), offset); } }
protected void StartAnimation(Item item) { ContentPresenter dobj = (ContentPresenter)itemsControl.ItemContainerGenerator.ContainerFromItem(item); double x = (double)dobj.GetValue(Canvas.LeftProperty); double y = (double)dobj.GetValue(Canvas.TopProperty); Point targetPoint = GetTargetPosition(dobj, item); double dist = Math.Sqrt((x - targetPoint.X) * (x - targetPoint.X) + (y - targetPoint.Y) * (y - targetPoint.Y)); double dur = Math.Pow(dist / 400, 0.5); if (dur > 1) { dur = 1; } if (dur < 0.1) { dur = 0.1; } Duration duration = new Duration(TimeSpan.FromSeconds(dur)); DoubleAnimation xanim = new DoubleAnimation(targetPoint.X, duration); DoubleAnimation yanim = new DoubleAnimation(targetPoint.Y, duration); dobj.BeginAnimation(Canvas.LeftProperty, xanim); dobj.BeginAnimation(Canvas.TopProperty, yanim); }
protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { Storyboard oldStoryboard = (Storyboard)oldContent.GetValue(OldContentStoryboardProperty); if (oldStoryboard != null) { oldStoryboard.Stop(oldContent); } oldContent.ClearValue(ContentPresenter.StyleProperty); Storyboard newStoryboard = (Storyboard)newContent.GetValue(NewContentStoryboardProperty); if (newStoryboard != null) { newStoryboard.Stop(newContent); } newContent.ClearValue(ContentPresenter.StyleProperty); }
public static ICommand GetCommand(ContentPresenter element) { return((ICommand)element.GetValue(CommandProperty)); }
public static bool GetIsCenter(ContentPresenter element) { return((bool)element.GetValue(IsCenterProperty)); }
private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Rectangle r = (Rectangle)sender; r.ReleaseMouseCapture(); ContentPresenter dobj = (ContentPresenter)itemsControl.ItemContainerGenerator.ContainerFromItem(r.DataContext); Point ct = new Point((double)dobj.GetValue(Canvas.LeftProperty) + r.Width / 2, (double)dobj.GetValue(Canvas.TopProperty) + r.Height / 2); r.IsHitTestVisible = false; // TODO: find a better way to do this hit testing List <Rectangle> hitTests = new List <Rectangle>(); hitTests.Add(r); Rectangle hit = null; while (hit == null) { IInputElement el = InputHitTest(ct); if (!(el is Rectangle)) { break; } Rectangle r2 = (Rectangle)el; if (r2.DataContext is Item) { r2.IsHitTestVisible = false; hitTests.Add(r2); continue; } hit = r2; } foreach (Rectangle r3 in hitTests) { r3.IsHitTestVisible = true; } Item item = (Item)r.DataContext; int oldState = item.State; if (hit == positiveBlock) { item.State = 1; r.Stroke = Brushes.LimeGreen; } if (hit == negativeBlock) { item.State = -1; r.Stroke = Brushes.Red; } if (hit == null) { item.State = 0; r.Stroke = normalStroke; } if (oldState != item.State) { // Update classifier ItemsModel model = (ItemsModel)DataContext; r.Cursor = Cursors.Wait; bool isClassifying = model.Reclassify(); BottomPanel.Visibility = isClassifying? Visibility.Visible : Visibility.Hidden; r.Cursor = null; foreach (Item it2 in model.Items) { if (it2 != item) { StartAnimation(it2); } } } StartAnimation(item); dragPoint.X = -1; }
internal Point GetTargetPosition(ContentPresenter dobj, Item item) { Rectangle r = (Rectangle)dobj.ContentTemplate.FindName("itemRect", dobj); double x = (double)dobj.GetValue(Canvas.LeftProperty); double y = (double)dobj.GetValue(Canvas.TopProperty); double newx = x; double newy = y; int width = (int)r.Width; int height = (int)r.Height; if (item.State == -2) { Point pt = GetRandomPosition(dobj); newx = pt.X; newy = pt.Y; } int binHeight = (int)binRow.Height.Value; if (x < marg) { newx = marg; } if (x + width > Width - marg) { newx = Width - marg - width; } if (y < marg) { newy = marg; } if (y + height > Height - marg - bottomMargin) { newy = Height - marg - height - bottomMargin; } if (item.State == 0) { if (y < binHeight + marg) { newy = binHeight + marg; } } else { if (item.State != -2) { if (y + height > binHeight - marg) { newy = binHeight - marg - height; } if (item.State == 1) { if (x + width > Width / 2 - marg) { newx = Width / 2 - marg - width; } } else { if (x < marg + Width / 2) { newx = Width / 2 + marg; } } } } if ((item.State == 0) && (item.probTrue >= 0)) { newx = marg + Squash(Squash(1 - item.probTrue)) * (Width - width - marg * 2); } return(new Point(newx, newy)); }
public static bool GetUpdateTemplateSelectorOnContentChange(ContentPresenter obj) { return((bool)obj.GetValue(UpdateTemplateSelectorOnContentChangeProperty)); }
private static long GetContentChangedToken(ContentPresenter obj) { return((long)obj.GetValue(ContentChangedTokenProperty)); }