本文整理汇总了C#中System.Windows.Controls.Canvas.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.SetValue方法的具体用法?C# Canvas.SetValue怎么用?C# Canvas.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Canvas
的用法示例。
在下文中一共展示了Canvas.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddColor
public void AddColor(Hex hex, Color color)
{
hex.Dispatcher.BeginInvoke(() =>
{
Canvas canvas = new Canvas();
canvas.Name = "ColorCanvas";
canvas.SetValue(Canvas.ZIndexProperty, 9);
canvas.Opacity = .5;
Path path = new Path();
CreatePathOutline(path, "ColorPath");
SolidColorBrush colorBrush = new SolidColorBrush();
colorBrush.Color = color;
ScaleTransform scaleTransform = new ScaleTransform();
scaleTransform.ScaleX = Game.CurrentViewLevel;
scaleTransform.ScaleY = Game.CurrentViewLevel;
colorBrush.Transform = scaleTransform;
path.Fill = colorBrush;
canvas.Children.Add(path);
hex.MainCanvas.Children.Add(canvas);
});
}
示例2: flickrClient_SearchCompleted
void flickrClient_SearchCompleted(object sender, SearchCompletedEventArgs e)
{
try
{
for (int x = 0; x < e.Results.Count; x++)
{
int cx = x;
Pictures.Dispatcher.BeginInvoke(() =>
{
Canvas c = new Canvas();
c.Width = 580;
c.Height = 580;
PanelFrame img = new PanelFrame();
img.Image.Source = new BitmapImage(e.Results[cx].ImageUri);
img.ImageUrl = e.Results[cx].ImageUri.ToString();
img.Image.ImageOpened += delegate(object s, RoutedEventArgs args)
{
BitmapImage bi = img.Image.Source as BitmapImage;
c.Dispatcher.BeginInvoke(() =>
{
//c.Width = bi.PixelWidth * (580D / bi.PixelHeight);
//img.Width = c.Width;
//img.Image.Width = c.Width;
});
};
c.Children.Add(img);
c.SetValue(MIRIA.UIKit.ScrollView.HookableProperty, true);
c.Tag = img.ImageUrl;
if (Pictures.Children.Count > 21)
Pictures2.Children.Add(c);
else
Pictures.Children.Add(c);
});
//
_resultssofar++;
if (_resultssofar == _resultstoget)
break;
}
}
catch (Exception ex) { }
if (_resultssofar < _resultstoget)
{
_flickrsearch.Page++;
_flickrclient.SearchAsync(_flickrsearch);
}
}
示例3: _init
private void _init()
{
if (VisualTreeHelper.GetChildrenCount(this) == 0) return;
if (_scrollerpanel != null) // already inited
return;
DependencyObject child = VisualTreeHelper.GetChild(this, 0);
if (child != null && child is Panel)
{
_scrollerpanel = (Panel)child;
_scrollertransformhelper = new Animations.TransformHelper(_scrollerpanel);
_scrollertransformhelper.AnimationStarting += new TransformHelper.AnimationStartingHandler(_scrollertransformhelper_AnimationStarting);
_scrollertransformhelper.AnimationComplete += new TransformHelper.AnimationCompleteHandler(_scrollertransformhelper_AnimationComplete);
_gesturesinterpreter = new TouchGestures(_scrollerpanel);
_gesturesinterpreter.Translate += new TouchGestures.GestureTranslateHandler(_gesturesinterpreter_Translate); //Translate;
_gesturesinterpreter.Tap += new TouchGestures.GestureTapHandler(_gesturesinterpreter_Tap);
_gesturesinterpreter.Hold += new TouchGestures.GestureHold(_gesturesinterpreter_Hold);
_gesturesinterpreter.Scale += new TouchGestures.GestureScaleHandler(_gesturesinterpreter_Scale);
_gesturesinterpreter.GestureDetected += new TouchGestures.GestureDetectedHandler(_gesturesinterpreter_GestureDetected);
// add scrollbars
//
_scrollbarscanvas = new Canvas();
_scrollbarscanvas.SetValue(Canvas.ZIndexProperty, 255);
//
_scrollbarh = new Border();
_scrollbarh.BorderBrush = new SolidColorBrush(Colors.White);
_scrollbarh.BorderThickness = new Thickness(2.0);
_scrollbarh.CornerRadius = new CornerRadius(5.0);
_scrollbarh.Background = new SolidColorBrush(Colors.Black);
_scrollbarh.Opacity = 0.3;
_scrollbarh.Width = this.Width;
_scrollbarh.Height = 40D;
_scrollbarh.Cursor = Cursors.Hand;
_scrollbarscanvas.Children.Add(_scrollbarh);
//
_scrollbarv = new Border();
_scrollbarv.BorderBrush = new SolidColorBrush(Colors.White);
_scrollbarv.BorderThickness = new Thickness(2.0);
_scrollbarv.CornerRadius = new CornerRadius(5.0);
_scrollbarv.Background = new SolidColorBrush(Colors.Black);
_scrollbarv.Opacity = 0.3;
_scrollbarv.Width = 40D;
_scrollbarv.Height = this.Height;
_scrollbarv.Cursor = Cursors.Hand;
_scrollbarscanvas.Children.Add(_scrollbarv);
//
this.Children.Add(_scrollbarscanvas);
//
_scrollbarsupdate();
}
else
{
// THROW EXCEPTION IF NO PANEL FOUND
throw(new Exception("MIRIA.UIKIT.ScrollView child element must be subclass of Panel"));
}
}
示例4: ResizePanels
/// <summary>
/// Resize existing panels to update the chart
/// </summary>
internal void ResizePanels(Size remainingSizeAfterDrawingAxes, AxisRepresentations renderAxisType, Boolean isPartialUpdate)
{
PlotAreaScrollViewer = Chart._plotAreaScrollViewer;
PlotAreaScrollViewer.Background = Graphics.TRANSPARENT_BRUSH;
PlotAreaCanvas.Width = remainingSizeAfterDrawingAxes.Width;
PlotAreaCanvas.Height = remainingSizeAfterDrawingAxes.Height;
if (Chart._forcedRedraw || PlottingCanvas == null)
{
PlottingCanvas = new Canvas();
PlottingCanvas.Loaded += new RoutedEventHandler(PlottingCanvas_Loaded);
PlottingCanvas.SetValue(Canvas.ZIndexProperty, 1);
PlotAreaCanvas.Children.Add(PlottingCanvas);
//PlottingCanvas.Background = Graphics.GetRandomColor();
}
if (Double.IsNaN(remainingSizeAfterDrawingAxes.Height) || remainingSizeAfterDrawingAxes.Height <= 0 || Double.IsNaN(remainingSizeAfterDrawingAxes.Width) || remainingSizeAfterDrawingAxes.Width <= 0)
{
return;
}
else
{
if (PlotDetails.ChartOrientation == ChartOrientationType.Vertical)
{
PlottingCanvas.Width = ScrollableLength + PLANK_DEPTH;
PlottingCanvas.Height = remainingSizeAfterDrawingAxes.Height;
}
else if (PlotDetails.ChartOrientation == ChartOrientationType.Horizontal)
{
PlottingCanvas.Width = remainingSizeAfterDrawingAxes.Width;
PlottingCanvas.Height = ScrollableLength + PLANK_DEPTH;
}
}
// Create the chart canvas
if (Chart._forcedRedraw || ChartVisualCanvas == null)
{
ChartVisualCanvas = new Canvas();
PlottingCanvas.Children.Add(ChartVisualCanvas);
}
// Default size of the chart canvas
Size chartCanvasSize = new Size(0, 0);
// Create the various region required for drawing charts
switch (PlotDetails.ChartOrientation)
{
case ChartOrientationType.Vertical:
chartCanvasSize = CreateRegionsForVerticalCharts(ScrollableLength, remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate);
// set chart Canvas position
ChartVisualCanvas.SetValue(Canvas.LeftProperty, PLANK_DEPTH);
Chart.PlotArea.BorderElement.SetValue(Canvas.LeftProperty, PLANK_DEPTH);
break;
case ChartOrientationType.Horizontal:
chartCanvasSize = CreateRegionsForHorizontalCharts(ScrollableLength, remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate);
// set chart Canvas position
ChartVisualCanvas.SetValue(Canvas.LeftProperty, PLANK_OFFSET);
Chart.PlotArea.BorderElement.SetValue(Canvas.LeftProperty, PLANK_OFFSET);
break;
case ChartOrientationType.NoAxis:
chartCanvasSize = CreateRegionsForChartsWithoutAxis(remainingSizeAfterDrawingAxes);
break;
default:
// No chart to render
break;
}
// Don't atempt to draw chart if the size is not fesiable
if (chartCanvasSize.Width <= 0 || chartCanvasSize.Height <= 0)
return;
// set the ChartVisualCanvas Size
ChartVisualCanvas.Width = chartCanvasSize.Width - ((PlotDetails.ChartOrientation == ChartOrientationType.Horizontal) ? SCROLLVIEWER_OFFSET4HORIZONTAL_CHART : 0);
ChartVisualCanvas.Height = chartCanvasSize.Height - ((PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) ? Chart.SHADOW_DEPTH : 0);
Chart.PlotArea.BorderElement.Height = ChartVisualCanvas.Height;
Chart.PlotArea.BorderElement.Width = chartCanvasSize.Width;
Chart.PlotArea.ApplyBevel(PLANK_DEPTH, PLANK_THICKNESS);
Chart.PlotArea.ApplyShadow(remainingSizeAfterDrawingAxes, PLANK_OFFSET, PLANK_DEPTH, PLANK_THICKNESS);
Chart._plotCanvas.Width = PlottingCanvas.Width;
Chart._plotCanvas.Height = PlottingCanvas.Height;
Chart._bottomAxisScrollBar.UpdateLayout();
Chart._topAxisScrollBar.UpdateLayout();
Chart._leftAxisScrollBar.UpdateLayout();
Chart._rightAxisScrollBar.UpdateLayout();
}
示例5: CreateFunnelSlice
/// <summary>
/// Create a slice of a funnel
/// </summary>
/// <param name="isLightingGradientLayer">Whether CreateFunnelSlice() function should create a layer for lighting</param>
/// <param name="topRadius">Top Radius of the funnel</param>
/// <param name="is3D">Whether the chart is a 3D Chart</param>
/// <param name="funnelSlice">FunnelSlice canvas reference</param>
/// <param name="yScaleTop">Top YScale for 3D view</param>
/// <param name="yScaleBottom">Bottom YScale for 3D view</param>
/// <param name="sideFillColor">Side surface fill color</param>
/// <param name="topFillColor">Top surface fill color</param>
/// <param name="topSurfaceStroke">Top surface stroke color</param>
/// <param name="animationEnabled">Whether animation is enabled</param>
/// <returns>Return funnel slice canvas</returns>
private static Canvas CreateFunnelSlice(Boolean isLightingGradientLayer, Double topRadius, Boolean is3D, TriangularChartSliceParms funnelSlice, Double yScaleTop, Double yScaleBottom, Brush sideFillColor, Brush topFillColor, Brush topSurfaceStroke, Boolean animationEnabled)
{
Double SOLID_FUNNEL_EDGE_THICKNESS = 3;
if (funnelSlice.Index == 0 && is3D && isLightingGradientLayer && (funnelSlice.FillType == FillType.Solid))
{
funnelSlice.Height += SOLID_FUNNEL_EDGE_THICKNESS;
}
Canvas sliceCanvas = new Canvas() { Tag = new ElementData() { Element = funnelSlice.DataPoint } };
Canvas visual = new Canvas() { Width = topRadius * 2, Height = funnelSlice.Height, Tag = new ElementData() { Element = funnelSlice.DataPoint } }; // Canvas holds a slice of a funnel chart
Faces faces = null;
// GeometryGroup for for a funnel slice path
GeometryGroup geometryGroup = new GeometryGroup();
// PathGeometry for for a funnel slice path
PathGeometry pathGeometry = new PathGeometry();
// pathFigure for for a funnel slice path
PathFigure pathFigure = new PathFigure() { StartPoint = new Point(topRadius - funnelSlice.TopRadius, 0) }; // PathFigure of a funnel slice
// Path for for a funnel slice
Path path4Slice = new Path() { Fill = sideFillColor };
path4Slice.Tag = new ElementData() { Element = funnelSlice.DataPoint };
// Add PathGeometry to GeometryGroup
geometryGroup.Children.Add(pathGeometry);
// Set path data
path4Slice.Data = geometryGroup;
// Set properties for path
path4Slice.StrokeThickness = 0;
path4Slice.Stroke = new SolidColorBrush(Colors.Black);
// Add path elements to its parent canvas
pathGeometry.Figures.Add(pathFigure);
visual.Children.Add(path4Slice);
if (is3D)
{
#region 3D
geometryGroup.FillRule = FillRule.Nonzero;
// Create top arc left
ArcSegment arcSegment = new ArcSegment();
arcSegment.Point = new Point(topRadius, yScaleTop / 2);
arcSegment.Size = new Size(funnelSlice.TopRadius, yScaleTop / 2);
pathFigure.Segments.Add(arcSegment);
// Create top arc right
arcSegment = new ArcSegment();
arcSegment.Point = new Point(topRadius + funnelSlice.TopRadius, 0);
arcSegment.Size = new Size(funnelSlice.TopRadius, yScaleTop / 2);
pathFigure.Segments.Add(arcSegment);
// Create right Plain
LineSegment lineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.BottomRadius, funnelSlice.Height) };
pathFigure.Segments.Add(lineSegment);
lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.BottomRadius, funnelSlice.Height) };
pathFigure.Segments.Add(lineSegment);
// Create left Plain
lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.TopRadius, 0) };
pathFigure.Segments.Add(lineSegment);
EllipseGeometry ellipseGeometry = new EllipseGeometry();
ellipseGeometry.Center = new Point(topRadius, funnelSlice.Height);
ellipseGeometry.RadiusX = funnelSlice.BottomRadius;
ellipseGeometry.RadiusY = yScaleBottom / 2;
geometryGroup.Children.Add(ellipseGeometry);
// Create ellips for the funnel top
Ellipse funnelTopEllipse = new Ellipse() { Height = yScaleTop, Width = funnelSlice.TopRadius * 2, Fill = topFillColor, Tag = new ElementData() { Element = funnelSlice.DataPoint } };
funnelTopEllipse.SetValue(Canvas.TopProperty, -yScaleTop / 2);
funnelTopEllipse.SetValue(Canvas.LeftProperty, topRadius - funnelSlice.TopRadius);
//.........这里部分代码省略.........
示例6: CreatePreviewLayer
/// <summary>
/// Creates the preview layer and adds it to the parent grid.
/// </summary>
/// <param name="parentGrid">Grid to add the preview layer to.</param>
private void CreatePreviewLayer(Grid parentGrid)
{
Debug.Assert(parentGrid != null, "parentGrid should not be null!");
Debug.Assert(parentGrid.RowDefinitions != null, "parentGrid.RowDefinitions should not be null!");
Debug.Assert(parentGrid.ColumnDefinitions != null, "parentGrid.ColumnDefinitions should not be null!");
_previewLayer = new Canvas();
// RowSpan and ColumnSpan default to 1 and should not be set to 0 in
// the case that a Grid has been created without explicitly setting
// its ColumnDefinitions or RowDefinitions
if (parentGrid.RowDefinitions.Count > 0)
{
_previewLayer.SetValue(Grid.RowSpanProperty, parentGrid.RowDefinitions.Count);
}
if (parentGrid.ColumnDefinitions.Count > 0)
{
_previewLayer.SetValue(Grid.ColumnSpanProperty, parentGrid.ColumnDefinitions.Count);
}
// REMOVE_RTM: Uncomment once Jolt Bug 11276 is fixed
// this.previewLayer.SetValue(Grid.ZIndex, int.MaxValue);
parentGrid.Children.Add(_previewLayer);
}
示例7: layoutVisuals
/// <summary>
/// Helper method that populates the private variables containing
/// the UI visuals.
/// </summary>
/// <param name="count"></param>
private void layoutVisuals(int count)
{
//double[] centers = new double[count];
//double widthOne = 30; // this.ActualHeight;
mainGrid.Children.Clear();
mainGrid.ColumnDefinitions.Clear();
for (int i = 0; i < count; i++)
mainGrid.ColumnDefinitions.Add(new ColumnDefinition());
canvases.Clear();
labels.Clear();
valueLabels.Clear();
if (count > 0)
{
double widthEach = this.ActualWidth / (double)count;
double offset = (widthEach - widthOne) / 2;
for (int i = 0; i < count; i++)
{
double left = widthEach * i + offset;
//mainVisual.Children.Add(new DrawingVisual());
Canvas c = new Canvas()
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Width = widthOne,
Height = widthOne,
};
//c.SetValue(Canvas.LeftProperty, left);
//c.SetValue(Canvas.TopProperty, 0.0);
c.SetValue(Grid.RowProperty, 0);
Path p = new Path();
if (curColor != null)
{
p.Fill = Brushes.Transparent;
p.Stroke = new SolidColorBrush(Color.FromArgb(128, curColor.R, curColor.G, curColor.B));
p.StrokeThickness = -1.0;
}
c.Children.Add(p);
p = new Path();
if (curColor != null)
p.Fill = new SolidColorBrush(curColor);
c.Children.Add(p);
int myI = i;
c.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { valueChangeHelper(myI, e); };
canvases.Add(c);
TextBlock l = new TextBlock()
{
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Center,
TextAlignment = TextAlignment.Center,
TextWrapping = TextWrapping.WrapWithOverflow,
Margin = new Thickness(0),
Padding = new Thickness(0),
Foreground = Brushes.CadetBlue,
};
//l.SetValue(Canvas.TopProperty, 0.0);
//l.SetValue(Canvas.LeftProperty, 0.0);
l.SetValue(Grid.RowProperty, 1);
l.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { valueChangeHelper(myI, e); };
labels.Add(l);
Label lv = new Label()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
Padding = new Thickness(0),
Foreground = Brushes.Black,
FontSize = 9,
};
lv.SetValue(Grid.RowProperty, 0);
lv.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { valueChangeHelper(myI, e); };
valueLabels.Add(lv);
Grid g = new Grid()
{
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Stretch,
};
g.SetValue(Grid.ColumnProperty, i);
g.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
g.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
g.Children.Add(c);
g.Children.Add(lv);
g.Children.Add(l);
mainGrid.Children.Add(g);
}
}
}
示例8: DrawHighlightedPoint
/// <summary>
/// Draws the highlighted point (if any) that the user selected when he touched the chart.
/// </summary>
private void DrawHighlightedPoint()
{
if (pointHighlighted)
{
Point point = WorldToScreenOptimized(highlightedPoint.X, highlightedPoint.Y);
if (point.X >= 0 && point.X < graphWidth)
{
// We might have to create the canvas that holds a circle for the point the user tapped as well
// as a text box with the information of that point. This canvas might already exist from a previous drawing
if (highlightedPointCanvas == null)
{
highlightedPointCanvas = new Canvas();
double fontSize = (double)this.Resources["PhoneFontSizeSmall"]; ;
SolidColorBrush contrastBgBrush = (SolidColorBrush)this.Resources["PhoneContrastBackgroundBrush"];
Ellipse circle = new Ellipse()
{
Fill = new SolidColorBrush(Colors.Transparent),
Height = 10,
Width = 10,
StrokeThickness = 2,
Stroke = contrastBgBrush
};
highlightedPointCanvas.SetValue(Canvas.LeftProperty, point.X);
highlightedPointCanvas.SetValue(Canvas.TopProperty, point.Y);
circle.SetValue(Canvas.LeftProperty, -5.0);
circle.SetValue(Canvas.TopProperty, -5.0);
highlightedPointCanvas.Children.Add(circle);
TextBlock pointText = new TextBlock()
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
FontSize = fontSize,
Text = String.Format("({0}, {1})", GraphData[0].GetXText(highlightedPoint.X), GraphData[0].GetYText(ScreenToWorldY(point.Y)))
};
highlightedPointCanvas.Children.Add(pointText);
}
// If the canvas exists, we just need to shift the X-coordinate of the TextBlock inside the canvas as the user translates the graph
if (highlightedPointCanvas != null)
{
highlightedPointCanvas.SetValue(Canvas.LeftProperty, point.X);
highlightedPointCanvas.SetValue(Canvas.TopProperty, point.Y);
if (highlightedPointCanvas.Children.Count == 2 && highlightedPointCanvas.Children[1].GetType() == typeof(TextBlock))
{
TextBlock pointText = (TextBlock)highlightedPointCanvas.Children[1];
double textHeight = pointText.ActualHeight + 12;
double textLocation = textHeight - point.Y < 12 ? -textHeight : textHeight;
pointText.SetValue(Canvas.LeftProperty, -((point.X / graphWidth) * pointText.ActualWidth));
pointText.SetValue(Canvas.TopProperty, textLocation);
graphArea.Children.Add(highlightedPointCanvas);
}
}
}
}
}
示例9: GetStacked3DAreaFrontFace
/// <summary>
/// Get Stacked3DArea front face
/// </summary>
/// <param name="faces">Faces</param>
/// <param name="areaParams">Area parameters</param>
/// <returns>Canvas</returns>
internal static Canvas GetStacked3DAreaFrontFace(ref Faces faces, PolygonalChartShapeParams areaParams)
{
Polygon polygon = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference, VisualElementName = "AreaBase" } };
faces.Parts.Add(polygon);
Point centroid = GetCentroid(areaParams.Points);
Rect size = GetBounds(areaParams.Points);
polygon.SetValue(Canvas.ZIndexProperty, (Int32)centroid.Y + 1000);
polygon.Fill = areaParams.Lighting ? Graphics.GetFrontFaceBrush(areaParams.Background) : areaParams.Background;
polygon.Stroke = areaParams.BorderColor;
polygon.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
polygon.StrokeThickness = areaParams.BorderThickness;
polygon.StrokeMiterLimit = 1;
polygon.Points = areaParams.Points;
polygon.Stretch = Stretch.Fill;
polygon.Width = size.Width;
polygon.Height = size.Height;
polygon.SetValue(Canvas.TopProperty, areaParams.Depth3D);
polygon.SetValue(Canvas.LeftProperty, 0.0);
Canvas polygonSet = new Canvas() { Tag = new ElementData() { Element = areaParams.TagReference } };
polygonSet.Width = size.Width + areaParams.Depth3D;
polygonSet.Height = size.Height + areaParams.Depth3D;
polygonSet.SetValue(Canvas.TopProperty, size.Top - areaParams.Depth3D);
polygonSet.SetValue(Canvas.LeftProperty, size.Left);
polygonSet.Children.Add(polygon);
return polygonSet;
}
示例10: GetStacked3DSideFaces
/// <summary>
/// Get Stacked3D side faces
/// </summary>
/// <param name="faces">Faces</param>
/// <param name="areaParams">Area parameters</param>
/// <returns>Canvas</returns>
private static Canvas GetStacked3DSideFaces(ref Faces faces, PolygonalChartShapeParams areaParams)
{
Point centroid;
Brush sideBrush = areaParams.Lighting ? Graphics.GetRightFaceBrush(areaParams.Background) : areaParams.Background;
Brush topBrush = areaParams.Lighting ? Graphics.GetTopFaceBrush(areaParams.Background) : areaParams.Background;
Int32 pointIndexLimit = areaParams.IsPositive ? areaParams.Points.Count - 1 : areaParams.Points.Count;
Canvas polygonSet = new Canvas();
Rect size = GetBounds(areaParams.Points);
polygonSet.Width = size.Width + areaParams.Depth3D;
polygonSet.Height = size.Height + areaParams.Depth3D;
polygonSet.SetValue(Canvas.TopProperty, size.Top - areaParams.Depth3D);
polygonSet.SetValue(Canvas.LeftProperty, size.Left);
for (Int32 i = 0; i < pointIndexLimit; i++)
{
Polygon sides = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference } };
PointCollection points = new PointCollection();
Int32 index1 = i % areaParams.Points.Count;
Int32 index2 = (i + 1) % areaParams.Points.Count;
points.Add(areaParams.Points[index1]);
points.Add(areaParams.Points[index2]);
points.Add(new Point(areaParams.Points[index2].X + areaParams.Depth3D, areaParams.Points[index2].Y - areaParams.Depth3D));
points.Add(new Point(areaParams.Points[index1].X + areaParams.Depth3D, areaParams.Points[index1].Y - areaParams.Depth3D));
sides.Points = points;
centroid = GetCentroid(points);
Int32 zindex = GetAreaZIndex(centroid.X, centroid.Y, areaParams.IsPositive);
sides.SetValue(Canvas.ZIndexProperty, zindex);
if (i == (areaParams.Points.Count - 2))
{
sides.Fill = sideBrush;
(sides.Tag as ElementData).VisualElementName = "Side";
}
else
{
sides.Fill = topBrush;
(sides.Tag as ElementData).VisualElementName = "Top";
}
sides.Stroke = areaParams.BorderColor;
sides.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
sides.StrokeThickness = areaParams.BorderThickness;
sides.StrokeMiterLimit = 1;
Rect sidesBounds = GetBounds(points);
sides.Stretch = Stretch.Fill;
sides.Width = sidesBounds.Width;
sides.Height = sidesBounds.Height;
sides.SetValue(Canvas.TopProperty, sidesBounds.Y - (size.Top - areaParams.Depth3D));
sides.SetValue(Canvas.LeftProperty, sidesBounds.X - size.X);
faces.Parts.Add(sides);
polygonSet.Children.Add(sides);
}
return polygonSet;
}
示例11: Get3DArea
/// <summary>
/// Get visual of Area 3D
/// </summary>
/// <param name="faces">Faces</param>
/// <param name="areaParams">AreaParams</param>
/// <returns>Canvas</returns>
internal static Canvas Get3DArea(DataSeries currentDataSeries, ref Faces faces, PolygonalChartShapeParams areaParams)
{
Canvas visual = new Canvas();
visual.Width = areaParams.Size.Width;
visual.Height = areaParams.Size.Height;
Point centroid;
Brush sideBrush = areaParams.Lighting ? Graphics.GetRightFaceBrush(areaParams.Background) : areaParams.Background;
Brush topBrush = areaParams.Lighting ? Graphics.GetTopFaceBrush(areaParams.Background) : areaParams.Background;
Int32 pointIndexLimit = areaParams.IsPositive ? areaParams.Points.Count - 1 : areaParams.Points.Count;
Canvas polygonSet = new Canvas();
Rect size = GetBounds(areaParams.Points);
polygonSet.Width = size.Width + areaParams.Depth3D;
polygonSet.Height = size.Height + areaParams.Depth3D;
polygonSet.SetValue(Canvas.TopProperty, size.Top - areaParams.Depth3D);
polygonSet.SetValue(Canvas.LeftProperty, size.Left);
visual.Children.Add(polygonSet);
for (Int32 i = 0; i < pointIndexLimit; i++)
{
Polygon sides = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference } };
PointCollection points = new PointCollection();
Int32 index1 = i % areaParams.Points.Count;
Int32 index2 = (i + 1) % areaParams.Points.Count;
points.Add(areaParams.Points[index1]);
points.Add(areaParams.Points[index2]);
points.Add(new Point(areaParams.Points[index2].X + areaParams.Depth3D, areaParams.Points[index2].Y - areaParams.Depth3D));
points.Add(new Point(areaParams.Points[index1].X + areaParams.Depth3D, areaParams.Points[index1].Y - areaParams.Depth3D));
sides.Points = points;
centroid = GetCentroid(points);
Int32 zindex = GetAreaZIndex(centroid.X, centroid.Y, areaParams.IsPositive);
sides.SetValue(Canvas.ZIndexProperty, zindex);
if (i == (areaParams.Points.Count - 2))
{
sides.Fill = sideBrush;
(sides.Tag as ElementData).VisualElementName = "Side";
}
else
{
sides.Fill = topBrush;
(sides.Tag as ElementData).VisualElementName = "Top";
}
sides.Stroke = areaParams.BorderColor;
sides.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
sides.StrokeThickness = areaParams.BorderThickness;
sides.StrokeMiterLimit = 1;
Rect sidesBounds = GetBounds(points);
sides.Stretch = Stretch.Fill;
sides.Width = sidesBounds.Width;
sides.Height = sidesBounds.Height;
sides.SetValue(Canvas.TopProperty, sidesBounds.Y - (size.Top - areaParams.Depth3D));
sides.SetValue(Canvas.LeftProperty, sidesBounds.X - size.X);
faces.Parts.Add(sides);
polygonSet.Children.Add(sides);
}
Polygon polygon = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference, VisualElementName = "AreaBase" } };
faces.Parts.Add(polygon);
centroid = GetCentroid(areaParams.Points);
polygon.SetValue(Canvas.ZIndexProperty, (Int32)centroid.Y + 1000);
polygon.Fill = areaParams.Lighting ? Graphics.GetFrontFaceBrush(areaParams.Background) : areaParams.Background;
polygon.Stroke = areaParams.BorderColor;
polygon.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
polygon.StrokeThickness = areaParams.BorderThickness;
polygon.StrokeMiterLimit = 1;
polygon.Points = areaParams.Points;
polygon.Stretch = Stretch.Fill;
polygon.Width = size.Width;
polygon.Height = size.Height;
polygon.SetValue(Canvas.TopProperty, areaParams.Depth3D);
polygon.SetValue(Canvas.LeftProperty, 0.0);
// apply area animation
if (areaParams.AnimationEnabled)
{
// apply animation to the entire canvas that was used to create the area
areaParams.Storyboard = ApplyAreaAnimation(currentDataSeries, polygonSet, areaParams.Storyboard, areaParams.IsPositive, 0);
}
//.........这里部分代码省略.........
示例12: btnDesigner_Click
private void btnDesigner_Click(object sender, RoutedEventArgs e)
{
if (cmbScript.Items.Count > 0)
{
if (cmbScript.SelectedItem != null)
{
if (cnv == null)
{
cnv = new Canvas();
cnv.Height = 768;
cnv.Width = 1024;
cnv.SetValue(Canvas.LeftProperty, 0.0);
cnv.SetValue(Canvas.TopProperty, 0.0);
//ctlDesigner = new ctlScriptDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString());
ctlDesigner = new ctlScriptDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString());
((ctlScriptDesigner)ctlDesigner).btnBack.Focus();
ctlDesigner.SctiptID = int.Parse(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString());
// ctlDesigner.ScriptName = ((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString();
prevScript = ctlDesigner.SctiptID;
ctlDesigner.GetQuestions();
cnv.Children.Add(ctlDesigner);
cnvMain.Children.Add(cnv);
if (c != null)
c.Visibility = Visibility.Collapsed;
}
else
{
cnv.Children.Clear();
cnv = new Canvas();
cnv.Height = 768;
cnv.Width = 1024;
cnv.SetValue(Canvas.LeftProperty, 0.0);
cnv.SetValue(Canvas.TopProperty, 0.0);
//ctlDesigner = new ctlScriptDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString());
ctlDesigner = new ctlScriptDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString());
((ctlScriptDesigner)ctlDesigner).btnBack.Focus();
ctlDesigner.SctiptID = int.Parse(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString());
// ctlDesigner.ScriptName = ((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString();
prevScript = ctlDesigner.SctiptID;
ctlDesigner.GetQuestions();
cnv.Children.Add(ctlDesigner);
cnvMain.Children.Add(cnv);
if (c != null)
c.Visibility = Visibility.Collapsed;
//cnv.Visibility = Visibility.Visible;
//if (c != null)
// c.Visibility = Visibility.Collapsed;
//if (prevScript != int.Parse(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString()))
//{
// ctlDesigner = new ctlScriptDesigner();
// ctlDesigner.SctiptID = int.Parse(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString());
// ctlDesigner.ScriptName = ((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString();
// prevScript = ctlDesigner.SctiptID;
// ctlDesigner.GetQuestions();
// cnv.Children.Add(ctlDesigner);
//}
}
}
else
{
MessageBox.Show("Please Select The Script First", "-> Designer", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
//v
else
{
MessageBox.Show("currently there are no scripts ");
}
//NavigationService.GetNavigationService(this).Navigate(new Uri("pgDesigner.xaml",UriKind.RelativeOrAbsolute));
}
示例13: CreateIndicators
/// <summary>
/// Create Indicators for Axis and Plotarea
/// </summary>
private void CreateIndicators()
{
if (_axisCallOutContainer == null && _axisIndicatorBorderElement == null)
{
//_axisIndicatorElement = new StackPanel();
_axisCallOutContainer = new Canvas();
_axisCallOutContainer.SetValue(Canvas.ZIndexProperty, -1);
_axisCallOutContainer.Height = 8;
_axisCallOutContainer.HorizontalAlignment = HorizontalAlignment.Center;
PathGeometry pathGeometry = new PathGeometry();
_callOutPath4AxisIndicator = new System.Windows.Shapes.Path();
_callOutPath4AxisIndicator.Fill = new SolidColorBrush(Colors.LightGray); // new SolidColorBrush(Color.FromArgb((Byte)153, (Byte)153, (Byte)153, (Byte)153));
_callOutPath4AxisIndicator.Data = pathGeometry;
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(-6, 8);
pathGeometry.Figures.Add(pathFigure);
LineSegment lineSegment = new LineSegment();
lineSegment.Point = new Point(0, 0);
pathFigure.Segments.Add(lineSegment);
lineSegment = new LineSegment();
lineSegment.Point = new Point(6, 8);
pathFigure.Segments.Add(lineSegment);
_axisCallOutContainer.Children.Add(_callOutPath4AxisIndicator);
_axisIndicatorBorderElement = new Border();
_axisIndicatorBorderElement.SetValue(Canvas.ZIndexProperty, -1);
_axisIndicatorBorderElement.CornerRadius = new CornerRadius(3);
_axisIndicatorBorderElement.MinWidth = 25;
_axisIndicatorBorderElement.HorizontalAlignment = HorizontalAlignment.Center;
_axisIndicatorBorderElement.Padding = new Thickness(5, 0, 5, 0);
_axisIndicatorBorderElement.Background = new SolidColorBrush(Colors.LightGray); // new SolidColorBrush(Color.FromArgb((Byte)153, (Byte)153, (Byte)153, (Byte)153));
_axisIndicatorTextBlock = new TextBlock();
_axisIndicatorTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
_axisIndicatorBorderElement.Child = _axisIndicatorTextBlock;
Chart._toolTipCanvas.Children.Add(_axisCallOutContainer);
Chart._toolTipCanvas.Children.Add(_axisIndicatorBorderElement);
//Chart._toolTipCanvas.Children.Add(_axisIndicatorElement);
CreateVerticalLineIndicator();
}
}
示例14: CreateLabelsAndSetPyramidCanvasSize
/// <summary>
/// Create labels and set width for the label canvas
/// </summary>
/// <param name="pyramidChartCanvas">Main Pyramid chart canvas</param>
/// <param name="labelCanvas">Label canvas for pyramid chart placed in side pyramidChartCanvas</param>
/// <param name="pyramidSeries">DataSeries reference</param>
private static void CreateLabelsAndSetPyramidCanvasSize(Grid pyramidChartCanvas, Canvas labelCanvas, Canvas pyramidCanvas, List<DataPoint> pyramidDataPoints)
{
Int32 index = 0;
Double totalLabelsHeight = 0;
_streamLineParentTitleSize = new Size(0, 0);
labelCanvas.Width = 0;
for (; index < pyramidDataPoints.Count; index++)
{
// Create label for a pyramid slice
pyramidDataPoints[index].LabelVisual = CreateLabelForDataPoint(pyramidDataPoints[index], index);
// Calculate label size
Size labelSize = Graphics.CalculateVisualSize(pyramidDataPoints[index].LabelVisual);
labelSize.Width += 2.5;
if ((Boolean)pyramidDataPoints[index].LabelEnabled && pyramidDataPoints[index].LabelStyle == LabelStyles.OutSide)
totalLabelsHeight += labelSize.Height;
if (labelSize.Width > labelCanvas.Width && (Boolean)pyramidDataPoints[index].LabelEnabled && pyramidDataPoints[index].LabelStyle == LabelStyles.OutSide) // && !(isStreamLine && index == 0))
labelCanvas.Width = labelSize.Width;
pyramidDataPoints[index].LabelVisual.Height = labelSize.Height;
pyramidDataPoints[index].LabelVisual.Width = labelSize.Width;
}
labelCanvas.Width += Chart.BEVEL_DEPTH;
pyramidCanvas.Width = Math.Max(pyramidChartCanvas.Width - labelCanvas.Width, 0);
labelCanvas.SetValue(Canvas.LeftProperty, pyramidCanvas.Width);
}
示例15: CreatePyramidSlice
//.........这里部分代码省略.........
Point[] pyramidCornerPoints = new Point[8];
pyramidCornerPoints[0] = new Point(topRadius - pyramidSlice.TopRadius, 0);
pyramidCornerPoints[1] = new Point(topRadius + pyramidSlice.TopRadius, 0);
pyramidCornerPoints[2] = new Point(topRadius + pyramidSlice.BottomRadius, pyramidSlice.Height);
pyramidCornerPoints[3] = new Point(topRadius - pyramidSlice.BottomRadius, pyramidSlice.Height);
// Apply animation for the 2D pyramid slice
if (animationEnabled)
pyramidSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(path4Slice, pyramidSlice.DataPoint.Parent, pyramidSlice.DataPoint.Parent.Storyboard, 0, pyramidSlice.DataPoint.InternalOpacity, 0, 1);
if (!isLightingGradientLayer)
{
// Update faces for the DataPoint
faces = new Faces();
faces.VisualComponents.Add(path4Slice);
(path4Slice.Tag as ElementData).VisualElementName = "PyramidBase";
faces.Parts.Add(path4Slice);
faces.BorderElements.Add(path4Slice);
path4Slice.StrokeThickness = pyramidSlice.DataPoint.BorderThickness.Left;
path4Slice.Stroke = pyramidSlice.DataPoint.BorderColor;
path4Slice.StrokeDashArray = ExtendedGraphics.GetDashArray((BorderStyles)pyramidSlice.DataPoint.BorderStyle);
pyramidSlice.DataPoint.Faces = faces;
// Apply bevel effect for the 2D pyramid Slice
if (pyramidSlice.DataPoint.Parent.Bevel)
{
ApplyPyramidBevel(visual, pyramidSlice, sideFillColor, pyramidCornerPoints);
}
}
else
{
path4Slice.IsHitTestVisible = false;
pyramidSlice.DataPoint.Faces.VisualComponents.Add(path4Slice);
(path4Slice.Tag as ElementData).VisualElementName = "Lighting";
}
}
if (isLightingGradientLayer)
{
visual.IsHitTestVisible = false;
}
else
{
// Drawing LabelLine
Canvas labelLineCanvas = CreateLabelLine(pyramidSlice, pyramid3DSlice, topRadius, animationEnabled);
if (labelLineCanvas != null)
{
sliceCanvas.Children.Add(labelLineCanvas);
faces.VisualComponents.Add(labelLineCanvas);
}
// Add label visual to the visual
if ((Boolean)pyramidSlice.DataPoint.LabelEnabled)
{
Canvas labelCanvas = new Canvas();
labelCanvas.SetValue(Canvas.ZIndexProperty, (Int32)10);
faces.VisualComponents.Add(pyramidSlice.DataPoint.LabelVisual);
// Label placement
if (pyramidSlice.DataPoint.LabelStyle == LabelStyles.OutSide)
{
pyramidSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, pyramidSlice.LabelLineEndPoint.Y - pyramidSlice.DataPoint.LabelVisual.Height / 2);
pyramidSlice.DataPoint.LabelVisual.SetValue(Canvas.LeftProperty, pyramidSlice.LabelLineEndPoint.X + 2);
}
else
{
if(is3D)
{
Point centerPoint = Graphics.MidPointOfALine(pyramid3DSlice.Top3DLayer.CB, pyramid3DSlice.Bottom3DLayer.CB);
pyramidSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, (centerPoint.Y - pyramidSlice.DataPoint.LabelVisual.Height / 2));
}
else
pyramidSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, pyramidSlice.LabelLineEndPoint.Y - pyramidSlice.DataPoint.LabelVisual.Height / 2);
pyramidSlice.DataPoint.LabelVisual.SetValue(Canvas.LeftProperty, topRadius - pyramidSlice.DataPoint.LabelVisual.Width / 2);
}
if (animationEnabled)
pyramidSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(pyramidSlice.DataPoint.LabelVisual, pyramidSlice.DataPoint.Parent, pyramidSlice.DataPoint.Parent.Storyboard, 1.2, 0.5, 0, 1);
labelCanvas.Children.Add(pyramidSlice.DataPoint.LabelVisual);
sliceCanvas.Children.Add(labelCanvas);
}
}
// if (!isLightingGradientLayer)
// faces.Visual = visual;
sliceCanvas.Children.Add(visual);
// sliceCanvas.Background = new SolidColorBrush(Color.FromArgb((byte)rand.Next(0,200),(byte)rand.Next(0,200),(byte)rand.Next(0,200),(byte)rand.Next(0,200)));
return sliceCanvas;
}