コード例 #1
0
ファイル: CSRepl.xaml.cs プロジェクト: xiaoxiongnpu/CShell
        public CSRepl()
        {
            InitializeComponent();

            textEditor            = new CSReplTextEditor();
            textEditor.FontFamily = new FontFamily("Consolas");
            var convertFrom = new FontSizeConverter().ConvertFrom("10pt");

            if (convertFrom != null)
            {
                textEditor.FontSize = (double)convertFrom;
            }
            textEditor.TextArea.PreviewKeyDown += TextAreaOnPreviewKeyDown;
            textEditor.IsEnabled          = false;
            textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
            textEditor.FileName           = "repl.csx";
            textEditor.Repl = this;
            this.Content    = textEditor;

            commandHistory = new CommandHistory();

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

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

            //clears the console and prints the headers
            // when clearing the initial transormers are removed too but we want to keep them
            initialTransformers = textEditor.TextArea.TextView.LineTransformers.ToArray();
            Clear();
        }
コード例 #2
0
        public CaseReportAmendment()
        {
            m_FontSizeConverter = new FontSizeConverter();
            m_Rule = new YellowstonePathology.Business.Rules.Rule();

            this.m_Rule.ActionList.Add(this.SetAmendments);
        }
コード例 #3
0
        public PaintingWithImagesExample()
        {
            Background = Brushes.White;
            StackPanel mainPanel = new StackPanel();

            mainPanel.Margin = new Thickness(20.0);

            // Create a button.
            Button berriesButton = new Button();

            berriesButton.Foreground = Brushes.White;
            berriesButton.FontWeight = FontWeights.Bold;
            FontSizeConverter sizeConverter = new FontSizeConverter();

            berriesButton.FontSize            = (Double)sizeConverter.ConvertFromString("16pt");
            berriesButton.FontFamily          = new FontFamily("Verdana");
            berriesButton.Content             = "Berries";
            berriesButton.Padding             = new Thickness(20.0);
            berriesButton.HorizontalAlignment = HorizontalAlignment.Left;

            // Create an ImageBrush.
            ImageBrush berriesBrush = new ImageBrush();

            berriesBrush.ImageSource =
                new BitmapImage(
                    new Uri(@"sampleImages\berries.jpg", UriKind.Relative)
                    );

            // Use the brush to paint the button's background.
            berriesButton.Background = berriesBrush;

            mainPanel.Children.Add(berriesButton);
            this.Content = mainPanel;
        }
コード例 #4
0
        private bool GuardarDatos()
        {
            object              tamano      = 0;
            object              familia     = null;
            Style               estiloNuevo = new Style();
            FontSizeConverter   convertidor = new FontSizeConverter();
            FontFamilyConverter conFami     = new FontFamilyConverter();

            try
            {
                tamano  = txtTamano.Text.ToString();
                familia = listFonts.SelectedItem.ToString();
                Setter Size   = new Setter(FontSizeProperty, convertidor.ConvertFrom(tamano));
                Setter Family = new Setter(FontFamilyProperty, conFami.ConvertFrom(familia));
                Setter color  = new Setter(ForegroundProperty, new SolidColorBrush(Color.FromRgb(byte.Parse(sldRojo.Value.ToString()), byte.Parse(sldVerde.Value.ToString()), byte.Parse(sldAzul.Value.ToString()))));
                estiloNuevo.Setters.Add(Size);
                estiloNuevo.Setters.Add(Family);
                estiloNuevo.Setters.Add(color);
                App.Current.Resources["txtEnter"] = estiloNuevo;
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show("ERROR: " + e.Message);
                return(false);
            }
        }
コード例 #5
0
        public ConfigurationViewModel()
        {
            this.keyboards = new List <string>()
            {
                "Default",
                "Plain",
                "Chat",
                "Email",
                "Numeric",
                "Telephone",
                "Text",
                "Url"
            };

            this.textColors = new List <string>()
            {
                "Gray",
                "Orange",
                "Blue",
                "Pink"
            };

            this.fontSizes = new List <NamedSize>()
            {
                NamedSize.Default,
                NamedSize.Large,
                NamedSize.Small
            };

            this.keyboardTypeConverter = new KeyboardTypeConverter();
            this.colorTypeConverter    = new ColorTypeConverter();
            this.fontSizeConverter     = new FontSizeConverter();
        }
コード例 #6
0
        public void FontSizeConverterTests()
        {
            var converter = new FontSizeConverter();

            Assert.AreEqual(12, converter.ConvertFromInvariantString("12"));
            Assert.AreEqual(10.7, converter.ConvertFromInvariantString("10.7"));
        }
コード例 #7
0
        private void changeSize(object sender, SelectionChangedEventArgs args)
        {
            ListBoxItem       li = ((sender as ListBox).SelectedItem as ListBoxItem);
            FontSizeConverter myFontSizeConverter = new FontSizeConverter();

            text1.FontSize = (Double)myFontSizeConverter.ConvertFromString(li.Content.ToString());
        }
コード例 #8
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var n         = (int)value;
            var converter = new FontSizeConverter();

            return(converter.ConvertFromString($"{n}pt"));
        }
コード例 #9
0
ファイル: App.cs プロジェクト: populvuh/DailyPrayer
        public static void GetDeviceStats()
        {
            // Get Metrics
            //var metrics = DeviceDisplay.MainDisplayInfo.ScreenMetrics;

            // Orientation (Landscape, Portrait, Square, Unknown)
            var orientation = DeviceDisplay.MainDisplayInfo.Orientation;

            if (orientation == DisplayOrientation.Landscape)
            {
                FontSizeConverter fontSizeConverter = new FontSizeConverter();
                Application.Current.Properties["HeadingSize"] = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                Application.Current.Properties["ContactSize"] = Device.GetNamedSize(NamedSize.Small, typeof(Label));
            }
            else
            {
                var rotation = DeviceDisplay.MainDisplayInfo.Rotation;                    // Rotation (0, 90, 180, 270)
                var width    = DeviceDisplay.MainDisplayInfo.Width;                       // Width (in pixels)
                var height   = DeviceDisplay.MainDisplayInfo.Height;                      // Height (in pixels)
                var density  = DeviceDisplay.MainDisplayInfo.Density;                     // Screen density

                // density == 3/ width<1000
                SmallScreen = (width < 1000);
                Application.Current.Properties["HeadingSize"] = Device.GetNamedSize(SmallScreen ? NamedSize.Small : NamedSize.Medium, typeof(Label));
                Application.Current.Properties["ContactSize"] = Device.GetNamedSize(NamedSize.Small, typeof(Label));
            }
            Application.Current.SavePropertiesAsync();

            System.Diagnostics.Debug.WriteLine($"App.GetDeviceStats(): width={DeviceDisplay.MainDisplayInfo.Width}, height={DeviceDisplay.MainDisplayInfo.Height}, density={DeviceDisplay.MainDisplayInfo.Density}");
        }
コード例 #10
0
        private static Inline BuildFont(ElementToken token, Hint hint)
        {
            var span = new Span();

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

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

            if (token.Attributes.TryGetValue("color", out var color))
            {
                var bc = new BrushConverter();
                var br = (Brush)bc.ConvertFromString(color);
                span.Foreground = br;
            }

            return(span.Fill(token, hint));
        }
コード例 #11
0
        public ObservableCollection <ICalendarEvent> HasEventsOnDate(DateTime?date)
        {
            if (date == null)
            {
                return(null);
            }

            string            ffamily = Device.RuntimePlatform == Device.iOS ? "FontAwesome5Free-Solid" :  "FontAwesome5Solid.otf#Regular";
            FontSizeConverter fsc     = new FontSizeConverter();
            //double fsize = (double)fsc.ConvertFromInvariantString("Micro");
            double fsize = 6;

            List <ICalendarEvent> allEvents = new List <ICalendarEvent>()
            {
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.Aqua, FontSize = fsize
                },
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.Bisque, FontSize = fsize
                },
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.Brown, FontSize = fsize
                },
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.Teal, FontSize = fsize
                },
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.Salmon, FontSize = fsize
                },
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.SeaGreen, FontSize = fsize
                },
                new CalendarEvent()
                {
                    Symbol = FontAwesome.Stop, FontFamily = ffamily, Color = Xamarin.Forms.Color.Fuchsia, FontSize = fsize
                }
            };

            Random random = new Random();
            int    num    = random.Next(0, allEvents.Count);
            ObservableCollection <ICalendarEvent> events = new ObservableCollection <ICalendarEvent>();
            int            maxEventsPerDay = 4;
            int            eventsToDisplay = num > maxEventsPerDay ? maxEventsPerDay : num;
            ICalendarEvent currentEvent    = null;

            for (int n = 0; n < eventsToDisplay; n++)
            {
                int ndx = random.Next(0, allEvents.Count);
                currentEvent = allEvents[ndx];
                events.Add(currentEvent);
            }
            return(events);
        }
コード例 #12
0
        public static TextRange Size(this TextRange range, string size)
        {
            FontSizeConverter fc = new FontSizeConverter();
            var fontSize         = fc.ConvertFromString(size);

            range.ApplyPropertyValue(TextElement.FontSizeProperty, fontSize);
            return(range);
        }
コード例 #13
0
        private void Button17_Click(object sender, RoutedEventArgs e)
        {
            //Will change visualBrush of Rectangle6 to skew Text "Hello World"
            Rectangle6.Width  = 100;
            Rectangle6.Height = 110;

            VisualBrush brush17 = new VisualBrush();
            StackPanel  txt     = new StackPanel();

            txt.Background = Brushes.White;

            TextBlock         text = new TextBlock();
            FontSizeConverter size = new FontSizeConverter();

            text.FontSize = (double)size.ConvertFrom("10pt");
            text.Text     = "Hello, World!";
            txt.Children.Add(text);

            TextBlock         text1 = new TextBlock();
            FontSizeConverter size2 = new FontSizeConverter();

            text1.FontSize = (double)size2.ConvertFrom("10pt");
            text1.Text     = "Hello, World!";
            txt.Children.Add(text1);

            TextBlock         text2 = new TextBlock();
            FontSizeConverter size3 = new FontSizeConverter();

            text2.FontSize = (double)size3.ConvertFrom("10pt");
            text2.Text     = "Hello, World!";
            txt.Children.Add(text2);

            TextBlock         text3 = new TextBlock();
            FontSizeConverter size4 = new FontSizeConverter();

            text3.FontSize = (double)size4.ConvertFrom("10pt");
            text3.Text     = "Hello, World!";
            txt.Children.Add(text3);

            TextBlock         text4 = new TextBlock();
            FontSizeConverter size5 = new FontSizeConverter();

            text4.FontSize = (double)size5.ConvertFrom("2pt");
            text4.Text     = "Hello, World!";
            txt.Children.Add(text4);

            RotateTransform rotate = new RotateTransform();

            rotate.CenterX = 0.5;
            rotate.CenterY = 0.5;
            rotate.Angle   = -45;

            brush17.Visual            = txt;
            brush17.RelativeTransform = rotate;

            Rectangle6.Fill = brush17;
        }
コード例 #14
0
        private static void SetFontSize(BindableObject bindingObject, object newValue)
        {
            FontSizeConverter myFontSizeConverter = new FontSizeConverter();

            var fontSize = (double)myFontSizeConverter.ConvertFromInvariantString(newValue.ToString());

            ((ParameterLabelView)bindingObject).ContentControl.FontSize = fontSize;
            ((ParameterLabelView)bindingObject).LabelControl.FontSize   = fontSize;
            ((ParameterLabelView)bindingObject).UnitControl.FontSize    = fontSize;
        }
コード例 #15
0
ファイル: ESIPicker.xaml.cs プロジェクト: bardasoft/UsefulUI
        private static void OnPickerLabelFontSizeChanged(BindableObject bindable, object oldValue, object newValue)
        {
            ESIPicker thisctrl = (ESIPicker)bindable;

            if (thisctrl != null && oldValue != newValue)
            {
                FontSizeConverter fsc = new FontSizeConverter();
                thisctrl.pickerLabel.FontSize = (double)fsc.ConvertFromInvariantString((string)newValue);
            }
        }
コード例 #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var convertFrom = new FontSizeConverter().ConvertFrom(value.ToString());

            if (convertFrom != null)
            {
                return((double)convertFrom);
            }
            return(1);
        }
コード例 #17
0
        private RectSet GetAdjustedRects(bool returnIfAnchored)
        {
            var parentSize     = Size;
            var parentLocation = Location;

            var childSize     = Editor.Control.Size;
            var childLocation = new Point(CalculatedPadding.Left, CalculatedPadding.Top);

            // --- Anchored

            // If we're anchored to two opposite sides of the form, don't adjust the size because
            // we'll lose our anchored size by resetting to the requested width.
            if (returnIfAnchored &&
                (Anchor & (AnchorStyles.Top | AnchorStyles.Bottom)) == (AnchorStyles.Top | AnchorStyles.Bottom))
            {
                return(new RectSet(new Rectangle(parentLocation, parentSize), new Rectangle(childLocation, childSize)));
            }

            var lrPad = CalculatedPadding.Left + CalculatedPadding.Right;
            var tbPad = CalculatedPadding.Top + CalculatedPadding.Bottom;

            // --- Multiline

            if (Multiline)
            {
                childSize = new Size(parentSize.Width - lrPad,
                                     parentSize.Height - tbPad);

                return(new RectSet(new Rectangle(parentLocation, parentSize), new Rectangle(childLocation, childSize)));
            }

            // --- Singleline

            var fontSize = FontSizeConverter.GetWinFormsFontSize(Editor.FontSize);
            var font     = new Font(Font.FontFamily, (float)fontSize, Font.Style, GraphicsUnit.Point, Font.GdiCharSet, Font.GdiVerticalFont);

            Size measuredTextSize;

            using (var g = CreateGraphics())
            {
                var size = g.MeasureString("MQ", font);
                measuredTextSize = new Size((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height));
            }

            var parentWidth  = parentSize.Width;
            var parentHeight = (int)Math.Ceiling((double)measuredTextSize.Height);

            parentSize = new Size(parentWidth,
                                  parentHeight + tbPad);

            childSize = new Size(parentWidth + Editor.VerticalScrollBarWidthAllowance - lrPad,
                                 parentHeight + Editor.HorizontalScrollBarHeightAllowance);

            return(new RectSet(new Rectangle(parentLocation, parentSize), new Rectangle(childLocation, childSize)));
        }
コード例 #18
0
        private static void OnDayOfWeekFontSizeChanged(BindableObject bindable, object oldValue, object newValue)
        {
            DayGridHeader thisctrl = (DayGridHeader)bindable;

            if (thisctrl != null && oldValue != newValue)
            {
                FontSizeConverter fsc   = new FontSizeConverter();
                double            fsize = (double)fsc.ConvertFromInvariantString((string)newValue);
                thisctrl.header.FontSize = fsize;
            }
        }
コード例 #19
0
        private static void OnCalendarDayFontSizeChanged(BindableObject bindable, object oldValue, object newValue)
        {
            CalendarDayView thisctrl = (CalendarDayView)bindable;

            if (thisctrl != null && oldValue != newValue)
            {
                FontSizeConverter fsc   = new FontSizeConverter();
                double            fsize = (double)fsc.ConvertFromInvariantString((string)newValue);
                thisctrl.calendarDay.FontSize = fsize;
            }
        }
コード例 #20
0
        private static void OnFontSizeChanged(BindableObject bindable, object oldValue, object newValue)
        {
            IteratorControl thisctrl = (IteratorControl)bindable;

            if (thisctrl != null && oldValue != newValue)
            {
                FontSizeConverter fsc   = new FontSizeConverter();
                double            fsize = (double)fsc.ConvertFromInvariantString((string)newValue);
                thisctrl.previous.FontSize     = fsize;
                thisctrl.next.FontSize         = fsize;
                thisctrl.iteratorName.FontSize = fsize;
            }
        }
コード例 #21
0
ファイル: BrushTypesExample.cs プロジェクト: zhimaqiao51/docs
        private void createVisualBrushExample(Panel examplePanel)
        {
            // <SnippetGraphicsMMVisualBrushExampleInline>
            Rectangle exampleRectangle = new Rectangle();

            exampleRectangle.Width  = 75;
            exampleRectangle.Height = 75;

            // Create a VisualBrush and use it
            // to paint the rectangle.
            VisualBrush myBrush = new VisualBrush();

            //
            // Create the brush's contents.
            //
            StackPanel aPanel = new StackPanel();

            // Create a DrawingBrush and use it to
            // paint the panel.
            DrawingBrush  myDrawingBrushBrush = new DrawingBrush();
            GeometryGroup aGeometryGroup      = new GeometryGroup();

            aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
            aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));
            RadialGradientBrush checkerBrush = new RadialGradientBrush();

            checkerBrush.GradientStops.Add(new GradientStop(Colors.MediumBlue, 0.0));
            checkerBrush.GradientStops.Add(new GradientStop(Colors.White, 1.0));
            GeometryDrawing checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);

            myDrawingBrushBrush.Drawing = checkers;
            aPanel.Background           = myDrawingBrushBrush;

            // Create some text.
            TextBlock someText = new TextBlock();

            someText.Text = "Hello, World";
            FontSizeConverter fSizeConverter = new FontSizeConverter();

            someText.FontSize = (double)fSizeConverter.ConvertFromString("10pt");
            someText.Margin   = new Thickness(10);

            aPanel.Children.Add(someText);

            myBrush.Visual        = aPanel;
            exampleRectangle.Fill = myBrush;

            // </SnippetGraphicsMMVisualBrushExampleInline>

            examplePanel.Children.Add(exampleRectangle);
        }
コード例 #22
0
        // <SnippetGraphicsMMVisualBrushAsRectangleBackgroundExample>
        private void visualBrushAsRectangleFillExample(Panel mainPanel)
        {
            // <SnippetGraphicsMMVisualBrushAsRectangleBackgroundExample1>
            VisualBrush myVisualBrush = new VisualBrush();

            // Create the visual brush's contents.
            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Background = Brushes.White;

            Rectangle redRectangle = new Rectangle();

            redRectangle.Width  = 25;
            redRectangle.Height = 25;
            redRectangle.Fill   = Brushes.Red;
            redRectangle.Margin = new Thickness(2);
            myStackPanel.Children.Add(redRectangle);

            TextBlock         someText            = new TextBlock();
            FontSizeConverter myFontSizeConverter = new FontSizeConverter();

            someText.FontSize = (double)myFontSizeConverter.ConvertFrom("10pt");
            someText.Text     = "Hello, World!";
            someText.Margin   = new Thickness(2);
            myStackPanel.Children.Add(someText);

            Button aButton = new Button();

            aButton.Content = "A Button";
            aButton.Margin  = new Thickness(2);
            myStackPanel.Children.Add(aButton);

            // Use myStackPanel as myVisualBrush's content.
            myVisualBrush.Visual = myStackPanel;

            // Create a rectangle to paint.
            Rectangle myRectangle = new Rectangle();

            myRectangle.Width  = 150;
            myRectangle.Height = 150;
            myRectangle.Stroke = Brushes.Black;
            myRectangle.Margin = new Thickness(5, 0, 5, 0);

            // Use myVisualBrush to paint myRectangle.
            myRectangle.Fill = myVisualBrush;

            // </SnippetGraphicsMMVisualBrushAsRectangleBackgroundExample1>

            mainPanel.Children.Add(myRectangle);
        }
コード例 #23
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string str = value as string;

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            FontSizeConverter fontSizeConverter = new FontSizeConverter();
            double            result;

            if (double.TryParse(str, NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)culture, out result))
            {
                return((object)UnitTypedSize.CreateFromUnits(result, this.unitType));
            }
            return((object)UnitTypedSize.CreateFromPixels((double)fontSizeConverter.ConvertFromString(context, culture, str), this.unitType));
        }
コード例 #24
0
        public void AddGithubInfo(string source, string Header, string command = null, string commandParameter = null)
        {
            var cnt = GithubGrid.ColumnDefinitions?.Count() ?? 0;

            GithubGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            var sl = new StackLayout();

            if (command != null)
            {
                {
                    var gr = new TapGestureRecognizer();
                    gr.SetBinding(TapGestureRecognizer.CommandProperty, command);
                    gr.SetBinding(TapGestureRecognizer.CommandParameterProperty, commandParameter);
                    sl.GestureRecognizers.Add(gr);
                }
                {
                    var gr = new ClickGestureRecognizer();
                    gr.SetBinding(ClickGestureRecognizer.CommandProperty, command);
                    gr.SetBinding(ClickGestureRecognizer.CommandParameterProperty, commandParameter);
                    sl.GestureRecognizers.Add(gr);
                }
            }
            var fc = new FontSizeConverter();

            {
                var label = new Label()
                {
                    HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = (double)fc.ConvertFromInvariantString("Large"), FontAttributes = FontAttributes.Bold
                };
                label.SetBinding(Label.TextProperty, source);
                sl.Children.Add(label);
            }
            sl.Children.Add(new Label()
            {
                Text = Header, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = new Color(0.0, 0.0, 0.0, 0.5)
            });
            Grid.SetColumn(sl, cnt);
            GithubGrid.Children.Add(sl);
        }
コード例 #25
0
        private void Button16_Click(object sender, RoutedEventArgs e)
        {
            //Will change visualBrush of Rectangle6 to Text "Hello World"
            Rectangle6.Width  = 100;
            Rectangle6.Height = 110;

            VisualBrush brush16    = new VisualBrush();
            StackPanel  stack_text = new StackPanel();

            stack_text.Background = Brushes.White;

            TextBlock         brushA = new TextBlock();
            FontSizeConverter size   = new FontSizeConverter();

            brushA.FontSize = (double)size.ConvertFrom("10pt");
            brushA.Text     = "Hello, World!";
            stack_text.Children.Add(brushA);

            TextBlock         brushB = new TextBlock();
            FontSizeConverter size2  = new FontSizeConverter();

            brushB.FontSize = (double)size2.ConvertFrom("10pt");
            brushB.Text     = "Hello, World!";
            stack_text.Children.Add(brushB);

            TextBlock         brushC = new TextBlock();
            FontSizeConverter size3  = new FontSizeConverter();

            brushC.FontSize = (double)size3.ConvertFrom("10pt");
            brushC.Text     = "Hello, World!";
            stack_text.Children.Add(brushC);

            TextBlock         brushD = new TextBlock();
            FontSizeConverter size4  = new FontSizeConverter();

            brushD.FontSize = (double)size4.ConvertFrom("10pt");
            brushD.Text     = "Hello, World!";
            stack_text.Children.Add(brushD);

            brush16.Visual  = stack_text;
            Rectangle6.Fill = brush16;
        }
コード例 #26
0
        /// <summary>
        /// 設定されているタイトル数によってフォントサイズを決定する。
        /// </summary>
        private void AjustSize()
        {
            // 空でないタイトル数をカウントする。
            int rows = 0;

            if (!string.IsNullOrEmpty(Title1))
            {
                rows++;
            }
            if (!string.IsNullOrEmpty(Title2))
            {
                rows++;
            }
            if (!string.IsNullOrEmpty(Title3))
            {
                rows++;
            }

            // フォントサイズを決定し、設定する。
            FontSizeConverter fsc = new FontSizeConverter();
            double            fontSize;

            switch (rows)
            {
            case 2:
                fontSize = (double)fsc.ConvertFromInvariantString("Small");
                break;

            case 3:
                fontSize = (double)fsc.ConvertFromInvariantString("Micro");
                break;

            default:
                fontSize = (double)fsc.ConvertFromInvariantString("Title");
                break;
            }
            ;
            Title1Label.FontSize = fontSize;
            Title2Label.FontSize = fontSize;
            Title3Label.FontSize = fontSize;
        }
コード例 #27
0
        public TiledImageBrushExample()
        {
            Background = Brushes.White;
            StackPanel mainPanel = new StackPanel();

            mainPanel.Margin = new Thickness(20.0);

            // Create a button.
            Button berriesButton = new Button();

            berriesButton.Foreground = Brushes.White;
            berriesButton.FontWeight = FontWeights.Bold;
            FontSizeConverter sizeConverter = new FontSizeConverter();

            berriesButton.FontSize            = (Double)sizeConverter.ConvertFromString("16pt");
            berriesButton.FontFamily          = new FontFamily("Verdana");
            berriesButton.Content             = "Berries";
            berriesButton.Padding             = new Thickness(20.0);
            berriesButton.HorizontalAlignment = HorizontalAlignment.Left;

            // Create an ImageBrush.
            ImageBrush berriesBrush = new ImageBrush();

            berriesBrush.ImageSource =
                new BitmapImage(
                    new Uri(@"sampleImages\berries.jpg", UriKind.Relative)
                    );

            // Set the ImageBrush's Viewport and TileMode
            // so that it produces a pattern from
            // the image.
            berriesBrush.Viewport = new Rect(0, 0, 0.5, 0.5);
            berriesBrush.TileMode = TileMode.FlipXY;

            // Use the brush to paint the button's background.
            berriesButton.Background = berriesBrush;

            mainPanel.Children.Add(berriesButton);
            this.Content = mainPanel;
        }
コード例 #28
0
 public BlockBrush()
 {
     flag             = new ImageBrush();
     flag.ImageSource = new BitmapImage(new Uri("pack://application:,,,/image/flag.png"));
     mine             = new ImageBrush();
     mine.ImageSource = new BitmapImage(new Uri("pack://application:,,,/image/mine.png"));
     for (int i = 0; i < 9; i++)
     {
         var        my_brush = new VisualBrush();
         StackPanel aPanel   = new StackPanel();
         TextBlock  someText = new TextBlock();
         someText.Text = i.ToString();
         FontSizeConverter fSizeConverter = new FontSizeConverter();
         someText.FontSize   = (double)fSizeConverter.ConvertFromString("10pt");
         someText.Margin     = new Thickness(10);
         someText.Foreground = new SolidColorBrush(colors[i]);
         if (i != 0)
         {
             aPanel.Children.Add(someText);
         }
         my_brush.Visual = aPanel;
         numbers.Add(my_brush);
     }
 }
コード例 #29
0
ファイル: MinePage.cs プロジェクト: XiaoBaiXJ/RFID
        private void InitializeComponent()
        {
            if (ResourceLoader.ResourceProvider != null && ResourceLoader.ResourceProvider(typeof(MinePage).GetTypeInfo().Assembly.GetName(), "Views/MinePage.xaml") != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(base.GetType()) != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            RowDefinition      rowDefinition      = new RowDefinition();
            RowDefinition      rowDefinition2     = new RowDefinition();
            RowDefinition      rowDefinition3     = new RowDefinition();
            BindingExtension   bindingExtension   = new BindingExtension();
            Image              image              = new Image();
            BindingExtension   bindingExtension2  = new BindingExtension();
            CircleImage        circleImage        = new CircleImage();
            BindingExtension   bindingExtension3  = new BindingExtension();
            Label              label              = new Label();
            BindingExtension   bindingExtension4  = new BindingExtension();
            Label              label2             = new Label();
            StackLayout        stackLayout        = new StackLayout();
            AbsoluteLayout     absoluteLayout     = new AbsoluteLayout();
            Frame              frame              = new Frame();
            BindingExtension   bindingExtension5  = new BindingExtension();
            DataTemplate       dataTemplate       = new DataTemplate();
            ListView           listView           = new ListView();
            Frame              frame2             = new Frame();
            TranslateExtension translateExtension = new TranslateExtension();
            BindingExtension   bindingExtension6  = new BindingExtension();
            Button             button             = new Button();
            Grid              grid              = new Grid();
            ScrollView        scrollView        = new ScrollView();
            BindingExtension  bindingExtension7 = new BindingExtension();
            BindingExtension  bindingExtension8 = new BindingExtension();
            ActivityIndicator activityIndicator = new ActivityIndicator();
            Grid              grid2             = new Grid();
            NameScope         nameScope         = new NameScope();

            NameScope.SetNameScope(this, nameScope);
            NameScope.SetNameScope(grid2, nameScope);
            NameScope.SetNameScope(scrollView, nameScope);
            NameScope.SetNameScope(grid, nameScope);
            NameScope.SetNameScope(rowDefinition, nameScope);
            NameScope.SetNameScope(rowDefinition2, nameScope);
            NameScope.SetNameScope(rowDefinition3, nameScope);
            NameScope.SetNameScope(frame, nameScope);
            NameScope.SetNameScope(absoluteLayout, nameScope);
            NameScope.SetNameScope(image, nameScope);
            NameScope.SetNameScope(stackLayout, nameScope);
            NameScope.SetNameScope(circleImage, nameScope);
            NameScope.SetNameScope(label, nameScope);
            NameScope.SetNameScope(label2, nameScope);
            NameScope.SetNameScope(frame2, nameScope);
            NameScope.SetNameScope(listView, nameScope);
            ((INameScope)nameScope).RegisterName("listview", listView);
            if (listView.StyleId == null)
            {
                listView.StyleId = "listview";
            }
            NameScope.SetNameScope(button, nameScope);
            NameScope.SetNameScope(activityIndicator, nameScope);
            this.listview = listView;
            this.SetValue(NavigationPage.HasNavigationBarProperty, false);
            grid.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(10.0));
            grid.SetValue(Grid.RowSpacingProperty, 10.0);
            rowDefinition.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto"));
            grid.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition);
            rowDefinition2.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto"));
            grid.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition2);
            rowDefinition3.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto"));
            grid.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition3);
            frame.SetValue(Grid.RowProperty, 0);
            frame.SetValue(Frame.HasShadowProperty, false);
            frame.SetValue(Frame.CornerRadiusProperty, 10f);
            frame.SetValue(VisualElement.BackgroundColorProperty, Color.Black);
            frame.SetValue(Frame.BorderColorProperty, Color.Black);
            frame.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(0.0));
            absoluteLayout.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(0.0));
            absoluteLayout.SetValue(View.HorizontalOptionsProperty, LayoutOptions.FillAndExpand);
            absoluteLayout.SetValue(View.VerticalOptionsProperty, LayoutOptions.FillAndExpand);
            image.SetValue(Image.AspectProperty, Aspect.AspectFill);
            bindingExtension.Path = "Background";
            BindingBase binding = ((IMarkupExtension <BindingBase>)bindingExtension).ProvideValue(null);

            image.SetBinding(Image.SourceProperty, binding);
            image.SetValue(AbsoluteLayout.LayoutBoundsProperty, new Rectangle(0.0, 0.0, 1.0, 1.0));
            image.SetValue(AbsoluteLayout.LayoutFlagsProperty, AbsoluteLayoutFlags.All);
            absoluteLayout.Children.Add(image);
            stackLayout.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);
            stackLayout.SetValue(AbsoluteLayout.LayoutBoundsProperty, new Rectangle(0.5, 0.5, -1.0, -1.0));
            stackLayout.SetValue(AbsoluteLayout.LayoutFlagsProperty, AbsoluteLayoutFlags.PositionProportional);
            bindingExtension2.Path = "UserIcon";
            BindingBase binding2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue(null);

            circleImage.SetBinding(Image.SourceProperty, binding2);
            circleImage.SetValue(VisualElement.HeightRequestProperty, 80.0);
            circleImage.SetValue(VisualElement.WidthRequestProperty, 80.0);
            circleImage.SetValue(Image.AspectProperty, Aspect.AspectFit);
            stackLayout.Children.Add(circleImage);
            label.SetValue(Label.TextColorProperty, Color.White);
            BindableObject         bindableObject        = label;
            BindableProperty       fontSizeProperty      = Label.FontSizeProperty;
            IExtendedTypeConverter extendedTypeConverter = new FontSizeConverter();
            string value = "Large";
            XamlServiceProvider xamlServiceProvider = new XamlServiceProvider();
            Type typeFromHandle = typeof(IProvideValueTarget);

            object[] array = new object[0 + 8];
            array[0] = label;
            array[1] = stackLayout;
            array[2] = absoluteLayout;
            array[3] = frame;
            array[4] = grid;
            array[5] = scrollView;
            array[6] = grid2;
            array[7] = this;
            xamlServiceProvider.Add(typeFromHandle, new SimpleValueTargetProvider(array, Label.FontSizeProperty));
            xamlServiceProvider.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle2 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver();

            xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver.Add("circle", "clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin");
            xmlNamespaceResolver.Add("layout", "clr-namespace:RFID.Layout");
            xmlNamespaceResolver.Add("local", "clr-namespace:RFID");
            xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(MinePage).GetTypeInfo().Assembly));
            xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(25, 62)));
            bindableObject.SetValue(fontSizeProperty, extendedTypeConverter.ConvertFromInvariantString(value, xamlServiceProvider));
            bindingExtension3.Path = "Name";
            BindingBase binding3 = ((IMarkupExtension <BindingBase>)bindingExtension3).ProvideValue(null);

            label.SetBinding(Label.TextProperty, binding3);
            label.SetValue(Label.HorizontalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Center"));
            stackLayout.Children.Add(label);
            label2.SetValue(Label.TextColorProperty, Color.White);
            BindableObject         bindableObject2        = label2;
            BindableProperty       fontSizeProperty2      = Label.FontSizeProperty;
            IExtendedTypeConverter extendedTypeConverter2 = new FontSizeConverter();
            string value2 = "Medium";
            XamlServiceProvider xamlServiceProvider2 = new XamlServiceProvider();
            Type typeFromHandle3 = typeof(IProvideValueTarget);

            object[] array2 = new object[0 + 8];
            array2[0] = label2;
            array2[1] = stackLayout;
            array2[2] = absoluteLayout;
            array2[3] = frame;
            array2[4] = grid;
            array2[5] = scrollView;
            array2[6] = grid2;
            array2[7] = this;
            xamlServiceProvider2.Add(typeFromHandle3, new SimpleValueTargetProvider(array2, Label.FontSizeProperty));
            xamlServiceProvider2.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle4 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver2 = new XmlNamespaceResolver();

            xmlNamespaceResolver2.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver2.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver2.Add("circle", "clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin");
            xmlNamespaceResolver2.Add("layout", "clr-namespace:RFID.Layout");
            xmlNamespaceResolver2.Add("local", "clr-namespace:RFID");
            xamlServiceProvider2.Add(typeFromHandle4, new XamlTypeResolver(xmlNamespaceResolver2, typeof(MinePage).GetTypeInfo().Assembly));
            xamlServiceProvider2.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(26, 62)));
            bindableObject2.SetValue(fontSizeProperty2, extendedTypeConverter2.ConvertFromInvariantString(value2, xamlServiceProvider2));
            bindingExtension4.Path = "Introduce";
            BindingBase binding4 = ((IMarkupExtension <BindingBase>)bindingExtension4).ProvideValue(null);

            label2.SetBinding(Label.TextProperty, binding4);
            label2.SetValue(Label.HorizontalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Center"));
            stackLayout.Children.Add(label2);
            absoluteLayout.Children.Add(stackLayout);
            frame.SetValue(ContentView.ContentProperty, absoluteLayout);
            grid.Children.Add(frame);
            frame2.SetValue(Frame.OutlineColorProperty, Color.White);
            frame2.SetValue(Grid.RowProperty, 1);
            frame2.SetValue(Frame.CornerRadiusProperty, 5f);
            frame2.SetValue(VisualElement.BackgroundColorProperty, Color.White);
            frame2.SetValue(Frame.BorderColorProperty, new Color(0.87058824300765991, 0.87058824300765991, 0.87058824300765991, 1.0));
            frame2.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(0.0));
            listView.SetValue(ListView.RowHeightProperty, 50);
            listView.SetValue(VisualElement.HeightRequestProperty, 203.0);
            listView.SetValue(ListView.SeparatorColorProperty, new Color(0.87058824300765991, 0.87058824300765991, 0.87058824300765991, 1.0));
            listView.SetValue(ListView.SeparatorVisibilityProperty, SeparatorVisibility.Default);
            listView.ItemSelected += this.ListView_ItemSelected;
            bindingExtension5.Path = "MenuSource";
            BindingBase binding5 = ((IMarkupExtension <BindingBase>)bindingExtension5).ProvideValue(null);

            listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, binding5);
            IDataTemplate dataTemplate2 = dataTemplate;

            MinePage.< InitializeComponent > _anonXamlCDataTemplate_1 <InitializeComponent> _anonXamlCDataTemplate_ = new MinePage.< InitializeComponent > _anonXamlCDataTemplate_1();
            object[]   array3 = new object[0 + 7];
            array3[0] = dataTemplate;
            array3[1] = listView;
            array3[2] = frame2;
            array3[3] = grid;
            array3[4] = scrollView;
            array3[5] = grid2;
            array3[6] = this;
コード例 #30
0
ファイル: LabelTests.cs プロジェクト: Costo/Xamarin.Forms
		public void FontSizeConverterTests ()
		{
			var converter = new FontSizeConverter ();
			Assert.AreEqual (12, converter.ConvertFromInvariantString ("12"));
			Assert.AreEqual (10.7, converter.ConvertFromInvariantString ("10.7"));
		}
コード例 #31
0
        public AnoNePage()
        {
            InitializeComponent();
            if (Test.current.probiha)
            {
                Uspesnost = Test.current.procentHotovo;
            }
            else
            {
                Uspesnost = "Správně : " + Statistika.Current.Procent_uspesnost.ToString() + "%";
                Pokracovat_butt.IsEnabled = true;
            }
            Otazka otzk = NactiOtazku();

            Body    = otzk.Bodu.ToString();
            Spravne = otzk.Spravna;

            if (otzk.Bodu == 1)
            {
                Body += " bod";
            }
            else if (otzk.Bodu < 5)
            {
                Body += " body";
            }
            else
            {
                Body += " bodů";
            }
            Ukol = otzk.Ukol.Replace("\n", " ").Replace("    ", " ").Trim();
            while (Ukol.Contains("  "))
            {
                Ukol = Ukol.Replace("  ", " ");
            }

            moznosti = new List <string>();
            foreach (string m in otzk.Moznosti.Moznost)
            {
                string moznost = m.Replace("\n", " ");
                while (moznost.Contains("  ") || moznost.Contains("   "))
                {
                    moznost = moznost.Replace("  ", " ").Replace("   ", " ");
                }
                moznosti.Add(moznost);
            }

            int index = 0;

            foreach (String moznost in moznosti)
            {
                StackLayout layout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal
                };
                FontSizeConverter fontSizeConverter = new FontSizeConverter();
                Label             label             = new Label
                {
                    Text              = moznost.Replace("\n", " ").Replace("  ", " ").Trim(),
                    TextColor         = Color.Black,
                    FontSize          = (Double)fontSizeConverter.ConvertFromInvariantString("Small"),
                    VerticalOptions   = Xamarin.Forms.LayoutOptions.Center,
                    Margin            = new Thickness(15, 0, 0, 0),
                    HorizontalOptions = LayoutOptions.StartAndExpand
                };
                layout.Children.Add(label);
                Switch switchA = new Switch();
                layout.Children.Add(switchA);

                HlavniStackLayout.Children.Insert(index + 3, layout);
                index++;
            }
            BindingContext = this;
        }