public Column(string dataColumnName, int width) { Header = new Text(); Style = new TextStyle(); this.width = width; this.Header.Contents = this.Expression = dataColumnName; }
/// <summary> /// 拷贝的构造函数。 /// </summary> /// <param name="textStyle">TextStyle对象实例。</param> public TextStyle(TextStyle textStyle) { if (textStyle == null) throw new ArgumentNullException(); this.Align = textStyle.Align; if (textStyle.BackColor != null) this.BackColor = new Color(textStyle.BackColor); this.BackOpaque = textStyle.BackOpaque; this.Bold = textStyle.Bold; this.FontHeight = textStyle.FontHeight; this.FontName = textStyle.FontName; this.FontScale = textStyle.FontScale; this.FontWeight = textStyle.FontWeight; this.FontWidth = textStyle.FontWidth; if (textStyle.ForeColor != null) this.ForeColor = new Color(textStyle.ForeColor); this.Italic = textStyle.Italic; this.ItalicAngle = textStyle.ItalicAngle; this.OpaqueRate = textStyle.OpaqueRate; this.Outline = textStyle.Outline; this.Rotation = textStyle.Rotation; this.Shadow = textStyle.Shadow; this.SizeFixed = textStyle.SizeFixed; this.Strikeout = textStyle.Strikeout; this.Underline = textStyle.Underline; }
//========================================================================================= public BoundedElement(TextStyle bodyStyle, TextStyle boundStyle, string startSymbols, string endSymbols) : base(bodyStyle) { this.BoundStyle = boundStyle; this.StartSymbols = startSymbols; this.EndSymbols = endSymbols; }
private static void write(string text, TextStyle s) { if (s != null) { if (s.Bold) Out("<b>"); if (s.Italic) Out("<i>"); if (s.Transparent) Out("<span style=\"color:" + GetHTMLColor(s.ForeColor) + "\">"); else Out("<span style=\"color:" + GetHTMLColor(s.ForeColor) + ";background-color:" + GetHTMLColor(s.BackColor) + ";\">"); } text = text.Replace("&", "&"); text = text.Replace("<", "<"); text = text.Replace(">", ">"); text = text.Replace(" ", " "); text = text.Replace("\t", " "); Out(text); if (s != null) { Out("</span>"); if (s.Italic) Out("</i>"); if (s.Bold) Out("</b>"); } }
/// <summary> /// Initializes a new instance of the <see cref="Common.App.ResourceTypes.Loaders.TextStyleLoader"/> class. /// </summary> /// <param name="path">Path to text style.</param> public TextStyleLoader(string path) { DebugEx.VerboseFormat("Created TextStyleLoader(path = {0}) object", path); mPath = path; mTextStyle = null; }
public Column(DataColumn col, int width) { Header = new Text(); Style = new TextStyle(); this.width = width; this.Header.Contents = this.Expression = col.ColumnName; }
protected static void ApplyTextStyles(TextElement textElement, TextStyle style) { if (style != null) { SetBinding(style, TextStyle.FontSizeProperty, () => { var fontSize = style.FontSize * style.FontSizeRatioValue(); if (fontSize > 0) { textElement.FontSize = fontSize; } }); SetBinding(style, TextStyle.FontSizeRatioProperty, () => { var fontSize = style.FontSize * style.FontSizeRatioValue(); if (fontSize > 0) { textElement.FontSize = fontSize; } }); BindingOperations.SetBinding(textElement, TextElement.FontFamilyProperty, CreateBinding(style, "FontFamily")); BindingOperations.SetBinding(textElement, TextElement.FontStyleProperty, CreateBinding(style, "FontStyle")); BindingOperations.SetBinding(textElement, TextElement.FontWeightProperty, CreateBinding(style, "FontWeight")); BindingOperations.SetBinding(textElement, TextElement.ForegroundProperty, CreateBinding(style, "Foreground")); } }
//========================================================================================= public Token(string typeName, string text, TextPoint start, TextPoint end, TextStyle style) { this.TokenTypeName = typeName; this.Text = text; this.Start = start; this.End = end; this.Style = style; }
public static void AddPatternString(string Text,Row Row,Pattern Pattern,TextStyle Style,Segment Segment,bool HasError) { Word x= Row.Add (Text); x.Style = Style; x.Pattern = Pattern; x.HasError =HasError; x.Segment =Segment; }
public override void SetParagraphStyle(TextStyle style, TextAlign align) { _wordapp.Selection.set_Style(style.ToString()); if (align == TextAlign.Right) _wordapp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight; else if (align == TextAlign.Center) _wordapp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; }
public void InitializeStyle() { library = new Font.Library(); library.LoadUFFMemory( Resources.UberConsoleUFF, Industry.FX.Font.GreyscaleAsForecolorAlphaScaledBitmapColorTransform ); ltgray4 = new Font( library, "Uber Console", 4 ) { Color = Color.FromArgb(unchecked((int)0x44000000u)) }; ltblue4 = new Font( library, "Uber Console", 4 ) { Color = Color.FromArgb(unchecked((int)0x440000BBu)) }; ltgray5 = new Font( library, "Uber Console", 5 ) { Color = Color.FromArgb(unchecked((int)0x44000000u)) }; ltblue5 = new Font( library, "Uber Console", 5 ) { Color = Color.FromArgb(unchecked((int)0x440000BBu)) }; gray4 = new Font( library, "Uber Console", 4 ) { Color = Color.FromArgb(unchecked((int)0x88000000u)) }; gray5 = new Font( library, "Uber Console", 5 ) { Color = Color.FromArgb(unchecked((int)0x88000000u)) }; blue4 = new Font( library, "Uber Console", 4 ) { Color = Color.Blue }; blue5 = new Font( library, "Uber Console", 5 ) { Color = Color.Blue }; purple = new Font( library, "Uber Console", 5 ) { Color = Color.Purple }; black = new Font( library, "Uber Console", 5 ) { Color = Color.Black }; red4 = new Font( library, "Uber Console", 4 ) { Color = Color.FromArgb(unchecked((int)0x88FF0000u)) }; red5 = new Font( library, "Uber Console", 5 ) { Color = Color.Red }; orange = new Font( library, "Uber Console", 5 ) { Color = Color.Orange }; semiignore = new TextStyle() { Timestamp = new ColumnStyle() { Font = gray4, Width = 35 } , Nickname = new ColumnStyle() { Font = gray4, Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = gray4, LinkFont = ltblue4, Width = -1 } }; normal = new TextStyle() { Timestamp = new ColumnStyle() { Font = gray4, Width = 35 } , Nickname = new ColumnStyle() { Font = blue5, Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = black, LinkFont = blue5, Width = -1 } }; self = new TextStyle() { Timestamp = new ColumnStyle() { Font = gray4 , Width = 35 } , Nickname = new ColumnStyle() { Font = purple, Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = black, LinkFont = blue5, Width = -1 } }; alerted = new TextStyle() { Timestamp = new ColumnStyle() { Font = gray4, Width = 35 } , Nickname = new ColumnStyle() { Font = red5 , Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = black, LinkFont = blue5, Width = -1 } }; commanderror = alerted; system = new TextStyle() { Timestamp = new ColumnStyle() { Font = gray4, Width = 35 } , Nickname = new ColumnStyle() { Font = gray5, Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = gray5, LinkFont = ltblue5, Width = -1 } }; smallalert = new TextStyle() { Timestamp = new ColumnStyle() { Font = red4, Width = 35 } , Nickname = new ColumnStyle() { Font = red4, Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = red4, LinkFont = blue4, Width = -1 } }; baddyalert = new TextStyle() { Timestamp = new ColumnStyle() { Font = gray4 , Width = 35 } , Nickname = new ColumnStyle() { Font = orange, Width = 100, HorizontalAlignment = HorizontalAlignment.Right } , Message = new MessageColumnStyle() { Font = black , LinkFont = blue5, Width = -1 } }; }
//public static char[] Parse(string text,string separators) //{ // //string Result=""; // System.Text.StringBuilder Result=new System.Text.StringBuilder (); // text= " " + text +" "; // char c; // for(int i = 0; i <text.Length;i++) // { // c = text[i]; // if (separators.IndexOf (c)>=0 ) // Result.Append (' '); // else // Result.Append ('.'); // } // return Result.ToString().ToCharArray (); //} public static void AddPatternString(string text, Row row, Pattern pattern, TextStyle style, TextStyle matchingStyle, Segment segment, bool hasError) { Word x = row.Add(text); x.Style = style; x.MatchingStyle = matchingStyle; x.Pattern = pattern; x.HasError = hasError; x.Segment = segment; }
public TextString(string text, TextStyle style, uint size) { characterSize = size; if( style == TextStyle.Bold ) Text = "<b>" + text + "</b>"; else if( style == TextStyle.Italic ) Text = "<i>" + text + "</i>"; else Text = text; }
public void AddContextText(string text, TextStyle style = TextStyle.Normal) { if (style == TextStyle.Bold) { contextParagraph.AddFormattedText(text, document.Styles["Bold"].Font); } else { contextParagraph.AddText(text); } }
public static void DrawText(Graphics graphics, string text, Font font, Rectangle bounds, Color color, TextFormatFlags flags, TextStyle textStyle) { if (!VisualStyleRenderer.IsSupported) { TextRenderer.DrawText(graphics, text, font, bounds, color, flags); return; } IntPtr primaryHdc = graphics.GetHdc(); // Create a memory DC so we can work offscreen IntPtr memoryHdc = CreateCompatibleDC(primaryHdc); // Create a device-independent bitmap and select it into our DC BITMAPINFO info = new BITMAPINFO(); info.biSize = Marshal.SizeOf(info); info.biWidth = bounds.Width; info.biHeight = -bounds.Height; info.biPlanes = 1; info.biBitCount = 32; info.biCompression = 0; // BI_RGB IntPtr dib = CreateDIBSection(primaryHdc, info, 0, 0, IntPtr.Zero, 0); SelectObject(memoryHdc, dib); // Create and select font IntPtr fontHandle = font.ToHfont(); SelectObject(memoryHdc, fontHandle); // Draw glowing text VisualStyleRenderer renderer = new VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.Window.Caption.Active); DTTOPTS dttOpts = new DTTOPTS(); dttOpts.dwSize = Marshal.SizeOf(typeof(DTTOPTS)); if (textStyle == TextStyle.Glowing) { dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR; } else { dttOpts.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR; } dttOpts.crText = ColorTranslator.ToWin32(color); dttOpts.iGlowSize = 8; // This is about the size Microsoft Word 2007 uses RECT textBounds = new RECT(0, 0, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top); DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, text, -1, (int)flags, ref textBounds, ref dttOpts); // Copy to foreground const int SRCCOPY = 0x00CC0020; BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, SRCCOPY); // Clean up DeleteObject(fontHandle); DeleteObject(dib); DeleteDC(memoryHdc); graphics.ReleaseHdc(primaryHdc); }
/// <summary> /// Apply text style to specified text component. /// </summary> /// <param name="text">Text component.</param> public void Apply(Text text) { DebugEx.VerboseFormat("TextStyleLoader.Apply(text = {0})", text); if (mTextStyle == null) { mTextStyle = AssetUtils.LoadTextStyle(mPath); } mTextStyle.Apply(text); }
public void AddContextText(string text, TextStyle style = TextStyle.Normal) { if (style == TextStyle.Bold) { content.Append("#" + text + "#"); } else { content.Append(text); } }
public SimpleTable() { this.TableStyle = new TableStyle(); this.HeaderTextStyle = new TextStyle(); this.HeaderTextStyle.FontWeight = FontWeight.Bold; this.HeaderTextStyle.FontSize = ReportDefinition.default_font_size; this.DetailTextStyle = new TextStyle(); this.DetailTextStyle.FontSize = ReportDefinition.default_font_size; this.ColumnStyles = new List<TableColumnStyle>(); }
public BasicLabel(UIManager manager_, Widget parent_, DCFont font, TextStyle style, Color color, string str, uint size = 30 ) : base(manager_, parent_) { Manager.RegisterWidgetType("BasicLabel", "Widget"); myFont = font; myText = str; myTextSize = size; myStyle = style; myTextColor = color; updateSize(); }
public static void AddPatternString(string Text, Row Row, Pattern Pattern, TextStyle Style, Span span, bool HasError) { var x = new Word { Style = Style, Pattern = Pattern, HasError = HasError, Span = span, Text = Text }; Row.Add(x); }
public ReportDefinition( ) { this.ReportHeaderDefinition = new ReportHeaderDefinition(); this.ReportHeaderDefinition.ReportTitle.TextStyle.FontSize = default_font_size; this.ReportFooterDefinition = new ReportFooterDefinition(); this.Table = new SimpleTable(); this.TextStyle = new TextStyle(); }
private GeoText3D CreateText3DMessage() { TextPart3D textPart3D = new TextPart3D(); textPart3D.AnchorPoint = new Point3D(0, 0, 0); textPart3D.Text = String.Empty; TextStyle style = new TextStyle(); style.ForeColor = Color.White; style.IsSizeFixed = true; style.FontHeight = 4; GeoText3D text3D = new GeoText3D(textPart3D, style); text3D.Style3D = new GeoStyle3D(); text3D.Style3D.AltitudeMode = AltitudeMode.RelativeToGround; return text3D; }
protected void DrawOnSelection(Usable usable, float distance, Selector.Reticle reticle, GUIStyle guiStyle, string defaultUseMessage, Color inRangeColor, Color outOfRangeColor, TextStyle textStyle, Color textStyleColor) { if (usable == null) return; if ((usable != lastUsable) || string.IsNullOrEmpty(heading)) { lastUsable = usable; heading = usable.GetName(); useMessage = string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage; } GameObject selection = usable.gameObject; if (selection != lastSelectionDrawn) { selectionHeight = Tools.GetGameObjectHeight(selection); selectionHeadingSize = guiStyle.CalcSize(new GUIContent(heading)); selectionUseMessageSize = guiStyle.CalcSize(new GUIContent(useMessage)); } // Set text color based on distance: bool inUseRange = (distance <= usable.maxUseDistance); guiStyle.normal.textColor = inUseRange ? inRangeColor : outOfRangeColor; // Draw heading: Vector3 screenPos = Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * selectionHeight)); screenPos += offset; screenPos = new Vector3(screenPos.x, screenPos.y + selectionUseMessageSize.y + selectionHeadingSize.y, screenPos.z); if (screenPos.z < 0) return; Rect rect = new Rect(screenPos.x - (selectionHeadingSize.x / 2), (Screen.height - screenPos.y) - (selectionHeadingSize.y / 2), selectionHeadingSize.x, selectionHeadingSize.y); UnityGUITools.DrawText(rect, heading, guiStyle, textStyle, textStyleColor); // Draw use message: screenPos = Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * (selectionHeight))); screenPos += offset; screenPos = new Vector3(screenPos.x, screenPos.y + selectionUseMessageSize.y, screenPos.z); rect = new Rect(screenPos.x - (selectionUseMessageSize.x / 2), (Screen.height - screenPos.y) - (selectionUseMessageSize.y / 2), selectionUseMessageSize.x, selectionUseMessageSize.y); UnityGUITools.DrawText(rect, useMessage, guiStyle, textStyle, textStyleColor); // Draw reticle: if (reticle != null) { Texture2D reticleTexture = inUseRange ? reticle.inRange : reticle.outOfRange; if (reticleTexture != null) { screenPos = Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * 0.5f * selectionHeight)); rect = new Rect(screenPos.x - (reticle.width / 2), (Screen.height - screenPos.y) - (reticle.height / 2), reticle.width, reticle.height); GUI.Label(rect, reticleTexture); } } }
public ConsoleForm([NotNull] IServiceProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); _provider = provider; _commandService = _provider.GetRequiredService<ICommandService>(); _commandHandlerService = _provider.GetRequiredService<ICommandHandlerService>(); _history = new List<string>(); InitializeComponent(); var styleImageManager = _provider.GetService<IStyleImageManager>(); if (styleImageManager != null) Icon = styleImageManager.TryGetImage("console", StyleImageType.Small).ToIcon(); _toolbarGenerator = new StripMenuGenerator(_provider, _toolStrip, "Janus.Console.Toolbar"); var font = new Font("Courier New", 10F); _consoleEditor.Font = font; _defaultStyle = new TextStyle( "Default", 0, font, Color.Black, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None); _commandNameStyle = new TextStyle( "CommandName", 1, font, Color.Brown, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None); _parameterNameStyle = new TextStyle( "ParameterName", 2, font, Color.Red, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None); _parameterValueStyle = new TextStyle( "ParameterValue", 3, font, Color.Blue, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None); _consoleEditor.TextStyles.AddRange( new[] { _defaultStyle, _commandNameStyle, _parameterNameStyle, _parameterValueStyle }); Prompt(); }
public static unsafe void AddString(string Text, Row Row, TextStyle Style, Segment Segment) { if (Text == "") return; StringBuilder CurrentWord = new StringBuilder(); char[] Buff = Text.ToCharArray(); fixed (char* c = &Buff[0]) { for (int i = 0; i < Text.Length; i++) { if (c[i] == ' ' || c[i] == '\t') { if (CurrentWord.Length != 0) { Word word = Row.Add(CurrentWord.ToString()); word.Style = Style; word.Segment = Segment; CurrentWord = new StringBuilder(); } Word ws = Row.Add(c[i].ToString (CultureInfo.InvariantCulture)); if (c[i] == ' ') ws.Type = WordType.xtSpace; else ws.Type = WordType.xtTab; ws.Style = Style; ws.Segment = Segment; } else CurrentWord.Append(c[i].ToString (CultureInfo.InvariantCulture)); } if (CurrentWord.Length != 0) { Word word = Row.Add(CurrentWord.ToString()); word.Style = Style; word.Segment = Segment; } } }
private void AddPattern( string desc, string pattern, TextStyle style ) { var view = CurrentView; Begin(()=>{ if ( view == null ) return; lock ( view.NuhFilters ) if ( pattern == "" ) { bool first = true; foreach ( var filter in view.NuhFilters.Where(f=>f.Style==style) ) { AddHistory( view, first?(desc+"ing"):"", Timestamp, filter.Pattern, system ); first = false; } if ( first ) AddHistory( view, desc+"ing", Timestamp, "absolutely nobody", system ); } else { view.NuhFilters.Add( new Filter() { Pattern=pattern, Regex=RegexFromPattern(pattern), Style=style } ); AddHistory( view, "", Timestamp, "You are now "+desc+"ing "+pattern, system ); } }); }
/// <summary> /// Creates a new <see cref="ShapeStyle"/> instance. /// </summary> /// <param name="name">The shape style name.</param> /// <param name="sa">The stroke color alpha channel.</param> /// <param name="sr">The stroke color red channel.</param> /// <param name="sg">The stroke color green channel.</param> /// <param name="sb">The stroke color blue channel.</param> /// <param name="fa">The fill color alpha channel.</param> /// <param name="fr">The fill color red channel.</param> /// <param name="fg">The fill color green channel.</param> /// <param name="fb">The fill color blue channel.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="textStyle">The text style.</param> /// <param name="lineStyle">The line style.</param> /// <param name="startArrowStyle">The start arrow style.</param> /// <param name="endArrowStyle">The end arrow style.</param> /// <param name="lineCap">The line cap.</param> /// <param name="dashes">The line dashes.</param> /// <param name="dashOffset">The line dash offset.</param> /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns> public static ShapeStyle Create(string name = "", byte sa = 0xFF, byte sr = 0x00, byte sg = 0x00, byte sb = 0x00, byte fa = 0xFF, byte fr = 0x00, byte fg = 0x00, byte fb = 0x00, double thickness = 2.0, TextStyle textStyle = null, LineStyle lineStyle = null, ArrowStyle startArrowStyle = null, ArrowStyle endArrowStyle = null, LineCap lineCap = LineCap.Round, string dashes = default(string), double dashOffset = 0.0) { var style = new ShapeStyle() { Name = name, Stroke = ArgbColor.Create(sa, sr, sg, sb), Fill = ArgbColor.Create(fa, fr, fg, fb), Thickness = thickness, LineCap = lineCap, Dashes = dashes, DashOffset = dashOffset, LineStyle = lineStyle ?? LineStyle.Create("Line"), TextStyle = textStyle ?? TextStyle.Create("Text") }; style.StartArrowStyle = startArrowStyle ?? ArrowStyle.Create("Start", style); style.EndArrowStyle = endArrowStyle ?? ArrowStyle.Create("End", style); return style; }
/// <summary> /// Add text annotation to chart. /// </summary> /// <param name="sender">Source Chart.</param> /// <param name="text">Text to display.</param> /// <param name="x">Text box upper left X Coordinate.</param> /// <param name="y">Text box upper left Y coordinate.</param> /// <param name="textColor">Text color.</param> /// <param name="name">Annotation name.</param> /// <param name="textStyle">Style of text.</param> public static void AddText(this Chart sender, string text, double x, double y, Drawing.Color textColor, string name = "", TextStyle textStyle = TextStyle.Default) { TextAnnotation textAnn = new TextAnnotation(); string chartAreaName = sender.ChartAreas[0].Name; textAnn.ClipToChartArea = chartAreaName; textAnn.AxisXName = chartAreaName + "\\rX"; textAnn.YAxisName = chartAreaName + "\\rY"; textAnn.IsSizeAlwaysRelative = false; textAnn.Text = text; textAnn.ForeColor = textColor; textAnn.X = x; textAnn.Y = y; textAnn.TextStyle = textStyle; sender.Annotations.Add(textAnn); if (!string.IsNullOrEmpty(name)) textAnn.Name = name; }
protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent) { base.DrawSampleCore(canvas, drawingExtent); PointShape upperLeftPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX - drawingExtent.Width / 2, drawingExtent.CenterY - drawingExtent.Height / 2, canvas.Width, canvas.Height); PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX + drawingExtent.Width / 2, drawingExtent.CenterY + drawingExtent.Height / 2, canvas.Width, canvas.Height); RectangleShape rectangle = new RectangleShape(upperLeftPoint, lowerRightPoint); rectangle.ScaleDown(10); // Here draw the points on Legend Image Random random = new Random(DateTime.Now.Millisecond); Collection<BaseShape> drawingPoints = new Collection<BaseShape>(); for (int i = 0; i < DrawingPointsNumber; i++) { double x = rectangle.LowerLeftPoint.X + random.NextDouble() * (rectangle.Width); double y = rectangle.LowerLeftPoint.Y + random.NextDouble() * (rectangle.Height); drawingPoints.Add(new PointShape(x, y)); } TextStyle textStyle = new TextStyle(DrawingPointsNumber.ToString(), new GeoFont("Arial", 20, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(180, GeoColor.FromHtml("#d3d3d3")))); textStyle.DrawSample(canvas, drawingExtent); CustomPointStyle.Draw(drawingPoints, canvas, new Collection<SimpleCandidate>(), new Collection<SimpleCandidate>()); }
/// <summary> /// Создаёт книгу и запоминает её в массиве. Указывает размер в зависимости от стиля. /// </summary> /// <param name="text">текст книги</param> /// <param name="textStyle">стиль текста</param> public void CreateProduct(string text, TextStyle textStyle) { BookSize size; switch (textStyle) { case TextStyle.FlipChars: size = BookSize.Small; break; case TextStyle.FlipWords: size = BookSize.Big; break; default: throw new InvalidOperationException("Передан незарегистрированный размер книги"); } Book product = new Book(text, textStyle, size); books.Add(product); }
public static void Run() { // ExStart:CreateDocWithFormattedRichText // ExFor:SaveOptions.PageIndex // ExFor:RichText.Append(System.String,TextStyle) // ExSummary:Shows how to create a document with formatted rich text. // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); // Create an object of the Document class Document doc = new Document(); // Initialize Page class object Page page = new Page(); // Initialize Title class object Title title = new Title(); // Initialize TextStyle class object and set formatting properties ParagraphStyle defaultTextStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 }; RichText titleText = new RichText() { ParagraphStyle = defaultTextStyle }.Append("Title!"); Outline outline = new Outline() { VerticalOffset = 100, HorizontalOffset = 100 }; OutlineElement outlineElem = new OutlineElement(); TextStyle textStyleForHelloWord = new TextStyle { FontColor = Color.Red, FontName = "Arial", FontSize = 10, }; TextStyle textStyleForOneNoteWord = new TextStyle { FontColor = Color.Green, FontName = "Calibri", FontSize = 10, IsItalic = true, }; TextStyle textStyleForTextWord = new TextStyle { FontColor = Color.Blue, FontName = "Arial", FontSize = 15, IsBold = true, IsItalic = true, }; RichText text = new RichText() { ParagraphStyle = defaultTextStyle } .Append("Hello", textStyleForHelloWord) .Append(" OneNote", textStyleForOneNoteWord) .Append(" text", textStyleForTextWord) .Append("!", TextStyle.Default); title.TitleText = titleText; // Set page title page.Title = title; // Add RichText node outlineElem.AppendChildLast(text); // Add OutlineElement node outline.AppendChildLast(outlineElem); // Add Outline node page.AppendChildLast(outline); // Add Page node doc.AppendChildLast(page); // Save OneNote document dataDir = dataDir + "CreateDocWithFormattedRichText_out.one"; doc.Save(dataDir); // ExEnd:CreateDocWithFormattedRichText Console.WriteLine("\nOneNote document created successfully with formatted rich text.\nFile saved at " + dataDir); }
private static void WriteDxfFile() { DxfDocument dxf = new DxfDocument(); //arc Arc arc = new Arc(new Vector3d(10, 10, 0), 10, 45, 135); arc.Layer = new Layer("arc"); arc.Layer.Color.Index = 1; dxf.AddEntity(arc); //xData sample XData xdata = new XData(new ApplicationRegistry("netDxf")); xdata.XDataRecord.Add(new XDataRecord(XDataCode.String, "extended data with netDxf")); xdata.XDataRecord.Add(XDataRecord.OpenControlString); xdata.XDataRecord.Add(new XDataRecord(XDataCode.WorldSpacePositionX, 0)); xdata.XDataRecord.Add(new XDataRecord(XDataCode.WorldSpacePositionY, 0)); xdata.XDataRecord.Add(new XDataRecord(XDataCode.WorldSpacePositionZ, 0)); xdata.XDataRecord.Add(XDataRecord.CloseControlString); XData xdata2 = new XData(new ApplicationRegistry("other application")); xdata2.XDataRecord.Add(new XDataRecord(XDataCode.String, "extended data with netDxf")); xdata2.XDataRecord.Add(XDataRecord.OpenControlString); xdata2.XDataRecord.Add(new XDataRecord(XDataCode.String, "string record")); xdata2.XDataRecord.Add(new XDataRecord(XDataCode.Real, 15.5)); xdata2.XDataRecord.Add(new XDataRecord(XDataCode.Long, 350)); xdata2.XDataRecord.Add(XDataRecord.CloseControlString); //circle Vector3d extrusion = new Vector3d(1, 1, 1); Vector3d centerWCS = new Vector3d(1, 1, 1); Vector3d centerOCS = MathHelper.Transform(centerWCS, extrusion, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object); Circle circle = new Circle(centerOCS, 5); circle.Layer = new Layer("circle with spaces"); circle.Layer.Color = AciColor.Yellow; circle.LineType = LineType.Dashed; circle.Normal = extrusion; circle.XData = new Dictionary <ApplicationRegistry, XData> { { xdata.ApplicationRegistry, xdata }, { xdata2.ApplicationRegistry, xdata2 } }; dxf.AddEntity(circle); //points Point point1 = new Point(new Vector3d(-3, -3, 0)); point1.Layer = new Layer("point"); point1.Color = new AciColor(30); Point point2 = new Point(new Vector3d(1, 1, 1)); point2.Layer = point1.Layer; point2.Layer.Color.Index = 9; point2.Normal = new Vector3d(1, 1, 1); dxf.AddEntity(point1); dxf.AddEntity(point2); //3dface Face3d face3D = new Face3d(new Vector3d(-5, -5, 5), new Vector3d(5, -5, 5), new Vector3d(5, 5, 5), new Vector3d(-5, 5, 5)); face3D.Layer = new Layer("3dface"); face3D.Layer.Color.Index = 3; dxf.AddEntity(face3D); //polyline PolylineVertex polyVertex; List <PolylineVertex> polyVertexes = new List <PolylineVertex>(); polyVertex = new PolylineVertex(new Vector2d(-50, -50)); polyVertex.BeginThickness = 2; polyVertexes.Add(polyVertex); polyVertex = new PolylineVertex(new Vector2d(50, -50)); polyVertex.BeginThickness = 1; polyVertexes.Add(polyVertex); polyVertex = new PolylineVertex(new Vector2d(50, 50)); polyVertex.Bulge = 1; polyVertexes.Add(polyVertex); polyVertex = new PolylineVertex(new Vector2d(-50, 50)); polyVertexes.Add(polyVertex); Polyline polyline2d = new Polyline(polyVertexes, true); polyline2d.Layer = new Layer("polyline2d"); polyline2d.Layer.Color.Index = 5; polyline2d.Normal = new Vector3d(1, 1, 1); polyline2d.Elevation = 100.0; dxf.AddEntity(polyline2d); //lightweight polyline LightWeightPolylineVertex lwVertex; List <LightWeightPolylineVertex> lwVertexes = new List <LightWeightPolylineVertex>(); lwVertex = new LightWeightPolylineVertex(new Vector2d(-25, -25)); lwVertex.BeginThickness = 2; lwVertexes.Add(lwVertex); lwVertex = new LightWeightPolylineVertex(new Vector2d(25, -25)); lwVertex.BeginThickness = 1; lwVertexes.Add(lwVertex); lwVertex = new LightWeightPolylineVertex(new Vector2d(25, 25)); lwVertex.Bulge = 1; lwVertexes.Add(lwVertex); lwVertex = new LightWeightPolylineVertex(new Vector2d(-25, 25)); lwVertexes.Add(lwVertex); LightWeightPolyline lwPolyline = new LightWeightPolyline(lwVertexes, true); lwPolyline.Layer = new Layer("lwpolyline"); lwPolyline.Layer.Color.Index = 5; lwPolyline.Normal = new Vector3d(1, 1, 1); lwPolyline.Elevation = 100.0; dxf.AddEntity(lwPolyline); //line Line line = new Line(new Vector3d(0, 0, 0), new Vector3d(10, 10, 10)); line.Layer = new Layer("line"); line.Layer.Color.Index = 6; dxf.AddEntity(line); //3d polyline Polyline3dVertex vertex; List <Polyline3dVertex> vertexes = new List <Polyline3dVertex>(); vertex = new Polyline3dVertex(new Vector3d(-50, -50, 0)); vertexes.Add(vertex); vertex = new Polyline3dVertex(new Vector3d(50, -50, 10)); vertexes.Add(vertex); vertex = new Polyline3dVertex(new Vector3d(50, 50, 25)); vertexes.Add(vertex); vertex = new Polyline3dVertex(new Vector3d(-50, 50, 50)); vertexes.Add(vertex); Polyline3d polyline = new Polyline3d(vertexes, true); polyline.Layer = new Layer("polyline3d"); polyline.Layer.Color.Index = 24; dxf.AddEntity(polyline); //block definition Block block = new Block("TestBlock"); block.Entities.Add(new Line(new Vector3d(-5, -5, 5), new Vector3d(5, 5, 5))); block.Entities.Add(new Line(new Vector3d(5, -5, 5), new Vector3d(-5, 5, 5))); //insert Insert insert = new Insert(block, new Vector3d(5, 5, 5)); insert.Layer = new Layer("insert"); insert.Layer.Color.Index = 4; dxf.AddEntity(insert); //text TextStyle style = new TextStyle("True type font", "Arial.ttf"); Text text = new Text("Hello world!", Vector3d.Zero, 10.0f, style); text.Layer = new Layer("text"); text.Layer.Color.Index = 8; text.Alignment = TextAlignment.TopRight; dxf.AddEntity(text); dxf.Save("AutoCad2007.dxf", DxfVersion.AutoCad2007); dxf.Save("AutoCad2004.dxf", DxfVersion.AutoCad2004); dxf.Save("AutoCad2000.dxf", DxfVersion.AutoCad2000); dxf.Save("AutoCad12.dxf", DxfVersion.AutoCad12); }
public override void Start() { m_teamColorIndexes = new int[2]; m_colorSchemeDataAsset = Engine.AssetManager.GetAsset <ColorSchemeData>("Game/Colors.lua::ColorShemeTeams"); m_teamColorIndexes[0] = -1; m_teamColorIndexes[1] = -1; if (Game.GameSession.CurrentMatchInfo == null) { Game.GameSession.CurrentMatchInfo = new MatchStartInfo(); m_teamColorIndexes[0] = 0; m_teamColorIndexes[1] = m_colorSchemeDataAsset.Content.ColorSchemes.Length / 2; } else { for (int i = 0; i < Game.GameSession.CurrentMatchInfo.Teams.Length; i++) { for (int j = 0; j < m_colorSchemeDataAsset.Content.ColorSchemes.Length; j++) { if (Game.GameSession.CurrentMatchInfo.Teams[i].ColorScheme == m_colorSchemeDataAsset.Content.ColorSchemes[j]) { m_teamColorIndexes[i] = j; break; } } } } m_parameters = Engine.AssetManager.GetAsset <SelectTeamMenuParamters>("Interface/SelectTeamMenu.lua::Params"); var backgroundCmp = new SpriteComponent(Sprite.CreateFromTexture("Graphics/Menu/Background.png"), "MenuBackground"); Menu.Owner.Attach(backgroundCmp); var backgroundTeamCmp = new SpriteComponent(Sprite.CreateFromTexture("Graphics/Menu/TeamSelectionBackground.png"), "Menu"); Menu.Owner.Attach(backgroundTeamCmp); m_ctrlInfos = new Dictionary <MenuController, ControllerInfo>(); m_playerSlots = new MenuController[4]; SpriteFont font = Engine.AssetManager.Get <SpriteFont>("Graphics/Menu/BigMacUnselectedPen"); m_style = new TextStyle() { Scale = 0.4f, Color = Color.White, Font = font }; m_playerSpotPos = new Vector2[4]; m_playerSpotPos[0] = Parameters.Offset * Vector2.UnitX - Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY; m_playerSpotPos[1] = Parameters.Offset * Vector2.UnitX - Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY - Parameters.ControllersHeightOffset * Vector2.UnitY; m_playerSpotPos[2] = Parameters.Offset * Vector2.UnitX + Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY; m_playerSpotPos[3] = Parameters.Offset * Vector2.UnitX + Parameters.PanelWidth * Vector2.UnitX + Parameters.ControllersHeight * Vector2.UnitY - Parameters.ControllersHeightOffset * Vector2.UnitY; m_pressStartCmp = new TextComponent("Menu"); m_pressStartCmp.Text = "Press Start\n to join"; m_pressStartCmp.Alignement = TextAlignementHorizontal.Center; m_pressStartCmp.AlignementVertical = TextAlignementVertical.Down; m_pressStartCmp.Style = new TextStyle() { Font = m_style.Font, Scale = m_style.Scale, Color = Color.DarkGray }; m_pressStartCmp.Visible = false; Menu.Owner.Attach(m_pressStartCmp); m_teamColorTextCmp = new TextComponent[2]; m_teamColorTextCmp[0] = new TextComponent("Menu"); m_teamColorTextCmp[0].Text = "Color :"; m_teamColorTextCmp[0].Alignement = TextAlignementHorizontal.Center; m_teamColorTextCmp[0].Position = m_playerSpotPos[1] - Parameters.ControllersHeight * Vector2.UnitY; m_teamColorTextCmp[0].Style = new TextStyle() { Font = m_style.Font, Scale = m_style.Scale, Color = Color.White }; m_teamColorTextCmp[0].Visible = true; Menu.Owner.Attach(m_teamColorTextCmp[0]); m_teamColorTextCmp[1] = new TextComponent("Menu"); m_teamColorTextCmp[1].Text = "Color :"; m_teamColorTextCmp[1].Alignement = TextAlignementHorizontal.Center; m_teamColorTextCmp[1].Position = m_playerSpotPos[3] - Parameters.ControllersHeight * Vector2.UnitY; m_teamColorTextCmp[1].Style = new TextStyle() { Font = m_style.Font, Scale = m_style.Scale, Color = Color.White }; m_teamColorTextCmp[1].Visible = true; Menu.Owner.Attach(m_teamColorTextCmp[1]); // if (m_teamColorIndexes[0] == -1) { m_teamColorIndexes[0] = 0; } if (m_teamColorIndexes[1] == -1) { m_teamColorIndexes[1] = m_colorSchemeDataAsset.Content.ColorSchemes.Length / 2; } m_teamColorSpriteCmp = new ColorMaskedSprite[2]; Sprite colorSprite = Sprite.CreateFromTexture("Graphics/Menu/ColorSelectionBase.png"); var texAsset = Engine.AssetManager.GetAsset <Texture2D>("Graphics/Menu/ColorSelectionColorMask.png"); m_teamColorSpriteCmp[0] = new ColorMaskedSprite(colorSprite, "Menu2"); m_teamColorSpriteCmp[0].Position = m_teamColorTextCmp[0].Position - Parameters.ControllersHeight * Vector2.UnitY; m_teamColorSpriteCmp[0].Mask = texAsset.Content; m_teamColorSpriteCmp[0].Color1 = m_colorSchemeDataAsset.Content.ColorSchemes[m_teamColorIndexes[0]].Color1; m_teamColorSpriteCmp[0].Color2 = Color.White; m_teamColorSpriteCmp[0].Color3 = Color.White; m_teamColorSpriteCmp[0].Color4 = Color.White; Menu.Owner.Attach(m_teamColorSpriteCmp[0]); m_teamColorSpriteCmp[1] = new ColorMaskedSprite(colorSprite, "Menu2"); m_teamColorSpriteCmp[1].Position = m_teamColorTextCmp[1].Position - Parameters.ControllersHeight * Vector2.UnitY; m_teamColorSpriteCmp[1].Mask = texAsset.Content; m_teamColorSpriteCmp[1].Color1 = m_colorSchemeDataAsset.Content.ColorSchemes[m_teamColorIndexes[1]].Color1; m_teamColorSpriteCmp[1].Color2 = Color.White; m_teamColorSpriteCmp[1].Color3 = Color.White; m_teamColorSpriteCmp[1].Color4 = Color.White; Menu.Owner.Attach(m_teamColorSpriteCmp[1]); // SpriteDefinition spriteDef = Engine.AssetManager.Get <SpriteDefinition>("Graphics/controlSprite.lua::Sprite"); m_playerSpotCmp = new SpriteComponent[4]; m_playerSpotTextCmp = new TextComponent[4]; for (int i = 0; i < 4; i++) { m_playerSpotCmp[i] = new SpriteComponent(new Sprite(spriteDef), "Menu"); m_playerSpotCmp[i].Position = m_playerSpotPos[i]; m_playerSpotCmp[i].Sprite.Scale = iconSpriteScale * Vector2.One; Menu.Owner.Attach(m_playerSpotCmp[i]); m_playerSpotTextCmp[i] = new TextComponent("Menu"); m_playerSpotTextCmp[i].Text = "AI"; m_playerSpotTextCmp[i].Alignement = TextAlignementHorizontal.Center; m_playerSpotTextCmp[i].Style = m_style; m_playerSpotTextCmp[i].Position = m_playerSpotPos[i] - Parameters.ControllerTextHeightOffset * Vector2.UnitY; Menu.Owner.Attach(m_playerSpotTextCmp[i]); } for (int i = 0; i < 4; i++) { var playerInfo = Game.GameSession.CurrentMatchInfo.Players[i]; if (playerInfo.InputType != InputType.AI) { foreach (var menuController in Game.MenuManager.Controllers) { if (menuController.InputIndex == playerInfo.InputIndex && menuController.Type == playerInfo.InputType) { AddController(menuController); m_playerSlots[i] = menuController; m_ctrlInfos[menuController].PlayerIndex = i; if (i == 0 || i == 1) { m_ctrlInfos[menuController].State = ControllerState.Left; } else { m_ctrlInfos[menuController].State = ControllerState.Right; } } } } } Menu.SelectItem(0); Game.GameMusic.PlayMenuMusic(); }
private void _Draw(UISpriteBatch batch) { for (var i = 0; i < NumVisibleRows; i++) { var rowIndex = i + ScrollOffset; if ((rowIndex >= m_Items.Count) || rowIndex < 0) { /** Out of bounds **/ continue; } var row = m_Items[rowIndex]; var rowY = i * RowHeight; var columnX = 0; var selected = rowIndex == m_SelectedRow; var hover = rowIndex == m_HoverRow; if (selected) { /** Draw selection background **/ var white = TextureGenerator.GetPxWhite(batch.GraphicsDevice); DrawLocalTexture(batch, white, null, new Vector2(0, rowY), new Vector2(m_Width, RowHeight), m_SelectionFillColor); } var ts = TextStyle; if (row.CustomStyle != null) { ts = row.CustomStyle; } TextStyle style = null; var isDisabled = ValuePointer.Get<Boolean>(row.Disabled); if (ts != null) { style = ts.Normal; if (ValuePointer.Get<Boolean>(row.UseDisabledStyleByDefault)) { style = ts.Disabled; } if (selected) { style = ts.Selected; } else if (hover) { style = ts.Highlighted; } else if (isDisabled) { style = ts.Disabled; } } for (var x = 0; x < row.Columns.Length; x++) { var columnValue = row.Columns[x]; var columnSpec = m_Columns[x]; var columnBounds = new Rectangle(0, 0, columnSpec.Width, RowHeight); if(columnValue is FSO.Content.Model.ITextureRef){ columnValue = ((FSO.Content.Model.ITextureRef)columnValue).Get(batch.GraphicsDevice); } if (columnValue is string) { DrawLocalString(batch, style.TruncateToWidth((string)columnValue, columnSpec.Width), new Vector2(columnX, rowY), style, columnBounds, columnSpec.Alignment); } else if (columnValue is Texture2D) { var tex = (Texture2D)columnValue; var texWidthDiv4 = tex.Width / 4; /** We assume its a 4 state button **/ Rectangle from = new Rectangle(texWidthDiv4 * columnSpec.TextureDefaultFrame, 0, texWidthDiv4, tex.Height); if (selected) { from.X = texWidthDiv4 * columnSpec.TextureSelectedFrame; } else if (hover) { from.X = texWidthDiv4 * columnSpec.TextureHoverFrame; } else if (isDisabled) { from.X = texWidthDiv4 * columnSpec.TextureDisabledFrame; } var destWidth = texWidthDiv4; var destHeight = tex.Height; if(columnSpec.TextureBounds != null && columnSpec.TextureBounds.HasValue) { var boundsX = columnSpec.TextureBounds.Value.X; var boundsY = columnSpec.TextureBounds.Value.Y; if (!columnSpec.TextureMaintainAspectRatio) { destWidth = (int)boundsX; destHeight = (int)boundsY; } else { if(destWidth > destHeight) { destWidth = (int)boundsX; destHeight = (int)(((float)tex.Height / (float)texWidthDiv4) * destWidth); } else { destHeight = (int)boundsY; destWidth = (int)(((float)texWidthDiv4 / (float)tex.Height) * destHeight); } } } var to = new Vector2(columnX, rowY); if ((columnSpec.Alignment & TextAlignment.Middle) == TextAlignment.Middle) { to.Y = rowY + ((RowHeight - destHeight) / 2); } else if ((columnSpec.Alignment & TextAlignment.Bottom) == TextAlignment.Bottom) { to.Y = rowY + ((RowHeight - destHeight)); } if ((columnSpec.Alignment & TextAlignment.Center) == TextAlignment.Center) { to.X = columnX + ((columnBounds.Width - destWidth) / 2); } else if ((columnSpec.Alignment & TextAlignment.Right) == TextAlignment.Right) { to.X = columnX + (columnBounds.Width - destWidth); } DrawLocalTexture(batch, (Texture2D)columnValue, from, to, new Vector2((float)destWidth / (float)texWidthDiv4, (float)destHeight / (float)tex.Height)); } else if (columnValue is UIElement) { var container = (UIElement)columnValue; var to = new Vector2(columnX, rowY); var bounds = container.GetBounds(); if ((columnSpec.Alignment & TextAlignment.Middle) == TextAlignment.Middle) { to.Y = rowY + ((RowHeight - bounds.Height) / 2); } else if ((columnSpec.Alignment & TextAlignment.Bottom) == TextAlignment.Bottom) { to.Y = rowY + ((RowHeight - bounds.Height)); } if ((columnSpec.Alignment & TextAlignment.Center) == TextAlignment.Center) { to.X = columnX + ((columnBounds.Width - bounds.Width) / 2); } else if ((columnSpec.Alignment & TextAlignment.Right) == TextAlignment.Right) { to.X = columnX + (columnBounds.Width - bounds.Width); } container.Position = this.Position + to; container.Parent = this.Parent; container.InvalidationParent = this.InvalidationParent; container.InvalidateMatrix(); container.PreDraw(batch); container.Draw(batch); container.Parent = null; } else if (columnValue != null) { //Convert it to a string DrawLocalString(batch, (string)columnValue.ToString(), new Vector2(columnX, rowY), style, columnBounds, columnSpec.Alignment); } columnX += columnSpec.Width; } } }
private static IReadOnlyList <Request> MakeTextRequests(Page slide, string target, IReadOnlyList <ParagraphData> paragraphs) { var textElement = slide.PageElements.Where(x => x.Shape.Placeholder.Type == target).Select(x => x.ObjectId).FirstOrDefault(); if (textElement == null) { throw new InvalidOperationException($"Text element '{target}' not found in slide '{slide.ObjectId}' of layout '{slide.LayoutProperties.Name}'."); } var text = new StringBuilder(); var spans = new List <Span>(); var bulletLists = new List <BulletList>(); var blockquotes = new List <Blockquote>(); void closeBulletList() { if (bulletLists.Count != 0 && bulletLists[bulletLists.Count - 1].End == 0) { bulletLists[bulletLists.Count - 1].End = text.Length; } } void closeBlockquote() { if (blockquotes.Count != 0 && blockquotes[blockquotes.Count - 1].End == 0) { blockquotes[blockquotes.Count - 1].End = text.Length; } } bool isFirstParagraph = true; foreach (var paragraph in paragraphs) { if (isFirstParagraph) { isFirstParagraph = false; } else { text.Append("\n"); } if (paragraph.ListItem != null) { closeBlockquote(); if (bulletLists.Count == 0 || bulletLists[bulletLists.Count - 1].End != 0) { bulletLists.Add(new BulletList { Start = text.Length, IsOrdered = paragraph.ListItem.IsOrdered }); } text.Append(new string('\t', paragraph.ListItem.Level + 1)); } else if (paragraph.IsBlockquote) { closeBulletList(); if (blockquotes.Count == 0 || blockquotes[bulletLists.Count - 1].End != 0) { blockquotes.Add(new Blockquote { Start = text.Length }); } } else { closeBulletList(); closeBlockquote(); } foreach (var run in paragraph.Runs) { var span = new Span(text.Length, text.Length + run.Text.Length); if (run.IsBold) { span.Formats.Add((x => x.Bold = true, "bold")); } if (run.IsItalic) { span.Formats.Add((x => x.Italic = true, "italic")); } if (run.IsStrikethrough) { span.Formats.Add((x => x.Strikethrough = true, "strikethrough")); } if (run.IsCode) { span.Formats.Add((x => x.FontFamily = "Consolas", "fontFamily")); } if (run.LinkUrl != null) { span.Formats.Add((x => x.Link = new Link { Url = run.LinkUrl }, "link")); } if (span.Formats.Count != 0) { spans.Add(span); } text.Append(run.Text); } } closeBulletList(); closeBlockquote(); var requests = new List <Request> { new Request { InsertText = new InsertTextRequest { Text = text.ToString(), ObjectId = textElement, }, } }; foreach (var span in spans) { var style = new TextStyle(); foreach (var format in span.Formats) { format.UpdateStyle(style); } requests.Add(new Request { UpdateTextStyle = new UpdateTextStyleRequest { TextRange = CreateTextRange(span.Start, span.End), Style = style, Fields = string.Join(",", span.Formats.Select(x => x.Field)), ObjectId = textElement, }, }); } foreach (var blockquote in blockquotes) { requests.Add(new Request { UpdateTextStyle = new UpdateTextStyleRequest { TextRange = CreateTextRange(blockquote.Start, blockquote.End), Style = new TextStyle { Italic = true }, Fields = "italic", ObjectId = textElement, }, }); } foreach (var bulletList in bulletLists.OrderByDescending(x => x.Start)) { requests.Add(new Request { CreateParagraphBullets = new CreateParagraphBulletsRequest { TextRange = CreateTextRange(bulletList.Start, bulletList.End), BulletPreset = bulletList.IsOrdered ? "NUMBERED_DIGIT_ALPHA_ROMAN" : "BULLET_DISC_CIRCLE_SQUARE", ObjectId = textElement, }, }); } return(requests); }
/// <summary> /// Initializes a new instance of the <c>Text</c> class. /// </summary> /// <param name="text">Text string.</param> /// <param name="position">Text <see cref="Vector2">position</see> in world coordinates.</param> /// <param name="height">Text height.</param> /// <param name="style">Text <see cref="TextStyle">style</see>.</param> public Text(string text, Vector2 position, double height, TextStyle style) : this(text, new Vector3(position.X, position.Y, 0.0), height, style) { }
//----------------------------------------------------------------------- /// <summary> /// Gets the textual representation of the zone, such as 'British Time' or /// '+02:00'. /// <para> /// This returns the textual name used to identify the time-zone ID, /// suitable for presentation to the user. /// The parameters control the style of the returned text and the locale. /// </para> /// <para> /// If no textual mapping is found then the <seealso cref="#getId() full ID"/> is returned. /// /// </para> /// </summary> /// <param name="style"> the length of the text required, not null </param> /// <param name="locale"> the locale to use, not null </param> /// <returns> the text value of the zone, not null </returns> public virtual String GetDisplayName(TextStyle style, Locale locale) { return((new DateTimeFormatterBuilder()).AppendZoneText(style).ToFormatter(locale).Format(ToTemporal())); }
public UIAlert(UIAlertOptions options) : base(UIDialogStyle.Standard, true) { this.m_Options = options; this.Caption = options.Title; this.Opacity = 0.9f; m_TextStyle = TextStyle.DefaultLabel.Clone(); m_TextStyle.Size = options.TextSize; Icon = new UIImage(); Icon.Position = new Vector2(32, 32); Icon.SetSize(0, 0); Add(Icon); /** Determine the size **/ ComputeText(); if (options.ProgressBar) { _ProgressBar = new UIProgressBar(); _ProgressBar.Mode = ProgressBarMode.Animated; _ProgressBar.Position = new Microsoft.Xna.Framework.Vector2(32, 0); _ProgressBar.SetSize(options.Width - 64, 26); this.Add(_ProgressBar); } /** Add buttons **/ Buttons = new List <UIButton>(); foreach (var button in options.Buttons) { string buttonText = ""; if (button.Text != null) { buttonText = button.Text; } else { switch (button.Type) { case UIAlertButtonType.OK: buttonText = GameFacade.Strings.GetString("142", "ok button"); break; case UIAlertButtonType.Yes: buttonText = GameFacade.Strings.GetString("142", "yes button"); break; case UIAlertButtonType.No: buttonText = GameFacade.Strings.GetString("142", "no button"); break; case UIAlertButtonType.Cancel: buttonText = GameFacade.Strings.GetString("142", "cancel button"); break; } } var btnElem = AddButton(buttonText, button.Type, button.Handler == null); Buttons.Add(btnElem); if (button.Handler != null) { btnElem.OnButtonClick += button.Handler; } } if (options.TextEntry) { TextBox = new UITextBox(); TextBox.MaxChars = options.MaxChars; this.Add(TextBox); } if (options.Color) { ColorEntry = new UIColorPicker(); Add(ColorEntry); } /** Position buttons **/ RefreshSize(); }
public UIChatPanel(VM vm, UILotControl owner) { this.vm = vm; this.Owner = owner; if (FSOEnvironment.SoftwareKeyboard) { //need a button to initiate chat history var btn = new UIButton(); btn.Caption = "Chat"; btn.Position = new Vector2(10, 10); btn.OnButtonClick += (state) => { HistoryDialog.Visible = !HistoryDialog.Visible; }; Add(btn); } Style = TextStyle.DefaultTitle.Clone(); Style.Size = 16; Style.Shadow = true; Labels = new List <UIChatBalloon>(); TextBox = new UITextBox(); TextBox.SetBackgroundTexture(null, 0, 0, 0, 0); TextBox.Visible = false; Add(TextBox); TextBox.Position = new Vector2(25, 25); TextBox.SetSize(GlobalSettings.Default.GraphicsWidth - 50, 25); var emojis = new UIEmojiSuggestions(TextBox); Add(emojis); emojis.Parent = this; TextBox.OnEnterPress += TextBox_OnEnterPress; SelectionFillColor = new Color(0, 25, 70); //-- populate invalid areas -- //chat bubbles will be pushed out of these areas //when this happens, they will also begin displaying the name of the speaking avatar. InvalidAreas = new List <Rectangle>(); InvalidAreas.Add(new Rectangle(-100000, -100000, 100020, 200000 + GlobalSettings.Default.GraphicsHeight)); //left InvalidAreas.Add(new Rectangle(-100000, -100000, 200000 + GlobalSettings.Default.GraphicsWidth, 100020)); //top InvalidAreas.Add(new Rectangle(GlobalSettings.Default.GraphicsWidth - 20, -100000, 100020, 200000 + GlobalSettings.Default.GraphicsHeight)); //right InvalidAreas.Add(new Rectangle(-100000, GlobalSettings.Default.GraphicsHeight - 20, 200000 + GlobalSettings.Default.GraphicsWidth, 100020)); //bottom InvalidAreas.Add(new Rectangle(-100000, GlobalSettings.Default.GraphicsHeight - 230, 100230, 100230)); //ucp HistoryDialog = new UIChatDialog(owner); HistoryDialog.Position = new Vector2(GlobalSettings.Default.ChatLocationX, GlobalSettings.Default.ChatLocationY); HistoryDialog.Visible = true; HistoryDialog.Opacity = 0.8f; HistoryDialog.OnSendMessage += SendMessage; this.Add(HistoryDialog); PropertyLog = new UIPropertyLog(); PropertyLog.Position = new Vector2(400, 20); PropertyLog.Visible = false; PropertyLog.Opacity = 0.8f; this.Add(PropertyLog); }
/// <summary> /// Initializes a new instance of the <c>MText</c> class. /// </summary> /// <param name="text">Text string.</param> /// <param name="position">Text <see cref="Vector2">position</see> in world coordinates.</param> /// <param name="height">Text height.</param> /// <param name="rectangleWidth">Reference rectangle width.</param> /// <param name="style">Text <see cref="TextStyle">style</see>.</param> public MText(string text, Vector3 position, double height, double rectangleWidth, TextStyle style) : base(EntityType.MText, DxfObjectCode.MText) { this.value = text; this.position = position; this.attachmentPoint = MTextAttachmentPoint.TopLeft; if (style == null) { throw new ArgumentNullException("style", "The Text style cannot be null."); } this.style = style; this.rectangleWidth = rectangleWidth; if (height <= 0.0) { throw (new ArgumentOutOfRangeException("height", this.value, "The MText height must be greater than zero.")); } this.height = height; this.lineSpacing = 1.0; this.paragraphHeightFactor = 1.0; this.lineSpacingStyle = MTextLineSpacingStyle.AtLeast; this.rotation = 0.0; }
/// <summary> /// Initializes a new instance of the <c>MText</c> class. /// </summary> /// <param name="text">Text string.</param> /// <param name="position">Text <see cref="Vector2">position</see> in world coordinates.</param> /// <param name="height">Text height.</param> /// <param name="rectangleWidth">Reference rectangle width.</param> /// <param name="style">Text <see cref="TextStyle">style</see>.</param> public MText(string text, Vector2 position, double height, double rectangleWidth, TextStyle style) : this(text, new Vector3(position.X, position.Y, 0.0), height, rectangleWidth, style) { }
private static void InitStyle(string name, FontStyle style, Color color, SyntaxHighlighter sh) { if (sh == null) { return; } var tcstyle = new TextStyle(new SolidBrush(color), null, style); switch (name) { case "Comment": sh.Comment = tcstyle; break; case "String": sh.String = tcstyle; break; case "Number": sh.Number = tcstyle; break; case "Variable": sh.Variable = tcstyle; break; case "Keyword": sh.Keyword = tcstyle; break; case "Constant": sh.Constant = tcstyle; break; case "Storage": sh.Storage = tcstyle; break; case "TagBracket": sh.TagBracket = tcstyle; break; case "TagName": sh.TagName = tcstyle; break; case "ClassName": sh.ClassName = tcstyle; break; case "FunctionName": sh.FunctionName = tcstyle; break; case "FunctionArgument": sh.FunctionArgument = tcstyle; break; case "Punctuation": sh.Punctuation = tcstyle; break; case "AttributeName": sh.AttributeName = tcstyle; break; case "AttributeValue": sh.AttributeValue = tcstyle; break; case "CSSProperty": sh.CSSProperty = tcstyle; break; case "CSSSelector": sh.CSSSelector = tcstyle; break; case "CSSPropertyValue": sh.CSSPropertyValue = tcstyle; break; case "Preprocessor": sh.Preprocessor = tcstyle; break; case "LibraryClass": sh.LibraryClass = tcstyle; break; case "LibraryFunction": sh.LibraryFunction = tcstyle; break; case "DoctypeDeclaration": sh.DoctypeDeclaration = tcstyle; break; } }
//------------------------------------------------------------------------------------------------------------------------ private static List <SimpleMenuItem> AddCreateFileMenuItem(Lifetime lifetime, TestCopProjectItem projectItem, string targetFile) { var menuItems = new List <SimpleMenuItem>(); var result = new SimpleMenuItem("Create associated file" , null, ResharperHelper.ProtectActionFromReEntry(lifetime, "TestingMenuNavigation", () => ResharperHelper.CreateFileWithinProject(projectItem, targetFile))); result.Style = MenuItemStyle.Enabled; result.Icon = UnnamedThemedIcons.Agent16x16.Id; result.Text = new RichText("Create ", TextStyle.FromForeColor(Color.Green)).Append(targetFile, TextStyle.FromForeColor(TextStyle.DefaultForegroundColor)); result.ShortcutText = new RichText("(" + projectItem.Project.GetPresentableProjectPath() + projectItem.SubNamespaceFolder.FullPath.RemoveLeading( projectItem.Project.ProjectFileLocation.Directory.FullPath) + ")", TextStyle.FromForeColor(Color.LightGray)); menuItems.Add(result); return(menuItems); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument doc = app.ActiveUIDocument; //List<string> fonts = Utils.TextUtilities.InstalledFonts(); //System.Windows.Forms.MessageBox.Show(string.Format("I found {0} fonts.\nThe first one is: {1}",fonts.Count,fonts[0])); //<LeaderStyle Name="ARROW (30°) FILLED" // ArrowStyle="8" // Angle="30" // Filled="1" // Size="3" // HeavyEndWeight="5" /> LeaderStyle leader = new LeaderStyle() { Name = "ARROW (30°) FILLED", Style = LeaderStyle.ArrowStyle.Arrow, Angle = 30, Filled = true, Size = 3, HeavyEndWeight = 5 }; //<Style Name="" // Description="Bold" // Background="1" // Bold="1" // Italic="0" // Underline="0" // Colour="0" // Leader="ARROW (30°) FILLED" // LeaderOffset="1.0" // LineWeight="1" // TextBox="0" // TabSize="12.0" // WidthFactor="1" //> TextStyle style = new TextStyle() { Name = "test", Description = "Bold", Background = true, Bold = true, Italic = false, Underline = false, Color = System.Drawing.Color.Black, Leader = leader, LeaderOffset = 1, LineWeight = 1, TextBox = false, TabSize = 12, WidthFactor = 1 }; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><KRSP_Annotation_Styles />"); XmlNode node = xdoc.DocumentElement; style.AddToXmlDoc(ref node); return(Result.Succeeded); }
public UIListBoxTextStyle(TextStyle baseStyle) { Normal = Selected = Highlighted = Disabled = baseStyle; }
public static UIWordWrapOutput WordWrap(string text, int width, TextStyle style, Vector2 scale) { var result = new UIWordWrapOutput(); result.Lines = new List <string>(); var textLines = text.Split('\n');// new string[] {text}; //only support single line for now, since we're only using this utility function for captions int maxWidth = 0; int curpos = 0; var positions = new List <int>(); for (var l = 0; l < textLines.Length; l++) { List <string> words = textLines[l].Split(' ').ToList(); while (words.Count > 0) { var lineBuffer = new List <string>(); int i = 0; for (i = 0; i < words.Count; i++) { lineBuffer.Add(words[i]); var str = JoinWordList(lineBuffer); //(lineBuffer.concat([words[i]])).join(" "); int w = (int)(style.SpriteFont.MeasureString(str).X *scale.X); if (w > width) { lineBuffer.RemoveAt(lineBuffer.Count - 1); if (lineBuffer.Count == 0) { for (var j = words[i].Length - 1; j > 0; j--) { var str2 = words[i].Substring(0, j); var w2 = (int)(style.SpriteFont.MeasureString(str2).X *scale.X); if (w2 <= width) { curpos += j; lineBuffer.Add(words[i].Substring(0, j)); words[i] = words[i].Substring(j); if (w > maxWidth) { maxWidth = w; } break; } } } break; } else { if (w > maxWidth) { maxWidth = w; } curpos += words[i].Length + 1; } } result.Lines.Add(JoinWordList(lineBuffer)); positions.Add(curpos); words.RemoveRange(0, i); } //curpos++; } result.Positions = positions; result.MaxWidth = maxWidth; result.Height = result.Lines.Count * style.LineHeight; return(result); }
//========================================================================================= public FixedListElement(TextStyle style) : base(style) { this.Keywords = new List <string>(); }
/// <summary> /// 画文本 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="component">打印组件</param> /// <param name="x">文字起始x坐标</param> /// <param name="y">文字起始y坐标</param> /// <param name="text">内容</param> /// <param name="fontSize">字体大小</param> /// <param name="textStyle">字体样式</param> public static T DrawText <T>(this IPrintComponent <T> component, int x, int y, string text, FontSize fontSize, TextStyle textStyle) where T : IPrintCommand <T> => component.DrawText(x, y, text, fontSize, RotationAngle.None, textStyle);
/// <summary> /// Initializes a new instance of the <c>AttributeDefiniton</c> class. /// </summary> /// <param name="tag">Attribute identifier.</param> /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param> public AttributeDefinition(string tag, TextStyle style) : this(tag, MathHelper.IsZero(style.Height) ? 1.0 : style.Height, style) { }
private void OutputMeasureDistance(SuperMap.UI.Tracking3DEventArgs e) { try { Point location = mSceneControl.PointToClient(Cursor.Position); if (mTempPoint != Point3D.Empty && mPoint3Ds.Count > 1) { mPoint3Ds.Remove(mPoint3Ds.Count - 1); } mTempPoint = new Point3D(e.X, e.Y, e.Z); mPoint3Ds.Add(mTempPoint); location.Offset(30, 30); if (location.X > mSceneControl.Bounds.Width / 3 * 2) { location.X = mSceneControl.Bounds.Width / 3 * 2; } if (location.Y > mSceneControl.Bounds.Height) { location.Y = location.Y - 60; } TextPart3D textPart3D = new TextPart3D(); textPart3D.AnchorPoint = new Point3D(0, 0, 0); textPart3D.Text = String.Empty; TextStyle style = new TextStyle(); style.ForeColor = Color.White; style.IsSizeFixed = true; style.FontHeight = 6; style.Alignment = TextAlignment.BottomLeft; style.BackColor = Color.Black; style.Outline = true; GeoText3D text3d = new GeoText3D(textPart3D, style); text3d.Style3D = new GeoStyle3D(); text3d.Style3D.AltitudeMode = AltitudeMode.Absolute; text3d[0].Text = e.CurrentLength.ToString("##.00") + "米"; Point3D lastPoint = Point3D.Empty; if (e.Geometry != null) { Point3Ds points = (e.Geometry as GeoLine3D)[0]; lastPoint = points[points.Count - 1]; } else { lastPoint = mPoint3Ds[0]; } text3d[0].X = (lastPoint.X + e.X) / 2; text3d[0].Y = (lastPoint.Y + e.Y) / 2; int index = mSceneControl.Scene.TrackingLayer.IndexOf(MessageTrackingTag); if (index >= 0) { mSceneControl.Scene.TrackingLayer.Remove(index); } mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTrackingTag); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public TotalPagesField(TextStyle textStyle) : base(textStyle) { }
/// <summary> /// 测量面积 /// </summary> /// <param name="e"></param> private void OutputMeasureArea(SuperMap.UI.Tracking3DEventArgs e) { try { Point location = mSceneControl.PointToClient(Cursor.Position); if (mTempPoint != Point3D.Empty) { mPoint3Ds.Remove(mPoint3Ds.Count - 1); } mTempPoint = new Point3D(e.X, e.Y, e.Z); mPoint3Ds.Add(mTempPoint); GeoRegion3D geoRegion3D = null; if (mPoint3Ds.Count >= 3) { geoRegion3D = new GeoRegion3D(mPoint3Ds); geoRegion3D.Style3D = mGeoStyle3DTemp.Clone(); location.Offset(30, 30); if (location.X > mSceneControl.Bounds.Width / 4 * 3) { location.X = mSceneControl.Bounds.Width / 4 * 3; } if (location.Y > mSceneControl.Bounds.Height) { location.Y = location.Y - 60; } TextPart3D textPart3D = new TextPart3D(); textPart3D.AnchorPoint = new Point3D(0, 0, 0); textPart3D.Text = String.Empty; TextStyle style = new TextStyle(); style.ForeColor = Color.White; style.IsSizeFixed = true; style.FontHeight = 6; style.Alignment = TextAlignment.BottomLeft; style.BackColor = Color.Black; style.Outline = true; GeoText3D text3d = new GeoText3D(textPart3D, style); text3d.Style3D = new GeoStyle3D(); text3d.Style3D.AltitudeMode = AltitudeMode.Absolute; text3d[0].Text = e.TotalArea.ToString("##.00") + "平方米"; if (e.Geometry != null) { text3d[0].X = e.Geometry.InnerPoint.X; text3d[0].Y = e.Geometry.InnerPoint.Y; } else { text3d[0].X = geoRegion3D.InnerPoint.X; text3d[0].Y = geoRegion3D.InnerPoint.Y; } int index = mSceneControl.Scene.TrackingLayer.IndexOf(MessageTrackingTag); if (index >= 0) { mSceneControl.Scene.TrackingLayer.Remove(index); } mSceneControl.Scene.TrackingLayer.Add(text3d, MessageTrackingTag); mCurArea = e.TotalArea; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public void Load_setting() { StreamReader reader = new StreamReader("init\\setting.txt"); string line; string[] split; SolidBrush brush; line = reader.ReadLine(); while (line != null) { fctb.ClearStylesBuffer(); split = line.Split('='); split[0].Replace(" ", ""); split[1].Replace(" ", ""); if (split[0] == "comment_style") { split = split[1].Split(';'); brush = new SolidBrush(Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2]))); comment_style = new TextStyle(brush, null, FontStyle.Regular); } else if (split[0] == "drawing_style") { split = split[1].Split(';'); brush = new SolidBrush(Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2]))); drawing_style = new TextStyle(brush, null, FontStyle.Regular); } else if (split[0] == "scad_style") { split = split[1].Split(';'); brush = new SolidBrush(Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2]))); scad_style = new TextStyle(brush, null, FontStyle.Regular); } else if (split[0] == "variable_style") { split = split[1].Split(';'); brush = new SolidBrush(Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2]))); variable_style = new TextStyle(brush, null, FontStyle.Regular); } else if (split[0] == "BackColor") { split = split[1].Split(';'); fctb.BackColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "BookmarkColor") { split = split[1].Split(';'); fctb.BookmarkColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "CaretColor") { split = split[1].Split(';'); fctb.CaretColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "ChangedLineColor") { split = split[1].Split(';'); fctb.ChangedLineColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "CurrentLineColor") { split = split[1].Split(';'); fctb.CurrentLineColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "DisabledColor") { split = split[1].Split(';'); fctb.DisabledColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "FoldingIndicatorColor") { split = split[1].Split(';'); fctb.FoldingIndicatorColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "ForeColor") { split = split[1].Split(';'); fctb.ForeColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "IndentBackColor") { split = split[1].Split(';'); fctb.IndentBackColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "LineNumberColor") { split = split[1].Split(';'); fctb.LineNumberColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "PaddingBackColor") { split = split[1].Split(';'); fctb.PaddingBackColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "SelectionColor") { split = split[1].Split(';'); fctb.SelectionColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "ServiceLinesColor") { split = split[1].Split(';'); fctb.ServiceLinesColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "TextAreaBorderColor") { split = split[1].Split(';'); fctb.TextAreaBorderColor = Color.FromArgb(Convert.ToInt16(split[0]), Convert.ToInt16(split[1]), Convert.ToInt16(split[2])); } else if (split[0] == "scad_filename") { scad_filename = split[1]; } line = reader.ReadLine(); } reader.Close(); Refresh(); }
/// <summary> /// Initializes a new instance of the <c>MText</c> class. /// </summary> /// <param name="text">Text string.</param> /// <param name="position">Text <see cref="Vector2">position</see> in world coordinates.</param> /// <param name="height">Text height.</param> /// <param name="rectangleWidth">Reference rectangle width.</param> /// <param name="style">Text <see cref="TextStyle">style</see>.</param> public MText(string text, Vector3 position, double height, double rectangleWidth, TextStyle style) : base(EntityType.MText, DxfObjectCode.MText) { this.text = text; this.position = position; this.attachmentPoint = MTextAttachmentPoint.TopLeft; if (style == null) { throw new ArgumentNullException(nameof(style)); } this.style = style; this.rectangleWidth = rectangleWidth; if (height <= 0.0) { throw new ArgumentOutOfRangeException(nameof(height), this.text, "The MText height must be greater than zero."); } this.height = height; this.lineSpacing = 1.0; this.lineSpacingStyle = MTextLineSpacingStyle.AtLeast; this.drawingDirection = MTextDrawingDirection.ByStyle; this.rotation = 0.0; }
public void allocRunPos(painting.TextStyle style, string text, int offset, int size, float textScaleFactor = 1.0f) { this.allocRunPos(TextStyle.applyStyle(null, style, textScaleFactor), text, offset, size); }
public Text(string text, TextStyle style) { Content = text; this.style = style; }
public InputField( Key key = null, TextEditingController controller = null, FocusNode focusNode = null, bool obscureText = false, bool autocorrect = true, bool enabled = true, Decoration decoration = null, TextStyle style = null, TextAlign textAlign = TextAlign.left, Alignment alignment = null, int?maxLines = 1, int?minLines = null, int?maxLength = null, bool maxLengthEnforced = true, bool autofocus = false, List <TextInputFormatter> inputFormatters = null, Widget prefix = null, Widget suffix = null, string hintText = null, float?hintTextWidth = null, TextStyle hintStyle = null, string labelText = null, TextStyle labelStyle = null, Color cursorColor = null, float cursorWidth = 2, Radius cursorRadius = null, TextInputAction textInputAction = TextInputAction.none, TextInputType keyboardType = null, float?height = 44.0f, InputFieldClearButtonMode clearButtonMode = InputFieldClearButtonMode.never, bool enableInteractiveSelection = true, Color selectionColor = null, ValueChanged <string> onChanged = null, ValueChanged <string> onSubmitted = null, EdgeInsets scrollPadding = null ) : base(key: key) { D.assert(maxLines == null || minLines == null || maxLines >= minLines); this.controller = controller; this.textAlign = textAlign; this.focusNode = focusNode; this.obscureText = obscureText; this.autocorrect = autocorrect; this.enabled = enabled; this.decoration = decoration; this.style = style; this.textAlign = textAlign; this.alignment = alignment ?? Alignment.center; this.maxLines = maxLines; this.minLines = minLines; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.autofocus = autofocus; this.inputFormatters = inputFormatters; this.prefix = prefix; this.suffix = suffix; this.hintText = hintText; this.hintTextWidth = hintTextWidth; this.hintStyle = hintStyle; this.labelText = labelText; this.labelStyle = labelStyle; this.height = height; this.clearButtonMode = clearButtonMode; this.enableInteractiveSelection = enableInteractiveSelection; this.selectionColor = selectionColor ?? new Color(0x667FAACF); this.cursorColor = cursorColor; this.cursorWidth = cursorWidth; this.cursorRadius = cursorRadius ?? Radius.circular(1.0f); this.textInputAction = textInputAction; this.keyboardType = keyboardType; this.onChanged = onChanged; this.onSubmitted = onSubmitted; this.scrollPadding = scrollPadding; }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="serviceProvider">The service provider.</param> public static void InitializeContext(IServiceProvider serviceProvider) { // Editor Editor = serviceProvider.GetService <ProjectEditor>(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // New Project Editor.OnNewProject(); // Transform Transform = MatrixObject.Identity; // Data var db = Database.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => Column.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => Value.Create(c)); var record = Record.Create( db, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = Context.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = PageContainer.CreateTemplate(); Page = PageContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(LineShape.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = DocumentContainer.Create(); Layer = LayerContainer.Create(); Options = Options.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(128, 255, 0, 0); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = ArcShape.Create(0, 0, Style, null); CubicBezier = CubicBezierShape.Create(0, 0, Style, null); Ellipse = EllipseShape.Create(0, 0, Style, null); Group = GroupShape.Create(Constants.DefaulGroupName); Image = ImageShape.Create(0, 0, Style, null, "key"); Line = LineShape.Create(0, 0, Style, null); Path = PathShape.Create(Style, null); Point = PointShape.Create(); QuadraticBezier = QuadraticBezierShape.Create(0, 0, Style, null); Rectangle = RectangleShape.Create(0, 0, Style, null); Text = TextShape.Create(0, 0, Style, null, "Text"); // Path ArcSegment = ArcSegment.Create(PointShape.Create(), PathSize.Create(), 180, true, SweepDirection.Clockwise, true, true); CubicBezierSegment = CubicBezierSegment.Create(PointShape.Create(), PointShape.Create(), PointShape.Create(), true, true); LineSegment = LineSegment.Create(PointShape.Create(), true, true); PathFigure = PathFigure.Create(PointShape.Create(), false, true); PathGeometry = PathGeometry.Create(ImmutableArray.Create <PathFigure>(), FillRule.EvenOdd); PathSize = PathSize.Create(); PolyCubicBezierSegment = PolyCubicBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyLineSegment = PolyLineSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyQuadraticBezierSegment = PolyQuadraticBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); QuadraticBezierSegment = QuadraticBezierSegment.Create(PointShape.Create(), PointShape.Create(), true, true); }
/// <summary> /// Initializes a new instance of the <c>MText</c> class. /// </summary> /// <param name="position">Text <see cref="Vector2">position</see> in world coordinates.</param> /// <param name="height">Text height.</param> /// <param name="rectangleWidth">Reference rectangle width.</param> /// <param name="style">Text <see cref="TextStyle">style</see>.</param> public MText(Vector3 position, double height, double rectangleWidth, TextStyle style) : this(string.Empty, position, height, rectangleWidth, style) { }
public override void Paint(Graphics g) { base.Paint(g); g.SmoothingMode = SmoothingMode.HighQuality; using (Pen pen = new Pen(lineColor, lineWidth)) { SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45); titleSize.Height += 10; //add spacing SizeF subtitleSize = g.MeasureString(this.Subtitle, ArtPalette.DefaultFont, Rectangle.Width - 45); subtitleSize.Height += 5; //add spacing if (this.Title == this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) { subtitleSize = new SizeF(0, 0); } if ((int)titleSize.Height + (int)subtitleSize.Height != Rectangle.Height) { headerHeight = (int)titleSize.Height + (int)subtitleSize.Height; this.UpdateLabels(); } GraphicsPath path = new GraphicsPath(); path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90); path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y); path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90); path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10); path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90); path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height); path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90); path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10); //shadow if (ArtPalette.EnableShadows) { Region darkRegion = new Region(path); darkRegion.Translate(5, 5); g.FillRegion(ArtPalette.ShadowBrush, darkRegion); } //background g.FillPath(Brush, path); using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) { Region gradientRegion = new Region(path); g.FillRegion(gradientBrush, gradientRegion); } if (!this.Collapsed) { TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near); StringFormat stringFormat = textStyle.StringFormat; stringFormat.Trimming = StringTrimming.EllipsisWord; stringFormat.FormatFlags = StringFormatFlags.LineLimit; Rectangle rect; const int verticalHeaderSpacing = 5; Point separationLineStart = new Point(Rectangle.X + 25, Rectangle.Y + headerHeight - verticalHeaderSpacing); Point separationLineEnd = new Point(Rectangle.X + Rectangle.Width - 25, Rectangle.Y + headerHeight - verticalHeaderSpacing); using (LinearGradientBrush brush = new LinearGradientBrush(separationLineStart, separationLineEnd, Color.Black, Color.White)) { using (Pen separationLinePen = new Pen(brush)) { g.DrawLine(separationLinePen, separationLineStart, separationLineEnd); } } for (int i = 0; i < this.labels.Count; i++) { rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT); g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat); } } //the border g.DrawPath(pen, path); //the title g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black, new Rectangle(Rectangle.X + 25, Rectangle.Y + 5, Rectangle.Width - 45, Rectangle.Height - 5 - (int)subtitleSize.Height)); //the subtitle if (this.Title != this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) { g.DrawString(this.Subtitle, ArtPalette.DefaultFont, Brushes.Black, new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height - 5, Rectangle.Width - 45, Rectangle.Height - 5)); } //the material foreach (IShapeMaterial material in Children) { material.Paint(g); } //the connectors if (this.ShowConnectors) { foreach (IConnector t in Connectors) { t.Paint(g); } } } }