using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Media; using System.Windows.Shapes; namespace JetBrains.UI.Avalon.Controls { /// /// Implements a progress indication control in a circle. /// public class ProgressCircle : RangeBase { #region Data private readonly Grid myGridRoot = new Grid(); #endregion #region Init public ProgressCircle() { InitView(); } #endregion #region Implementation private void InitView() { AddLogicalChild(myGridRoot); AddVisualChild(myGridRoot); // Background myGridRoot.Children.Add(new Ellipse {Fill = SystemColors.ControlBrush}); // Outer rim myGridRoot.Children.Add(new Ellipse {Stroke = Brushes.Green}); // Placeholder for the progress elements Grid gridProgress; myGridRoot.Children.Add(gridProgress = new Grid()); // Inner rim Grid grid; myGridRoot.Children.Add(grid = new Grid().Cols("*", "*", "*").Rows("*", "*", "*")); grid.Children.Add(AvalonEx.InGrid(new Ellipse {Fill = SystemColors.ControlBrush, Stroke = Brushes.Green}, 1, 1)); // Temp: Progress Elements Image image; gridProgress.Children.Add(image = new Image()); Geometry geometry = new EllipseGeometry(new Point(50, 50), 50, 50); Drawing drawing = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0x00, 0xC0, 0x00)), null, geometry); image.Source = new DrawingImage(drawing); } private void UpdatePosition() { // TODO } #endregion #region Overrides /// ///Called to arrange and size the content of a object. /// /// /// ///The size of the control. /// /// ///The computed size that is used to arrange the content. protected override Size ArrangeOverride(Size arrangeBounds) { myGridRoot.Arrange(new Rect(new Point(), arrangeBounds)); return arrangeBounds; } /// ///Called to remeasure a control. /// /// /// ///The size of the control. /// /// ///Measurement constraints, a control cannot return a size larger than the constraint. protected override Size MeasureOverride(Size constraint) { return new Size(24, 24).Constrain(constraint); } /// ///Called when the property changes. /// /// ///New value of the property. ///Old value of the property. protected override void OnMaximumChanged(double oldMaximum, double newMaximum) { base.OnMaximumChanged(oldMaximum, newMaximum); UpdatePosition(); } /// /// Called when the property changes. /// /// ///Old value of the property. ///New value of the property. protected override void OnMinimumChanged(double oldMinimum, double newMinimum) { base.OnMinimumChanged(oldMinimum, newMinimum); UpdatePosition(); } /// /// Called when the property changes. /// /// ///Old value of the property ///New value of the property protected override void OnValueChanged(double oldValue, double newValue) { base.OnValueChanged(oldValue, newValue); UpdatePosition(); } #endregion } }