/// <summary> /// Constructs the label with an initial string and font ID /// </summary> /// <param name="text"></param> /// <param name="fontID"></param> public GUILabel(string text, int fontID) { Layout = new LabelLayout(); FontID = fontID; Text = text; Name = "Label"; }
/// <summary> /// Constructor /// </summary> public GUILabel() { Layout = new LabelLayout(); FontID = -1; Text = "Label Text"; Name = "Label"; }
/// <summary> /// Equals override /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { LabelLayout layout = (LabelLayout)obj; return(base.Equals(obj) && layout.Color.Equals(this.Color) && layout.Scale.Equals(this.Scale)); }
/// <summary> /// Clones the layout /// </summary> /// <returns></returns> public override object Clone() { LabelLayout layout = new LabelLayout(); layout.SetFrom(this); layout.Color = this.Color; layout.Scale = this.Scale; layout.Skew = this.Skew; layout.DropShadow = this.DropShadow; return(layout); }
/// <summary> /// Applies the provided keyframe to the control, /// overriding all needed properties /// </summary> /// <param name="frame"></param> public override void ApplyKeyFrame(KeyFrame startFrame, KeyFrame endFrame, float factor) { base.ApplyKeyFrame(startFrame, endFrame, factor); if (startFrame == null && endFrame == null) { return; } LabelLayout startLayout = startFrame != null ? startFrame.Layout as LabelLayout : null; LabelLayout endLayout = endFrame != null ? endFrame.Layout as LabelLayout : null; int r, g, b, a; float scaleX, scaleY; float skew; int dropShadow; if (endLayout == null) { r = startLayout.Color.R; g = startLayout.Color.G; b = startLayout.Color.B; a = startLayout.Color.A; scaleX = startLayout.Scale.Width; scaleY = startLayout.Scale.Height; skew = startLayout.Skew; dropShadow = startLayout.DropShadow; } else { r = (int)((float)startLayout.Color.R * (1.0f - factor) + (float)endLayout.Color.R * factor); g = (int)((float)startLayout.Color.G * (1.0f - factor) + (float)endLayout.Color.G * factor); b = (int)((float)startLayout.Color.B * (1.0f - factor) + (float)endLayout.Color.B * factor); a = (int)((float)startLayout.Color.A * (1.0f - factor) + (float)endLayout.Color.A * factor); scaleX = startLayout.Scale.Width * (1.0f - factor) + (float)endLayout.Scale.Width * factor; scaleY = startLayout.Scale.Height * (1.0f - factor) + (float)endLayout.Scale.Height * factor; skew = startLayout.Skew * (1.0f - factor) + endLayout.Skew * factor; dropShadow = (int)(startLayout.DropShadow * (1.0f - factor) + endLayout.DropShadow * factor); } this.Color = Color.FromArgb(a, r, g, b); this.Scale = new SizeF(scaleX, scaleY); this.Skew = skew; this.DropShadow = dropShadow; }
/// <summary> /// Draws the label /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { if (mText == "" || mText == null) { return; } if (mFont == null) { return; } LabelLayout layout = Layout as LabelLayout; mFont.Draw(mText, 0, 0, layout.Size.Width, layout.Size.Height, layout.Color, layout.Scale, HorizontalAlignment, VerticalAlignment, mLeading, mTracking, Skew, mTextFit, DropShadow, InheritedMask); }
/// <summary> /// Clones the layout /// </summary> /// <returns></returns> public override object Clone() { LabelLayout layout = new LabelLayout(); layout.SetFrom(this); layout.Color = this.Color; layout.Scale = this.Scale; layout.Skew = this.Skew; layout.DropShadow = this.DropShadow; return layout; }