示例#1
0
                public BoundingBox2 AppendTextBlock(TextBlock monBlock)
                {
                    MonitorOption opt;

                    SpriteBuilder mk = new SpriteBuilder(Surface, Cursor, Scale, FrameCount)
                    {
                        Color = Color, BGColor = BGColor
                    };
                    BoxStyle style = new BoxStyle();

                    if (monBlock.Options.TryGetValue("scale", out opt))
                    {
                        mk.Scale = opt.FloatValue;
                    }
                    if (monBlock.Options.TryGetValue("padding", out opt))
                    {
                        style.Padding = opt.FloatValue;
                    }
                    if (monBlock.Options.TryGetValue("color", out opt))
                    {
                        mk.Color = opt.ColorValue;
                    }
                    if (monBlock.Options.TryGetValue("bgcolor", out opt))
                    {
                        mk.BGColor = opt.ColorValue;
                    }

                    mk.TextBox(style, monBlock.Text);
                    Sprites.AddRange(mk.Sprites);

                    Cursor.Y += mk.Box.Height;
                    return(mk.Box);
                }
        private static void DoDrawText(Vector3 position, object text, Color color, Camera camera)
        {
            if (!WorldToGUIPoint(position, out Vector2 screenPos, camera))
            {
                return;
            }
            //------DRAW-------
            string value;

            switch (text)
            {
            case Vector3 vector3:
                value = vector3.ToString("F3");
                break;

            case Vector2 vector2:
                value = vector2.ToString("F3");
                break;

            default:
                value = text.ToString();
                break;
            }

            var  content = new GUIContent(value);
            Rect rect    = new Rect(screenPos, BoxStyle.CalcSize(content));

            DrawGUIRect(rect, color);
            GUI.Label(rect, content, EditorStyles.boldLabel);
            //-----------------
        }
示例#3
0
            public void EmptyBox(BoxStyle style)
            {
                Vector2      size = style.Size * Scale;
                BoundingBox2 box  = new BoundingBox2(Cursor, Cursor + size);

                MoveCursor(box.Width);
                MergeBox(box);
            }
示例#4
0
        public Box(float top, float left, BoxStyle style)
            : base(top, left)
        {
            got = 0;
            canGet = 1;
            canGetNext = DateTime.Now;

            Style = style;
        }
示例#5
0
        public Manager(GameState state)
        {
            Manager.GameState = state;
            originalTimeScale = 1;
            Time.timeScale    = originalTimeScale;
            styles            = GameObject.FindGameObjectWithTag("Manager").GetComponent <BoxStyle>();

            UserProfile.ID = UserProfile.ID == UserProfile.GuestID ? Guid.NewGuid().ToString(): UserProfile.ID;
        }
示例#6
0
        /// <summary>Computes the box for the given element now.</summary>
        public BoxStyle Compute(Css.Value value, Css.Value style, RenderableData context)
        {
            // Result:
            BoxStyle result = new BoxStyle();

            if (value == null || style == null)
            {
                return(result);
            }

            // Top:
            result.Top = value[0].GetDecimal(context, Top);

            // Right:
            result.Right = value[1].GetDecimal(context, Right);

            // Bottom:
            result.Bottom = value[2].GetDecimal(context, Bottom);

            // Left:
            result.Left = value[3].GetDecimal(context, Left);

            // Account for style, dropping widths to 0 when 'none':
            for (int i = 0; i < 4; i++)
            {
                // If null or 'none'..
                if (style[i].IsType(typeof(Css.Keywords.None)))
                {
                    // Clear it:
                    result[i] = 0f;
                }
            }

            // Negative values aren't allowed - enforce that now:
            if (result.Top < 0f)
            {
                result.Top = 0f;
            }

            if (result.Right < 0f)
            {
                result.Right = 0f;
            }

            if (result.Bottom < 0f)
            {
                result.Bottom = 0f;
            }

            if (result.Left < 0f)
            {
                result.Left = 0f;
            }

            return(result);
        }
示例#7
0
            public void SpriteBox(BoxStyle style, string spriteId)
            {
                BoundingBox2 box = new BoundingBox2(Cursor, Cursor + style.Size * Scale);

                if (Sprites != null)
                {
                    Sprites.Add(new MySprite(SpriteType.TEXTURE, spriteId, box.Center, style.InnerSize * Scale, Color));
                }

                MoveCursor(box.Width);
                MergeBox(box);
            }
示例#8
0
                // ----
                public BoundingBox2 AppendBlockIcon(SpriteBuilder maker, BoxStyle style, IMonitorBlock monitorBlock, MonitorInfo info)
                {
                    BoundingBox2  box = new BoundingBox2(Cursor, Cursor);
                    SpriteBuilder sb  = new SpriteBuilder(maker);

                    InfoItem item; if (info.TryGetValue("block", out item))

                    {
                        CommonInfo commonInfo = item as CommonInfo;
                        string     icon       = "";

                        if (commonInfo.IsBeingHacked)
                        {
                            if ((FrameCount % 1.0f) < 0.5f)
                            {
                                icon = SpriteId.Danger;
                            }
                            else
                            {
                                icon = SpriteId.Cross;
                            }
                        }
                        else if (!commonInfo.IsFunctional)
                        {
                            icon = SpriteId.Cross;
                        }
                        //else if (!info.BlockInfo.IsEnabled)
                        //    icon = SpriteId.Construction;
                        else if (!commonInfo.IsWorking)
                        {
                            icon = SpriteId.Danger;
                        }

                        if (icon != "")
                        {
                            sb.SpriteBox(style, icon);
                            //box = maker.SpriteBox(Sprites, style, icon);
                        }
                        else
                        {
                            SpriteDataBuilder sdb; if (IconRes.TryGetValue(commonInfo.Icon, out sdb))
                            {
                                sb.SpriteDataBox(style, sdb);
                            }
                            //box = maker.SpriteDataBox(Sprites, style, sdb);
                        }
                    }

                    Cursor.X += sb.Box.Width;
                    //Cursor.X += box.Width;
                    Sprites.AddRange(sb.Sprites);
                    return(sb.Box);
                }
示例#9
0
            public void TextBox(BoxStyle style, string text)
            {
                if (style.SizeRule == SizeRule.Auto)
                {
                    style = new BoxStyle(style)
                    {
                        Size = CalcStringSize(text, FontId, FontScale)
                    };
                }

                Vector2       size  = style.Size * Scale;
                TextAlignment align = style.Align;
                MySprite      sprite;
                BoundingBox2  box       = new BoundingBox2(Cursor, Cursor + size);
                Vector2       innerSize = style.InnerSize * Scale;

                float textScale;

                if (size.Y != 0)
                {
                    textScale = innerSize.Y / size.Y;
                }
                else
                {
                    textScale = 0;
                }

                Vector2 textPos = new Vector2(box.Center.X, box.Center.Y - innerSize.Y / 2.0f);

                if (align == TextAlignment.LEFT)
                {
                    textPos.X -= innerSize.X / 2.0f;
                }
                else if (align == TextAlignment.RIGHT)
                {
                    textPos.X += innerSize.X / 2.0f;
                }

                if (Sprites != null)
                {
                    //sprite = MySprite.CreateSprite(SpriteId.SquareSimple, box.Center, box.Size);
                    //sprite.Color = BGColor;
                    //Sprites.Add(sprite);

                    sprite          = MySprite.CreateText(text, FontId, Color, textScale * FontScale * Scale, align);
                    sprite.Position = textPos;
                    Sprites.Add(sprite);
                }

                MoveCursor(box.Width);
                MergeBox(box);
            }
示例#10
0
文件: Box.cs 项目: saint11/oldskull
        public Box(Box Father, BoxStyle Style)
            : base(false)
        {
            this.Father = Father;
            if (Father == null)
            {
                _Width = Engine.Instance.Screen.Width;
                _Height = Engine.Instance.Screen.Height;
            }

            this.Style = Style;
            Children = new List<GraphicsComponent>();
        }
示例#11
0
            public void SpriteDataBox(BoxStyle style, SpriteDataBuilder data)
            {
                Vector2      size = style.Size * Scale;
                BoundingBox2 box  = new BoundingBox2(Cursor, Cursor + size);

                if (Sprites != null)
                {
                    data.BuildSprites(Sprites, box.Center, style.InnerSize * Scale, FrameCount, Color, BGColor);
                }

                MoveCursor(box.Width);
                MergeBox(box);
            }
示例#12
0
文件: padding.cs 项目: ru-ace/spark
        /// <summary>Computes the box for the given element now.</summary>
        public BoxStyle Compute(Css.Value value, RenderableData context, int display)
        {
            // Result:
            BoxStyle result = new BoxStyle();

            if (value == null)
            {
                return(result);
            }

            // Using a display mode that doesn't allow padding?
            if ((display & NoPaddingAllowed) != 0)
            {
                return(result);
            }

            // Top:
            result.Top = value[0].GetDecimal(context, Top);

            // Right:
            result.Right = value[1].GetDecimal(context, Right);

            // Bottom:
            result.Bottom = value[2].GetDecimal(context, Bottom);

            // Left:
            result.Left = value[3].GetDecimal(context, Left);

            // Negative values aren't allowed - enforce that now:
            if (result.Top < 0f)
            {
                result.Top = 0f;
            }

            if (result.Right < 0f)
            {
                result.Right = 0f;
            }

            if (result.Bottom < 0f)
            {
                result.Bottom = 0f;
            }

            if (result.Left < 0f)
            {
                result.Left = 0f;
            }

            return(result);
        }
示例#13
0
        internal TackConsole()
        {
            // Set the static instance
            ActiveInstance = this;

            m_logPath = string.Format("logs/log_{0}_{1}_{2}.txt", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);

            if (!Directory.Exists(Directory.GetCurrentDirectory() + "/logs"))
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/logs");
            }

            mInputFieldStyle = new InputFieldStyle();
            mInputFieldStyle.BackgroundColour  = new Colour4b(100, 100, 100, 190);
            mInputFieldStyle.FontColour        = new Colour4b(0, 0, 0, 255);
            mInputFieldStyle.SpriteTexture     = Sprite.DefaultSprite;
            mInputFieldStyle.FontSize          = 10f;
            mInputFieldStyle.VerticalAlignment = VerticalAlignment.Middle;
            mInputFieldStyle.FontFamilyId      = 0; //TackGUI.LoadFontFromFile(Environment.GetFolderPath(Environment.SpecialFolder.Fonts) + "\\cour.ttf");
            mInputFieldStyle.Scrollable        = false;

            mActivationKey = KeyboardKey.Tilde;

            mConsoleUIStyle = new TextAreaStyle()
            {
                BackgroundColour  = new Colour4b(0, 0, 0, 190),
                FontColour        = new Colour4b(0, 255, 0, 255),
                FontFamilyId      = TackGUI.GetFontFamilyId("Courier New"),
                FontSize          = 10f,
                VerticalAlignment = VerticalAlignment.Top,
                ScrollPosition    = 0,
                Scrollable        = true
            };

            mCaretBoxStyle = new BoxStyle()
            {
                Colour = new Colour4b(255, 0, 0, 255),
            };

            mConsoleInputField = null;
            mConsoleTextArea   = null;
            mConsoleGUIActive  = true;
        }
示例#14
0
 public void Render(SpriteBuilder sb, BoxStyle style, MonitorContent content, T info)
 {
     if ((info is ValueInfoBase) && (content.Subtype == "bar"))
     {
         sb.HorizonalBarBox(style, (info as ValueInfoBase).Ratio, (content.IntValue > 0) ? content.IntValue : 8);
     }
     else
     {
         string text = info.ToText(content);
         if (text.Length > 0)
         {
             sb.TextBox(style, text);
         }
         else
         {
             sb.EmptyBox(style);
         }
     }
 }
示例#15
0
        public Menu(int row            = 0, int column = 0, string _title = "",
                    BoxStyle menuStyle = BoxStyle.FullSize, Alignment _alignment = Alignment.Free,
                    int width          = 0)
        {
            alignment   = _alignment;
            firstRow    = row;
            style       = menuStyle;
            columnStart = column;
            if (alignment == Alignment.Centered)
            {
                columnStart = (Console.LargestWindowWidth - width) / 2;
            }

            columnWidth = width;
            if (_title != "")
            {
                title    = _title;
                hasTitle = true;
            }
        }
            public bool TryRender(SpriteBuilder sb, BoxStyle style, MonitorContent content, MonitorInfo info)
            {
                Func <IContentRenderer> provider; if (TryGetValue(content.Type, out provider))

                {
                    IContentRenderer renderer = provider();
                    if (renderer is IInfoContentRenderer)
                    {
                        InfoItem item; if (info.TryGetValue(content.Type, out item))
                        {
                            (renderer as IInfoContentRenderer).Render(sb, style, content, item); return(true);
                        }
                    }
                    else
                    {
                        renderer.Render(sb, style, content); return(true);
                    }
                }
                return(false);
            }
示例#17
0
文件: scroll.cs 项目: ru-ace/spark
        /// <summary>Computes the box for the given context now.</summary>
        public BoxStyle Compute(Css.Value value, RenderableData context)
        {
            BoxStyle box = new BoxStyle();

            if (value != null)
            {
                Css.Value a = value[0];

                if (a != null)
                {
                    box.Top = a.GetDecimal(context, Top);
                }

                a = value[1];

                if (a != null)
                {
                    box.Left = a.GetDecimal(context, Left);
                }
            }

            return(box);
        }
示例#18
0
        /// <summary>
        /// Gets Flowchart.NET box's style
        /// </summary>
        /// <param name="newBox">Box reference</param>
        /// <returns>Returned BoxStyle</returns>
        private BoxStyle GetBoxStyle(MindFusion.FlowChartX.Box newBox)
        {
            BoxStyle retStyle = BoxStyle.Shape;

            if (newBox.Shape == null)
            {
                return(newBox.Style);
            }

            if (newBox.Style != BoxStyle.Shape)
            {
                return(newBox.Style);
            }

            switch (newBox.Shape.ToString())
            {
            case "Rectangle":
                retStyle = BoxStyle.Rectangle;
                break;

            case "Ellipse":
                retStyle = BoxStyle.Ellipse;
                break;

            case "RoundRect":
                retStyle = BoxStyle.RoundedRectangle;
                break;

            default:
                retStyle = newBox.Style;
                break;
            }
            ;

            return(retStyle);
        }
示例#19
0
 public Menu(int row, int column, int maxShown, string _title = "",
             BoxStyle menuStyle = BoxStyle.FullSize, Alignment _alignment = Alignment.Free,
             int width          = 0)
 {
     alignment     = _alignment;
     scrollable    = true;
     top           = 0;
     this.maxShown = maxShown;
     end           = maxShown - 1;
     maxHeight     = maxShown;
     firstRow      = row;
     style         = menuStyle;
     columnStart   = column;
     if (alignment == Alignment.Centered)
     {
         columnStart = (Console.LargestWindowWidth - width) / 2;
     }
     columnWidth = width;
     if (_title != "")
     {
         title    = _title;
         hasTitle = true;
     }
 }
示例#20
0
        private static char GetCharForStyle(BoxStyle style, BoxFramePart part)
        {
            switch (style)
            {
            case BoxStyle.Stars:
                return('*');

            case BoxStyle.Dots:
                return('.');

            case BoxStyle.Eqls:
                return('=');

            case BoxStyle.Lines:
                switch (part)
                {
                case BoxFramePart.NWCorner:
                case BoxFramePart.NECorner:
                case BoxFramePart.SWCorner:
                case BoxFramePart.SECorner:
                    return('+');

                case BoxFramePart.Horizontal:
                    return('-');

                case BoxFramePart.Vertical:
                    return('|');

                default:
                    throw new ArgumentOutOfRangeException(nameof(part));
                }

            default:
                throw new ArgumentOutOfRangeException(nameof(style));
            }
        }
示例#21
0
 public UISkinInfo Button(BoxStyle style)
 {
     _button = style;
     return(this);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckBoxField" /> class.
 /// </summary>
 /// <param name="Links">Link to the document.</param>
 /// <param name="PartialName">Field name.</param>
 /// <param name="FullName">Full Field name.</param>
 /// <param name="Rect">Field rectangle.</param>
 /// <param name="Value">Field value.</param>
 /// <param name="PageIndex">Page index. (required)</param>
 /// <param name="Height">Gets or sets height of the field.</param>
 /// <param name="Width">Gets or sets width of the field.</param>
 /// <param name="ZIndex">Z index.</param>
 /// <param name="IsGroup">Is group.</param>
 /// <param name="Parent">Gets field parent.</param>
 /// <param name="IsSharedField">Property for Generator support. Used when field is added to header or footer. If true, this field will created once and it&#39;s appearance will be visible on all pages of the document. If false, separated field will be created for every document page.</param>
 /// <param name="Flags">Gets Flags of the field.</param>
 /// <param name="Color">Color of the annotation.</param>
 /// <param name="Contents">Get the field content.</param>
 /// <param name="Margin">Gets or sets a outer margin for paragraph (for pdf generation)</param>
 /// <param name="Highlighting">Field highlighting mode.</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the field.</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the field.</param>
 /// <param name="Border">Gets or sets annotation border characteristics.</param>
 /// <param name="AllowedStates">Returns list of allowed states.</param>
 /// <param name="Style">Gets or sets style of check box.</param>
 /// <param name="ActiveState">Gets or sets current annotation appearance state.</param>
 /// <param name="_Checked">Gets or sets state of check box. (required)</param>
 /// <param name="ExportValue">Gets or sets export value of CheckBox field.</param>
 public CheckBoxField(List <Link> Links = default(List <Link>), string PartialName = default(string), string FullName = default(string), Rectangle Rect = default(Rectangle), string Value = default(string), int?PageIndex = default(int?), double?Height = default(double?), double?Width = default(double?), int?ZIndex = default(int?), bool?IsGroup = default(bool?), FormField Parent = default(FormField), bool?IsSharedField = default(bool?), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), Color Color = default(Color), string Contents = default(string), MarginInfo Margin = default(MarginInfo), LinkHighlightingMode Highlighting = default(LinkHighlightingMode), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), Border Border = default(Border), List <string> AllowedStates = default(List <string>), BoxStyle Style = default(BoxStyle), string ActiveState = default(string), bool?_Checked = default(bool?), string ExportValue = default(string))
 {
     // to ensure "PageIndex" is required (not null)
     if (PageIndex == null)
     {
         throw new InvalidDataException("PageIndex is a required property for CheckBoxField and cannot be null");
     }
     else
     {
         this.PageIndex = PageIndex;
     }
     // to ensure "_Checked" is required (not null)
     if (_Checked == null)
     {
         throw new InvalidDataException("_Checked is a required property for CheckBoxField and cannot be null");
     }
     else
     {
         this._Checked = _Checked;
     }
     this.Links               = Links;
     this.PartialName         = PartialName;
     this.FullName            = FullName;
     this.Rect                = Rect;
     this.Value               = Value;
     this.Height              = Height;
     this.Width               = Width;
     this.ZIndex              = ZIndex;
     this.IsGroup             = IsGroup;
     this.Parent              = Parent;
     this.IsSharedField       = IsSharedField;
     this.Flags               = Flags;
     this.Color               = Color;
     this.Contents            = Contents;
     this.Margin              = Margin;
     this.Highlighting        = Highlighting;
     this.HorizontalAlignment = HorizontalAlignment;
     this.VerticalAlignment   = VerticalAlignment;
     this.Border              = Border;
     this.AllowedStates       = AllowedStates;
     this.Style               = Style;
     this.ActiveState         = ActiveState;
     this.ExportValue         = ExportValue;
 }
示例#23
0
			public virtual void loadFrom(BinaryReader reader, PersistContext ctx)
			{
				backColor = ctx.loadColor();
				behavior = (BehaviorType)reader.ReadInt32();
				arrowHead = (ArrowHead)reader.ReadInt32();
				arrowBase = (ArrowHead)reader.ReadInt32();
				arrowInterm = (ArrowHead)reader.ReadInt32();
				arrowHeadSize = (float)reader.ReadDouble();
				arrowBaseSize = (float)reader.ReadDouble();
				arrowIntermSize = (float)reader.ReadDouble();
				shadowsStyle = (ShadowsStyle)reader.ReadInt32();
				boxFillColor = ctx.loadColor();
				arrowFillColor = ctx.loadColor();
				boxFrameColor = ctx.loadColor();
				arrowColor = ctx.loadColor();
				alignToGrid = reader.ReadBoolean();
				showGrid = reader.ReadBoolean();
				gridColor = ctx.loadColor();
				gridSize = (float)reader.ReadDouble();
				boxStyle = (BoxStyle)reader.ReadInt32();
				shadowColor = ctx.loadColor();
				imagePos = (ImageAlign)reader.ReadInt32();
				textColor = ctx.loadColor();
				activeMnpColor = ctx.loadColor();
				selMnpColor = ctx.loadColor();
				disabledMnpColor = ctx.loadColor();
				arrowStyle = (ArrowStyle)reader.ReadInt32();
				arrowSegments = reader.ReadInt16();
				scrollX = (float)reader.ReadDouble();
				scrollY = (float)reader.ReadDouble();

				// zoomFactor was a short, now it is a float
				if (ctx.FileVersion < 19)
					zoomFactor = reader.ReadInt16();
				else
					zoomFactor = reader.ReadSingle();

				penDashStyle = (DashStyle)reader.ReadInt32();
				penWidth = (float)reader.ReadDouble();
				int c = reader.ReadInt32();
				defPolyShape = reader.ReadBytes(c);
				docExtents = ctx.loadRectF();
				shadowOffsetX = (float)reader.ReadDouble();
				shadowOffsetY = (float)reader.ReadDouble();
				tableFillColor = ctx.loadColor();
				tableFrameColor = ctx.loadColor();
				tableRowsCount = reader.ReadInt32();
				tableColumnsCount = reader.ReadInt32();
				tableColWidth = (float)reader.ReadDouble();
				tableRowHeight = (float)reader.ReadDouble();
				tableCaptionHeight = (float)reader.ReadDouble();
				tableCaption = reader.ReadString();
				arrowCascadeOrientation = (Orientation)reader.ReadInt32();
				tableCellBorders = (CellFrameStyle)reader.ReadInt32();
				boxIncmAnchor = (ArrowAnchor)reader.ReadInt32();
				boxOutgAnchor = (ArrowAnchor)reader.ReadInt32();
				boxesExpandable = reader.ReadBoolean();
				tablesScrollable = reader.ReadBoolean();
			}
示例#24
0
 public Container(Rdl.Render.Container parent, Rdl.Engine.ReportElement reportElement, BoxStyle style)
     : base(parent, reportElement, style)
 {
     Rows    = new Rows(this);
     Columns = new Columns(this);
 }
示例#25
0
文件: Box.cs 项目: ChrisMoreton/Test3
		private void setStyle(BoxStyle newStyle)
		{
			bool changed = style != newStyle;
			style = newStyle;

			if (style == BoxStyle.Shape && shapeTemplate == null)
				Shape = flowChart.DefaultShape;

			updateShapePoints();

			if (changed)
				updPosArrows();
		}
示例#26
0
		private bool AddBox(RectangleF rect, long ItemID, float RotationAngle, float ShapeOrientation, Image Picture ,
			Color FillColor, Color FrameColor, Color TextColor, Font ShapeFont, bool Transparent,
			FlowChartX.Pen ItemPen, FlowChartX.Brush ItemBrush, bool IsStyled, string ItemText, 
			BoxStyle ItemStyle, FlowChartX.ShapeTemplate ItemTemplate,
			RectangleF rectGroup, bool IsGroup, StringAlignment sa)
		{
			bool bOk = false, bPicture = false, NoDimChanges = false;
			double lLeft = 0,	lRight = 0,	lTop = 0, lBottom =	0, lW =	0, lH =	0, 
				lLeftG = 0,lRightG = 0,lTopG = 0, lBottomG =0,lWG = 0, lHG =0, fTemp = 0;
			string sTemp = null, sImg = null;
			XmlNode node_temp = null;


			try
			{
				// Inserting new Box
				if ( rectGroup != RectangleF.Empty)
				{
					sTemp = String.Format("vdx:Shape[@ID='{0}']", ItemID );
					shapeNew = shapeRoot.SelectSingleNode(sTemp, ns);
					if ( shapeNew == null )
						shapeNew = groupLast.InsertAfter( shapeTemplate.Clone(),  groupLast.LastChild );
					else
						NoDimChanges = true;
				}
				else
				{
					if (IsGroup) // If the box is main group's frame
					{
						
						shapeNew = shapeRoot.InsertAfter( shapeTemplate.Clone(), shapeRoot.LastChild);
					}
					else
						shapeNew = shapeRoot.InsertAfter( shapeTemplate.Clone(), shapeLast);
				}
				
				if ( shapeNew == null )
					return false;

				// If group is added then creating <Shapes> sub-tree

				
				/*
				 * 
				 * ROTATION
				 * 
				 */
				
				if ( RotationAngle!=0 )
				{
				
					float fAngle = RotationAngle + ShapeOrientation;
					int iSign = ( fAngle<180 ) ? -1 : 1;
					float fAngle2 = ( fAngle<180 ) ? fAngle : 360 - fAngle;

					sTemp =  String.Format("{0}", iSign*Math.PI*(fAngle2/180));
					sTemp = sTemp.Replace(sSeparator, ".");
					SetShapeAttr("vdx:XForm/vdx:Angle","",shapeNew, sTemp);
					RemoveNode(shapeNew.SelectSingleNode("vdx:XForm/vdx:Angle", ns),"F",false);

				}

				if (IsGroup)
				{
					node_temp = shapeNew.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Shapes","http://schemas.microsoft.com/visio/2003/core"), shapeNew.LastChild);
					if ( node_temp == null )
						return false;

					groupLast = node_temp;
				}

				// Setting shape's ID & unique GUID
				if ( rectGroup == RectangleF.Empty)
					shapeLast = shapeNew;

				shapeNew.Attributes["ID"].Value = ItemID.ToString();
			
				sTemp = GetGUID();
				if ( sTemp != null )
				{
					shapeNew.Attributes["UniqueID"].Value = sTemp;
				}	
				lLeft = rect.Left;
				lRight =  rect.Right;
				lTop =  rect.Top;
				lBottom = rect.Bottom;
				lW = rect.Width;
				lH = rect.Height;

				if (( ShapeOrientation == 90 )|| (ShapeOrientation == 270 ))
				{
					double lTemp = lW;
					lW = lH;
					lH = lTemp;
				}

				if ( Picture != null )
				{
					bPicture = true;
					sImg = Image2String(Picture);
					
				}

				if (rectGroup!=RectangleF.Empty )
				{
					lLeftG = rectGroup.Left;
					lRightG = rectGroup.Right;
					lTopG =  rectGroup.Top;
					lBottomG = rectGroup.Bottom;
					lWG = rectGroup.Width;
					lHG = rectGroup.Height;
					
					lLeft = lLeft - ( lLeftG );
					lTop = lTop - lTopG + lDocY  - lHG;
				}

				if (!IsGroup)
				{
					if ( bPicture )
					{
						// If the box is picture container
						// If box is PICTURE or OLE Control

						RemoveNode(shapeNew, "vdx:LayerMem", true);
						RemoveNode(shapeNew, "vdx:Event", true);
						RemoveNode(shapeNew, "vdx:Char", true);
						RemoveNode(shapeNew, "vdx:Text", true);
						RemoveNode(shapeNew, "vdx:Line", true);
						RemoveNode(shapeNew, "vdx:Fill", true);
						RemoveNode(shapeNew, "vdx:Misc", true);
						RemoveNode(shapeNew, "vdx:Group", true);
						RemoveNode(shapeNew, "Master", false);
						
						shapeNew.Attributes["NameU"].Value =  String.Format("Foreign.{0}", ItemID);
						shapeNew.Attributes["Name"].Value =  String.Format("Foreign.{0}", ItemID);
						shapeNew.Attributes["Type"].Value =  "Foreign";
						
						shapeNew.SelectSingleNode("vdx:XForm/vdx:LocPinX", ns).Attributes.RemoveNamedItem("F");
						shapeNew.SelectSingleNode("vdx:XForm/vdx:LocPinY", ns).Attributes.RemoveNamedItem("F");
					
						node_temp = shapeNew.SelectSingleNode("vdx:XForm", ns);

						if ( node_temp!=null)
						{
							XmlNode foregin_node = shapeNew.InsertAfter(doc.CreateNode(XmlNodeType.Element,"Foreign","http://schemas.microsoft.com/visio/2003/core"), node_temp);
							if ( foregin_node!=null)
							{
								XmlNode first_node = null, second_node = null;
								first_node = foregin_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ImgOffsetX","http://schemas.microsoft.com/visio/2003/core"), first_node);
								second_node = foregin_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ImgOffsetY","http://schemas.microsoft.com/visio/2003/core"), first_node);
								second_node = foregin_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ImgWidth","http://schemas.microsoft.com/visio/2003/core"), second_node);
								second_node = foregin_node.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ImgHeight","http://schemas.microsoft.com/visio/2003/core"), second_node);
								SetShapeDim(shapeNew, "vdx:Foreign/vdx:ImgOffsetX", 0 , false);
								SetShapeDim(shapeNew, "vdx:Foreign/vdx:ImgOffsetY", 0, false);
								SetShapeDim(shapeNew, "vdx:Foreign/vdx:ImgWidth", lW , false);
								SetShapeDim(shapeNew, "vdx:Foreign/vdx:ImgHeight", lH, false);
							}

							XmlNode foregin_data_node = shapeNew.InsertAfter(doc.CreateNode(XmlNodeType.Element,"ForeignData","http://schemas.microsoft.com/visio/2003/core"), foregin_node);
							if ( foregin_data_node!=null)
							{
								SetShapeAttr("", "ForeignType",foregin_data_node, "Bitmap");
								foregin_data_node.InnerText = sImg;
																
							}
						}

					
					}
					else
					{
						// If the box is regular					
						sTemp= SetMasterID(shapeNew,ItemTemplate, ItemStyle, ItemID);
						if (!NoDimChanges)
							RemoveNode(shapeNew, "vdx:Group", true);
					}

				}
				else
				{
					// If the box is a main group object

					SetShapeAttr("vdx:Misc/vdx:ObjType","", shapeNew, "8");
					SetShapeAttr("","Type", shapeNew, "Group");

					RemoveNode(shapeNew, "vdx:LayerMem", true);
					RemoveNode(shapeNew, "vdx:Event", true);
					//RemoveNode(shapeNew, "vdx:Char", true);
					//RemoveNode(shapeNew, "vdx:Text", true);
					//RemoveNode(shapeNew, "vdx:Line", true);
					//RemoveNode(shapeNew, "vdx:Fill", true);
					RemoveNode(shapeNew, "vdx:Foreign", true);
					RemoveNode(shapeNew, "vdx:ForeignData", true);
					RemoveNode(shapeNew, "Master", false);
					RemoveNode(shapeNew, "NameU", false);
					RemoveNode(shapeNew, "Name", false);
					sTemp = SetMasterID(shapeNew,ItemTemplate, ItemStyle, ItemID);
					
				}
				
				// Setting shape's dimensions for Visio	XML	nodes
				if (!NoDimChanges)
				{
					SetShapeDim(shapeNew, "vdx:XForm/vdx:PinX", lLeft + lW/2,  true);
					SetShapeDim(shapeNew, "vdx:XForm/vdx:PinY", (lDocY - ( lTop + lH/2)),  true);
					SetShapeDim(shapeNew, "vdx:XForm/vdx:Width",	 lW ,  true);
					SetShapeDim(shapeNew, "vdx:XForm/vdx:Height", lH,  true) ; 
					SetShapeDim(shapeNew, "vdx:XForm/vdx:LocPinX", lW/2 ,  true );
					SetShapeDim(shapeNew, "vdx:XForm/vdx:LocPinY", lH/2 ,  true);
				}

				if ( bPicture )
					return true;

				// Getting font's parameters

				if (ShapeFont == null)
					ShapeFont = pChart.Font;

				SetShapeFont(shapeNew, ShapeFont);

				// Setting shape elements colors
				
				SetShapeColor(shapeNew, "vdx:Fill/vdx:FillForegnd", FillColor);
				
				
				if ( ItemBrush is MindFusion.FlowChartX.LinearGradientBrush )
				{
					SetShapeColor(shapeNew, "vdx:Fill/vdx:FillBkgnd", 
						(ItemBrush as MindFusion.FlowChartX.LinearGradientBrush).LinearColors[1]);
					SetShapeAttr("vdx:Fill/vdx:FillPattern","", shapeNew, "36");
				}
				

				SetShapeColor(shapeNew, "vdx:Char/vdx:Color", TextColor);
				SetShapeColor(shapeNew, "vdx:Line/vdx:LineColor",FrameColor	);

				// Getting shape's transparency	level
				if (Transparent)
				{
					SetShapeAttr("vdx:Fill/vdx:FillForegndTrans","",shapeNew, "1");
					SetShapeAttr("vdx:Line/vdx:LineColorTrans","",shapeNew, "1");
					SetShapeAttr("vdx:Fill/vdx:FillPattern","", shapeNew, "0");
				}
				else
				{
					if (( FillColor == Color.Transparent ) || ( FillColor.A == 0 ))
					{
						SetShapeAttr("vdx:Fill/vdx:FillForegndTrans","",shapeNew, "1");
						SetShapeAttr("vdx:Fill/vdx:FillPattern","", shapeNew, "0");
					}
					else
					{
						fTemp  = (1 - FillColor.A)/ 255;
						sTemp = String.Format("{0}", fTemp);
						SetShapeAttr("vdx:Fill/vdx:FillForegndTrans","",shapeNew, sTemp);
					}
					
					if ( FrameColor == Color.Transparent )
					{
						SetShapeAttr("vdx:Line/vdx:LineColorTrans","",shapeNew, "1");
					}	
						
					
				}
		
				// Setting shape's text
				SetText(shapeNew, ItemText, IsStyled , ShapeFont, sa);

				// Getting line	width & pattern
		
				fTemp =  ItemPen.Width / PixPerInch;
				sTemp = String.Format("{0}", fTemp);
				sTemp = sTemp.Replace(sSeparator, ".");
				SetShapeAttr("vdx:Line/vdx:LineWeight","",shapeNew, sTemp);
				SetShapeAttr("vdx:Line/vdx:LinePattern","",shapeNew, DashStyle2String(ItemPen.DashStyle));

				bOk = true;
			}
			catch ( Exception ex )
			{
				Trace.WriteLine(String.Format("Box#{2}({3}) {0} error {1}\n","AddBox",ex.Message, ItemID, ItemText));
				bOk = false;
			}

			return bOk;
		
		}
示例#27
0
 public abstract void Render(SpriteBuilder sb, BoxStyle style, MonitorContent content, InfoItem info);
示例#28
0
 public override void Render(SpriteBuilder sb, BoxStyle style, MonitorContent content, InfoItem info)
 {
     Render(sb, style, content, info as T);
 }
示例#29
0
 public IBoxItems HorizontalDisplay()
 {
     style = BoxStyle.horizontal;
     return(this);
 }
示例#30
0
 public IBoxItems HorizontalDisplay()
 {
     style = BoxStyle.horizontal;
     return this;
 }
示例#31
0
        /*
         * public override void OnChildrenLoaded(){
         *
         *      // Construct the selector structure now:
         *      // Style.Computed.RefreshStructure();
         *
         * }
         */

        /// <summary>Part of shrink-to-fit. Computes the maximum and minimum possible width for an element.
        /// This does not include the elements own padding/margin/border.</summary>
        public virtual void GetWidthBounds(out float min, out float max)
        {
            min = 0f;
            max = 0f;

            // For each child, get its width bounds too.
            if (RenderData.FirstBox == null)
            {
                return;
            }

            if (childNodes_ != null)
            {
                // Current line:
                float cMin = 0f;
                float cMax = 0f;

                for (int i = 0; i < childNodes_.length; i++)
                {
                    Node child = childNodes_[i];

                    IRenderableNode renderable = (child as IRenderableNode);

                    if (renderable == null)
                    {
                        continue;
                    }

                    float bMin;
                    float bMax;

                    if (child is RenderableTextNode)
                    {
                        // Always get bounds:
                        renderable.GetWidthBounds(out bMin, out bMax);
                    }
                    else
                    {
                        // Get the first box from the render data:
                        ComputedStyle  cs  = renderable.ComputedStyle;
                        RenderableData rd  = renderable.RenderData;
                        LayoutBox      box = rd.FirstBox;

                        if (box == null)
                        {
                            continue;
                        }

                        int displayMode = box.DisplayMode;

                        // If it's inline (or float) then it's additive to the current line.
                        if ((displayMode & DisplayMode.OutsideBlock) != 0 && box.FloatMode == FloatMode.None)
                        {
                            // Line break!
                            cMin = 0f;
                            cMax = 0f;
                        }

                        // Get an explicit width:
                        bool wasAuto;
                        bMin = rd.GetWidth(true, out wasAuto);

                        if (bMin == float.MinValue)
                        {
                            // Get the bounds:
                            renderable.GetWidthBounds(out bMin, out bMax);
                        }
                        else
                        {
                            bMax = bMin;
                        }

                        // Add margins etc (NB: These are calculated twice due to %):
                        BoxStyle padding = cs.GetPaddingBox(displayMode);
                        BoxStyle border  = cs.GetBorderBox(displayMode);

                        // Compute the initial margin:
                        bool     marginAuto = false;
                        BoxStyle margin     = cs.GetMarginBox(displayMode, box.FloatMode, ref marginAuto);

                        float extraStyle = (
                            border.Left + border.Right +
                            padding.Left + padding.Right +
                            margin.Left + margin.Right
                            );

                        bMin += extraStyle;
                        bMax += extraStyle;
                    }

                    // Apply to line:
                    cMin += bMin;
                    cMax += bMax;

                    // Longest line?
                    if (cMin > min)
                    {
                        min = cMin;
                    }

                    if (cMax > max)
                    {
                        max = cMax;
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RadioButtonField" /> class.
 /// </summary>
 /// <param name="Links">Link to the document.</param>
 /// <param name="PartialName">Field name.</param>
 /// <param name="FullName">Full Field name.</param>
 /// <param name="Rect">Field rectangle.</param>
 /// <param name="Value">Field value.</param>
 /// <param name="PageIndex">Page index. (required)</param>
 /// <param name="Height">Gets or sets height of the field.</param>
 /// <param name="Width">Gets or sets width of the field.</param>
 /// <param name="ZIndex">Z index.</param>
 /// <param name="IsGroup">Is group.</param>
 /// <param name="Parent">Gets field parent.</param>
 /// <param name="IsSharedField">Property for Generator support. Used when field is added to header or footer. If true, this field will created once and it&#39;s appearance will be visible on all pages of the document. If false, separated field will be created for every document page.</param>
 /// <param name="Flags">Gets Flags of the field.</param>
 /// <param name="Color">Color of the annotation.</param>
 /// <param name="Contents">Get the field content.</param>
 /// <param name="Margin">Gets or sets a outer margin for paragraph (for pdf generation)</param>
 /// <param name="Highlighting">Field highlighting mode.</param>
 /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the field.</param>
 /// <param name="VerticalAlignment">Gets VerticalAlignment of the field.</param>
 /// <param name="Border">Gets or sets annotation border characteristics.</param>
 /// <param name="MultiSelect">Gets or sets multiselection flag.</param>
 /// <param name="Selected">Gets or sets index of selected item. Numbering of items is started from 1.</param>
 /// <param name="Options">Gets collection of options of the radio button.</param>
 /// <param name="RadioButtonOptionsField">Gets collection of radio button options field.</param>
 /// <param name="Style">Style of field box.</param>
 public RadioButtonField(List <Link> Links = default(List <Link>), string PartialName = default(string), string FullName = default(string), Rectangle Rect = default(Rectangle), string Value = default(string), int?PageIndex = default(int?), double?Height = default(double?), double?Width = default(double?), int?ZIndex = default(int?), bool?IsGroup = default(bool?), FormField Parent = default(FormField), bool?IsSharedField = default(bool?), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), Color Color = default(Color), string Contents = default(string), MarginInfo Margin = default(MarginInfo), LinkHighlightingMode Highlighting = default(LinkHighlightingMode), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), Border Border = default(Border), bool?MultiSelect = default(bool?), int?Selected = default(int?), List <Option> Options = default(List <Option>), List <RadioButtonOptionField> RadioButtonOptionsField = default(List <RadioButtonOptionField>), BoxStyle Style = default(BoxStyle))
 {
     // to ensure "PageIndex" is required (not null)
     if (PageIndex == null)
     {
         throw new InvalidDataException("PageIndex is a required property for RadioButtonField and cannot be null");
     }
     else
     {
         this.PageIndex = PageIndex;
     }
     this.Links                   = Links;
     this.PartialName             = PartialName;
     this.FullName                = FullName;
     this.Rect                    = Rect;
     this.Value                   = Value;
     this.Height                  = Height;
     this.Width                   = Width;
     this.ZIndex                  = ZIndex;
     this.IsGroup                 = IsGroup;
     this.Parent                  = Parent;
     this.IsSharedField           = IsSharedField;
     this.Flags                   = Flags;
     this.Color                   = Color;
     this.Contents                = Contents;
     this.Margin                  = Margin;
     this.Highlighting            = Highlighting;
     this.HorizontalAlignment     = HorizontalAlignment;
     this.VerticalAlignment       = VerticalAlignment;
     this.Border                  = Border;
     this.MultiSelect             = MultiSelect;
     this.Selected                = Selected;
     this.Options                 = Options;
     this.RadioButtonOptionsField = RadioButtonOptionsField;
     this.Style                   = Style;
 }
示例#33
0
		/// <summary>
		/// Intended to set 'Master' attribute of the [Shape]
		/// </summary>
		/// <param name="shape">VDX node name</param>
		/// <param name="newBox">FlowChart/NET box reference</param>
		/// <returns>String FLowchart.NET predefinde shape's name</returns>
		private string SetMasterID(XmlNode shape, 	MindFusion.FlowChartX.ShapeTemplate templ,
			BoxStyle StyleOfShape, long IdOfShape)
		{

			string sFXShape = null, sTemp = null, sVisioShape = null, sMasterID = null;
			XmlNode node_temp = null;
			
			try
			{
				if ( shape == null )
					return null;

				if ( templ == null )
					sFXShape = "Rectangle";
				else
					sFXShape = templ.ToString();

				switch ( StyleOfShape )
				{
					case BoxStyle.Rectangle:
						sFXShape = "Rectangle";
						break;
					case BoxStyle.Ellipse:
						sFXShape = "Ellipse";
						break;
					case BoxStyle.RoundedRectangle:
						sFXShape = "RoundRect";
						break;
					case BoxStyle.Rhombus:
						sFXShape = "Decision";
						break;
					case BoxStyle.Delay:
						sFXShape = "Delay";
						break;
				};
		
				sTemp = String.Format("//vdx:Masters/vdx:Master[@Name='{0}']", sFXShape);
				node_temp =	root.SelectSingleNode(sTemp, ns);

				if (node_temp != null)
				{
					sVisioShape	 = node_temp.Attributes["NameU"].Value.ToString();
					sMasterID  = node_temp.Attributes["ID"].Value.ToString();
				}
				else
				{
					sVisioShape	= "Process";
					sMasterID =	"0";
				}
			
				SetShapeAttr("","Master",shape,sMasterID);
				//??? shape.Attributes["Master"].Value =  sMasterID;
				sTemp = String.Format("{0}.{1}", sVisioShape, IdOfShape);
				SetShapeAttr("","NameU",shape,sMasterID);
				SetShapeAttr("","Name",shape,sMasterID);
				//shape.Attributes["NameU"].Value = sTemp;
				//shape.Attributes["Name"].Value = sTemp;
			}
			catch ( Exception ex )
			{
				Trace.WriteLine(String.Format("{0} error {1}\n","SetMasterID",ex.Message));
				sVisioShape = null;
			}
			
			return sVisioShape;
		}
示例#34
0
 public IBoxItems VerticalDisplay()
 {
     style = BoxStyle.vertical;
     return this;
 }
示例#35
0
            public void HorizonalBarBox(BoxStyle style, float value, int separate = 8, bool discrete = false)
            {
                if (style.SizeRule == SizeRule.Auto)
                {
                    style = new BoxStyle(style)
                    {
                        Size = new Vector2(100, 29)
                    };
                }

                Vector2      size = style.Size * Scale;
                BoundingBox2 box  = new BoundingBox2(Cursor, Cursor + size);

                if (Sprites != null)
                {
                    Vector2  innerSize = style.InnerSize * Scale;
                    MySprite sprite;

                    sprite          = MySprite.CreateSprite(SpriteId.SquareHollow, new Vector2(), new Vector2(1.0f, 1.0f));
                    sprite.Color    = Color;
                    sprite.Position = sprite.Position * innerSize + box.Center;
                    sprite.Size    *= innerSize;
                    Sprites.Add(sprite);

                    //sprite = MySprite.CreateText($"value={value}", FontId, Color, 1.0f, TextAlignment.LEFT);
                    //sprite.Position = new Vector2(-0.45f, -0.45f);
                    //sprite.Position = sprite.Position * size + center;
                    //sprites.Add(sprite);

                    if (value > 1.0f)
                    {
                        value = 1.0f;
                    }
                    if (value < 0.0f)
                    {
                        value = 0.0f;
                    }
                    if (Single.IsNaN(value))
                    {
                        value = 0.0f;
                    }

                    double  len      = value * separate;
                    float   delta    = (float)(len - Math.Floor(len));
                    Vector2 deltaVec = new Vector2(delta, 1.0f);

                    int top;

                    if (discrete)
                    {
                        top = Convert.ToInt32(len);
                    }
                    else
                    {
                        top = Convert.ToInt32(Math.Floor(len));
                    }

                    Vector2 cellPos  = new Vector2(0, 0.0f);
                    Vector2 cellSize = new Vector2(0.9f / separate, 0.9f);
                    //Vector2 innerCellSize = new Vector2(cellSize.X * 0.8f, cellSize.Y * 0.8f);
                    Vector2 innerCellSize = new Vector2(cellSize.X - 0.04f, cellSize.Y * 0.8f);

                    for (int i = 0; i < separate; i++)
                    {
                        if (((discrete) && (i < top)) || ((!discrete) && (i <= top)))
                        {
                            //cellPos.X = 0.92f * (i - (int)((separate - 1)/2)) / separate;

                            cellPos.X = (0.0f - (0.9f / 2)) + (cellSize.X / 2) + (i * cellSize.X);

                            if (i == top)
                            {
                                cellPos.X += ((delta - 1) * innerCellSize.X) / 2.0f;
                                sprite     = MySprite.CreateSprite(SpriteId.SquareSimple, cellPos, innerCellSize * deltaVec);
                            }
                            else
                            {
                                sprite = MySprite.CreateSprite(SpriteId.SquareSimple, cellPos, innerCellSize);
                            }
                            //sprite.Color = new Color(0, 255, 255);
                            sprite.Color    = Color;
                            sprite.Position = sprite.Position * innerSize + box.Center;
                            sprite.Size    *= innerSize;
                            Sprites.Add(sprite);
                        }
                    }
                }

                MoveCursor(box.Width);
                MergeBox(box);
            }
示例#36
0
 public BoxStyle(BoxStyle style) : this(style.SizeRule, style.Size.X, style.Size.Y, style.Align, style.Padding)
 {
 }
示例#37
0
 public IBoxItems VerticalDisplay()
 {
     style = BoxStyle.vertical;
     return(this);
 }
示例#38
0
 public void Render(SpriteBuilder sb, BoxStyle style, MonitorContent content)
 {
     sb.TextBox(style, content.StrValue);
 }
示例#39
0
		/// <summary>
		/// Produces DXF output for Flowchart shape
		/// </summary>
		/// <param name="rect">Bounding Rectangle</param>
		/// <param name="ShapeStyle">Flowchart shape style</param>
		/// <param name="st">ElementTemplate reference if shape is complex null otherwise</param>
		/// <param name="crLine">Line color</param>
		/// <param name="RA">Rotation angle</param>
		/// <param name="dash">DashStyle</param>
		/// <param name="LineWidth">Line width ( not used)</param>
		/// <param name="Offset">Offset if it's necessary</param>
		/// <param name="WCS2UCS">if true conversion for world-coordinate to user-coordinate is required</param>
		/// <param name="gr">GraphicsPath to be assigned</param>
		/// <param name="result">>DXF output string</param>
		/// <returns>true if successfull otherwise false</returns>
		public bool Shape2Str( RectangleF rect, BoxStyle ShapeStyle, ElementTemplate[] st, 
			Color crLine, float RA,  DashStyle dash, Single LineWidth, 
			float Offset, bool WCS2UCS, ref GraphicsPath gr, ref string result )
		{
			
			float X	= 0, Y = 0,	X1 = 0,	Y1 = 0,
				X2 = 0,	Y2 = 0,	X3 = 0,	Y3 = 0;
			bool DisableStringOutput = false;
			PointF[] pts = null;
			bool bOk = false;
			string PathPart = "";
			GraphicsPath gr_temp = new GraphicsPath(FillMode.Winding);

			try
			{
		
				if ( gr == null )
					throw new Exception("Empty Graphics Path reference passed");
						

				DisableStringOutput = ( result == null );
			
				// Detecting box's style
				switch (ShapeStyle)
				{
		
					case BoxStyle.Rectangle:
						gr.AddRectangle(rect);
						break;
					case BoxStyle.Ellipse:
						gr.AddEllipse(rect.X,rect.Y,rect.Width,	rect.Height);
						break;
					case BoxStyle.RoundedRectangle:
						gr = Utilities.getRoundRect(rect.X,	rect.Y,	rect.Width,	rect.Height,10);
						break;
					case BoxStyle.Delay:
						gr.AddRectangle(rect);
						break;
					case BoxStyle.Rhombus:
		
						pts = new PointF[4] {new PointF((rect.Left	+ rect.Right) /	2, rect.Top - Offset),
												new PointF(Math.Max(rect.Right, rect.Left) + Offset, (rect.Top	+ rect.Bottom) / 2),
												new PointF((rect.Left	+ rect.Right) /	2,	Math.Max(rect.Bottom, rect.Top) + Offset),
												new PointF(rect.Left - Offset,(rect.Top	+ rect.Bottom) / 2)};
		
									
						gr.AddPolygon(pts);
									
					
						break;
					case BoxStyle.Shape:  // if shape is complex then processing all its elements
						

						if (st  ==	null)
							throw new Exception("Empty shape reference in the complex shape");

						

						foreach	(ElementTemplate et	in st )
						{
							switch ( et.getClassId())
							{
								case 28: // If shape element is arc
						
									ArcTemplate	at =  et as	ArcTemplate;
									double rx = 0, ry = 0 , cx = 0, cy = 0;
					
									rx = rect.Width * (at.Bounds.Width/200);
									ry = rect.Height * (at.Bounds.Height/200);

									cx = rect.X + rect.Width*(at.Bounds.X/100) + rx;
									cy = rect.Y + rect.Height*(at.Bounds.Y/100) + ry;

									gr.AddArc((float) (cx - rx), (float) ( cy - ry) , (float) rx*2, (float) ry*2, at.StartAngle ,at.SweepAngle);

									float StartAngle =  180 + at.StartAngle + (360 - at.SweepAngle) - RA, EndAngle =  StartAngle + at.SweepAngle;

									if ( rx != ry )
									{
										

										float iAngleC = 0;
										double majorx = 0, majory = 0;
									
										
										if (at.StartAngle<0)
											iAngleC = 360 - Math.Abs(at.StartAngle);
										else
											iAngleC = at.StartAngle;


										majorx = (rx < ry) ? 0 : rx;
										majory = (rx < ry) ? ry : 0; 
										
									
										if (( iAngleC >=0 ) && (iAngleC<90))
										{
										
											majorx*=-1;
											majory*=-1;
										}
										else if (( iAngleC >=90 ) && (iAngleC<180))
										{
										
								
										}
										else if (( iAngleC >=180 ) && (iAngleC<270))
										{
								
										
											majorx*=-1;
											majory*=-1;
											
										}
										else if (( iAngleC >=270 ) && (iAngleC<=360))
										{
								
										}
										
									

										
										StartAngle =  at.StartAngle + RA;
										EndAngle =  StartAngle + at.SweepAngle;
										
										if ((at.SweepAngle>=270) && (at.SweepAngle<360))
										{
											if ( ry > rx )
										{
												StartAngle = at.StartAngle + RA + 90 + ( 360 - at.SweepAngle);
												EndAngle = at.StartAngle + RA + 90;
											}
											
										} 
										else if (at.SweepAngle>=180)
										{
											if (ry>rx)
											{
												StartAngle-=90;
												EndAngle-=90;
											}
										
											
										}
										
										
	
										
										
										PathPart = String.Format(provider, "  0\nELLIPSE\n  100\nAcDbEntity\n{0:HAN}  8\n{5}\n  62\n{6:ACI}\n 100\nAcDbEllipse\n  10\n{0:U}\n  20\n{1:U}\n  11\n{7:U}\n  21\n{8:U}\n  40\n{9:U}\n  41\n{3:U}\n  42\n{4:U}\n",
											cx, m_FlowChart.DocExtents.Height - cy,0, (StartAngle*Math.PI)/180 , (EndAngle*Math.PI)/180, SHAPE_LAYER, crLine, majorx , majory , (rx < ry) ? rx/ry : ry/rx);
									}
									else
									{
										
										PathPart = String.Format(provider, "  0\nARC\n  100\nAcDbEntity\n{0:HAN}  8\n{5}\n  62\n{6:ACI}\n 100\nAcDbCircle\n  10\n{0:U}\n  20\n{1:U}\n  40\n{2:U}\n  100\nAcDbArc\n  50\n{3}\n  51\n{4}\n",
											cx, m_FlowChart.DocExtents.Height - cy,rx, StartAngle , EndAngle, SHAPE_LAYER, crLine);
									}

									break;
								case 29: // If shape element is bezier curve

									BezierTemplate	bt =  et as	BezierTemplate;

									X =	rect.X	+ rect.Width * (bt.Coordinates[0]/100);
									Y =	rect.Y	+  rect.Height*	(bt.Coordinates[1]/100);

									X1 = rect.X	 + rect.Width *	(bt.Coordinates[2]/100);
									Y1 = rect.Y	 +	rect.Height* (bt.Coordinates[3]/100);

									X2 = rect.X	 + rect.Width *	(bt.Coordinates[4]/100);
									Y2 = rect.Y	 + rect.Height*	(bt.Coordinates[5]/100);

									X3 = rect.X	 + rect.Width *	(bt.Coordinates[6]/100);
									Y3 = rect.Y	 + rect.Height*	(bt.Coordinates[7]/100);

									
									gr_temp.Reset();
									gr_temp.AddBezier(X,Y,X1,Y1,X2,Y2,X3,Y3);
									gr.AddBezier(X,Y,X1,Y1,X2,Y2,X3,Y3);
									
									// Applying rotation if it's necessary
									pts = RotatePoints(RA , new PointF(rect.X + rect.Width/2,rect.Y + rect.Height/2), gr_temp);

									gr_temp.Flatten();
									PointF[] pts2 = gr_temp.PathData.Points.Clone() as PointF[];
									
									PathPart = String.Format(provider, "0\nPOLYLINE\n{0:HAN}   100\nAcDbEntity\n8\n{0}\n  62\n{1:ACI}\n  100\nAcDb2dPolyline\n  66\n1\n  70\n4\n  75\n6\n{2}{3}0\nSEQEND\n  100\nAcDbEntity\n{0:HAN}", 
										SHAPE_LAYER,
										crLine, 
										Pt2String(pts,crLine,SHAPE_LAYER,DxLineType.ltVertex, dash, 16),
										Pt2String(pts2,crLine,SHAPE_LAYER,DxLineType.ltVertex, dash, 8));

									break;
								case 30:  // If shape element is line


									LineTemplate lt	= et as	LineTemplate;
					
									X1 = rect.X	+ rect.Width * (lt.Coordinates[0]/100);
									Y1 = rect.Y	+ rect.Height* (lt.Coordinates[1]/100);

									X2 = rect.X	+ rect.Width * (lt.Coordinates[2]/100);
									Y2 = rect.Y	+ rect.Height* (lt.Coordinates[3]/100);
									
									gr_temp.Reset();
									gr_temp.AddLine(X1,Y1,X2,Y2);
									gr.AddLine(X1,Y1,X2,Y2);
									
									// Applying rotation if it's necessary
									pts = RotatePoints(RA , new PointF(rect.X + rect.Width/2,rect.Y + rect.Height/2), gr_temp);
									PathPart = Pt2String(pts, crLine,SHAPE_LAYER,DxLineType.ltSingle,DashStyle.Solid, 1);
									break;
							}

							result+=PathPart;
						}
						break;
					default:
						gr.AddRectangle(rect);
						break;

				}


			
				// Converting shapes coordinates from UCS to WSC
				TranslateCoords(RA , new PointF(rect.X + rect.Width/2,rect.Y + rect.Height/2), WCS2UCS, ref gr);
				
				gr.Flatten();

				// If string output is required producing DXF string
				if (!DisableStringOutput)
				{
					if ( result=="" )
					{
						pts = gr.PathPoints.Clone() as PointF[];
						result = Pt2String(pts, crLine, SHAPE_LAYER, DxLineType.ltClosedSingle, dash, LineWidth);
					}
					
				}
				
				bOk = true;
			}
			catch (	Exception ex)
			{

				Trace.WriteLine(String.Format("{0} error {1}\n","Box2Str",ex.Message));
				bOk = false;
			}

			return bOk;
		}
示例#40
0
 public override void Deserialize(Dictionary<string, object> ser)
 {
     base.Deserialize(ser);
     btype = (BoxType)ser["BoxType"];
     Style = (BoxStyle)ser["BoxStyle"];
     Content = (int)ser["Content"];
 }