Beispiel #1
0
        private static Inline BuildFont(ElementToken token, Hint hint)
        {
            var span = new Span();

            string size;
            if (token.Attributes.TryGetValue("size", out size))
            {
                var fc = new FontSizeConverter();
                var sz = (double)fc.ConvertFromString(size);
                span.FontSize = sz;
            }

            string face;
            if (token.Attributes.TryGetValue("face", out face))
            {
                span.FontFamily = new FontFamily(face);
            }

            string color;
            if (token.Attributes.TryGetValue("color", out color))
            {
                var bc = new BrushConverter();
                var br = (Brush)bc.ConvertFromString(color);
                span.Foreground = br;
            }
            return span.Fill(token, hint);
        }
Beispiel #2
0
        public CSRepl()
        {
            InitializeComponent();

            textEditor = new CSReplTextEditor();
            textEditor.FontFamily = new FontFamily("Consolas");
            var convertFrom = new FontSizeConverter().ConvertFrom("10pt");
            if (convertFrom != null) textEditor.FontSize = (double)convertFrom;
            textEditor.TextArea.PreviewKeyDown += TextAreaOnPreviewKeyDown;
            textEditor.IsEnabled = false;
            textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
            textEditor.FileName = "repl.csx";
            textEditor.Repl = this;
            this.Content = textEditor;

            commandHistory = new CommandHistory();

            ShowConsoleOutput = true;
            OutputColor = Color.FromArgb(255, 78, 78, 78);
            WarningColor = Color.FromArgb(255, 183, 122, 0);
            ErrorColor = Color.FromArgb(255, 138, 6, 3);
            ReplColor = Color.FromArgb(255, 0, 127, 0);

            //supress duplicate using warnings
            SuppressWarning("CS0105");

            //clears the console and prints the headers
            // when clearing the initial transormers are removed too but we want to keep them
            initialTransformers = textEditor.TextArea.TextView.LineTransformers.ToArray();
            Clear();
        }
Beispiel #3
0
        public Tile(ICase tile, TileFactory tileFactory, List<Unite> listUnite, SolidColorBrush playerBrush)
        {
            InitializeComponent();
            this.tile = tile;
            this.nbUnite = listUnite.Count;
            VisualBrush myBrush = new VisualBrush();
            aPanel = new Grid();

            aPanel.Background = tileFactory.getViewTile(tile);

            // Create some text.
            TextBlock backText = new TextBlock();
            Canvas.SetZIndex(backText, 3);
            if (listUnite != null && listUnite.Count > 0)
            {
                backText.Text = " " + listUnite.Count.ToString() + " ";
                backText.Background = (SolidColorBrush)new BrushConverter().ConvertFromString(listUnite[0].Proprietaire.Couleur);
                backText.Foreground = Brushes.White;
            }
            FontSizeConverter fSizeConverter = new FontSizeConverter();
            backText.FontSize = (double)fSizeConverter.ConvertFromString("10pt");
            backText.Margin = new Thickness(10);
            Grid.SetColumn(backText, 0);
            Grid.SetRow(backText, 0);
            DropShadowEffect myDropShadowEffect  = new DropShadowEffect();
            myDropShadowEffect.BlurRadius = 1;
            myDropShadowEffect.Color = Color.FromRgb(0,0,0);
            myDropShadowEffect.ShadowDepth = 2;
            backText.Effect=myDropShadowEffect;
            aPanel.Children.Add(backText);
            myBrush.Visual = aPanel;
            rect.Fill = myBrush;
            rect1.Stroke = playerBrush;
        }
        public CaseReportAmendment()
        {
            m_FontSizeConverter = new FontSizeConverter();
            m_Rule = new YellowstonePathology.Business.Rules.Rule();

            this.m_Rule.ActionList.Add(this.SetAmendments);
        }
Beispiel #5
0
        /// <summary>Converts a specified type to a <see cref="T:System.Double" />.</summary>
        /// <param name="context">Context information of a component such as its container and <see cref="T:System.ComponentModel.PropertyDescriptor" />.</param>
        /// <param name="culture">Cultural specific information, including the writing system and calendar used.</param>
        /// <param name="value">The value which is being converted to a font size value.</param>
        /// <returns>A <see cref="T:System.Double" /> value that represents the converted font size value.</returns>
        // Token: 0x06000415 RID: 1045 RVA: 0x0000BAB0 File Offset: 0x00009CB0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw base.GetConvertFromException(value);
            }
            string text = value as string;

            if (text != null)
            {
                double num;
                FontSizeConverter.FromString(text, culture, out num);
                return(num);
            }
            if (value is int || value is float || value is double)
            {
                return((double)value);
            }
            return(null);
        }
 // Initialize known object types
 internal static TypeConverter CreateKnownTypeConverter(Int16 converterId)
 { 
     TypeConverter o = null;
     switch (converterId) 
     { 
         case -42: o = new System.Windows.Media.Converters.BoolIListConverter(); break;
         case -46: o = new System.ComponentModel.BooleanConverter(); break; 
         case -53: o = new System.Windows.Media.BrushConverter(); break;
         case -61: o = new System.ComponentModel.ByteConverter(); break;
         case -70: o = new System.ComponentModel.CharConverter(); break;
         case -71: o = new System.Windows.Media.Converters.CharIListConverter(); break; 
         case -87: o = new System.Windows.Media.ColorConverter(); break;
         case -94: o = new System.Windows.Input.CommandConverter(); break; 
         case -96: o = new System.Windows.Markup.ComponentResourceKeyConverter(); break; 
         case -111: o = new System.Windows.CornerRadiusConverter(); break;
         case -114: o = new System.ComponentModel.CultureInfoConverter(); break; 
         case -115: o = new System.Windows.CultureInfoIetfLanguageTagConverter(); break;
         case -117: o = new System.Windows.Input.CursorConverter(); break;
         case -124: o = new System.ComponentModel.DateTimeConverter(); break;
         case -125: o = new System.Windows.Markup.DateTimeConverter2(); break; 
         case -130: o = new System.ComponentModel.DecimalConverter(); break;
         case -137: o = new System.Windows.Markup.DependencyPropertyConverter(); break; 
         case -138: o = new System.Windows.DialogResultConverter(); break; 
         case -174: o = new System.Windows.Media.DoubleCollectionConverter(); break;
         case -175: o = new System.ComponentModel.DoubleConverter(); break; 
         case -176: o = new System.Windows.Media.Converters.DoubleIListConverter(); break;
         case -188: o = new System.Windows.DurationConverter(); break;
         case -190: o = new System.Windows.DynamicResourceExtensionConverter(); break;
         case -201: o = new System.Windows.ExpressionConverter(); break; 
         case -204: o = new System.Windows.FigureLengthConverter(); break;
         case -215: o = new System.Windows.Media.FontFamilyConverter(); break; 
         case -216: o = new System.Windows.FontSizeConverter(); break; 
         case -218: o = new System.Windows.FontStretchConverter(); break;
         case -220: o = new System.Windows.FontStyleConverter(); break; 
         case -222: o = new System.Windows.FontWeightConverter(); break;
         case -240: o = new System.Windows.Media.GeometryConverter(); break;
         case -256: o = new System.Windows.GridLengthConverter(); break;
         case -267: o = new System.ComponentModel.GuidConverter(); break; 
         case -286: o = new System.Windows.Media.ImageSourceConverter(); break;
         case -299: o = new System.Windows.Input.InputScopeConverter(); break; 
         case -301: o = new System.Windows.Input.InputScopeNameConverter(); break; 
         case -306: o = new System.ComponentModel.Int16Converter(); break;
         case -314: o = new System.Windows.Media.Int32CollectionConverter(); break; 
         case -315: o = new System.ComponentModel.Int32Converter(); break;
         case -319: o = new System.Windows.Int32RectConverter(); break;
         case -324: o = new System.ComponentModel.Int64Converter(); break;
         case -338: o = new System.Windows.Input.KeyConverter(); break; 
         case -340: o = new System.Windows.Input.KeyGestureConverter(); break;
         case -342: o = new System.Windows.KeySplineConverter(); break; 
         case -344: o = new System.Windows.KeyTimeConverter(); break; 
         case -348: o = new System.Windows.LengthConverter(); break;
         case -387: o = new System.Windows.Media.Media3D.Matrix3DConverter(); break; 
         case -392: o = new System.Windows.Media.MatrixConverter(); break;
         case -410: o = new System.Windows.Input.ModifierKeysConverter(); break;
         case -411: o = new System.Windows.Input.MouseActionConverter(); break;
         case -415: o = new System.Windows.Input.MouseGestureConverter(); break; 
         case -423: o = new System.Windows.NullableBoolConverter(); break;
         case -445: o = new System.Windows.Media.PathFigureCollectionConverter(); break; 
         case -453: o = new System.Windows.Media.PixelFormatConverter(); break; 
         case -462: o = new System.Windows.Media.Media3D.Point3DCollectionConverter(); break;
         case -463: o = new System.Windows.Media.Media3D.Point3DConverter(); break; 
         case -467: o = new System.Windows.Media.Media3D.Point4DConverter(); break;
         case -473: o = new System.Windows.Media.PointCollectionConverter(); break;
         case -474: o = new System.Windows.PointConverter(); break;
         case -475: o = new System.Windows.Media.Converters.PointIListConverter(); break; 
         case -492: o = new System.Windows.PropertyPathConverter(); break;
         case -498: o = new System.Windows.Media.Media3D.QuaternionConverter(); break; 
         case -507: o = new System.Windows.Media.Media3D.Rect3DConverter(); break; 
         case -511: o = new System.Windows.RectConverter(); break;
         case -521: o = new System.Windows.Media.Animation.RepeatBehaviorConverter(); break; 
         case -538: o = new System.Windows.Markup.RoutedEventConverter(); break;
         case -545: o = new System.ComponentModel.SByteConverter(); break;
         case -563: o = new System.ComponentModel.SingleConverter(); break;
         case -568: o = new System.Windows.Media.Media3D.Size3DConverter(); break; 
         case -572: o = new System.Windows.SizeConverter(); break;
         case -615: o = new System.ComponentModel.StringConverter(); break; 
         case -619: o = new System.Windows.StrokeCollectionConverter(); break; 
         case -633: o = new System.Windows.TemplateBindingExpressionConverter(); break;
         case -635: o = new System.Windows.TemplateBindingExtensionConverter(); break; 
         case -637: o = new System.Windows.Markup.TemplateKeyConverter(); break;
         case -645: o = new System.Windows.TextDecorationCollectionConverter(); break;
         case -655: o = new System.Windows.ThicknessConverter(); break;
         case -664: o = new System.ComponentModel.TimeSpanConverter(); break; 
         case -681: o = new System.Windows.Media.TransformConverter(); break;
         case -692: o = new System.Windows.Markup.TypeTypeConverter(); break; 
         case -696: o = new System.ComponentModel.UInt16Converter(); break; 
         case -698: o = new System.ComponentModel.UInt32Converter(); break;
         case -700: o = new System.ComponentModel.UInt64Converter(); break; 
         case -701: o = new System.Windows.Media.Converters.UShortIListConverter(); break;
         case -705: o = new System.UriTypeConverter(); break;
         case -714: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter(); break;
         case -715: o = new System.Windows.Media.Media3D.Vector3DConverter(); break; 
         case -722: o = new System.Windows.Media.VectorCollectionConverter(); break;
         case -723: o = new System.Windows.VectorConverter(); break; 
         case -757: o = new System.Windows.Markup.XmlLanguageConverter(); break; 
     }
     return o; 
 }
        private void risuem(int i, int j, int kol, String pathImage)
        {
            bool b = false;
            int w=0, h=0;
            do
            {
                b = false;
                w = wKvadrat(j, i);
                h = hKvadrat(i);
                for (int n = j; n < j + w; n++)
                {
                    if (pole[i, n] != 0)
                        b = true;
                }
                for (int n = i; n < i + h; n++)
                {
                    if (pole[n, j] != 0)
                        b = true;
                }
            } while (b);

            for (int n = i; n < i + h; n++)
                for(int p = j; p < j + w; p++)
                {
                    pole[n, p] = kol;
                }

            //Рисуем на канве
            prjamougolnic = new Rectangle();
            prjamougolnic.Width = 30 * w;
            prjamougolnic.Height = 30 * h;
            prjamougolnic.Stroke = Brushes.Black;
            Canvas.SetLeft(prjamougolnic, 100 + (j * 30));
            Canvas.SetTop(prjamougolnic, 0 + (i * 30));

            //Пишем текст

            VisualBrush myBrush = new VisualBrush();
            StackPanel aPanel = new StackPanel();
            TextBlock someText = new TextBlock();
            someText.Text = kol.ToString();
            FontSizeConverter fSizeConverter = new FontSizeConverter();
            someText.FontSize = (double)fSizeConverter.ConvertFromString("16pt");
            someText.Margin = new Thickness(10);
            aPanel.Children.Add(someText);
            myBrush.Visual = aPanel;
            prjamougolnic.Fill = myBrush;
            canvas.Children.Add(prjamougolnic);

            //Записываем в файл
            file.Write((j * widthKvadrat + 2) + "," + (i * heightKvadrat + 2)+ ",");
            //Обрезаем изображение
            System.Drawing.Bitmap bmp = Crop(pathImage, w * widthKvadrat - 4, h * heightKvadrat - 4, j * widthKvadrat + 4, i * heightKvadrat + 4);
            bmp.Save(putSave + @"\Level" + textBoxLevel.Text + @"\image" + kol + ".png", System.Drawing.Imaging.ImageFormat.Png);
            bmp.Dispose();
            System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 4);
            gfxTable.DrawRectangle(pen, new System.Drawing.Rectangle(j * widthKvadrat, i * heightKvadrat, w * widthKvadrat, h * heightKvadrat));
        }
 public static double ToFontSize(this string fontSize)
 {
     var fontSizeConverter = new FontSizeConverter();
     return (double)fontSizeConverter.ConvertFromString(fontSize);
 }
Beispiel #9
0
        public CSRepl()
        {
            InitializeComponent();

            textEditor = new CSReplTextEditor();
            textEditor.FontFamily = new FontFamily("Consolas");
            var convertFrom = new FontSizeConverter().ConvertFrom("10pt");
            if (convertFrom != null) textEditor.FontSize = (double)convertFrom;
            textEditor.TextArea.PreviewKeyDown += TextAreaOnPreviewKeyDown;
            textEditor.IsEnabled = false;
            textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
            textEditor.FileName = "repl.csx";
            textEditor.Repl = this;
            this.Content = textEditor;

            commandHistory = new CommandHistory();

            var errorStream = new ConsoleStream(TextType.Error, Write);
            var errorWriter = new StreamWriter(errorStream);
            errorWriter.AutoFlush = true;
            Console.SetError(errorWriter);

            var stdoutStream = new ConsoleStream(TextType.Output, Write);
            var stdoutWriter = new StreamWriter(stdoutStream);
            stdoutWriter.AutoFlush = true;
            Console.SetOut(stdoutWriter);

            ShowConsoleOutput = true;
            ResetColor();

            //supress duplicate using warnings
            SuppressWarning("CS0105");

            //clears the console and prints the headers
            // when clearing the initial transormers are removed too but we want to keep them
            initialTransformers = textEditor.TextArea.TextView.LineTransformers.ToArray();
            Clear();
        }
 /// <summary>
 /// Loads the editor config.
 /// </summary>
 /// <param name="editor">The editor.</param>
 private void LoadEditorConfig(TextEditor editor)
 {
     editor.Options.AllowScrollBelowDocument = true;
     editor.Options.IndentationSize = this.configuationSettings.TabWidth;
     editor.FontFamily = this.configuationSettings.EditorTypeface.FontFamily;
     editor.FontSize = this.configuationSettings.EditorFontSize;
     editor.FontWeight = this.configuationSettings.EditorTypeface.Weight;
     editor.FontStyle = this.configuationSettings.EditorTypeface.Style;
     editor.ShowLineNumbers = true;
     editor.LineNumbersForeground = this.configuationSettings.LineNumberForeBrush;
     editor.Background = this.configuationSettings.LineNumberBackBrush;
     FontSizeConverter fsc = new FontSizeConverter();
 }
        private void Update()
        {
            IntPtr hTheme = IntPtr.Zero;

            try
            {
                FontFamily fontfamily = null;
                double fontsizediu = 0, fontsizepx = 0;
                FontWeight fontweight = FontWeights.Normal;
                Brush foreground = null;

                // get a handle to theme data for textstyle
                hTheme = OpenThemeData(IntPtr.Zero, "TEXTSTYLE");

                bool fallbackfont = false, fallbackcolour = false;

                // if hTheme is null, 'TEXTSTYLE' could not be found - this probably means theming is turned off
                if (hTheme == IntPtr.Zero)
                {
                    fallbackfont = true;
                    fallbackcolour = true;
                }
                else
                {
                    int S_OK = 0;

                    // from vssym32.h
                    int TMT_TEXTCOLOR = 3803;

                    COLORREF pColor;
                    if (GetThemeColor(hTheme, (int)TEXTSTYLEPARTS.TEXT_MAININSTRUCTION, 0, TMT_TEXTCOLOR, out pColor) == S_OK)
                    {
                        foreground = new SolidColorBrush(Color.FromRgb(pColor.R, pColor.G, pColor.B));
                    }
                    else
                    {
                        // fall back to the window text colour
                        fallbackcolour = true;
                    }

                    // from vssym32.h
                    int TMT_FONT = 210;

                    LOGFONT lFont;
                    if (GetThemeFont(hTheme, IntPtr.Zero, (int)TEXTSTYLEPARTS.TEXT_MAININSTRUCTION, 0, TMT_FONT, out lFont) == S_OK)
                    {
                        fontfamily = new FontFamily(lFont.lfFaceName);
                        fontweight = FontWeight.FromOpenTypeWeight(lFont.lfWeight);

                        //// important: lfHeight contains the height in pixels
                        //// e.g. for main instruction text in Aero at 96dpi is 16px high, and at 120dpi is 20px high
                        //// WPF uses device independent units, however - 16 DIU = 16px @ 96dpi, 20px @ 120dpi, etc.

                        FontSizeConverter converter = new FontSizeConverter();
                        fontsizepx = Math.Abs(lFont.lfHeight);
                    }
                    else
                    {
                        // fall back to caption font
                        fallbackfont = true;
                    }
                }

                if (fallbackfont)
                {
                    // if there is no theming, use SystemFonts.CaptionFont*
                    // also fall back to this if GetThemeFont fails
                    fontfamily = SystemFonts.CaptionFontFamily;
                    fontsizediu = SystemFonts.CaptionFontSize;
                    fontweight = SystemFonts.CaptionFontWeight;
                }

                if (fallbackcolour)
                {
                    // if there is no theming, use SystemColors.WindowTextBrush
                    // also fall back to this if GetThemeColor fails
                    foreground = SystemColors.WindowTextBrush;
                }

                #region DPI Calculations

                // get the handle of the window
                HwndSource windowhandlesource = PresentationSource.FromVisual(this) as HwndSource;

                // work out the current screen's DPI
                Matrix screenmatrix = windowhandlesource.CompositionTarget.TransformToDevice;
                //double dpiX = screenmatrix.M11;
                double dpiY = screenmatrix.M22; // 1.0 = 96dpi, 1.25 = 120dpi, etc.

                if (fontsizepx == 0)
                {
                    // convert from DIUs to pixels
                    fontsizepx = fontsizediu * dpiY;
                }
                else if (fontsizediu == 0)
                {
                    // convert from pixels to DIUs
                    fontsizediu = fontsizepx / dpiY;
                }

                #endregion

                // set text block style
                MainInstructionTextBlock.FontFamily = fontfamily;
                MainInstructionTextBlock.FontSize = fontsizediu;
                MainInstructionTextBlock.FontWeight = fontweight;
                MainInstructionTextBlock.Foreground = foreground;

                // display info
                MainInstructionFontFamilyTextBlock.Text = fontfamily.ToString();
                MainInstructionFontSizeTextBlock.Text = fontsizediu.ToString() + " DIU (" + fontsizepx + " px)";
                MainInstructionFontWeightTextBlock.Text = fontweight.ToString();
                MainInstructionForegroundTextBlock.Text = foreground.ToString();

                MainInstructionFontFallbackTextBlock.Text = fallbackfont.ToString();
                MainInstructionColourFallbackTextBlock.Text = fallbackcolour.ToString();
            }
            finally
            {
                // clean up
                if (hTheme != IntPtr.Zero)
                    CloseThemeData(hTheme);
            }
        }