Ejemplo n.º 1
0
        public Cell(int row, int col, Grid gameGrid, Action action, double probability, bool draw)
        {
            random        = new Random();
            this.row      = row;
            this.col      = col;
            this.gameGrid = gameGrid;
            this.action   = action;
            this.draw     = draw;
            if (!draw)
            {
                return;
            }

            rect = new Rectangle();
            var txt = new TextBlock();

            txt.Background        = Brushes.White;
            txt.FontWeight        = FontWeight.FromOpenTypeWeight(500);
            txt.TextAlignment     = TextAlignment.Center;
            txt.VerticalAlignment = VerticalAlignment.Top;
            txt.Text    = probability.ToString("N3");
            txt.Opacity = 0.8;
            SetToGridCell(new List <UIElement> {
                rect, txt
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a stop.
        /// </summary>
        /// <param name="layer">Assigned route layer</param>
        /// <param name="p">Position of the way point (world coordinates)</param>
        /// <param name="style">Style of the way point</param>
        public Stop(RouteLayer layer, Point p, ShapeStyle style) : base(layer, p, style)
        {
            // add a pin
            Pin = new Pin {
                Color = style.Color, Width = style.Size, Height = style.Size
            };
            Children.Add(Pin);

            // overlay pin with a text block
            Children.Add(new TextBlock
            {
                Text            = "",
                Foreground      = new SolidColorBrush(Colors.Black),
                FontSize        = style.Size * 0.3125,
                FontWeight      = FontWeight.FromOpenTypeWeight(800),
                RenderTransform = new RotateTransform(-45),
                Effect          = new DropShadowEffect
                {
                    ShadowDepth = 0.125 * style.Size,
                    Direction   = 45,
                    Color       = Colors.White,
                    Opacity     = 0.5,
                    BlurRadius  = 0.125 * style.Size
                }
            });

            // position subordinate elements
            SetLeft(Children[1], 0.25 * style.Size);
            SetTop(Children[1], 0.4375 * style.Size);

            ShapeCanvas.SetAnchor(this, LocationAnchor.RightBottom);
            layer.Shapes.Add(this);
        }
        public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
        {
            if (String.IsNullOrEmpty(text))
            {
                return(OxySize.Empty);
            }

            var tb = new TextBlock
            {
                Text = text
            };

            if (fontFamily != null)
            {
                tb.FontFamily = new FontFamily(fontFamily);
            }
            if (fontSize > 0)
            {
                tb.FontSize = fontSize;
            }
            if (fontWeight > 0)
            {
                tb.FontWeight = FontWeight.FromOpenTypeWeight((int)fontWeight);
            }

            tb.Measure(new Size(1000, 1000));

            return(new OxySize(tb.DesiredSize.Width, tb.DesiredSize.Height));
        }
Ejemplo n.º 4
0
        public void UpdateNativeView()
        {
            if (_currentInputWidget == null)
            {
                // If the input widget does not exist, we don't need to update it.
                return;
            }

            var textBox = _owner.TextBox;

            if (textBox == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            EnsureWidgetForAcceptsReturn();

            _currentInputWidget.FontSize      = textBox.FontSize;
            _currentInputWidget.FontWeight    = FontWeight.FromOpenTypeWeight(textBox.FontWeight.Weight);
            _currentInputWidget.AcceptsReturn = textBox.AcceptsReturn;
            _currentInputWidget.TextWrapping  = textBox.AcceptsReturn ? TextWrapping.Wrap : TextWrapping.NoWrap;
            _currentInputWidget.MaxLength     = textBox.MaxLength;
            _currentInputWidget.IsReadOnly    = textBox.IsReadOnly;
            _currentInputWidget.Foreground    = textBox.Foreground.ToWpfBrush();
        }
Ejemplo n.º 5
0
        private void ChangeItemSoursedgTable()
        {
            List <RowBase> list = new List <RowBase>();

            DateTime datePEndEndDay = DateTime.MinValue;

            if (datePEnd.SelectedDate != null)
            {
                datePEndEndDay = (DateTime)datePEnd.SelectedDate;
            }

            foreach (RowBase item in _listBases)
            {
                if (!(_filterIsNotList && item.Name != _nameRowIsNotList))
                {
                    if (item.DateCreate >= datePBegin.SelectedDate && item.DateCreate <= datePEndEndDay ||
                        item.DateEdit >= datePBegin.SelectedDate && item.DateEdit <= datePEndEndDay)
                    {
                        list.Add(item);
                    }
                }
            }

            _listBasesFiltering = list;

            dgTable.ItemsSource = _listBasesFiltering;

            btnFilterIsNotList.FontWeight = FontWeight.FromOpenTypeWeight(_filterIsNotList ? 500 : 1);
        }
Ejemplo n.º 6
0
        public void UpdateNativeView()
        {
            if (_currentInputWidget == null)
            {
                // If the input widget does not exist, we don't need to update it.
                return;
            }

            var textBox = _owner.TextBox;

            if (textBox == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            EnsureWidgetForAcceptsReturn();

            _currentInputWidget.FontSize      = textBox.FontSize;
            _currentInputWidget.FontWeight    = FontWeight.FromOpenTypeWeight(textBox.FontWeight.Weight);
            _currentInputWidget.AcceptsReturn = textBox.AcceptsReturn;
            _currentInputWidget.TextWrapping  = textBox.AcceptsReturn ? TextWrapping.Wrap : TextWrapping.NoWrap;
            _currentInputWidget.MaxLength     = textBox.MaxLength;
            _currentInputWidget.IsReadOnly    = textBox.IsReadOnly;

            if (textBox.Foreground is SolidColorBrush colorBrush)
            {
                var unoColor = colorBrush.Color;
                _currentInputWidget.Foreground = new System.Windows.Media.SolidColorBrush(Color.FromArgb(unoColor.A, unoColor.R, unoColor.G, unoColor.B));
            }
        }
Ejemplo n.º 7
0
        TextBlock AddTitle(string title)
        {
            var tb = AddLabel(title);

            tb.FontWeight = FontWeight.FromOpenTypeWeight(500);
            return(tb);
        }
Ejemplo n.º 8
0
        private void PrintNode(Node item, Color color)
        {
            double  x  = zeroX + item.Coordenates.X * passoX;
            double  y  = zeroY - item.Coordenates.Y * passoY;
            Ellipse el = new Ellipse();

            el.Width  = DiametroNode;
            el.Height = DiametroNode;
            el.Fill   = new SolidColorBrush(color);
            Canvas.SetLeft(el, x - RaioNode);
            Canvas.SetTop(el, y - RaioNode);
            canvas.Children.Add(el);
            el.MouseUp += ellipse_MouseUp;

            TextBlock txt = new TextBlock();

            txt.Inlines.Add(new Run(item.Name)
            {
                FontWeight = FontWeights.Bold
            });
            txt.Foreground = new SolidColorBrush(Colors.White);
            txt.FontWeight = FontWeight.FromOpenTypeWeight(10);
            Canvas.SetLeft(txt, x - 5);
            Canvas.SetTop(txt, y - 8);
            canvas.Children.Add(txt);
        }
Ejemplo n.º 9
0
        internal static Table FromTableInfo(TableInfo info)
        {
            var control = new Table();

            Canvas.SetLeft(control, info.Location().X);
            Canvas.SetTop(control, info.Location().Y);
            control.TableFontFamily  = new FontFamily(info.FontFamily);
            control.TableFontSize    = Helper.ToEmSize(info.FontSize, MainWindow.DpiY);;
            control.TableFontStyle   = info.FontStyle == FontStyles.Italic.ToString() ? FontStyles.Italic : FontStyles.Normal;
            control.TableFontWeight  = FontWeight.FromOpenTypeWeight(info.FontOpenTypeWeight);
            control.TableFontStretch = FontStretch.FromOpenTypeStretch(info.FontOpenTypeStretch);
            control.TextFontFamily   = new FontFamily(info.TextFontFamily);
            control.TextFontSize     = Helper.ToEmSize(info.TextFontSize, MainWindow.DpiY);;
            control.TextFontStyle    = info.TextFontStyle == FontStyles.Italic.ToString() ? FontStyles.Italic : FontStyles.Normal;
            control.TextFontWeight   = FontWeight.FromOpenTypeWeight(info.TextFontOpenTypeWeight);
            control.TextFontStretch  = FontStretch.FromOpenTypeStretch(info.TextFontOpenTypeStretch);
            control.XlsColumn        = info.XlsColumn;

            control.Initialize(
                info.RowCount,
                info.RowHeight,
                new GridLength(info.Col0Width, GridUnitType.Pixel),
                new GridLength(info.Col1Width, GridUnitType.Pixel),
                new GridLength(info.Col2Width, GridUnitType.Pixel));

            return(control);
        }
Ejemplo n.º 10
0
        private void WriteShipmentDetailLine(string labelText, string textValue)
        {
            Grid          grid = new Grid();
            RowDefinition row  = new RowDefinition();

            grid.RowDefinitions.Add(row);
            ColumnDefinition column1 = new ColumnDefinition();

            column1.Width = new GridLength(96 * .95, GridUnitType.Pixel);
            grid.ColumnDefinitions.Add(column1);
            ColumnDefinition column2 = new ColumnDefinition();

            column2.Width = new GridLength(96 * 3, GridUnitType.Pixel);
            grid.ColumnDefinitions.Add(column2);

            TextBlock label = new TextBlock();

            label.Text                = labelText;
            label.Margin              = new Thickness(2, 2, 2, 2);
            label.FontWeight          = FontWeight.FromOpenTypeWeight(700);
            label.HorizontalAlignment = HorizontalAlignment.Right;
            Grid.SetColumn(label, 0);
            Grid.SetRow(label, 0);
            grid.Children.Add(label);

            TextBlock text = new TextBlock();

            text.Text   = textValue;
            text.Margin = new Thickness(2, 2, 2, 2);
            text.HorizontalAlignment = HorizontalAlignment.Left;
            Grid.SetColumn(text, 1);
            Grid.SetRow(text, 0);
            grid.Children.Add(text);
            this.m_ReportDocument.WriteRowContent(grid);
        }
        public void DrawText(ScreenPoint p, string text, OxyColor fill, string fontFamily, double fontSize,
                             double fontWeight, double rotate, HorizontalAlignment halign, VerticalTextAlign valign)
        {
            var tb = new TextBlock
            {
                Text       = text,
                Foreground = new SolidColorBrush(fill.ToColor())
            };

            if (fontFamily != null)
            {
                tb.FontFamily = new FontFamily(fontFamily);
            }
            if (fontSize > 0)
            {
                tb.FontSize = fontSize;
            }
            if (fontWeight > 0)
            {
                tb.FontWeight = FontWeight.FromOpenTypeWeight((int)fontWeight);
            }

            tb.Measure(new Size(1000, 1000));

            double dx = 0;

            if (halign == HorizontalAlignment.Center)
            {
                dx = -tb.DesiredSize.Width / 2;
            }
            if (halign == HorizontalAlignment.Right)
            {
                dx = -tb.DesiredSize.Width;
            }

            double dy = 0;

            if (valign == VerticalTextAlign.Middle)
            {
                dy = -tb.DesiredSize.Height / 2;
            }
            if (valign == VerticalTextAlign.Bottom)
            {
                dy = -tb.DesiredSize.Height;
            }

            var transform = new TransformGroup();

            transform.Children.Add(new TranslateTransform(dx, dy));
            if (rotate != 0)
            {
                transform.Children.Add(new RotateTransform(rotate));
            }
            transform.Children.Add(new TranslateTransform(p.X, p.Y));
            tb.RenderTransform = transform;

            tb.SetValue(RenderOptions.ClearTypeHintProperty, ClearTypeHint.Enabled);

            Add(tb);
        }
        private static Inline FormatInlineTextRun(AdaptiveTextRun textRun, AdaptiveRenderContext context)
        {
            Marked marked = new Marked();

            marked.Options.Renderer = new AdaptiveXamlMarkdownRenderer();
            marked.Options.Mangle   = false;
            marked.Options.Sanitize = true;

            // Handle Date/Time parsing
            string text = RendererUtilities.ApplyTextFunctions(textRun.Text, context.Lang);

            // Handle markdown
            string       xaml         = $"<Span  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"  xml:space=\"preserve\">{marked.Parse(text)}</Span>";
            StringReader stringReader = new StringReader(xaml);
            XmlReader    xmlReader    = XmlReader.Create(stringReader);

            Span uiInlineElement = XamlReader.Load(xmlReader) as Span;

            uiInlineElement.Style = context.GetStyle($"Adaptive.{textRun.Type}");

            uiInlineElement.FontFamily = new FontFamily(context.Config.GetFontFamily(textRun.FontStyle));
            uiInlineElement.FontWeight = FontWeight.FromOpenTypeWeight(context.Config.GetFontWeight(textRun.FontStyle, textRun.Weight));
            uiInlineElement.FontSize   = context.Config.GetFontSize(textRun.FontStyle, textRun.Size);

            uiInlineElement.SetColor(textRun.Color, textRun.IsSubtle, context);

            return(uiInlineElement);
        }
Ejemplo n.º 13
0
        private void InitBarChart(List <YuMiBaoZiModel> models)
        {
            ColumnSeries col = new ColumnSeries();

            col.XAxis           = (CategoryAxisBase)dataChart.Axes[0];
            col.YAxis           = (NumericYAxis)dataChart.Axes[1];
            col.ItemsSource     = models;
            col.Visibility      = Visibility.Visible;
            col.ValueMemberPath = "yData";
            if (YuMiBaoZiPage.type == 1)
            {
                DataTemplate            template = new DataTemplate();
                FrameworkElementFactory fef      = new FrameworkElementFactory(typeof(TextBlock));
                fef.SetBinding(TextBlock.TextProperty, new Binding()
                {
                    Path = new PropertyPath("Item.yData")
                });
                fef.SetValue(Label.MarginProperty, new Thickness(0, 0, 0, 15));
                fef.SetValue(Label.ForegroundProperty, new SolidColorBrush(Colors.Green));
                fef.SetValue(Label.FontSizeProperty, Convert.ToDouble(14));
                fef.SetValue(Label.FontWeightProperty, FontWeight.FromOpenTypeWeight(700));
                template.VisualTree = fef;
                col.MarkerTemplate  = template;
            }
            col.ToolTip = InitToolTip(models, col);
            //if (dataChart.Series.Count > 0)
            //{
            //    dataChart.Series.Clear();
            //}
            dataChart.Series.Add(col);
        }
        /// <summary>
        /// Creates the font preview.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateFontPreview(PropertyItem property)
        {
            var c = new TextBox
            {
                Background    = Brushes.Transparent,
                BorderBrush   = null,
                AcceptsReturn = true,
                TextWrapping  = TextWrapping.Wrap,
                FontWeight    = FontWeight.FromOpenTypeWeight(property.FontWeight),
                FontSize      = property.FontSize
            };

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

            return(c);
        }
Ejemplo n.º 15
0
        public static void ConfigureStyle(this TextElement textElement, FigmaTypeStyle style)
        {
            string family = style.fontFamily;

            if (family == "SF UI Text")
            {
                family = ".SF NS Text";
            }
            else if (family == "SF Mono")
            {
                family = ".SF NS Display";
            }
            else
            {
                Console.WriteLine("FONT: {0} - {1}", family, style.fontPostScriptName);
            }
            textElement.FontFamily = new FontFamily(family);

            if (style.fontSize > 0)
            {
                textElement.FontSize = style.fontSize;// -3 ;
            }
            textElement.FontWeight = FontWeight.FromOpenTypeWeight(style.fontWeight);
            if (style.letterSpacing != default)
            {
                textElement.FontStretch = FontStretch.FromOpenTypeStretch(style.letterSpacing > 9 ? 9 : (int)style.letterSpacing);
            }

            var fill = style.fills.FirstOrDefault();

            if (fill != null)
            {
                textElement.Foreground = fill.color.ToColor();
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 显伤脚本
        /// </summary>
        /// <param name="monster">对应的怪物</param>
        public void ShowDamage(int left, int top)
        {
            if (textBlock != null)
            {
                HideDamage();
            }
            Run run = new Run()
            {
                Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 150, 0)),
                FontWeight = FontWeight.FromOpenTypeWeight(999)
            };
            int damage = CalculationUtility.CalculateDamage(this);

            // -1代表不可战斗显示问号
            if (damage == -1)
            {
                run.Text = "???";
            }
            else
            {
                run.Text = damage + "";
            }
            textBlock = new TextBlock(run)
            {
                Height   = 20,
                FontSize = 13
            };
            Canvas.SetLeft(textBlock, left);
            Canvas.SetTop(textBlock, top);
            Panel.SetZIndex(textBlock, 9);
            FloorFactory.canvas.Children.Add(textBlock);
        }
Ejemplo n.º 17
0
        private void InitSpline(List <DaoGuZhiLiangTeXingModel> models, MarkerType type)
        {
            SplineSeries spline = new SplineSeries();

            spline.XAxis = (CategoryAxisBase)dataChart.Axes[0];

            spline.YAxis = (NumericYAxis)dataChart.Axes[1];

            spline.ItemsSource     = models;
            spline.Visibility      = Visibility.Visible;
            spline.ValueMemberPath = "yData";
            spline.MarkerType      = type;
            spline.Thickness       = 3;
            if (DaoGuTeXingCanShuPage.type == 3)
            {
                DataTemplate            template = new DataTemplate();
                FrameworkElementFactory fef      = new FrameworkElementFactory(typeof(Label));
                fef.SetBinding(Label.ContentProperty, new Binding()
                {
                    Path = new PropertyPath("Item.yData"), Converter = new StringFormatConverter(), ConverterParameter = "0.00"
                });
                //fef.SetValue(Label.MarginProperty, new Thickness(0, 0, 0, 15));
                fef.SetValue(Label.ForegroundProperty, new SolidColorBrush(Colors.Green));
                fef.SetValue(Label.FontSizeProperty, Convert.ToDouble(14));
                fef.SetValue(Label.FontWeightProperty, FontWeight.FromOpenTypeWeight(700));
                template.VisualTree   = fef;
                spline.MarkerTemplate = template;
            }
            spline.ToolTip = InitToolTip(models, spline);

            dataChart.Series.Add(spline);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates the font family control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateFontFamilyControl(PropertyItem property)
        {
            var c = new ComboBox {
                ItemsSource = GetFontFamilies()
            };

            if (property.PreviewFonts)
            {
                var dt = new DataTemplate {
                    DataType = typeof(ComboBox)
                };
                var factory = new FrameworkElementFactory(typeof(TextBlock));
                factory.SetValue(TextBlock.FontSizeProperty, property.FontSize);
                factory.SetValue(TextBlock.FontWeightProperty, FontWeight.FromOpenTypeWeight(property.FontWeight));
                factory.SetBinding(TextBlock.TextProperty, new Binding());
                factory.SetBinding(TextBlock.FontFamilyProperty, new Binding {
                    Converter = FontFamilyConverter
                });
                dt.VisualTree  = factory;
                c.ItemTemplate = dt;
            }

            var binding = property.CreateBinding();

            if (property.ActualPropertyType == typeof(string))
            {
                binding.Converter = FontFamilyConverter;
            }

            c.SetBinding(Selector.SelectedValueProperty, binding);
            return(c);
        }
Ejemplo n.º 19
0
        private void LoadState()
        {
            Log.Information("Loading State");
            var regAccessor             = new RegistryAccessor();
            var fontFamConverter        = new Media.FontFamilyConverter();
            var fontFamily              = regAccessor.Read("FONTFAMILY");
            var fontWeightToBeConverted = regAccessor.Read("FONTWEIGHT");
            var fontSize  = regAccessor.Read("FONTSIZE");
            var fontStyle = regAccessor.Read("FONTSYLE");

            if (fontFamily != null)
            {
                _formatModel.Family = fontFamConverter.ConvertFromString(fontFamily) as Media.FontFamily;
            }

            if (fontWeightToBeConverted != null)
            {
                _formatModel.Weight = FontWeight.FromOpenTypeWeight(Convert.ToInt32(regAccessor.Read("FONTWEIGHT")));
            }

            if (fontSize != null && fontSize != "0")
            {
                _formatModel.Size = Convert.ToDouble(fontSize);
            }

            if (fontStyle != null)
            {
                _formatModel.Style = ConvertFontSytleFromString(fontStyle);
            }
        }
Ejemplo n.º 20
0
        public static void OnTextChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs eventArgs)
        {
            var itemMod = (ItemMod)dependencyObject;

            var text             = itemMod.Modifier.Text;
            var matches          = Highlight.Matches(text);
            var highlightMatches = new Dictionary <int, string>();

            for (var i = 0; i < matches.Count; i++)
            {
                var info = matches[i];

                highlightMatches.Add(info.Index, info.Value);
            }

            itemMod.TextBlock.Inlines.Clear();
            var index = 0;

            while (text.Length > 0)
            {
                if (highlightMatches.ContainsKey(index))
                {
                    itemMod.TextBlock.Inlines.Add(new Run(highlightMatches[index])
                    {
                        Foreground = Brushes.LightBlue,
                        FontWeight = FontWeight.FromOpenTypeWeight(700),
                    });
                    text   = text[highlightMatches[index].Length..];
Ejemplo n.º 21
0
        public MainWindow()
        {
            InitializeComponent();
            CompilerUtils.DeleteFilesByWildcards("Test*.exe");

            ViewModel.Window = this;


            TextEditor.Text = ViewModel.SourceCode;
            TextEditor.TextArea.TextEntering       += textEditor_TextArea_TextEntering;
            TextEditor.TextArea.TextEntered        += textEditor_TextArea_TextEntered;
            TextEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(TextEditor.Options);
            foldingStrategy = new BraceFoldingStrategy();

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();

            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick    += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();


            if (foldingManager == null)
            {
                foldingManager = FoldingManager.Install(TextEditor.TextArea);
            }
            foldingStrategy.UpdateFoldings(foldingManager, TextEditor.Document);

            // Dynamic syntax highlighting for Intermediate Representation
            var rules = IL.SyntaxHighlighting.MainRuleSet.Rules;

            var highlightingRule = new HighlightingRule();

            highlightingRule.Color = new HighlightingColor()
            {
                Foreground = new CustomizedBrush(Color.Green),
                FontWeight = FontWeight.FromOpenTypeWeight(130)
            };

            var wordList = ILOperatorKeywords;
            var regex    = String.Format(@"\b({0})\b", String.Join("|", wordList));

            highlightingRule.Regex = new Regex(regex);

            rules.Add(highlightingRule);

            highlightingRule       = new HighlightingRule();
            highlightingRule.Color = new HighlightingColor()
            {
                Foreground = new CustomizedBrush(Color.Red)
            };

            wordList = ILKeywords;
            regex    = String.Format(@"\b({0})\b", String.Join("|", wordList));
            highlightingRule.Regex = new Regex(regex);

            rules.Add(highlightingRule);


            TextEditor.Text = VisualCompilerConstants.InitialCode;
        }
Ejemplo n.º 22
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            string content = _button.Content as string;

            if (string.IsNullOrEmpty(content))
            {
                Size elementSize = AdornedElement.RenderSize;
                Rect rect        = new Rect(0, 0, elementSize.Width, elementSize.Height);

                Typeface typeFace = _button.FontFamily.GetTypefaces().FirstOrDefault();
                if (typeFace != null)
                {
#pragma warning disable 0618
                    // DpiScale dpiScale = VisualTreeHelper.GetDpi(this);
                    // Use it with framework 4.71!
                    FormattedText formattedText = new FormattedText("Select ifc file...", System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                                                                    typeFace, _button.FontSize, Brushes.Red /*, dpiScale.PixelsPerDip*/);
#pragma warning restore 0618

                    double margin = 5.0;

                    formattedText.MaxTextWidth  = elementSize.Width - 2 * margin;
                    formattedText.Trimming      = TextTrimming.WordEllipsis;
                    formattedText.TextAlignment = TextAlignment.Center;
                    formattedText.SetFontWeight(FontWeight.FromOpenTypeWeight(400));

                    drawingContext.DrawText(formattedText, new Point(margin, (elementSize.Height - formattedText.Height) / 2));
                }
            }
        }
        private FontKey FontKeyFromStyle(MyScript.IInk.Graphics.Style style)
        {
            var fontFamily  = new FontFamily(toPlatformFontFamily(style.FontFamily, style.FontStyle));
            var fontSize    = mm2px(style.FontSize, dpiY);
            var fontWeight  = FontWeight.FromOpenTypeWeight(style.FontWeight);
            var fontStretch = FontStretches.Normal;
            var fontStyle   = FontStyles.Normal;

            if (style.FontStyle.Equals("italic"))
            {
                fontStyle = FontStyles.Italic;
            }
            else if (style.FontStyle.Equals("oblique"))
            {
                fontStyle = FontStyles.Oblique;
            }

            if (style.FontWeight >= 700)
            {
                fontWeight = FontWeights.Bold;
            }
            else if (style.FontWeight >= 400)
            {
                fontWeight = FontWeights.Normal;
            }
            else
            {
                fontWeight = FontWeights.Light;
            }

            return(new FontKey(fontFamily, fontSize, fontWeight, fontStretch, fontStyle));
        }
Ejemplo n.º 24
0
        //On Country button click
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //Write Category Label only once - dont waste resources
            if (leftLabel.Content.Equals(""))
            {
                showCategories();
            }

            //Use query to get desired country based, on button content
            Button     btnClicked  = (Button)sender;
            JsonObject countryJSON = GetJSON.GetData(string.Join(",", CountryJsonLink.abbreviationMap.Where(n => n.Key.Equals(btnClicked.Content)).Select(n => n.Value).ToArray()));

            //Write all the data from API
            rightLabel.FontWeight = FontWeight.FromOpenTypeWeight(150);
            rightLabel.Content    = countryJSON.countrydata[0].info.title + "\n" +
                                    countryJSON.countrydata[0].total_new_cases_today + "\n" +
                                    countryJSON.countrydata[0].total_new_deaths_today + "\n" +
                                    countryJSON.countrydata[0].total_cases + "\n" +
                                    countryJSON.countrydata[0].total_deaths + "\n" +
                                    countryJSON.countrydata[0].total_unresolved + "\n" +
                                    countryJSON.countrydata[0].total_recovered + "\n" +
                                    countryJSON.countrydata[0].total_active_cases + "\n" +
                                    countryJSON.countrydata[0].total_serious_cases + "\n" +
                                    countryJSON.countrydata[0].total_danger_rank + "\n";
        }
Ejemplo n.º 25
0
        public static Label MakeSimpleLabel(string text, Rect bounds, Brush brush)
        {
            Label label = new Label {
                Content = text
            };

            if (text.ToUpper().Contains("?"))
            {
                label.Background = new SolidColorBrush(Colors.Black);
            }

            if (bounds.Width != 0)
            {
                label.SetValue(Canvas.LeftProperty, bounds.Left);
                label.SetValue(Canvas.TopProperty, bounds.Top);
                label.Width  = bounds.Width;
                label.Height = bounds.Height;
            }

            label.Foreground          = brush;
            label.FontFamily          = new FontFamily("Arial");
            label.FontWeight          = FontWeight.FromOpenTypeWeight(600);
            label.FontStyle           = FontStyles.Normal;
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment   = VerticalAlignment.Center;
            return(label);
        }
Ejemplo n.º 26
0
        private void GitCommitDialog_Loaded(object sender, RoutedEventArgs e)
        {
            string defaultText = null;

            if (AppModel.Configuration.Git.GitCommitBehavior == GitCommitBehaviors.CommitAndPush)
            {
                ButtonCommitAndPush.IsDefault  = true;
                ButtonCommitAndPush.FontWeight = FontWeight.FromOpenTypeWeight(600);
                ButtonCommit.Opacity           = 0.6;
                defaultText = "commit and push";
            }
            else
            {
                ButtonCommit.IsDefault      = true;
                ButtonCommit.FontWeight     = FontWeight.FromOpenTypeWeight(600);
                ButtonCommitAndPush.Opacity = 0.6;
                defaultText = "commit";
            }

            CommitModel.GetRepositoryChanges();

            DataContext = CommitModel;

            ShowStatus($"Press Ctrl-Enter to quickly {defaultText}.", 8000);
            TextCommitMessage.Focus();
        }
Ejemplo n.º 27
0
        private FlowDocument GenerateStatusMessagesFlowDocument()
        {
            FlowDocument doc = new FlowDocument();

            foreach (XMLProcessor xmlProcessor in ViewModel.XMLProcessors.Where(x => x.StatusMessages.Count > 0))
            {
                Paragraph title = new Paragraph
                {
                    FontSize = 20,
                    Margin   = new Thickness(0, 10, 0, 5)
                };

                title.Inlines.Add(new Run(xmlProcessor.SongTitle));

                // Add arrangement type unless it is "N/A"
                if (!xmlProcessor.ArrangementType.StartsWith("N"))
                {
                    title.Inlines.Add(new Run($" ({xmlProcessor.ArrangementType})"));
                }

                Run xmlFile = new Run($" [{xmlProcessor.XMLFileName}]")
                {
                    FontSize   = 13,
                    Foreground = Brushes.Gray
                };
                title.Inlines.Add(xmlFile);
                doc.Blocks.Add(title);

                foreach (var messageType in (MessageType[])Enum.GetValues(typeof(MessageType)))
                {
                    var messages = from message in xmlProcessor.StatusMessages
                                   where message.Type == messageType
                                   select message.Message;

                    if (messages.Any())
                    {
                        Paragraph messageListTitle = new Paragraph(new Run($"{messageType}s: "))
                        {
                            FontSize   = 18,
                            FontWeight = FontWeight.FromOpenTypeWeight(600),
                            Margin     = new Thickness(10, 0, 0, 0)
                        };
                        doc.Blocks.Add(messageListTitle);

                        List messageList = new List
                        {
                            Margin = new Thickness(15, 5, 0, 15)
                        };

                        foreach (string message in messages)
                        {
                            messageList.ListItems.Add(new ListItem(new Paragraph(new Run(message))));
                        }
                        doc.Blocks.Add(messageList);
                    }
                }
            }
            return(doc);
        }
Ejemplo n.º 28
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if ((bool)value)
     {
         return(FontWeight.FromOpenTypeWeight(700));
     }
     return(FontWeight.FromOpenTypeWeight(400));
 }
Ejemplo n.º 29
0
        private async void UpdateTimer_Tick(object sender, EventArgs e)
        {
            var day  = (utcNow.DayOfWeek == 0) ? 7 : (int)utcNow.DayOfWeek;
            var hour = utcNow.Hour;

            if (minified)
            {
                ShowDayColumn(day);
            }
            if (utcNow.Minute == 50)
            {
                var nextEvent = timetableData.Timetable.Where(t => t.Day == day && t.Hour == hour + 1).FirstOrDefault();
                if (nextEvent != null)
                {
                    new ToastNotification(nextEvent.Event?.Name ?? nextEvent.Name).Show();
                }
            }

            try
            {
                var json = await client.GetStringAsync("https://thishabbo.com/api/events/timetable");

                ClearEvents();
                timetableData = JsonConvert.DeserializeObject <TimetableData>(json);
            }
            catch (HttpRequestException hEx)
            {
                // HTTP exception or timeout, TH probably down for a moment
                // TODO: handle exception maybe?
                _ = hEx; // discard to shut up IDE0059
            }

            foreach (var evt in timetableData.Timetable)
            {
                var eventLabel = new Label
                {
                    Content = evt.Event?.Name ?? evt.Name,
                    ToolTip = new ToolTip()
                    {
                        Content = $"{evt.Event?.Name ?? evt.Name}\r\n{evt.User.Habbo}\r\nTH: {evt.User.Nickname}"
                    },
                    HorizontalAlignment = HorizontalAlignment.Center,
                    ForceCursor         = true,

                    Foreground = new SolidColorBrush(Color.FromRgb(200, 200, 200))
                };

                if (evt.Day == day && evt.Hour == hour)
                {
                    eventLabel.FontWeight = FontWeight.FromOpenTypeWeight(600);
                    eventLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                }

                Grid.SetColumn(eventLabel, evt.Day);
                Grid.SetRow(eventLabel, evt.Hour + 1);
                grdTimetable.Children.Add(eventLabel);
            }
        }
Ejemplo n.º 30
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is Boolean && (bool)value)
            {
                return(FontWeight.FromOpenTypeWeight(600));
            }

            return(FontWeight.FromOpenTypeWeight(400));
        }