Exemplo n.º 1
0
        public TextControlScreen(Window Parent)
        {
            InitializeComponent();

            _parent = Parent;
            Margin  = new Thickness(0);

            _parent = Parent;

            _cursorCanvas = new Canvas
            {
                Background = ZColorCheck.ZColorToBrush(1, ColorType.Foreground),
                Visibility = Visibility.Hidden
            };
            cnvsTop.Children.Add(_cursorCanvas);

            _sound = new FrotzSound();
            LayoutRoot.Children.Add(_sound);

            fColor = 1;
            bColor = 1;

            Background = ZColorCheck.ZColorToBrush(1, ColorType.Background);

            _substituion = new NumberSubstitution();

            SetFontInfo();

            Unloaded += (s, e) =>
            {
                _regularLines?.Dispose();
                _fixedWidthLines?.Dispose();
            };
        }
Exemplo n.º 2
0
        public TextControlScreen(Window Parent)
        {
            InitializeComponent();

            _parent     = Parent;
            this.Margin = new Thickness(0);

            _parent = Parent;

            _cursorCanvas            = new System.Windows.Controls.Canvas();
            _cursorCanvas.Background = ZColorCheck.ZColorToBrush(1, ColorType.Foreground);
            _cursorCanvas.Visibility = System.Windows.Visibility.Hidden;
            cnvsTop.Children.Add(_cursorCanvas);

            _sound = new FrotzSound();
            LayoutRoot.Children.Add(_sound);

            fColor = 1;
            bColor = 1;

            this.Background = ZColorCheck.ZColorToBrush(1, ColorType.Background);

            _substituion = new NumberSubstitution();

            setFontInfo();
        }
        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);
        }
Exemplo n.º 4
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            lock (_text)
            {
                if (RegularFont == null || FixedWidthFont == null)
                {
                    return;
                }
                foreach (var at in _text)
                {
                    FontInfo f = RegularFont;
                    if (at.DisplayInfo.Font == ZFont.FIXED_WIDTH_FONT || at.DisplayInfo.ImplementsStyle(ZStyles.FIXED_WIDTH_STYLE))
                    {
                        f = FixedWidthFont;
                    }
                    Brush         b  = ZColorCheck.ZColorToBrush(at.DisplayInfo.ForegroundColor, Support.ColorType.Foreground);
                    FormattedText ft = new FormattedText(at.Text,
                                                         System.Globalization.CultureInfo.CurrentCulture,
                                                         FlowDirection.LeftToRight, f.Typeface, f.PointSize, b,
                                                         new NumberSubstitution(), TextFormattingMode.Display);

                    if (at.DisplayInfo.ImplementsStyle(ZStyles.REVERSE_STYLE))
                    {
                        drawingContext.DrawRectangle(b, null, new Rect(at.X + 2, at.Y + 2, ft.WidthIncludingTrailingWhitespace, Math.Max(ft.Height, FontHeight)));
                        ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(at.DisplayInfo.BackgroundColor, Support.ColorType.Background));
                    }
                    drawingContext.DrawText(ft, new Point(at.X + 2, at.Y + 2));
                    // Note: Offsetting positions by 2 to get everything to line up correctly
                }
            }
        }
        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 void Clear()
 {
     invoke(() =>
     {
         mainCanvas.Children.Clear();
         bColor          = _currentInfo.BackgroundColor;
         this.Background = ZColorCheck.ZColorToBrush(_currentInfo.BackgroundColor, ColorType.Background);
     });
 }
Exemplo n.º 7
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));
            }
        }
Exemplo n.º 8
0
        public void Clear()
        {
            ztc.Clear();

            Dispatcher.Invoke(() =>
            {
                Background = ZColorCheck.ZColorToBrush(bColor, ColorType.Background);

                for (int i = 0; i < cnvsTop.Children.Count; i++)
                {
                    {
                        if (cnvsTop.Children[i] is Image img)
                        {
                            cnvsTop.Children.RemoveAt(i--);
                        }
                    }
                }
            });
        }
Exemplo n.º 9
0
        public void Clear()
        {
            ztc.Clear();

            Dispatcher.Invoke(new Action(delegate
            {
                this.Background = ZColorCheck.ZColorToBrush(bColor, ColorType.Background);

                for (int i = 0; i < cnvsTop.Children.Count; i++)
                {
                    {
                        Image img = cnvsTop.Children[i] as Image;
                        if (img != null)
                        {
                            cnvsTop.Children.RemoveAt(i--);
                        }
                    }
                }
            }));
        }
Exemplo n.º 10
0
        internal void SetFontInfo()
        {
            int font_size = Properties.Settings.Default.FontSize;

            _regularFont = new FontInfo(Properties.Settings.Default.ProportionalFont, font_size);
            _fixedFont   = new FontInfo(Properties.Settings.Default.FixedWidthFont, font_size);

            rtb.FontFamily = _regularFont.Family;
            rtb.FontSize   = _regularFont.PointSize;
            _fd            = new System.Windows.Documents.FlowDocument();
            rtb.Document   = _fd;
            rtb.Background = Brushes.Transparent;
            rtb.Foreground = ZColorCheck.ZColorToBrush(1, ColorType.Foreground);
            rtb.IsReadOnly = true;

            _adorner.RegularFont    = _regularFont;
            _adorner.FixedWidthFont = _fixedFont;
            _adorner.Clear();

            // this.Background = ZColorCheck.ZColorToBrush(1, ColorType.Background);
        }
Exemplo n.º 11
0
        private FormattedText buildFormattedText(String Text, FontInfo Font, bool UseDisplayMode,
                                                 List <FontChanges> changes, DrawingContext dc)
        {
            TextFormattingMode tfm = TextFormattingMode.Display;
            FormattedText      ft  = new FormattedText(Text,
                                                       CultureInfo.CurrentCulture,
                                                       FlowDirection.LeftToRight,
                                                       Font.Typeface,
                                                       Font.PointSize,
                                                       ZColorCheck.ZColorToBrush(fColor, ColorType.Foreground),
                                                       _substituion, tfm);

            if (changes != null)
            {
                foreach (FontChanges fc in changes)
                {
                    setStyle(fc.FandS, fc, ft, dc);
                }
            }

            return(ft);
        }
Exemplo n.º 12
0
        private FormattedText BuildFormattedText(string text, FontInfo font, bool useDisplayMode,
                                                 List <FontChanges> changes, DrawingContext dc)
        {
            var tfm = TextFormattingMode.Display;
            var ft  = new FormattedText(text,
                                        CultureInfo.CurrentCulture,
                                        FlowDirection.LeftToRight,
                                        font.Typeface,
                                        font.PointSize,
                                        ZColorCheck.ZColorToBrush(fColor, ColorType.Foreground),
                                        _substituion, tfm, VisualTreeHelper.GetDpi(this).PixelsPerDip);

            if (changes != null)
            {
                foreach (var fc in changes)
                {
                    SetStyle(fc.FontAndStyle, fc, ft, dc);
                }
            }

            return(ft);
        }
Exemplo n.º 13
0
        internal void ImplementRunStyle(ZRun run)
        {
            if (run == null)
            {
                return;
            }

            if (run.DisplayInfo.ImplementsStyle(ZStyles.BOLDFACE_STYLE))
            {
                FontWeight = FontWeights.Bold;
            }

            if (run.DisplayInfo.ImplementsStyle(ZStyles.EMPHASIS_STYLE))
            {
                run.FontStyle = FontStyles.Italic;
            }

            if (run.DisplayInfo.ImplementsStyle(ZStyles.FIXED_WIDTH_STYLE) || run.DisplayInfo.Font != ZFont.TEXT_FONT)
            {
                run.FontFamily = _parent._fixedFont.Family;
            }

            if (run.DisplayInfo.ImplementsStyle(ZStyles.REVERSE_STYLE))
            {
                run.Background = ZColorCheck.ZColorToBrush(run.DisplayInfo.ForegroundColor, ColorType.Foreground);
                run.Foreground = ZColorCheck.ZColorToBrush(run.DisplayInfo.BackgroundColor, ColorType.Background);
            }
            else
            {
                run.Foreground = ZColorCheck.ZColorToBrush(run.DisplayInfo.ForegroundColor, ColorType.Foreground);
                int color = run.DisplayInfo.BackgroundColor;
                if (color != _parent.bColor)
                {
                    run.Background = ZColorCheck.ZColorToBrush(color, ColorType.Background);
                }
            }
        }