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);
        }
예제 #2
0
        private ZRun AddInline(String Text, CharDisplayInfo DisplayInfo)
        {
            ZRun temp = CreateInline(Text, DisplayInfo);

            Inlines.Add(temp);
            return(temp);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 internal AbsoluteText(String text, int y, int x, CharDisplayInfo displayInfo)
 {
     this.Text        = text;
     this.X           = x;
     this.Y           = y;
     this.DisplayInfo = displayInfo;
 }
        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);
        }
예제 #6
0
        public int GetStringWidth(string s, CharDisplayInfo font)
        {
            var ft = font.Font == ZFont.FIXED_WIDTH_FONT
                ? BuildFormattedText(s, _fixedFont, true, null, null)
                : BuildFormattedText(s, _regularFont, true, null, null);

            return((int)ft.WidthIncludingTrailingWhitespace);
        }
예제 #7
0
        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);
        }
예제 #8
0
 // 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();
 }
        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);
            });
        }
예제 #10
0
 internal void SetDisplayInfo(CharDisplayInfo CurrentInfo)
 {
     if (_currentText.Length > 0)
     {
         Dispatcher.Invoke(new Action(delegate
         {
             Flush();
         }));
     }
     _currentInfo = CurrentInfo;
 }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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));
            }
        }
예제 #15
0
        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);
        }
예제 #16
0
 private void setAbsolute(String text, int _x, CharDisplayInfo _info)
 {
     _parent._adorner.AddAbsolute(text, (int)Top, _x, _info);
 }
예제 #17
0
파일: ZRun.cs 프로젝트: jtmueller/frotzcore
 internal ZRun(CharDisplayInfo displayInfo)
 {
     DisplayInfo = displayInfo;
 }
예제 #18
0
        public void AddString(string text, CharDisplayInfo cdi)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            _parent.Dispatcher.Invoke(() =>
            {
                if (text == "\r\n")
                {
                    if (_p.Inlines.LastInline is LineBreak && _p.Inlines.LastInline.PreviousInline is LineBreak)
                    {
                        return;
                    }
                    var 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))
                    {
                        var sb = new StringBuilder(_currentRun.Text);

                        while (sb[^ 6] == '\r' && sb[^ 5] == '\n' &&
                               sb[^ 4] == '\r' && sb[^ 3] == '\n' &&
                               sb[^ 2] == '\r' && sb[^ 1] == '\n')
                        {
                            sb.Remove(^ 2..);
                        }

                        _currentRun.Text = sb.ToString();

                        //
                    }
예제 #19
0
        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;
            }));
        }
예제 #20
0
 private bool IsFixedWidth(CharDisplayInfo Info)
 {
     return(Info.Font == ZFont.FIXED_WIDTH_FONT || Info.ImplementsStyle(ZStyles.FIXED_WIDTH_STYLE));
 }
예제 #21
0
 internal ZRun(CharDisplayInfo DisplayInfo)
 {
     this.DisplayInfo = DisplayInfo;
 }
예제 #22
0
 public FontChanges(int startCol, int count, CharDisplayInfo FandS)
 {
     StartCol     = startCol;
     FontAndStyle = FandS;
     _sb          = new(count);
 }
예제 #23
0
 public int GetStringWidth(string s, CharDisplayInfo Font)
 {
     return(s.Length);
 }