예제 #1
0
 public Label(Vector2 pos, HAlign hAlign, VAlign vAlign, string text)
     : base(pos, Vector2.Zero, hAlign, vAlign, false, ContentType.Text, text)
 {
     this.size = font.MeasureString(text);
     size.Y   += textOffset;
     color     = Style.fontColor;
 }
예제 #2
0
 public Legend(Layout _layout, HAlign _hAlign, VAlign _vAlign, int _borderwidth)
 {
     borderWidth = _borderwidth;
     layout      = _layout.ToString();
     hAlign      = _hAlign.ToString();
     vAlign      = _vAlign.ToString();
 }
예제 #3
0
 //
 // Public constructor
 // TODO:  Should this be internal?  Users call AddRow() on StringTableBuilder.  Only AddRow() calls new Row().
 //
 public Row(StringTableBuilder stringTableBuilder)
 {
     _maxHeight          = 1;
     _stringTableBuilder = stringTableBuilder;
     _hAlign             = HAlign.Default;
     _vAlign             = VAlign.Default;
 }
예제 #4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Color.GetHashCode();
         hashCode = (hashCode * 397) ^ Width.GetHashCode();
         hashCode = (hashCode * 397) ^ Height.GetHashCode();
         hashCode = (hashCode * 397) ^ BackgroundColor.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderLeftColor.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderLeftWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderRightColor.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderTopColor.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderBottomColor.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderRightWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderTopWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderBottomWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ Font.GetHashCode();
         hashCode = (hashCode * 397) ^ FontSize.GetHashCode();
         hashCode = (hashCode * 397) ^ HAlign.GetHashCode();
         hashCode = (hashCode * 397) ^ VAlign.GetHashCode();
         hashCode = (hashCode * 397) ^ IsLineThrough.GetHashCode();
         hashCode = (hashCode * 397) ^ IsOverline.GetHashCode();
         hashCode = (hashCode * 397) ^ IsUnderline.GetHashCode();
         hashCode = (hashCode * 397) ^ IsItalic.GetHashCode();
         hashCode = (hashCode * 397) ^ IsBold.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderBottomStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderLeftStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderRightStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ BorderTopStyle.GetHashCode();
         return(hashCode);
     }
 }
 public static IRange SetAlignment(this IRange range, VAlign vertical, HAlign horizontal)
 {
     range.VerticalAlignment      = vertical;
     range.HorizontalAlignment    = horizontal;
     range.Style.IncludeAlignment = true;
     return(range);
 }
예제 #6
0
 public void AddText(
     float relativeWidth  = 100,
     string text          = "",
     float size           = 10,
     VAlign vAlign        = VAlign.Top,
     HAlign hAlign        = HAlign.Left,
     BaseColor background = null,
     BaseColor foreground = null,
     SvnBorder border     = null)
 {
     this.AddCol(
         relativeWidth: relativeWidth,
         background: background,
         foreground: foreground,
         delegator: col =>
     {
         col.AddText(
             text: text,
             size: size,
             vAlign: vAlign,
             hAlign: hAlign,
             background: background,
             foreground: foreground,
             border: border);
     });
 }
 //
 // Public constructor
 //
 public Column(string name)
 {
     _name     = name;
     _hAlign   = HAlign.Default;
     _vAlign   = VAlign.Default;
     _maxWidth = 0;
 }
예제 #8
0
    protected void AlignPivot(VAlign v, HAlign h, ref float pivotX, ref float pivotY)
    {
        switch (v)
        {
        case VAlign.TOP:
            pivotY = 0;
            break;

        case VAlign.MIDDLE:
            pivotY = Target.Height / 2;
            break;

        case VAlign.BOTTOM:
            pivotY = Target.Height;
            break;
        }

        switch (h)
        {
        case HAlign.LEFT:
            pivotX = 0;
            break;

        case HAlign.CENTER:
            pivotX = Target.Width / 2;
            break;

        case HAlign.RIGHT:
            pivotX = Target.Width;
            break;
        }
    }
예제 #9
0
        }                                                // ???

        internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var td = new TagBuilder("td");

            MergeAttributes(td, context);
            td.MergeAttribute("colspan", ColSpan);
            td.MergeAttribute("rowspan", RowSpan);
            if (Align != null)
            {
                td.AddCssClass("text-" + Align.ToString().ToLowerInvariant());
            }
            if (VAlign != VerticalAlign.Default)
            {
                td.AddCssClass($"valign-{VAlign.ToString().ToLowerInvariant()}");
            }
            if (GroupIndent && IsInTreeSection)
            {
                td.MergeAttribute(":class", "row.indentCssClass()");
            }
            if (Underline)
            {
                td.AddCssClass("underline");
            }
            MergeContent(td, context);
            td.AddCssClassBoolNo(Bold, "bold");
            td.AddCssClassBoolNo(Italic, "italic");
            td.RenderStart(context);
            RenderContent(context);
            td.RenderEnd(context);
        }
예제 #10
0
 public Connector(Control source, Connected target, VisualDirection direction,
                  HAlign horizAlign, VAlign vertAlign, ConnectorKind kind, VisualStyle style)
     : base(source, horizAlign, vertAlign)
 {
     Target         = target;
     Kind           = kind;
     ConnectorStyle = style;
 }
예제 #11
0
 public _Connector(Visual visual, _Anchor target, VisualDirection direction,
                   HAlign horizAlign, VAlign vertAlign, ConnectorKind kind)
     : base(visual, horizAlign, vertAlign)
 {
     Target    = target;
     Direction = direction;
     Kind      = kind;
 }
예제 #12
0
        public Connector(Control source, Connected target, VisualDirection direction, 
			HAlign horizAlign, VAlign vertAlign, ConnectorKind kind, VisualStyle style)
            : base(source, horizAlign, vertAlign)
        {
            Target = target;
            Kind = kind;
            ConnectorStyle = style;
        }
예제 #13
0
 public Button(Vector2 pos, Vector2 size, HAlign hAlign, VAlign vAlign, string ID, string regularImageID, string mouseOverImageID, string clickImageID, List <UIObject> InnerElements)
     : base(pos, size, hAlign, vAlign, true, ContentType.Image, regularImageID, InnerElements)
 {
     this.ID               = ID;
     this.regularImageID   = regularImageID;
     this.mouseOverImageID = mouseOverImageID;
     this.clickImageID     = clickImageID;
 }
예제 #14
0
 public Slider(Vector2 pos, Vector2 size, HAlign hAlign, VAlign vAlign, string ID)
     : base(pos, size, hAlign, vAlign, true, ContentType.Structural, "")
 {
     this.ID = ID;
     InnerElements.Add(new UIObject(Vector2.Zero, size - new Vector2(Style.SliderHandleSize.X, 0), HAlign.Center, VAlign.Center, false, ContentType.Image, Style.SliderBar));
     InnerElements.Add(new UIObject(Vector2.Zero, Style.SliderHandleSize, HAlign.Center, VAlign.Center, false, ContentType.Image, Style.SliderHandle));
     Init();
 }
예제 #15
0
 private static string ToString(VAlign va)
 {
     switch (va)
     {
     case VAlign.Middle:
         return("middle");
     }
     return("baseline");
 }
예제 #16
0
        //rowspan

        public CRow(string Id)
        {
            this.Id = Id;

            this.Align  = CHtmlParser.GetDefaultHAlign();
            this.VAlign = CHtmlParser.GetDefaultVAlign();

            this.mColumns = new Columns();
        }
예제 #17
0
 public FormattedText(string rawText, FontData fontData, Color foreColor, HAlign hAlign, VAlign vAlign)
     : this()
 {
     _rawText    = rawText;
     _fontData   = fontData;
     _foreColor  = foreColor;
     _hAlignment = hAlign;
     _vAlignment = vAlign;
 }
예제 #18
0
 public override Image ExecuteFilterDemo(Image rawImage)
 {
     this.Caption           = "Caption Demo";
     this.TextSize          = 18;
     this.AutomaticTextSize = false;
     this.Halign            = HAlign.Bottom;
     this.Valign            = VAlign.Right;
     return(this.ExecuteFilter(rawImage));
 }
예제 #19
0
 public AbilityButton(Vector2 pos, Vector2 size, HAlign hAlign, VAlign vAlign, AbilityType abilityType)
     : base(pos, size, hAlign, vAlign, "", REGULAR_TEX, MOUSEOVER_TEX, PRESSED_TEX)
 {
     m_abilityType = abilityType;
     InnerElements.Add(new UIObject(Vector2.Zero, new Vector2(AbilityBar.ICON_WIDTH, AbilityBar.ICON_HEIGHT), HAlign.Center, VAlign.Center, false, ContentType.Image, Player.Instance.GetAbilityByType(m_abilityType).m_iconTextureAssetName,
                                    new List <UIObject> {
         new Label(Vector2.Zero, HAlign.Right, VAlign.Bottom, Player.Instance.GetAbilityByType(abilityType).Cost.ToString())
     }));
 }
예제 #20
0
 /// <summary>
 /// Draws a connector between visuals. The target visual must be wrapped by an
 /// anchor in order to draw a connector to it.
 /// </summary>
 public static Visual Connector(Visual visual, Visual target, VisualDirection direction,
                                HAlign horizAlign, VAlign vertAlign, ConnectorKind kind = ConnectorKind.Line)
 {
     if (!(target is _Anchor))
     {
         throw new ArgumentException("Target visual must be surronded by an anchor", "target");
     }
     return(new _Connector(visual, target as _Anchor, direction, horizAlign, vertAlign, kind));
 }
예제 #21
0
 /// <summary>
 /// Initializes a new pile.
 /// </summary>
 public _Pile(IEnumerable <Tuple <float, Visual> > items, VisualDirection direction,
              HAlign horizAlign, VAlign vertAlign) : base(direction, horizAlign, vertAlign)
 {
     if (items.Any(t => t.Item1 < 0f || t.Item1 > 1f))
     {
         throw new ArgumentException("The position value must be in range [0, 1].");
     }
     Items = items.ToArray();
 }
예제 #22
0
        /// <summary>
        /// Draw text in a vertical and horizontal position
        /// When "align" is "Center" then "margin" is ignored.
        /// Also when "vAlign" is "Middle" then "vMargin"  is ignored.
        /// </summary>
        /// <param name="screen"></param>
        /// <param name="color"></param>
        /// <param name="font"></param>
        /// <param name="inString"></param>
        /// <param name="align"></param>
        /// <param name="margin"></param>
        /// <param name="vAlign"></param>
        /// <param name="vMargin"></param>
        public void DrawAlignedText(Bitmap screen, Color color, Font font, string inString, HAlign align, int margin, VAlign vAlign, int vMargin)
        {

            Point p = new Point();
            var stringWidth = MeasureString(inString, font);
            var stringHeight = 0;
            var textAreaLength = 0;
           

            switch (align)
            {

                case HAlign.Left:

                    p.X = margin + 1;
                    break;

                case HAlign.Center:

                    textAreaLength = screen.Width - (margin * 2);
                    p.X = margin + ((textAreaLength - stringWidth) / 2);
                    break;

                case HAlign.Right:

                    textAreaLength = screen.Width - margin;
                    p.X = textAreaLength - stringWidth;
                    break;

            }

            stringHeight = font.Height;

            switch (vAlign)
            {

                case VAlign.Top:

                    p.Y = vMargin + 1;
                    break;

                case VAlign.Middle:

                    p.Y= (screen.Height / 2) - (stringHeight / 2);
                    break;

                case VAlign.Bottom:

                    p.Y = screen.Height - stringHeight - vMargin;
                    break;

            }

            screen.DrawText(inString, font, color, p.X, p.Y);

        }
예제 #23
0
파일: TextElement.cs 프로젝트: andi2/ld32-1
        public TextElement(InterfaceElement parent, Vector2 location, BitmapFont font, string text, HAlign h, VAlign v)
            : base(parent, location)
        {
            Opacity = 1f;

            this.Text = text;
            this.Font = font;
            this.hAlign = h;
            this.vAlign = v;
        }
예제 #24
0
        public Column(string Id)
        {
            this.Id = Id;

            this.Align  = CHtmlParser.GetDefaultHAlign();
            this.VAlign = CHtmlParser.GetDefaultVAlign();
            this.Width  = 0;

            this.mValues = new Values();
        }
예제 #25
0
        public TextElement(InterfaceElement parent, Vector2 location, BitmapFont font, string text, HAlign h, VAlign v)
            : base(parent, location)
        {
            Opacity = 1f;

            this.Text   = text;
            this.Font   = font;
            this.hAlign = h;
            this.vAlign = v;
        }
예제 #26
0
 public void AddText(
     string text          = "",
     float size           = 10,
     VAlign vAlign        = VAlign.Top,
     HAlign hAlign        = HAlign.Left,
     BaseColor background = null,
     BaseColor foreground = null,
     SvnBorder border     = null)
 {
     this.Content = new SvnText(this, text, size, vAlign, hAlign, background, foreground, border);
 }
예제 #27
0
 private VAlign OverwriteVAlign(VAlign AOld, VAlign ANew)
 {
     if (ANew == CHtmlParser.GetDefaultVAlign())
     {
         return(AOld);
     }
     else
     {
         return(ANew);
     }
 }
예제 #28
0
 /** Creates a new TextFormat instance with the given properties. */
 public TextFormat(string font            = BitmapFont.MINI, float size = 12, uint color = 0x0,
                   HAlign horizontalAlign = HAlign.Center, VAlign verticalAlign = VAlign.Center)
 {
     _font            = font;
     _size            = size;
     _color           = color;
     _horizontalAlign = horizontalAlign;
     _verticalAlign   = verticalAlign;
     _kerning         = true;
     _leading         = 0.0f;
 }
예제 #29
0
        /** Sets the most common properties at once. */
        public void SetTo(string font            = "Verdana", float size = 12, uint color = 0x0,
                          HAlign horizontalAlign = HAlign.Center, VAlign verticalAlign = VAlign.Center)
        {
            _font            = font;
            _size            = size;
            _color           = color;
            _horizontalAlign = horizontalAlign;
            _verticalAlign   = verticalAlign;

            ChangeEvent?.Invoke();
        }
예제 #30
0
        public Container(VisualDirection direction, HAlign horizAlign,	VAlign vertAlign,  
			bool framed, bool wrapAround, IEnumerable<Tuple<Control, Reaction<Control>>> controls)
        {
            Direction = direction;
            HorizAlign = horizAlign;
            VertAlign = vertAlign;
            Framed = framed;
            WrapAround = wrapAround;
            Controls = new List<Tuple<Control, Reaction<Control>>> (controls);
            if (Controls.Select (TupleExt.Second).Any (r => r != null))
                _mouseRegions = new MouseRegions<Tuple<Control, Reaction<Control>>> ();
        }
예제 #31
0
        public Column(string Id, int Width)
        {
            this.Id = Id;

            this.Align           = CHtmlParser.GetDefaultHAlign();
            this.VAlign          = CHtmlParser.GetDefaultVAlign();
            this.Width           = Width;
            this.ColSpan         = 1;
            this.WidthBeforeSpan = 0;

            this.mValues = new Values();
        }
예제 #32
0
        //public Color BackColor
        //{
        //  get { return _backColor; }
        //  set { _backColor = value; }
        //}

        #endregion Properties

        #region Constructor

        public FormattedText()
        {
            _rawText               = "";
            _formattedText         = "";
            _fontData              = new FontData();
            _fontData.Name         = "Verdana";
            _fontData.SizeInPoints = 10;
            _foreColor             = Color.Black;
            //_backColor = Color.White;
            _hAlignment = HAlign.Left;
            _vAlignment = VAlign.Top;
        }
예제 #33
0
        //NOTE: I know a lot of these variables shouldn't be public. I got lazy.

        //contructor for UIObjects without child elements
        public UIObject(Vector2 pos, Vector2 size, HAlign hAlign, VAlign vAlign, bool TriggerMouseEvent, ContentType contentType, string param)
        {
            this.pos  = pos;
            this.size = size;
            this.TriggerMouseEvent = TriggerMouseEvent;
            this.contentType       = contentType;
            this.param             = param;
            this.InnerElements     = new List <UIObject>();
            this.hAlign            = hAlign;
            this.vAlign            = vAlign;
            topLeft    = pos;
            scaledSize = pos;
        }
예제 #34
0
        public static XLAlignVertEnum ToXLAlignV(this VAlign align)
        {
            XLAlignVertEnum result;

            if (Enum.TryParse(align.ToString(), out result))
            {
                return(result);
            }
            else
            {
                return(XLAlignVertEnum.Undefined);
            }
        }
예제 #35
0
        public TextField(float width, float height, string text = "", string fontName = "mini", float fontSize = 14, uint color = 0x0)
        {
            _text = text;
            _fontSize = fontSize;
            _color = color;
            _hAlign = HAlign.Center;
            _vAlign = VAlign.Center;
            _autoScale = false;
            _kerning = true;
            _requiresRedraw = true;
            FontName = fontName;

            _hitArea = new Quad(width, height);
            _hitArea.Alpha = 0.0f;
            AddChild(_hitArea);

            _contents = new QuadBatch();
            _contents.Touchable = false;
            AddChild(_contents);

            //[self addEventListener:@selector(onFlatten:) atObject:self forType:SPEventTypeFlatten];
        }
예제 #36
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            public _Connector(Visual visual, _Anchor target, VisualDirection direction, 
				HAlign horizAlign, VAlign vertAlign, ConnectorKind kind)
                : base(visual, horizAlign, vertAlign)
            {
                Target = target;
                Direction = direction;
                Kind = kind;
            }
예제 #37
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 public _Container(VisualDirection direction, HAlign horizAlign, VAlign vertAlign)
 {
     Direction = direction;
     HorizAlign = horizAlign;
     VertAlign = vertAlign;
 }
예제 #38
0
        /// <summary>
        /// Moves the pivot point to a certain position within the local coordinate system of the object.
        /// </summary>
        public void Align(HAlign hAlign, VAlign vAlign)
        {
            Rectangle bounds = BoundsInSpace(this);
            _orientationChanged = true;

            switch (hAlign)
            {
                case HAlign.Left:
                    _pivotX = bounds.X;
                    break;
                case HAlign.Center:
                    _pivotX = bounds.X + bounds.Width / 2.0f;
                    break;
                case HAlign.Right:
                    _pivotX = bounds.X + bounds.Width; 
                    break;
                default:
                    throw new InvalidOperationException("invalid horizontal alignment");
            }

            switch (vAlign)
            {
                case VAlign.Top:
                    _pivotY = bounds.Top;  
                    break;
                case VAlign.Center:
                    _pivotY = bounds.Top + bounds.Height / 2.0f; 
                    break;
                case VAlign.Bottom:
                    _pivotY = bounds.Top + bounds.Height; 
                    break;
                default:
                    throw new InvalidOperationException("invalid vertical alignment");
            }
        }
예제 #39
0
        public static string GetImageGenUrl(
            this string imageUrl,
            int? width = null,
            int? height = null,
            int? quality = null,
            Align? align = null,
            bool? allowUpsizing = null,
            bool? antiAlias = null,
            int? border = null,
            string borderColor = null,
            ColorMode? colorMode = null,
            bool? constrain = null,
            Flip? flip = null,
            int? fontSize = null,
            FontStyle? fontStyle = null,
            string font = "",
            string fontColor = "",
            Format? format = null,
            int? lineHeight = null,
            int? maxHeight = null,
            int? maxWidth = null,
            bool? noCache = null,
            int? overlayMargin = null,
            bool? pad = null,
            int? rotate = null,
            bool? transparent = null,
            VAlign? vAlign = null,
            string altImage = null,
            string bgColor = null,
            string overlayImage = null,
            string text = null,
            string imageCropperValue = null,
            string imageCropperCropId = null,
            string furtherOptions = null,
            bool slimmage = false)
        {
            if (!string.IsNullOrEmpty(imageUrl))
            {
                var imageGenUrl = new StringBuilder();
                imageGenUrl.Append(string.Format("/ImageGen.ashx?Image={0}",imageUrl));

                if (!string.IsNullOrEmpty(imageCropperValue) && imageCropperValue.IsJson())
                {
                    var allTheCrops = imageCropperValue.GetImageCrops();
                    if (allTheCrops != null && allTheCrops.Any())
                    {
                        var crop = imageCropperCropId != null
                            ? allTheCrops.Find(x => x.Id == imageCropperCropId)
                            : allTheCrops.First();
                        if (crop != null)
                        {
                            imageGenUrl.Append(string.Format("&crop={0}",crop.CropCoOrds));
                        }
                    }
                }
                if (width != null)
                {
                    imageGenUrl.Append(string.Format("&width={0}",width));
                }
                if (height != null)
                {
                    imageGenUrl.Append(string.Format("&height={0}", width));
                }
                if (quality != null)
                {
                    imageGenUrl.Append(string.Format("&quality={0}", quality));
                }

                //Align (Left, Center, Right, Near, Far)
                if (align != null)
                {
                    imageGenUrl.Append(string.Format("&Align={0}", align));
                }
                //Allow Upsizing (True False)
                if (allowUpsizing != null)
                {
                    imageGenUrl.Append(string.Format("&AllowUpsizing={0}", allowUpsizing));
                }

                //Alt Image (/photos/waterfall.png)
                if (!string.IsNullOrEmpty(altImage))
                {
                    imageGenUrl.Append(string.Format("&AltImage={0}", altImage));
                }

                //AntiAlias (True of False)
                if (antiAlias != null)
                {
                    imageGenUrl.Append(string.Format("&AntiAlias={0}", antiAlias));
                }

                //BgColor (FFFFFF)
                if (!string.IsNullOrEmpty(bgColor))
                {
                    imageGenUrl.Append(string.Format("&BgColor={0}", bgColor));
                }

                //Color Mode (enum)
                if (colorMode != null)
                {
                    imageGenUrl.Append(string.Format("&ColorMode={0}", colorMode));
                }

                //Border (15)
                if (border != null)
                {
                    imageGenUrl.Append(string.Format("&Border={0}", border));
                }

                //BorderColor (000000)
                if (!string.IsNullOrEmpty(borderColor))
                {
                    imageGenUrl.Append(string.Format("&BorderColor={0}", borderColor));
                }

                //Color Mode (enum)
                if (colorMode != null)
                {
                    imageGenUrl.Append(string.Format("&ColorMode={0}", colorMode));
                }

                //Constrain (true/false)
                if (constrain != null)
                {
                    imageGenUrl.Append(string.Format("&Constrain={0}", constrain));
                }

                //Flip (x,y,xy)
                if (flip != null)
                {
                    imageGenUrl.Append(string.Format("&Flip={0}", flip));
                }

                //fontSize (000033)
                if (fontSize != null)
                {
                    imageGenUrl.Append(string.Format("&FontSize={0}", fontSize));
                }

                //FontStyle (Bold%2BItalic)
                if (fontStyle != null)
                {
                    imageGenUrl.Append(string.Format("&FontStyle={0}", fontStyle));
                }

                //Font (Verdana)
                if (font != null)
                {
                    imageGenUrl.Append(string.Format("&Font={0}", font));
                }

                //FontColor (000033)
                if (fontColor != null)
                {
                    imageGenUrl.Append(string.Format("&FontColor={0}", fontColor));
                }

                //Format (JPEG, JPG, GIF, PNG, BMP, TIFF, TIF)
                if (format != null)
                {
                    imageGenUrl.Append(string.Format("&Format={0}", format));
                }

                //LineHeight (40)
                if (lineHeight != null)
                {
                    imageGenUrl.Append(string.Format("&LineHeight={0}", lineHeight));
                }

                //MaxHeight (40)
                if (maxHeight != null)
                {
                    imageGenUrl.Append(string.Format("&MaxHeight={0}", maxHeight));
                }

                //MaxWidth (40)
                if (maxWidth != null)
                {
                    imageGenUrl.Append(string.Format("&MaxWidth={0}", maxWidth));
                }

                //NoCache (true/false)
                if (noCache != null)
                {
                    imageGenUrl.Append(string.Format("&NoCache={0}", noCache));
                }

                //OverlayMargin (8)
                if (overlayMargin != null)
                {
                    imageGenUrl.Append(string.Format("&OverlayMargin={0}", overlayMargin));
                }

                //Pad (true/false)
                if (pad != null)
                {
                    imageGenUrl.Append(string.Format("&Pad={0}", pad));
                }

                //Rotate (0 - 360) int with validation -360 to 360
                if (rotate != null)
                {
                    //Check values
                    //If larger than 360 set it to 360
                    if (rotate > 360)
                    {
                        rotate = 360;
                    }

                    //If larger than minus 360 set it to minus 360
                    if (rotate < -360)
                    {
                        rotate = -360;
                    }

                    imageGenUrl.Append(string.Format("&Rotate={0}", rotate));
                }

                //Transparent (Bool True of False)
                if (transparent != null)
                {
                    imageGenUrl.Append(string.Format("&Transparent={0}", transparent));
                }

                //VAlign (Enum Top, Middle, Bottom, Near, Far)
                if (vAlign != null)
                {
                    imageGenUrl.Append(string.Format("&VAlign={0}", vAlign));
                }

                //OverlayImage (/images/watermark.png)
                if (overlayImage != null)
                {
                    imageGenUrl.Append(string.Format("&OverlayImage={0}", overlayImage));
                }

                if (text != null)
                {
                    imageGenUrl.Append(string.Format("&Text={0}", HttpUtility.UrlEncode(HttpUtility.HtmlEncode(text))));
                }

                if (slimmage)
                {
                    if (width == null)
                    {
                        imageGenUrl.Append("&width=300");
                    }
                    if (quality == null)
                    {
                        imageGenUrl.Append("&quality=90");
                    }
                    imageGenUrl.Append("&slimmage=true");
                }
                if (furtherOptions != null)
                {
                    imageGenUrl.Append(furtherOptions);
                }

                return imageGenUrl.ToString();
            }
            return string.Empty;
        }
예제 #40
0
 /// <summary>
 /// To set vertical alignment 
 /// </summary>
 /// <param name="workbook">Instance of IWorkbook</param>
 /// <param name="sheetIndex">Worksheet index starts from zero</param>
 /// <param name="startColIndex"></param>
 /// <param name="startRowIndex"></param>
 /// <param name="endRowIndex"></param>
 /// <param name="endColInex"></param>
 /// <param name="valign"></param>
 internal static void SetVerticalAlignment(IWorkbook workbook, int sheetIndex, int startRowIndex, int startColIndex, int endRowIndex, int endColInex, VAlign valign)
 {
     SpreadsheetGear.IRange Range;
     try
     {
         // Get a reference to a cell.
         Range = workbook.Worksheets[sheetIndex].Cells[startRowIndex, startColIndex, endRowIndex, endColInex];
         Range.VerticalAlignment = valign;
     }
     catch (Exception ex)
     {
         //                ExceptionFacade.ThrowException(ex);
     }
 }
예제 #41
0
 public Legend(Layout _layout, HAlign _hAlign, VAlign _vAlign, int _borderwidth)
 {
     borderWidth = _borderwidth;
     layout = _layout.ToString();
     hAlign = _hAlign.ToString();
     vAlign = _vAlign.ToString();
 }
예제 #42
0
 /// <summary>
 /// To set vertical alignment 
 /// </summary>
 /// <param name="workbook">Instance of IWorkbook</param>
 /// <param name="sheetIndex">Worksheet index starts from zero.</param>
 /// <param name="rowIndex"></param>
 /// <param name="colIndex"></param>
 internal static void SetVerticalAlignment(IWorkbook workbook, int sheetIndex, int rowIndex, int colIndex, VAlign valign)
 {
     SpreadsheetGear.IRange Range;
     try
     {
         // Get a reference to a cell.
         Range = workbook.Worksheets[sheetIndex].Cells[rowIndex, colIndex];
         Range.VerticalAlignment = valign;
     }
     catch (Exception ex)
     {
         //                new ApplicationException(ex.ToString());
     }
 }
예제 #43
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Create a vertical stack.
 /// </summary>
 public static Visual VPile(HAlign horizAlign, VAlign vertAlign, params Tuple<float, Visual>[] visuals)
 {
     return new _Pile (visuals, VisualDirection.Vertical, horizAlign, vertAlign);
 }
예제 #44
0
        private List<CharLocation> ArrangeCharsInArea(float width, float height, string text, float size, HAlign hAlign, VAlign vAlign, bool autoScale, bool kerning)
        {
            if (text.Length == 0)
            {
                return new List<CharLocation>();
            }

            if (size < 0)
            {
                size *= -_size;
            }

            bool isFinished = false;
            float scale = 0;
            float containerWidth = 0;
            float containerHeight = 0;

            List<List<CharLocation>> lines = new List<List<CharLocation>>();
            while (!isFinished)
            {
                scale = size / _size;
                containerWidth = width / scale;
                containerHeight = height / scale;

                if (_lineHeight <= containerHeight)
                {
                    int lastWhiteSpace = -1;
                    int lastCharId = -1;
                    int numChars = text.Length;
                    float currentX = 0;
                    float currentY = 0;
                    List<CharLocation> currentLine = new List<CharLocation>();

                    for (int i = 0; i < numChars; i++)
                    {
                        bool isLineFull = false;
                        int charId = text[i];
                        BitmapChar bitmapChar = CharById(charId);

                        if (charId == NewLineAsciiCode || charId == CarriageReturnAsciiCode)
                        {
                            isLineFull = true;
                        }
                        else if (bitmapChar == null)
                        {
                            Console.WriteLine("Missing character: " + charId);
                        }
                        else
                        {
                            if (charId == SpaceAsciiCode || charId == TabAsciiCode)
                            {
                                lastWhiteSpace = i;
                            }
                                
                            if (kerning)
                            {
                                currentX += bitmapChar.KerningToChar(lastCharId);
                            }
                            CharLocation charLocation = CharLocation.Create(bitmapChar, 1.0f, currentX + bitmapChar.XOffset, currentY + bitmapChar.YOffset);
                            currentLine.Add(charLocation);
                            currentX += bitmapChar.XAdvance;
                            lastCharId = charId;

                            if (charLocation.X + bitmapChar.Width > containerWidth)
                            {
                                int numCharsToRemove = (lastWhiteSpace == -1) ? 1 : i - lastWhiteSpace;
                                int removeIndex = currentLine.Count - numCharsToRemove;
                                currentLine.RemoveRange(removeIndex, numCharsToRemove);

                                if (currentLine.Count == 0)
                                {
                                    break;
                                }

                                i -= numCharsToRemove;
                                isLineFull = true;
                            }
                        }

                        if (i == numChars - 1)
                        {
                            lines.Add(currentLine);
                            isFinished = true;
                        }
                        else if (isLineFull)
                        {
                            lines.Add(currentLine);

                            if (lastWhiteSpace == i)
                            {
                                currentLine.RemoveAt(currentLine.Count - 1);
                            }

                            if (currentY + 2 * _lineHeight <= containerHeight)
                            {
                                currentLine = new List<CharLocation>();
                                currentX = 0;
                                currentY += _lineHeight;
                                lastWhiteSpace = -1;
                                lastCharId = -1;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }

                if (autoScale && !isFinished)
                {
                    size -= 1;
                    lines.Clear();
                }
                else
                {
                    isFinished = true;
                }
            }

            List<CharLocation> finalLocations = new List<CharLocation>();
            int numLines = lines.Count;
            float bottom = numLines * _lineHeight;
            int yOffset = 0;

            if (vAlign == VAlign.Bottom)
            {
                yOffset = (int)(containerHeight - bottom);
            }
            else if (vAlign == VAlign.Center)
            {
                yOffset = (int)((containerHeight - bottom) / 2);
            }

            List<CharLocation> line;
            for (int i = 0; i < lines.Count; i++)
            {
                line = lines[i];
                int numChars = line.Count;
                if (numChars == 0)
                {
                    continue;
                }

                int xOffset = 0;
                CharLocation lastLocation = line[line.Count - 1];
                float right = lastLocation.X - lastLocation.BitmapChar.XOffset + lastLocation.BitmapChar.XAdvance;

                if (hAlign == HAlign.Right)
                {
                    xOffset = (int)(containerWidth - right);
                }
                else if (hAlign == HAlign.Center)
                {
                    xOffset = (int)((containerWidth - right) / 2);
                }

                CharLocation charLocation;
                for (int j = 0; j < line.Count; j++)
                {
                    charLocation = line[j];
                    charLocation.X = scale * (charLocation.X + xOffset);
                    charLocation.Y = scale * (charLocation.Y + yOffset);
                    charLocation.Scale = scale;

                    if (charLocation.BitmapChar.Width > 0 && charLocation.BitmapChar.Height > 0)
                    {
                        finalLocations.Add(charLocation);
                    }
                }
            }
                
            return finalLocations;
        }
예제 #45
0
        /// <summary>
        ///  Draws text into a quad batch.
        /// </summary>
        public void FillQuadBatch(QuadBatch quadBatch, float width, float height, string text, float size, uint color, HAlign hAlign, VAlign vAlign, bool autoScale, bool kerning)
        {
            List<CharLocation> charLocations = ArrangeCharsInArea(width, height, text, size, hAlign, vAlign, autoScale, kerning);
            _helperImage.Color = color;

            if (charLocations.Count > MAX_TEXT_CHAR_COUNT)
            {
                throw new InvalidDataException(string.Format("Bitmap font text is limited to {0} characters", MAX_TEXT_CHAR_COUNT));
            }

            CharLocation charLocation;
            for (int i = 0; i < charLocations.Count; i++)
            {
                charLocation = charLocations[i];
                _helperImage.Texture = charLocation.BitmapChar.Texture;
                _helperImage.X = charLocation.X;
                _helperImage.Y = charLocation.Y;
                _helperImage.ScaleX = _helperImage.ScaleY = charLocation.Scale;
                _helperImage.ReadjustSize();
                quadBatch.AddQuad(_helperImage);
            }

        }
예제 #46
0
 /// <summary>
 /// To set vertical alignment 
 /// </summary>
 /// <param name="sheetIndex">Worksheet index starts from zero</param>
 /// <param name="startColIndex"></param>
 /// <param name="startRowIndex"></param>
 /// <param name="endRowIndex"></param>
 /// <param name="endColIndex"></param>
 /// <param name="valign"></param>
 public void SetVerticalAlignment(int sheetIndex, int startRowIndex, int startColIndex, int endRowIndex, int endColIndex, VAlign valign)
 {
     try
     {
         ExcelHelper.SetVerticalAlignment(this.Workbook, sheetIndex, startRowIndex, startColIndex, endRowIndex, endColIndex, valign);
     }
     catch (Exception ex)
     {
         //               throw ex;
     }
 }
예제 #47
0
        public Container(VisualDirection direction, HAlign horizAlign, VAlign vertAlign,
			bool framed, bool wrapAround, params Control[] controls)
            : this(direction, horizAlign, vertAlign, framed, wrapAround, 
				(IEnumerable<Control>)controls)
        {
        }
예제 #48
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Create a horizontal stack.
 /// </summary>
 public static Visual HStack(VAlign alignment, params Visual[] visuals)
 {
     return new _Stack (visuals, VisualDirection.Horizontal, HAlign.Left, alignment);
 }
예제 #49
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            /// <summary>
            /// Initializes a new pile.
            /// </summary>
            public _Pile(IEnumerable<Tuple<float, Visual>> items, VisualDirection direction, 
				HAlign horizAlign, VAlign vertAlign)
                : base(direction, horizAlign, vertAlign)
            {
                if (items.Any (t => t.Item1 < 0f || t.Item1 > 1f))
                    throw new ArgumentException ("The position value must be in range [0, 1].");
                Items = items.ToArray ();
            }
예제 #50
0
 /// <summary>
 /// To set vertical alignment 
 /// </summary>
 /// <param name="sheetIndex">Worksheet index starts from zero.</param>
 /// <param name="rowIndex"></param>
 /// <param name="colIndex"></param>
 public void SetVerticalAlignment(int sheetIndex, int rowIndex, int colIndex, VAlign valign)
 {
     try
     {
         ExcelHelper.SetVerticalAlignment(this.Workbook, sheetIndex, rowIndex, colIndex, valign);
     }
     catch (Exception ex)
     {
     //                ExceptionFacade.ThrowException(ex);
     }
 }
예제 #51
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 public _Anchor(Visual visual, HAlign horizAlign, VAlign vertAlign)
     : base(visual)
 {
     HorizAlign = horizAlign;
     VertAlign = vertAlign;
 }
예제 #52
0
파일: Visual.cs 프로젝트: johtela/Compose3D
        /// <summary>
        /// Draws a connector between visuals. The target visual must be wrapped by an
        /// anchor in order to draw a connector to it.
        /// </summary>
        public static Visual Connector(Visual visual, Visual target, VisualDirection direction,
			HAlign horizAlign, VAlign vertAlign, ConnectorKind kind = ConnectorKind.Line)
        {
            if (!(target is _Anchor))
                throw new ArgumentException ("Target visual must be surronded by an anchor", "target");
            return new _Connector(visual, target as _Anchor, direction, horizAlign, vertAlign, kind);
        }
예제 #53
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Create a vertical pile.
 /// </summary>
 public static Visual VPile(HAlign horizAlign, VAlign vertAlign, IEnumerable<Tuple<float, Visual>> visuals)
 {
     return new _Pile (visuals, VisualDirection.Vertical, horizAlign, vertAlign);
 }
예제 #54
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Create an anchor around a visual to act as a target of a connector.
 /// </summary>
 public static Visual Anchor(Visual visual, HAlign horizAlign, VAlign vertAlign)
 {
     return new _Anchor (visual, horizAlign, vertAlign);
 }
예제 #55
0
 public Connected(Control source, HAlign horizAlign, VAlign vertAlign)
 {
     Source = source;
     HorizAlign = horizAlign;
     VertAlign = vertAlign;
 }
예제 #56
0
 /// <summary>
 /// To set vertical alignment 
 /// </summary>
 /// <param name="sheetIndex">Worksheet index starts from zero.</param>
 /// <param name="rowIndex"></param>
 /// <param name="colIndex"></param>
 public void SetVerticalAlignment(int sheetIndex, int rowIndex, int colIndex, VAlign valign)
 {
     try
     {
         ExcelHelper.SetVerticalAlignment(this.Workbook, sheetIndex, rowIndex, colIndex, valign);
     }
     catch (Exception ex)
     {
     //                new ApplicationException(ex.ToString());
     }
 }
예제 #57
0
파일: Visual.cs 프로젝트: johtela/Compose3D
 /// <summary>
 /// Create a horizontal stack.
 /// </summary>
 public static Visual HStack(VAlign alignment, IEnumerable<Visual> visuals)
 {
     return new _Stack (visuals, VisualDirection.Horizontal, HAlign.Left, alignment);
 }
예제 #58
0
파일: Visual.cs 프로젝트: johtela/Compose3D
            public _Flow(IEnumerable<Visual> items, VisualDirection direction, HAlign horizAlign,
				VAlign vertAlign, SizeF containerSize)
                : base(direction, horizAlign, vertAlign)
            {
                Items = items.ToArray ();
                ContainerSize = containerSize;
            }
예제 #59
0
 /// <summary>
 /// Generate an ImageGen URL from a Media Item
 /// </summary>
 /// <param name="mediaItem">The media item (iPublishedContent)</param>
 /// <param name="align">The horizontal alignment of the overlay image or text</param>
 /// <param name="allowUpsizing">Allow the image to be upsized</param>
 /// <param name="antiAlias">Boolean to allow the image to be Anti Aliased</param>
 /// <param name="border">Pass in a int to specifiy the border width</param>
 /// <param name="borderColor">The string of the Hexadecimal color value for the border color</param>
 /// <param name="colorMode">The colour mode of the image (colour, greyscale, sepia)</param>
 /// <param name="quality">A percentage scale of the amount of compression to apply to the image</param>
 /// <param name="constrain">A boolean if to constrain the width and height of the image</param>
 /// <param name="flip">Apply x, y or x & y flipping of the image</param>
 /// <param name="fontSize">An int of the size of the font to be applied to the image</param>
 /// <param name="fontStyle">The font style such as bold, italic to be applied to the image</param>
 /// <param name="font">The path or the name of the font installed on the server</param>
 /// <param name="fontColor">The string of the Hexadecimal color value for the font</param>/// 
 /// <param name="format">The output format of the image to be served, such as gif, jpb, png or tiff</param>
 /// <param name="height">The height of the image you want it to be resized to</param>
 /// <param name="lineHeight">An int of the lineheight used in conjuction with text & font params</param>
 /// <param name="maxHeight">An int of the max height of the image</param>
 /// <param name="maxWidth">An int of the max width of the image</param>
 /// <param name="noCache">A boolean to ensure the image is not cached</param>
 /// <param name="overlayMargin">An int to apply a margin to the overlay item, such as text or image</param>
 /// <param name="pad">An int to apply padding to the image</param>
 /// <param name="rotate">The number of degrees to rotate the image by</param>
 /// <param name="transparent">A bool to ensure the image is returned as transparent or not</param>
 /// <param name="vAlign">The vertical alignment of the overlay image or text</param>
 /// <param name="width">The width of the image you want it to be resized to</param>
 /// <param name="altImage">A path to an alternative image if the original image is not found</param>
 /// <param name="bgColor">The string of the Hexadecimal color value for the background of the image</param>
 /// <param name="overlayImage">A path to the image you wish to display over the top of the image, such as PNG watermark</param>
 /// <param name="text">The text you wish to display over the top of the image</param>
 /// <param name="imageCropperAlias">If using a custom crop, the alias of the cropper property</param>
 /// <param name="imageCropperCropId">If using a custom crop, the id of the corp to use</param>
 /// <param name="furtherOptions">If you need some further querystring option pass them here, e.g. &something=true</param>
 /// <param name="slimmage">Output the image for use with Slimmage</param>
 /// <returns>A string to the ImageGen Url with the parameters passed in</returns>
 public static string GetImageGenUrl(
     this IPublishedContent mediaItem,
     int? width = null,
     int? height = null,
     int? quality = null,
     Align? align = null,
     bool? allowUpsizing = null,
     bool? antiAlias = null,
     int? border = null,
     string borderColor = "",
     ColorMode? colorMode = null,
     bool? constrain = null,
     Flip? flip = null,
     int? fontSize = null,
     FontStyle? fontStyle = null,
     string font = null,
     string fontColor = null,
     Format? format = null,
     int? lineHeight = null,
     int? maxHeight = null,
     int? maxWidth = null,
     bool? noCache = null,
     int? overlayMargin = null,
     bool? pad = null,
     int? rotate = null,
     bool? transparent = null,
     VAlign? vAlign = null,
     string altImage = null,
     string bgColor = null,            
     string overlayImage = null,
     string text = null,
     string imageCropperAlias = null,
     string imageCropperCropId = null,
     string furtherOptions = null,
     bool slimmage = false)
 {
     string imageCropperValue = null;
     if (mediaItem.HasPropertyAndValueAndCrop(imageCropperAlias, imageCropperCropId))
     {
         imageCropperValue = mediaItem.GetPropertyValueHack(imageCropperAlias);
     }
     return mediaItem != null ? GetImageGenUrl(mediaItem.Url, width, height, quality, align, allowUpsizing, antiAlias, border, borderColor, colorMode, constrain, flip, fontSize, fontStyle, font, fontColor, format, lineHeight, maxHeight, maxWidth, noCache, overlayMargin, pad, rotate, transparent, vAlign, altImage, bgColor, overlayImage, text, imageCropperValue, imageCropperCropId, furtherOptions, slimmage) : string.Empty;
 }
예제 #60
0
        public Container(VisualDirection direction, HAlign horizAlign, VAlign vertAlign,
			bool framed, bool wrapAround, IEnumerable<Control> controls)
            : this(direction, horizAlign, vertAlign, framed, wrapAround, 
				controls.Select (c => new Tuple<Control, Reaction<Control>> (c, null)))
        {
        }