Example #1
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;
        }
Example #2
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);
                }
                SD.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;
                }
                SD.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);
                SD.StatusBar.SetMessage("Total memory = " + (GC.GetTotalMemory(true) / 1024 / 1024f).ToString("f1") + " MB");
            }
        }
Example #3
0
 public Artboard(IViewObjectFactory viewObjectFactory, ViewExceptionCallback viewExceptionCallback)
 {
     this.ViewObjectFactory              = viewObjectFactory;
     this.contentBorder                  = new ArtboardBorder(viewExceptionCallback);
     this.contentBorder.BorderBrush      = (Brush)Brushes.Black;
     this.contentBorder.MinWidth         = 20.0;
     this.contentBorder.MinHeight        = 20.0;
     this.contentBorder.IsHitTestVisible = false;
     TextOptions.SetTextFormattingMode((DependencyObject)this.contentBorder, TextFormattingMode.Ideal);
     this.snapToGridRenderer = new SnapToGridRenderer(this);
     this.snapToGridRenderer.IsHitTestVisible = false;
     this.overlayLayer = new OverlayLayer();
     this.overlayLayer.IsHitTestVisible = false;
     this.adornerLayer = new AdornerLayer();
     this.adornerLayer.IsHitTestVisible  = false;
     this.adornerLayer.IsVisibleChanged += (DependencyPropertyChangedEventHandler)((s, e) => this.UpdateExtensibleAdornersVisibility());
     this.feedbackLayer = new FeedbackLayer();
     this.feedbackLayer.IsHitTestVisible = false;
     this.annotationLayer = new AnnotationLayer();
     this.annotationLayer.IsHitTestVisible = true;
     this.extraLayersCanvas = new Canvas();
     this.extraLayersCanvas.IsHitTestVisible = false;
     this.liveControlLayer = new Canvas();
     this.liveControlLayer.Resources.Add((object)typeof(TextBox), (object)new Style(typeof(TextBox), new TextBox().Style));
     this.liveControlLayer.Resources.Add((object)typeof(RichTextBox), (object)new Style(typeof(RichTextBox), new RichTextBox().Style));
     this.resourcesHost = new Canvas();
     this.resourcesHost.IsHitTestVisible = false;
     this.resourcesHost.Children.Add((UIElement)this.contentBorder);
     this.resourcesHost.Children.Add((UIElement)this.overlayLayer);
     this.designerView       = (DesignerView) new Artboard.BlendDesignerView();
     this.designerView.Child = (UIElement)this.resourcesHost;
     this.canvas             = new Canvas();
     this.canvas.Children.Add((UIElement)this.designerView);
     this.canvas.Children.Add((UIElement)this.liveControlLayer);
     this.canvas.Children.Add((UIElement)this.extraLayersCanvas);
     this.canvas.Children.Add((UIElement)this.snapToGridRenderer);
     this.canvas.Children.Add((UIElement)this.adornerLayer);
     this.canvas.Children.Add((UIElement)this.feedbackLayer);
     this.canvas.Children.Add((UIElement)this.annotationLayer);
     this.childrenVisuals = new VisualCollection((Visual)this);
     this.childrenVisuals.Add((Visual)this.canvas);
     this.adornerService = new AdornerService(this);
     this.SetValue(TabControl.TabStripPlacementProperty, (object)Dock.Top);
     this.InheritanceBehavior     = InheritanceBehavior.SkipToThemeNow;
     this.AllowDrop               = true;
     this.contentBorder.AllowDrop = false;
     AccessKeyManager.AddAccessKeyPressedHandler((DependencyObject)this.contentBorder, new AccessKeyPressedEventHandler(this.Content_AccessKeyPressed));
     AccessKeyManager.AddAccessKeyPressedHandler((DependencyObject)this.overlayLayer, new AccessKeyPressedEventHandler(this.Content_AccessKeyPressed));
     this.contentBorder.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Content_PreviewGotKeyboardFocus);
     this.overlayLayer.PreviewGotKeyboardFocus  += new KeyboardFocusChangedEventHandler(this.Content_PreviewGotKeyboardFocus);
     this.SetTextDefaults();
 }
        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;
        }
Example #5
0
            public static AppSettingsWindow Create()
            {
                var window = new AppSettingsWindow()
                {
                    DataContext = new AppSettingsViewModel()
                };

                Config.Instance.RestoreWindow(Config.WindowKey.AppSettings, window);

                (window.DataContext as WindowViewModel)?.SetWindowOwner(window);
                TextOptions.SetTextFormattingMode(window);
                return(window);
            }
Example #6
0
            /// <summary>
            /// Creates an instance of CameraManageWindow and its corresponding view model.
            /// </summary>
            /// <param name="camera">The camera to manage.</param>
            /// <returns>The window.</returns>
            public static CameraManageWindow Create(CameraRow camera)
            {
                var window = new CameraManageWindow()
                {
                    DataContext = new CameraManageViewModel(camera),
                };

                Config.Instance.RestoreWindow(Config.WindowKey.CameraManage, window);

                (window.DataContext as WindowViewModel)?.SetWindowOwner(window);
                TextOptions.SetTextFormattingMode(window);
                return(window);
            }
Example #7
0
            /// <summary>
            /// Creates an instance of MainWindow and its corresponding view model.
            /// </summary>
            /// <param name="viewModel">The view model to inject, or null to use the default.</param>
            /// <returns>The window</returns>
            public static MainWindow Create(ApplicationViewModel viewModel = null)
            {
                var window = new MainWindow()
                {
                    DataContext = viewModel ?? new MainWindowViewModel()
                };

                Config.Instance.RestoreWindow(Config.WindowKey.Main, window);

                (window.DataContext as WindowViewModel)?.SetWindowOwner(window);
                TextOptions.SetTextFormattingMode(window);
                return(window);
            }
Example #8
0
        public BaseWindow()
        {
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            //图片与字体清晰显示
            SnapsToDevicePixels = true;
            UseLayoutRounding   = true;

            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
            //RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.NearestNeighbor);
            Icon         = Properties.Resources.eems.ToImageSource();
            this.Loaded += BaseWindow_Loaded;
        }
Example #9
0
        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);
            }
        }
Example #10
0
        protected override Window CreateWindow()
        {
            var window = new MetroWindow
            {
                Style             = new Style(),
                FontFamily        = new FontFamily("Segoe UI"),
                UseLayoutRounding = true
            };

            TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display);
            WindowChrome.SetInstance(window, new WindowChrome());
            return(window);
        }
Example #11
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);
        }
Example #12
0
        private void createLevel()
        {
            level = new Label();
            level.IsHitTestVisible           = false;
            level.FontFamily                 = new FontFamily("Calibri");
            level.FontSize                   = 10.0;
            level.Width                      = level.Height = 2 * Radius.ToPixels();
            level.VerticalContentAlignment   = VerticalAlignment.Center;
            level.HorizontalContentAlignment = HorizontalAlignment.Center;

            TextOptions.SetTextFormattingMode(level, TextFormattingMode.Display);
            Panel.SetZIndex(level, GameProperties.TowersLevelZIndex);
            Canvas.SetLeft(level, Position.X - Radius.ToPixels());
            Canvas.SetTop(level, Position.Y - Radius.ToPixels());
        }
Example #13
0
 public ApplicationWindow(IConfigurationObject configuration, IFeedbackService feedbackService)
 {
     PerformanceUtility.StartPerformanceSequence(PerformanceEvent.ApplicationWindowConstructor);
     base.Name            = "WindowService";
     base.MinWidth        = 400;
     base.MinHeight       = 100;
     base.Width           = 1024;
     base.Height          = 768;
     this.Configuration   = configuration;
     this.FeedbackService = feedbackService;
     TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
     base.UseLayoutRounding = DpiHelper.DeviceToLogicalUnitsScalingFactorX == 1;
     base.SetResourceReference(ApplicationWindow.ThemeObserverBrushProperty, SystemColors.WindowFrameBrushKey);
     PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ApplicationWindowConstructor);
 }
Example #14
0
        public PopupWindow()
        {
            AllowsTransparency = true;
            WindowStyle        = WindowStyle.None;
            Background         = Brushes.Transparent;
            FontSize           = 12.0d * (96d / 72d);

            Topmost       = true;
            ShowActivated = false;
            ShowInTaskbar = false;

            Loaded += InvisibleWindow_Loaded;
            SnapsToDevicePixels = true;
            TextOptions.SetTextFormattingMode((DependencyObject)this, TextFormattingMode.Display);
        }
Example #15
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public ExtendedWindow()
        {
            // Note: Xaml classes can't derive from Xaml classes, so we have to do this in code.
            // http://support.microsoft.com/kb/957231
            //
            // Make the text look MUCH better on screen.
            // http://blogs.msdn.com/b/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx
            //
            // Note 2: I don't really understand why this call is necessary.  I expected the OverrideMetadata
            // call to be sufficient, but it doesn't seem to have the desired effect on the attached property.
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);

            // Try to make controls align to pixel boundaries too.
            this.UseLayoutRounding = true;
        }
Example #16
0
        public MainWindow()
        {
            Loaded += MyWindow_Loaded;
            InitializeComponent();
            //Percentage.Content = String.Empty;
            this.AllowDrop   = true;
            openFileDelegate = new DelegateOpenFile(this.OpenFile);
            var typeConverter        = new HighlightingDefinitionTypeConverter();
            var xmlSyntaxHighlighter = (IHighlightingDefinition)typeConverter.ConvertFrom("XML");

            xmlin.SyntaxHighlighting = xmlSyntaxHighlighter;
            xmlin.ShowLineNumbers    = true;
            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();

            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick    += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();
            xmlin.FontFamily = new System.Windows.Media.FontFamily("Consolas");
            xmlin.FontSize   = 13.333333333333333; // 10pt
            TextOptions.SetTextFormattingMode(xmlin, TextFormattingMode.Ideal);
            SolidColorBrush color = new SolidColorBrush(Color.FromRgb(243, 243, 243));

            xmlin.Background = color;

            //Expander
            starHeight    = new GridLength[expanderGrid.RowDefinitions.Count];
            starHeight[0] = expanderGrid.RowDefinitions[0].Height;
            starHeight[2] = expanderGrid.RowDefinitions[2].Height;
            ExpandedOrCollapsed(topExpander);
            ExpandedOrCollapsed(bottomExpander);

            // InitializeComponent calls topExpander.Expanded
            topExpander.Expanded     += ExpandedOrCollapsed;
            topExpander.Collapsed    += ExpandedOrCollapsed;
            bottomExpander.Expanded  += ExpandedOrCollapsed;
            bottomExpander.Collapsed += ExpandedOrCollapsed;

            // Create the events for the Background Worker.
            if (worker.IsBusy != true)
            {
                worker.WorkerReportsProgress      = true;
                worker.WorkerSupportsCancellation = true;
                worker.DoWork             += new DoWorkEventHandler(worker_DoWork);
                worker.ProgressChanged    += new ProgressChangedEventHandler(worker_ProgressChanged);
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            }
        }
Example #17
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);
 }
Example #18
0
        private static UIElement WrapContent(object content)
        {
            var border = new Border {
                Child = new ContentPresenter {
                    Content = content
                },
                Background      = Brushes.White,
                BorderBrush     = Brushes.DarkGray,
                BorderThickness = new Thickness(1),
                Focusable       = true
            };

            RenderOptions.SetClearTypeHint(border, ClearTypeHint.Enabled);
            TextOptions.SetTextFormattingMode(border, TextFormattingMode.Display);
            FocusManager.SetIsFocusScope(border, true);
            return(border);
        }
Example #19
0
        /// <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> >();
        }
            public FlowDocumentTooltip(FlowDocument document)
            {
                TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
                viewer          = new FlowDocumentScrollViewer();
                viewer.Document = document;
                Border border = new Border {
                    Background      = SystemColors.InfoBrush,
                    BorderBrush     = SystemColors.InfoTextBrush,
                    BorderThickness = new Thickness(1),
                    MaxHeight       = 400,
                    Child           = viewer
                };

                this.Child        = border;
                viewer.Foreground = SystemColors.InfoTextBrush;
                document.FontSize = CodeEditorOptions.Instance.FontSize;
            }
        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);
        }
        public ContextActionsBulbPopup(UIElement parent) : base(parent)
        {
            UseLayoutRounding = true;
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);

            StaysOpen          = true;
            AllowsTransparency = true;

            _headerImage = new Image();

            _mainItem = new MenuItem
            {
                ItemContainerStyle = CreateItemContainerStyle(),
                Header             = _headerImage,
                Padding            = new Thickness(0),
            };

            _mainItem.SubmenuOpened += (sender, args) =>
            {
                if (ReferenceEquals(args.OriginalSource, _mainItem))
                {
                    _isOpen = true;
                    MenuOpened?.Invoke(this, EventArgs.Empty);
                }
            };

            Closed += (sender, args) =>
            {
                if (_isOpen)
                {
                    _isOpen = false;
                    MenuClosed?.Invoke(this, EventArgs.Empty);
                }
            };

            var menu = new Menu
            {
                Background      = Brushes.Transparent,
                BorderBrush     = _mainItem.BorderBrush,
                BorderThickness = _mainItem.BorderThickness,
                Items           = { _mainItem }
            };

            Child = menu;
        }
Example #23
0
        private Grid GetRoot()
        {
            var root = new Grid()
            {
                //Background = Brushes.LightCoral,
                Margin = this.PageMargins,
                Height = this.PageSize.Height - this.PageMargins.Top - this.PageMargins.Bottom, // TODO: cache available space
                Width  = this.PageSize.Width - this.PageMargins.Left - this.PageMargins.Right,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };

            TextOptions.SetTextFormattingMode(root, TextFormattingMode.Ideal);
            TextOptions.SetTextHintingMode(root, TextHintingMode.Fixed);
            TextOptions.SetTextRenderingMode(root, TextRenderingMode.Auto);

            return(root);
        }
Example #24
0
 void SetTextFormattingMode(DependencyObject textObj, double scale)
 {
     if (scale == 1)
     {
         if (wpfSupportsPerMonitorDpi || WindowDpi == new Size(96, 96))
         {
             TextOptions.SetTextFormattingMode(textObj, TextFormattingMode.Display);
         }
         else
         {
             TextOptions.SetTextFormattingMode(textObj, TextFormattingMode.Ideal);
         }
     }
     else
     {
         // We must set it to Ideal or the text will be blurry
         TextOptions.SetTextFormattingMode(textObj, TextFormattingMode.Ideal);
     }
 }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="containers"></param>
        public static void Show(IList <Container> containers)
        {
            var renderer = new WpfRenderer();

            renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable;

            var sw = new ScrollViewer()
            {
                HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalScrollBarVisibility   = ScrollBarVisibility.Auto
            };

            var sp = new StackPanel()
            {
                Margin              = new Thickness(5),
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            sw.Content = sp;

            foreach (var container in containers)
            {
                var vb = ToViewbox(container, renderer);
                vb.Margin = new Thickness(5);
                sp.Children.Add(vb);
            }

            var window = new Window()
            {
                Title  = "Core2D Viewer",
                Width  = 900,
                Height = 680,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                SnapsToDevicePixels   = true,
                UseLayoutRounding     = true
            };

            TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display);

            window.Content = sw;
            window.ShowDialog();
        }
Example #26
0
 void SetTextFormattingMode(DependencyObject textObj, double scale)
 {
     if (scale == 1)
     {
         if (WindowDPI == 96)
         {
             TextOptions.SetTextFormattingMode(textObj, TextFormattingMode.Display);
         }
         else
         {
             TextOptions.SetTextFormattingMode(textObj, TextFormattingMode.Ideal);
         }
     }
     else
     {
         // We must set it to Ideal or the text will be blurry
         TextOptions.SetTextFormattingMode(textObj, TextFormattingMode.Ideal);
     }
 }
Example #27
0
        private ProductionGraphViewer CreateViewer(
            ProductionGraphViewModel graph, double scale, Thickness margin)
        {
            var viewer = new ProductionGraphViewer();

            RenderOptions.SetBitmapScalingMode(viewer, BitmapScalingMode.Fant);
            TextOptions.SetTextFormattingMode(viewer, TextFormattingMode.Display);
            viewer.SnapsToDevicePixels = true;
            viewer.UseLayoutRounding   = true;

            viewer.DataContext = graph;
            if (!TransparencyCheckBox.IsChecked == true)
            {
                viewer.Background = Brushes.White;
            }

            viewer.UpdateLayout();
            viewer.Dispatcher.Flush(DispatcherPriority.Render);

            Rect bounds = Rect.Empty;

            foreach (var node in graph.Elements.OfType <NodeElement>())
            {
                bounds.Union(new Rect(node.Position - (Vector)node.RenderSize / 2, node.RenderSize));
            }

            bounds.X      *= scale;
            bounds.Y      *= scale;
            bounds.X      -= margin.Left;
            bounds.Y      -= margin.Top;
            bounds.Width  *= scale;
            bounds.Height *= scale;
            bounds.Width  += margin.Left + margin.Right;
            bounds.Height += margin.Top + margin.Bottom;

            graph.Offset  = new Vector(bounds.X, bounds.Y);
            viewer.Width  = bounds.Width;
            viewer.Height = bounds.Height;
            viewer.UpdateLayout();

            return(viewer);
        }
        public MainWindow()
        {
            InitializeComponent();

            // Try to sharpen text.
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);

            DataContext = this;

            // Initialize clip list view model.
            clipViewModel = new ViewModels.ClipListViewModel();

            clipboardManager = new Clipboard.ClipboardManager();
            clipboardManager.ClipCaptured += OnClipCaptured;
            clipboardManager.ClipCopied   += OnClipCopied;

            // Insert saved snippets from last time.
            var clips = Utility.Storage.RetrieveClips();

            clips.Sort();
            foreach (var clip in clips)
            {
                clipViewModel.AddClip(clip);
                clipboardManager.Subscribe(clip);
            }

            clipList.DataContext = clipViewModel;

            settingsPanelViewModel    = new ViewModels.SettingsPanelViewModel(settings);
            settingsPanel.DataContext = settingsPanelViewModel;

            keyboardMonitor             = new Settings.KeyboardMonitor();
            keyboardMonitor.KeyPressed += OnHotkeyPressed;

            InitializeKeybindings();

            InitializeTheme();

            InitializeWindow();

            Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name);
        }
Example #29
0
        public ChildWindow(UserControl content = null)
        {
            TextOptions.SetTextRenderingMode(this, TextRenderingMode.Auto);
            TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);

            this.SnapsToDevicePixels = true;
            this.UseLayoutRounding   = true;
            this.ShowInTaskbar       = false;
            this.Width  = double.NaN;
            this.Height = double.NaN;
            this.VerticalContentAlignment   = VerticalAlignment.Stretch;
            this.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            this.ShowInTaskbar         = false;
            this.SizeToContent         = SizeToContent.WidthAndHeight;
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.MinHeight             = 150;
            this.MinWidth   = 150;
            this.Content    = content;
            this.Activated += ChildWindow_Activated;
        }
Example #30
0
        protected void CreateWindow()
        {
            var window = new Window();

            MainWindow                = window;
            window.Closing           += (obj, args) => OnQuit();
            window.WindowStyle        = WindowStyle.SingleBorderWindow;
            window.AllowsTransparency = false;
            window.Background         = new SolidColorBrush(System.Windows.SystemColors.ControlColor);
            window.ShowInTaskbar      = true;
            window.Title              = "UMM";
            window.Content            = RootPanel;
            window.Width              = 1024;
            window.Height             = 768;
            window.MinWidth           = 1024;
            window.MinHeight          = 768;
            TextOptions.SetTextRenderingMode(window, TextRenderingMode.ClearType);
            TextOptions.SetTextHintingMode(window, TextHintingMode.Fixed);
            TextOptions.SetTextFormattingMode(window, TextFormattingMode.Display);
        }