コード例 #1
0
ファイル: Manequin.cs プロジェクト: Kobodera/WorkoutCreator
        private ManequinPoint CreatePoint(string partId, string title, PointType type, int data, ManequinPoint parent, string extension = "")
        {
            ManequinPoint point = new ManequinPoint()
            {
                PartId = partId,
                Title = title,
                PointType = type,
                Data = data,
                ParentId = parent == null ? null : parent.PartId,
                Extension = extension
            };

            Points.Add(point);

            return point;
        }
コード例 #2
0
ファイル: Manequin.cs プロジェクト: Kobodera/WorkoutCreator
        private void DrawManequinPoint(Bitmap bmp, Graphics g, Pen p, ManequinPoint point, ManequinPoint parent)
        {
            if (!string.IsNullOrWhiteSpace(ManequinText))
            {
                using (Font f = new Font("Times New Roman", bmp.Height / 12))
                {
                    SizeF size = g.MeasureString(ManequinText, f);

                    g.DrawString(ManequinText, f, Brushes.Black, (bmp.Width - size.Width) / 2, (bmp.Height - size.Height));
                }
            }

            if ((((int)point.XRel) != -1) && (((int)point.YRel) != -1))
            {
                float x = bmp.Width * (float)point.XRel;
                float y = bmp.Height * (float)point.YRel;

                switch (point.PointType)
                {
                    case PointType.Circle:

                        if (parent != null && parent.XRel != -1 && parent.YRel != -1)
                        {
                            float widthPar = (float)(bmp.Width * (parent.Data / 100));
                            float heightPar = (float)(bmp.Height * (parent.Data / 100));
                            float xPar = bmp.Width * (float)parent.XRel - widthPar / 2;
                            float yPar = bmp.Height * (float)parent.YRel - heightPar / 2;

                            g.DrawLine(p, xPar, yPar, x, y);
                        }

                        if (point.Data != -1)
                        {
                            float width = (float)(bmp.Width * (point.Data / 100));
                            float height = (float)(bmp.Height * (point.Data / 100));

                            x = x - width / 2;
                            y = y - height / 2;

                            g.FillEllipse(Brushes.White, x, y, width, height);
                            g.DrawEllipse(p, x, y, width, height);
                            //g.DrawEllipse(p, bmp.Width * (float)point.XRel, bmp.Height * (float)point.YRel, (float)bmp.Width * (point.Data / 100), (float)bmp.Height * (point.Data / 100));
                        }

                        break;
                    case PointType.FilledCircle:
                        break;
                    case PointType.Line:
                        //A parent point has been registered. Draw a line from that point to this point
                        if (parent != null && ((int)parent.XRel) != -1 && ((int)parent.YRel) != -1)
                        {
                            if (parent.Extension.Length > 0 && parent.Extension != point.PartId)
                            {
                                ManequinPoint extension = GetPoint(parent.Extension);
                                if (extension.XRel != -1 && extension.YRel != -1)
                                {
                                    DrawManequinPoint(bmp, g, p, extension, parent);
                                    parent = extension;
                                }
                            }

                            if (parent.PointType == PointType.Circle)
                            {
                                float widthPar = (float)(bmp.Width * (parent.Data / 100));
                                float heightPar = (float)(bmp.Height * (parent.Data / 100));
                                float xPar = bmp.Width * (float)parent.XRel;
                                float yPar = bmp.Height * (float)parent.YRel;

                                g.DrawLine(p, xPar, yPar, x, y);
                                g.FillEllipse(Brushes.White, xPar - widthPar / 2, yPar - heightPar / 2, widthPar, heightPar);
                                g.DrawEllipse(p, xPar - widthPar / 2, yPar - heightPar / 2, widthPar, heightPar);
                            }
                            else
                            {
                                //Needed in order to be able to save the manequin
                                ManequinPoint parentsParent = GetPoint(parent.ParentId);
                                if (parentsParent != null && parentsParent.Extension.Length > 0)
                                {
                                    ManequinPoint extension = GetPoint(parentsParent.Extension);
                                    if (extension.XRel != -1 && extension.YRel != -1 && parentsParent != null && point.Data != -1)
                                    {
                                        parent = extension;
                                    }
                                }

                                float xPar = bmp.Width * (float)parent.XRel;
                                float yPar = bmp.Height * (float)parent.YRel;

                                if (parentsParent != null && point.Data != -1)
                                {
                                    float xPar2 = bmp.Width * (float)parentsParent.XRel;
                                    float yPar2 = bmp.Height * (float)parentsParent.YRel;

                                    xPar = (float)(xPar + (xPar2 - xPar) * (point.Data / 100));
                                    yPar = (float)(yPar + (yPar2 - yPar) * (point.Data / 100));
                                }

                                g.DrawLine(p, xPar, yPar, x, y);
                            }
                        }

                        break;
                }

                foreach (ManequinPoint pt in point.ManequinPoints)
                {
                    DrawManequinPoint(bmp, g, p, pt, point);
                }

            }
        }
コード例 #3
0
ファイル: Manequin.cs プロジェクト: Kobodera/WorkoutCreator
        private void CreateNode(ManequinPoint point, TreeNode parent)
        {
            parent.Nodes.Add(point.PartNode);

            foreach (ManequinPoint child in point.ManequinPoints)
            {
                CreateNode(child, point.PartNode);
            }
        }