public AbsoluteScreen(Window Parent) { InitializeComponent(); _parent = Parent; _scrollback = new ScrollbackArea(this); _cursorCanvas = new System.Windows.Controls.Canvas(); _cursorCanvas.Background = ZColorCheck.ZColorToBrush(1, ColorType.Foreground); _cursorCanvas.Visibility = System.Windows.Visibility.Visible; cnvsTop.Children.Add(_cursorCanvas); _sound = new FrotzSound(); LayoutRoot.Children.Add(_sound); _substituion = new NumberSubstitution(); setFontInfo(); _currentInfo = new CharDisplayInfo(1, 0, 1, 1); bColor = 1; this.Background = ZColorCheck.ZColorToBrush(bColor, ColorType.Background); this.MouseDown += new MouseButtonEventHandler(AbsoluteScreen_MouseDown); this.MouseDoubleClick += new MouseButtonEventHandler(AbsoluteScreen_MouseDoubleClick); }
public FontChanges(int StartCol, int Count, CharDisplayInfo FandS) { this.StartCol = StartCol; this.Count = Count; this.FandS = FandS; }
// TODO Maybe just make this take the AbsoluteText object internal void AddAbsolute(String text, int y, int x, CharDisplayInfo displayInfo) { lock (_text) { _text.Add(new AbsoluteText(text, y, x, displayInfo)); } Refresh(); }
internal ZParagraph(ZTextControl Parent, CharDisplayInfo CurrentInfo) { _parent = Parent; _currentInfo = CurrentInfo; _defaultInfo = new CharDisplayInfo(ZFont.TEXT_FONT, ZStyles.NORMAL_STYLE, 1, 1); _fixedInfo = new CharDisplayInfo(ZFont.FIXED_WIDTH_FONT, ZStyles.NORMAL_STYLE, 1, 1); }
public void SetChar(int pos, char c, CharDisplayInfo FandS) { lock (this) { _text[pos] = c; _styles[pos] = FandS; LastCharSet = Math.Max(pos, LastCharSet); _changes = null; } }
public ZTextControl() { InitializeComponent(); _currentDisplay = new CharDisplayInfo(ZFont.TEXT_FONT, ZStyles.NORMAL_STYLE, 1, 1); _currentParagraph = new ZParagraph(this, _currentDisplay); _adorner = new OverlayAdorner(rtb); this.Loaded += new RoutedEventHandler(ZTextControl_Loaded); }
internal void SetDisplayInfo(CharDisplayInfo CurrentInfo) { if (_currentText.Length > 0) { Dispatcher.Invoke(new Action(delegate { Flush(); })); } _currentInfo = CurrentInfo; }
private void SendStringToScreen(String text, CharDisplayInfo cdi) { invoke(() => { Image myImage = new Image(); DrawingVisual dv = new DrawingVisual(); DrawingContext dc = dv.RenderOpen(); double x = _cursorX; double y = _cursorY; if (lastDrawn != Rect.Empty && inInputMode == false) { x = lastDrawn.X + lastDrawn.Width; } FontInfo fi = _regularFont; if (cdi.Font == 4) { fi = _fixedFont; } FormattedText ft = buildFormattedText(text, fi, cdi, dc); Brush b = Brushes.Transparent; if (cdi.ImplementsStyle(ZStyles.REVERSE_STYLE)) { b = ZColorCheck.ZColorToBrush(cdi.ForegroundColor, ColorType.Foreground); } else { if (_currentInfo.BackgroundColor != bColor) { b = ZColorCheck.ZColorToBrush(cdi.BackgroundColor, ColorType.Background); } } dc.DrawRectangle(b, null, new Rect(0, 0, ft.WidthIncludingTrailingWhitespace, charHeight)); dc.DrawText(ft, new Point(0, 0)); dc.Close(); RenderTargetBitmap bmp = new RenderTargetBitmap((int)dv.ContentBounds.Width, (int)charHeight, 96, 96, PixelFormats.Pbgra32); bmp.Render(dv); myImage.Source = bmp; mainCanvas.Children.Add(myImage); myImage.SetValue(Canvas.TopProperty, y); myImage.SetValue(Canvas.LeftProperty, x); lastDrawn = new Rect(x, y, (int)dv.ContentBounds.Width, charHeight); removeCoveredImages(myImage); }); }
public int GetStringWidth(string s, CharDisplayInfo Font) { throw new NotImplementedException(); }
public int GetStringWidth(string s, CharDisplayInfo Font) { FormattedText ft; if (Font.Font == ZFont.FIXED_WIDTH_FONT) { ft = buildFormattedText(s, _fixedFont, true, null, null); } else { ft = buildFormattedText(s, _regularFont, true, null, null); } return (int)ft.WidthIncludingTrailingWhitespace; }
private void setAbsolute(String text, int _x, CharDisplayInfo _info) { _parent._adorner.AddAbsolute(text, (int)Top, _x, _info); }
public int GetStringWidth(string s, CharDisplayInfo Font) { return s.Length; }
public CharInfo(char character, CharDisplayInfo displayInfo) { Character = character; DisplayInfo = displayInfo; }
public CharInfo(char Character, CharDisplayInfo DisplayInfo) { this._character = Character; this._displayInfo = DisplayInfo; }
public void setStyle(CharDisplayInfo fs, int count, FormattedText ft) { if ((fs.Style & (int)ZStyles.BOLDFACE_STYLE) > 0) { ft.SetFontWeight(FontWeights.Bold); } if ((fs.Style & (int)ZStyles.REVERSE_STYLE) > 0) { ft.SetFontWeight(FontWeights.Bold); ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.BackgroundColor, ColorType.Background)); } else { ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.ForegroundColor, ColorType.Foreground)); } if ((fs.Style & (int)ZStyles.EMPHASIS_STYLE) > 0) { ft.SetFontStyle(FontStyles.Italic); } if ((fs.Style & (int)ZStyles.FIXED_WIDTH_STYLE) > 0) { ft.SetFontFamily(_fixedFont.Family); } }
private ZRun CreateInline(String Text, CharDisplayInfo DisplayInfo) { // Add an empty inline to allow for the absolute positioning ZRun temp = new ZRun(DisplayInfo); temp.Text = Text; if (_currentInfo.Font == 1) { temp.FontFamily = _parent._regularFont.Family; } else { temp.FontFamily = _parent._fixedFont.Family; } ImplementRunStyle(temp); return temp; }
private ZRun AddInline(String Text, CharDisplayInfo DisplayInfo) { ZRun temp = CreateInline(Text, DisplayInfo); Inlines.Add(temp); return temp; }
private bool IsFixedWidth(CharDisplayInfo Info) { return (Info.Font == ZFont.FIXED_WIDTH_FONT || Info.ImplementsStyle(ZStyles.FIXED_WIDTH_STYLE)); }
protected FormattedText buildFormattedText(String Text, FontInfo Font, CharDisplayInfo cdi, DrawingContext dc) { TextFormattingMode tfm = TextFormattingMode.Display; FormattedText ft = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, Font.Typeface, Font.PointSize, ZColorCheck.ZColorToBrush(cdi.ForegroundColor, ColorType.Foreground), _substituion, tfm); setStyle(cdi, Text.Length, ft); return ft; }
public int GetStringWidth(string s, CharDisplayInfo Font) { int f = Font.Font; if (f == -1) f = _currentInfo.Font; FormattedText ft; if (f == ZFont.FIXED_WIDTH_FONT) { ft = buildFormattedText(s, _fixedFont, _currentInfo, null); } else if (f == ZFont.GRAPHICS_FONT) { ft = buildFormattedText(s, _fixedFont, _currentInfo, null); } else { ft = buildFormattedText(s, _regularFont, _currentInfo, null); } return (int)ft.WidthIncludingTrailingWhitespace; }
public void AddString(String text, CharDisplayInfo cdi) { if (text == "") return; _parent.Dispatcher.Invoke(new Action(delegate { if (text == "\r\n") { if (_p.Inlines.LastInline is LineBreak && _p.Inlines.LastInline.PreviousInline is LineBreak) { return; } LineBreak lb = new LineBreak(); _p.Inlines.Add(lb); _currentRun = null; return; } if (currentStyle != cdi.Style) { currentStyle = cdi.Style; _currentRun = new Run(); _p.Inlines.Add(_currentRun); if ((cdi.Style & ZStyles.BOLDFACE_STYLE) != 0) { _currentRun.FontWeight = FontWeights.Bold; } if ((cdi.Style & ZStyles.EMPHASIS_STYLE) != 0) { _currentRun.FontStyle = FontStyles.Italic; } if ( (cdi.Style & ZStyles.REVERSE_STYLE) != 0) { _currentRun.Background = Brushes.Black; _currentRun.Foreground = Brushes.White; } if ( (cdi.Style & ZStyles.FIXED_WIDTH_STYLE) != 0) { _currentRun.FontFamily = new System.Windows.Media.FontFamily(Properties.Settings.Default.FixedWidthFont); } } if (_currentRun == null) { _currentRun = new Run(text); _p.Inlines.Add(_currentRun); } else { _currentRun.Text += text; if (_currentRun.Text.EndsWith(threeNewLines)) { StringBuilder sb = new StringBuilder(_currentRun.Text); while (sb.ToString().EndsWith(threeNewLines)) { sb.Remove(sb.Length - 2, 2); } _currentRun.Text = sb.ToString(); // } } _RTB.CaretPosition = _RTB.CaretPosition.DocumentEnd; })); }
internal AbsoluteText(String text, int y, int x, CharDisplayInfo displayInfo) { this.Text = text; this.X = x; this.Y = y; this.DisplayInfo = displayInfo; }
public void AddChar(char c, CharDisplayInfo FandS) { SetChar(++LastCharSet, c, FandS); }
public bool AreSame(CharDisplayInfo fs) { return (fs.Font == this.Font && fs.Style == this.Style && fs.ForegroundColor == this.ForegroundColor && fs.BackgroundColor == this.BackgroundColor); }
public bool AreSame(CharDisplayInfo fs) { return(fs.Font == this.Font && fs.Style == this.Style && fs.ForegroundColor == this.ForegroundColor && fs.BackgroundColor == this.BackgroundColor); }
public void SetChar(int Row, int Col, char c, CharDisplayInfo FandS) { // TODO Check boundaries _lines[Row].SetChar(Col, c, FandS); }
internal ZRun(CharDisplayInfo DisplayInfo) { this.DisplayInfo = DisplayInfo; }
public void SetChar(int row, int col, char c, CharDisplayInfo FandS = default) { // TODO Check boundaries _lines[row].SetChar(col, c, FandS); }
public void setStyle(CharDisplayInfo fs, FontChanges fc, FormattedText ft, DrawingContext dc) { int startPos = fc.Offset + fc.StartCol; if ((fs.Style & (int)ZStyles.BOLDFACE_STYLE) > 0) { ft.SetFontWeight(FontWeights.Bold, startPos, fc.Count); } int rectColor = -1; ColorType type = ColorType.Foreground; if ((fs.Style & (int)ZStyles.REVERSE_STYLE) > 0) { ft.SetFontWeight(FontWeights.Bold, startPos, fc.Count); ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.BackgroundColor, ColorType.Background), startPos, fc.Count); rectColor = fs.ForegroundColor; } else { ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.ForegroundColor, ColorType.Foreground), startPos, fc.Count); if (fs.BackgroundColor > 1 && fs.BackgroundColor != bColor) { rectColor = fs.BackgroundColor; type = ColorType.Background; } } if ((fs.Style & (int)ZStyles.EMPHASIS_STYLE) > 0) { ft.SetFontStyle(FontStyles.Italic, startPos, fc.Count); } if ((fs.Style & (int)ZStyles.FIXED_WIDTH_STYLE) > 0) { ft.SetFontFamily(_fixedFont.Family, startPos, fc.Count); } if (dc != null && rectColor != -1) { Brush b = ZColorCheck.ZColorToBrush(rectColor, type); dc.DrawRectangle(b, null, new Rect(fc.StartCol * charWidth, fc.Line * charHeight, fc.Count * charWidth, charHeight)); } }