private void DrawLabelVartical(LabelContent labelContent, SKCanvas canvas, float x, float y) { using var toLabel = this._labelDrawer.Draw(TO_HEADER_TEXT, labelContent.ToAddress); using var fromLabel = this._labelDrawer.Draw(FROM_HEADER_TEXT, labelContent.FromAddress); canvas.DrawBitmap(toLabel, x, y); canvas.DrawBitmap(fromLabel, x, y + this._layoutProperty.LabelHeight); canvas.Save(); }
private void DrawLabel(LabelContent labelContent, SKCanvas canvas, float x, float y) { if (this._layoutProperty.LabelOrientation == LabelOrientation.Hirizontal) { this.DrawLabelHorizontal(labelContent, canvas, x, y); } else { this.DrawLabelVartical(labelContent, canvas, x, y); } }
protected override void OnShown(System.EventArgs e) { //SuspendLayouts() Tag = null; int i = (int)DefaultButton; if (i > 0 && i <= VButtons.Length) { AcceptButton = (IButtonControl)Buttons[i - 1]; Buttons[i - 1].Focus(); } else { LabelContent.Focus(); } //'If LabelTitle.Visible AndAlso LabelContent.Visible Then //' LabelTitle.Margin = New Padding(LabelTitle.Margin.Left, LabelTitle.Margin.Top, LabelTitle.Margin.Right, 0) //' LabelContent.Margin = New Padding(LabelContent.Margin.Left, If(_drawGradient, 16, LabelContent.Margin.Top), LabelContent.Margin.Right, 16) //'End If //'If Not String.IsNullOrEmpty(ExpandedInformation) AndAlso Expanded Then //' Expanded = True //'End If //'MakeCenter() //'ResumeLayouts() if (Sound != null) { Sound.Play(); } Activate(); uint result = 0; if (Native.SystemParametersInfo(Native.SPI_GETSNAPTODEFBUTTON, 0, ref result, 0)) { if (result != 0) { var c = FindFocusedControl(); if (c != null) { var p = c.PointToScreen(new Point(c.Width / 2, c.Height / 2)); Cursor.Position = p; } } } base.OnShown(e); }
/// <summary> /// Ensure bounds /// </summary> /// <param name="content">Item on canvas</param> private void MeasureToFit(LabelContent content) { if (content.ActualWidth + content.ViewModel.Left >= ModelDesignerCanvas.ActualWidth) { content.ViewModel.Left = ModelDesignerCanvas.ActualWidth - content.ActualWidth - 10; } if (content.ActualHeight + content.ViewModel.Top >= ModelDesignerCanvas.ActualHeight) { content.ViewModel.Top = ModelDesignerCanvas.ActualHeight - content.ActualHeight - 10; } }
public override void OnPreviewSettings() { const int itemCount = 3; var width = EditorGUIUtility.currentViewWidth / (itemCount * 2 + 3); EditorGUIUtility.labelWidth = width; EditorGUIUtility.fieldWidth = width; labelContent = (LabelContent)EditorGUILayout.EnumPopup("Label content", labelContent); Caches.Instance.shapePreviewMesh = EditorGUILayout.ObjectField(Caches.Instance.shapePreviewMesh, typeof(Mesh), false) as Mesh; Caches.Instance.shapePreviewMaterial = EditorGUILayout.ObjectField(Caches.Instance.shapePreviewMaterial, typeof(Material), false) as Material; }
/// <summary> /// Add new label to canvas /// </summary> /// <param name="viewModel">Label viewmodel</param> private void AddLabelElement(LabelViewModel viewModel) { var content = new LabelContent(viewModel); RoutedEventHandler loadedEventHandler = null; loadedEventHandler = (sender, args) => { MeasureToFit(content); DesignerCanvas.SetZIndex(content, DesignerCanvas.LabelUnselectedZIndex); DesignerCanvas.SetTop(content, viewModel.Top); DesignerCanvas.SetLeft(content, viewModel.Left); content.Height = content.ActualHeight + 30; content.Width = content.ActualWidth + 30; viewModel.Height = content.Height; viewModel.Width = content.Width; content.Loaded -= loadedEventHandler; }; content.Loaded += loadedEventHandler; ModelDesignerCanvas.Children.Add(content); }
protected override void OnShown(System.EventArgs e) { //SuspendLayouts() Tag = null; int i = (int)DefaultButton; if (i > 0 && i <= VButtons.Length) { AcceptButton = (IButtonControl)Buttons[i - 1]; Buttons[i - 1].Focus(); } else { LabelContent.Focus(); } //'If LabelTitle.Visible AndAlso LabelContent.Visible Then //' LabelTitle.Margin = New Padding(LabelTitle.Margin.Left, LabelTitle.Margin.Top, LabelTitle.Margin.Right, 0) //' LabelContent.Margin = New Padding(LabelContent.Margin.Left, If(_drawGradient, 16, LabelContent.Margin.Top), LabelContent.Margin.Right, 16) //'End If //'If Not String.IsNullOrEmpty(ExpandedInformation) AndAlso Expanded Then //' Expanded = True //'End If //'MakeCenter() //'ResumeLayouts() if (Sound != null) { Sound.Play(); } Activate(); base.OnShown(e); }
void Start() { this.InitMesh(); this.startColor.a = this.battleText.settings.fadeInStart; GUIFont font = null; if(DataHolder.BattleSystemData().textSkin != null) font = DataHolder.Fonts().GetFont(DataHolder.BattleSystemData().textSkin.font); if(font != null) { LabelContent label = new LabelContent(new GUIContent(this.battleText.text), 0, 0, this.battleText.color, this.battleText.shadowColor, font); Texture2D texture = TextureDrawer.GetCleanTexture( TextureDrawer.GetNextPowerOfTwo(label.bounds.width), TextureDrawer.GetNextPowerOfTwo(label.bounds.height)); texture = font.AddTextTexture(texture, label, 0, new Vector2((texture.width-label.bounds.width)/2, (texture.height-label.bounds.height)/2), this.battleText.settings.showShadow, this.battleText.settings.shadowOffset); texture.Apply(); this.renderer.material.mainTexture = texture; transform.position = new Vector3(0, -0.5f, 0); this.UpdateGUISize(false, GameHandler.GUIHandler().GetScreenRatio()); } else GameObject.Destroy(this.gameObject); }
/// <summary> /// Draw shape preview meshes and gizmos. /// </summary> /// <param name="shape">The shape to draw.</param> /// <param name="camera"></param> /// <param name="content"></param> /// <returns>Information to draw gizmos.</returns> public static void DrawShapePreview(Shape shape, [NotNull] Camera camera, LabelContent content) { if (shape is null || !Preferences._.shapePreviewMesh || !Preferences._.shapePreviewMaterial) { return; } var prs = new List <Tuple <Vector3, Quaternion, float> >(); for (var i = 0; i < shape.Count; i++) { var position = shape[i].position; var speed = shape[i].velocity.magnitude; var lookRotation = speed == 0 ? Quaternion.identity : Quaternion.LookRotation(shape[i].velocity); var size = shape[i].DefaultSize ? Vector3.one : shape[i].size; var block = new MaterialPropertyBlock(); block.SetColor(ColorIndex, shape[i].DefaultColor ? Color.white : shape[i].color); Graphics.DrawMesh(Preferences._.shapePreviewMesh, Matrix4x4.TRS(position, lookRotation, size), Preferences._.shapePreviewMaterial, 0, camera, 0, block); prs.Add(new Tuple <Vector3, Quaternion, float>(position, lookRotation, speed)); } // clear depth camera.Render(); // draw gizmos Handles.SetCamera(camera); var index = 0; foreach (var(position1, rotation, speed1) in (IEnumerable <Tuple <Vector3, Quaternion, float> >)prs) { Handles.zTest = CompareFunction.Greater; Handles.color = Color.red; Handles.ArrowHandleCap(0, position1, rotation, speed1 / 4, EventType.Repaint); Handles.zTest = CompareFunction.LessEqual; Handles.color = Color.green; Handles.ArrowHandleCap(0, position1, rotation, speed1 / 4, EventType.Repaint); Handles.zTest = CompareFunction.Always; string text; switch (content) { case LabelContent.Index: text = index.ToString(); break; case LabelContent.Speed: text = speed1.ToString(CultureInfo.CurrentCulture); break; case LabelContent.Position: text = position1.ToString(); break; case LabelContent.None: text = ""; break; default: throw new ArgumentOutOfRangeException(); } Handles.Label(position1, text); index++; } }
public MultiContent(string text, DialoguePosition dp) { this.font = DataHolder.Fonts().GetFont(dp.skin.font); GUIStyle shadowStyle = new GUIStyle(dp.skin.label); shadowStyle.normal.textColor = DataHolder.Color(1); GUIStyle textStyle = new GUIStyle(dp.skin.label); textStyle.wordWrap = false; TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing); textPosition.bounds.width -= (dp.boxPadding.x + dp.boxPadding.z); textPosition.bounds.height -= (dp.boxPadding.y + dp.boxPadding.w); this.originalText = text; this.label = new LabelContent[0]; this.currentColor = 0; this.shadowColor = -1; int oldColor = 0; int oldShadowColor = -1; this.textPos = 0; int i = 0; int nl = 0; int fs = 0; int skip = 0; bool lineBreak = false; this.xPos = 0; this.yPos = 0; bool setNextX = false; bool setNextY = false; float nextX = 0; float nextY = 0; string addstring = ""; bool addSpace = false; bool finished = false; Vector2 v = Vector2.zero; Color tCol; Color sCol; Texture2D icon = null; GUIContent part = null; LabelContent nextLabel; while(!finished) { skip = 0; lineBreak = false; oldColor = this.currentColor; oldShadowColor = this.shadowColor; icon = null; part = null; tCol = DataHolder.Color(this.currentColor); if(this.shadowColor == -1 || this.shadowColor >= DataHolder.Colors().GetDataCount()) { sCol = DataHolder.Color(1); } else { sCol = DataHolder.Color(this.shadowColor); } fs = text.IndexOf("#", this.textPos); nl = text.IndexOf("\n", this.textPos); if(fs != -1 && (nl == -1 || fs < nl)) { i = fs; } else { i = nl; } if(i == -1) { i = text.Length - 1; finished = true; } if(setNextX) { this.xPos = nextX; setNextX = false; } if(setNextY) { this.yPos = nextY; setNextY = false; } if(!finished) { if (text[i].ToString() == "#") { if((text.Length - i) >= 1) { string nextChar = text[i+1].ToString(); if(nextChar == "c" || nextChar == "s") { // set text color for the next part int nS = text.IndexOf("#", i+1); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; try { if(nextChar == "c") { this.currentColor = int.Parse(sub.Substring(2, sub.Length-3)); } else if(nextChar == "s") { this.shadowColor = int.Parse(sub.Substring(2, sub.Length-3)); } } catch(System.Exception e) { Debug.Log(e.Message); if(nextChar == "c") { this.currentColor = 0; } else if(nextChar == "s") { this.shadowColor = -1; } } } } else if(nextChar == "!") { this.currentColor = 0; this.shadowColor = -1; skip = 3; if((text.Length - (i+skip-1)) >= 1 && (text.Substring(i+skip-1, 1) == "\n" || text.Substring(i+skip-1, 1) == "\r")) { lineBreak = true; skip += 1; } } else if(nextChar == "#") { i++; skip = 2; } else if(nextChar == "p") { nextChar = text[i+2].ToString(); // set x or y position for the next text part int nS = text.IndexOf("#", i+2); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; try { if(nextChar == "x") { nextX = float.Parse(sub.Substring(3, sub.Length-4)); setNextX = true; } else if(nextChar == "y") { nextY = float.Parse(sub.Substring(3, sub.Length-4)); setNextY = true; } } catch(System.Exception e) { Debug.Log(e.Message); } } } else if(nextChar == "i" && text[i+2].ToString() == "q") // icons { int nS = text.IndexOf("#", i+4); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; sub = text.Substring(i+5, nS-(i+5)); int index = int.Parse(sub); sub = text.Substring(i+3, 2); if(sub == "sv") icon = DataHolder.StatusValues().GetIcon(index); else if(sub == "se") icon = DataHolder.Effects().GetIcon(index); else if(sub == "el") icon = DataHolder.Elements().GetIcon(index); else if(sub == "st") icon = DataHolder.SkillTypes().GetIcon(index); else if(sub == "sk") icon = DataHolder.Skills().GetIcon(index); else if(sub == "it") icon = DataHolder.ItemTypes().GetIcon(index); else if(sub == "im") icon = DataHolder.Items().GetIcon(index); else if(sub == "ir") icon = DataHolder.ItemRecipes().GetIcon(index); else if(sub == "ep") icon = DataHolder.EquipmentParts().GetIcon(index); else if(sub == "wp") icon = DataHolder.Weapons().GetIcon(index); else if(sub == "am") icon = DataHolder.Armors().GetIcon(index); else if(sub == "cl") icon = DataHolder.Classes().GetIcon(index); else if(sub == "ch") icon = DataHolder.Characters().GetIcon(index); else if(sub == "en") icon = DataHolder.Enemies().GetIcon(index); else icon = null; } } else { skip = 2; } } else { skip = 1; } } else if((text.Length - i) >= 1 && (text.Substring(i, 1) == "\n" || text.Substring(i, 1) == "\r")) { lineBreak = true; skip = 2; } i--; } if((i-this.textPos+1) > 0) { if(addSpace) addstring = " "; else addstring = ""; part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); if ((this.xPos+v.x) > textPosition.bounds.width) { i = this.textPos+font.GetFittingTextLength(part.text, textPosition.bounds.width-this.xPos); lineBreak = true; icon = null; skip = 0; int tmp = i; part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); v = font.GetTextSize(part.text); while (this.xPos+v.x > textPosition.bounds.width) { i--; if((i-this.textPos+1) > 0) { part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); } else { part = new GUIContent(""); } v = font.GetTextSize(part.text); tmp = i+1; } while(" " != text[i].ToString() && i>(this.textPos+1)) { i--; } if((i-this.textPos+1) > 0 && " " == text[i].ToString()) { part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); } else { i = tmp; } nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); this.currentColor = oldColor; this.shadowColor = oldShadowColor; finished = false; } this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; if(!lineBreak) { addSpace = part.text[part.text.Length-1].ToString() == " "; } } if(icon != null) { part = new GUIContent(icon); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); //this.xPos += font.GetTextSize(".").x; if(this.xPos+v.x <= textPosition.bounds.width) { this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; addSpace = true; icon = null; } else { lineBreak = true; } } if(lineBreak) { this.xPos = 0; this.yPos += v.y + textPosition.lineSpacing; addSpace = false; if(i+skip < text.Length && " " == text[i+skip].ToString()) { i++; } if((this.yPos+v.y) > (textPosition.bounds.height) && !dp.scrollable) { finished = true; } else if(icon != null) { part = new GUIContent(icon); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); //this.xPos += font.GetTextSize(".").x; this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; addSpace = true; icon = null; } } else if(finished) { this.xPos = 0; this.yPos += v.y + textPosition.lineSpacing; } this.textPos = i + skip; } }
public Texture2D AddTextTexture(Texture2D texture, LabelContent label, float paddingX, Vector2 p2Offset, bool showShadow, Vector2 shadowOffset) { return this.AddTextTexture(texture, label.content.text, label.bounds, label.textColor, label.shadowColor, paddingX, p2Offset, showShadow, shadowOffset, true); }
public Texture2D AddTextTexture(Texture2D texture, LabelContent label, DialoguePosition dp, Vector2 p2Offset) { return this.AddTextTexture(texture, label, dp.boxPadding.x, p2Offset, dp.showShadow, dp.shadowOffset); }
public void Draw(LabelContent labelContent) { this.Draw(new[] { labelContent }); }
public static LabelContent[] Add(LabelContent n, LabelContent[] list) { ArrayList tmp = new ArrayList(); foreach(LabelContent str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(LabelContent)) as LabelContent[]; }
public static LabelContent[] Remove(int index, LabelContent[] list) { ArrayList tmp = new ArrayList(); foreach(LabelContent str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(LabelContent)) as LabelContent[]; }
internal object CalculateLabelContent(LabelContent content, string labelFormat) { switch (content) { case LabelContent.XValue: return(this.XData.ToString(labelFormat, CultureInfo.CurrentCulture)); case LabelContent.YValue: if (!double.IsNaN(YData)) { labelFormat = string.IsNullOrEmpty(labelFormat) ? "0.##" : labelFormat; //Round off default decimal point to two digits while segment dragging-WRT-4212 return(this.YData.ToString(labelFormat, CultureInfo.CurrentCulture)); } else { return(""); } case LabelContent.Percentage: double grandPercentage; grandPercentage = (Series is HistogramSeries) ? this.Series.GetGrandTotal((Series as HistogramSeries).ActualYValues) : this.Series.GetGrandTotal(this.Series.ActualSeriesYValues[0]); labelFormat = string.IsNullOrEmpty(labelFormat) ? "0.##" : labelFormat; //WP-559 - decimal digits round-off to 2 positions by default return((this.YData / grandPercentage * 100).ToString(labelFormat, CultureInfo.CurrentCulture) + "%"); case LabelContent.YofTot: double grandTotal; grandTotal = (Series is HistogramSeries) ? this.Series.GetGrandTotal((Series as HistogramSeries).ActualYValues) : this.Series.GetGrandTotal(this.Series.ActualSeriesYValues[0]); labelFormat = string.IsNullOrEmpty(labelFormat) ? "0.##" : labelFormat; return(this.YData.ToString(labelFormat, CultureInfo.CurrentCulture) + " of " + grandTotal.ToString(labelFormat, CultureInfo.CurrentCulture)); case LabelContent.DateTime: object datetimeContent = null; if (this.Series.IsIndexed) { List <double> dateValues = this.Series.ActualXValues as List <double>; if (dateValues != null) { datetimeContent = dateValues[(int)this.XData].FromOADate().ToString(this.Series.adornmentInfo.SegmentLabelFormat, CultureInfo.CurrentCulture); } else { List <string> stringValues = this.Series.ActualXValues as List <string>; DateTime date = DateTime.MinValue; DateTime.TryParse(stringValues[(int)this.XData], out date); datetimeContent = date.ToString(this.Series.adornmentInfo.SegmentLabelFormat, CultureInfo.CurrentCulture); } } else { datetimeContent = (Series is HistogramSeries) ? this.XPos.FromOADate().ToString(this.Series.adornmentInfo.SegmentLabelFormat, CultureInfo.CurrentCulture) : this.XData.FromOADate().ToString(this.Series.adornmentInfo.SegmentLabelFormat, CultureInfo.CurrentCulture); } return(datetimeContent); case LabelContent.LabelContentPath: return(this); default: if (!double.IsNaN(YData)) { labelFormat = string.IsNullOrEmpty(labelFormat) ? "0.##" : labelFormat; return(this.YData.ToString(labelFormat, CultureInfo.CurrentCulture)); } else { return(""); } } }
public void AddName(string name) { if("" != name && this.nameTexture == null) { GUIFont font = null; if(dp.nameSkin != null && dp.nameSkin.font != null) font = DataHolder.Fonts().GetFont(dp.nameSkin.font); else if(dp.skin != null && dp.skin.font != null) font = DataHolder.Fonts().GetFont(dp.skin.font); if(font != null) { if(dp.isDragWindow) { this.nameTexture = font.GetTextTexture(name); this.nameTexture.Apply(); } else { LabelContent nameLabel = new LabelContent(new GUIContent(name), 0, 0, DataHolder.Color(0), DataHolder.Color(1), font); dp.nameBounds.width = nameLabel.bounds.width+dp.namePadding.x+dp.namePadding.z; this.nameTexture = TextureDrawer.GetCleanTexture( TextureDrawer.GetNextPowerOfTwo(dp.nameBounds.width), TextureDrawer.GetNextPowerOfTwo(dp.nameBounds.height)); nameLabel.bounds.x = dp.namePadding.x+(this.nameTexture.width-dp.nameBounds.width)/2; nameLabel.bounds.y = dp.namePadding.y+(this.nameTexture.height-dp.nameBounds.height)/2; Rect b2 = new Rect((this.nameTexture.width-dp.nameBounds.width)/2, (this.nameTexture.height-dp.nameBounds.height)/2, dp.nameBounds.width, dp.nameBounds.height); if(dp.showNameBox) { this.nameTexture = TextureDrawer.SetImageTexture( this.nameTexture, b2, GameHandler.GetSkin(dp.skin).box); } this.nameTexture = font.AddTextTexture(this.nameTexture, nameLabel, 0, Vector2.zero, dp.showShadow, dp.shadowOffset); this.nameTexture.Apply(); } } } }