コード例 #1
0
        public virtual Window CreateWindow(Window owner, string title, bool modal)
        {
            Window window = new Window();

            if (title != null)
            {
                window.Title = title;
            }

            if (owner != null)
            {
                window.Owner = owner;
            }

            if (modal)
            {
                window.ShowInTaskbar = false;
            }

            // Needed for sharp text rendering.
            TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(window, TextRenderingMode.Aliased);

            return(window);
        }
コード例 #2
0
        public WindowHelper(Window window)
        {
            this.window = window;

            // Set the icon.
            window.Icon = SessionCore.Instance.Icon;
            window.UseLayoutRounding = true;
            TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(window, TextRenderingMode.ClearType);

            // Set vertical content align for all textboxes
            window.Loaded += delegate(object sender, RoutedEventArgs e) {
                foreach (TextBox item in window.FindVisualChildren <TextBox>())
                {
                    if (item.VerticalScrollBarVisibility != ScrollBarVisibility.Visible)
                    {
                        item.VerticalContentAlignment = VerticalAlignment.Center;
                    }
                }
            };

            // Set the focus to the first control.
            window.SourceInitialized += (sender, e) => {
                window.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                currentZoom = 1;
                if (Settings.Zoom != 1)
                {
                    Settings_Changed(null, null);
                }
            };

            Settings.SettingsChanged += Settings_Changed;
        }
コード例 #3
0
        /// <summary>
        /// Creates the font preview.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateFontPreview(PropertyItem property)
        {
            var c = new TextBox
            {
                Background    = Brushes.Transparent,
                BorderBrush   = null,
                AcceptsReturn = true,
                TextWrapping  = TextWrapping.Wrap,
                FontWeight    = FontWeight.FromOpenTypeWeight(property.FontWeight),
                FontSize      = property.FontSize
            };

            TextOptions.SetTextFormattingMode(c, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(c, TextRenderingMode.ClearType);
            c.SetBinding(TextBox.TextProperty, new Binding(property.Descriptor.Name)
            {
                Mode = BindingMode.OneWay
            });
            if (property.FontFamilyPropertyDescriptor != null)
            {
                c.SetBinding(Control.FontFamilyProperty, new Binding(property.FontFamilyPropertyDescriptor.Name));
            }

            return(c);
        }
コード例 #4
0
        public override object GetEditableControl()
        {
            var value = GetValue();

            _dateTimePicker = new DateTimePicker
            {
                Foreground        = Brushes.Blue,
                BorderThickness   = new Thickness(0),
                BorderBrush       = Brushes.Transparent,
                Background        = Brushes.Transparent,
                Padding           = new Thickness(0),
                Margin            = new Thickness(0),
                VerticalAlignment = VerticalAlignment.Top,
                FontFamily        = new FontFamily(@"Segoe UI"),
                FontSize          = 11
            };

            TextOptions.SetTextRenderingMode(_dateTimePicker, TextRenderingMode.ClearType);
            TextOptions.SetTextFormattingMode(_dateTimePicker, TextFormattingMode.Display);

            _dateTimePicker.Value = DateTimeExtensions.FromIso(value, DateTime.MinValue);

            _dateTimePicker.ValueChanged += SetValue;

            return(_dateTimePicker);
        }
コード例 #5
0
        => userControl.GetType().FullName == "Microsoft.VisualStudio.Text.AdornmentLibrary.ToolTip.Implementation.WpfToolTipControl";                 // VS 15.8

        private static void SetItemsControlStyle([NotNull] ItemsControl itemsControl, [CanBeNull] IDocument document)
        {
            if (!(itemsControl.GetValue(_originalStylesProperty) is OriginalStyles))
            {
                itemsControl.SetValue(_originalStylesProperty, new OriginalStyles {
                    Style = itemsControl.Style,
                    ItemContainerStyle = itemsControl.ItemContainerStyle,
                    ItemTemplate       = itemsControl.ItemTemplate
                });
            }

            IContextBoundSettingsStore settings = document.TryGetSettings();

            bool isLegacy = itemsControl is ListBox;

            itemsControl.Style              = UIResources.Instance.QuickInfoListBoxStyle;
            itemsControl.ItemTemplate       = isLegacy ? UIResources.Instance.LegacyQuickInfoItemDataTemplate : UIResources.Instance.QuickInfoItemDataTemplate;
            itemsControl.ItemContainerStyle = CreateItemContainerStyle(settings, isLegacy);
            itemsControl.MaxWidth           = ComputeItemsControlMaxWidth(itemsControl, settings);
            TextOptions.SetTextFormattingMode(itemsControl, GetTextFormattingMode(settings));
            TextOptions.SetTextRenderingMode(itemsControl, TextRenderingMode.Auto);

            if (!isLegacy &&
                itemsControl.FindVisualAncestor(o => o is UserControl uc && IsToolTipRootControl(uc)) is UserControl rootControl)
            {
                SetRootControlTemplate(rootControl);
            }
        }
コード例 #6
0
 public DevWindowBase()
 {
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
     SizeToContent         = SizeToContent.WidthAndHeight;
     TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
     TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
 }
コード例 #7
0
        private static byte[] CreateRGBByteArray(int width, int height)
        {
            var dv = new DrawingVisual();

            TextOptions.SetTextRenderingMode(dv, TextRenderingMode.Aliased);
            TextOptions.SetTextFormattingMode(dv, TextFormattingMode.Ideal);

            using (var dc = dv.RenderOpen())
            {
                dc.DrawRectangle(new SolidColorBrush(Colors.White), null, new Rect(0, 0, width, height));
                var radius = width / 2;
                dc.DrawEllipse(
                    new SolidColorBrush(Colors.Crimson),
                    null,
                    new System.Windows.Point(0.5 * width, 0.5 * height),
                    radius,
                    radius);
            }
            RenderTargetBitmap rtb = new RenderTargetBitmap(
                width,
                height,
                96,
                96,
                PixelFormats.Pbgra32);

            rtb.Render(dv);

            var converted = new FormatConvertedBitmap(rtb, PixelFormats.Bgr24, null, 0);

            var imageBytes = new byte[rtb.PixelHeight * rtb.PixelWidth * 3];

            converted.CopyPixels(imageBytes, rtb.PixelWidth * 3, 0);

            return(imageBytes);
        }
コード例 #8
0
        //public static void SaveImageToFile(string filePath, BitmapSource image)
        //{
        //    using (var fileStream = new FileStream(filePath, FileMode.Create))
        //    {
        //        BitmapEncoder encoder = new PngBitmapEncoder();
        //        encoder.Frames.Add(BitmapFrame.Create(image));
        //        encoder.Save(fileStream);
        //    }
        //}

        public static void SaveTo(Stream stream, DrawingImage drawing)
        {
            if (drawing.Width <= 1 || drawing.Height < 1)
            {
                return;
            }

            var image = new Image {
                Source = drawing
            };

            image.Arrange(new Rect(new Size(drawing.Width, drawing.Height)));

            // this is the important line here!
            TextOptions.SetTextRenderingMode(image, TextRenderingMode.Aliased);

            // note if you use a different DPI than the screen (96 here), you still will have anti-aliasing
            // as the system is pretty automatic anyway
            var bitmap = new RenderTargetBitmap((int)drawing.Width, (int)drawing.Height, 96, 96, PixelFormats.Pbgra32);

            bitmap.Render(image);


            var encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(bitmap));
            encoder.Save(stream);
        }
コード例 #9
0
        public WindowHelper(Window window)
        {
            this.window = window;

            // All windows will get the icon of the first window.
            if (Icon == null)
            {
                Icon = window.Icon;
            }
            else
            {
                // Set the icon.
                window.Icon = Icon;
                window.UseLayoutRounding = true;
                TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display);
                TextOptions.SetTextRenderingMode(window, TextRenderingMode.ClearType);
            }

            // Set vertical content align for all textboxes
            window.Loaded += delegate(object sender, RoutedEventArgs e) {
                foreach (TextBox item in window.FindVisualChildren <TextBox>())
                {
                    if (item.VerticalScrollBarVisibility != ScrollBarVisibility.Visible)
                    {
                        item.VerticalContentAlignment = VerticalAlignment.Center;
                    }
                }
            };

            // Set the focus to the first control.
            window.SourceInitialized += (sender, e) => {
                window.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            };
        }
コード例 #10
0
        public static FrameworkElement MakeSingleLineItem(BadgeCaps device, string message, bool halfSize = false, bool fullWidth = true)
        {
            var   size    = halfSize ? 7 : 12;
            var   font    = new FontFamily(halfSize ? "Lucida Console" : "Arial");
            Brush color   = Brushes.White;
            var   element = new TextBlock()
            {
                Text                = message,
                Background          = Brushes.Transparent,
                FontSize            = size,
                Margin              = halfSize ? new Thickness(0, 0, 0, -1) : new Thickness(0, -2, 0, 0),
                FontFamily          = font,
                TextWrapping        = TextWrapping.NoWrap,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                TextAlignment       = System.Windows.TextAlignment.Center,
                Foreground          = color,
                MinWidth            = !fullWidth || halfSize ? 0 : device.Width,
                UseLayoutRounding   = true,
                SnapsToDevicePixels = true
            };

            TextOptions.SetTextFormattingMode(element, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(element, TextRenderingMode.Aliased);
            TextOptions.SetTextHintingMode(element, TextHintingMode.Fixed);

            return(element);
        }
コード例 #11
0
ファイル: Styling.cs プロジェクト: nnunix/dwsim5
        public static void SetStyles()
        {
            Eto.Style.Add <Eto.Forms.Button>("main", button =>
            {
                var wpfbutton             = (Button)button.ControlObject;
                wpfbutton.BorderThickness = new Thickness(0.0);
                var img    = (Image)((Grid)wpfbutton.Content).Children[0];
                img.Margin = new Thickness(5.0d);
                var label  = (Label)((Grid)wpfbutton.Content).Children[1];
                label.HorizontalAlignment = HorizontalAlignment.Left;
                TextOptions.SetTextRenderingMode(label, TextRenderingMode.Auto);
            });

            Eto.Style.Add <Eto.Forms.Button>("donate", button =>
            {
                var wpfbutton             = (Button)button.ControlObject;
                wpfbutton.BorderThickness = new Thickness(0.0);
                var img    = (Image)((Grid)wpfbutton.Content).Children[0];
                img.Margin = new Thickness(5.0d);
                var label  = (Label)((Grid)wpfbutton.Content).Children[1];
                label.HorizontalAlignment = HorizontalAlignment.Left;
                TextOptions.SetTextRenderingMode(label, TextRenderingMode.Auto);
            });

            Eto.Style.Add <Eto.Forms.Panel>("transparent-form", control =>
            {
                var wpfwnd = (System.Windows.Window)control.ControlObject;
                TextOptions.SetTextRenderingMode(wpfwnd, TextRenderingMode.Auto);
                wpfwnd.AllowsTransparency = true;
                wpfwnd.Background         = Brushes.Transparent;
            });

            Eto.Style.Add <Eto.Forms.TextBox>("textbox-rightalign", control =>
            {
                var tbox           = (System.Windows.Controls.TextBox)control.ControlObject;
                tbox.TextAlignment = TextAlignment.Right;
            });

            Eto.Style.Add <Eto.Forms.GridView>("spreadsheet", control =>
            {
                var wpfgrid           = (Eto.Wpf.Forms.Controls.EtoDataGrid)control.ControlObject;
                wpfgrid.SelectionUnit = DataGridSelectionUnit.Cell;
                var style             = new Style(typeof(DataGridColumnHeader));
                style.Setters.Add(new Setter(DataGrid.HorizontalContentAlignmentProperty, HorizontalAlignment.Center));
                wpfgrid.ColumnHeaderStyle          = style;
                wpfgrid.ColumnWidth                = new DataGridLength(100, DataGridLengthUnitType.Pixel);
                wpfgrid.HeadersVisibility          = DataGridHeadersVisibility.All;
                wpfgrid.RowHeaderWidth             = 50;
                wpfgrid.EnableColumnVirtualization = true;
                wpfgrid.EnableRowVirtualization    = true;
                VirtualizingPanel.SetVirtualizationMode(wpfgrid, VirtualizationMode.Recycling);
                VirtualizingStackPanel.SetIsVirtualizing(wpfgrid, true);
                wpfgrid.LoadingRow += (sender, e) =>
                {
                    e.Row.Header = (e.Row.GetIndex() + 1).ToString();
                };
                wpfgrid.UpdateLayout();
            });
        }
コード例 #12
0
        public TimelineDialog()
        {
            InitializeComponent();

            if (Settings.Default.IsClearTypeEnabled)
            {
                TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
            }
        }
コード例 #13
0
        public PopupWindow()
        {
            InitializeComponent();

            if (Settings.Default.IsClearTypeEnabled)
            {
                TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
            }
        }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionControl"/> class.
        /// </summary>
        public SessionControl()
        {
            TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
            RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);

            VisualTextRenderingMode = TextRenderingMode.ClearType;

            InitializeComponent();
        }
コード例 #15
0
ファイル: WpfHelper.VS.cs プロジェクト: wangjieest/Codist
 public static void SetUITextRenderOptions(DependencyObject element, bool optimize)
 {
     if (element == null)
     {
         return;
     }
     //TextOptions.SetTextFormattingMode(element, optimize ? TextFormattingMode.Ideal : TextFormattingMode.Display);
     TextOptions.SetTextHintingMode(element, optimize ? TextHintingMode.Fixed : TextHintingMode.Auto);
     TextOptions.SetTextRenderingMode(element, optimize ? TextRenderingMode.Grayscale : TextRenderingMode.Auto);
 }
コード例 #16
0
        public BaseWindow()
        {
            InitializeComponent();

            TextOptions.SetTextRenderingMode(this, TextRenderingMode.Auto);
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);

            this.Closed       += OnClosed;
            this.StateChanged += BaseWindow_StateChanged;
        }
コード例 #17
0
ファイル: WindowBase.cs プロジェクト: Macbiche/Playnite
        public WindowBase() : base()
        {
            Style defaultStyle = (Style)Application.Current.TryFindResource(typeof(WindowBase));

            if (defaultStyle != null)
            {
                Style = defaultStyle;
            }

            TextOptions.SetTextFormattingMode(this, TextFormattingMode);
            TextOptions.SetTextRenderingMode(this, TextRenderingMode);
        }
コード例 #18
0
        protected override void CreateImage()
        {
            // If width and height are not set, we need to measure the string.
            int  calculatedWidth, calculatedHeight;
            Size measuredSize = MeasureString();

            if (Width == null || Height == null)
            {
                double width  = Width ?? measuredSize.Width;
                double height = Height ?? measuredSize.Height;
                calculatedWidth  = (int)width;
                calculatedHeight = (int)height;
            }
            else             // otherwise just create the image at the desired size
            {
                calculatedWidth  = Width.Value;
                calculatedHeight = Height.Value;
            }

            #region Draw text

            DrawingVisual  dv = new DrawingVisual();
            DrawingContext dc = dv.RenderOpen();

            //RenderOptions.SetClearTypeHint(dv, ClearTypeHint.Auto);
            TextOptions.SetTextRenderingMode(dv, TextRenderingMode.Auto);
            //TextOptions.SetTextFormattingMode(dv, TextFormattingMode.Ideal)

            UseFormattedText(ft =>
            {
                Pen pen = null;
                if (StrokeWidth > 0 && StrokeColor != null)
                {
                    pen = new Pen(new SolidColorBrush(StrokeColor.Value.ToWpfColor()), StrokeWidth);
                }

                // Calculate position to draw text at, based on vertical text alignment.
                int x = CalculateHorizontalPosition((int)measuredSize.Width);
                int y = CalculateVerticalPosition((int)measuredSize.Height);

                dc.DrawGeometry(new SolidColorBrush(ForeColor.ToWpfColor()), pen,
                                ft.BuildGeometry(new Point(x, y)));
            });

            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(calculatedWidth, calculatedHeight);
            rtb.Render(dv);

            #endregion

            Bitmap = new FastBitmap(rtb);
        }
コード例 #19
0
        public static void GetTextOptions(FrameworkElement element)
        {
            var ar = new[] { "Windows Vista", "Windows 7", "Windows 8" };

            if (ar.Any(j => j.Contains(GetOSName())))
            {
                return;
            }
            RenderOptions.SetClearTypeHint(element, ClearTypeHint.Enabled);
            TextOptions.SetTextRenderingMode(element, TextRenderingMode.Aliased);
            TextOptions.SetTextFormattingMode(element, TextFormattingMode.Display);
        }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedPage{TView, TViewModel}"/> class.
        /// </summary>
        protected ExtendedPage()
        {
            SnapsToDevicePixels = true;

            FocusVisualStyle = null;

            TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
            RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);

            VisualTextRenderingMode = TextRenderingMode.ClearType;
        }
コード例 #21
0
ファイル: ZWindow.cs プロジェクト: jtmueller/NZag
        protected ZWindow(ZWindowManager manager, FontAndColorService fontAndColorService)
        {
            this.Manager             = manager;
            this.fontAndColorService = fontAndColorService;
            this.foregroundThreadAffinitizedObject = new ForegroundThreadAffinitizedObject();

            UseLayoutRounding   = true;
            SnapsToDevicePixels = true;

            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(this, TextRenderingMode.Auto);
        }
コード例 #22
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);
            if (!e.Handled && e.Key == Key.D && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
            {
                enableFocusDebugOutput = !enableFocusDebugOutput;

                StringWriter output = new StringWriter();
                output.WriteLine("Keyboard.FocusedElement = " + GetElementName(Keyboard.FocusedElement));
                output.WriteLine("ActiveContent = " + GetElementName(this.ActiveContent));
                output.WriteLine("ActiveViewContent = " + GetElementName(this.ActiveViewContent));
                output.WriteLine("ActiveWorkbenchWindow = " + GetElementName(this.ActiveWorkbenchWindow));
                ((AvalonDockLayout)workbenchLayout).WriteState(output);
                LoggingService.Debug(output.ToString());
                e.Handled = true;
            }
            if (!e.Handled && e.Key == Key.F && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
            {
                if (TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display)
                {
                    TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal);
                }
                else
                {
                    TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
                }
                this.StatusBar.SetMessage("TextFormattingMode=" + TextOptions.GetTextFormattingMode(this));
            }
            if (!e.Handled && e.Key == Key.R && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
            {
                switch (TextOptions.GetTextRenderingMode(this))
                {
                case TextRenderingMode.Auto:
                case TextRenderingMode.ClearType:
                    TextOptions.SetTextRenderingMode(this, TextRenderingMode.Grayscale);
                    break;

                case TextRenderingMode.Grayscale:
                    TextOptions.SetTextRenderingMode(this, TextRenderingMode.Aliased);
                    break;

                default:
                    TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
                    break;
                }
                this.StatusBar.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this));
            }
            if (!e.Handled && e.Key == Key.G && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
            {
                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                this.StatusBar.SetMessage("Total memory = " + (GC.GetTotalMemory(true) / 1024 / 1024f).ToString("f1") + " MB");
            }
        }
コード例 #23
0
        public ControlClusters()
        {
            InitializeComponent();

            IsInitializeComplete = false;


            GenDPList();

            _renderer = new CRenderer(this, _drwVis);
            _alarmer  = CKernelTerminal.GetKernelTerminalInstance().Alarmer;

            if (_typeFaceDefault == null)
            {
                _typeFaceDefault = new Typeface(_fontFamilyDefault, FontStyles.Normal, _fontWeightDefault, new FontStretch());
            }
            _penClusterTotal = new Pen(Brushes.LightGray, 1.0);
            //KAA removed 2016-May-31
            // StringHeight = 13;
            _lstImageSegments.Add(Image_0);
            _lstImageSegments.Add(Image_1);
            _lstImageSegments.Add(Image_2);
            _lstImageSegments.Add(Image_3);
            _lstImageSegments.Add(Image_4);
            _lstImageSegments.Add(Image_5);
            _lstImageSegments.Add(Image_6);
            _lstImageSegments.Add(Image_7);
            _lstImageSegments.Add(Image_8);
            _lstImageSegments.Add(Image_9);

            ScrollViewerClusters.ScrollToRightEnd();

            for (int i = 0; i < _lstImageSegments.Count; i++)
            {
                RenderOptions.SetBitmapScalingMode(_lstImageSegments[i], BitmapScalingMode.NearestNeighbor);
                TextOptions.SetTextRenderingMode(_lstImageSegments[i], TextRenderingMode.ClearType);
                TextOptions.SetTextFormattingMode(_lstImageSegments[i], TextFormattingMode.Display);
            }
            RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);



            //  CUtil.TaskStart(TaskTriggerPaint);
            CUtil.ThreadStart(ThreadDrawClusters);


            SizeChanged += ControlClusters_SizeChanged;

            GridCanvasControlClusters.MouseEnter += GridCanvasControlClusters_MouseEnter;

            _guiDispatcher = Dispatcher.CurrentDispatcher;
        }
コード例 #24
0
ファイル: Utils.cs プロジェクト: hydh/Amatsukaze
        public static void SetWindowProperties(Window win)
        {
            var version = System.Environment.OSVersion;

            if (version.Platform == PlatformID.Win32NT &&
                version.Version.Major <= 6 &&
                version.Version.Minor <= 1)
            {
                // windows7のクラシックモードでテキスト表示がにじむのを回避
                TextOptions.SetTextFormattingMode(win, TextFormattingMode.Display);
                TextOptions.SetTextRenderingMode(win, TextRenderingMode.ClearType);
            }
        }
コード例 #25
0
        private void PushTextRenderingMode()
        {
            if (_popupRoot == null || Child == null)
            {
                return;
            }

            var vs = DependencyPropertyHelper.GetValueSource(Child, TextOptions.TextRenderingModeProperty);

            if (vs.BaseValueSource <= BaseValueSource.Inherited)
            {
                TextOptions.SetTextRenderingMode(_popupRoot, TextOptions.GetTextRenderingMode(this));
            }
        }
コード例 #26
0
        internal ZWindow(ZWindowManager manager)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            this.manager = manager;

            this.UseLayoutRounding   = true;
            this.SnapsToDevicePixels = true;
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(this, TextRenderingMode.Auto);
        }
コード例 #27
0
ファイル: TimeStampMargin.cs プロジェクト: zyonet/VS-PPT
        /// <summary>
        /// Use clear type if we are in an en-us environment and the <see cref="TextFormattingRunProperties"/>'
        /// font is under the Consolas family.
        /// </summary>
        /// <param name="textProperties">The properties that contain the font information.</param>
        private void SetClearTypeHint(TextFormattingRunProperties textProperties)
        {
            string familyName;

            if (!textProperties.TypefaceEmpty &&
                textProperties.Typeface.FontFamily.FamilyNames.TryGetValue(EnUsLanguage, out familyName) &&
                string.Compare(familyName, "Consolas", StringComparison.OrdinalIgnoreCase) == 0)
            {
                TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
            }
            else
            {
                TextOptions.SetTextRenderingMode(this, TextRenderingMode.Auto);
            }
        }
コード例 #28
0
ファイル: ExtendedWindow.cs プロジェクト: StevenThuriot/Nova
        /// <summary>
        ///     Initializes a new instance of the <see cref="ExtendedWindow&lt;TView, TViewModel&gt;" /> class.
        /// </summary>
        protected ExtendedWindow()
        {
            SnapsToDevicePixels = true;

            TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
            RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);
            VisualTextRenderingMode = TextRenderingMode.ClearType;

            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            _actionQueueManager = new ActionQueueManager();

            ViewModel = ViewModel <TView, TViewModel> .Create((TView)this, _actionQueueManager);

            Closing += (sender, args) => ViewModel.InvokeAction <LeaveAction <TView, TViewModel> >();
        }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppWindow"/> class.
 /// </summary>
 public AppWindow()
 {
     MinimizeCommand    = RelayCommand.Create((p) => WindowState = WindowState.Minimized);
     ChangeStateCommand = RelayCommand.Create(RunChangeStateCommand);
     CloseCommand       = RelayCommand.Create((p) => Close());
     /* see comments in this method */
     SetMaxHeight();
     /* see comments in this method */
     SystemParameters.StaticPropertyChanged += SystemParametersStaticPropertyChanged;
     Loaded           += (s, e) => OnLoaded(s, e);
     UseLayoutRounding = true;
     //RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
     // Default for the following is: Auto, Ideal, Auto
     TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
     TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
     TextOptions.SetTextHintingMode(this, TextHintingMode.Fixed);
 }
コード例 #30
0
        private static FrameworkElement CreateElement(string text, IWpfTextView textView, TextFormattingRunProperties format)
        {
            // Constructs the hint block which gets assigned parameter name and fontstyles according to the options
            // page. Calculates a font size 1/4 smaller than the font size of the rest of the editor
            var block = new TextBlock
            {
                FontFamily = format.Typeface.FontFamily,
                FontSize   = format.FontRenderingEmSize - (0.25 * format.FontRenderingEmSize),
                FontStyle  = FontStyles.Normal,
                Foreground = format.ForegroundBrush,

                // Adds a little bit of padding to the left of the text relative to the border
                // to make the text seem more balanced in the border
                Padding           = new Thickness(left: 1, top: 0, right: 0, bottom: 0),
                Text              = text + ":",
                VerticalAlignment = VerticalAlignment.Center,
            };

            // Encapsulates the textblock within a border. Sets the height of the border to be 3/4 of the original
            // height. Gets foreground/background colors from the options menu. The margin is the distance from the
            // adornment to the text and pushing the adornment upwards to create a separation when on a specific line
            var border = new Border
            {
                Background          = format.BackgroundBrush,
                Child               = block,
                CornerRadius        = new CornerRadius(2),
                Height              = textView.LineHeight - (0.25 * textView.LineHeight),
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin              = new Thickness(left: 0, top: -0.20 * textView.LineHeight, right: 5, bottom: 0),
                Padding             = new Thickness(1),

                // Need to set SnapsToDevicePixels and UseLayoutRounding to avoid unnecessary reformatting
                SnapsToDevicePixels = textView.VisualElement.SnapsToDevicePixels,
                UseLayoutRounding   = textView.VisualElement.UseLayoutRounding,
                VerticalAlignment   = VerticalAlignment.Center
            };

            // Need to set these properties to avoid unnecessary reformatting because some dependancy properties
            // affect layout
            TextOptions.SetTextFormattingMode(border, TextOptions.GetTextFormattingMode(textView.VisualElement));
            TextOptions.SetTextHintingMode(border, TextOptions.GetTextHintingMode(textView.VisualElement));
            TextOptions.SetTextRenderingMode(border, TextOptions.GetTextRenderingMode(textView.VisualElement));

            border.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            return(border);
        }