Exemple #1
0
        private PiePiece CreatePiePiece(int rad, double wedgeAngle, double rotationAngle, int level, CallTreeNodeViewModel node)
        {
            // prevent exception when ProfilerHook screws up and children are larger than their parent (e.g. when process is killed)
            if (rotationAngle > 360)
            {
                rotationAngle %= 360;
            }

            PiePiece p = new PiePiece();

            p.Radius              = 20 + level * rad;
            p.InnerRadius         = level * rad;
            p.WedgeAngle          = wedgeAngle;
            p.RotationAngle       = rotationAngle;
            p.Stroke              = Brushes.Black;
            p.ToolTip             = node.CreateToolTip(Translation);
            p.VerticalAlignment   = VerticalAlignment.Center;
            p.HorizontalAlignment = HorizontalAlignment.Center;
            p.Tag = node;

            p.MouseLeftButtonDown += new MouseButtonEventHandler(
                delegate(object sender, MouseButtonEventArgs e) {
                node.IsExpanded    = true;
                node.IsSelected    = true;                      // expand the path to the node so that the treeview can select it
                var oldNode        = this.SelectedRoot;
                this.SelectedRoot  = node;
                oldNode.IsSelected = false;
            }
                );

            HSVColor hsv = new HSVColor {
                Hue        = (float)rotationAngle,
                Saturation = 0.5f,
                Value      = 0.6f - level / 50f
            };

            SolidColorBrush brush = new SolidColorBrush();

            p.Fill = brush;

            Color normalColor = hsv.ToColor();

            hsv.Value = 0.8f;
            Color highlightColor = hsv.ToColor();

            brush.Color = normalColor;

            p.IsMouseDirectlyOverChanged += (sender, e) => {
                if (p.IsMouseDirectlyOver)
                {
                    brush.BeginAnimation(SolidColorBrush.ColorProperty,
                                         new ColorAnimation(highlightColor, new Duration(TimeSpan.FromSeconds(0.5)),
                                                            FillBehavior.HoldEnd));
                }
                else
                {
                    brush.BeginAnimation(SolidColorBrush.ColorProperty,
                                         new ColorAnimation(normalColor, new Duration(TimeSpan.FromSeconds(0.5)),
                                                            FillBehavior.Stop));
                }
            };

            return(p);
        }
		private PiePiece CreatePiePiece(int rad, double wedgeAngle, double rotationAngle, int level, CallTreeNodeViewModel node)
		{
			// prevent exception when ProfilerHook screws up and children are larger than their parent (e.g. when process is killed)
			if (rotationAngle > 360)
				rotationAngle %= 360;
			
			PiePiece p = new PiePiece();

			p.Radius = 20 + level * rad;
			p.InnerRadius = level * rad;
			p.WedgeAngle = wedgeAngle;
			p.RotationAngle = rotationAngle;
			p.Stroke = Brushes.Black;
			p.ToolTip = node.CreateToolTip(Translation);
			p.VerticalAlignment = VerticalAlignment.Center;
			p.HorizontalAlignment = HorizontalAlignment.Center;
			p.Tag = node;

			p.MouseLeftButtonDown += new MouseButtonEventHandler(
				delegate(object sender, MouseButtonEventArgs e)	{					
					node.IsExpanded = true;
					node.IsSelected = true; // expand the path to the node so that the treeview can select it
					var oldNode = SelectedRoot;
					SelectedRoot = node;
					oldNode.IsSelected = false;
				}
			);
			
			HSVColor hsv = new HSVColor {
				Hue = (float)rotationAngle,
				Saturation = 0.5f,
				Value = 0.6f - level / 50f
			};
			
			SolidColorBrush brush = new SolidColorBrush();
			p.Fill = brush;
			
			Color normalColor = hsv.ToColor();
			hsv.Value = 0.8f;
			Color highlightColor = hsv.ToColor();
			brush.Color = normalColor;
			
			p.IsMouseDirectlyOverChanged += (sender, e) => {
				if (p.IsMouseDirectlyOver) {
					brush.BeginAnimation(SolidColorBrush.ColorProperty,
					                     new ColorAnimation(highlightColor, new Duration(TimeSpan.FromSeconds(0.5)),
					                                        FillBehavior.HoldEnd));
				} else {
					brush.BeginAnimation(SolidColorBrush.ColorProperty,
					                     new ColorAnimation(normalColor, new Duration(TimeSpan.FromSeconds(0.5)),
					                                        FillBehavior.Stop));
				}
			};

			return p;
		}