Exemple #1
0
        /// <summary>
        /// This will return real height of balloon considering its static ballon children
        /// </summary>
        /// <returns></returns>
        public float GetFitToContentHeightInPixels()
        {
            float res         = 0;
            float heightToAdd = 0;

            if (this.FitToContent)
            {
                // if it is empty and has no other child balloons then result should be its own Width
                if (this.ChildBalloons == 0)
                {
                    res = this.HeightInPixels;
                }
                else
                {
                    // count child static balloons and width should be the right most one
                    foreach (EditorItem item in this.Children)
                    {
                        if (item is StaticBalloon)
                        {
                            StaticBalloon sb = item as StaticBalloon;

                            // handle docking to get this information
                            if (sb.DockPosition == DockingPosition.DOCK_BOTTOM)
                            {
                                // static docked balloons are just adding additional minimal hight
                                heightToAdd += sb.HeightInPixels;
                            }
                            else
                            {
                                float tmpRes = sb.LocationInPixelsY + sb.GetFitToContentHeightInPixels();
                                if (tmpRes > res)
                                {
                                    res = tmpRes;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // FitToContent is false, so just return HeightInPixels
                res = this.HeightInPixels;
            }

            return(res + heightToAdd);
        }
Exemple #2
0
        public override void Load(System.Xml.XmlNode element)
        {
            base.Load(element);

            UnitsManager unitMng = new UnitsManager();

            // Load info
            XmlNode node = element.SelectSingleNode("Info");
            if (node != null)
            {
                this.Description = node.Attributes["Description"].Value;
            }

            // Load page size
            node = element.SelectSingleNode("Size");
            if (node != null)
            {
                MeasureUnit = unitMng.StringToUnit(node.Attributes["Width"].Value);
                WidthInUnits = (float)(System.Convert.ToDouble(node.Attributes["Width"].Value.TrimEnd(unitMng.UnitToString(MeasureUnit).ToCharArray())));
                HeightInUnits = (float)(System.Convert.ToDouble(node.Attributes["Height"].Value.TrimEnd(unitMng.UnitToString(MeasureUnit).ToCharArray())));
            }
            else
            {
                // set default sizes
                MeasureUnit = MeasureUnits.cm;
                WidthInUnits = (float)unitMng.ConvertUnit(19, MeasureUnits.cm, MeasureUnits.point);
                HeightInPixels = (float)unitMng.ConvertUnit(21, MeasureUnits.cm, MeasureUnits.point);
            }

            // Load fill color
            node = element.SelectSingleNode("FillColor");
            if (node != null)
            {
                try
                {
                    int r = Convert.ToInt32(node.Attributes["R"].Value);
                    int g = Convert.ToInt32(node.Attributes["G"].Value);
                    int b = Convert.ToInt32(node.Attributes["B"].Value);
                    int a = Convert.ToInt32(node.Attributes["A"].Value);
                    this.FillColor = Color.FromArgb(a, r, g, b);
                }
                catch { }
            }

            // Load BackgroundImageName
            node = element.SelectSingleNode("BackgroundImage");
            if (node != null)
            {
                this.imageName = node.Attributes["Name"].Value;
            }

            // load embedded image if available
            node = element.SelectSingleNode("EmbeddedImage");
            if (node != null)
            {
                if (node.InnerText != null && node.InnerText.Length > 0)
                {
                    this.imageData = Convert.FromBase64String(node.InnerText);
                    pictureForDisplay = Bitmap.FromStream(new MemoryStream(this.imageData));
                }
            }

            // Load none balloons items
            node = element.SelectSingleNode("Items");
            if(node != null)
            {
                foreach(XmlNode childNode in node.ChildNodes)
                {
                    if(childNode.Name == "Item")
                    {
                        // this is not valid for generator but this can be loaded into editor
                        string itemType = childNode.Attributes["Type"].Value;
                        EditorItem newItem = ReportPage.CreateItemFromType(itemType);
                        newItem.Load(childNode);
                        newItem.Parent = this;
                        //Children.Add(newItem);
                    }
                }
            }

            // Load balloons
            node = element.SelectSingleNode("Balloons");
            if (node != null)
            {
                foreach(XmlNode balloonNode in node.ChildNodes)
                {
                    if (balloonNode.Name == "Balloon")
                    {
                        string tmpType;
                        tmpType = balloonNode.Attributes["Type"].Value;
                        if (tmpType == "Static")
                        {
                            StaticBalloon child = new StaticBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                        else if (tmpType == "Dynamic")
                        {
                            DynamicBalloon child = new DynamicBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                    }
                    else if (balloonNode.Name == "Item")
                    {
                        // this is not valid for generator but this can be loaded into editor
                        string itemType = balloonNode.Attributes["Type"].Value;
                        EditorItem newItem = ReportPage.CreateItemFromType(itemType);
                        newItem.Load(balloonNode);
                        newItem.Parent = this;
                        //Children.Add(newItem);
                    }
                }
            }
        }
Exemple #3
0
        public override void Load(System.Xml.XmlNode element)
        {
            base.Load(element);

            UnitsManager unitMng = new UnitsManager();

            // Load info
            XmlNode node = element.SelectSingleNode("Info");

            if (node != null)
            {
                this.Description = node.Attributes["Description"].Value;
            }

            // Load page size
            node = element.SelectSingleNode("Size");
            if (node != null)
            {
                MeasureUnit   = unitMng.StringToUnit(node.Attributes["Width"].Value);
                WidthInUnits  = (float)(System.Convert.ToDouble(node.Attributes["Width"].Value.TrimEnd(unitMng.UnitToString(MeasureUnit).ToCharArray())));
                HeightInUnits = (float)(System.Convert.ToDouble(node.Attributes["Height"].Value.TrimEnd(unitMng.UnitToString(MeasureUnit).ToCharArray())));
            }
            else
            {
                // set default sizes
                MeasureUnit    = MeasureUnits.cm;
                WidthInUnits   = (float)unitMng.ConvertUnit(19, MeasureUnits.cm, MeasureUnits.point);
                HeightInPixels = (float)unitMng.ConvertUnit(21, MeasureUnits.cm, MeasureUnits.point);
            }

            // Load fill color
            node = element.SelectSingleNode("FillColor");
            if (node != null)
            {
                try
                {
                    int r = Convert.ToInt32(node.Attributes["R"].Value);
                    int g = Convert.ToInt32(node.Attributes["G"].Value);
                    int b = Convert.ToInt32(node.Attributes["B"].Value);
                    int a = Convert.ToInt32(node.Attributes["A"].Value);
                    this.FillColor = Color.FromArgb(a, r, g, b);
                }
                catch { }
            }

            // Load BackgroundImageName
            node = element.SelectSingleNode("BackgroundImage");
            if (node != null)
            {
                this.imageName = node.Attributes["Name"].Value;
            }

            // load embedded image if available
            node = element.SelectSingleNode("EmbeddedImage");
            if (node != null)
            {
                if (node.InnerText != null && node.InnerText.Length > 0)
                {
                    this.imageData    = Convert.FromBase64String(node.InnerText);
                    pictureForDisplay = Bitmap.FromStream(new MemoryStream(this.imageData));
                }
            }



            // Load none balloons items
            node = element.SelectSingleNode("Items");
            if (node != null)
            {
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if (childNode.Name == "Item")
                    {
                        // this is not valid for generator but this can be loaded into editor
                        string     itemType = childNode.Attributes["Type"].Value;
                        EditorItem newItem  = ReportPage.CreateItemFromType(itemType);
                        newItem.Load(childNode);
                        newItem.Parent = this;
                        //Children.Add(newItem);
                    }
                }
            }


            // Load balloons
            node = element.SelectSingleNode("Balloons");
            if (node != null)
            {
                foreach (XmlNode balloonNode in node.ChildNodes)
                {
                    if (balloonNode.Name == "Balloon")
                    {
                        string tmpType;
                        tmpType = balloonNode.Attributes["Type"].Value;
                        if (tmpType == "Static")
                        {
                            StaticBalloon child = new StaticBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                        else if (tmpType == "Dynamic")
                        {
                            DynamicBalloon child = new DynamicBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                    }
                    else if (balloonNode.Name == "Item")
                    {
                        // this is not valid for generator but this can be loaded into editor
                        string     itemType = balloonNode.Attributes["Type"].Value;
                        EditorItem newItem  = ReportPage.CreateItemFromType(itemType);
                        newItem.Load(balloonNode);
                        newItem.Parent = this;
                        //Children.Add(newItem);
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Load balloon properties
        /// </summary>
        /// <param name="txR"></param>
        public override void Load(System.Xml.XmlNode element)
        {
            base.Load(element);

            XmlAttribute attr = (XmlAttribute)element.Attributes.GetNamedItem("DataStream");

            if (attr != null)
            {
                this.SourceDataStream = attr.Value;
            }

            XmlNode node = element.SelectSingleNode("AvailableOnEveryPage");

            if (node != null)
            {
                this.AvailableOnEveryPage = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("FitToContent");
            if (node != null)
            {
                this.FitToContent = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("FillingGeneratesNew");
            if (node != null)
            {
                this.FillingGeneratesNew = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("FillCapacity");
            if (node != null)
            {
                this.FillCapacity = Convert.ToInt32(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("CanGrow");
            if (node != null)
            {
                this.CanGrow = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            // Load fill color
            node = element.SelectSingleNode("FillColor");
            if (node != null)
            {
                try
                {
                    int r = Convert.ToInt32(node.Attributes["R"].Value);
                    int g = Convert.ToInt32(node.Attributes["G"].Value);
                    int b = Convert.ToInt32(node.Attributes["B"].Value);
                    int a = Convert.ToInt32(node.Attributes["A"].Value);
                    this.FillColor = Color.FromArgb(a, r, g, b);
                }
                catch { }
            }

            this.Borders.top.Load(element);
            this.Borders.left.Load(element);
            this.Borders.bottom.Load(element);
            this.Borders.right.Load(element);

            // EditorController.Instance.MainFormOfTheProject.AddNewEditorItemToList(this);


            // Load items
            node = element.SelectSingleNode("Items");
            if (node != null)
            {
                foreach (XmlNode itemNode in node.ChildNodes)
                {
                    if (itemNode.Name == "Item")
                    {
                        LoadItem(itemNode);
                    }
                }
            }


            // Load other child balloons
            node = element.SelectSingleNode("Balloons");
            if (node != null)
            {
                foreach (XmlNode balloonNode in node.ChildNodes)
                {
                    if (balloonNode.Name == "Balloon")
                    {
                        string tmpType;
                        tmpType = balloonNode.Attributes["Type"].Value;
                        if (tmpType == "Static")
                        {
                            StaticBalloon child = new StaticBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                        else if (tmpType == "Dynamic")
                        {
                            DynamicBalloon child = new DynamicBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Load balloon properties
        /// </summary>
        /// <param name="txR"></param>
        public override void Load(System.Xml.XmlNode element)
        {
            base.Load(element);

            XmlAttribute attr = (XmlAttribute)element.Attributes.GetNamedItem("DataStream");
            if (attr != null)
            {
                this.SourceDataStream = attr.Value;
            }

            XmlNode node = element.SelectSingleNode("AvailableOnEveryPage");
            if (node != null)
            {
                this.AvailableOnEveryPage = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("FitToContent");
            if (node != null)
            {
                this.FitToContent = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("FillingGeneratesNew");
            if (node != null)
            {
                this.FillingGeneratesNew = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("FillCapacity");
            if (node != null)
            {
                this.FillCapacity = Convert.ToInt32(node.Attributes["Value"].Value);
            }

            node = element.SelectSingleNode("CanGrow");
            if (node != null)
            {
                this.CanGrow = Convert.ToBoolean(node.Attributes["Value"].Value);
            }

            // Load fill color
            node = element.SelectSingleNode("FillColor");
            if (node != null)
            {
                try
                {
                    int r = Convert.ToInt32(node.Attributes["R"].Value);
                    int g = Convert.ToInt32(node.Attributes["G"].Value);
                    int b = Convert.ToInt32(node.Attributes["B"].Value);
                    int a = Convert.ToInt32(node.Attributes["A"].Value);
                    this.FillColor = Color.FromArgb(a, r, g, b);
                }
                catch { }
            }

            this.Borders.top.Load(element);
            this.Borders.left.Load(element);
            this.Borders.bottom.Load(element);
            this.Borders.right.Load(element);

               // EditorController.Instance.MainFormOfTheProject.AddNewEditorItemToList(this);

            // Load items
            node = element.SelectSingleNode("Items");
            if (node != null)
            {
                foreach(XmlNode itemNode in node.ChildNodes)
                {
                    if (itemNode.Name == "Item")
                    {
                        LoadItem(itemNode);
                    }
                }
            }

            // Load other child balloons
            node = element.SelectSingleNode("Balloons");
            if (node != null)
            {
                foreach(XmlNode balloonNode in node.ChildNodes)
                {
                    if (balloonNode.Name == "Balloon")
                    {
                        string tmpType;
                        tmpType = balloonNode.Attributes["Type"].Value;
                        if (tmpType == "Static")
                        {
                            StaticBalloon child = new StaticBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                        else if (tmpType == "Dynamic")
                        {
                            DynamicBalloon child = new DynamicBalloon();
                            //child.Parent = this;
                            child.Load(balloonNode);
                            child.Parent = this;
                            //Children.Add(child);
                        }
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// This will create new Balloon object based from Balloon information. 
        /// </summary>
        /// <param name="balloon">Original from what new should be created</param>
        /// <param name="page">Current page</param>
        /// <param name="parentBalloon">parent balloon that is generated</param>
        /// <param name="isStatic">If new balloon should be created as StaticBalloon</param>
        /// <param name="level">level of recursion, for logging purposes</param>
        /// <returns></returns>
        Balloon CreateNewBalloon(Balloon balloon, ReportPage page, Balloon parentBalloon, bool isStatic)
        {
            if (isStatic)
            {
                StaticBalloon newStaticBalloon = new StaticBalloon();
                newStaticBalloon.TemplateBalloon = balloon;
                newStaticBalloon.LocationInUnitsX = balloon.LocationInUnitsX;
                newStaticBalloon.LocationInUnitsY = balloon.LocationInUnitsY;

                newStaticBalloon.WidthInPixels = balloon.GetFitToContentWidthInPixels();
                newStaticBalloon.HeightInPixels = balloon.GetFitToContentHeightInPixels();

                newStaticBalloon.zoomLevel = balloon.zoomLevel;
                newStaticBalloon.sourceBallon = balloon;
                newStaticBalloon.Disabled = true;
                newStaticBalloon.CanGrow = balloon.DockPosition == EditorItem.DockingPosition.DOCK_BOTTOM ? false : balloon.CanGrow;
                newStaticBalloon.Borders = balloon.Borders;
                newStaticBalloon.FillCapacity = balloon.FillCapacity;
                newStaticBalloon.AvailableOnEveryPage = balloon.AvailableOnEveryPage;
                newStaticBalloon.FillingGeneratesNew = balloon.FillingGeneratesNew;
                newStaticBalloon.FitToContent = balloon.FitToContent;
                newStaticBalloon.FillColor = balloon.FillColor;
                newStaticBalloon.MeasureUnit = balloon.MeasureUnit;

                float relLocationX = balloon.LocationInPixelsX; //unitConverter.ConvertUnit(balloon.LocationInUnitsX, balloon.MeasureUnit, MeasureUnits.point);
                float relLocationY = balloon.LocationInPixelsY; //unitConverter.ConvertUnit(balloon.LocationInUnitsY, balloon.MeasureUnit, MeasureUnits.point);
                float width = balloon.GetFitToContentWidthInPixels();
                float height = balloon.GetFitToContentHeightInPixels();

                newStaticBalloon.containerRect.left = relLocationX;
                newStaticBalloon.containerRect.bottom = relLocationY + height;
                newStaticBalloon.containerRect.right = relLocationX + width;
                newStaticBalloon.containerRect.top = relLocationY;
                newStaticBalloon.positionRect.top = relLocationY;
                newStaticBalloon.positionRect.left = relLocationX;
                return newStaticBalloon;
            }
            else
            {
                DynamicBalloon newDynamicBalloon = new DynamicBalloon();
                newDynamicBalloon.FillColor = balloon.FillColor;
                newDynamicBalloon.TemplateBalloon = balloon;
                newDynamicBalloon.LocationInUnitsX = balloon.LocationInUnitsX;
                newDynamicBalloon.LocationInUnitsY = balloon.LocationInUnitsY;
                newDynamicBalloon.zoomLevel = balloon.zoomLevel;
                newDynamicBalloon.sourceBallon = balloon;
                newDynamicBalloon.Disabled = true;
                newDynamicBalloon.FitToContent = balloon.FitToContent;
                newDynamicBalloon.CanGrow = balloon.CanGrow;
                newDynamicBalloon.Borders = balloon.Borders;
                newDynamicBalloon.FillCapacity = balloon.FillCapacity;
                newDynamicBalloon.AvailableOnEveryPage = balloon.AvailableOnEveryPage;
                newDynamicBalloon.FillingGeneratesNew = balloon.FillingGeneratesNew;
                newDynamicBalloon.MeasureUnit = balloon.MeasureUnit;

                newDynamicBalloon.WidthInPixels = balloon.GetFitToContentWidthInPixels();
                newDynamicBalloon.HeightInPixels = balloon.GetFitToContentHeightInPixels();
                newDynamicBalloon.positionRect.top = balloon.LocationInPixelsY;
                newDynamicBalloon.positionRect.left = balloon.LocationInPixelsX;
                return newDynamicBalloon;
            }
            return null;
        }