/// <summary>
        /// Draw the line
        /// </summary>
        public override void Draw(BackgroundTemplate parent, Graphics g, Rectangle r)
        {
            PointF newS, newD, oldP1,oldP2;

            oldP1 = this.m_Line.P1;
            oldP2 = this.m_Line.P2;

            //Update P1 P2 if the line is repeated
            this.CheckForIterater();

            newS = this.m_Line.P1;
            newD = this.m_Line.P2;

            switch (this.m_Line.LineType)
            {
                case LineType.LINE: GetLineRectIntersections(parent, ref newS, ref newD); break;
                case LineType.RAY: GetRayRectIntersections(parent, ref newD); break;
                case LineType.SEGMENT: break;
            }

            SerializablePen pen = parent.GetPrimitivePenByIndex(this.m_Line.PenIndex);
            if(pen!=null)
                g.DrawLine(pen.GetPen(), newS, newD);

            this.m_Line.P1 = oldP1;
            this.m_Line.P2 = oldP2;
        }
Exemplo n.º 2
0
        public BackgroundTemplate Clone()
        {
            BackgroundTemplate bkgTemplate = new BackgroundTemplate();

            bkgTemplate.Name   = this.Name;
            bkgTemplate.CNName = this.CNName;
            bkgTemplate.FRName = this.FRName;
            bkgTemplate.ESName = this.ESName;
            bkgTemplate.PTName = this.PTName;
            if (this.BackgroundBrush != null)
            {
                bkgTemplate.BackgroundBrush = (SerializableBrush)this.BackgroundBrush.Clone();
            }
            bkgTemplate.GeometryTransform = this.GeometryTransform;
            bkgTemplate.Height            = this.Height;
            bkgTemplate.Width             = this.Width;

            for (int i = 0; i < this.PrimitivePens.Count; i++)
            {
                bkgTemplate.PrimitivePens.Add(((SerializablePen)this.PrimitivePens[i]).Clone());
            }

            for (int i = 0; i < this.Geometry.Count; i++)
            {
                bkgTemplate.Geometry.Add(((IBackgroundPrimitive)this.Geometry[i]).Clone());
            }

            return(bkgTemplate);
        }
Exemplo n.º 3
0
        public void UpdateValue(BackgroundTemplate template)
        {
            if (this == template)
            {
                return;
            }

            if (template.BackgroundBrush != null)
            {
                this.BackgroundBrush = template.BackgroundBrush.Clone();
            }

            this.Name              = template.Name;
            this.CNName            = template.CNName;
            this.ESName            = template.ESName;
            this.FRName            = template.FRName;
            this.PTName            = template.PTName;
            this.Height            = template.Height;
            this.Width             = template.Width;
            this.GeometryTransform = template.GeometryTransform;

            this.PrimitivePens.Clear();
            for (int i = 0; i < template.PrimitivePens.Count; i++)
            {
                this.PrimitivePens.Add(((SerializablePen)template.PrimitivePens[i]).Clone());
            }

            this.Geometry.Clear();
            for (int i = 0; i < template.Geometry.Count; i++)
            {
                this.Geometry.Add(((IBackgroundPrimitive)template.Geometry[i]).Clone());
            }
        }
        /// <summary>
        /// Construction for Form
        /// </summary>
        public BackgroundPropertiesForm(PresenterModel model)
        {
            this.m_Model = model;

            this.SuspendLayout();
            this.ClientSize = new Size(320, 320);
            this.Font = ViewerStateModel.FormFont;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.Name = "BackgroundPropertiesForm";
            this.Text = Strings.BackgroundPropertiesFormTitle;

            //Get the BackgroundTemplate Model
            using (this.m_Model.Workspace.Lock())
            {
                DeckTraversalModel traversal = this.m_Model.Workspace.CurrentDeckTraversal;
                if (traversal != null)
                {
                    using (Synchronizer.Lock(traversal.SyncRoot))
                    {
                        if (this.m_ApplyToCurrentSlideOnly)
                        {
                            SlideModel current = traversal.Current.Slide;
                            if (current != null)
                            {
                                using (Synchronizer.Lock(traversal.Current.Slide.SyncRoot))
                                {
                                    if (traversal.Current.Slide.BackgroundTemplate != null)
                                    {
                                        this.m_Template = traversal.Current.Slide.BackgroundTemplate.Clone();
                                    }
                                }
                            }
                        }
                        else
                        {
                            DeckModel deck = traversal.Deck;
                            using (Synchronizer.Lock(deck.SyncRoot))
                            {
                                if (deck.DeckBackgroundTemplate != null)
                                    this.m_Template = deck.DeckBackgroundTemplate.Clone();
                            }
                        }
                    }
                }
            }

            this.m_BkgTemplateSelectionGroup = new BkgTemplateSelectionGroup(this, this.m_Template, new Point(20, 10), new Size(280, 50), 0);
            this.Controls.Add(this.m_BkgTemplateSelectionGroup);

            this.m_BkgTemplatePreviewGroup = new BkgTemplatePreviewGroup(this, new Point(20, 70), new Size(280, 210), 1);
            this.Controls.Add(this.m_BkgTemplatePreviewGroup);

            this.Controls.Add(new PropertiesOKButton(this, this.m_Model, new Point(80, 285), 2));
            this.Controls.Add(new PropertiesCancelButton(this, this.m_Model, this.m_Template, new Point(180, 285), 3));

            this.ResumeLayout();
        }
Exemplo n.º 5
0
 public DeckMessage(DeckModel deck)
     : base(deck.Id)
 {
     this.AddLocalRef( deck );
     using(Synchronizer.Lock(deck.SyncRoot)) {
         this.Group = deck.Group;
         this.HumanName = deck.HumanName;
         this.Disposition = deck.Disposition;
         this.DeckBackgroundColor = deck.DeckBackgroundColor;
         this.DeckBackgroundTemplate = deck.DeckBackgroundTemplate;
     }
 }
        /// <summary>
        /// Set BackgroundBrush of the template into xml document
        /// </summary>
        private void SetBackgroundBrush(XmlDocument doc, XmlElement newTemplate, BackgroundTemplate template)
        {
            XmlElement backgroundBrushNode = doc.CreateElement("BakcgroundBrush");

            if (template.BackgroundBrush != null)
            {
                if (template.BackgroundBrush.BrushType == BrushType.SolidBrush)
                {
                    XmlElement solidBrushNode = doc.CreateElement("SolidBrush");

                    XmlAttribute color = doc.CreateAttribute("color");
                    color.InnerText = template.BackgroundBrush.SolidBrushColor.Name;
                    solidBrushNode.SetAttributeNode(color);

                    backgroundBrushNode.AppendChild(solidBrushNode);
                }
                else if (template.BackgroundBrush.BrushType == BrushType.LinearGradientBrush)
                {
                    XmlElement linearGradientBrushNode = doc.CreateElement("LinearGradientBrush");

                    XmlAttribute color1 = doc.CreateAttribute("color1");
                    color1.InnerText = template.BackgroundBrush.LinearGradientBrushColor1.Name;
                    linearGradientBrushNode.SetAttributeNode(color1);

                    XmlAttribute color2 = doc.CreateAttribute("color2");
                    color2.InnerText = template.BackgroundBrush.LinearGradientBrushColor2.Name;
                    linearGradientBrushNode.SetAttributeNode(color2);

                    XmlAttribute point1 = doc.CreateAttribute("point1");
                    point1.InnerText = "( "+template.BackgroundBrush.LinearGradientPoint1.X+","+template.BackgroundBrush.LinearGradientPoint1.Y+")";
                    linearGradientBrushNode.SetAttributeNode(point1);

                    XmlAttribute point2 = doc.CreateAttribute("point2");
                    point2.InnerText="( "+template.BackgroundBrush.LinearGradientPoint2.X+","+template.BackgroundBrush.LinearGradientPoint2.Y+")";
                    linearGradientBrushNode.SetAttributeNode(point2);

                    backgroundBrushNode.AppendChild(linearGradientBrushNode);
                }
            }

            newTemplate.AppendChild(backgroundBrushNode);
        }
        /// <summary>
        /// Set all the PrimitivePens into xml document
        /// </summary>
        private void SetPrimitivePens(XmlDocument doc, XmlElement newTemplate, BackgroundTemplate template)
        {
            XmlElement primitivePens = doc.CreateElement("PrimitivePens");

            for (int i = 0; i < template.PrimitivePens.Count; i++)
            {
                SerializablePen pen = (SerializablePen) template.PrimitivePens[i];

                XmlElement penElement = doc.CreateElement("Pen");

                XmlAttribute index = doc.CreateAttribute("index");
                index.InnerText =""+ pen.Index;
                penElement.SetAttributeNode(index);

                XmlAttribute width = doc.CreateAttribute("width");
                width.InnerText =""+ pen.Width;
                penElement.SetAttributeNode(width);

                XmlAttribute color = doc.CreateAttribute("color");
                color.Value = pen.Color.Name;
                penElement.SetAttributeNode(color);

                XmlAttribute dashstyle = doc.CreateAttribute("dashstyle");
                dashstyle.Value = pen.DashStyle.ToString();
                penElement.SetAttributeNode(dashstyle);

                primitivePens.AppendChild(penElement);
            }

            newTemplate.AppendChild(primitivePens);
        }
        /// <summary>
        /// Parse all the pens, and add them into the PrimitivePens List in BackgroundTemplate
        /// </summary>
        private void ParsePrimitivePens(XmlNode primitivePensNode, BackgroundTemplate template)
        {
            for (int i = 0; i < primitivePensNode.ChildNodes.Count; i++)
            {
                XmlNode penNode = primitivePensNode.ChildNodes[i];
                SerializablePen pen;

                //Get the pen color
                Color color = Color.Black;

                XmlAttribute attribute = penNode.Attributes["color"];

                if (attribute != null)
                {
                    String colorStr = attribute.Value;
                    color = ParseColor(colorStr);
                }

                pen = new SerializablePen(color);

                //Get the pen dashstyle
                attribute = penNode.Attributes["dashstyle"];
                if(attribute!=null)
                {
                    switch (attribute.Value)
                    {
                        case "Solid": pen.DashStyle = DashStyle.Solid; break;
                        case "Dot": pen.DashStyle = DashStyle.Dot; break;
                        case "Dash": pen.DashStyle = DashStyle.Dash; break;
                        case "DashDot": pen.DashStyle = DashStyle.DashDot; break;
                        case "DashDotDot": pen.DashStyle = DashStyle.DashDotDot; break;
                        default: pen.DashStyle = DashStyle.Solid; break;
                    }
                }

                //get the pen width
                float width = 1f;
                attribute = penNode.Attributes["width"];
                if (attribute != null)
                {
                    try
                    {
                        width = float.Parse(attribute.Value);
                    }
                    catch { width = 1f; }
                }
                pen.Width = width;

                //get the pen index
                int index=i;

                attribute = penNode.Attributes["index"];
                if(attribute!=null)
                {
                    try{
                     index=Int32.Parse(attribute.Value);
                    }
                    catch{
                        index = i;
                    }
                }
                pen.Index = index;

                template.PrimitivePens.Add(pen);
            }
        }
        /// <summary>
        /// Get all the templates in BackgroundTemplate.xml
        /// </summary>
        public void GetTemplates(ArrayList templates)
        {
            //Create XmlDocument and Load BackgroundTemplate.xml

            StreamReader sr = new StreamReader(this.m_BackgroundTemplateXmlPath);

            XmlDocument doc = new XmlDocument();
            doc.Load(sr);

            string language = null;
            using (Synchronizer.Lock(m_ViewerStateModel.SyncRoot))
            {
                language = m_ViewerStateModel.Language;
            }

            //Get all the BackgroundTemplate Nodes, and parse each template node
            XmlNodeList list = doc.GetElementsByTagName("BackgroundTemplate");
            for (int i = 0; i < list.Count; i++)
            {
                BackgroundTemplate template = new BackgroundTemplate(language);
                XmlNode templateNode = list[i];

                XmlAttribute temp;

                //Get the name of the BackgroundTemplate
                temp = templateNode.Attributes["name"];
                if (temp != null)
                    template.Name = temp.Value;

                //Get the chinese name
                temp = templateNode.Attributes["name.zh-CN"];
                if (temp != null)
                    template.CNName = temp.Value;

                //Get the spanish name
                temp = templateNode.Attributes["name.es-ES"];
                if (temp != null)
                    template.ESName = temp.Value;

                //Get the french name
                temp = templateNode.Attributes["name.fr-FR"];
                if (temp != null)
                    template.FRName = temp.Value;

                //Get the portuguese name
                temp = templateNode.Attributes["name.pt-BR"];
                if (temp != null)
                    template.PTName = temp.Value;

                //Get the width of the BackgroundTemplate
                temp = templateNode.Attributes["width"];
                if (temp != null)
                    template.Width = Int32.Parse(temp.Value);

                //Get the height of the BackgroundTemplate
                temp = templateNode.Attributes["height"];
                if (temp != null)
                    template.Height = Int32.Parse(temp.Value);

                //Get the childnode of PrimitivePens, BackgroundBrush, GeomrtryTransform, Geometry
                XmlNodeList childnodes = templateNode.ChildNodes;
                for (int j = 0; j < childnodes.Count; j++)
                {
                    XmlNode subNode = childnodes[j];
                    switch (subNode.Name)
                    {
                        case "PrimitivePens": ParsePrimitivePens(subNode, template); break;
                        case "BackgroundBrush": ParseBackgroundBrush(subNode, template); break;
                        case "GeometryTransform": template.GeometryTransform=ParseGeometryTransform(subNode); break;
                        case "Geometry": ParseGeometry(subNode, template.Geometry); break;
                    }
                }

                templates.Add(template);
            }
            sr.Close();
        }
        /// <summary>
        /// Save the BackgroundTemplate into xml file
        /// </summary>
        /// <param name="template"></param>
        public void SaveTemplate(BackgroundTemplate template)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(this.m_BackgroundTemplateXmlPath);

            XmlNode templatesNode = doc.SelectSingleNode("BackgroundTemplates");
            //Create a new BackgroundTemplate node
            XmlElement newTemplateNode = doc.CreateElement("BackgroundTemplate");

            //Add name attribute to BackgroundTemplate
            XmlAttribute name = doc.CreateAttribute("name");
            name.InnerText = template.Name;
            newTemplateNode.SetAttributeNode(name);

            //Add chinese name of the template
            if (template.CNName != null)
            {
                XmlAttribute cnname = doc.CreateAttribute("name.zh-CN");
                cnname.Value = template.CNName;
                newTemplateNode.SetAttributeNode(cnname);
            }

            //add french name of the template
            if (template.FRName != null)
            {
                XmlAttribute frname = doc.CreateAttribute("name.fr-FR");
                frname.Value = template.FRName;
                newTemplateNode.SetAttributeNode(frname);
            }

            //add spanish name of the template
            if (template.ESName != null)
            {
                XmlAttribute esname = doc.CreateAttribute("name.es-ES");
                esname.Value = template.ESName;
                newTemplateNode.SetAttributeNode(esname);
            }

            //add portaugust name of the template
            if (template.PTName != null)
            {
                XmlAttribute ptname = doc.CreateAttribute("name.pt-BR");
                ptname.Value = template.PTName;
                newTemplateNode.SetAttributeNode(ptname);
            }

            //add width
            if (template.Width != 0)
            {
                XmlAttribute width = doc.CreateAttribute("width");
                width.InnerText = "" + template.Width;
                newTemplateNode.SetAttributeNode(width);
            }

            //add height
            if (template.Height != 0)
            {
                XmlAttribute height = doc.CreateAttribute("height");
                height.InnerText = "" + template.Height;
                newTemplateNode.SetAttributeNode(height);
            }

            SetPrimitivePens(doc, newTemplateNode, template);

            SetBackgroundBrush(doc, newTemplateNode, template);

            SetGeometryTransform(doc, newTemplateNode, template.GeometryTransform);

            SetGeometry(doc, newTemplateNode, template.Geometry);

            templatesNode.AppendChild(newTemplateNode);

            doc.Save(this.m_BackgroundTemplateXmlPath);
        }
        /// <summary>
        /// Parse BackgroundBrush for the template from BackgroundBrush Node
        /// </summary>
        /// <param name="backgroundBrushNode">XmlNode for the BackgroundBrush</param>
        /// <param name="template"> BackgroundTemplate model</param>
        private void ParseBackgroundBrush(XmlNode backgroundBrushNode, BackgroundTemplate template)
        {
            if (backgroundBrushNode.HasChildNodes)
            {
                XmlNode brushNode = backgroundBrushNode.ChildNodes[0];

                //if the brush is solid brush, then create SerializableBrush, and set it to BackgroundTemplate
                if (brushNode.Name.Equals("SolidBrush"))
                {
                    XmlAttribute attribute=brushNode.Attributes["color"];
                    if (attribute != null)
                    {
                        String colorStr = attribute.Value;
                        Color color = ParseColor(colorStr);
                        if (color != Color.Empty)
                        {
                            SerializableBrush brush = new SerializableBrush(color);
                            template.BackgroundBrush = brush;
                        }
                    }
                }
                //if the brush is LinearGradientBrush, then create SerializableBrush, and set it to BackgroundTemplate
                else if (brushNode.Name.Equals("LinearGradientBrush"))
                {

                    XmlAttribute attribute = brushNode.Attributes["color1"];
                    if (attribute == null) return;
                    String value = attribute.Value;
                    Color color1 = ParseColor(value);

                    attribute = brushNode.Attributes["color2"];
                    if (attribute == null) return;
                    value = attribute.Value;
                    Color color2=ParseColor(value);

                    attribute = brushNode.Attributes["point1"];
                    if (attribute == null) return;
                    value = attribute.Value;
                    PointF point1 = ParsePoint(value);

                    attribute = brushNode.Attributes["point2"];
                    if (attribute == null) return;
                    value = attribute.Value;
                    PointF point2 = ParsePoint(value);

                    if (color1 != Color.Empty && color2 != Color.Empty && (point1 != Point.Empty || point2 != Point.Empty))
                    {
                        SerializableBrush brush = new SerializableBrush(point1, point2, color1, color2);
                        template.BackgroundBrush = brush;
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void UpdateValue(BackgroundTemplate template)
        {
            if (this == template) return;

            if (template.BackgroundBrush != null)
            {
                this.BackgroundBrush = template.BackgroundBrush.Clone();
            }

            this.Name = template.Name;
            this.CNName = template.CNName;
            this.ESName = template.ESName;
            this.FRName = template.FRName;
            this.PTName = template.PTName;
            this.Height = template.Height;
            this.Width = template.Width;
            this.GeometryTransform = template.GeometryTransform;

            this.PrimitivePens.Clear();
            for (int i = 0; i < template.PrimitivePens.Count; i++)
                this.PrimitivePens.Add(((SerializablePen)template.PrimitivePens[i]).Clone());

            this.Geometry.Clear();
            for (int i = 0; i < template.Geometry.Count; i++)
                this.Geometry.Add(((IBackgroundPrimitive)template.Geometry[i]).Clone());
        }
 /// <summary>
 /// Construction
 /// </summary>
 public BackgroundTemplateRenderer(BackgroundTemplate backgroundTemplate)
 {
     this.m_BackgroundTemplate = backgroundTemplate;
     this.m_Zoom = 1f;
 }
Exemplo n.º 14
0
 // NOTE: Eventually this code should be converted to use SlideRenderer instead of each SheetRenderer. There were some issues with doing
 // this initially so for the time being we will keep it like this.
 public static Bitmap DrawSlide(TableOfContentsModel.Entry currentEntry, BackgroundTemplate template, System.Drawing.Color background, SheetDisposition dispositions)
 {
     return PPTDeckIO.DrawSlide(currentEntry, template, background, dispositions, 0, 0, 1.0f);
 }
        /// <summary>
        /// Draw the iterator primitives
        /// </summary>
        public override void Draw(BackgroundTemplate parent, Graphics g, Rectangle r)
        {
            Matrix old = g.Transform.Clone();

            //if the repeatAmount==0 (infinitely), then compute the repeat times for both directions

            if (this.m_Iterator.RepeatAmount== 0)
            {
                int totalRepeatTimes = this.GetRepeatTimesForInfinite((int)(parent.Width / this.m_Zoom), (int)(parent.Height / this.m_Zoom));

                //draw as offset direction
                for (int i = 0; i < totalRepeatTimes; i++)
                {
                    Matrix current = g.Transform.Clone();

                    foreach (IBackgroundPrimitive p in this.m_Iterator.Geometry)
                    {
                        PrimitiveRenderer render = PrimitiveRenderer.GetRenderer(p, this.m_Zoom);
                        if (render == null) continue;

                        //For Line, compute the Transform when rendering
                        if (render is LinePrimitiveRenderer)
                        {
                            ((LinePrimitiveRenderer)render).HasIterator = true;
                            ((LinePrimitiveRenderer)render).IteratorIndex = i;
                            ((LinePrimitiveRenderer)render).OffsetTransform = this.m_Iterator.OffsetTransform.GetMatrix();
                            g.Transform = old;
                            render.Draw(parent, g, r);
                            continue;
                        }
                        else render.Draw(parent, g, r);
                    }

                    //Compute new offset transform
                    current.Multiply(this.m_Iterator.OffsetTransform.GetMatrix());
                    g.Transform = current;
                }

                //Get reverse matrix of offsetTransform
                g.Transform = old.Clone();
                Matrix reverseTransform = this.m_Iterator.OffsetTransform.GetMatrix();

                if (reverseTransform.IsInvertible)
                    reverseTransform.Invert();

                //draw as reverse offset direction
                for (int i = 0; i < totalRepeatTimes; i++)
                {
                    Matrix current = g.Transform.Clone();

                    foreach (IBackgroundPrimitive p in this.m_Iterator.Geometry)
                    {
                        PrimitiveRenderer render = PrimitiveRenderer.GetRenderer(p, this.m_Zoom);
                        if (render == null) continue;

                        //For Line, compute the Transform when rendering
                        if (render is LinePrimitiveRenderer)
                        {
                            ((LinePrimitiveRenderer)render).HasIterator = true;
                            ((LinePrimitiveRenderer)render).IteratorIndex = i;
                            ((LinePrimitiveRenderer)render).OffsetTransform = reverseTransform;
                            g.Transform = old;
                            render.Draw(parent, g, r);
                            continue;
                        }
                        else render.Draw(parent, g, r);
                    }

                    //Compute new offset transform
                    current.Multiply(reverseTransform);
                    g.Transform = current;
                }
            }
            else
            {
                //the repeat number is non indifinited, ao draw primitive as defined
                for (int i = 0; i < this.m_Iterator.RepeatAmount; i++)
                {
                    foreach (IBackgroundPrimitive p in this.m_Iterator.Geometry)
                    {
                        PrimitiveRenderer.GetRenderer(p, this.m_Zoom).Draw(parent, g, r);
                    }

                    Matrix current = g.Transform.Clone();
                    current.Multiply(this.m_Iterator.OffsetTransform.GetMatrix());
                    g.Transform = current;
                }
            }
            g.Transform = old;
        }
 public PropertiesCancelButton(BackgroundPropertiesForm parent, PresenterModel model, BackgroundTemplate template, Point location, int tabIndex)
 {
     this.m_Parent = parent;
     this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.FlatStyle = FlatStyle.System;
     this.Font = ViewerStateModel.StringFont;
     this.Location = location;
     this.Name = "propertiesCancelButton";
     this.TabIndex = tabIndex;
     this.Text = Strings.Cancel;
 }
Exemplo n.º 17
0
        /// <summary>
        /// Compute the intersections between ray and template boundary rect.
        /// </summary>
        private void GetRayRectIntersections(BackgroundTemplate parent, ref PointF dstPoint)
        {
            float recWidth, recHeight;

            PointF p1, p2;
            p1 = this.m_Line.P1;
            p2 = this.m_Line.P2;

            recWidth = parent.Width;
            recHeight = parent.Height;

            ArrayList points = new ArrayList();
            if (p1.X == p2.X)
            {
                dstPoint = (p1.Y - p2.Y > 0) ? new PointF(p1.X, 0) : new PointF(p1.X, recHeight - 1);
                return;
            }
            else if (p1.Y == p2.Y)
            {
                dstPoint = (p1.X - p2.X > 0) ? new PointF(0, p1.Y) : new PointF(parent.Width - 1, p1.Y);
                return;
            }
            else
            {
                float slope = (p1.Y - p2.Y) / (p1.X - p2.X);

                if (p1.X > p2.X)
                {
                    float leftY = p1.Y - slope * p1.X;
                    if (leftY >= 0 && leftY <= recHeight - 1)
                        points.Add(new PointF(0, leftY));
                }
                else
                {
                    float rightY = p1.Y + slope * (recWidth - 1 - p1.X);
                    if (rightY >= 0 && rightY <= recHeight - 1)
                        points.Add(new PointF(recWidth - 1, rightY));
                }

                if (p1.Y > p2.Y)
                {
                    float topX = p1.X - p1.Y / slope;
                    if (topX >= 0 && topX <= recWidth - 1)
                        points.Add(new PointF(topX, 0));
                }
                else
                {
                    float bottomX = p1.X + (recHeight - 1 - p1.Y) / slope;
                    if (bottomX >= 0 && bottomX <= recWidth - 1)
                        points.Add(new PointF(bottomX, recHeight - 1));
                }
            }
            if (points.Count > 0)
            {
                dstPoint = (PointF)points[0];
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Compute the intersections between line and template boundary rect.
        /// </summary>
        private void GetLineRectIntersections(BackgroundTemplate parent, ref PointF point1, ref PointF point2)
        {
            float recWidth, recHeight;

            PointF p1, p2;
            p1 = this.m_Line.P1;
            p2 = this.m_Line.P2;

            recWidth = parent.Width/this.m_Zoom;
            recHeight = parent.Height/this.m_Zoom;

            ArrayList points = new ArrayList();
            if (p1.X == p2.X)
            {
                point1 = new PointF(p1.X, 0);
                point2 = new PointF(p1.X, recHeight - 1);
                return;
            }
            else if (p1.Y == p2.Y)
            {
                point1 = new PointF(0, p1.Y);
                point2 = new PointF(recWidth - 1, p1.Y);
                return;
            }
            else
            {
                float slope = (p1.Y - p2.Y) / (p1.X - p2.X);

                float leftY = p1.Y - slope * p1.X;
                if (leftY >= 0 && leftY <= recHeight - 1)
                    points.Add(new PointF(0, leftY));

                float rightY = p1.Y + slope * (recWidth - 1 - p1.X);
                if (rightY >= 0 && rightY <= recHeight - 1)
                    points.Add(new PointF(recWidth-1, rightY));

                float topX = p1.X - p1.Y / slope;
                if (topX >= 0 && topX <= recWidth - 1)
                    points.Add(new PointF(topX, 0));

                float bottomX = p1.X + (recHeight - 1 - p1.Y) / slope;
                if (bottomX >= 0 && bottomX <= recWidth - 1)
                    points.Add(new PointF(bottomX, recHeight - 1));
            }
            if (points.Count >= 2)
            {
                point1 = (PointF)points[0];
                point2 = (PointF)points[1];
                if (point2.Equals(point1) && points.Count > 2)
                    point2 = (PointF)points[2];
            }
        }
            public BkgTemplateSelectionGroup(BackgroundPropertiesForm parent, BackgroundTemplate template, Point location, Size size, int tabIndex)
            {
                this.SuspendLayout();

                this.FlatStyle = FlatStyle.System;
                this.Location = location;
                this.Size = size;
                this.TabIndex = tabIndex;
                this.Name = "BkgTemplateSelectionGroup";
                this.TabStop = false;
                this.Text = Strings.BkgChooseTemplate;

                this.m_BkgTemplateSelectionComboBox = new BkgTemplateSelectionComboBox(parent, new Point(20, 20), new Size(180, 30), 0);
                this.Controls.Add(this.m_BkgTemplateSelectionComboBox);

                this.ResumeLayout();
            }
        /// <summary>
        /// Check whether there is a template with the same name in xml file 
        /// </summary>
        /// <param name="name"> the name of the template</param>
        /// <returns>true for exist</returns>
        public bool IsTemplateExist(string name)
        {
            bool result = false;

            StreamReader sr = new StreamReader(this.m_BackgroundTemplateXmlPath);

            XmlDocument doc = new XmlDocument();
            doc.Load(sr);

            //Get all the BackgroundTemplate Nodes, and parse each template node
            XmlNodeList list = doc.GetElementsByTagName("BackgroundTemplate");
            for (int i = 0; i < list.Count; i++)
            {
                BackgroundTemplate template = new BackgroundTemplate();
                XmlNode templateNode = list[i];

                XmlAttribute temp;

                //Get the name of the BackgroundTemplate
                temp = templateNode.Attributes["name"];
                if (name.Equals(temp.Value))
                    result = true;
            }

            sr.Close();
            return result;
        }
Exemplo n.º 21
0
        // NOTE: Eventually this code should be converted to use SlideRenderer instead of each SheetRenderer. There were some issues with doing
        // this initially so for the time being we will keep it like this.
        public static Bitmap DrawSlide(TableOfContentsModel.Entry currentEntry, BackgroundTemplate template, System.Drawing.Color background, SheetDisposition dispositions, int width, int height, float scale )
        {
            // Save the old state
            System.Drawing.Drawing2D.GraphicsState oldState;

            using (Synchronizer.Lock(currentEntry.Slide.SyncRoot)) {
                Rectangle rect;
                int boundsWidth = currentEntry.Slide.Bounds.Width;
                int boundsHeight = currentEntry.Slide.Bounds.Height;
                int exportWidth = width;
                int exportHeight = height;

                if (width > 0 && height > 0) {
                    // Do Nothing
                }
                else if (width > 0) {
                    exportHeight = (int)Math.Round( ( (float)width / (float)boundsWidth ) * (float)boundsHeight );
                }
                else if (height > 0) {
                    exportWidth = (int)Math.Round( ( (float)height / (float)boundsHeight ) * (float)boundsWidth );
                }
                else {
                    exportWidth = boundsWidth;
                    exportHeight = boundsHeight;
                }

                // Scale the size
                exportWidth = (int)Math.Round( exportWidth * scale );
                exportHeight = (int)Math.Round( exportHeight * scale );
                rect = new Rectangle(0, 0, exportWidth, exportHeight);

                //Note: Uses DibGraphicsBuffer from TPC SDK to do antialiasing
                //See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dntablet/html/tbconprintingink.asp
                /// create the bitmap we're exporting to
                Bitmap toExport = new Bitmap(rect.Width, rect.Height);
                /// create what we will be drawing on to the export
                Graphics toSave = Graphics.FromImage(toExport);

                /// draw the slide data on a temporary graphics object in a temporary form
                System.Windows.Forms.Form tempForm = new System.Windows.Forms.Form();
                Graphics screenGraphics = tempForm.CreateGraphics();
                DibGraphicsBuffer dib = new DibGraphicsBuffer();
                Graphics tempGraphics = dib.RequestBuffer(screenGraphics, rect.Width, rect.Height);

                //Add the background color
                //First see if there is a Slide BG, if not, try the Deck.  Otherwise, use transparent.
                tempGraphics.Clear(background);

                //Add the background template
                if (template != null)
                {
                    using (BackgroundTemplateRenderer bkgRender = new BackgroundTemplateRenderer(template))
                    {
                        bkgRender.DrawAll(tempGraphics, rect);
                    }
                }

                //Get the Slide content and draw it
                oldState = tempGraphics.Save();

                Model.Presentation.SlideModel.SheetCollection sheets = currentEntry.Slide.ContentSheets;
                for (int i = 0; i < sheets.Count; i++)
                {
                    Model.Viewer.SlideDisplayModel display = new Model.Viewer.SlideDisplayModel(tempGraphics, null);

                    Rectangle slide = rect;
                    float zoom = 1f;
                    if (currentEntry.Slide != null)
                    {
                        slide = currentEntry.Slide.Bounds;
                        zoom = currentEntry.Slide.Zoom;
                    }

                    System.Drawing.Drawing2D.Matrix pixel, ink;
                    display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink);
                    using (Synchronizer.Lock(display.SyncRoot))
                    {
                        display.SheetDisposition = dispositions;
                        display.Bounds = slide;
                        display.PixelTransform = pixel;
                        display.InkTransform = ink;
                    }

                    Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet(display, sheets[i]);
                    if ((r.Sheet.Disposition & dispositions) != 0)
                        r.Paint(new System.Windows.Forms.PaintEventArgs(tempGraphics, rect));
                    r.Dispose();
                }

                //Restore the Old State
                tempGraphics.Restore(oldState);
                oldState = tempGraphics.Save();

                //Get the Annotation content and draw it
                sheets = currentEntry.Slide.AnnotationSheets;
                for (int i = 0; i < sheets.Count; i++)
                {
                    Model.Viewer.SlideDisplayModel display = new Model.Viewer.SlideDisplayModel(tempGraphics, null);

                    Rectangle slide = rect;
                    float zoom = 1f;
                    if (currentEntry.Slide != null)
                    {
                        slide = currentEntry.Slide.Bounds;
                        zoom = currentEntry.Slide.Zoom;
                    }

                    System.Drawing.Drawing2D.Matrix pixel, ink;
                    display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink);
                    using (Synchronizer.Lock(display.SyncRoot))
                    {
                        display.SheetDisposition = dispositions;
                        display.Bounds = slide;
                        display.PixelTransform = pixel;
                        display.InkTransform = ink;
                    }

                    Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet(display, sheets[i]);
                    if ((r.Sheet.Disposition & dispositions) != 0)
                        r.Paint(new System.Windows.Forms.PaintEventArgs(tempGraphics, rect));
                    r.Dispose();
                }

                //Restore the Old State
                tempGraphics.Restore(oldState);

                //Export the image
                //Merge the graphics
                dib.PaintBuffer(toSave, 0, 0);

                //Dispose all the graphics
                toSave.Dispose();
                screenGraphics.Dispose();
                tempGraphics.Dispose();

                return toExport;
            }
        }
Exemplo n.º 22
0
 public SlideMessage( SlideModel slide, bool localRef )
     : base(slide.Id)
 {
     if( localRef )
         this.AddLocalRef( slide );
     this.LocalId = slide.LocalId;
     using( Synchronizer.Lock( slide.SyncRoot ) ) {
         this.Zoom = slide.Zoom;
         this.Bounds = slide.Bounds;
         this.Title = slide.Title;
         this.SlideBackgroundColor = slide.BackgroundColor;
         this.SlideBackgroundTemplate = slide.BackgroundTemplate;
         this.SubmissionSlideGuid = slide.SubmissionSlideGuid;
         this.SubmissionStyle = slide.SubmissionStyle;
         this.Visited = slide.Visited;
         this.AssociationSlideId = slide.AssociationId;
         if (!this.AssociationSlideId.Equals(Guid.Empty)) {
             AddAssociationExtension(slide);
         }
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Draw the current Primitive
 /// </summary>
 public abstract void Draw(BackgroundTemplate parent, Graphics g, Rectangle r);
Exemplo n.º 24
0
        public BackgroundTemplate Clone()
        {
            BackgroundTemplate bkgTemplate = new BackgroundTemplate();

            bkgTemplate.Name = this.Name;
            bkgTemplate.CNName = this.CNName;
            bkgTemplate.FRName = this.FRName;
            bkgTemplate.ESName = this.ESName;
            bkgTemplate.PTName = this.PTName;
            if (this.BackgroundBrush != null)
            {
                bkgTemplate.BackgroundBrush = (SerializableBrush)this.BackgroundBrush.Clone();
            }
            bkgTemplate.GeometryTransform = this.GeometryTransform;
            bkgTemplate.Height = this.Height;
            bkgTemplate.Width = this.Width;

            for (int i = 0; i < this.PrimitivePens.Count; i++)
                bkgTemplate.PrimitivePens.Add(((SerializablePen)this.PrimitivePens[i]).Clone());

            for (int i = 0; i < this.Geometry.Count; i++)
                bkgTemplate.Geometry.Add(((IBackgroundPrimitive)this.Geometry[i]).Clone());

            return bkgTemplate;
        }