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); }); }
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")); } }
/// <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(); }
/// <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); //if (funnelSlice.DataPoint.Parent.Bevel) funnelTopEllipse.StrokeThickness = 1.24; //else // funnelTopEllipse.StrokeThickness = 0.24; funnelTopEllipse.Stroke = Graphics.GetBevelTopBrush(topSurfaceStroke, 0); visual.Children.Add(funnelTopEllipse); if (!isLightingGradientLayer) { // Update faces for the DataPoint faces = new Faces(); faces.VisualComponents.Add(path4Slice); faces.VisualComponents.Add(funnelTopEllipse); (path4Slice.Tag as ElementData).VisualElementName = "FunnelBase"; (funnelTopEllipse.Tag as ElementData).VisualElementName = "FunnelTop"; #region Creating Seperate BorderLine GeometryGroup borderGeometryGroup = new GeometryGroup(); // PathGeometry for for a funnel slice path PathGeometry leftRightBorderPathGeometry = new PathGeometry(); // LeftLine Border PathFigure leftBorderPathFigure = new PathFigure() { StartPoint = pathFigure.StartPoint }; LineSegment leftBorderLineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.BottomRadius, funnelSlice.Height) }; leftBorderPathFigure.Segments.Add(leftBorderLineSegment); leftRightBorderPathGeometry.Figures.Add(leftBorderPathFigure); // RightLine Border PathGeometry rightRightBorderPathGeometry = new PathGeometry(); PathFigure rightBorderPathFigure = new PathFigure() { StartPoint = new Point(topRadius + funnelSlice.TopRadius, 0) }; LineSegment rightBorderLineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.BottomRadius, funnelSlice.Height) }; rightBorderPathFigure.Segments.Add(rightBorderLineSegment); rightRightBorderPathGeometry.Figures.Add(rightBorderPathFigure); // Bottom _axisIndicatorBorderElement Ellipse EllipseGeometry ellipseGeometryBorder = new EllipseGeometry(); ellipseGeometryBorder.Center = new Point(topRadius, funnelSlice.Height); ellipseGeometryBorder.RadiusX = funnelSlice.BottomRadius; ellipseGeometryBorder.RadiusY = yScaleBottom / 2; borderGeometryGroup.Children.Add(ellipseGeometryBorder); // Bottom _axisIndicatorBorderElement Ellipse ellipseGeometryBorder = new EllipseGeometry(); ellipseGeometryBorder.Center = new Point(topRadius, 0); ellipseGeometryBorder.RadiusX = funnelSlice.TopRadius; ellipseGeometryBorder.RadiusY = yScaleTop / 2; borderGeometryGroup.Children.Add(ellipseGeometryBorder); borderGeometryGroup.Children.Add(leftRightBorderPathGeometry); borderGeometryGroup.Children.Add(rightRightBorderPathGeometry); Path borderPath = new Path() { Data = borderGeometryGroup, IsHitTestVisible = false }; borderPath.SetValue(Canvas.ZIndexProperty, (Int32)(-1)); visual.Children.Add(borderPath); faces.BorderElements.Add(borderPath); faces.BorderElements.Add(funnelTopEllipse); #endregion faces.Parts.Add(path4Slice); faces.Parts.Add(funnelTopEllipse); funnelSlice.DataPoint.Faces = faces; } else { if (funnelSlice.FillType == FillType.Solid && funnelSlice.Index == 0) { path4Slice.SetValue(Canvas.ZIndexProperty, 1); path4Slice.SetValue(Canvas.TopProperty, (-SOLID_FUNNEL_EDGE_THICKNESS)); funnelSlice.Height -= SOLID_FUNNEL_EDGE_THICKNESS; } path4Slice.IsHitTestVisible = false; funnelTopEllipse.IsHitTestVisible = false; funnelSlice.DataPoint.Faces.Parts.Add(path4Slice); funnelSlice.DataPoint.Faces.Parts.Add(funnelTopEllipse); funnelSlice.DataPoint.Faces.VisualComponents.Add(path4Slice); funnelSlice.DataPoint.Faces.VisualComponents.Add(funnelTopEllipse); (path4Slice.Tag as ElementData).VisualElementName = "Lighting"; (funnelTopEllipse.Tag as ElementData).VisualElementName = "FunnelTopLighting"; } // Apply animation for the 3D funnel slice if (animationEnabled) { funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(funnelTopEllipse, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 0, funnelSlice.DataPoint.InternalOpacity, 0, 1); funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(path4Slice, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 0, funnelSlice.DataPoint.InternalOpacity, 0, 1); } #endregion } else { // Points of a 2D funnel slice Point[] funnelCornerPoints = new Point[8]; // Top line LineSegment lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.BottomRadius, funnelSlice.Height) }; pathFigure.Segments.Add(lineSegment); funnelCornerPoints[3] = lineSegment.Point; // Right line lineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.BottomRadius, funnelSlice.Height) }; pathFigure.Segments.Add(lineSegment); funnelCornerPoints[2] = lineSegment.Point; // Bottom line lineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.TopRadius, 0) }; pathFigure.Segments.Add(lineSegment); funnelCornerPoints[1] = lineSegment.Point; // Left line lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.TopRadius, 0) }; pathFigure.Segments.Add(lineSegment); funnelCornerPoints[0] = lineSegment.Point; // Apply animation for the 2D funnel slice if (animationEnabled) funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(path4Slice, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 0, funnelSlice.DataPoint.InternalOpacity, 0, 1); if (!isLightingGradientLayer) { // Update faces for the DataPoint faces = new Faces(); faces.VisualComponents.Add(path4Slice); (path4Slice.Tag as ElementData).VisualElementName = "FunnelBase"; faces.Parts.Add(path4Slice); faces.BorderElements.Add(path4Slice); funnelSlice.DataPoint.Faces = faces; // Apply bevel effect for the 2D funnel Slice if (funnelSlice.DataPoint.Parent.Bevel) { ApplyFunnelBevel(visual, funnelSlice, sideFillColor, funnelCornerPoints); } } else { path4Slice.IsHitTestVisible = false; funnelSlice.DataPoint.Faces.VisualComponents.Add(path4Slice); (path4Slice.Tag as ElementData).VisualElementName = "Lighting"; } } if (isLightingGradientLayer) { visual.IsHitTestVisible = false; } else { // Drawing LabelLine Canvas labelLineCanvas = CreateLabelLine(funnelSlice, topRadius, animationEnabled); if (labelLineCanvas != null) { sliceCanvas.Children.Add(labelLineCanvas); faces.VisualComponents.Add(labelLineCanvas); } // Add label visual to the visual if ((Boolean)funnelSlice.DataPoint.LabelEnabled) { Canvas labelCanvas = new Canvas(); labelCanvas.SetValue(Canvas.ZIndexProperty, (Int32)10); faces.VisualComponents.Add(funnelSlice.DataPoint.LabelVisual); // Label placement funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, funnelSlice.LabelLineEndPoint.Y - funnelSlice.DataPoint.LabelVisual.Height / 2); if (funnelSlice.DataPoint.LabelStyle == LabelStyles.OutSide) { funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, funnelSlice.LabelLineEndPoint.Y - funnelSlice.DataPoint.LabelVisual.Height / 2); funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.LeftProperty, funnelSlice.LabelLineEndPoint.X); } else { funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, funnelSlice.LabelLineEndPoint.Y - funnelSlice.DataPoint.LabelVisual.Height / 2 + (is3D ? yScaleTop / 2 : 0)); funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.LeftProperty, topRadius - funnelSlice.DataPoint.LabelVisual.Width / 2); } if (animationEnabled) funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(funnelSlice.DataPoint.LabelVisual, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 1.2, 0.5, 0, 1); labelCanvas.Children.Add(funnelSlice.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; }
protected override void OnRender(System.Windows.Media.DrawingContext dc) { _cursorCanvas.SetValue(Canvas.TopProperty, (double)_cursorY + (charHeight - cursorHeight)); _cursorCanvas.SetValue(Canvas.LeftProperty, (double)_cursorX); }
//コンストラクタ public Channel(Sequence _parent, int divisionCount) { parent = _parent; nodes = new List<Node>(); panel = new StackPanel() { }; Text_rowIndex = new TextBlock() { Background=Brushes.Black , Foreground=Brushes.White }; Text_virtualName = new TextBox() { Text = "IO " + uniqueId, Background = Brushes.LightGray, ContextMenu = new ContextMenu() }; Text_rowIndex.ContextMenuOpening += (object sender, ContextMenuEventArgs arg) => CheckContextMenuOfLabel(); uniqueId++; ADCombo = new ComboBox() { }; ADCombo.Items.Add("Analog"); ADCombo.Items.Add("Digital"); ADCombo.SelectedIndex = 0; ADCombo.SelectionChanged += ((s, e) => updateItemList()); IOCombo = new ComboBox() { }; IOCombo.Items.Add("Out"); IOCombo.Items.Add("In"); IOCombo.SelectedIndex = 0; IOCombo.SelectionChanged += ((s, e) => updateItemList()); // IOCombo.IsEnabled = false; Combo_channelName = new ComboBox() { }; foreach (string str in TaskManager.GetInstance().getAnalogOutputList()) { Combo_channelName.Items.Add(str); } Text_minVoltage = new TextBox() { Text = "-1" , Width=40}; Text_minVoltage.TextChanged += (s, e) => repaint(); Text_maxVoltage = new TextBox() { Text = "1", Width=40 }; Text_maxVoltage.TextChanged += (s, e) => repaint(); panel.Children.Add(Text_rowIndex); panel.Children.Add(Text_virtualName); { StackPanel miniStack = new StackPanel() { Orientation = Orientation.Horizontal }; miniStack.Children.Add(ADCombo); miniStack.Children.Add(IOCombo); panel.Children.Add(miniStack); } panel.Children.Add(Combo_channelName); { StackPanel miniStack = new StackPanel() { Orientation = Orientation.Horizontal }; miniStack.Children.Add(Text_minVoltage); miniStack.Children.Add(new Label() { Content = "V ~ " }); miniStack.Children.Add(Text_maxVoltage); miniStack.Children.Add(new Label() { Content = "V" }); panel.Children.Add(miniStack); } for (int i = 0; i < divisionCount - 1; i++) { nodes.Add(new Node(this) { index = i, value = 0, type = NodeType.Hold, isEnd = false }); } nodes.Add(new Node(this) { index = divisionCount-1, value = 0, type = NodeType.Hold, isEnd = true }); canvas = new Canvas() { Background = Brushes.White, ContextMenu = new ContextMenu() }; canvas.SetValue(Grid.ColumnSpanProperty, divisionCount); canvas.ContextMenuOpening += (object sender, ContextMenuEventArgs e) => CheckContextMenuOfCanvas(); repaintValueBoxes(); }
public void DisplayChar(char c) { if (_currentInfo.Font == ZFont.GRAPHICS_FONT) { invoke(() => { #if !TEMP String lines = null; if (graphicsChars.ContainsKey(c)) { lines = graphicsChars[c]; } else { String temp = Frotz.Other.GraphicsFont.getLines(c); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 8; i++) { int x = Convert.ToInt32(temp.Substring(i * 2, 2), 16); for (int j = 0; j < 8; j++) { int toggled = (x >> j) & 1; if (toggled == 1) { //sb.AppendFormat("<Line X1=\"{0}\" Y1=\"{1}\" X2=\"{2}\" Y2=\"{3}\" Stroke=\"White\" StrokeThickness=\"1\" />\r\n", // j, i, j + 1, i + 1); sb.AppendFormat("M {0} {1} L {2} {3} ", j, i, j + 1, i); } } } lines = String.Format(@" <Image xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Width=""8"" Height=""8"" Stretch=""None""> <Image.Source> <DrawingImage> <DrawingImage.Drawing> <GeometryDrawing Geometry=""{0} ""> <GeometryDrawing.Pen> <Pen Brush=""White"" Thickness=""1"" /> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingImage.Drawing> </DrawingImage> </Image.Source> </Image>", sb.ToString()); sb.ToString(); graphicsChars.Add(c, lines); //var sw = new System.IO.StreamWriter(String.Format(@"c:\temp\{0}.xaml", (byte)c)); //sw.Write(lines); //sw.Close(); } //String temp = String.Format("<Canvas xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">{0}</Canvas>", Frotz.Other.GraphicsFont.getLines(c)); //temp = temp.Replace("Black", "White"); Image img = System.Windows.Markup.XamlReader.Parse(lines) as Image; Canvas cnvs = new Canvas(); cnvs.Children.Add(img); img.SnapsToDevicePixels = true; // img.Stretch = Stretch.Uniform; cnvs.SetValue(Canvas.TopProperty, (double)_cursorY); cnvs.SetValue(Canvas.LeftProperty, (double)_cursorX); cnvs.SetValue(Canvas.RightProperty, (double)(_cursorX + _metrics.FontSize.Width)); cnvs.SetValue(Canvas.BottomProperty, (double)(_cursorY + _metrics.FontSize.Height)); _cursorX += _metrics.FontSize.Width; mainCanvas.Children.Add(cnvs); #else var bmp = Frotz.Other.GraphicsFont.getImage(c); var ms = new System.IO.MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); bmp.Save("C:\\TEMP\\TEST.BMP"); ms.Position = 0; Image img = new Image(); BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = ms; bi.EndInit(); img.Source = bi; img.Stretch = Stretch.Fill; img.SetValue(Canvas.TopProperty, (double)_cursorY); img.SetValue(Canvas.LeftProperty, (double)_cursorX); img.SetValue(Canvas.RightProperty, (double)(_cursorX + _metrics.FontSize.Width)); img.SetValue(Canvas.BottomProperty, (double)(_cursorY + _metrics.FontSize.Height)); // _cursorX += Convert.ToInt32(bi.Width); _cursorX += _metrics.FontSize.Width; mainCanvas.Children.Add(img); //Image img = new Image(); //img.Source = null; //BitmapImage bi = new BitmapImage(); // //Image img = new Image(); //BitmapImage bi = new BitmapImage(); //bi.BeginInit(); //bi.StreamSource = new System.IO.MemoryStream(ScaleImages.Scale(buffer, scale)); //bi.EndInit(); //img.Source = bi; //int newX = x; //int newY = y; //if (newY > short.MaxValue) newY -= ushort.MaxValue; //if (newX > short.MaxValue) newX -= ushort.MaxValue; //img.SetValue(Canvas.TopProperty, (double)newY); //img.SetValue(Canvas.LeftProperty, (double)newX); //mainCanvas.Children.Add(img); #endif }); } else { _currentText.Append(c); } }
private Canvas DrawGrid(double height) { Canvas gridBackGround = new Canvas(); for (int i = _startViewYear; i < _endViewYear; i += 5) { gridBackGround.Children.Add(DrawGridLine(i, height)); } gridBackGround.Children.Add(DrawGridLine(_endViewYear, height)); gridBackGround.SetValue(Canvas.TopProperty, 0); gridBackGround.SetValue(Canvas.LeftProperty, 0); gridBackGround.Width = Width; gridBackGround.Height = height; return gridBackGround; }
/// <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; }
/// <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); } polygonSet.Children.Add(polygon); return visual; }
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)); }
/// <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(); } }
/// <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); }
/// <summary> /// Create a slice of a pyramid /// </summary> /// <param name="isLightingGradientLayer">Whether CreatePyramidSlice() function should create a layer for lighting</param> /// <param name="topRadius">Top Radius of the pyramid</param> /// <param name="is3D">Whether the chart is a 3D Chart</param> /// <param name="pyramidSlice">PyramidSlice 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 pyramid slice canvas</returns> private static Canvas CreatePyramidSlice(Boolean isLightingGradientLayer, Double topRadius, Boolean is3D, TriangularChartSliceParms pyramidSlice, Double yScaleTop, Double yScaleBottom, Brush sideFillColor, Brush topFillColor, Brush topSurfaceStroke, Boolean animationEnabled) { Canvas sliceCanvas = new Canvas() { Tag = new ElementData() { Element = pyramidSlice.DataPoint } }; Canvas visual = new Canvas() { Width = topRadius * 2, Height = pyramidSlice.Height, Tag = new ElementData() { Element = pyramidSlice.DataPoint } }; // Canvas holds a slice of a pyramid chart Faces faces = null; //visual.Background = Graphics.GetRandomColor(); Pyramid2DSlice pyramid2DSlice = new Pyramid2DSlice() { LT = new Point(topRadius - Math.Abs(pyramidSlice.TopRadius), 0), RT = new Point(topRadius + Math.Abs(pyramidSlice.TopRadius), 0), LB = new Point(topRadius - Math.Abs(pyramidSlice.BottomRadius), pyramidSlice.Height), RB = new Point(topRadius + Math.Abs(pyramidSlice.BottomRadius), pyramidSlice.Height) }; Pyramid3DSlice pyramid3DSlice = null; if (is3D) { Double opacity = pyramidSlice.DataPoint.Opacity * pyramidSlice.DataPoint.Parent.Opacity; pyramid3DSlice = new Pyramid3DSlice(pyramid2DSlice, Math.Abs(yScaleTop / 2), Math.Abs(yScaleBottom / 2) , isLightingGradientLayer ? new SolidColorBrush(Colors.Transparent) : pyramidSlice.DataPoint.Color , (pyramidSlice.Index == 0) , (Boolean)pyramidSlice.DataPoint.LightingEnabled, opacity); List<Path> paths = new List<Path>(); Path lightingLayerLeft = null, lightingLayerFront = null, lightingLayerRight = null; Path backLayerLeft = pyramid3DSlice.GetFace(Pyramid3dLayer.BackLayerLeft, pyramidSlice.DataPoint, !isLightingGradientLayer); Path backLayerRight = pyramid3DSlice.GetFace(Pyramid3dLayer.BackLayerRight, pyramidSlice.DataPoint, !isLightingGradientLayer); Path bottomLayer = pyramid3DSlice.GetFace(Pyramid3dLayer.BottomLayer, pyramidSlice.DataPoint, !isLightingGradientLayer); Path frontLayerLeft = pyramid3DSlice.GetFace(Pyramid3dLayer.FrontLayerLeft, pyramidSlice.DataPoint, !isLightingGradientLayer); Path frontLayerRight = pyramid3DSlice.GetFace(Pyramid3dLayer.FrontLayerRight, pyramidSlice.DataPoint, !isLightingGradientLayer); Path topLayer = pyramid3DSlice.GetFace(Pyramid3dLayer.TopLayer, pyramidSlice.DataPoint, !isLightingGradientLayer); paths.Add(backLayerLeft); paths.Add(backLayerRight); paths.Add(bottomLayer); paths.Add(frontLayerLeft); paths.Add(frontLayerRight); paths.Add(topLayer); if ((Boolean)pyramidSlice.DataPoint.LightingEnabled && !isLightingGradientLayer) { if (pyramidSlice.Index != 0) paths.Add(lightingLayerLeft = pyramid3DSlice.GetFace(Pyramid3dLayer.LightingLayerLeft, pyramidSlice.DataPoint, !isLightingGradientLayer)); paths.Add(lightingLayerFront = pyramid3DSlice.GetFace(Pyramid3dLayer.LightingLayerFront, pyramidSlice.DataPoint, !isLightingGradientLayer)); if (pyramidSlice.Index != 0) paths.Add(lightingLayerRight = pyramid3DSlice.GetFace(Pyramid3dLayer.LightingLayerRight, pyramidSlice.DataPoint, !isLightingGradientLayer)); } foreach (Path path in paths) visual.Children.Add(path); if (!isLightingGradientLayer) { // Update faces for the DataPoint faces = new Faces(); foreach (Path path in paths) faces.VisualComponents.Add(path); foreach (Path path in paths) faces.Parts.Add(path); // If lighting is disabled then the visual components are the border elements if (!(Boolean)pyramidSlice.DataPoint.LightingEnabled) { foreach (Path path in paths) { if (path != bottomLayer && path != backLayerLeft && path != backLayerRight) faces.BorderElements.Add(path); } if(opacity < 1) faces.BorderElements.Add(bottomLayer); } pyramidSlice.DataPoint.Faces = faces; } else { faces = pyramidSlice.DataPoint.Faces; if (faces != null) { foreach (Path path in paths) { if (path != bottomLayer && path != backLayerLeft && path != backLayerRight) faces.BorderElements.Add(path); } if (opacity < 1) faces.BorderElements.Add(bottomLayer); } } if (faces.BorderElements != null) { foreach (Path path in faces.BorderElements) { path.StrokeThickness = pyramidSlice.DataPoint.BorderThickness.Left; path.Stroke = pyramidSlice.DataPoint.BorderColor; path.StrokeDashArray = ExtendedGraphics.GetDashArray((BorderStyles)pyramidSlice.DataPoint.BorderStyle); } } // Apply animation for the 3D pyramid slice if (animationEnabled) { foreach (Path path in paths) { //Double animationBeginTime = (pyramidSlice.DataPoint.Parent.InternalDataPoints.Count - pyramidSlice.Index) / pyramidSlice.DataPoint.Parent.InternalDataPoints.Count; pyramidSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(path, pyramidSlice.DataPoint.Parent, pyramidSlice.DataPoint.Parent.Storyboard, 0, pyramidSlice.DataPoint.InternalOpacity, 0, 1); } } } else { // PathGeometry for for a pyramid slice path PathGeometry pathGeometry = new PathGeometry(); // pathFigure for for a pyramid slice path PathFigure pathFigure = new PathFigure() { StartPoint = pyramid2DSlice.LT, IsClosed= true }; // PathFigure of a pyramid slice // Path for for a pyramid slice Path path4Slice = new Path() { Fill = sideFillColor }; path4Slice.Tag = new ElementData() { Element = pyramidSlice.DataPoint }; // Set path data path4Slice.Data = pathGeometry; // 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); PolyLineSegment polySeg = new PolyLineSegment(); polySeg.Points = pyramid2DSlice.GetAllPoints(); pathFigure.Segments.Add(polySeg); // Points of a 2D pyramid slice 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; }
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); } }
public PlotPanel() : base() { ClipToBounds = true; // Add Canvas objects this.Background = Brushes.White; this.HorizontalAlignment = HorizontalAlignment.Center; this.VerticalAlignment = VerticalAlignment.Center; Canvas = new Canvas(); BackgroundCanvas = new Canvas(); this.Children.Add(Canvas); this.Children.Add(BackgroundCanvas); // Canvas.ClipToBounds = true; Canvas.SetValue(Grid.ZIndexProperty, 100); BackgroundCanvas.SetValue(Grid.ZIndexProperty, 50); Axes = new Axes2D(this); //LinearGradientBrush background = new LinearGradientBrush(); //background.StartPoint = new Point(0, 0); background.EndPoint = new Point(1, 1); //background.GradientStops.Add(new GradientStop(Colors.White, 0.0)); //background.GradientStops.Add(new GradientStop(Colors.LightGray, 1.0)); Canvas.Background = Brushes.Transparent; BackgroundCanvas.Background = Brushes.White; direct2DControl = null; // if (!(this is ColourBarPanel)) this.AddInteractionEvents(); this.AddSelectionRectangle(); this.InitialiseChildenCollection(); marginChangeTimer = new DispatcherTimer(TimeSpan.FromSeconds(0.0), DispatcherPriority.Normal, marginChangeTimer_Tick, this.Dispatcher); }
/// <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; }
/// <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); } } } } }
/// <summary> /// Get visual object for area chart /// </summary> /// <param name="width">Width of the PlotArea</param> /// <param name="height">Height of the PlotArea</param> /// <param name="plotDetails">PlotDetails</param> /// <param name="seriesList">List of DataSeries with render as area chart</param> /// <param name="chart">Chart</param> /// <param name="plankDepth">PlankDepth</param> /// <param name="animationEnabled">Whether animation is enabled for chart</param> /// <returns>Area chart canvas</returns> internal static Canvas GetVisualObjectForAreaChart(Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, List<DataSeries> seriesList, Chart chart, Double plankDepth, bool animationEnabled) { if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0) return null; DataSeries series = seriesList[0] as DataSeries; if (animationEnabled) { if (series.Storyboard == null) series.Storyboard = new Storyboard(); } Canvas visual, labelCanvas, areaCanvas, areaFaceCanvas; RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out areaCanvas, width, height); areaFaceCanvas = new Canvas() { Height = height, Width = width }; Double depth3d = plankDepth / plotDetails.Layer3DCount * (chart.View3D ? 1 : 0); Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[series] + 1); visual.SetValue(Canvas.TopProperty, visualOffset); visual.SetValue(Canvas.LeftProperty, -visualOffset); labelCanvas.SetValue(Canvas.TopProperty, (Double)0); labelCanvas.SetValue(Canvas.LeftProperty, (Double)0); areaFaceCanvas.SetValue(Canvas.TopProperty, (Double)0); areaFaceCanvas.SetValue(Canvas.LeftProperty, (Double)0); //areaFaceCanvas.SetValue(Canvas.ZIndexProperty, (Int32)1); DataSeries currentDataSeries; Double minimumXValue = Double.MaxValue; Double maximumXValue = Double.MinValue; if ((Boolean)series.Enabled) { if (series.Storyboard == null) series.Storyboard = new Storyboard(); currentDataSeries = series; PlotGroup plotGroup = series.PlotGroup; Double limitingYValue = plotGroup.GetLimitingYValue(); minimumXValue = Math.Min(minimumXValue, plotGroup.MinimumX); maximumXValue = Math.Max(maximumXValue, plotGroup.MaximumX); //List<DataPoint> enabledDataPoints = (from datapoint in series.InternalDataPoints where datapoint.Enabled == true select datapoint).ToList(); Faces dataSeriesFaces = new Faces(); dataSeriesFaces.FrontFacePaths = new List<Path>(); dataSeriesFaces.Visual = areaFaceCanvas; dataSeriesFaces.LabelCanvas = labelCanvas; series.Faces = dataSeriesFaces; List<List<DataPoint>> brokenAreaDataPointsCollection = BrokenAreaDataPointsGroup(width, height, series); DataPoint currentDataPoint; DataPoint nextDataPoint; DataPoint previusDataPoint; Double plankYPos = Graphics.ValueToPixelPosition(height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue); foreach (List<DataPoint> dataPointList in brokenAreaDataPointsCollection) { if (dataPointList.Count <= 0) continue; currentDataPoint = dataPointList[0]; previusDataPoint = currentDataPoint; PointCollection points = new PointCollection(); List<DataPoint> dataPoints = new List<DataPoint>(); Path frontFacePath = null; PathGeometry frontFacePathGeometry; PathFigure frontFacePathFigure = null; Int32 maxZIndex = 0; for (Int32 i = 0; i < dataPointList.Count - 1; i++) { Path areaBase = new Path(); Faces dataPointFaces; Faces nextDataPointFaces = new Faces(); currentDataPoint = dataPointList[i]; currentDataPoint._parsedToolTipText = currentDataPoint.TextParser(currentDataPoint.ToolTipText); nextDataPoint = dataPointList[i + 1]; if (currentDataPoint.Faces == null) { dataPointFaces = new Faces(); currentDataPoint.Faces = dataPointFaces; } else dataPointFaces = currentDataPoint.Faces; nextDataPoint.Faces = nextDataPointFaces; dataPointFaces.PreviousDataPoint = previusDataPoint; dataPointFaces.NextDataPoint = nextDataPoint; if (i == 0) { // For the first DataPoint left and top face are drawn. Double xPosDataPoint = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, currentDataPoint.InternalXValue); if (chart.View3D) { // Set points for left face Area3DDataPointFace leftFace = new Area3DDataPointFace(depth3d); leftFace.FrontFacePoints.Add(new Point(xPosDataPoint, plankYPos)); // Bottom Point leftFace.FrontFacePoints.Add(currentDataPoint._visualPosition); // Top Point currentDataPoint.Faces.Area3DLeftFace = leftFace; // Set points for top left face Area3DDataPointFace topFace = new Area3DDataPointFace(depth3d); topFace.FrontFacePoints.Add(currentDataPoint._visualPosition); // Front Left Point topFace.FrontFacePoints.Add(nextDataPoint._visualPosition); // Front Right Point currentDataPoint.Faces.Area3DRightTopFace = topFace; nextDataPointFaces.Area3DLeftTopFace = topFace; } // Start creating front face of 3D area frontFacePath = new Path() { Opacity = currentDataPoint.Parent.Opacity }; //frontFacePath = new Path() { Opacity = 0.5 }; ApplyBorderProperties(frontFacePath, currentDataPoint.Parent); dataSeriesFaces.FrontFacePaths.Add(frontFacePath); frontFacePathGeometry = new PathGeometry(); frontFacePathFigure = new PathFigure() { StartPoint = new Point(xPosDataPoint, plankYPos), IsClosed = true }; frontFacePathGeometry.Figures.Add(frontFacePathFigure); frontFacePath.Data = frontFacePathGeometry; // Area front face Line path from end point to first LineSegment ls = new LineSegment() { Point = currentDataPoint._visualPosition }; frontFacePathFigure.Segments.Add(ls); dataPointFaces.AreaFrontFaceLineSegment = ls; } else { if (chart.View3D) { // DataPoint which has two different top faces at the left and right side of it position. Area3DDataPointFace topFace = new Area3DDataPointFace(depth3d); topFace.FrontFacePoints.Add(currentDataPoint._visualPosition); // Front Left Point topFace.FrontFacePoints.Add(nextDataPoint._visualPosition); // Front Right Point currentDataPoint.Faces.Area3DRightTopFace = topFace; nextDataPointFaces.Area3DLeftTopFace = topFace; } else { if(currentDataPoint.Parent.Bevel) CreateBevelFor2DArea(areaFaceCanvas, currentDataPoint, previusDataPoint,false, false); } // Area front face Line path LineSegment ls = new LineSegment() { Point = currentDataPoint._visualPosition }; frontFacePathFigure.Segments.Add(ls); dataPointFaces.AreaFrontFaceLineSegment = ls; } #region Create Marker if (nextDataPoint.MarkerEnabled == true || nextDataPoint.LabelEnabled == true) { Double xPos, yPos; // Create Marker Marker marker = LineChart.CreateMarkerAForLineDataPoint(currentDataPoint, width, height, ref labelCanvas, out xPos, out yPos); //if (marker != null) //{ // //LineChart.ApplyDefaultInteractivityForMarker(dataPoint); // //marker.AddToParent(labelCanvas, currentDataPoint._visualPosition.X, currentDataPoint._visualPosition.Y, new Point(0.5, 0.5)); // // Apply marker animation // if (animationEnabled) // { // if (currentDataPoint.Parent.Storyboard == null) // currentDataPoint.Parent.Storyboard = new Storyboard(); // // Apply marker animation // currentDataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(marker, CurrentDataSeries, currentDataPoint.Parent.Storyboard, 1, currentDataPoint.Opacity * currentDataPoint.Parent.Opacity); // } //} } #endregion if (chart.View3D) { Int32 zindex = Draw3DArea(areaFaceCanvas, previusDataPoint, currentDataPoint, nextDataPoint, ref dataSeriesFaces, ref dataPointFaces, currentDataPoint.Parent, plankYPos); maxZIndex = Math.Max(maxZIndex, zindex); } else { //areaCanvas.Children.Add(Get2DArea(ref faces, areaParams)); } if (i == dataPointList.Count - 2) // If next DataPoint is the last DataPoint { if (chart.View3D) { DataPoint lastDataPoint = nextDataPoint; Area3DDataPointFace rightFace = new Area3DDataPointFace(depth3d); rightFace.FrontFacePoints.Add(nextDataPoint._visualPosition); // Front top point rightFace.FrontFacePoints.Add(new Point(nextDataPoint._visualPosition.X, plankYPos)); nextDataPoint.Faces.Area3DRightFace = rightFace; // Draw base of the 3d area areaBase = new Path(); areaBase.Fill = (Boolean)dataPointList[0].Parent.LightingEnabled ? Graphics.GetTopFaceBrush(dataPointList[0].Parent.Color) : dataPointList[0].Parent.Color; PathGeometry pg = new PathGeometry(); PathFigure pf = new PathFigure() { StartPoint = new Point(dataPointList[0]._visualPosition.X, plankYPos) }; pg.Figures.Add(pf); pf.Segments.Add(new LineSegment() { Point = new Point(dataPointList[0]._visualPosition.X + depth3d, plankYPos - depth3d) }); pf.Segments.Add(new LineSegment() { Point = new Point(lastDataPoint._visualPosition.X + depth3d, plankYPos - depth3d) }); pf.Segments.Add(new LineSegment() { Point = new Point(lastDataPoint._visualPosition.X, plankYPos) }); areaBase.Data = pg; areaBase.SetValue(Canvas.ZIndexProperty, (Int32) 1); areaBase.Opacity = lastDataPoint.Parent.Opacity; areaCanvas.Children.Add(areaBase); dataSeriesFaces.FrontFacePaths.Add(areaBase); series.Faces.VisualComponents.Add(areaBase); // Animating AreaBase opacity if (animationEnabled) series.Storyboard = AnimationHelper.ApplyOpacityAnimation(areaBase, series, series.Storyboard, 0.25, 1, 0, 1); } else { if (nextDataPoint.Parent.Bevel) CreateBevelFor2DArea(areaFaceCanvas, nextDataPoint, currentDataPoint, false, false); } // Front face for 3D and 2D both LineSegment ls = new LineSegment() { Point = nextDataPoint._visualPosition }; frontFacePathFigure.Segments.Add(ls); nextDataPointFaces.AreaFrontFaceLineSegment = ls; ls = new LineSegment() { Point = new Point(nextDataPoint._visualPosition.X, plankYPos) }; frontFacePathFigure.Segments.Add(ls); nextDataPointFaces.AreaFrontFaceBaseLineSegment = ls; nextDataPointFaces.NextDataPoint = nextDataPoint; // Graphics.DrawPointAt(rightFace.FrontFacePoints[0], areaCanvas, Colors.Yellow); if (chart.View3D) { Int32 zindex = Draw3DArea(areaFaceCanvas, previusDataPoint, nextDataPoint, nextDataPoint, ref dataSeriesFaces, ref nextDataPointFaces, nextDataPoint.Parent, plankYPos); maxZIndex = Math.Max(maxZIndex, zindex); } else { // areaCanvas.Children.Add(Get2DArea(ref faces, areaParams)); } if (nextDataPoint.MarkerEnabled == true || nextDataPoint.LabelEnabled == true) { Double xPos, yPos; Marker marker = LineChart.CreateMarkerAForLineDataPoint(nextDataPoint, width, height, ref labelCanvas, out xPos, out yPos); } nextDataPoint._parsedToolTipText = nextDataPoint.TextParser(nextDataPoint.ToolTipText); } previusDataPoint = currentDataPoint; } if (frontFacePath != null) { if (chart.View3D) frontFacePath.Fill = (Boolean)dataPointList[0].Parent.LightingEnabled ? Graphics.GetFrontFaceBrush(dataPointList[0].Parent.Color) : dataPointList[0].Parent.Color; else frontFacePath.Fill = (Boolean)dataPointList[0].Parent.LightingEnabled ? Graphics.GetLightingEnabledBrush(dataPointList[0].Parent.Color, "Linear", null) : dataPointList[0].Parent.Color; series.Faces.VisualComponents.Add(frontFacePath); frontFacePath.SetValue(Canvas.ZIndexProperty, maxZIndex); areaFaceCanvas.Children.Add(frontFacePath); } foreach (FrameworkElement face in series.Faces.VisualComponents) VisifireElement.AttachEvents2AreaVisual(currentDataPoint, currentDataPoint, face); } foreach (FrameworkElement face in series.Faces.VisualComponents) VisifireElement.AttachEvents2AreaVisual(series, series, face); series.AttachAreaToolTip(chart, dataSeriesFaces.VisualComponents); areaFaceCanvas.Tag = null; Canvas plank = ColumnChart.CreateOrUpdatePlank(chart, series.PlotGroup.AxisY, areaCanvas, depth3d, Orientation.Horizontal); // apply area animation if (animationEnabled) { // if (series.Storyboard == null) // series.Storyboard = new Storyboard(); ScaleTransform scaleTransform = new ScaleTransform() { ScaleY = 0 }; areaFaceCanvas.RenderTransformOrigin = new Point(0.5, plankYPos / height); areaFaceCanvas.RenderTransform = scaleTransform; List<KeySpline> splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 1), new Point(0.5, 1) ); // Apply animation to the entire canvas that was used to create the area series.Storyboard = AnimationHelper.ApplyPropertyAnimation(scaleTransform, "(ScaleTransform.ScaleY)", series, series.Storyboard, 1, new Double[] { 0, 1 }, new Double[] { 0, 1 }, splines); // Animating plank opacity //series.Storyboard = AnimationHelper.ApplyOpacityAnimation(areaBase, series, series.Storyboard, 1.25, 1, 0, 1); // Apply animation for label canvas series.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, series, series.Storyboard, 1.25, 1, 0, 1); } } areaFaceCanvas.SetValue(Canvas.ZIndexProperty, (Int32)2); areaCanvas.Children.Add(areaFaceCanvas); // Remove old visual and add new visual in to the existing panel if (preExistingPanel != null) { visual.Children.RemoveAt(1); visual.Children.Add(areaCanvas); } else { labelCanvas.SetValue(Canvas.ZIndexProperty, 1); visual.Children.Add(labelCanvas); visual.Children.Add(areaCanvas); } RectangleGeometry clipRectangle = new RectangleGeometry(); clipRectangle.Rect = new Rect(0, -depth3d - 4, width + depth3d, height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10); areaCanvas.Clip = clipRectangle; // Clip the label canvas clipRectangle = new RectangleGeometry(); Double clipLeft = 0; Double clipTop = -depth3d - 4; Double clipWidth = width + depth3d; Double clipHeight = height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10; GetClipCoordinates(chart, ref clipLeft, ref clipTop, ref clipWidth, ref clipHeight, minimumXValue, maximumXValue); clipRectangle.Rect = new Rect(clipLeft, clipTop, clipWidth, clipHeight); labelCanvas.Clip = clipRectangle; return visual; }
/// <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); } } }
public void AddNation(Hex hex, Nation nation) { hex.Dispatcher.BeginInvoke(() => { Canvas canvas = new Canvas(); canvas.Name = "NationCanvas"; canvas.SetValue(Canvas.ZIndexProperty, 1); Path path = new Path(); CreatePathOutline(path, "NationPath"); AddImage(path, Game.ImageFactory.NationImage, nation.ImageXCoordinate * -1, nation.ImageYCoordinate * -1); canvas.Children.Add(path); hex.MainCanvas.Children.Add(canvas); }); }
/// <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); }
public void AddStrength(Hex hex, IUnit unit) { hex.Dispatcher.BeginInvoke(() => { Canvas canvas = new Canvas(); canvas.Name = "StrengthCanvas"; canvas.SetValue(Canvas.ZIndexProperty, 2); Path path = new Path(); CreatePathOutline(path, "StrengthPath"); AddImage(path, Game.ImageFactory.StrengthImage, Game.StrengthFactory.GetXCoordinate(unit.CurrentStrength), Game.StrengthFactory.GetYCoordinate(unit.Nation.Side.SideId)); canvas.Children.Add(path); hex.MainCanvas.Children.Add(canvas); }); }
/// <summary> /// Create visual for Marker /// </summary> public void CreateVisual() { // Create Visual as Grid Visual = new Grid(); //Visual.Background = new SolidColorBrush(Colors.Yellow); //Visual.ShowGridLines = true; // Create Shape for Marker MarkerShape = GetShape(); MarkerShape.Tag = Tag; MarkerShape.SetValue(Grid.RowProperty, 1); MarkerShape.SetValue(Grid.ColumnProperty, 1); if (ShadowEnabled) ApplyRemoveShadow(); Visual.Children.Add(MarkerShape); UpdateMarker(); if (!String.IsNullOrEmpty(Text)) { // Define row and columns Visual.RowDefinitions.Add(new RowDefinition()); Visual.RowDefinitions.Add(new RowDefinition()); Visual.RowDefinitions.Add(new RowDefinition()); Visual.ColumnDefinitions.Add(new ColumnDefinition()); Visual.ColumnDefinitions.Add(new ColumnDefinition()); Visual.ColumnDefinitions.Add(new ColumnDefinition()); // Create TextBlock for Label of the Marker TextBlock = new TextBlock() { Tag = this.Tag }; // Apply TextBlock Properties ApplyTextBlockProperties(); if (!Double.IsNaN(LabelAngle)) { // Create Canvas for TextBlock LabelCanvas = new Canvas(); TextBackgroundCanvas = new Canvas(); TextBackgroundCanvas.Background = TextBackground; TextBackgroundCanvas.Children.Add(TextBlock); // Add TextBackgroundCanvas to LabelCanvas LabelCanvas.Children.Add(TextBackgroundCanvas); // Set Alignment SetAlignment4Label(); if (TextAlignmentX == AlignmentX.Left) { LabelCanvas.SetValue(Grid.ColumnProperty, 0); } else if (TextAlignmentX == AlignmentX.Right) { LabelCanvas.SetValue(Grid.ColumnProperty, 2); } else { LabelCanvas.SetValue(Grid.ColumnProperty, 1); LabelCanvas.HorizontalAlignment = HorizontalAlignment.Center; } if (TextAlignmentY == AlignmentY.Top) { LabelCanvas.SetValue(Grid.RowProperty, 0); LabelCanvas.VerticalAlignment = VerticalAlignment.Top; } else if (TextAlignmentY == AlignmentY.Bottom) { LabelCanvas.SetValue(Grid.RowProperty, 2); LabelCanvas.VerticalAlignment = VerticalAlignment.Top; } else { LabelCanvas.SetValue(Grid.RowProperty, 1); LabelCanvas.VerticalAlignment = VerticalAlignment.Top; } // Add LabelCanvas into Visual Visual.Children.Add(LabelCanvas); } else { if (TextBackground != null) { TextBackgroundCanvas = new Canvas(); TextBackgroundCanvas.Background = TextBackground; Visual.Children.Add(TextBackgroundCanvas); } // Set Alignment SetAlignment4Label(); Visual.Children.Add(TextBlock); } TextBlock.Margin = new Thickness(LabelMargin, 0, 0, 0); Visual.Margin = new Thickness(Margin, Margin, Margin, Margin); } else { TextBlock = null; TextBackgroundCanvas = null; TextBlockSize = new Size(0,0); _markerShapePosition.X = 0; _markerShapePosition.Y = 0; } MarkerShape.Opacity = Opacity; MarkerActualSize = Graphics.CalculateVisualSize(Visual); }
private void btnDesigner_Click(object sender, RoutedEventArgs e) { try { if (cmbScript.Items.Count > 0) { if (cmbScript.SelectedItem != null) { if (cnv == null) { cnv = new Canvas(); tbc = new TabControl(); tbc.Height = 768; tbc.Width = 1024; tbc.SetValue(Canvas.LeftProperty, 0.0); tbc.SetValue(Canvas.TopProperty, 0.0); cnv.Height = 768; cnv.Width = 1024; cnv.SetValue(Canvas.LeftProperty, 0.0); cnv.SetValue(Canvas.TopProperty, 0.0); //ctlDesigner = new ctlCRMDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString()); //ctlDesigner = new ctlCRMDesigner.FunCRMDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString()); ctlDesigner = new ctlCRMDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString()); ctlDesigner.SctiptID = int.Parse(((ListBoxItem)(cmbScript.SelectedItem)).Tag.ToString()); 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 ctlCRMDesigner(((ListBoxItem)(cmbScript.SelectedItem)).Content.ToString()); ctlDesigner.GetQuestions(); cnv.Children.Add(ctlDesigner); cnvMain.Children.Add(cnv); if (c != null) { c.Visibility = Visibility.Collapsed; } } } else { MessageBox.Show("Please Select the CRM first", "-> Designer", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Currently there are no CRMs"); } //NavigationService.GetNavigationService(this).Navigate(new Uri("pgDesigner.xaml", UriKind.RelativeOrAbsolute)); } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "btnDesigner_Click()", "CtlQuestionAns.xaml.cs"); } }
/// <summary> /// Create labels and set width for the label canvas /// </summary> /// <param name="funnelChartCanvas">Main Funnel chart canvas</param> /// <param name="labelCanvas">Label canvas for funnel chart placed in side funnelChartCanvas</param> /// <param name="funnelSeries">DataSeries reference</param> private static void CreateLabelsAndSetFunnelCanvasSize(Boolean isStreamLine, Grid funnelChartCanvas, Canvas labelCanvas, Canvas funnelCanvas, List<DataPoint> funnelDataPoints) { Int32 index = 0; Double totalLabelsHeight = 0; _streamLineParentTitleSize = new Size(0, 0); labelCanvas.Width = 0; for (; index < funnelDataPoints.Count; index++) { // Create label for a funnel slice funnelDataPoints[index].LabelVisual = CreateLabelForDataPoint(funnelDataPoints[index], isStreamLine, index); // Calculate label size Size labelSize = Graphics.CalculateVisualSize(funnelDataPoints[index].LabelVisual); labelSize.Width += 2.5; if (isStreamLine && index == 0) labelSize.Height += TITLE_FUNNEL_GAP; if ((Boolean)funnelDataPoints[index].LabelEnabled && funnelDataPoints[index].LabelStyle == LabelStyles.OutSide) totalLabelsHeight += labelSize.Height; if (isStreamLine && index == 0) _streamLineParentTitleSize = labelSize; else if (labelSize.Width > labelCanvas.Width && (Boolean)funnelDataPoints[index].LabelEnabled && funnelDataPoints[index].LabelStyle == LabelStyles.OutSide) // && !(isStreamLine && index == 0)) labelCanvas.Width = labelSize.Width; funnelDataPoints[index].LabelVisual.Height = labelSize.Height; funnelDataPoints[index].LabelVisual.Width = labelSize.Width; // labelCanvas.Children.Add(funnelDataPoints[index].LabelVisual); } labelCanvas.Width += Chart.BEVEL_DEPTH; if (labelCanvas.Width > .6 * funnelChartCanvas.Width) { // Do some optimization here } // if funnelcanvas height is less than total labels height reduce the funnel canvas height //if (funnelCanvas.Height < totalLabelsHeight) // funnelCanvas.Height -= (totalLabelsHeight - funnelCanvas.Height); funnelCanvas.Width = Math.Max(funnelChartCanvas.Width - labelCanvas.Width, 0); labelCanvas.SetValue(Canvas.LeftProperty, funnelCanvas.Width); if (isStreamLine) { funnelCanvas.Height -= _streamLineParentTitleSize.Height; labelCanvas.Height -= _streamLineParentTitleSize.Height; funnelCanvas.SetValue(Canvas.TopProperty, _streamLineParentTitleSize.Height); labelCanvas.SetValue(Canvas.TopProperty, _streamLineParentTitleSize.Height); //funnelChartCanvas.Children.Add(funnelDataPoints[0].LabelVisual); funnelDataPoints[0].LabelVisual.SetValue(Canvas.LeftProperty, (Double)(funnelCanvas.Width - _streamLineParentTitleSize.Width) / 2); funnelDataPoints[0].Faces = new Faces(); funnelDataPoints[0].Faces.VisualComponents.Add(funnelDataPoints[0].LabelVisual); funnelDataPoints[0].Faces.Visual = funnelDataPoints[0].LabelVisual; if ((funnelDataPoints[0].Chart as Chart).InternalAnimationEnabled) { // funnelDataPoints[0].Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(funnelDataPoints[0].LabelVisual, funnelDataPoints[0].Parent, funnelDataPoints[0].Parent.Storyboard, 1, funnelDataPoints[0].Opacity, 1); } } }
private void btnDesignCRM_Click(object sender, RoutedEventArgs e) { try { if (cmbCRM.SelectedIndex!= -1) { if (cnv == null) { cnv = new Canvas(); cnv.Height = 768; cnv.Width = 1024; cnv.SetValue(Canvas.LeftProperty, 0.0); cnv.SetValue(Canvas.TopProperty, 0.0); cnvView.Children.Clear(); //objDesginer = new ctlCRMDesigner(((ListBoxItem)(cmbCRM.SelectedItem)).Content.ToString()); objDesginer = new ctlCRMDesigner(((ListBoxItem)(cmbCRM.SelectedItem)).Tag.ToString()); //objDesginer = new ctlCRMDesigner(cmbCRM.SelectedItem.ToString()); //objDesginer.GetQuestions(); cnv.Children.Add(objDesginer); cnvView.Children.Add(cnv); } else { cnv.Children.Clear(); cnv.Height = 768; cnv.Width = 1024; cnv.SetValue(Canvas.LeftProperty, 0.0); cnv.SetValue(Canvas.TopProperty, 0.0); //cnvView.Children.Clear(); //objDesginer = new ctlCRMDesigner(((ListBoxItem)(cmbCRM.SelectedItem)).Content.ToString()); objDesginer = new ctlCRMDesigner(((ListBoxItem)(cmbCRM.SelectedItem)).Tag.ToString()); //objDesginer = new ctlCRMDesigner(cmbCRM.SelectedItem.ToString()); //objDesginer.GetQuestions(); cnv.Children.Add(objDesginer); cnvView.Children.Add(cnv); } } else { MessageBox.Show("Please Select any CRM Name"); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "btnDesignCRM_Click()", "CtlCRM.xaml.cs"); } }
public void Register_Canvas_Custom_Canvas () { Canvas canvas = new Canvas (); CustomCanvasType custom_canvas = new CustomCanvasType (); DependencyProperty property; DependencyPropertyInfo info; DependencyPropertyInfo.ChangedInfo changed_info; InkPresenter ink = new InkPresenter (); // The only builtin type derived from Canvas object actual_value; object previous_expected_value = null; int iterations = 0; int changes = 0; Canvas_Custom_Canvas = new DependencyPropertyInfo ("Custom", typeof (Canvas), typeof (Canvas), true); info = Canvas_Custom_Canvas; property = info.Property; Assert.IsNull (canvas.GetValue (property)); Assert.IsNull (ink.GetValue (property)); Assert.Throws (delegate { canvas.SetValue (property, 1); }, typeof (ArgumentException)); Assert.Throws (delegate { canvas.SetValue (property, ""); }, typeof (ArgumentException)); Assert.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }, typeof (ArgumentException)); foreach (object expected_value in new object [] { null, new Canvas (), null, canvas, canvas, null, new CustomCanvasType (), custom_canvas, custom_canvas, ink }) { iterations++; canvas.SetValue (property, expected_value); actual_value = canvas.GetValue (property); if (expected_value != previous_expected_value) { changes++; changed_info = info.Changes [info.Changes.Count - 1]; DependencyPropertyChangedEventArgs args = changed_info.args; Assert.AreSame (args.OldValue, previous_expected_value); Assert.AreSame (args.NewValue, expected_value); Assert.AreSame (changed_info.obj, canvas); } previous_expected_value = expected_value; Assert.AreSame (expected_value, actual_value, "Iteration #{0}", iterations); Assert.AreEqual (changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count); } }
private void openPreviousLayer(Canvas currentMenu, Canvas previousMenu) { previousMenu.SetValue(LeftProperty, -this.Width); currentMenu.SetValue(LeftProperty, 0.0); previousMenu.Visibility = Visibility.Visible; animationInProgress = true; this.RegisterName(previousMenu.Name, previousMenu); this.RegisterName(currentMenu.Name, currentMenu); DoubleAnimation leftAnimPrevious = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(1.0))); Storyboard.SetTargetProperty(leftAnimPrevious, new PropertyPath(Window.LeftProperty)); Storyboard storyboard = new Storyboard(); leftAnimPrevious.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetName(leftAnimPrevious, previousMenu.Name); storyboard.Children.Add(leftAnimPrevious); DoubleAnimation leftAnimCurrent = new DoubleAnimation(this.Width, new Duration(TimeSpan.FromSeconds(1.0))); Storyboard.SetTargetProperty(leftAnimCurrent, new PropertyPath(Window.LeftProperty)); leftAnimCurrent.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetName(leftAnimCurrent, currentMenu.Name); storyboard.Children.Add(leftAnimCurrent); leftAnimPrevious.Completed += delegate(object sender, EventArgs e) { storyboard.Stop(); animationInProgress = false; previousMenu.SetValue(LeftProperty, 0.0); currentMenu.Visibility = Visibility.Hidden; currentMenu.SetValue(LeftProperty, 0.0); if (previousMenu == RootMenu) { // hide back area this.ButtonBack.Visibility = Visibility.Hidden; } active_menu = previousMenu; }; storyboard.Begin(previousMenu); }
/// <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); Debug.Assert(parentGrid.RowDefinitions != null); Debug.Assert(parentGrid.ColumnDefinitions != null); _previewLayer = new Canvas(); _previewLayer.SetValue(Grid.RowSpanProperty, parentGrid.RowDefinitions.Count); _previewLayer.SetValue(Grid.ColumnSpanProperty, parentGrid.ColumnDefinitions.Count); parentGrid.Children.Add(_previewLayer); }
public void Bind(object BindingCollection) { try { ClearGrid(); grdControl.ColumnDefinitions.Add(new ColumnDefinition()); grdControl.ColumnDefinitions[grdControl.ColumnDefinitions.Count - 1].Width = new GridLength(200); System.Reflection.PropertyInfo[] myProps = BindingCollection.GetType().GetProperties(); for (int j = 0; j < myProps.Length; j++) { if (myProps[j].PropertyType.BaseType.ToString().Split('.')[myProps[j].PropertyType.BaseType.ToString().Split('.').Length - 1].ToString() == "ClsBaseObject") { try { int rows = 1; while (true) { object[] indexArgs = { rows - 1 }; System.Reflection.PropertyInfo[] mySubProps = myProps[j].GetValue(BindingCollection, indexArgs).GetType().GetProperties(); grdControl.RowDefinitions.Add(new RowDefinition()); grdControl.RowDefinitions[grdControl.RowDefinitions.Count - 1].Height = new GridLength(50); grdControl.Height += 50; Canvas cnvBuddy = new Canvas(); cnvBuddy.Width = 150; cnvBuddy.Height = 50; Label lblHeader = new Label(); lblHeader.Height = 25; lblHeader.Width = 150; lblHeader.SetValue(Canvas.TopProperty, 0.0); lblHeader.SetValue(Canvas.LeftProperty, 0.0); lblHeader.Content = mySubProps[4].GetValue(myProps[j].GetValue(BindingCollection, indexArgs), null).ToString() + " Wants to Join You"; cnvBuddy.Children.Add(lblHeader); Label lblQuestion = new Label(); lblQuestion.Height = 25; lblQuestion.Width = 50; lblQuestion.Content = "Add ?"; lblQuestion.SetValue(Canvas.TopProperty, 25.0); lblQuestion.SetValue(Canvas.LeftProperty, 0.0); cnvBuddy.Children.Add(lblQuestion); Button btnAccept = new Button(); btnAccept.Content = "Accept"; btnAccept.Width = 50; btnAccept.Tag = rows - 1; btnAccept.SetValue(Canvas.TopProperty, 25.0); btnAccept.SetValue(Canvas.LeftProperty, 50.0); btnAccept.Click += new RoutedEventHandler(btnAccept_Click); cnvBuddy.Children.Add(btnAccept); Button btnReject = new Button(); btnReject.Content = "Reject"; btnReject.Width = 50; btnReject.Tag = rows - 1; btnReject.SetValue(Canvas.TopProperty, 25.0); btnReject.SetValue(Canvas.LeftProperty, 100.0); btnReject.Click += new RoutedEventHandler(btnReject_Click); cnvBuddy.Children.Add(btnReject); grdControl.Children.Add(cnvBuddy); cnvBuddy.SetValue(Grid.ColumnProperty, 0); cnvBuddy.SetValue(Grid.RowProperty, rows - 1); if (grdControl.Visibility == Visibility.Collapsed) { grdControl.Visibility = Visibility.Visible; } rows++; } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "Bind()", "Controls\\CtlBuddyGrid.xaml.cs"); } } } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "Bind()--2", "Controls\\CtlBuddyGrid.xaml.cs"); } }