예제 #1
0
        public IEnumerable<string> ConvertTagsToHtml(string[] lines)
        {
            var tables = new Dictionary<string, List<string>>();
            var lastLine = "";
            var tableCount = 0;

            var list = new List<string>();
            foreach (var line in lines)
            {

                if (line.StartsWith("<F>") && line.Length > 3)
                    list.Add(string.Format("<span>{0}</span>", line[3].ToString().PadLeft(lines.Max(x => x.Length), line[3])));
                if (line.StartsWith("<T>"))
                    list.Add(string.Format("<B>{0}</B>", RemoveTag(line)));
                if (line.StartsWith("<C") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                    list.Add(string.Format("<span>{0}</span>", RemoveTag(line)));
                if (line.StartsWith("<L") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                    list.Add(string.Format("<span>{0}</span>", RemoveTag(line)));
                if (line.StartsWith("<EB>"))
                    list.Add("<B>");
                if (line.StartsWith("<DB>"))
                    list.Add("</B>");

                if (line.StartsWith("<J") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                {
                    if (!lastLine.StartsWith("<J"))
                    {
                        tableCount++;
                        list.Add("tbl" + tableCount);
                    }

                    var tableName = "tbl" + tableCount;
                    if (!tables.ContainsKey(tableName))
                        tables.Add(tableName, new List<string>());
                    tables[tableName].Add(RemoveTag(line));
                }

                if (!line.Contains("<") && !string.IsNullOrEmpty(line.Trim()))
                    list.Add(line);

                lastLine = line;
            }

            foreach (var table in tables)
            {
                list.InsertRange(list.IndexOf(table.Key), GetTableLines(table.Value, Printer.CharsPerLine));
                list.Remove(table.Key);
            }

            for (int i = 0; i < list.Count; i++)
            {
                list[i] = list[i].TrimEnd();
                if ((!list[i].ToLower().EndsWith("<BR>") && RemoveTag(list[i]).Trim().Length > 0) || list[i].Trim().Length == 0)
                    list[i] += "<BR>";
                list[i] = list[i].Replace(" ", "&nbsp;");
            }

            return list;
        }
예제 #2
0
        public void UpdateMapLayout()
        {
            List<Personnage> mespersos = new List<Personnage>();
            mespersos.InsertRange(0, conf.EquipeRouge.Joueurs);
            mespersos.InsertRange(0, conf.EquipeVerte.Joueurs);

            List<Quete> mesquetes = new List<Quete>();
            mesquetes.InsertRange(0, conf.EquipeRouge.Quetes);
            mesquetes.InsertRange(0, conf.EquipeVerte.Quetes);

            ChessBoard.Children.Clear();
            for (int x = 0; x < Parametres.nbColonne; ++x)
            {
                for (int y = 0; y < Parametres.nbLigne; ++y)
                {
                    ZoneAbstraite zone = conf.Plateau.GetZone(new Position(x, y));
                    if (zone != null)
                    {
                        //List<ZoneAbstraite> meszones = conf.Plateau.GetNeighbourZones(zone.point);
                        ChessBoard.Children.Add(design.GetCaseImage(zone, mespersos, mesquetes));
                    }
                }
            }
            /***
             * Affichage des personnages
             ***/
            //this.personnages.ClearValue(TextBlock.TextProperty);

            personnages.Document.Blocks.Clear();

            String textEquipeRouge = conf.EquipeRouge.Nom + "\n";
            String textEquipeVerte = conf.EquipeVerte.Nom + "\n";

            foreach (Personnage p in mespersos)
            {
                if (p.equipe == TypeEquipe.Rouge)
                    textEquipeRouge += p.Nom + " (" + p.PointsDeVie + "pv)";
                else
                    textEquipeVerte += p.Nom + " (" + p.PointsDeVie + "pv)";
            }

            textEquipeRouge += "\n\n";
            textEquipeVerte += "\n\n";

            #region ajout des couleurs et du style de la fenêtre personnages

            TextRange styleEquipeRouge = new TextRange(personnages.Document.ContentEnd, personnages.Document.ContentEnd);
            styleEquipeRouge.Text = textEquipeRouge;
            styleEquipeRouge.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red);
            styleEquipeRouge.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

            TextRange styleEquipeVerte = new TextRange(personnages.Document.ContentEnd, personnages.Document.ContentEnd);
            styleEquipeVerte.Text = textEquipeVerte;
            styleEquipeVerte.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Green);
            styleEquipeVerte.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

            #endregion

            /***
             * Fin affichage des personnages
             ***/
            this.Refresh();
            UpdateLayout();
        }
예제 #3
0
파일: PieChart.cs 프로젝트: tdhieu/openvss
        /// <summary>
        /// Returns 3D Doughnut shapes
        /// </summary>
        /// <param name="faces">Doughnut faces</param>
        /// <param name="doughnutParams">Doughnut parameters</param>
        /// <param name="unExplodedPoints">UnExploded dataPoints</param>
        /// <param name="explodedPoints">Exploded dataPoints</param>
        /// <param name="labelLinePath">Label line path</param>
        /// <param name="enabledDataPoints">List of enabled dataPoints</param>
        /// <returns>List of Shape</returns>
        private static List<Shape> GetDoughnut3D(DataSeries currentDataSeries, ref Faces faces, SectorChartShapeParams doughnutParams, ref PieDoughnut3DPoints unExplodedPoints, ref PieDoughnut3DPoints explodedPoints, ref Path labelLinePath, List<DataPoint> enabledDataPoints)
        {
            List<Shape> pieFaces = new List<Shape>();
            Shape topFace = null, bottomFace = null, rightFace = null, leftFace = null;

            // calculate 3d offsets
            Double yOffset = -doughnutParams.Depth / 2 * doughnutParams.ZAxisScaling;
            Point center = new Point();
            center.X += doughnutParams.Width / 2;
            center.Y += doughnutParams.Height / 2;

            // calculate all points
            Point3D topFaceCenter = new Point3D();
            topFaceCenter.X = center.X;
            topFaceCenter.Y = center.Y + yOffset;
            topFaceCenter.Z = doughnutParams.OffsetY * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topOuterArcStart = new Point3D();
            topOuterArcStart.X = topFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StartAngle);
            topOuterArcStart.Y = topFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            topOuterArcStart.Z = (topFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topOuterArcStop = new Point3D();
            topOuterArcStop.X = topFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StopAngle);
            topOuterArcStop.Y = topFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            topOuterArcStop.Z = (topFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topInnerArcStart = new Point3D();
            topInnerArcStart.X = topFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StartAngle);
            topInnerArcStart.Y = topFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            topInnerArcStart.Z = (topFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topInnerArcStop = new Point3D();
            topInnerArcStop.X = topFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StopAngle);
            topInnerArcStop.Y = topFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            topInnerArcStop.Z = (topFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomFaceCenter = new Point3D();
            bottomFaceCenter.X = center.X;
            bottomFaceCenter.Y = center.Y - yOffset;
            bottomFaceCenter.Z = doughnutParams.OffsetY * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomOuterArcStart = new Point3D();
            bottomOuterArcStart.X = bottomFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StartAngle);
            bottomOuterArcStart.Y = bottomFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            bottomOuterArcStart.Z = (bottomFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomOuterArcStop = new Point3D();
            bottomOuterArcStop.X = bottomFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StopAngle);
            bottomOuterArcStop.Y = bottomFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            bottomOuterArcStop.Z = (bottomFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomInnerArcStart = new Point3D();
            bottomInnerArcStart.X = bottomFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StartAngle);
            bottomInnerArcStart.Y = bottomFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            bottomInnerArcStart.Z = (bottomFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomInnerArcStop = new Point3D();
            bottomInnerArcStop.X = bottomFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StopAngle);
            bottomInnerArcStop.Y = bottomFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            bottomInnerArcStop.Z = (bottomFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D centroid = GetCentroid(topInnerArcStart, topInnerArcStop, topOuterArcStart, topOuterArcStop, bottomInnerArcStart, bottomInnerArcStop, bottomOuterArcStart, bottomOuterArcStop);

            UpdatePositionLabelInsidePie(doughnutParams, yOffset);

            if (doughnutParams.StartAngle == doughnutParams.StopAngle && doughnutParams.IsLargerArc || enabledDataPoints.Count == 1)
            {
                // draw singleton pie here
                topFace = new Ellipse() { Tag = new ElementData() { Element = doughnutParams.TagReference } };
                // topFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : doughnutParams.Background;
                topFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, "Linear", new Double[] { 0.99, 0.854 }) : doughnutParams.Background;
                
                topFace.Width = 2 * doughnutParams.OuterRadius;
                topFace.Height = 2 * doughnutParams.OuterRadius * doughnutParams.YAxisScaling;
                topFace.SetValue(Canvas.LeftProperty, (Double)(doughnutParams.Center.X - topFace.Width / 2));
                topFace.SetValue(Canvas.TopProperty, (Double)(doughnutParams.Center.Y - topFace.Height / 2 + yOffset));

                GeometryGroup gg = new GeometryGroup();
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = topFace.Width, RadiusY = topFace.Height });
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = doughnutParams.InnerRadius, RadiusY = topFace.Height - 2 * (doughnutParams.OuterRadius - doughnutParams.InnerRadius) });

                topFace.Clip = gg;
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = new Ellipse() { Tag = new ElementData() { Element = doughnutParams.TagReference } };
                bottomFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : doughnutParams.Background;
                // topFace.Stroke = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;
                bottomFace.Width = 2 * doughnutParams.OuterRadius;
                bottomFace.Height = 2 * doughnutParams.OuterRadius * doughnutParams.YAxisScaling;
                bottomFace.SetValue(Canvas.LeftProperty, (Double)(doughnutParams.Center.X - topFace.Width / 2));
                bottomFace.SetValue(Canvas.TopProperty, (Double)(doughnutParams.Center.Y - topFace.Height / 2));

                gg = new GeometryGroup();
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = topFace.Width, RadiusY = topFace.Height });
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = doughnutParams.InnerRadius, RadiusY = topFace.Height - 2 * (doughnutParams.OuterRadius - doughnutParams.InnerRadius) });

                bottomFace.Clip = gg;
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);
            }
            else
            {
                topFace = GetDoughnutFace(doughnutParams, centroid, topInnerArcStart, topInnerArcStop, topOuterArcStart, topOuterArcStop, true);
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = GetDoughnutFace(doughnutParams, centroid, bottomInnerArcStart, bottomInnerArcStop, bottomOuterArcStart, bottomOuterArcStop, false);
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);

                rightFace = GetPieSide(doughnutParams, centroid, topInnerArcStart, bottomInnerArcStart, topOuterArcStart, bottomOuterArcStart);
                pieFaces.Add(rightFace);
                faces.Parts.Add(rightFace);

                leftFace = GetPieSide(doughnutParams, centroid, topInnerArcStop, bottomInnerArcStop, topOuterArcStop, bottomOuterArcStop);
                pieFaces.Add(leftFace);
                faces.Parts.Add(leftFace);
            }

            List<Shape> curvedSurface = GetDoughnutCurvedFace(doughnutParams, centroid, topFaceCenter, bottomFaceCenter);
            pieFaces.InsertRange(pieFaces.Count, curvedSurface);

            foreach (FrameworkElement fe in curvedSurface)
                faces.Parts.Add(fe);

            labelLinePath = CreateLabelLine(currentDataSeries, doughnutParams, center, ref unExplodedPoints, ref explodedPoints);

            if ((doughnutParams.TagReference as DataPoint).InternalYValue == 0)
                return new List<Shape>();

            //Top face ZIndex
            topFace.SetValue(Canvas.ZIndexProperty, (Int32)(50000));
            //BottomFace ZIndex
            bottomFace.SetValue(Canvas.ZIndexProperty, (Int32)(-50000));

            if (!(doughnutParams.StartAngle == doughnutParams.StopAngle && doughnutParams.IsLargerArc))
            {
                // ZIndex of curved face
                if (doughnutParams.StartAngle >= Math.PI && doughnutParams.StartAngle <= Math.PI * 2 && doughnutParams.StopAngle >= Math.PI && doughnutParams.StopAngle <= Math.PI * 2 && doughnutParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], doughnutParams.StartAngle, 0));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[2], Math.PI, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, 0, Math.PI));
                }
                else if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle <= Math.PI && doughnutParams.StopAngle >= 0 && doughnutParams.StopAngle <= Math.PI && doughnutParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], Math.PI * 2, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[2], Math.PI, Math.PI * 2));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                    if (labelLinePath != null)
                        labelLinePath.SetValue(Canvas.ZIndexProperty, -50000);
                }
                else if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle <= Math.PI && doughnutParams.StopAngle >= Math.PI && doughnutParams.StopAngle <= Math.PI * 2)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], Math.PI, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                }
                else if (doughnutParams.StartAngle >= Math.PI && doughnutParams.StartAngle <= Math.PI * 2 && doughnutParams.StopAngle >= 0 && doughnutParams.StopAngle <= Math.PI)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], doughnutParams.StartAngle, 0));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StopAngle, doughnutParams.StopAngle));
                }
                else
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle < Math.PI / 2 && doughnutParams.StopAngle >= 0 && doughnutParams.StopAngle < Math.PI / 2)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StopAngle, doughnutParams.StopAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle < Math.PI / 2 && doughnutParams.StopAngle >= Math.PI / 2 && doughnutParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            labelLinePath.SetValue(Canvas.ZIndexProperty, 40000);
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else if (doughnutParams.StartAngle >= Math.PI / 2 && doughnutParams.StartAngle < Math.PI && doughnutParams.StopAngle >= Math.PI / 2 && doughnutParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else if (doughnutParams.StartAngle >= Math.PI && doughnutParams.StartAngle < Math.PI * 1.5 && doughnutParams.StopAngle >= Math.PI && doughnutParams.StopAngle < Math.PI * 1.5)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    }
                    else if (doughnutParams.StartAngle >= Math.PI * 1.5 && doughnutParams.StartAngle < Math.PI * 2 && doughnutParams.StopAngle >= Math.PI * 1.5 && doughnutParams.StopAngle < Math.PI * 2)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                }
            }

            return pieFaces;
        }
예제 #4
0
파일: PieChart.cs 프로젝트: tdhieu/openvss
        /// <summary>
        /// Returns 3D Pie shapes
        /// </summary>
        /// <param name="faces">Pie faces</param>
        /// <param name="pieParams">Pie parameters</param>
        /// <param name="zindex">Zindex</param>
        /// <param name="unExplodedPoints">UnExploded dataPoints</param>
        /// <param name="explodedPoints">Exploded dataPoints</param>
        /// <param name="labelLinePath">Label line path</param>
        /// <param name="enabledDataPoints">List of enabled dataPoints</param>
        /// <returns>List of Shape</returns>
        private static List<Shape> GetPie3D(DataSeries currentDataSeries, ref Faces faces, SectorChartShapeParams pieParams, ref Int32 zindex, ref PieDoughnut3DPoints unExplodedPoints, ref PieDoughnut3DPoints explodedPoints, ref Path labelLinePath, List<DataPoint> enabledDataPoints)
        {
            List<Shape> pieFaces = new List<Shape>();

            Shape topFace = null, bottomFace = null, rightFace = null, leftFace = null;
            Point center = new Point();
            center.X = pieParams.Width / 2;
            center.Y = pieParams.Height / 2;

            // calculate 3d offsets
            Double yOffset = -pieParams.Depth / 2 * pieParams.ZAxisScaling;

            // calculate all points
            Point3D topFaceCenter = new Point3D();
            topFaceCenter.X = center.X;
            topFaceCenter.Y = center.Y + yOffset;
            topFaceCenter.Z = pieParams.OffsetY * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D topArcStart = new Point3D();
            topArcStart.X = topFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
            topArcStart.Y = topFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle) * pieParams.YAxisScaling;
            topArcStart.Z = (topFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D topArcStop = new Point3D();
            topArcStop.X = topFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
            topArcStop.Y = topFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle) * pieParams.YAxisScaling;
            topArcStop.Z = (topFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StopAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D bottomFaceCenter = new Point3D();
            bottomFaceCenter.X = center.X;
            bottomFaceCenter.Y = center.Y - yOffset;
            bottomFaceCenter.Z = pieParams.OffsetY * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D bottomArcStart = new Point3D();
            bottomArcStart.X = bottomFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
            bottomArcStart.Y = bottomFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle) * pieParams.YAxisScaling;
            bottomArcStart.Z = (bottomFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D bottomArcStop = new Point3D();
            bottomArcStop.X = bottomFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
            bottomArcStop.Y = bottomFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle) * pieParams.YAxisScaling;
            bottomArcStop.Z = (bottomFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StopAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D centroid = GetCentroid(topFaceCenter, topArcStart, topArcStop, bottomFaceCenter, bottomArcStart, bottomArcStop);

            UpdatePositionLabelInsidePie(pieParams, yOffset);

            if (pieParams.StartAngle == pieParams.StopAngle && pieParams.IsLargerArc || enabledDataPoints.Count == 1)
            {
                // draw singleton pie here
                topFace = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                // topFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;
                topFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Linear", new Double[] { 0.99, 0.854 }) : pieParams.Background;

                topFace.Width = 2 * pieParams.OuterRadius;
                topFace.Height = 2 * pieParams.OuterRadius * pieParams.YAxisScaling;
                topFace.SetValue(Canvas.LeftProperty, (Double)(pieParams.Center.X - topFace.Width / 2));
                topFace.SetValue(Canvas.TopProperty, (Double)(pieParams.Center.Y - topFace.Height / 2 + yOffset));
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                bottomFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;

                bottomFace.Width = 2 * pieParams.OuterRadius;
                bottomFace.Height = 2 * pieParams.OuterRadius * pieParams.YAxisScaling;
                bottomFace.SetValue(Canvas.LeftProperty, (Double)(pieParams.Center.X - topFace.Width / 2));
                bottomFace.SetValue(Canvas.TopProperty, (Double)(pieParams.Center.Y - topFace.Height / 2 + yOffset));
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);
            }
            else
            {
                topFace = GetPieFace(pieParams, centroid, topFaceCenter, topArcStart, topArcStop);
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = GetPieFace(pieParams, centroid, bottomFaceCenter, bottomArcStart, bottomArcStop);
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);

                rightFace = GetPieSide(pieParams, centroid, topFaceCenter, bottomFaceCenter, topArcStart, bottomArcStart);
                pieFaces.Add(rightFace);
                faces.Parts.Add(rightFace);

                leftFace = GetPieSide(pieParams, centroid, topFaceCenter, bottomFaceCenter, topArcStop, bottomArcStop);
                pieFaces.Add(leftFace);
                faces.Parts.Add(leftFace);
            }

            labelLinePath = CreateLabelLine(currentDataSeries, pieParams, center, ref unExplodedPoints, ref explodedPoints);

            if ((pieParams.TagReference as DataPoint).InternalYValue == 0)
                return new List<Shape>();

            List<Shape> curvedSurface = GetPieOuterCurvedFace(pieParams, centroid, topFaceCenter, bottomFaceCenter);
            pieFaces.InsertRange(pieFaces.Count, curvedSurface.ToList());

            foreach (FrameworkElement fe in curvedSurface)
                faces.Parts.Add(fe);

            //Top face ZIndex
            topFace.SetValue(Canvas.ZIndexProperty, (Int32)(50000));

            //BottomFace ZIndex
            bottomFace.SetValue(Canvas.ZIndexProperty, (Int32)(-50000));

            if (pieParams.StartAngle == pieParams.StopAngle && pieParams.IsLargerArc)
            {

            }
            else
            {
                // ZIndex of curved face
                if (pieParams.StartAngle >= Math.PI && pieParams.StartAngle <= Math.PI * 2 && pieParams.StopAngle >= Math.PI && pieParams.StopAngle <= Math.PI * 2 && pieParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, 0, Math.PI));
                }
                else if (pieParams.StartAngle >= 0 && pieParams.StartAngle <= Math.PI && pieParams.StopAngle >= 0 && pieParams.StopAngle <= Math.PI && pieParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], 0, pieParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    if (labelLinePath != null)
                        labelLinePath.SetValue(Canvas.ZIndexProperty, -50000);
                }
                else if (pieParams.StartAngle >= 0 && pieParams.StartAngle <= Math.PI && pieParams.StopAngle >= Math.PI && pieParams.StopAngle <= Math.PI * 2)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    
                    //  if (labelLinePath != null)
                    //      _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, Math.PI));

                    //------------
                    if (labelLinePath != null)
                    {
                        if (pieParams.StartAngle >= Math.PI / 2 && pieParams.StopAngle <= Math.PI)
                            labelLinePath.SetValue(Canvas.ZIndexProperty, 50000);
                        else
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, Math.PI));
                    }
                    //------------

                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, Math.PI));
                }
                else if (pieParams.StartAngle >= Math.PI && pieParams.StartAngle <= Math.PI * 2 && pieParams.StopAngle >= 0 && pieParams.StopAngle <= Math.PI)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, pieParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StopAngle, pieParams.StopAngle));
                }
                else
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    if (pieParams.StartAngle >= 0 && pieParams.StartAngle < Math.PI / 2 && pieParams.StopAngle >= 0 && pieParams.StopAngle < Math.PI / 2)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StopAngle, pieParams.StopAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                    }
                    else if (pieParams.StartAngle >= 0 && pieParams.StartAngle < Math.PI / 2 && pieParams.StopAngle >= Math.PI / 2 && pieParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            labelLinePath.SetValue(Canvas.ZIndexProperty, 40000);
                        curvedSurface[0].SetValue(Canvas.ZIndexProperty, 35000);
                    }
                    else if (pieParams.StartAngle >= Math.PI / 2 && pieParams.StartAngle < Math.PI && pieParams.StopAngle >= Math.PI / 2 && pieParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                    }
                    else if (pieParams.StartAngle >= Math.PI && pieParams.StartAngle < Math.PI * 1.5 && pieParams.StopAngle >= Math.PI && pieParams.StopAngle < Math.PI * 1.5)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StartAngle));
                    }
                    else if (pieParams.StartAngle >= Math.PI * 1.5 && pieParams.StartAngle < Math.PI * 2 && pieParams.StopAngle >= Math.PI * 1.5 && pieParams.StopAngle < Math.PI * 2)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StopAngle));
                    }
                    else
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                    }

                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                }
            }

            return pieFaces;

        }
예제 #5
0
        public void FncShowPopup(clsPageInfo objPageInfo)
        {

            try
            {

                List<string> buddies = new List<string>();
                List<string> modules = new List<string>();
                foreach (clsTabInfo objtab in objPageInfo.objaTabs)
                {
                    foreach (clsPodInfo objpod in objtab.objaPods)
                    {


                        buddies.InsertRange(buddies.Count, objpod.straPodBuddies);
                        modules.Add(objpod.strPodTitle);

                    }
                }
                objPopup.FnvLoadpopup(objPageInfo.strFrom, modules, buddies);


            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "FncShowPopup()", "pgHome.xaml.cs");

            }
        }
예제 #6
0
파일: DisplayBox.cs 프로젝트: Mofsy/jinxbot
        // Actually adds the nodes to the chat window.
        private void AddChatImpl(List<ChatNode> nodes)
        {
            if (IncludeTimestamp)
            {
                DateTime now = DateTime.Now;
                string timestamp = string.Format(CultureInfo.CurrentCulture, m_timestampFormat, now.Hour, now.Minute, now.Second);
                ChatNode ts = new ChatNode(timestamp, m_tsColor);
                nodes.InsertRange(0, new ChatNode[] { ts, new ChatNode(" ", Color.Black) });
            }

            Paragraph element = ParseChatNodesIntoParagraph(nodes.ToArray());
            ThreadStart invokee = delegate
            {
                display.Document.Blocks.Add(element);
                if (display.Viewer.Selection.IsEmpty) 
                    display.Viewer.FindFirstVisualDescendantOfType<ScrollViewer>().ScrollToBottom();
            };
            display.Dispatcher.BeginInvoke(invokee);

            UpdateParagraphs();
        }
예제 #7
0
        /// <summary>
        /// Calculate ControlPoints of a DataSeries
        /// </summary>
        /// <param name="chart">Chart</param>
        /// <param name="plotGroup">Corresponding plotGroup</param>
        /// <param name="dataPoints">List of DataPoints</param>
        /// <returns>ControlPoints</returns>
        internal static Point[] CalculateControlPointsOfADataSeries(Chart chart, PlotGroup plotGroup, List<DataPoint> dataPoints)
        {   
            List<Point> tempCPoints = new List<Point>();

            if (chart != null && chart.InternalSeries != null && plotGroup != null && dataPoints.Count > 0)
            {   
                Double minimumZVal, maximumZVal;

                List<DataSeries> seriesList = chart.InternalSeries;
                CalculateMaxAndMinZValueFromAllSeries(ref seriesList, out minimumZVal, out maximumZVal);

                Double tempAxisMinimum = plotGroup._initialAxisXMin;
                Double tempAxisMaximum = plotGroup._initialAxisXMax;

                dataPoints = dataPoints.OrderBy(a => a.ZValue).ToList();
                DataPoint dataPointHavingMaxZVal = dataPoints.Last();
                Double maxBubbleRadius = CalculateBubbleSize(dataPointHavingMaxZVal, minimumZVal, maximumZVal);

                foreach (DataPoint dataPoint in dataPoints)
                {   
                    // Double maxBubbleRadius = CalculateBubbleSize(dataPoint, minimumZVal, maximumZVal);
                    List<Point> controlPointsOfDp = CalculateControlPointsOfDataPoint(dataPoint, plotGroup, maxBubbleRadius, minimumZVal, maximumZVal, plotGroup.AxisX, plotGroup.AxisY);
                    tempCPoints.InsertRange(0, controlPointsOfDp);
                }

                if (tempCPoints.Count > 0)
                {   
                    tempCPoints = tempCPoints.OrderBy(x => x.X).ToList();
                }

                // tempCPoints.Clear();
            }

            return tempCPoints.ToArray();
        }
예제 #8
0
 private List<object> ItemsFind(string sPattern)
 {
     List<object> aRetVal = new List<object>();
     List<object> aStartedWith = new List<object>();
     sPattern = sPattern.ToLower();
     string sValue;
     foreach (object o in aItemsSource)
     {
         sValue = _cPropertyTarget.GetValue(o, null).ToString().ToLower().Trim();
         if (sValue.Contains(sPattern))
         {
             if (sValue.StartsWith(sPattern))
                 aStartedWith.Add(o);
             else
                 aRetVal.Add(o);
         }
     }
     aRetVal.InsertRange(0, aStartedWith);
     return aRetVal;
 }