public ExamineKeystrokes()
        {
            Title = "Examine Keystrokes";
            FontFamily = new FontFamily("Courier New");

            Grid grid = new Grid();
            Content = grid;

            // Make one row "auto" and the other fill the remaining space.
            RowDefinition rowdef = new RowDefinition();
            rowdef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowdef);
            grid.RowDefinitions.Add(new RowDefinition());

            // Display header text.
            TextBlock textHeader = new TextBlock();
            textHeader.FontWeight = FontWeights.Bold;
            textHeader.Text = strHeader;
            grid.Children.Add(textHeader);

            // Create StackPanel as child of ScrollViewer for displaying events.
            scroll = new ScrollViewer();
            grid.Children.Add(scroll);
            Grid.SetRow(scroll, 1);

            stack = new StackPanel();
            scroll.Content = stack;
        }
 public CreateScheduleClass(string AppDirectory)
 {
     //create the formatting items
     FontFamily AdobeJenson = new FontFamily(AppDirectory + AdobeJensonPath);
     FontFamily Georgia = new FontFamily("Georgia");
     fontFamily = Georgia;
 }
Пример #3
0
        public FontInfo(FontFamily fontFamily, double fontSize)
        {
            FontFamily = fontFamily;
            Size = fontSize;
            LineHeight = fontSize * FontFamily.LineSpacing;

            var fixedWidthCharacter = new FormattedText("X",
                CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface(FontFamily.Source),
                fontSize,
                Brushes.Black);

            CharacterWidth = fixedWidthCharacter.Width;

            var tabCharacter = new FormattedText("\t",
                CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface(FontFamily.Source),
                fontSize,
                Brushes.Black);

            TabWidth = tabCharacter.WidthIncludingTrailingWhitespace;

            LeftOffset = 0;
        }
		public override string ProvideText(string text, double width, FontFamily font, double fontSize, Thickness padding)
		{
			var renderstr = text;
			width -= 10;
			if (TrimIndex >= renderstr.Length)
				return renderstr;
			if (width <= 40)
				return renderstr;
			var fixedprefix = text.Substring(0, TrimIndex);
			var suffix = text.Substring(TrimIndex);
			var ellipse = "...";
			
			
			var renderSize = RenderingExtensions.EstimateLabelRenderSize(font, fontSize, padding, renderstr);
			if (renderSize.Width > width)
			{
				do
				{
					suffix = suffix.Substring(1);
					renderstr = fixedprefix + ellipse + suffix;
					renderSize = RenderingExtensions.EstimateLabelRenderSize(font, fontSize, padding, renderstr);
				} while (renderSize.Width > width && renderstr.Length > 2);
			}

			return renderstr;
		}
Пример #5
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            if (!EnsureTreeInitialized() || session == null || qiContent == null)
                return;

            // Map the trigger point down to our buffer.
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            ParseItem item = _tree.StyleSheet.ItemBeforePosition(point.Value.Position);
            if (item == null || !item.IsValid)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || !dec.IsValid || !_allowed.Contains(dec.PropertyName.Text.ToUpperInvariant()))
                return;

            string fontName = item.Text.Trim('\'', '"');

            if (fonts.Families.SingleOrDefault(f => f.Name.Equals(fontName, StringComparison.OrdinalIgnoreCase)) != null)
            {
                FontFamily font = new FontFamily(fontName);

                applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
                qiContent.Add(CreateFontPreview(font, 10));
                qiContent.Add(CreateFontPreview(font, 11));
                qiContent.Add(CreateFontPreview(font, 12));
                qiContent.Add(CreateFontPreview(font, 14));
                qiContent.Add(CreateFontPreview(font, 25));
                qiContent.Add(CreateFontPreview(font, 40));
            }
        }
        public FontData GetFontData(string fontFamilyName, bool isItalic, bool isBold)
        {
            FontData data = new FontData()
            {
                IsValid = false,
                Bytes = null,
                FontFamilyName = fontFamilyName,
                IsItalic = isItalic,
                IsBold = isBold
            };

            FontFamily fontFamily = new FontFamily(fontFamilyName);
            FontStyle fontStyle = isItalic ? FontStyles.Italic : FontStyles.Normal;
            FontWeight fontWeight = isBold ? FontWeights.Bold : FontWeights.Normal;
            Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
            GlyphTypeface glyphTypeface;
            if (typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                using (var memoryStream = new MemoryStream())
                {
                    glyphTypeface.GetFontStream().CopyTo(memoryStream);
                    data.Bytes = memoryStream.ToArray();
                    data.IsValid = true;
                }
            }

            return data;
        }
Пример #7
0
    public Bitmap GenerateBarcodeImage(string text, FontFamily fontFamily, int fontSizeInPoints)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("*");
        sb.Append(text);
        sb.Append("*");

        Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);

        Font font = new Font(fontFamily, fontSizeInPoints, FontStyle.Regular, GraphicsUnit.Point);

        Graphics graphics = Graphics.FromImage(bmp);

        SizeF textSize = graphics.MeasureString(sb.ToString(), font);

        bmp = new Bitmap(bmp, textSize.ToSize());

        graphics = Graphics.FromImage(bmp);
        graphics.Clear(Color.White);
        graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
        graphics.DrawString(sb.ToString(), font, new SolidBrush(Color.Black), 0, 0);
        graphics.Flush();

        font.Dispose();
        graphics.Dispose();

        return bmp;
    }
Пример #8
0
        public void AddVisualText(String text, String name_of_element, FontFamily fontFamily, Double fontSize, Point location, Double rotateAngle, Brush brush)
        {
            Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
            DrawingContext dc;

            DrawingVisual dv = new DrawingVisual();
            FormattedText ft1 = new FormattedText(text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, fontSize, brush);

            if (location.X == -1)
            {
                location = new Point(this.Width / 2 - ft1.Width / 2, location.Y);
            }
            if (location.Y == -1)
            {
                location = new Point(location.X, this.Height / 2 - ft1.Height / 2);
            }

            RotateTransform rt = new RotateTransform(rotateAngle, location.X + ft1.Width / 2, location.Y + ft1.Height / 2);

            dc = dv.RenderOpen();
            dc.PushTransform(rt);
            dc.DrawText(ft1, location);
            dc.Close();

            this.visuals.Add(new NamedVisual(name_of_element, dv));
            this.AddVisualChild(dv);

        }
 private void GenerateImage(
     HttpResponse response,
     string textToInsert,
     int width,
     int height,
     Color backgroundColor,
     FontFamily fontFamily,
     float emSize,
     Brush brush,
     float x,
     float y,
     string contentType,
     ImageFormat imageFormat)
 {
     using (Bitmap bitmap = new Bitmap(width, height))
     {
         using (Graphics graphics = Graphics.FromImage(bitmap))
         {
             graphics.Clear(backgroundColor);
             graphics.DrawString(textToInsert, new Font(fontFamily, emSize), brush, x, y);
             response.ContentType = contentType;
             bitmap.Save(response.OutputStream, imageFormat);
         }
     }
 }
Пример #10
0
        public ExamineKeystrokes()
        {
            Title = "Examine Keystrokes";
            FontFamily = new FontFamily("Courier New");

            Grid grid = new Grid();
            Content = grid;

            RowDefinition rowdef = new RowDefinition();
            rowdef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowdef);
            grid.RowDefinitions.Add(new RowDefinition());

            TextBlock textHeader = new TextBlock();
            textHeader.FontWeight = FontWeights.Bold;
            textHeader.Text = strHeader;
            grid.Children.Add(textHeader);

            scroll = new ScrollViewer();
            grid.Children.Add(scroll);
            Grid.SetRow(scroll, 1);

            stack = new StackPanel();
            scroll.Content = stack;
        }
 public PFont(string name, double size, bool smooth, char [] charset)
 {
     Family = new FontFamily (name);
     Size = size;
     Smooth = smooth;
     Charset = charset;
 }
Пример #12
0
 public MainWindowViewModel()
 {
     BackgroundColor = new SolidColorBrush(Settings.Background);
     ForegroundColor = new SolidColorBrush(Settings.Foreground);
     FontFamily = new FontFamily(Settings.FontFamily);
     FontSize = Settings.FontSize;
 }
Пример #13
0
        public ZTextBufferWindow(ZWindowManager manager, FontAndColorService fontAndColorService)
            : base(manager, fontAndColorService)
        {
            this.normalFontFamily = new FontFamily("Cambria");
            this.fixedFontFamily = new FontFamily("Consolas");

            var zero = new FormattedText(
                textToFormat: "0",
                culture: CultureInfo.InstalledUICulture,
                flowDirection: FlowDirection.LeftToRight,
                typeface: new Typeface(normalFontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
                emSize: this.FontSize,
                foreground: Brushes.Black);

            this.fontCharSize = new Size(zero.Width, zero.Height);

            this.document = new FlowDocument
            {
                FontFamily = normalFontFamily,
                FontSize = this.FontSize,
                PagePadding = new Thickness(8.0)
            };

            this.paragraph = new Paragraph();
            this.document.Blocks.Add(this.paragraph);

            this.scrollViewer = new FlowDocumentScrollViewer
            {
                FocusVisualStyle = null,
                Document = this.document
            };

            this.Children.Add(this.scrollViewer);
        }
Пример #14
0
        internal Size MeasureText(string text, FontFamily fontFamily, FontStyle fontStyle,
            FontWeight fontWeight,
            FontStretch fontStretch, double fontSize)
        {
            var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
            GlyphTypeface glyphTypeface;

            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                return MeasureTextSize(text, fontFamily, fontStyle, fontWeight, fontStretch, fontSize);
            }

            double totalWidth = 0;
            double height = 0;

            foreach (var t in text)
            {
                var glyphIndex = glyphTypeface.CharacterToGlyphMap[t];
                var width = glyphTypeface.AdvanceWidths[glyphIndex] * fontSize;
                var glyphHeight = glyphTypeface.AdvanceHeights[glyphIndex] * fontSize;

                if (glyphHeight > height)
                {
                    height = glyphHeight;
                }
                totalWidth += width;
            }
            return new Size(totalWidth, height);
        }
        public void SetupElementCaches(FrameworkElement uie)
        {
            if (_setup) return;

            FfDefault = (FontFamily) uie.FindResource("DefaultFont"); //get & cache
            FfEmoticon = (FontFamily) uie.FindResource("Emoticon"); //get & cache
            FfUisymbol = (FontFamily) uie.FindResource("DefaultSymbol"); //get & cache
            FfWebsymbol = (FontFamily) uie.FindResource("WebSymbols"); //get & cache

            FsDefault = (double) uie.FindResource("DefaultFontSize"); //get & cache

            BrForeground = (Brush) uie.FindResource("BaseColour"); //get & cache
            BrHover = (Brush) uie.FindResource("HoverColour"); //get & cache
            BrBase = (Brush) uie.FindResource("BaseColour"); //get & cache
            BrText = (Brush) uie.FindResource("TextColour"); //get & cache
            BrTransparent = (Brush) uie.FindResource("TransparentColour"); //get & cache

            WordProcessors = CompositionManager.GetAll<IWordTransfomProvider>().OrderBy(tp => tp.Priority);
                //get & cache
            SentenceProcessors = CompositionManager.GetAll<IParagraphTransfomProvider>().OrderBy(tp => tp.Priority);
                //get & cache
            MediaProcessors = CompositionManager.GetAll<IMediaProvider>(); //get & cache
            UrlExpanders = CompositionManager.Get<IUrlExpandService>(); //get & cache
            ApplicationSettings = CompositionManager.Get<IApplicationSettingsProvider>(); //get & cache
            AdditonalTextSmarts = CompositionManager.GetAll<IAdditonalTextSmarts>(); //get & cache
            GlobalExcludeSettings = CompositionManager.Get<IGlobalExcludeSettings>(); //get & cache

            _setup = true;
        }
Пример #16
0
        internal static void SetFontType(UIElement control, FontFamily fontFamily, double? fontSize)
        {
            Queue<UIElement> queue = new Queue<UIElement>();
            queue.Enqueue(control);
            do
            {
                UIElement uiElement = queue.Dequeue();

                if (uiElement is Control)
                {
                    Control ctrl = (Control)uiElement;
                    ctrl.FontFamily = fontFamily ?? ctrl.FontFamily;
                    ctrl.FontSize = fontSize ?? ctrl.FontSize;                    
                }
                else if (uiElement is TextBlock)
                {
                    TextBlock tb = (TextBlock)uiElement;
                    tb.FontFamily = fontFamily ?? tb.FontFamily;
                    tb.FontSize = fontSize ?? tb.FontSize;
                }

                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(uiElement); i++)
                {
                    queue.Enqueue(VisualTreeHelper.GetChild(uiElement, i) as UIElement);
                }
            }
            while (queue.Count > 0);
        }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string fName = ConfigurationManager.AppSettings["Code39Barcode.FontFamily"];

        PrivateFontCollection fCollection = new PrivateFontCollection();
        fCollection.AddFontFile(ConfigurationManager.AppSettings["Code39Barcode.FontFile"]);
        FontFamily fFamily = new FontFamily(fName, fCollection);
        Font f = new Font(fFamily, FontSize);

        Bitmap bmp = new Bitmap(Width, Height);
        Graphics g = Graphics.FromImage(bmp);
        g.Clear(Color.White);
        Brush b = new SolidBrush(Color.Black);
        g.DrawString("*" + strPortfolioID + "*", f, b, 0, 0);

        //PNG format has no visible compression artifacts like JPEG or GIF, so use this format, but it needs you to copy the bitmap into a new bitmap inorder to display the image properly.  Weird MS bug.
        Bitmap bm = new Bitmap(bmp);
        System.IO.MemoryStream ms = new System.IO.MemoryStream();

        Response.ContentType = "image/png";
        bm.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        ms.WriteTo(Response.OutputStream);

        b.Dispose();
        bm.Dispose();
        Response.End();
    }
Пример #18
0
        /// <summary>
        /// Main windows에 적용 할 수 있는 간략한 Data 테스트
        /// </summary>
        private void SetCustomData()
        {
            // 제목
            Title = "Display Some Text";

            //// 현재 창에 나타날 data
            //Content = "Content can be simple text!";

            // font 지정
            FontFamily = new FontFamily("Comic Sans MS");

            FontSize = 48;

            // gradient 효과가 적용된 Brush
            Brush brush = new LinearGradientBrush(Colors.Black, Colors.White, new Point(0,0), new Point(1,1));

            Background = brush;
            Foreground = brush;

            // 현재 창의 content 내용에 따라 창의 크기를 조절 할 수 있는 값
            SizeToContent = SizeToContent.WidthAndHeight;

            // 현재 창의 Resizing 방법 지정
            ResizeMode = ResizeMode.CanMinimize;
        }
Пример #19
0
        public static FrameworkElement MakeSingleLineItem(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 : BadgeCaps.Width,
                UseLayoutRounding = true,
                SnapsToDevicePixels = true
            };
            TextOptions.SetTextFormattingMode(element, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(element, TextRenderingMode.Aliased);
            TextOptions.SetTextHintingMode(element, TextHintingMode.Fixed);

            return element;
        }
Пример #20
0
        /// <summary>
        /// Helper function that converts the values stored in the settings into the font values
        /// and then sets the tasklist font values.
        /// </summary>
		public void SetFont()
        {
            var family = new FontFamily(User.Default.TaskListFontFamily);

            double size = User.Default.TaskListFontSize;

            var styleConverter = new FontStyleConverter();

            FontStyle style = (FontStyle)styleConverter.ConvertFromString(User.Default.TaskListFontStyle);

            var stretchConverter = new FontStretchConverter();
            FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(User.Default.TaskListFontStretch);

            var weightConverter = new FontWeightConverter();
            FontWeight weight = (FontWeight)weightConverter.ConvertFromString(User.Default.TaskListFontWeight);

            Color color = (Color)ColorConverter.ConvertFromString(User.Default.TaskListFontBrushColor);

			lbTasks.FontFamily = family;
			lbTasks.FontSize = size;
			lbTasks.FontStyle = style;
			lbTasks.FontStretch = stretch;
			lbTasks.FontWeight = weight;
			lbTasks.Foreground = new SolidColorBrush(color);
        }
Пример #21
0
 private void FontChanged(object sender, PrefChangeEventArgs e)
 {
     if (e.PrefName == "fiddler.ui.font.face")
     {
         var font = e.ValueString;
         var fontFamily = new FontFamily(font);
         _panel.Dispatcher.BeginInvoke((Action)(() =>
         {
             var style = new Style(typeof(StackPanel), _panel.Style);
             style.Setters.Add(new Setter(TextBlock.FontFamilyProperty, fontFamily));
             style.Seal();
             _panel.Style = style;
         }));
     }
     if (e.PrefName == "fiddler.ui.font.size")
     {
         double value;
         if (double.TryParse(e.ValueString, out value))
         {
             _panel.Dispatcher.BeginInvoke((Action) (() =>
             {
                 var fontSizeInPoints = value*96d/72d;
                 var style = new Style(typeof (StackPanel), _panel.Style);
                 style.Setters.Add(new Setter(TextBlock.FontSizeProperty, fontSizeInPoints));
                 style.Seal();
                 _panel.Style = style;
             }));
         }
     }
 }
Пример #22
0
        public ChatDocument(IInlineUploadViewFactory factory, IWebBrowser browser, IPasteViewFactory pasteViewFactory)
        {
            _factory = factory;
            _browser = browser;
            _pasteViewFactory = pasteViewFactory;
            _handlers = new Dictionary<MessageType, Action<Message, User, Paragraph>>
                {
                    {MessageType.TextMessage, FormatUserMessage},
                    {MessageType.TimestampMessage, FormatTimestampMessage},
                    {MessageType.LeaveMessage, FormatLeaveMessage},
                    {MessageType.KickMessage, FormatKickMessage},
                    {MessageType.PasteMessage, FormatPasteMessage},
                    {MessageType.EnterMessage, FormatEnterMessage},
                    {MessageType.UploadMessage, FormatUploadMessage},
                    {MessageType.TweetMessage, FormatTweetMessage},
                    {MessageType.AdvertisementMessage, FormatAdvertisementMessage},
                    {MessageType.TopicChangeMessage, FormatTopicChangeMessage}

                };

            FontSize = 14;
            FontFamily = new FontFamily("Segoe UI");

            AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(NavigateToLink));
        }
Пример #23
0
 public Typeface(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     this.FontFamily = fontFamily;
     this.Style = style;
     this.Weight = weight;
     this.Stretch = stretch;
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FontInfo"/> class.
 /// </summary>
 /// <param name="family">The family.</param>
 /// <param name="size">The size.</param>
 /// <param name="style">The style.</param>
 /// <param name="weight">The weight.</param>
 public FontInfo(FontFamily family, double size, FontStyle style, FontWeight weight)
 {
     FontFamily = family;
     FontSize = size;
     FontStyle = style;
     FontWeight = weight;
 }
Пример #25
0
    Visual CreateContent()
    {
      DrawingContext dc;
      DrawingVisual dv = PrepareDrawingVisual(out dc);

      FontFamily family = new FontFamily("Verdana");
      Typeface typeface;
      FormattedText formattedText;
      Point position = new Point(10, 30);
      string text = String.Empty;
      double emSize = 25;
      Brush brush = Brushes.DarkBlue;

      BeginBox(dc, 1, BoxOptions.Tile);
      typeface = new Typeface(family, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
      text = "ÄÖÜäöüß";
      formattedText = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, emSize, brush);
      dc.DrawText(formattedText, position);
      EndBox(dc);

      BeginBox(dc, 2, BoxOptions.Tile);
      typeface = new Typeface(family, FontStyles.Normal, FontWeights.Bold, FontStretches.Normal);
      text = "§€ÿþ";
      formattedText = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, emSize, brush);
      dc.DrawText(formattedText, position);
      EndBox(dc);

      BeginBox(dc, 3, BoxOptions.Tile);
      typeface = new Typeface(family, FontStyles.Italic, FontWeights.Normal, FontStretches.Normal);
      formattedText = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, emSize, brush);
      dc.DrawText(formattedText, position);
      EndBox(dc);

      BeginBox(dc, 4, BoxOptions.Tile);
      typeface = new Typeface(family, FontStyles.Italic, FontWeights.Bold, FontStretches.Normal);
      formattedText = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, emSize, brush);
      dc.DrawText(formattedText, position);
      EndBox(dc);

      //BeginBox(dc, 5, BoxOptions.Tile);
      //brush = new LinearGradientBrush();
      //brush.GradientStops.Add(new GradientStop(Colors.DarkBlue, 0));
      //brush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
      //brush.GradientStops.Add(new GradientStop(Colors.Red, 1));
      //dc.DrawEllipse(brush, null, center, radiusX, radiusY);
      //EndBox(dc);

      //BeginBox(dc, 6, BoxOptions.Tile);
      //EndBox(dc);

      //BeginBox(dc, 7, BoxOptions.Tile);
      //EndBox(dc);

      //BeginBox(dc, 8, BoxOptions.Tile);
      //EndBox(dc);

      dc.Close();
      return dv;
    }
 internal void CancelPreviewFontFace()
 {
     if (_previousFontFamily != null)
     {
         RTB.FontFamily = _previousFontFamily;
         _previousFontFamily = null;
     }
 }
Пример #27
0
 public WpfFontFamilyInfo(FontFamily family, FontWeight weight, 
     FontStyle style, FontStretch stretch)
 {
     _family  = family;
     _weight  = weight;
     _style   = style;
     _stretch = stretch;
 }
Пример #28
0
        public ZRun(FontFamily Family, String Text)
            : base(Text)
        {
            this.FontStyle = System.Windows.FontStyles.Normal;
            this.FontWeight = System.Windows.FontWeights.Normal;
            this.FontFamily = Family;

        }
Пример #29
0
 public Cloud(int CanvasH, int CanvasW)
 {
     fontFamily = new FontFamily("Verdana");
     maxFontSize = 62;
     minFontSize = 12;
     CanvasHeight = CanvasH;
     CanvasWidth = CanvasW;
 }
Пример #30
0
 internal static UIFont TryGetFont(nfloat size, FontWeight fontWeight, FontStyle fontStyle, FontFamily requestedFamily, float?preferredBodyFontSize = null)
 {
     return(_tryGetFont(size, fontWeight, fontStyle, requestedFamily, preferredBodyFontSize ?? DefaultPreferredBodyFontSize));
 }
Пример #31
0
        private static UIFont InternalTryGetFont(nfloat size, FontWeight fontWeight, FontStyle fontStyle, FontFamily requestedFamily, nfloat?basePreferredSize)
        {
            UIFont font = null;

            size = GetScaledFontSize(size, basePreferredSize);

            if (requestedFamily?.Source != null)
            {
                var fontFamilyName = FontFamilyHelper.RemoveUri(requestedFamily.Source);

                // If there's a ".", we assume there's an extension and that it's a font file path.
                font = fontFamilyName.Contains(".") ? GetCustomFont(size, fontFamilyName, fontWeight, fontStyle) : GetSystemFont(size, fontWeight, fontStyle, fontFamilyName);
            }

            return(font ?? GetDefaultFont(size, fontWeight, fontStyle));
        }
Пример #32
0
        /// <summary>
        /// Adds a font family to be used in html rendering.<br/>
        /// The added font will be used by all rendering function including <see cref="HtmlContainer"/> and all WinForms controls.
        /// </summary>
        /// <remarks>
        /// The given font family instance must be remain alive while the renderer is in use.<br/>
        /// If loaded to <see cref="PrivateFontCollection"/> then the collection must be alive.<br/>
        /// If loaded from file then the file must not be deleted.
        /// </remarks>
        /// <param name="fontFamily">The font family to add.</param>
        public static void AddFontFamily(FontFamily fontFamily)
        {
            ArgChecker.AssertArgNotNull(fontFamily, "fontFamily");

            WinFormsAdapter.Instance.AddFontFamily(new FontFamilyAdapter(fontFamily));
        }
Пример #33
0
    private void ADAM_AutoIO_ChannelMask_Load(object sender, EventArgs e)
    {
        #region -- Item --
        chkbox     = new CheckBox[num_item];
        setTxtbox  = new TextBox[num_item];
        getTxtbox  = new TextBox[num_item];
        apaxTxtbox = new TextBox[num_item];
        modbTxtbox = new TextBox[num_item];
        resLabel   = new Label[num_item];
        chkbox.Initialize(); setTxtbox.Initialize();
        getTxtbox.Initialize(); apaxTxtbox.Initialize();
        modbTxtbox.Initialize(); resLabel.Initialize();
        var text_style = new FontFamily("Times New Roman");
        for (int i = 0; i < num_item; i++)
        {
            chkbox[i]                 = new CheckBox();
            chkbox[i].Name            = "StpChkIdx" + (i + 1).ToString();
            chkbox[i].Location        = new Point(10, 83 + 35 * (i + 1));
            chkbox[i].Text            = "";
            chkbox[i].Parent          = this;
            chkbox[i].CheckedChanged += new EventHandler(SubChkBoxChanged);

            setTxtbox[i]           = new TextBox();
            setTxtbox[i].Size      = new Size(60, 25);
            setTxtbox[i].Location  = new Point(174, 83 + 35 * (i + 1));
            setTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            setTxtbox[i].TextAlign = HorizontalAlignment.Center;
            setTxtbox[i].Parent    = this;

            getTxtbox[i]           = new TextBox();
            getTxtbox[i].Size      = new Size(60, 25);
            getTxtbox[i].Location  = new Point(240, 83 + 35 * (i + 1));
            getTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            getTxtbox[i].TextAlign = HorizontalAlignment.Center;
            getTxtbox[i].Parent    = this;

            apaxTxtbox[i]           = new TextBox();
            apaxTxtbox[i].Size      = new Size(60, 25);
            apaxTxtbox[i].Location  = new Point(306, 83 + 35 * (i + 1));
            apaxTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            apaxTxtbox[i].TextAlign = HorizontalAlignment.Center;
            apaxTxtbox[i].Parent    = this;

            modbTxtbox[i]           = new TextBox();
            modbTxtbox[i].Size      = new Size(60, 25);
            modbTxtbox[i].Location  = new Point(372, 83 + 35 * (i + 1));
            modbTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            modbTxtbox[i].TextAlign = HorizontalAlignment.Center;
            modbTxtbox[i].Parent    = this;

            resLabel[i]          = new Label();
            resLabel[i].Size     = new Size(60, 25);
            resLabel[i].Location = new Point(438, 83 + 35 * (i + 1));
            resLabel[i].Font     = new Font(text_style, 12, FontStyle.Regular);
            resLabel[i].Text     = "";
            resLabel[i].Parent   = this;
        }
        for (int i = 0; i < num_item; i++)
        {
            chkbox[i].Checked = true;
        }

        //
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid
        newCol.HeaderText = "Time";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 20;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Ch";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 30;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Step";
        newCol.Name       = "clmIns";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmDes";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Rowdata";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 200;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        #endregion

        ADAM6KReqService = new ADAM6KReqService();
        APAX5070Service  = new ModbusTCPService();
        //debug
        //ADAMConnection();
    }
Пример #34
0
 public static void SetButtonFontFamily(DependencyObject obj, FontFamily value)
 {
     obj.SetValue(ButtonFontFamilyProperty, value);
 }
Пример #35
0
 public static double GetFontWidth(string text, FontFamily fontFamily, double fontSize)
 {
     return(GetFontWidth(text, CultureInfo.CurrentUICulture, fontFamily, fontSize, FlowDirection.LeftToRight));
 }
Пример #36
0
        public static FlowDocument ConvertToFlowDocument(string evml, out Hyperlink[] links, FontFamily font, Brush background, double base_font_size = 12)
        {
            HtmlDocument doc = new HtmlDocument();

            FlowDocument     ret      = new FlowDocument();
            List <Hyperlink> linklist = new List <Hyperlink>();

            ret.FontFamily = font;
            ret.Background = background;

            doc.LoadHtml("<html><body>" + evml + "</body></html>");

            var body = doc.DocumentNode.SelectSingleNode("//body");

            Paragraph paragraph = new Paragraph();

            ret.Blocks.Add(paragraph);

            double fontsizemul = base_font_size / 12.0;

            StyleOptions base_style = new StyleOptions()
            {
                Color              = Colors.White,
                FontWeight         = FontWeights.Normal,
                FontStyle          = FontStyles.Normal,
                TextDecoration     = null,
                FontSize           = 12,
                FontSizeMultiplier = fontsizemul
            };

            base_style.Apply(paragraph);

            AddFlowNode(body, doc, paragraph.Inlines, linklist, base_style);

            links = linklist.ToArray();

            return(ret);
        }
Пример #37
0
        protected override void OnRender(DrawingContext dc, double renderWidth)
        {
            // This may be true if the UI for a column hasn't been loaded yet (e.g., restoring multiple tabs from workspace won't load each tab until it's clicked by the user)
            if (gridPen == null)
            {
                if (UiWrapper != null && PresentationSource.FromVisual(UiWrapper) != null)
                {
                    Matrix m         = PresentationSource.FromVisual(UiWrapper).CompositionTarget.TransformToDevice;
                    double dpiFactor = 1 / m.M11;
                    gridPen      = new Pen(Application.Current.TryFindResource("BorderThinBrush") as Brush, 1 * dpiFactor);
                    halfPenWidth = gridPen.Thickness * 0.5;
                }
            }

            columnWidth = renderWidth;
            gridHeight  = -gridPen.Thickness;
            double verticalOffset = -gridPen.Thickness;

            // If SuperDom scrolls so that editing price goes off the grid, hide the textbox until the editing price is visible again
            if (SuperDom.IsConnected)
            {
                if (tbNotes.Visibility == Visibility.Visible && SuperDom.Rows.All(r => r.Price != currentEditingPrice))
                {
                    tbNotes.Visibility = Visibility.Hidden;
                }
                if (tbNotes.Visibility == Visibility.Hidden && SuperDom.Rows.Any(r => r.Price == currentEditingPrice))
                {
                    tbNotes.Visibility = Visibility.Visible;
                }
            }

            lock (SuperDom.Rows)
                foreach (PriceRow row in SuperDom.Rows)
                {
                    // Add new prices if needed to the dictionary as the user scrolls
                    PriceStringValues.AddOrUpdate(row.Price, string.Empty, (key, oldValue) => oldValue);
                    // If textbox is open, move it when the SuperDom scrolls
                    if (tbNotes.Visibility == Visibility.Visible && row.Price == currentEditingPrice)
                    {
                        if (SuperDom.Rows.IndexOf(row) != gridIndex)
                        {
                            gridIndex = SuperDom.Rows.IndexOf(row);
                            double tbOffset = gridIndex * SuperDom.ActualRowHeight;
                            tbNotes.Margin = new Thickness(0, tbOffset, 0, 0);
                        }
                    }

                    // Draw cell
                    if (renderWidth - halfPenWidth >= 0)
                    {
                        Rect rect = new Rect(-halfPenWidth, verticalOffset, renderWidth - halfPenWidth, SuperDom.ActualRowHeight);

                        // Create a guidelines set
                        GuidelineSet guidelines = new GuidelineSet();
                        guidelines.GuidelinesX.Add(rect.Left + halfPenWidth);
                        guidelines.GuidelinesX.Add(rect.Right + halfPenWidth);
                        guidelines.GuidelinesY.Add(rect.Top + halfPenWidth);
                        guidelines.GuidelinesY.Add(rect.Bottom + halfPenWidth);

                        dc.PushGuidelineSet(guidelines);
                        dc.DrawRectangle(BackColor, null, rect);
                        dc.DrawLine(gridPen, new Point(-gridPen.Thickness, rect.Bottom), new Point(renderWidth - halfPenWidth, rect.Bottom));
                        dc.DrawLine(gridPen, new Point(rect.Right, verticalOffset), new Point(rect.Right, rect.Bottom));
                        // Print note value - remember to set MaxTextWidth so text doesn't spill into another column
                        string note;
                        if (PriceStringValues.TryGetValue(row.Price, out note) && !string.IsNullOrEmpty(PriceStringValues[row.Price]))
                        {
                            fontFamily = SuperDom.Font.Family;
                            typeFace   = new Typeface(fontFamily, SuperDom.Font.Italic ? FontStyles.Italic : FontStyles.Normal, SuperDom.Font.Bold ? FontWeights.Bold : FontWeights.Normal, FontStretches.Normal);

                            if (renderWidth - 6 > 0)
                            {
                                FormattedText noteText = new FormattedText(note, Core.Globals.GeneralOptions.CurrentCulture, FlowDirection.LeftToRight, typeFace, SuperDom.Font.Size, ForeColor)
                                {
                                    MaxLineCount = 1, MaxTextWidth = renderWidth - 6, Trimming = TextTrimming.CharacterEllipsis
                                };
                                dc.DrawText(noteText, new Point(0 + 4, verticalOffset + (SuperDom.ActualRowHeight - noteText.Height) / 2));
                            }
                        }

                        dc.Pop();
                        verticalOffset += SuperDom.ActualRowHeight;
                        gridHeight     += SuperDom.ActualRowHeight;
                    }
                }
        }
Пример #38
0
 internal static Typeface FontFamilyToTypeFace(FontFamily fontFamily, FontWeight fontWeight, TypefaceStyle style = TypefaceStyle.Normal)
 {
     return(_fontFamilyToTypeFace(fontFamily, fontWeight, style));
 }
Пример #39
0
 private void SetDefaultTabStop(FontFamily font, double fontSize)
 {
     Document.DefaultTabStop     = FontUtility.GetTextWidth(font, fontSize, "text");
     TextDocument.DefaultTabStop = FontUtility.GetTextWidth(font, fontSize, "text");
 }
Пример #40
0
 public LabelHEX() : base()
 {
     Text       = "DATA is null";
     FontFamily = new FontFamily(System.Drawing.FontFamily.GenericMonospace.Name);
 }
Пример #41
0
 public Button(String Name, TgcD3dInput Input, CustomBitmap normal, CustomBitmap mouseover, Action Callback, FontFamily fontFamily) : base(Input)
 {
     this.nombre                 = Name;
     this.sprite_normal          = normal;
     this.sprite_mouseover       = mouseover;
     this.current_sprite         = new CustomSprite();
     this.current_sprite.Bitmap  = sprite_normal;
     this.current_sprite.Scaling = new Vector2(0.5f, 0.5f);
     this.Callback               = Callback;
     drawText       = new TgcText2D();
     drawText.Align = TgcText2D.TextAlign.LEFT;
     drawText.changeFont(new Font(fontFamily, 25, FontStyle.Regular));
 }
Пример #42
0
 private void  MainWindow_Loaded(Object sender, RoutedEventArgs e)
 {
     familiaPre = ctEditor.FontFamily;
     sizePre    = ctEditor.FontSize;
 }
Пример #43
0
 // Add an element to this collection.
 internal void Add(FontFamily family)
 {
     _families.Add(family);
 }
Пример #44
0
        protected Size MeasureString(string text, double fontSize, double width, double height, FontWeight fontWeight, FontStyle fontStyle, FontFamily fontFamily)
        {
            TextBlock textBlock = new TextBlock {
                Text = text, TextWrapping = TextWrapping.NoWrap, FontSize = fontSize, FontWeight = fontWeight, FontStyle = fontStyle, FontFamily = fontFamily
            };

            textBlock.Measure(new Size(width, height));
            textBlock.Arrange(new Rect(textBlock.DesiredSize));
            return(textBlock.RenderSize);
        }
        public async void LoadEmbeddedBibles(Dispatcher dispatcher, FontFamily defaultFont)
        {
            Task <List <BibleModel> > loadedBiles = BiblesData.Database.GetBibles();

            if (loadedBiles.Result.Count >= bibleNames.Length)
            {
                dispatcher.Invoke(() =>
                {
                    this.InitialDataLoadCompleted?.Invoke(this, string.Empty, true, null);
                });

                return;
            }

            await Task.Run(() =>
            {
                try
                {
                    foreach (string bible in bibleNames)
                    {
                        dispatcher.Invoke(() =>
                        {
                            this.InitialDataLoadCompleted?.Invoke(this, $"Loading...{bible}", false, null);
                        });

                        BibleModel bibleModel = loadedBiles.Result.FirstOrDefault(l => l.BibleName == bible);

                        if (bibleModel == null)
                        {
                            bibleModel = new BibleModel
                            {
                                BiblesId  = 0,
                                BibleName = bible
                            };

                            BiblesData.Database.InsertBible(bibleModel);

                            BibleModel added = BiblesData.Database.GetBible(bible);

                            while (added == null)
                            {
                                Sleep.ThreadWait(100);

                                added = BiblesData.Database.GetBible(bible);
                            }

                            bibleModel.BiblesId = added.BiblesId;
                        }

                        this.LoadBibleVerses(dispatcher, bibleModel);

                        if (bible == this.systemDefaultbible)
                        {
                            UserPreferenceModel userPref = new UserPreferenceModel
                            {
                                DefaultBible     = bibleModel.BiblesId,
                                Font             = defaultFont.ParseToString(),
                                FontSize         = 12,
                                SynchronizzeTabs = false,
                                LanguageId       = 0
                            };

                            BiblesData.Database.InsertPreference(userPref);
                        }
                    }
                }
                catch (Exception err)
                {
                    dispatcher.Invoke(() =>
                    {
                        this.InitialDataLoadCompleted?.Invoke(this, string.Empty, false, err);
                    });
                }

                dispatcher.Invoke(() =>
                {
                    this.InitialDataLoadCompleted?.Invoke(this, string.Empty, true, null);
                });
            });
        }
 internal static string GetDisplayName(FontFamily family)
 {
     return(NameDictionaryHelper.GetDisplayName(family.FamilyNames));
 }
Пример #47
0
        protected void Display(bool aFilter)
        {
            Log("Display({0})", aFilter);
            Log("Current Label '{0}'", mCurrentLabel);
            mCode.Clear();
            tblkSource.Inlines.Clear();
            mRunsToLines.Clear();
            Log("Display - Done clearing");
            if (mData.Length == 0)
            {
                return;
            }

            int  nextCodeDistFromCurrent = 0;
            bool foundCurrentLine        = false;

            var xFont = new FontFamily("Consolas");
            //We need multiple prefix filters because method header has different prefix to IL labels.
            //We use:
            // - First "Method_" label prefix
            // - First label without "GUID_" or "METHOD_" on it as that will be the name of the current method
            List <string> xLabelPrefixes     = new List <string>();
            bool          foundMETHOD_Prefix = false;
            bool          foundMethodName    = false;
            int           mCurrentLineNumber = 0;

            Log("Display - Processing lines");
            foreach (var xLine in mLines)
            {
                string xDisplayLine = xLine.ToString();

                if (aFilter)
                {
                    if (xLine is AsmLabel xAsmLabel)
                    {
                        xDisplayLine = xAsmLabel.Label + ":";

                        // Skip ASM labels
                        if (xAsmLabel.Comment.ToUpper() == "ASM")
                        {
                            continue;
                        }

                        if (!foundMETHOD_Prefix && xAsmLabel.Label.StartsWith("METHOD_"))
                        {
                            var xLabelParts = xAsmLabel.Label.Split('.');
                            xLabelPrefixes.Add(xLabelParts[0] + ".");
                            foundMETHOD_Prefix = true;
                        }
                        else if (!foundMethodName && !xAsmLabel.Label.StartsWith("METHOD_") &&
                                 !xAsmLabel.Label.StartsWith("GUID_"))
                        {
                            var xLabelParts = xAsmLabel.Label.Split(':');
                            xLabelPrefixes.Add(xLabelParts[0] + ".");
                            foundMethodName = true;
                        }
                    }
                    else
                    {
                        xDisplayLine = xLine.ToString();
                    }

                    // Replace all and not just labels so we get jumps, calls etc
                    foreach (string xLabelPrefix in xLabelPrefixes)
                    {
                        xDisplayLine = xDisplayLine.Replace(xLabelPrefix, "");
                    }
                }

                if (xLine is AsmLabel)
                {
                    // Insert a blank line before labels, but not if its the top line
                    if (tblkSource.Inlines.Count > 0)
                    {
                        tblkSource.Inlines.Add(new LineBreak());
                        if (!foundCurrentLine)
                        {
                            mCurrentLineNumber++;
                        }

                        mCode.AppendLine();
                    }
                }
                else
                {
                    xDisplayLine = "\t" + xDisplayLine;
                }

                // Even though our code is often the source of the tab, it makes
                // more sense to do it this was because the number of space stays
                // in one place and also lets us differentiate from natural spaces.
                xDisplayLine = xDisplayLine.Replace("\t", "  ");

                var xRun = new Run(xDisplayLine);
                xRun.FontFamily = xFont;
                mRunsToLines.Add(xRun, xLine);

                var gutterRect = new Rectangle()
                {
                    Width  = 11,
                    Height = 11,
                    Fill   = Brushes.WhiteSmoke
                };
                tblkSource.Inlines.Add(gutterRect);

                // Set colour of line
                if (xLine is AsmLabel)
                {
                    xRun.Foreground = Brushes.Black;
                }
                else if (xLine is AsmComment)
                {
                    xRun.Foreground = Brushes.Green;
                }
                else if (xLine is AsmCode xAsmCode)
                {
                    gutterRect.MouseUp += gutterRect_MouseUp;
                    gutterRect.Fill     = Brushes.LightGray;
                    mGutterRectsToCode.Add(gutterRect, xAsmCode);
                    mGutterRectsToRun.Add(gutterRect, xRun);
                    Log("Current AsmCodeLabel: '{0}'", xAsmCode.AsmLabel);
                    if (xAsmCode.LabelMatches(mCurrentLabel))
                    {
                        xRun.Foreground = Brushes.WhiteSmoke;
                        xRun.Background = Brushes.DarkRed;

                        Package.StateStorer.CurrLineId = GetLineId(xAsmCode);
                        Package.StoreAllStates();

                        foundCurrentLine        = true;
                        nextCodeDistFromCurrent = 0;
                    }
                    else
                    {
                        if (foundCurrentLine)
                        {
                            nextCodeDistFromCurrent++;
                        }

                        if (mASMBPs.Contains(GetLineId(xAsmCode)))
                        {
                            xRun.Background = Brushes.MediumVioletRed;
                        }
                        else if (Package.StateStorer.ContainsStatesForLine(GetLineId(xAsmCode)))
                        {
                            xRun.Background = Brushes.LightYellow;
                        }

                        xRun.Foreground = Brushes.Blue;
                    }

                    xRun.MouseUp += OnASMCodeTextMouseUp;
                }
                else
                { // Unknown type
                    xRun.Foreground = Brushes.HotPink;
                }

                if (!foundCurrentLine)
                {
                    mCurrentLineNumber++;
                }
                tblkSource.Inlines.Add(xRun);
                tblkSource.Inlines.Add(new LineBreak());

                mCode.AppendLine(xDisplayLine);
            }
            Log("Display - Done processing lines");
            //EdMan196: This line of code was worked out by trial and error.
            double offset = mCurrentLineNumber * 13.1;

            Log("Display - Scroll to offset");
            ASMScrollViewer.ScrollToVerticalOffset(offset);
        }
Пример #48
0
        public static void SetSkin(string themeName)
        {
            Theme theme = ThemeLoader.loadTheme(themeName);

            Application.Current.Resources["Color_BackgroundTitle"]  = theme.DisplayProperty.Title.MainBackground;
            Application.Current.Resources["Color_BackgroundMain"]   = theme.DisplayProperty.Display.MainBackground;
            Application.Current.Resources["Color_BackgroundSide"]   = theme.DisplayProperty.Side.MainBackground;
            Application.Current.Resources["Color_BackgroundTab"]    = theme.DisplayProperty.Tools.MainBackground;
            Application.Current.Resources["Color_BackgroundSearch"] = theme.DisplayProperty.Search.MainBackground;
            Application.Current.Resources["Color_BackgroundMenu"]   = theme.DisplayProperty.Menu.MainBackground;
            Application.Current.Resources["Color_ForegroundGlobal"] = theme.DisplayProperty.Global.MainForeground;
            Application.Current.Resources["Color_ForegroundSearch"] = theme.DisplayProperty.Search.MainForeground;
            Application.Current.Resources["Color_BorderBursh"]      = Colors.Transparent;

            //设置字体
            GlobalFont = new FontFamily("微软雅黑");
            if (theme.Font != null)
            {
                var fonts = Fonts.GetFontFamilies(new Uri(theme.Font));
                if (fonts != null && fonts.Count >= 1)
                {
                    GlobalFont = fonts.First();
                }
            }
            foreach (Window window in App.Current.Windows)
            {
                window.FontFamily = GlobalFont;
            }

            //Console.WriteLine(fonts);

            //if (theme == "黑色")
            //{
            //    Application.Current.Resources["Color_BackgroundTitle"] = (Color)ColorConverter.ConvertFromString("#22252A");
            //    Application.Current.Resources["Color_BackgroundMain"] = (Color)ColorConverter.ConvertFromString("#1B1B1F");
            //    Application.Current.Resources["Color_BackgroundSide"] = (Color)ColorConverter.ConvertFromString("#101013");
            //    Application.Current.Resources["Color_BackgroundTab"] = (Color)ColorConverter.ConvertFromString("#383838");
            //    Application.Current.Resources["Color_BackgroundSearch"] = (Color)ColorConverter.ConvertFromString("#18191B");
            //    Application.Current.Resources["Color_BackgroundMenu"] = (Color)ColorConverter.ConvertFromString("#252526");
            //    Application.Current.Resources["Color_ForegroundGlobal"] = (Color)ColorConverter.ConvertFromString("#AFAFAF");
            //    Application.Current.Resources["Color_ForegroundSearch"] = Colors.White;
            //    Application.Current.Resources["Color_BorderBursh"] = Colors.Transparent;
            //}
            //else if (theme == "白色")
            //{
            //    Application.Current.Resources["Color_BackgroundTitle"] = (Color)ColorConverter.ConvertFromString("#E2E3E5");
            //    Application.Current.Resources["Color_BackgroundMain"] = (Color)ColorConverter.ConvertFromString("#F9F9F9");
            //    Application.Current.Resources["Color_BackgroundSide"] = (Color)ColorConverter.ConvertFromString("#F2F3F4");
            //    Application.Current.Resources["Color_BackgroundTab"] = (Color)ColorConverter.ConvertFromString("#FFF5EE");
            //    Application.Current.Resources["Color_BackgroundSearch"] = (Color)ColorConverter.ConvertFromString("#D1D1D1");
            //    Application.Current.Resources["Color_BackgroundMenu"] = Colors.White;
            //    Application.Current.Resources["Color_ForegroundGlobal"] = (Color)ColorConverter.ConvertFromString("#555555");
            //    Application.Current.Resources["Color_ForegroundSearch"] = Colors.Black;
            //    Application.Current.Resources["Color_BorderBursh"] = Colors.Gray;
            //}
            //else if (theme == "蓝色")

            //{
            //    Application.Current.Resources["Color_BackgroundTitle"] = (Color)ColorConverter.ConvertFromString("#0288D1");
            //    Application.Current.Resources["Color_BackgroundMain"] = (Color)ColorConverter.ConvertFromString("#2BA2D2");
            //    Application.Current.Resources["Color_BackgroundSide"] = (Color)ColorConverter.ConvertFromString("#03A9F5");
            //    Application.Current.Resources["Color_BackgroundTab"] = (Color)ColorConverter.ConvertFromString("#0288D1");
            //    Application.Current.Resources["Color_BackgroundSearch"] = (Color)ColorConverter.ConvertFromString("#87CEEB");
            //    Application.Current.Resources["Color_BackgroundMenu"] = (Color)ColorConverter.ConvertFromString("#0288D1");
            //    Application.Current.Resources["Color_ForegroundGlobal"] = Colors.White;
            //    Application.Current.Resources["Color_ForegroundSearch"] = Colors.White;
            //    Application.Current.Resources["Color_BorderBursh"] = (Color)ColorConverter.ConvertFromString("#95DCED");

            //}


            Application.Current.Resources["BackgroundTitle"]  = new SolidColorBrush((Color)Application.Current.Resources["Color_BackgroundTitle"]);
            Application.Current.Resources["BackgroundMain"]   = new SolidColorBrush((Color)Application.Current.Resources["Color_BackgroundMain"]);
            Application.Current.Resources["BackgroundSide"]   = new SolidColorBrush((Color)Application.Current.Resources["Color_BackgroundSide"]);
            Application.Current.Resources["BackgroundTab"]    = new SolidColorBrush((Color)Application.Current.Resources["Color_BackgroundTab"]);
            Application.Current.Resources["BackgroundSearch"] = new SolidColorBrush((Color)Application.Current.Resources["Color_BackgroundSearch"]);
            Application.Current.Resources["BackgroundMenu"]   = new SolidColorBrush((Color)Application.Current.Resources["Color_BackgroundMenu"]);
            Application.Current.Resources["ForegroundGlobal"] = new SolidColorBrush((Color)Application.Current.Resources["Color_ForegroundGlobal"]);
            Application.Current.Resources["ForegroundSearch"] = new SolidColorBrush((Color)Application.Current.Resources["Color_ForegroundSearch"]);
            Application.Current.Resources["BorderBursh"]      = new SolidColorBrush((Color)Application.Current.Resources["Color_BorderBursh"]);
        }
Пример #49
0
        public void DrawString(int x, int y, string message, Color?forecolor = null, Color?backcolor = null, int?fontsize = null,
                               string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null)
        {
            using (var g = GetGraphics())
            {
                try
                {
                    var family = FontFamily.GenericMonospace;
                    if (fontfamily != null)
                    {
                        family = new FontFamily(fontfamily);
                    }

                    var fstyle = FontStyle.Regular;
                    if (fontstyle != null)
                    {
                        switch (fontstyle.ToLower())
                        {
                        default:
                        case "regular":
                            break;

                        case "bold":
                            fstyle = FontStyle.Bold;
                            break;

                        case "italic":
                            fstyle = FontStyle.Italic;
                            break;

                        case "strikethrough":
                            fstyle = FontStyle.Strikeout;
                            break;

                        case "underline":
                            fstyle = FontStyle.Underline;
                            break;
                        }
                    }

                    // The text isn't written out using GenericTypographic, so measuring it using GenericTypographic seemed to make it worse.
                    // And writing it out with GenericTypographic just made it uglier. :p
                    var  f          = new StringFormat(StringFormat.GenericDefault);
                    var  font       = new Font(family, fontsize ?? 12, fstyle, GraphicsUnit.Pixel);
                    Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize();
                    if (horizalign != null)
                    {
                        switch (horizalign.ToLower())
                        {
                        default:
                        case "left":
                            break;

                        case "center":
                            x -= sizeOfText.Width / 2;
                            break;

                        case "right":
                            x -= sizeOfText.Width;
                            break;
                        }
                    }

                    if (vertalign != null)
                    {
                        switch (vertalign.ToLower())
                        {
                        default:
                        case "bottom":
                            break;

                        case "middle":
                            y -= sizeOfText.Height / 2;
                            break;

                        case "top":
                            y -= sizeOfText.Height;
                            break;
                        }
                    }

                    var bg = backcolor ?? _defaultBackground;
                    if (bg.HasValue)
                    {
                        for (var xd = -1; xd <= 1; xd++)
                        {
                            for (var yd = -1; yd <= 1; yd++)
                            {
                                g.DrawString(message, font, GetBrush(bg.Value), x + xd, y + yd);
                            }
                        }
                    }
                    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
                    g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y);
                }
                catch (Exception)
                {
                    return;
                }
            }
        }
Пример #50
0
        private void PaintSpecialEffects( )
        {
            if (_image != null)
            {
                _image.Dispose();
            }

            _image = _codecs.Load(ImagePath + _fileNameArray[_index]);

            _index = (_index + 1) % _fileNameArray.Length;

            Graphics g = _pnlViewer.CreateGraphics();

            Rectangle rc = _pnlViewer.ClientRectangle;

            rc = _processor.DrawFrame(
                g,
                rc,
                SpecialEffectsFrameStyleFlags.AdjustRectangle | SpecialEffectsFrameStyleFlags.OuterRaised,
                2,
                Color.Silver,
                2,
                Color.DarkGray,
                Color.White,
                2,
                Color.DarkGray,
                Color.White);

            if (_ckShowTransition.Checked)
            {
                for (int i = 0; i < _transitionOptions.EffectOptions.Passes; i++)
                {
                    _processor.PaintTransition(
                        g,
                        _transitionOptions.Style,
                        _transitionOptions.BackColor,
                        _transitionOptions.ForeColor,
                        Steps,
                        rc,
                        _transitionOptions.EffectOptions.Type,
                        _transitionOptions.EffectOptions.Grain,
                        _transitionOptions.EffectOptions.Delay,
                        Speed,
                        Cycles,
                        i + 1,
                        _transitionOptions.EffectOptions.Passes,
                        Transparency,
                        Color.Empty,
                        _transitionOptions.EffectOptions.Wand,
                        WandColor,
                        RasterPaintProperties.SourceCopy,
                        null);
                }
            }

            for (int i = 0; i < _effectOptions.Passes; i++)
            {
                RasterPaintProperties paintProp = new RasterPaintProperties();
                paintProp.RasterOperation = RasterPaintProperties.SourceCopy;

                _processor.PaintImage(g,
                                      _image,
                                      Rectangle.Empty,
                                      Rectangle.Empty,
                                      rc,
                                      rc,
                                      _effectOptions.Type,
                                      _effectOptions.Grain,
                                      _effectOptions.Delay,
                                      0,
                                      0,
                                      i + 1,
                                      _effectOptions.Passes,
                                      false,
                                      Color.Empty,
                                      _effectOptions.Wand,
                                      WandColor,
                                      paintProp,
                                      null);
            }

            if (_ckShowShape.Checked)
            {
                _processor.Draw3dShape(
                    g,
                    _shapeOptions.ShapeStyle,
                    rc,
                    _shapeOptions.BackColor,
                    null,
                    rc,
                    SpecialEffectsBackStyle.Translucent,
                    _shapeOptions.ForeColor,
                    _shapeOptions.FillStyle,
                    Color.Red,
                    SpecialEffectsBorderStyle.Solid,
                    2,
                    Color.Green,
                    Color.Yellow,
                    SpecialEffectsInnerStyle.Raised,
                    2,
                    Color.Turquoise,
                    Color.Snow,
                    SpecialEffectsOuterStyle.Inset,
                    2,
                    5,
                    5,
                    Color.Black,
                    null);
            }

            if (_ckShowText.Checked)
            {
                FontFamily ff = new FontFamily("Arial");

                Font f = new Font(ff, 48);

                _processor.Draw3dText(
                    g,
                    _textOptions.Text,
                    rc,
                    _textOptions.Style,
                    SpecialEffectsTextAlignmentFlags.HorizontalCenter | SpecialEffectsTextAlignmentFlags.VerticalCenter,
                    5,
                    5,
                    _textOptions.TextColor,
                    _textOptions.BorderColor,
                    Color.White,
                    f,
                    null);
            }

            g.Dispose();
        }
Пример #51
0
 public Typeface GetTypeface(FontFamily fontFamily, FontWeight fontWeight, FontStyle fontStyle)
 {
     return(TypefaceCache.Get(fontFamily.Name, fontWeight, fontStyle).Typeface);
 }
Пример #52
0
        internal static Typeface InternalFontFamilyToTypeFace(FontFamily fontFamily, FontWeight fontWeight, TypefaceStyle style)
        {
            if (fontFamily?.Source == null || fontFamily.Equals(FontFamily.Default))
            {
                fontFamily = GetDefaultFontFamily(fontWeight);
            }

            Typeface typeface;

            try
            {
                if (typeof(FontHelper).Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    typeof(FontHelper).Log().Debug($"Searching for font [{fontFamily.Source}]");
                }

                // If there's a ".", we assume there's an extension and that it's a font file path.
                if (fontFamily.Source.Contains("."))
                {
                    var source = fontFamily.Source;

                    // The lookup is always performed in the assets folder, even if its required to specify it
                    // with UWP.
                    source = source.TrimStart("ms-appx://", StringComparison.OrdinalIgnoreCase);
                    source = source.TrimStart("/assets/", StringComparison.OrdinalIgnoreCase);
                    source = FontFamilyHelper.RemoveHashFamilyName(source);

                    if (typeof(FontHelper).Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                    {
                        typeof(FontHelper).Log().Debug($"Searching for font as asset [{source}]");
                    }

                    // We need to lookup assets manually, as assets are stored this way by android, but windows
                    // is case insensitive.
                    string actualAsset = AssetsHelper.FindAssetFile(source);
                    if (actualAsset != null)
                    {
                        typeface = Android.Graphics.Typeface.CreateFromAsset(Android.App.Application.Context.Assets, actualAsset);

                        if (style != typeface.Style)
                        {
                            typeface = Typeface.Create(typeface, style);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException($"Unable to find [{fontFamily.Source}] from the application's assets.");
                    }
                }
                else
                {
                    typeface = Android.Graphics.Typeface.Create(fontFamily.Source, style);
                }

                return(typeface);
            }
            catch (Exception e)
            {
                if (typeof(FontHelper).Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Error))
                {
                    typeof(FontHelper).Log().Error("Unable to find font", e);

                    if (typeof(FontHelper).Log().IsEnabled(LogLevel.Warning))
                    {
                        if (!_assetsListed)
                        {
                            _assetsListed = true;

                            var allAssets = AssetsHelper.AllAssets.JoinBy("\r\n");
                            typeof(FontHelper).Log().Warn($"List of available assets: {allAssets}");
                        }
                    }
                }

                return(null);
            }
        }
Пример #53
0
 public FontFamilyItem(string familyName, string categoryName, string previewName, FontFamily fontFamily)
 {
     if (fontFamily == null)
     {
         familyName = FontFamilyItem.EnsureFamilyName(familyName);
         fontFamily = new FontFamily(familyName);
     }
     this.unescapedFamilyName = Uri.UnescapeDataString(familyName);
     this.familyName          = familyName;
     this.categoryName        = categoryName;
     this.previewName         = previewName;
     this.fontFamily          = fontFamily;
 }
Пример #54
0
 public static void SetValueFontFamily(DependencyObject i, FontFamily v) => i.Set(SecondaryValueFontFamilyProperty, v);
 private List <KeyValuePair <FontStyle, TogleButton> > GetFirstLevelAvailibleStyles(FontFamily family)
 {
     return(this
            .Where(pair => family
                   .IsStyleAvailable(pair.Key))
            .ToList());
 }
Пример #56
0
 /// <summary>
 /// Constructs a Font.
 /// </summary>
 /// <param name="family">the family to which this font belongs</param>
 /// <param name="size">the size of this font</param>
 public Font(FontFamily family, float size) : this(family, size, UNDEFINED, null)
 {
 }
 private List <KeyValuePair <FontStyle, TogleButton> > GetSecondLevelAvailibleStyles(FontFamily family, FontStyle style)
 {
     return(this
            .Where(pair => pair.Key != style)
            .Where(pair => family.IsStyleAvailable(style |= pair.Key))
            .ToList());
 }
Пример #58
0
 /// <summary>
 /// Constructs a Font.
 /// </summary>
 /// <param name="family">the family to which this font belongs</param>
 /// <param name="size">the size of this font</param>
 /// <param name="style">the style of this font</param>
 public Font(FontFamily family, float size, int style) : this(family, size, style, null)
 {
 }
Пример #59
0
        public OptionWnd(MainWindow main)
        {
            this.main = main;
            InitializeComponent();
            Title = MainWindow.ProgramName + " Option";

            if (!System.IO.File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\nofont.txt"))
            {
                FontFamily = new FontFamily("Microsoft YaHei");
            }

            txtProxy.Text = MainWindow.Proxy;

            rtNoProxy.IsChecked = true;
            if (MainWindow.ProxyType == ProxyType.System)
            {
                rtSystem.IsChecked = true;
            }
            else if (MainWindow.ProxyType == ProxyType.Custom)
            {
                rtCustom.IsChecked = true;
                txtProxy.IsEnabled = true;
            }
            txtBossKey.Text = MainWindow.BossKey.ToString();
            txtPattern.Text = main.namePatter;
            chkProxy_Click(null, null);
            //chkAero.IsChecked = main.isAero;
            txtCount.Text        = PreFetcher.CachedImgCount.ToString();
            txtParal.Text        = main.downloadC.NumOnce.ToString();
            chkSepSave.IsChecked = main.downloadC.IsSepSave;
            chkSscSave.IsChecked = main.downloadC.IsSscSave;
            chkSaSave.IsChecked  = main.downloadC.IsSaSave;
            txtSaveLocation.Text = DownloadControl.SaveLocation;

            if (main.bgSt == Stretch.None)
            {
                cbBgSt.SelectedIndex = 0;
            }
            else if (main.bgSt == Stretch.Uniform)
            {
                cbBgSt.SelectedIndex = 1;
            }
            else if (main.bgSt == Stretch.UniformToFill)
            {
                cbBgSt.SelectedIndex = 2;
            }

            if (main.bgHe == AlignmentX.Left)
            {
                cbBgHe.SelectedIndex = 0;
            }
            else if (main.bgHe == AlignmentX.Center)
            {
                cbBgHe.SelectedIndex = 1;
            }
            else if (main.bgHe == AlignmentX.Right)
            {
                cbBgHe.SelectedIndex = 2;
            }

            if (main.bgVe == AlignmentY.Top)
            {
                cbBgVe.SelectedIndex = 0;
            }
            else if (main.bgVe == AlignmentY.Center)
            {
                cbBgVe.SelectedIndex = 1;
            }
            else if (main.bgVe == AlignmentY.Bottom)
            {
                cbBgVe.SelectedIndex = 2;
            }

            textNameHelp.ToolTip = "【以下必须是小写英文】\r\n%site 站点名\r\n%id 编号\r\n%tag 标签\r\n%desc 描述\r\n"
                                   + "%author 作者名\r\n%date 上载时间\r\n%imgp[3] 图册页数[页数总长度(补0)]\r\n\r\n"
                                   + "<!< 裁剪符号【注意裁剪符号 <!< 只能有一个】\r\n"
                                   + "表示从 <!< 左边所有名称进行过长裁剪、避免路径过长问题\r\n"
                                   + "建议把裁剪符号写在 标签%tag 或 描述%desc 后面";

            #region 文件名规则格式按钮绑定
            FNRsite.Click   += new RoutedEventHandler(FNRinsert);
            FNRid.Click     += new RoutedEventHandler(FNRinsert);
            FNRtag.Click    += new RoutedEventHandler(FNRinsert);
            FNRdesc.Click   += new RoutedEventHandler(FNRinsert);
            FNRauthor.Click += new RoutedEventHandler(FNRinsert);
            FNRdate.Click   += new RoutedEventHandler(FNRinsert);
            FNRimgp.Click   += new RoutedEventHandler(FNRinsert);
            FNRcut.Click    += new RoutedEventHandler(FNRinsert);
            #endregion
        }
Пример #60
-2
 public FontProperties()
 {
     FontSize = 12;
     FontFamily = new FontFamily("Arial");
     FontStyle = FontStyles.Normal;
     FontWeight = FontWeights.Normal;
 }