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; }
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()) })); }
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)); }
//rowspan public CRow(string Id) { this.Id = Id; this.Align = CHtmlParser.GetDefaultHAlign(); this.VAlign = CHtmlParser.GetDefaultVAlign(); this.mColumns = new Columns(); }
/// <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); }
public Column(string Id) { this.Id = Id; this.Align = CHtmlParser.GetDefaultHAlign(); this.VAlign = CHtmlParser.GetDefaultVAlign(); this.Width = 0; this.mValues = new Values(); }
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; }
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); }
/** 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; }
/** 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(); }
public static FoldableContainer WithLabel(string label, bool framed, HAlign alignment, params Control[] controls) { var header = Visual.Styled( Visual.Margin( Visual.Label(label), left: 2f, right: 8f, top: 2f, bottom: 2f), new VisualStyle(font: new Font(Control.Style.Font, FontStyle.Bold))); return(new FoldableContainer(header, framed, alignment, controls)); }
private HAlign OverwriteHAlign(HAlign AOld, HAlign ANew) { if (ANew == CHtmlParser.GetDefaultHAlign()) { return(AOld); } else { return(ANew); } }
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>>> (); }
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(); }
//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; }
/// <summary> /// Draw a string of text (supports new line characters) /// </summary> /// <param name="canvas">The SKCanvas to draw on</param> /// <param name="text">Text string of text to display</param> /// <param name="xpos">The x coordinate of the text (meaning is dependent on <paramref name="halign"/>)</param> /// <param name="ypos">The y coordinate of the text (meaning is dependent on <paramref name="valign"/>)</param> /// <param name="paint">The SKPaint controlling drawing</param> /// <param name="halign">How to horizontally align the text (default: Left)</param> /// <param name="valign">How to vertically align the text (default: Top)</param> /// <param name="allCapsFont">If the font is in all caps; will ignore space below baseline (default: false)</param> public static void DrawTextExt(this SKCanvas canvas, string text, float xpos, float ypos, SKPaint paint, HAlign halign = HAlign.Left, VAlign valign = VAlign.Top, bool allCapsFont = false) { // Ignore blank text if (string.IsNullOrWhiteSpace(text)) { return; } // Draw after splitting into lines DrawTextExt(canvas, GetLines(text), xpos, ypos, paint, halign, valign, allCapsFont); }
public static XLAlignHorzEnum ToXLAlignH(this HAlign align) { XLAlignHorzEnum result; if (Enum.TryParse(align.ToString(), out result)) { return(result); } else { return(XLAlignHorzEnum.Undefined); } }
//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; }
public Switcher(Vector2 pos, Vector2 size, HAlign hAlign, VAlign vAlign, string ID, List <string> options) : base(pos, size, hAlign, vAlign, true, ContentType.Structural, "") { this.options = options; this.ID = ID; InnerElements.Add(new Button(Vector2.Zero, new Vector2(size.Y, size.Y), HAlign.Left, VAlign.Top, "SwitcherLeft", Style.SwitcherLeftNormal, Style.SwitcherLeftMouseOver, Style.SwitcherLeftPressed)); InnerElements.Add(new Button(Vector2.Zero, new Vector2(size.Y, size.Y), HAlign.Right, VAlign.Top, "SwitcherRight", Style.SwitcherRightNormal, Style.SwitcherRightMouseOver, Style.SwitcherRightPressed)); InnerElements.Add(new Label(Vector2.Zero, HAlign.Center, VAlign.Center, "")); Init(); foreach (UIObject element in InnerElements) { element.parent = this; } }
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> > > (); } }
public static void drawString(WriteableBitmap wb, int x, int y, string str, StringColor sc, int fontsize = 14, HAlign halign = HAlign.LEFT, string fnt = "Segoe WP Light") { TextBlock tb = new TextBlock(); tb.Text = str; tb.FontFamily = new FontFamily(fnt); tb.FontSize = fontsize; if (sc == StringColor.HIGHLIGHT) { //tb.FontFamily = new FontFamily("Segoe WP"); //tb.FontSize = fontsize + 1.0; //y--; tb.Foreground = new SolidColorBrush(foregroundColor); //tb.Foreground = new SolidColorBrush(getColor("PhoneContrastForegroundColor")); tb.FontWeight = System.Windows.FontWeights.Bold; //tb.TextDecorations = TextDecorations.Underline; } else { tb.Foreground = new SolidColorBrush(foregroundColor); if (sc == StringColor.DIMMED) { tb.Opacity = 0.5; } } switch (halign) { case HAlign.CENTER: x -= (int)tb.ActualWidth / 2; break; case HAlign.RIGHT: x -= (int)tb.ActualWidth; break; case HAlign.LEFT: break; } wb.Render(tb, new TranslateTransform() { X = x, Y = y }); if (sc == StringColor.HIGHLIGHT) { // TODO : FIXME, line is not drawn at all ( and even not sure if this is right UI element) Line ln = new Line(); ln.X1 = x; ln.Y1 = y + tb.ActualHeight + 2; ln.X2 = x + tb.ActualWidth; ln.Y2 = y + tb.ActualHeight + 2; wb.Render(ln, new TranslateTransform() { X = x, Y = y }); } }
/** Copies all properties from another TextFormat instance. */ public void CopyFrom(TextFormat format) { _font = format._font; _size = format._size; _color = format._color; //_bold = format._bold; //_italic = format._italic; //_underline = format._underline; _horizontalAlign = format._horizontalAlign; _verticalAlign = format._verticalAlign; _kerning = format._kerning; _leading = format._leading; ChangeEvent?.Invoke(); }
/// <summary> /// Load this object from XML /// </summary> /// <param name="reader"></param> /// <returns></returns> public int LoadFromXml(XmlSimpleElement reader) { foreach (XmlSimpleElement childElement in reader.ChildElements) { switch (childElement.TagName) { case V_SECTION_TEXT: _rawText = childElement.Text; break; case V_SECTION_HALIGN: _hAlignment = (HAlign)childElement.TextAsInt; break; case V_SECTION_VALIGN: _vAlignment = (VAlign)childElement.TextAsInt; break; case V_SECTION_FORECOLOR: _foreColor = Color.FromName(childElement.Text); break; //case V_SECTION_BACKCOLOR: // _backColor = Color.FromName(childElement.Text); // break; case V_SECTION_FONTDATA_SIZE: _fontData.SizeInPoints = childElement.TextAsInt; break; case V_SECTION_FONTDATA_NAME: _fontData.Name = childElement.Text; break; case V_SECTION_FONTDATA_UNDERLINE: _fontData.Underline = (childElement.TextAsBoolean) ? DefaultableBoolean.True : DefaultableBoolean.False; break; case V_SECTION_FONTDATA_BOLD: _fontData.Bold = (childElement.TextAsBoolean) ? DefaultableBoolean.True : DefaultableBoolean.False; break; default: break; } } return(0); }
public void SetCameraOnActor(IActor actor, bool xCenter = true, bool yCenter = true) { HAlign hAlign = HAlign.None; VAlign vAlign = VAlign.None; if (xCenter) { hAlign = HAlign.Center; } if (yCenter) { vAlign = VAlign.Middle; } SetCameraOnActor(actor, hAlign, vAlign); }
/// <summary> /// This method is passed the same UIElementDrawParams structure as GetPhasesToFilter() and a bit flag indicating /// which single draw phase is being performed. The method returns a boolean. If false is returned then the default /// drawing for that phase will be performed. If true is returned for a 'Before' phase then the default drawing /// for that phase will be skipped. Note: returning true for the BeforeDrawElement phase will cause all the other /// phases to be skipped (even if bits for those phases were returned by the call to GetPhasesToFilter). /// Also, if themes are active, returning true for the BeforeDrawTheme phase will skip all phases up to but not /// including the BeforeDrawChildElements phase. The BeforeDrawFocus phase is only called if the control has focus /// (or the forceDrawAsFocused parameter was set to true on the call to the Draw method) and the element's virtual /// DrawsFocusRect property returns true. /// </summary> public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // The TextHAlign set on the label must be honored, so we setup a StringFormat // to use when drawing the text. HAlign align = drawParams.AppearanceData.TextHAlign; StringFormat frmt = new StringFormat(); if (align == HAlign.Left) { frmt.Alignment = StringAlignment.Near; } else if (align == HAlign.Center) { frmt.Alignment = StringAlignment.Center; } else if (align == HAlign.Right) { frmt.Alignment = StringAlignment.Far; } // Draw the text. drawParams.Graphics.DrawString( _text.ToString(), drawParams.Font, drawParams.TextBrush, drawParams.Element.RectInsideBorders, frmt ); if (!_hasScrolled) { // Rearrange the characters in our private copy of the label's Text so that the next // time we draw the string it will be "scrolled" by one character. UpdateText(); // Since we only want to scroll the text once per tick of the timer, // set this flag now to prevent this block of code from executing until the next tick. _hasScrolled = true; } // Returning true prevents the text we just drew from being drawn over. return(true); }
//constructor for UIObjects with child elements public UIObject(Vector2 pos, Vector2 size, HAlign hAlign, VAlign vAlign, bool TriggerMouseEvent, ContentType contentType, string param, List <UIObject> InnerElements) { this.pos = pos; this.size = size; this.TriggerMouseEvent = TriggerMouseEvent; this.contentType = contentType; this.param = param; this.InnerElements = InnerElements; this.hAlign = hAlign; this.vAlign = vAlign; topLeft = pos; scaledSize = pos; foreach (UIObject element in InnerElements) { element.parent = this; } }
/// <summary> /// Aligns target vertically and horisontally inside specified bounds. /// </summary> public static void Align(this DisplayObject target, Rect bounds, HAlign horizontal, VAlign vertical, bool snapToPixels = false) { var objectBounds = target.GetLocalBounds(); var x = objectBounds.x; var y = objectBounds.y; switch (horizontal) { case HAlign.LEFT: x = bounds.xMin; break; case HAlign.CENTER: x = 0.5f * (bounds.xMin + bounds.xMax - objectBounds.width); break; case HAlign.RIGHT: x = bounds.xMax - objectBounds.width; break; } switch (vertical) { case VAlign.TOP: y = bounds.yMin; break; case VAlign.MIDDLE: y = 0.5f * (bounds.yMin + bounds.yMax - objectBounds.height); break; case VAlign.BOTTOM: y = bounds.yMax - objectBounds.height; break; } target.x += x - objectBounds.xMin; target.y += y - objectBounds.yMin; if (snapToPixels) { target.position = target.position.RoundToInt(); } }
/// <summary> /// Moves the pivot point to a certain position within the local coordinate system of the object. /// </summary> public void AlignPivot(HAlign hAlign, VAlign vAlign) { Rectangle bounds = GetBounds(this); SetOrientationChanged(); 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.Y; break; case VAlign.Center: _pivotY = bounds.Y + bounds.Height / 2.0f; break; case VAlign.Bottom: _pivotY = bounds.Y + bounds.Height; break; default: throw new InvalidOperationException("invalid vertical alignment"); } }
public void SetCameraOnActor(IActor actor, HAlign hAlign = HAlign.Center, VAlign vAlign = VAlign.Middle) { float x = Position.X; float y = Position.Y; float z = Position.Z; switch (hAlign) { case HAlign.Left: x = (int)actor.Position.X; break; case HAlign.Center: x = (int)(actor.Position.X - Screen.Width / 2); break; case HAlign.Right: x = (int)(actor.Position.X - actor.BoundingBox.Width + Screen.Width); break; default: break; } switch (vAlign) { case VAlign.Top: y = (int)actor.Position.Y; break; case VAlign.Middle: y = (int)(actor.Position.Y - Screen.Height / 2); break; case VAlign.Bottom: y = (int)(actor.Position.Y - actor.BoundingBox.Height + Screen.Height); break; default: break; } Position = new Vector3(x, y, z); }
public static void ShowStats(HAlign horizontalAlign = HAlign.Left, VAlign verticalAlign = VAlign.Top, float scale = 1f) { float stageWidth = Stage.StageWidth; float stageHeight = Stage.StageHeight; if (_statsDisplay == null) { _statsDisplay = new StatsDisplay(); _statsDisplay.Touchable = false; } Stage.AddChild(_statsDisplay); _statsDisplay.ScaleX = _statsDisplay.ScaleY = scale; if (horizontalAlign == HAlign.Left) { _statsDisplay.X = 0f; } else if (horizontalAlign == HAlign.Right) { _statsDisplay.X = stageWidth - _statsDisplay.Width; } else if (horizontalAlign == HAlign.Center) { _statsDisplay.X = (stageWidth - _statsDisplay.Width) / 2; } if (verticalAlign == VAlign.Top) { _statsDisplay.Y = 0f; } else if (verticalAlign == VAlign.Bottom) { _statsDisplay.Y = stageHeight - _statsDisplay.Height; } else if (verticalAlign == VAlign.Center) { _statsDisplay.Y = (stageHeight - _statsDisplay.Height) / 2; } }
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]; }
public void Parse(String[] items) { if (items.Length == Items) { Angle = System.Convert.ToInt32(items[1]); Position.X = System.Convert.ToInt32(items[2]); Position.Y = System.Convert.ToInt32(items[3]); Size = System.Convert.ToInt32(items[4]); Hiden = System.Convert.ToInt32(items[5]); Part = System.Convert.ToInt32(items[6]); Dmg = System.Convert.ToInt32(items[7]); Text = items[8].Trim('"'); Italic.Parse(items[9]); Bold = System.Convert.ToInt32(items[10]); HAlign.Parse(items[11]); VAlign.Parse(items[12]); } else { throw new Exception("LibPolygon public class parse error. Unexpected number of items."); } }
public Container(VisualDirection direction, HAlign horizAlign, VAlign vertAlign, bool framed, bool wrapAround, params Control[] controls) : this(direction, horizAlign, vertAlign, framed, wrapAround, (IEnumerable <Control>)controls) { }
/// <summary> /// To set horizontal 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> /// <param name="halign"></param> internal static void SetHorizontalAlignment(IWorkbook workbook, int sheetIndex, int rowIndex, int colIndex, HAlign halign) { SpreadsheetGear.IRange Range; try { // Get a reference to a cell. Range = workbook.Worksheets[sheetIndex].Cells[rowIndex, colIndex]; Range.HorizontalAlignment = halign; } catch (Exception ex) { // new ApplicationException(ex.ToString()); } }
/// <summary> /// To set horizontal 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="halign"></param> internal static void SetHorizontalAlignment(IWorkbook workbook, int sheetIndex, int startRowIndex, int startColIndex, int endRowIndex, int endColInex, HAlign halign) { SpreadsheetGear.IRange Range; try { // Get a reference to a cell. Range = workbook.Worksheets[sheetIndex].Cells[startRowIndex, startColIndex, endRowIndex, endColInex]; Range.HorizontalAlignment = halign; } catch (Exception ex) { // ExceptionFacade.ThrowException(ex); } }
/// <summary> /// To set horizontal alignment /// </summary> /// <param name="sheetIndex">Worksheet index starts from zero.</param> /// <param name="rowIndex"></param> /// <param name="colIndex"></param> /// <param name="halign"></param> public void SetHorizontalAlignment(int sheetIndex, int rowIndex, int colIndex, HAlign halign) { try { ExcelHelper.SetHorizontalAlignment(this.Workbook, sheetIndex, rowIndex, colIndex, halign); } catch (Exception ex) { // ExceptionFacade.ThrowException(ex); } }
public _Anchor(Visual visual, HAlign horizAlign, VAlign vertAlign) : base(visual) { HorizAlign = horizAlign; VertAlign = vertAlign; }
public Connected(Control source, HAlign horizAlign, VAlign vertAlign) { Source = source; HorizAlign = horizAlign; VertAlign = vertAlign; }
/// <summary> /// To set horizontal 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="halign"></param> public void SetHorizontalAlignment(int sheetIndex, int startRowIndex, int startColIndex, int endRowIndex, int endColIndex, HAlign halign) { try { ExcelHelper.SetHorizontalAlignment(this.Workbook, sheetIndex, startRowIndex, startColIndex, endRowIndex, endColIndex, halign); } catch (Exception ex) { // throw ex; } }
public _Flow(IEnumerable<Visual> items, VisualDirection direction, HAlign horizAlign, VAlign vertAlign, SizeF containerSize) : base(direction, horizAlign, vertAlign) { Items = items.ToArray (); ContainerSize = containerSize; }
internal static string AlignmentToString(HAlign a, DirState ds) { switch (a) { case HAlign.AlignLeft: return (ds != DirState.DirRTL) ? "Left" : "Right"; case HAlign.AlignRight: return (ds != DirState.DirRTL) ? "Right" : "Left"; case HAlign.AlignCenter: return "Center"; case HAlign.AlignJustify: return "Justify"; case HAlign.AlignDefault: default: return ""; } }
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; }
public Container(VisualDirection direction, HAlign horizAlign, VAlign vertAlign, bool framed, bool wrapAround, params Control[] controls) : this(direction, horizAlign, vertAlign, framed, wrapAround, (IEnumerable<Control>)controls) { }
/// <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); } }
public Legend(Layout _layout, HAlign _hAlign, VAlign _vAlign, int _borderwidth) { borderWidth = _borderwidth; layout = _layout.ToString(); hAlign = _hAlign.ToString(); vAlign = _vAlign.ToString(); }
/// <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); }
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))) { }
/// <summary> /// Create a vertical stack. /// </summary> public static Visual VStack(HAlign alignment, IEnumerable<Visual> visuals) { return new _Stack (visuals, VisualDirection.Vertical, alignment, VAlign.Top); }
public void SetColumn(string key, string caption = "", ImmasColumnStyle columnStyle = ImmasColumnStyle.Normal, int width = -1, HAlign halign = HAlign.Center, VAlign valign = VAlign.Middle, bool primaryKey = false, bool readOnly = false, bool hidden = false) { // set key UltraGridColumn column = this.DefaultBand.Columns.Add(key); // set header align this.DefaultBand.Columns[key].Header.Appearance.TextHAlign = HAlign.Center; // set caption if (caption != "") { this.DefaultBand.Columns[key].Header.Caption = caption; } // set columnType switch (columnStyle) { case (ImmasColumnStyle.TextBox): case (ImmasColumnStyle.Normal): this.DefaultBand.Columns[key].Style = ColumnStyle.Edit; break; case (ImmasColumnStyle.CheckBox): this.DefaultBand.Columns[key].Style = ColumnStyle.CheckBox; break; case (ImmasColumnStyle.ComboBox): this.DefaultBand.Columns[key].Style = ColumnStyle.DropDown; this.DefaultBand.Columns[key].ButtonDisplayStyle = ButtonDisplayStyle.Always; break; case (ImmasColumnStyle.Button): this.DefaultBand.Columns[key].Style = ColumnStyle.Button; break; } // set width if (width > -1) { this.DefaultBand.Columns[key].Width = width; } // set Vertical align switch (valign) { case (VAlign.Top): this.DefaultBand.Columns[key].CellAppearance.TextVAlign = VAlign.Top; break; case (VAlign.Middle): this.DefaultBand.Columns[key].CellAppearance.TextVAlign = VAlign.Middle; break; case (VAlign.Bottom): this.DefaultBand.Columns[key].CellAppearance.TextVAlign = VAlign.Bottom; break; case (VAlign.Default): this.DefaultBand.Columns[key].CellAppearance.TextVAlign = VAlign.Default; break; } // set Horizontal align switch (halign) { case (HAlign.Center): this.DefaultBand.Columns[key].CellAppearance.TextHAlign = HAlign.Center; break; case (HAlign.Left): this.DefaultBand.Columns[key].CellAppearance.TextHAlign = HAlign.Left; break; case (HAlign.Right): this.DefaultBand.Columns[key].CellAppearance.TextHAlign = HAlign.Right; break; case (HAlign.Default): this.DefaultBand.Columns[key].CellAppearance.TextHAlign = HAlign.Default; break; } // set hidden if (hidden) { this.DefaultBand.Columns[key].Hidden = true; } if (readOnly == true) { this.ReadOnlyColumns[key] = column; } // set primaryKey if (primaryKey == true) { this.PrimaryKeyColumns[key] = column; } }
/// <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 (); }
/// <summary> /// To set horizontal alignment /// </summary> /// <param name="sheetIndex">Worksheet index starts from zero.</param> /// <param name="rowIndex"></param> /// <param name="colIndex"></param> /// <param name="halign"></param> public void SetHorizontalAlignment(int sheetIndex, int rowIndex, int colIndex, HAlign halign) { try { ExcelHelper.SetHorizontalAlignment(this.Workbook, sheetIndex, rowIndex, colIndex, halign); } catch (Exception ex) { // new ApplicationException(ex.ToString()); } }
public void SetColAlign(HAlign colalign) { switch (this.selKind_) { case TableCellKind.ColSelected: { int i = 0; while (i < this.RowCount) { MCell cell = this.Get(i, this.curCol); if (cell != null) { cell.columnAlign = colalign; } i++; } break; } case TableCellKind.RowColSelected: { this.Get(this.curRow, this.curCol).columnAlign = colalign; return; } case TableCellKind.BottomSelected: { MRow row = this.GetRow(this.curRow); if (row.isLabeled && (row.cell != null)) { row.cell.columnAlign = colalign; } return; } } }
/// <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"); } }
/// <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); }
/// <summary> /// Create a vertical stack. /// </summary> public static Visual VStack(HAlign alignment, params Visual[] visuals) { return new _Stack (visuals, VisualDirection.Vertical, alignment, VAlign.Top); }
public _Container(VisualDirection direction, HAlign horizAlign, VAlign vertAlign) { Direction = direction; HorizAlign = horizAlign; VertAlign = vertAlign; }
internal static bool ConvertToHAlign(ConverterState converterState, string alignName, ref HAlign align) { if (alignName.Length == 0) { return false; } align = (HAlign)BasicLookup(HAlignTable, alignName); return true; }
public _Connector(Visual visual, _Anchor target, VisualDirection direction, HAlign horizAlign, VAlign vertAlign, ConnectorKind kind) : base(visual, horizAlign, vertAlign) { Target = target; Direction = direction; Kind = kind; }