예제 #1
0
 public BodyElementPropertyConverter(BodyElement bodyElement, System.Windows.Forms.ListViewItem viewItem, CoronaObject objectParent, Form1 mainForm)
 {
     this.bodyElement    = bodyElement;
     this.viewItem       = viewItem;
     this.selectedObject = objectParent;
     this.mainForm       = mainForm;
 }
예제 #2
0
        private void surfacePictBx_MouseUp(object sender, MouseEventArgs e)
        {
            this.isMouseDown = false;

            if (this.DrawMode.Equals("CIRCLE"))
            {
                //Creer directement l'element Circle
                int    index = this.coronaObject.PhysicsBody.BodyElements.Count;
                string name  = "Circle";

                BodyElement elem = new BodyElement(index, name, 0, 0, 0, this.surfaceCircleBuilding.Location, this.surfaceCircleBuilding.Width / 2);
                this.coronaObject.PhysicsBody.BodyElements.Add(elem);

                this.surfaceCircleBuilding = Rectangle.Empty;

                this.shapeBuilding = null;
                this.mainForm.physicsBodySettings1.reloadPanel();
            }
            else if (this.DrawMode.Equals("HAND"))
            {
                Point offSetPoint = this.getScrollOffsetPoint();
                Point pTouched    = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.currentScale)),
                                              Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.currentScale)));

                shapeBuilding.Add(pTouched);

                if (this.mainForm.isFormLocked == false)
                {
                    GorgonLibrary.Gorgon.Go();
                }
            }
        }
예제 #3
0
 public BodyElementPropertyConverter(BodyElement bodyElement, System.Windows.Forms.ListViewItem viewItem,CoronaObject objectParent,Form1 mainForm)
 {
     this.bodyElement = bodyElement;
     this.viewItem = viewItem;
     this.selectedObject = objectParent;
     this.mainForm = mainForm;
 }
예제 #4
0
        public override void GenerateBody()
        {
            base.GenerateBody();
            var annotationPage = new Div(Compatibility);

            annotationPage.GlobalAttributes.Class.Value = ElementStylesV3.Annotation;
            if (BookAnnotation != null)
            {
                foreach (var item in BookAnnotation.SubElements())
                {
                    annotationPage.Add(item);
                }
            }
            else
            {
                annotationPage.Add(new SimpleHTML5Text(Compatibility)
                {
                    Text = "Unnamed"
                });
            }

            annotationPage.Add(new EmptyLine(Compatibility));

            BodyElement.Add(annotationPage);
        }
예제 #5
0
        public override void GenerateBody()
        {
            base.GenerateBody();

            var coverPage = new Div(Compatibility);

            coverPage.GlobalAttributes.Class.Value = ElementStylesV2.CoverPage;
            coverPage.Add(_coverImage);
            BodyElement.Add(coverPage);
        }
예제 #6
0
        public List <BodyElement> GetSelectedBodyElements()
        {
            List <BodyElement> bodyElements = new List <BodyElement>();

            for (int i = 0; i < this.bodyElementsListView.SelectedItems.Count; i++)
            {
                BodyElement elem = this.bodyElementsListView.SelectedItems[i].Tag as BodyElement;
                bodyElements.Add(elem);
            }

            return(bodyElements);
        }
예제 #7
0
        private static XmlElement GenerateIllustration(XmlDocument document, string uniqueId, int count,
                                                       BodyElement element)
        {
            var illustrationElement = document.CreateElement("illustration");

            illustrationElement.AppendChild(
                document.CreateCDataSection($"<p style=\"\"><img src=\"{uniqueId}_{count}.png\"/></p>"));
            var path = $"./{ExtractionSettings.Output}/Items/Item-{ExtractionSettings.BankKey}-{uniqueId}";

            Directory.CreateDirectory(path);
            element.Image.Save($"{path}/{uniqueId}_{count}.png", ImageFormat.Png);
            return(illustrationElement);
        }
예제 #8
0
        public static BodyElement BodyElementFromNode(string path, HtmlNode node)
        {
            var element = new BodyElement();
            var imgNode =
                node.Descendants().FirstOrDefault(x => x.Name.Equals("img", StringComparison.OrdinalIgnoreCase));

            element.Text = node.OuterHtml;
            if (imgNode != null)
            {
                element.Image = ImageUtilities.ImageFromParentHtmlNode(path, imgNode);
            }
            return(element);
        }
예제 #9
0
        public List <BodyElement> getBodyLinesFromPoints()
        {
            if (this.shapeBuilding != null)
            {
                //APpliquer un algo de reduction de points
                List <Point> pointsReduced = this.DouglasPeuckerReduction(shapeBuilding, 3);

                //Convertir la liste de points en CPoints2D
                CPoint2D[] points2D = getCPoint2D(pointsReduced);

                //Creer un calculate reduction
                CalculateReduction cr        = new CalculateReduction(points2D);
                CPoint2D[]         pointsRet = cr.getPointReduce();
                if (pointsRet != null)
                {
                    List <Point> listPoints = convertCPoint2DToPoint(pointsRet);

                    //Creer les bodyelements
                    List <BodyElement> elements = new List <BodyElement>();


                    for (int i = 0; i < listPoints.Count - 1; i++)
                    {
                        Point        p1         = listPoints[i];
                        Point        p2         = listPoints[i + 1];
                        List <Point> pointsLine = new List <Point>();
                        pointsLine.Add(p1);
                        pointsLine.Add(p2);
                        BodyElement elem = new BodyElement(elements.Count, "Line" + elements.Count, 0, 0, 0, pointsLine);
                        elements.Add(elem);

                        if (listPoints.Count % 2 == 1)
                        {
                            if (i == listPoints.Count - 2)
                            {
                                Point        p3          = listPoints[i + 1];
                                List <Point> pointsLine2 = new List <Point>();
                                pointsLine2.Add(p2);
                                pointsLine2.Add(p3);

                                BodyElement elem2 = new BodyElement(elements.Count, "Line" + elements.Count, 0, 0, 0, pointsLine2);
                                elements.Add(elem2);
                            }
                        }
                    }
                    return(elements);
                }
            }

            return(null);
        }
예제 #10
0
        private static void ProcessBody(BodyElement bodyElement, Body xmlBody)
        {
            var xmlBodyElements = xmlBody.Elements();

            foreach (var xmlBodyElement in xmlBodyElements)
            {
                if (xmlBodyElement is Paragraph xmlParagraph)
                {
                    var paragraphElement = new ParagraphElement();
                    ProcessParagraph(paragraphElement, xmlParagraph);
                    bodyElement.AddElement(paragraphElement);
                }
            }
        }
예제 #11
0
        public void reloadPanel()
        {
            if (this.CoronaObject != null)
            {
                //Reinit entierement le panneau

                this.bodyElementsListView.Items.Clear();

                this.bodyElementsPropertyGrid.SelectedObjects = null;
                for (int i = 0; i < this.CoronaObject.PhysicsBody.BodyElements.Count; i++)
                {
                    BodyElement  bodyElement = this.CoronaObject.PhysicsBody.BodyElements[i];
                    ListViewItem bodyItem    = new ListViewItem();
                    bodyItem.Name = bodyElement.Name;
                    bodyItem.Text = bodyElement.Name;
                    bodyItem.Tag  = bodyElement;

                    if (bodyElement.Type.Equals("CIRCLE"))
                    {
                        bodyItem.ImageIndex = 0;
                    }
                    else
                    {
                        bodyItem.ImageIndex = 1;
                    }


                    this.bodyElementsListView.Items.Add(bodyItem);
                }

                if (this.CoronaObject.PhysicsBody.BodyElements.Count > 0)
                {
                    this.CoronaObject.PhysicsBody.isCustomizedBody = true;
                }
                else
                {
                    this.CoronaObject.PhysicsBody.isCustomizedBody = false;
                }
            }

            if (this.MainForm.isFormLocked == false)
            {
                GorgonLibrary.Gorgon.Go();
            }
        }
예제 #12
0
        public override void GenerateBody()
        {
            base.GenerateBody();
            Div page = new Div(Compatibility);

            page.GlobalAttributes.Class.Value = "about";
            H1 heading = new H1(Compatibility);

            heading.Add(new SimpleHTML5Text(Compatibility)
            {
                Text = "About"
            });
            page.Add(heading);

            foreach (var text in AboutTexts)
            {
                var p1    = new Paragraph(Compatibility);
                var text1 = new SimpleHTML5Text(Compatibility)
                {
                    Text = text
                };
                p1.Add(text1);
                page.Add(p1);
            }

            foreach (var text in AboutLinks)
            {
                var p1   = new Paragraph(Compatibility);
                var anch = new Anchor(Compatibility);
                anch.HRef.Value = text;
                anch.GlobalAttributes.Title.Value = text;
                var text3 = new SimpleHTML5Text(Compatibility)
                {
                    Text = text
                };
                anch.Add(text3);
                p1.Add(anch);
                page.Add(p1);
            }

            BodyElement.Add(page);
        }
예제 #13
0
        public void validerBodyShape()
        {
            if (this.MainForm.physicBodyEditorView1.DrawMode.Equals("SHAPE"))
            {
                //Recuperer la shape convertie

                List <BodyElement> elements = this.MainForm.physicBodyEditorView1.getTriangulatedShapes();
                if (elements != null)
                {
                    for (int i = 0; i < elements.Count; i++)
                    {
                        BodyElement elem = elements[i];


                        this.CoronaObject.PhysicsBody.BodyElements.Add(elements[i]);
                    }
                }
                else
                {
                    MessageBox.Show("The polygon cannot be created! Please try again.", "Invalid Polygon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (this.MainForm.physicBodyEditorView1.DrawMode.Equals("HAND"))
            {
                //Recuperer la shape convertie
                List <BodyElement> elements = this.MainForm.physicBodyEditorView1.getBodyLinesFromPoints();
                if (elements != null)
                {
                    for (int i = 0; i < elements.Count; i++)
                    {
                        BodyElement elem = elements[i];


                        this.CoronaObject.PhysicsBody.BodyElements.Add(elements[i]);
                    }
                }
            }

            this.MainForm.physicBodyEditorView1.setModeNormal();
            this.reloadPanel();
        }
예제 #14
0
        private void bodyElementsListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.bodyElementsPropertyGrid.SelectedObjects = null;
            if (this.bodyElementsListView.SelectedIndices.Count > 0)
            {
                BodyElementPropertyConverter[] tabConverter =
                    new BodyElementPropertyConverter[this.bodyElementsListView.SelectedIndices.Count];

                for (int i = 0; i < this.bodyElementsListView.SelectedItems.Count; i++)
                {
                    ListViewItem viewItem = this.bodyElementsListView.SelectedItems[i];
                    BodyElement  elem     = viewItem.Tag as BodyElement;
                    BodyElementPropertyConverter converter = new BodyElementPropertyConverter(elem, viewItem, this.CoronaObject, this.MainForm);
                    tabConverter[i] = converter;
                }

                this.bodyElementsPropertyGrid.SelectedObjects = tabConverter;
            }

            GorgonLibrary.Gorgon.Go();
        }
예제 #15
0
        public List <BodyElement> getTriangulatedShapes(CPolygonShape polygonShapes)
        {
            if (polygonShapes != null)
            {
                //Creer une liste de body elements
                List <BodyElement> elements = new List <BodyElement>();

                bool res = (bool)polygonShapes.CutEar();
                if (res == false)
                {
                    return(null);
                }

                //Recuperer le nombre d'elem deja present
                int nbElemExistants = this.coronaObject.PhysicsBody.BodyElements.Count;
                for (int i = 0; i < polygonShapes.NumberOfPolygons; i++)
                {
                    //Recuperer les polygons
                    CPoint2D[] tabCps = polygonShapes.Polygons(i);

                    //Recuperer le tableau de point associé
                    List <Point> pointsConverted = this.convertCPoint2DToPoint(tabCps);

                    //Creer un body elem
                    int indexElem = nbElemExistants;
                    nbElemExistants++;
                    string      name = "AUTO_SHAPE";
                    BodyElement elem = new BodyElement(indexElem, name, 0, 0, 0, pointsConverted);
                    elements.Add(elem);
                }

                return(elements);
            }

            return(null);
        }
예제 #16
0
        public List<BodyElement> getBodyLinesFromPoints()
        {
            if (this.shapeBuilding != null)
            {
                //APpliquer un algo de reduction de points
                List<Point> pointsReduced = this.DouglasPeuckerReduction(shapeBuilding,3);

                //Convertir la liste de points en CPoints2D
                CPoint2D[] points2D = getCPoint2D(pointsReduced);

                //Creer un calculate reduction
                CalculateReduction cr = new CalculateReduction(points2D);
                CPoint2D[] pointsRet = cr.getPointReduce();
                if (pointsRet != null)
                {
                    List<Point> listPoints = convertCPoint2DToPoint(pointsRet);

                    //Creer les bodyelements
                    List<BodyElement> elements = new List<BodyElement>();

                    for (int i = 0; i < listPoints.Count-1; i++)
                    {
                        Point p1 = listPoints[i];
                        Point p2 = listPoints[i + 1];
                        List<Point> pointsLine = new List<Point>();
                        pointsLine.Add(p1);
                        pointsLine.Add(p2);
                        BodyElement elem = new BodyElement(elements.Count, "Line" + elements.Count, 0, 0, 0, pointsLine);
                        elements.Add(elem);

                        if (listPoints.Count % 2 == 1)
                        {
                            if (i == listPoints.Count - 2)
                            {
                                Point p3 = listPoints[i + 1];
                                List<Point> pointsLine2 = new List<Point>();
                                pointsLine2.Add(p2);
                                pointsLine2.Add(p3);

                                BodyElement elem2 = new BodyElement(elements.Count, "Line" + elements.Count, 0, 0, 0, pointsLine2);
                                elements.Add(elem2);
                            }
                        }
                    }
                    return elements;

                }

            }

            return null;
        }
예제 #17
0
        public List<BodyElement> getTriangulatedShapes(CPolygonShape polygonShapes)
        {
            if (polygonShapes != null)
            {
                //Creer une liste de body elements
                List<BodyElement> elements = new List<BodyElement>();

                bool res = (bool)polygonShapes.CutEar();
                if (res == false) return null;

                //Recuperer le nombre d'elem deja present
                int nbElemExistants = this.coronaObject.PhysicsBody.BodyElements.Count;
                for (int i = 0; i < polygonShapes.NumberOfPolygons; i++)
                {
                    //Recuperer les polygons
                    CPoint2D[] tabCps = polygonShapes.Polygons(i);

                    //Recuperer le tableau de point associé
                    List<Point> pointsConverted = this.convertCPoint2DToPoint(tabCps);

                    //Creer un body elem
                    int indexElem = nbElemExistants;
                    nbElemExistants++;
                    string name = "AUTO_SHAPE";
                    BodyElement elem = new BodyElement(indexElem, name, 0, 0, 0, pointsConverted);
                    elements.Add(elem);
                }

                return elements;
            }

            return null;
        }
예제 #18
0
        public static BodyElement Parse(string text)
        {
            StringBuilder plainText = new StringBuilder(text.Length);
            BodyElement root = new BodyElement();
            root.HasExpandElement = false;
            MarkupElement currentParent = root;
            Stack openTags = new Stack();
            openTags.Push(root);
            // Input text is not wrapped into the container tag so we wrap it here
            text = text.Replace("&nbsp;", "{ent_nbsp}");
            text = text.Replace("&zwsp;", "{ent_zwsp}");
            text = text.Replace("&lt;", "{ent_lt}");
            text = text.Replace("&gt;", "{ent_gt}");
            text = text.Replace("&amp;", "{ent_amp}");
            text = text.Replace("|", "{ent_l}");
            text = text.Replace("&", "|");
            text = text.Replace("{ent_nbsp}", "&nbsp;");
            text = text.Replace("{ent_zwsp}", "&zwsp;"); 
            text = text.Replace("{ent_lt}", "&lt;");
            text = text.Replace("{ent_gt}", "&gt;");
            StringReader sr = new StringReader("<"+BodyTag+">" + text + "</"+BodyTag+">");
#if !DEBUG
            try
#endif
            {
                XmlTextReader reader = new XmlTextReader(sr);
                //reader.EntityHandling = EntityHandling.ExpandCharEntities;
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == BodyTag)
                            continue;
                        MarkupElement el = CreateMarkupElement(reader.Name);
                        if (el == null)
                        {
                            reader.Skip();
                            continue;
                        }
                        else if (el is ExpandElement)
                            root.HasExpandElement = true;

                        if (el is IActiveMarkupElement)
                            root.ActiveElements.Add(el);

                        // Parse any attributes here
                        if (reader.AttributeCount > 0)
                        {
                            el.ReadAttributes(reader);
                            reader.MoveToElement();
                        }

                        currentParent.Elements.Add(el);

                        if (el is ContainerElement)
                            currentParent = el;

                        if (!reader.IsEmptyElement)
                            openTags.Push(el);
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        if (reader.Value.Length == 1)
                        {
                            TextElement el = CreateMarkupElement(TextElementName) as TextElement;
                            if (reader.Value == " ")
                            {
                                el.TrailingSpace = true;
                                plainText.Append(' ');
                            }
                            else
                            {
                                el.Text = reader.Value;
                                el.Text = el.Text.Replace("|", "&");
                                el.Text = el.Text.Replace("{ent_l}", "|");
                                el.Text = el.Text.Replace("{ent_amp}", "&&");
                                plainText.Append(el.Text+" ");
                            }
                            currentParent.Elements.Add(el);
                        }
                        else
                        {
                            string s = reader.Value;
                            if (s.StartsWith("\r\n"))
                                s = s.TrimStart(new char[] { '\r', '\n' });
                            s = s.Replace("\r\n", " ");
                            string[] words = s.Split(' ');
                            bool space = false;
                            if (currentParent.Elements.Count > 0 && currentParent.Elements[currentParent.Elements.Count - 1] is NewLine)
                                space = true;
                            for (int i = 0; i < words.Length; i++)
                            {
                                if (words[i].Length == 0)
                                {
                                    if (space)
                                        continue;
                                    space = true;
                                }
                                else
                                    space = false;

                                TextElement el = CreateMarkupElement(TextElementName) as TextElement;
                                el.Text = words[i].Replace("|","&");
                                el.Text = el.Text.Replace("{ent_l}", "|");
                                el.Text = el.Text.Replace("{ent_amp}", "&&");
                                plainText.Append(el.Text + " ");
                                if (i < words.Length - 1)
                                {
                                    el.TrailingSpace = true;
                                    space = true;
                                }

                                currentParent.Elements.Add(el);
                            }
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.Whitespace)
                    {
                        if (reader.Value.IndexOf(' ') >= 0)
                        {
                            TextElement el = CreateMarkupElement(TextElementName) as TextElement;
                            el.TrailingSpace = true;
                            currentParent.Elements.Add(el);
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.EntityReference)
                    {
                        TextElement el = CreateMarkupElement(TextElementName) as TextElement;
                        if (reader.Name == "nbsp")
                        {
                            el.TrailingSpace = true;
                        }
                        else if (reader.Name == "zwsp")
                        {
                            el.TrailingSpace = false;
                        }
                        else
                            el.Text = reader.Name;
                        el.EnablePrefixHandling = false;
                        currentParent.Elements.Add(el);
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        MarkupElement el = openTags.Pop() as MarkupElement;
                        if (el != currentParent)
                        {
                            currentParent.Elements.Add(new EndMarkupElement(el));
                        }
                        else
                        {
                            if (currentParent != root)
                                currentParent = currentParent.Parent;
                        }
                    }
                }
            }
#if !DEBUG
            catch
            {
                return null;
            }
#endif
            root.PlainText = plainText.ToString();
            return root;
        }
예제 #19
0
        private void surfacePictBx_MouseUp(object sender, MouseEventArgs e)
        {
            this.isMouseDown = false;

            if (this.DrawMode.Equals("CIRCLE"))
            {
                //Creer directement l'element Circle
                int index = this.coronaObject.PhysicsBody.BodyElements.Count;
                string name = "Circle";

                BodyElement elem = new BodyElement(index, name, 0, 0, 0, this.surfaceCircleBuilding.Location, this.surfaceCircleBuilding.Width / 2);
                this.coronaObject.PhysicsBody.BodyElements.Add(elem);

                this.surfaceCircleBuilding = Rectangle.Empty ;

                this.shapeBuilding = null;
                this.mainForm.physicsBodySettings1.reloadPanel();
            }
               else if (this.DrawMode.Equals("HAND"))
            {
                Point offSetPoint = this.getScrollOffsetPoint();
                Point pTouched = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.currentScale)),
                     Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.currentScale)));

                shapeBuilding.Add(pTouched);

                if (this.mainForm.isFormLocked == false)
                    GorgonLibrary.Gorgon.Go();
            }
        }
예제 #20
0
 public WordDocument()
 {
     Body = new BodyElement();
 }
예제 #21
0
        public void DrawGorgon()
        {
            GorgonLibrary.Gorgon.CurrentRenderTarget.Clear(Color.Black);
            GorgonLibrary.Gorgon.CurrentRenderTarget.BeginDrawing();
            //Dessiner les shapes des element existants
            if (this.coronaObject != null)
            {
                Point offsetPoint = this.getScrollOffsetPoint();
                Point offsetFinal = new Point(offsetPoint.X - this.coronaObject.DisplayObject.SurfaceRect.X, offsetPoint.Y - this.coronaObject.DisplayObject.SurfaceRect.Y);

                this.coronaObject.DisplayObject.DrawGorgon(offsetFinal
                                                           , false, this.currentScale, this.currentScale, false);

                Color color = Color.FromArgb(100, Color.YellowGreen);
                this.coronaObject.PhysicsBody.drawGorgonBodyElements(color, false, offsetPoint, this.currentScale, false);

                //Dessiner d'une autre couleur les elements selectionnés
                List <BodyElement> selectedBodies = this.mainForm.physicsBodySettings1.GetSelectedBodyElements();
                for (int i = 0; i < selectedBodies.Count; i++)
                {
                    BodyElement elem = selectedBodies[i];
                    if (elem.Type.Equals("SHAPE"))
                    {
                        //Creer un tableau de points ajustés
                        List <Point> tabPointsAjust = new List <Point>();

                        Point middlePoint = new Point(this.coronaObject.DisplayObject.SurfaceRect.Width / 2,
                                                      this.coronaObject.DisplayObject.SurfaceRect.Height / 2);

                        for (int j = 0; j < elem.BodyShape.Count; j++)
                        {
                            Point pAjust = new Point((int)((float)(elem.BodyShape[j].X + offsetPoint.X)),
                                                     (int)((float)(elem.BodyShape[j].Y + offsetPoint.Y)));


                            tabPointsAjust.Insert(j, pAjust);

                            //Close the figure
                            if (j == elem.BodyShape.Count - 1)
                            {
                                tabPointsAjust.Add(tabPointsAjust[0]);
                            }
                        }

                        GorgonGraphicsHelper.Instance.DrawLines(tabPointsAjust, Color.FromArgb(150, Color.Blue), 1.5f, this.currentScale);
                    }
                    else if (elem.Type.Equals("CIRCLE"))
                    {
                        int radius = elem.Radius;


                        GorgonGraphicsHelper.Instance.FillCircle(elem.SurfaceCircle.X + offsetPoint.X,
                                                                 elem.SurfaceCircle.Y + offsetPoint.Y,
                                                                 elem.Radius, Color.FromArgb(150, Color.Blue), this.currentScale, false);
                    }
                }

                //Dessiner le build
                if (this.shapeBuilding != null)
                {
                    if (this.shapeBuilding.Count > 1)
                    {
                        List <Point> tabPoint = new List <Point>();
                        for (int i = 0; i < this.shapeBuilding.Count; i++)
                        {
                            tabPoint.Add(new Point(this.shapeBuilding[i].X + offsetPoint.X, this.shapeBuilding[i].Y + offsetPoint.Y));
                        }


                        GorgonGraphicsHelper.Instance.DrawLines(tabPoint, color, 1, this.currentScale);
                    }


                    if (this.DrawMode == "SHAPE")
                    {
                        Color blue = Color.FromArgb(100, Color.Blue);
                        for (int i = 0; i < this.shapeBuilding.Count; i++)
                        {
                            GorgonGraphicsHelper.Instance.FillCircle(this.shapeBuilding[i].X + offsetPoint.X - 3, this.shapeBuilding[i].Y + offsetPoint.Y - 3,
                                                                     3, blue, this.currentScale, false);
                        }
                    }
                }
                else if (this.surfaceCircleBuilding.IsEmpty == false)
                {
                    GorgonGraphicsHelper.Instance.FillCircle(this.surfaceCircleBuilding.Location.X + offsetPoint.X, this.surfaceCircleBuilding.Location.Y + offsetPoint.Y,
                                                             this.surfaceCircleBuilding.Size.Width / 2, color, this.currentScale, false);
                }
            }

            GorgonLibrary.Gorgon.CurrentRenderTarget.EndDrawing();
        }
예제 #22
0
파일: PhysicsBody.cs 프로젝트: nadar71/Krea
        public PhysicsBody cloneBody(CoronaObject objectParent)
        {
            PhysicsBody newBody = new PhysicsBody(objectParent);

            newBody.Mode = this.Mode;
            newBody.CollisionGroupIndex = this.CollisionGroupIndex;

            if (this.isCustomizedBody == true)
            {
                for (int i = 0; i < this.BodyElements.Count; i++)
                {
                    BodyElement elem = this.BodyElements[i];
                    if (elem.Type.Equals("CIRCLE"))
                    {

                        BodyElement newElem = new BodyElement(i, elem.Name, elem.Bounce, elem.Density, elem.Friction, elem.LocationCircle, elem.Radius);
                        newElem.CollisionGroupIndex = elem.CollisionGroupIndex;
                        newBody.BodyElements.Add(newElem);
                    }
                    else
                    {
                        //Create a new bodyElement
                        List<Point> bodyShape = elem.BodyShape.ToList();

                        BodyElement newElem = new BodyElement(i, elem.Name, elem.Bounce, elem.Density, elem.Friction, bodyShape);
                        newElem.CollisionGroupIndex = elem.CollisionGroupIndex;
                        newBody.BodyElements.Add(newElem);

                    }

                }
                newBody.isCustomizedBody = true;
            }
            else
            {
                newBody.Bounce = this.Bounce;
                newBody.Density = this.Density;
                newBody.Friction = this.Friction;
                newBody.isCustomizedBody = false;
            }

            newBody.isFixedRotation = this.isFixedRotation;
            return newBody;
        }
예제 #23
0
파일: PhysicsBody.cs 프로젝트: nadar71/Krea
        public void updateBody()
        {
            DisplayObject dispObject = this.objectParent.DisplayObject;
            Figure fig = dispObject.Figure;
            if (fig != null)
            {
                if (fig.ShapeType.Equals("LINE"))
                {
                    Line line = fig as Line;
                    this.BodyElements.Clear();

                    //Creer un bodyElement tout les deux points
                    for (int i = 0; i < line.Points.Count - 1; i++)
                    {
                        List<Point> listePointsLigne = new List<Point>();

                        Point p1 = new Point(line.Points[i].X - dispObject.SurfaceRect.X,
                                                line.Points[i].Y - dispObject.SurfaceRect.Y);

                        Point p2 = new Point(line.Points[i + 1].X - dispObject.SurfaceRect.X,
                                                line.Points[i + 1].Y - dispObject.SurfaceRect.Y);

                        listePointsLigne.Add(p1);
                        listePointsLigne.Add(p2);

                        BodyElement elem = new BodyElement(this.BodyElements.Count, "Line" + this.BodyElements.Count, 0, 0, 0, listePointsLigne);
                        this.BodyElements.Add(elem);

                    }

                    this.isCustomizedBody = true;
                }
                else if (fig.ShapeType.Equals("CURVE"))
                {
                    //Recuperer tous les points de la curve
                    CourbeBezier courbe = fig as CourbeBezier;
                    this.BodyElements.Clear();

                    GraphicsPath path = new GraphicsPath(FillMode.Winding);
                    path.AddCurve(courbe.UserPoints.ToArray());
                    path.Flatten();
                    PointF[] finalPoints = path.PathPoints;

                    //Creer un bodyElement tout les deux points
                    for (int i = 0; i < finalPoints.Length - 1; i++)
                    {
                        List<Point> listePointsLigne = new List<Point>();

                        Point p1 = new Point((int)finalPoints[i].X - dispObject.SurfaceRect.X,
                                                (int)finalPoints[i].Y - dispObject.SurfaceRect.Y);
                        Point p2 = new Point((int)finalPoints[i + 1].X - dispObject.SurfaceRect.X
                                            , (int)finalPoints[i + 1].Y - dispObject.SurfaceRect.Y);
                        listePointsLigne.Add(p1);
                        listePointsLigne.Add(p2);

                        BodyElement elem = new BodyElement(this.BodyElements.Count, "Line" + this.BodyElements.Count, 0, 0, 0, listePointsLigne);
                        this.BodyElements.Add(elem);

                    }

                    this.isCustomizedBody = true;
                }

            }
            else
            {
                if (dispObject.Type.Equals("SPRITE") || dispObject.Type.Equals("IMAGE"))
                {
                    if (this.OriginSize.Width > 0 && this.OriginSize.Height > 0)
                    {
                        double scaleX = Convert.ToDouble(dispObject.SurfaceRect.Width) / Convert.ToDouble(this.OriginSize.Width);
                        double scaleY = Convert.ToDouble(dispObject.SurfaceRect.Height) / Convert.ToDouble(this.OriginSize.Height);
                        for (int i = 0; i < this.BodyElements.Count; i++)
                        {
                            BodyElement elem = this.BodyElements[i];
                            if (elem.Type.Equals("CIRCLE"))
                            {
                                elem.Radius = Convert.ToInt32(Convert.ToDouble(elem.Radius) * scaleX);

                            }
                            else if (elem.Type.Equals("SHAPE"))
                            {
                                for (int j = 0; j < elem.BodyShape.Count; j++)
                                {
                                    Point p = elem.BodyShape[j];

                                    p.X = Convert.ToInt32(Convert.ToDouble(p.X) * scaleX);
                                    p.Y = Convert.ToInt32(Convert.ToDouble(p.Y) * scaleY);
                                    elem.BodyShape[j] = p;
                                }

                            }
                        }
                    }

                }
                this.OriginSize = dispObject.SurfaceRect.Size;
            }
        }
예제 #24
0
        public List <BodyElement> getTriangulatedShapes()
        {
            if (this.shapeBuilding != null)
            {
                //Creer une liste de body elements
                if (this.shapeBuilding.Count < 3)
                {
                    return(null);
                }

                List <BodyElement> elements = new List <BodyElement>();

                //Create a Cpolygon
                CPoint2D[] tabCpoint2D = getCPoint2D(this.shapeBuilding);

                CPolygonShape polygonShapes = new CPolygonShape(tabCpoint2D);
                //Generated
                bool res = (bool)polygonShapes.CutEar();
                if (res == false)
                {
                    return(null);
                }

                //Recuperer le nombre d'elem deja present
                int nbElemExistants = this.coronaObject.PhysicsBody.BodyElements.Count;
                for (int i = 0; i < polygonShapes.NumberOfPolygons; i++)
                {
                    //Recuperer les polygons
                    CPoint2D[] tabCps = polygonShapes.Polygons(i);

                    //Recuperer le tableau de point associé
                    List <Point> pointsConverted = this.convertCPoint2DToPoint(tabCps);

                    //Diviser les points en groupe de 8
                    List <List <Point> > listPolygones = new List <List <Point> >();
                    List <Point>         currentList   = new List <Point>();
                    for (int j = 0; j < pointsConverted.Count; j++)
                    {
                        if (currentList.Count == 8)
                        {
                            listPolygones.Add(currentList);
                            currentList = new List <Point>();
                            currentList.Add(pointsConverted[0]);
                            currentList.Add(pointsConverted[j - 1]);
                        }

                        currentList.Add(pointsConverted[j]);

                        if (j == pointsConverted.Count - 1)
                        {
                            listPolygones.Add(currentList);
                        }
                    }


                    //Creer un body elem par polygone
                    for (int j = 0; j < listPolygones.Count; j++)
                    {
                        int indexElem = nbElemExistants;
                        nbElemExistants++;
                        string      name = "AUTO_SHAPE";
                        BodyElement elem = new BodyElement(indexElem, name, 0, 0, 0, listPolygones[j]);
                        elements.Add(elem);
                    }
                }

                return(elements);
            }

            return(null);
        }
예제 #25
0
        public override void GenerateBody()
        {
            base.GenerateBody();
            var titlePage = new Div(Compatibility);

            titlePage.GlobalAttributes.Class.Value = ElementStylesV2.TitlePage;
            if (!string.IsNullOrEmpty(BookTitle))
            {
                // try to use FB2 book's title
                var p = new H2(Compatibility);
                p.Add(new SimpleHTML5Text(Compatibility)
                {
                    Text = BookTitle
                });
                p.GlobalAttributes.Class.Value = string.Format(ElementStylesV2.TitleItemFormat, 1);
                titlePage.Add(p);
            }
            else
            {
                titlePage.Add(new SimpleHTML5Text(Compatibility)
                {
                    Text = "Unnamed"
                });
            }

            titlePage.Add(new EmptyLine(Compatibility));

            var sbSeries = new StringBuilder();

            foreach (var serie in _series)
            {
                if (!string.IsNullOrEmpty(sbSeries.ToString()))
                {
                    sbSeries.Append(" , ");
                }
                sbSeries.Append(serie);
            }
            if (sbSeries.ToString() != string.Empty)
            {
                var seriesItem = new SimpleHTML5Text(Compatibility)
                {
                    Text = string.Format("( {0} )", sbSeries)
                };
                var containingText = new EmphasisedText(Compatibility);
                containingText.Add(seriesItem);
                var seriesHeading = new H3(Compatibility);
                seriesHeading.GlobalAttributes.Class.Value = ElementStylesV2.TitleSeries;
                seriesHeading.Add(containingText);
                titlePage.Add(seriesHeading);
            }

            foreach (var author in _authors)
            {
                var authorsHeading = new H3(Compatibility);
                var authorLine     = new SimpleHTML5Text(Compatibility)
                {
                    Text = author
                };
                authorsHeading.Add(authorLine);
                authorsHeading.GlobalAttributes.Class.Value = ElementStylesV2.TitleAuthors;
                titlePage.Add(authorsHeading);
            }


            BodyElement.Add(titlePage);
        }
예제 #26
0
        public List<BodyElement> getTriangulatedShapes()
        {
            if(this.shapeBuilding != null)
            {
                //Creer une liste de body elements
                if (this.shapeBuilding.Count < 3) return null;

                List<BodyElement> elements = new List<BodyElement>();

                //Create a Cpolygon
                CPoint2D[] tabCpoint2D = getCPoint2D(this.shapeBuilding);

                CPolygonShape polygonShapes = new CPolygonShape(tabCpoint2D);
                //Generated
                bool res = (bool)polygonShapes.CutEar();
                if (res == false) return null;

                //Recuperer le nombre d'elem deja present
                int nbElemExistants = this.coronaObject.PhysicsBody.BodyElements.Count;
                for(int i = 0;i<polygonShapes.NumberOfPolygons;i++)
                {
                    //Recuperer les polygons
                    CPoint2D[] tabCps = polygonShapes.Polygons(i);

                    //Recuperer le tableau de point associé
                    List<Point> pointsConverted = this.convertCPoint2DToPoint(tabCps);

                    //Diviser les points en groupe de 8
                    List<List<Point>> listPolygones = new List<List<Point>>();
                    List<Point> currentList = new List<Point>();
                    for (int j = 0; j < pointsConverted.Count; j++)
                    {
                        if (currentList.Count == 8)
                        {
                            listPolygones.Add(currentList);
                            currentList = new List<Point>();
                            currentList.Add(pointsConverted[0]);
                            currentList.Add(pointsConverted[j - 1]);

                        }

                        currentList.Add(pointsConverted[j]);

                        if (j == pointsConverted.Count - 1)
                        {
                            listPolygones.Add(currentList);
                        }

                    }

                    //Creer un body elem par polygone
                    for (int j = 0; j < listPolygones.Count; j++)
                    {
                        int indexElem = nbElemExistants;
                        nbElemExistants++;
                        string name = "AUTO_SHAPE";
                        BodyElement elem = new BodyElement(indexElem, name, 0, 0, 0, listPolygones[j]);
                        elements.Add(elem);
                    }

                }

                return elements;
            }

            return null;
        }