public TextEditRenderBox(RootGraphic rootgfx, int width, int height, bool isMultiLine) : base(rootgfx, width, height) { GlobalCaretController.RegisterCaretBlink(rootgfx); myCaret = new CaretRenderElement(rootgfx, 2, 17); myCaret.TransparentForAllEvents = true; this.MayHasViewport = true; this.BackgroundColor = Color.White;// Color.Transparent; this.currentSpanStyle = new TextSpanStyle(); this.currentSpanStyle.FontInfo = rootgfx.DefaultTextEditFontInfo; textLayer = new EditableTextFlowLayer(this); internalTextLayerController = new InternalTextLayerController(this, textLayer); this.isMultiLine = isMultiLine; if (isMultiLine) { textLayer.SetUseDoubleCanvas(false, true); } else { textLayer.SetUseDoubleCanvas(true, false); } this.IsBlockElement = false; }
public DocActionFormatting(TextSpanStyle textStyle, int startLineNumber, int startCharIndex, int endLineNumber, int endCharIndex) : base(startLineNumber, startCharIndex) { this.textStyle = textStyle; this.endLineNumber = endLineNumber; this.endCharIndex = endCharIndex; }
public EditableTextRun(RootGraphic gfx, char[] copyBuffer, TextSpanStyle style) : base(gfx) { //check line break? this.spanStyle = style; this.mybuffer = copyBuffer; UpdateRunWidth(); }
public override void CustomDrawToThisCanvas(Canvas canvas, Rectangle updateArea) { int bWidth = this.Width; int bHeight = this.Height; canvas.FillRectangle(Color.Yellow, updateArea.Left, updateArea.Top, updateArea.Width, updateArea.Height); if (!this.HasStyle) { canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), 0); } else { TextSpanStyle style = this.SpanStyle; switch (EvaluateFontAndTextColor(canvas, style)) { case DIFF_FONT_SAME_TEXT_COLOR: { var prevFont = canvas.CurrentFont; canvas.CurrentFont = style.FontInfo; canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), style.ContentHAlign); canvas.CurrentFont = prevFont; } break; case DIFF_FONT_DIFF_TEXT_COLOR: { var prevFont = canvas.CurrentFont; var prevColor = canvas.CurrentTextColor; canvas.CurrentFont = style.FontInfo; canvas.CurrentTextColor = style.FontColor; canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), style.ContentHAlign); canvas.CurrentFont = prevFont; canvas.CurrentTextColor = prevColor; } break; case SAME_FONT_DIFF_TEXT_COLOR: { var prevColor = canvas.CurrentTextColor; canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), style.ContentHAlign); canvas.CurrentTextColor = prevColor; } break; default: { canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), style.ContentHAlign); } break; } } }
public SolidTextRun(char[] copyBuffer, TextSpanStyle style) { //check line break? this.spanStyle = style; this.mybuffer = copyBuffer; UpdateRunWidth(); }
public override void SetStyle(TextSpanStyle spanStyle) { this.InvalidateGraphics(); this.spanStyle = spanStyle; this.InvalidateGraphics(); UpdateRunWidth(); }
protected override void OnStartDemo(SampleViewport viewport) { textbox = new LayoutFarm.CustomWidgets.TextBox(400, 300, true); textbox.SetLocation(20, 20); var style1 = new Text.TextSpanStyle(); style1.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 10); style1.FontColor = new PixelFarm.Drawing.Color(0, 0, 0); textbox.DefaultSpanStyle = style1; var textSplitter = new LayoutFarm.CustomWidgets.ContentTextSplitter(); textbox.TextSplitter = textSplitter; listView = new CustomWidgets.ListView(300, 200); listView.SetLocation(0, 40); listView.Visible = false; //------------------------------------ //create special text surface listener var textSurfaceListener = new LayoutFarm.Text.TextSurfaceEventListener(); textSurfaceListener.CharacterAdded += (s, e) => UpdateSuggestionList(); textSurfaceListener.CharacterRemoved += (s, e) => UpdateSuggestionList(); textSurfaceListener.PreviewArrowKeyDown += new EventHandler <Text.TextDomEventArgs>(textSurfaceListener_PreviewArrowKeyDown); textSurfaceListener.PreviewEnterKeyDown += new EventHandler <Text.TextDomEventArgs>(textSurfaceListener_PreviewEnterKeyDown); textbox.TextEventListener = textSurfaceListener; //------------------------------------ viewport.AddContent(textbox); viewport.AddContent(listView); //------------------------------------ BuildSampleCountryList(); }
protected override void OnStartDemo(SampleViewport viewport) { var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true); var style1 = new Text.TextSpanStyle(); style1.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 18); //test with various font style style1.FontColor = new PixelFarm.Drawing.Color(255, 0, 0); textbox1.DefaultSpanStyle = style1; viewport.AddContent(textbox1); //------------------- //this version we need to set a style font each textbox var textbox2 = new LayoutFarm.CustomWidgets.TextBox(400, 500, true); var style2 = new Text.TextSpanStyle(); style2.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 10); style2.FontColor = new PixelFarm.Drawing.Color(0, 0, 0); textbox2.DefaultSpanStyle = style2; textbox2.SetLocation(20, 120); viewport.AddContent(textbox2); var textSplitter = new ContentTextSplitter(); textbox2.TextSplitter = textSplitter; textbox2.Text = "Hello World!"; }
static int EvaluateFontAndTextColor(DrawBoard canvas, TextSpanStyle spanStyle) { var font = spanStyle.FontInfo; var color = spanStyle.FontColor; var currentTextFont = canvas.CurrentFont; var currentTextColor = canvas.CurrentTextColor; if (font != null && font != currentTextFont) { if (currentTextColor != color) { return(DIFF_FONT_DIFF_TEXT_COLOR); } else { return(DIFF_FONT_SAME_TEXT_COLOR); } } else { if (currentTextColor != color) { return(SAME_FONT_DIFF_TEXT_COLOR); } else { return(SAME_FONT_SAME_TEXT_COLOR); } } }
static int EvaluateFontAndTextColor(TextSpanStyle spanStyle) { return(1); //var font = spanStyle.FontInfo; //var currentTextFont = canvas.CurrentFont; //var currentTextColor = canvas.CurrentTextColor; //if (font != null && font != currentTextFont) //{ // if (currentTextColor != color) // { // return DIFF_FONT_DIFF_TEXT_COLOR; // } // else // { // return DIFF_FONT_SAME_TEXT_COLOR; // } //} //else //{ // if (currentTextColor != color) // { // return SAME_FONT_DIFF_TEXT_COLOR; // } // else // { // return SAME_FONT_SAME_TEXT_COLOR; // } //} }
protected override void OnStartDemo(SampleViewport viewport) { textbox = new LayoutFarm.CustomWidgets.TextBox(400, 300, true); textbox.SetLocation(20, 20); var style1 = new Text.TextSpanStyle(); style1.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 10); style1.FontColor = new PixelFarm.Drawing.Color(0, 0, 0); textbox.DefaultSpanStyle = style1; var textSplitter = new CustomWidgets.ContentTextSplitter(); textbox.TextSplitter = textSplitter; sgBox = new SuggestionWindowMx(300, 200); sgBox.UserConfirmSelectedItem += new EventHandler(sgBox_UserConfirmSelectedItem); sgBox.ListItemKeyboardEvent += new EventHandler <UIKeyEventArgs>(sgBox_ListItemKeyboardEvent); sgBox.Hide(); //------------------------------------ //create special text surface listener var textSurfaceListener = new LayoutFarm.Text.TextSurfaceEventListener(); textSurfaceListener.CharacterAdded += (s, e) => UpdateSuggestionList(); textSurfaceListener.CharacterRemoved += (s, e) => UpdateSuggestionList(); textSurfaceListener.PreviewArrowKeyDown += new EventHandler <Text.TextDomEventArgs>(textSurfaceListener_PreviewArrowKeyDown); textSurfaceListener.PreviewEnterKeyDown += new EventHandler <Text.TextDomEventArgs>(textSurfaceListener_PreviewEnterKeyDown); textbox.TextEventListener = textSurfaceListener; //------------------------------------ viewport.AddContent(textbox); viewport.AddContent(sgBox.GetPrimaryUI()); //------------------------------------ BuildSampleCountryList(); }
public void DoFormatSelection(TextSpanStyle textStyle) { int startLineNum = textLineWriter.LineNumber; int startCharIndex = textLineWriter.CharIndex; SplitSelectedText(); VisualSelectionRange selRange = SelectionRange; if (selRange != null) { foreach (EditableRun r in selRange.GetPrintableTextRunIter()) { r.SetStyle(textStyle); } this.updateJustCurrentLine = selectionRange.IsOnTheSameLine; CancelSelect(); CharIndex++; CharIndex--; } }
int[] glyphPositions = null; //TODO: review here-> change this to caret stop position public EditableTextRun(char[] copyBuffer, TextSpanStyle style) { //we need font info (in style) for evaluating the size fo this span //without font info we can't measure the size of this span this.spanStyle = style; this.mybuffer = copyBuffer; UpdateRunWidth(); }
public EditableTextRun(RootGraphic gfx, char[] copyBuffer, TextSpanStyle style) : base(gfx) { //we need font info (in style) for evaluating the size fo this span //without font info we can't measure the size of this span this.spanStyle = style; SetNewContent(copyBuffer); UpdateRunWidth(); }
public override void SetStyle(TextSpanStyle spanStyle) { //some content or style //change the apperance/ size //it need to invalidate graphic //this.InvalidateGraphics(); this.spanStyle = spanStyle; //this.InvalidateGraphics(); UpdateRunWidth(); }
public SolidTextRun(char c, TextSpanStyle style) { mybuffer = new char[] { c }; if (c == '\n') { this.IsLineBreak = true; } //check line break? UpdateRunWidth(); }
public SolidTextRun(RootGraphic gfx, char c, TextSpanStyle style) : base(gfx) { mybuffer = new char[] { c }; if (c == '\n') { this.IsLineBreak = true; } //check line break? UpdateRunWidth(); }
public EditableTextRun(RootGraphic gfx, char c, TextSpanStyle style) : base(gfx) { this.spanStyle = style; mybuffer = new char[] { c }; if (c == '\n') { this.IsLineBreak = true; } //check line break? UpdateRunWidth(); }
public EditableTextRun(char c, TextSpanStyle style) { this.spanStyle = style; mybuffer = new char[] { c }; if (c == '\n') { //TODO: review line break span this.IsLineBreak = true; } //check line break? UpdateRunWidth(); }
public override void SetStyle(TextSpanStyle spanStyle) { //TODO: review this again //update style may affect the 'visual' layout of the span //the span may expand large or shrink down //so we invalidate graphics area pre and post this.InvalidateGraphics(); this.spanStyle = spanStyle; this.InvalidateGraphics(); UpdateRunWidth(); }
public EditableTextRun(RootGraphic gfx, char c, TextSpanStyle style) : base(gfx) { this.spanStyle = style; SetNewContent(new char[] { c }); if (c == '\n') { //TODO: review line break span this.IsLineBreak = true; } //check line break? UpdateRunWidth(); }
protected override void OnStartDemo(SampleViewport viewport) { var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true); var style1 = new Text.TextSpanStyle(); style1.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 10);// viewport.P.GetFont("tahoma", 10, PixelFarm.Drawing.FontStyle.Regular); textbox1.DefaultSpanStyle = style1; viewport.AddContent(textbox1); var textbox2 = new LayoutFarm.CustomWidgets.TextBox(400, 500, true); textbox2.SetLocation(20, 120); viewport.AddContent(textbox2); var textSplitter = new ContentTextSplitter(); textbox2.TextSplitter = textSplitter; textbox2.Text = "Hello World!"; }
public static TextSpanStyle CreateNewStyle(Color color) { if (color != Color.Empty) { TextSpanStyle simpleBeh = new TextSpanStyle(); // simpleBeh.SharedBgColorBrush = new ArtSolidBrush(color); return simpleBeh; } else { TextSpanStyle simpleBeh = new TextSpanStyle(); //simpleBeh.SharedBgColorBrush = new ArtSolidBrush(color); return simpleBeh; } }
public static TextSpanStyle CreateNewStyle(Color color) { if (color != Color.Empty) { TextSpanStyle simpleBeh = new TextSpanStyle(); // simpleBeh.SharedBgColorBrush = new ArtSolidBrush(color); return(simpleBeh); } else { TextSpanStyle simpleBeh = new TextSpanStyle(); //simpleBeh.SharedBgColorBrush = new ArtSolidBrush(color); return(simpleBeh); } }
public SolidTextRun(string str, TextSpanStyle style) { if (str != null && str.Length > 0) { mybuffer = str.ToCharArray(); if (mybuffer.Length == 1 && mybuffer[0] == '\n') { this.IsLineBreak = true; } UpdateRunWidth(); } else { throw new Exception("string must be null or zero length"); } }
public SolidTextRun(RootGraphic gfx, string str, TextSpanStyle style) : base(gfx) { if (str != null && str.Length > 0) { mybuffer = str.ToCharArray(); if (mybuffer.Length == 1 && mybuffer[0] == '\n') { this.IsLineBreak = true; } UpdateRunWidth(); } else { throw new Exception("string must be null or zero length"); } }
public EditableTextRun(RootGraphic gfx, string str, TextSpanStyle style) : base(gfx) { this.spanStyle = style; if (str != null && str.Length > 0) { mybuffer = str.ToCharArray(); if (mybuffer.Length == 1 && mybuffer[0] == '\n') { this.IsLineBreak = true; } UpdateRunWidth(); } else { throw new Exception("string must be null or zero length"); } }
protected PixelFarm.Drawing.RequestFont GetFont() { if (!HasStyle) { return(this.Root.DefaultTextEditFontInfo); } else { TextSpanStyle spanStyle = this.SpanStyle; if (spanStyle.FontInfo != null) { return(spanStyle.FontInfo); } else { return(this.Root.DefaultTextEditFontInfo); } } }
protected override void OnStartDemo(SampleViewport viewport) { var textbox1 = new LayoutFarm.CustomWidgets.TextBox(400, 100, true); var style1 = new Text.TextSpanStyle(); style1.FontInfo = viewport.P.GetFont("tahoma", 10, PixelFarm.Drawing.FontStyle.Regular); textbox1.DefaultSpanStyle = style1; viewport.AddContent(textbox1); var textbox2 = new LayoutFarm.CustomWidgets.TextBox(400, 500, true); textbox2.SetLocation(20, 120); viewport.AddContent(textbox2); var textSplitter = new Composers.ContentTextSplitter(); textbox2.TextSplitter = textSplitter; textbox2.Text = "Hello World!"; }
protected FontInfo GetFontInfo() { if (!HasStyle) { return(this.Root.DefaultTextEditFontInfo); } else { TextSpanStyle spanStyle = this.SpanStyle; if (spanStyle.FontInfo != null) { return(spanStyle.FontInfo); } else { return(this.Root.DefaultTextEditFontInfo); } } }
protected RequestFont GetFont() { if (!HasStyle) { return(this.Root.DefaultTextEditFontInfo); } else { TextSpanStyle spanStyle = this.SpanStyle; if (spanStyle.FontInfo != null) { return(spanStyle.FontInfo); } else { //TODO: review here return(this.Root.DefaultTextEditFontInfo); } } }
public EditableTextRun(RootGraphic gfx, string str, TextSpanStyle style) : base(gfx) { this.spanStyle = style; if (str != null && str.Length > 0) { SetNewContent(str.ToCharArray()); //special treament if (mybuffer.Length == 1 && mybuffer[0] == '\n') { this.IsLineBreak = true; } UpdateRunWidth(); } else { //TODO: review here throw new Exception("string must be null or zero length"); } }
protected RequestFont GetFont() { if (!HasStyle) { return(FontService1.DefaultFont); //return this.Root.DefaultTextEditFontInfo; } else { TextSpanStyle spanStyle = this.SpanStyle; if (spanStyle.FontInfo != null) { return(spanStyle.FontInfo); } else { return(FontService1.DefaultFont); //return this.Root.DefaultTextEditFontInfo; } } }
public void AddUnformattedStringToCurrentLine(string str, TextSpanStyle initTextSpanStyle) { //this should be a text-service work *** using (System.IO.StringReader reader = new System.IO.StringReader(str)) { string line = reader.ReadLine(); List <EditableTextRun> runs = new List <EditableTextRun>(); RootGraphic root = visualTextSurface.Root; int lineCount = 0; while (line != null) { if (lineCount > 0) { runs.Add(new EditableTextRun(root, '\n', initTextSpanStyle)); } runs.Add(new EditableTextRun(root, line, initTextSpanStyle)); line = reader.ReadLine(); lineCount++; } AddTextRunsToCurrentLine(runs.ToArray()); } }
static int EvaluateFontAndTextColor(Canvas canvas, TextSpanStyle spanStyle) { var font = spanStyle.FontInfo; var color = spanStyle.FontColor; var currentTextFont = canvas.CurrentFont; var currentTextColor = canvas.CurrentTextColor; if (font != null && font != currentTextFont) { if (currentTextColor != color) { return DIFF_FONT_DIFF_TEXT_COLOR; } else { return DIFF_FONT_SAME_TEXT_COLOR; } } else { if (currentTextColor != color) { return SAME_FONT_DIFF_TEXT_COLOR; } else { return SAME_FONT_SAME_TEXT_COLOR; } } }
//-------------------- public abstract void SetStyle(TextSpanStyle spanStyle);
public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx) { if (textEditRenderElement == null) { var tbox = new TextEditRenderBox(rootgfx, this.Width, this.Height, _multiline); tbox.SetLocation(this.Left, this.Top); tbox.HasSpecificSize = true; if (this.defaultSpanStyle.IsEmpty()) { this.defaultSpanStyle = new TextSpanStyle(); this.defaultSpanStyle.FontInfo = rootgfx.DefaultTextEditFontInfo; tbox.CurrentTextSpanStyle = this.defaultSpanStyle; } else { tbox.CurrentTextSpanStyle = this.defaultSpanStyle; } tbox.BackgroundColor = this.backgroundColor; tbox.SetController(this); if (this.textSurfaceListener != null) { tbox.TextSurfaceListener = textSurfaceListener; } this.textEditRenderElement = tbox; if (userTextContent != null) { this.Text = userTextContent; userTextContent = null;//clear } } return textEditRenderElement; }