Beispiel #1
0
        public static Font FromFontFormat(FontFormat fontFormat)
        {
            //Build char map
            var charMap = new List <Vector4>();

            for (var i = 0; i < fontFormat.CharMap.Length; i += 4)
            {
                charMap.Add(new Vector4(fontFormat.CharMap[i], fontFormat.CharMap[i + 1], fontFormat.CharMap[i + 2],
                                        fontFormat.CharMap[i + 3]));
            }

            //Build font color data
            var colorData = new Color[fontFormat.Width * fontFormat.Height];

            for (var i = 0; i < fontFormat.TextureData.Length; i++)
            {
                colorData[i] = new Color(fontFormat.TextureData[i]);
            }

            return(new Font()
            {
                CharMap = charMap,
                Texture = new Texture2D(fontFormat.Width, fontFormat.Height, colorData),
                LineHeight = fontFormat.LineHeight,
                SpaceSize = fontFormat.SpaceSize
            });
        }
 public Font this[FontFormat format]
 {
     get
     {
         return(this.GetFont(format));
     }
 }
        private void SetSourceFormatToBox(FontFormat fontFormat)
        {
            switch (fontFormat)
            {
            case FontFormat.WOFF:
                comboBoxFormat.SelectedItem = "woff";
                break;

            case FontFormat.Unknown:
                comboBoxFormat.SelectedItem = "NA";
                break;

            case FontFormat.TrueType:
                comboBoxFormat.SelectedItem = "truetype";
                break;

            case FontFormat.SVGFont:
                comboBoxFormat.SelectedItem = "svg";
                break;

            case FontFormat.OpenType:
                comboBoxFormat.SelectedItem = "opentype";
                break;

            case FontFormat.EmbeddedOpenType:
                comboBoxFormat.SelectedItem = "embedded-opentype";
                break;
            }
        }
        private static void ApplyFontFormat(
            this Range range,
            FontFormat format)
        {
            if (format == null)
            {
                return;
            }

            var implementedProperties = new[]
            {
                nameof(FontFormat.FontColor),
                nameof(FontFormat.FontNamesInFallbackOrder),
                nameof(FontFormat.FontSizeInPoints),
                nameof(FontFormat.Options),
            };

            format.ThrowOnNotImplementedProperty(implementedProperties);

            range.SetFontColor(format.FontColor);

            range.SetFontName(format.FontNamesInFallbackOrder?.FirstOrDefault());

            range.SetFontSize(format.FontSizeInPoints == null ? (int?)null : decimal.ToInt32(Math.Round((decimal)format.FontSizeInPoints)));

            range.ApplyFontFormatOptions(format.Options);
        }
Beispiel #5
0
 private EPubCoreMediaType ConvertFontToMediaType(FontFormat fontFormat)
 {
     if (fontFormat == FontFormat.WOFF)
     {
         return(EPubCoreMediaType.ApplicationFontWoff);
     }
     return(EPubCoreMediaType.ApplicationFontMSOpen);
 }
 public TextEditorRowColumn(MultiLineTextBox owner)
     : base("rowcolumn", Docking.Left, new TextEditorRowColumnWidgetStyle())
 {
     Owner       = owner;
     DisplayMode = DisplayModes.ParagraphNumber;
     MinSize     = new Size(40, 0);
     Format      = new FontFormat(Alignment.Far, Alignment.Center, FontFormatFlags.None);
     Padding     = new Padding(6, 0, 6, 0);
 }
Beispiel #7
0
 public BaseTemplate()
 {
     this.TileFormat  = new TileFormat();
     this.DefaultFont = new FontFormat("Segoe UI", 8.0f);
     this.TitleFont   = new FontFormat("Segoe UI Semibold", this.DefaultFont.EmSize + 5.0f);
     this.Palette     = PaletteBuilder.GetDefaultPalette();
     this.Title       = this.DefaultChartTitle;
     this.SubTitle    = this.DefaultChartSubTitle;
 }
        public void TestSyncFontFamily()
        {
            Microsoft.Office.Interop.PowerPoint.Shape formatShape = GetShape(OriginalShapesSlideNo, CopyFromLargeShape);

            Microsoft.Office.Interop.PowerPoint.Shape newShape = GetShape(OriginalShapesSlideNo, CopyToShape);
            FontFormat.SyncFormat(formatShape, newShape);

            CompareSlides(OriginalShapesSlideNo, SyncFontFamilySlideNo);
            CheckFontStyle(OriginalShapesSlideNo, SyncFontFamilySlideNo);
        }
        private void InitStringFormats()
        {
            m_UserHeaderFormat        = new FontFormat(Alignment.Center, Alignment.Center, FontFormatFlags.Elipsis);
            m_DayHeaderFormat         = new FontFormat(Alignment.Center, Alignment.Center, FontFormatFlags.None);
            m_HourLabelFormat         = new FontFormat(Alignment.Near, Alignment.Center, FontFormatFlags.None);
            m_AppointmentStringFormat = new FontFormat(Alignment.Near, Alignment.Center, FontFormatFlags.WrapText | FontFormatFlags.Elipsis);

            //HourFont = HeaderFont;
            //MinuteFont = HeaderFont;
        }
        private void SetSourceFormatToFont(FontFormat format)
        {
            var currentSource = _myDataSourceSources.Current as FontSource;

            if (currentSource != null)
            {
                currentSource.Format = format;
                _myDataSourceFonts.ResetCurrentItem();
            }
        }
Beispiel #11
0
        public void TestSyncFontFamily()
        {
            var formatShape = GetShape(OriginalShapesSlideNo, CopyFromLargeShape);

            var newShape = GetShape(OriginalShapesSlideNo, CopyToShape);

            FontFormat.SyncFormat(formatShape, newShape);

            CompareSlides(OriginalShapesSlideNo, SyncFontFamilySlideNo);
            CheckFontStyle(OriginalShapesSlideNo, SyncFontFamilySlideNo);
        }
Beispiel #12
0
        public IFontFormat From(FontFormat format)
        {
            foreach (var f in _formats)
            {
                if (f.Format == format)
                {
                    return(f);
                }
            }

            throw new UnknownFontFormatException();
        }
Beispiel #13
0
        public Font LoadFontFromStream(Stream stream, FontFormat format)
        {
            FT_Face     face;
            FT_Error    error = FT_Error.FT_Err_Ok;
            IDisposable source;

            if (stream is UnmanagedMemoryStream ums)
            {
                unsafe
                {
                    error = FT_New_Memory_Face(this.library, (IntPtr)ums.PositionPointer, (int)ums.Length, 0, &face);
                }
                source = ums;
            }
            else
            {
                MemoryStream memoryStream;

                if (stream is MemoryStream ms)
                {
                    memoryStream = ms;
                }
                else
                {
                    int sourceLength;
                    checked
                    {
                        sourceLength = (int)stream.Length;
                    }
                    memoryStream = new MemoryStream(sourceLength);
                    stream.CopyTo(memoryStream);
                }

                unsafe
                {
                    fixed(byte *ptr = memoryStream.GetBuffer())
                    {
                        error = FT_New_Memory_Face(this.library, (IntPtr)ptr, (int)memoryStream.Length, 0, &face);
                    }
                }
                source = memoryStream;
            }


            if (error != FT_Error.FT_Err_Ok)
            {
                throw new ApplicationException(error.ToString());
            }

            return(new FreeTypeFont(face, source));
        }
        /// <summary>
        /// Construct alarm name row UI
        /// </summary>
        /// <param name="recod">AlarmRecord</param>
        /// <seealso cref="AlarmRecord">
        public AlarmEditName(AlarmRecord recod)
        {
            /// Fills horizontally
            HorizontalOptions = LayoutOptions.FillAndExpand;
            /// Fills vertically
            VerticalOptions = LayoutOptions.Start;
            HeightRequest   = 198;

            if (mainLabel == null)
            {
                mainLabel = new Label
                {
                    WidthRequest  = 720 - 32 * 2,
                    HeightRequest = 54,
                    Text          = "Alarm Name",
                    Style         = AlarmStyle.T023,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
            }

            /// Adds main label
            Children.Add(mainLabel,
                         Constraint.RelativeToParent((parent) => { return(32); }),
                         Constraint.RelativeToParent((parent) => { return(24); }));
            /// Creates entry
            mainEntry = new Entry()
            {
                WidthRequest  = 720 - (32 + 10) * 2,
                HeightRequest = 54,
                Text          = recod.AlarmName,
            };
            mainEntry.SetBinding(Entry.TextProperty, new Binding("AlarmName", BindingMode.Default, source: recod));

            /// Checks whether already set alarm name
            if (string.IsNullOrEmpty(AlarmModel.BindableAlarmRecord.AlarmName))
            {
                mainEntry.Placeholder = "Alarm";
            }
            else
            {
                mainEntry.Text = AlarmModel.BindableAlarmRecord.AlarmName;
            }

            /// Sets font size (DP base)
            mainEntry.FontSize = CommonStyle.GetDp(40);
            /// Adds to layout
            Children.Add(mainEntry,
                         Constraint.RelativeToView(mainLabel, (parent, sibling) => { return(sibling.X + 10); }),
                         Constraint.RelativeToView(mainLabel, (parent, sibling) => { return(sibling.Y + sibling.Height + 33); }));
        }
Beispiel #15
0
 public void CopyFrom(IFontSource fontSource)
 {
     if (fontSource == null)
     {
         throw new ArgumentNullException("fontSource");
     }
     if (fontSource == this)
     {
         return;
     }
     Type     = fontSource.Type;
     Location = fontSource.Location;
     Format   = fontSource.Format;
 }
        public Font GetFont(FontFormat format)
        {
            var map = this.Map;

            if (map.ContainsKey(format) == true)
            {
                return(map[format]);
            }
            else
            {
                var font = new Font(FontFamily, format.Size, format.Style);
                map[format] = font;
                return(font);
            }
        }
        /// <summary>
        /// Create UI layout that will be displayed at the top of the ListView
        /// </summary>
        /// <returns>RelativeLayout</returns>
        private RelativeLayout CreateListViewHeader()
        {
            // The View for Header of ListView
            RelativeLayout headerLayout = new RelativeLayout
            {
                HeightRequest = 93
            };

            // Title label of ListView's header
            Label headerTitleLabel = new Label()
            {
                HorizontalOptions     = LayoutOptions.FillAndExpand,
                VerticalTextAlignment = TextAlignment.Center,
                Text      = "Select all",
                TextColor = Color.Black,
                FontSize  = 20,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(headerTitleLabel, FontWeight.Light);
            headerLayout.Children.Add(headerTitleLabel,
                                      Constraint.RelativeToParent((parent) =>
            {
                return(32 + 10);
            }),
                                      Constraint.RelativeToParent((parent) =>
            {
                return(22 + 93 - 72);
            }));

            // Switch to give an app user an opportunity to delete all data items of List
            deleteAllSwitch = new Switch
            {
                HorizontalOptions = LayoutOptions.End,
            };
            VisualAttributes.SetThemeStyle(deleteAllSwitch, "CheckBox");
            deleteAllSwitch.Toggled += DeleteAllSwitch_Toggled;
            headerLayout.Children.Add(deleteAllSwitch,
                                      Constraint.RelativeToParent((parent) =>
            {
                return(720 - 104);
            }),
                                      Constraint.RelativeToParent((parent) =>
            {
                return(22 + 93 - 72);
            }));
            return(headerLayout);
        }
        // If user don't push enter that counts for no response.
        // An interaction interface.
        internal static void ConsoleInterface()
        {
            Console.WriteLine("The application will automatically close after a minute if " +
                              "no input is provided.");
            // Create timer to escape infinite loop.
            Timer timer = new Timer(TimerExit, null, 60000, 60000);

            // Create a list of formats.
            FontFormat[] formats = (FontFormat[])Enum.GetValues(typeof(FontFormat));
            // Initialization of new FontFormat object.
            FontFormat fontFormatVal = new FontFormat();

            do
            {
                Console.Write("Inscription Parameters: ");
                // Output current font format.
                Console.Write(fontFormatVal);
                Console.WriteLine("\n Type-in:");
                Console.WriteLine("1: " + FontFormat.Bold);
                Console.WriteLine("2: " + FontFormat.Italic);
                Console.WriteLine("3: " + FontFormat.Underline);
                int inputValue = 0;
                do
                {
                    // Change the user state to default.
                    noResponse = true;
                    // Read the format index.
                    Int32.TryParse(Console.ReadLine(), out inputValue);
                    // Change the user state to response.
                    noResponse = false;
                    // Reset timer.
                    timer.Change(60000, 60000);
                }
                // Until the index is correct.
                while (inputValue < 1 || inputValue > 3);
                // If current format contains input format
                fontFormatVal = fontFormatVal.HasFlag(formats[inputValue]) ?
                              // Exclude the format.
                                fontFormatVal ^ formats[inputValue]
                            : // If current format is none.
                                fontFormatVal.HasFlag(formats[inputValue]) ?
                              // Rewrite the format.
                                formats[inputValue]
                            : // Include the format.
                                fontFormatVal | formats[inputValue];
            } while (true);
        }
Beispiel #19
0
 public FSFontInfo(FileInfo file, FontFormat format, string postScriptName,
                   CIDSystemInfo cidSystemInfo, int usWeightClass, int sFamilyClass,
                   int ulCodePageRange1, int ulCodePageRange2, int macStyle, byte[] panose,
                   FileSystemFontProvider parent)
 {
     this.file             = file;
     this.format           = format;
     this.postScriptName   = postScriptName;
     this.cidSystemInfo    = cidSystemInfo;
     this.usWeightClass    = usWeightClass;
     this.sFamilyClass     = sFamilyClass;
     this.ulCodePageRange1 = ulCodePageRange1;
     this.ulCodePageRange2 = ulCodePageRange2;
     this.macStyle         = macStyle;
     this.panose           = panose != null ? new PanoseClassification(panose) : null;
     this.parent           = parent;
 }
Beispiel #20
0
        public void ProcessAppendsBoldTagToStringBuilder(FontFormat currentFontFormat)
        {
            //Arrange
            var boldCommand = new Bold();
            var currentPdf  = new CurrentPdf();

            currentPdf.StringBuilder     = new StringBuilder();
            currentPdf.CurrentFontFormat = currentFontFormat;

            var expectedValue = "<b>";

            //Act
            boldCommand.Process(ref currentPdf);

            //Assert
            Assert.AreEqual(expectedValue, currentPdf.StringBuilder.ToString());
            Assert.AreEqual(FontFormat.Bold, currentPdf.CurrentFontFormat);
        }
Beispiel #21
0
        public void ProcessAppendsItalicsTagToStringBuilder(FontFormat currentFontFormat)
        {
            //Arrange
            var italicsCommand = new Italics();
            var currentPdf     = new CurrentPdf();

            currentPdf.StringBuilder     = new StringBuilder();
            currentPdf.CurrentFontFormat = currentFontFormat;

            var expectedValue = "<i>";

            //Act
            italicsCommand.Process(ref currentPdf);

            //Assert
            Assert.AreEqual(expectedValue, currentPdf.StringBuilder.ToString());
            Assert.AreEqual(FontFormat.Italics, currentPdf.CurrentFontFormat);
        }
Beispiel #22
0
        private string GenerateFontFaceCss(bool isForPreview = true)
        {
            if (genericFontRadioButton.IsChecked.HasValue && genericFontRadioButton.IsChecked.Value)
            {
                return("");
            }

            string fontFilePath = fontFilePathTextBox.Text;

            if (string.IsNullOrEmpty(fontFilePath) || !File.Exists(fontFilePath))
            {
                return("");
            }

            // font name is already quoted
            string fontName = customFontFamilyName;
            Uri    fontUri  = new Uri(fontFilePathTextBox.Text);

            FontFormat fontFormat        = FontFormat.Unknown;
            string     fontFileExtension = System.IO.Path.GetExtension(fontFilePathTextBox.Text);

            if (!string.IsNullOrEmpty(fontFileExtension))
            {
                fontFormat = GetFontFormat(fontFileExtension);
            }

            string fontFormatStr = fontFormat == FontFormat.Unknown ? "" : "format(\"" + fontFormat.ToString().ToLower() + "\");";

            string path    = "";
            string srcType = "url";

            if (isForPreview)
            {
                path = fontUri.AbsoluteUri;
            }
            else
            {
                path = System.IO.Path.GetFileName(fontFilePathTextBox.Text);
            }

            return(string.Format("@font-face {{ font-family: {0}; src: {1}(\"{2}\") {3} }}", fontName, srcType, path, fontFormatStr));
        }
        public CounterView(/*StackLayout parent, */ CounterType type)
        {
            type_ = type;

            if (type == CounterType.COUNTER_TYPE_STOPWATCH)
            {
                layout_ = new RelativeLayout
                {
                    Style = stopwatchLayoutStyle,
                };
                hmsLabel_ = new Label
                {
                    Style = stopwatchHMSLabelStyle,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(hmsLabel_, FontWeight.Thin);

                msLabel_ = new Label
                {
                    Style = stopwatchMSLabelStyle,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(msLabel_, FontWeight.Thin);
            }
            else
            {
                layout_ = new RelativeLayout
                {
                    Style = timerLayoutStyle,
                };
                hmsLabel_ = new Label
                {
                    Style = timerLabelStyle,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(hmsLabel_, FontWeight.Thin);
            }

            AddChildren();
        }
Beispiel #24
0
        /// <summary>
        /// Create a RelativeLayout for custom cells
        /// </summary>
        /// <returns>RelativeLayout</returns>
        private RelativeLayout CreateCityList()
        {
            if (cityListItemLayout == null)
            {
                cityListItemLayout = new RelativeLayout
                {
                    WidthRequest  = 720,
                    HeightRequest = 22 + 53 + 43 + 26,
                };

                timeLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO040,
                    WidthRequest            = 113,
                    HeightRequest           = 61, /*67*/// GUI GUIDE : 67
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(timeLabel, FontWeight.Light);
                timeLabel.SetBinding(Label.TextProperty, "CityTime");

                cityListItemLayout.Children.Add(timeLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(17);
                }));

                amPmLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO041,
                    WidthRequest            = 52,
                    HeightRequest           = 40,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    //BackgroundColor = Color.Violet,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(amPmLabel, FontWeight.Medium);
                amPmLabel.SetBinding(Label.TextProperty, "CityAmPm");
                cityListItemLayout.Children.Add(amPmLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32 + 113 + 8);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(17 + 21);
                }));

                dateLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO042,
                    Text                    = "Wed, 20 Mar",
                    WidthRequest            = 173,
                    HeightRequest           = 40,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    //BackgroundColor = Color.Beige,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(dateLabel, FontWeight.Normal);
                dateLabel.SetBinding(Label.TextProperty, "CityDate");
                cityListItemLayout.Children.Add(dateLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(17 + 61);
                }));

                citiesLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO043,
                    Text                    = "Beijing, China",
                    WidthRequest            = 405,
                    HeightRequest           = 53,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    //BackgroundColor = Color.SpringGreen,
                    LineBreakMode = LineBreakMode.TailTruncation,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(citiesLabel, FontWeight.Normal);
                citiesLabel.SetBinding(Label.TextProperty, "Cities");
                cityListItemLayout.Children.Add(citiesLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32 + 173 + 82);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(22);
                }));

                relativeToLocalLabel = new Label
                {
                    Style                   = WorldclockStyle.ATO044,
                    Text                    = "Same as local time",
                    WidthRequest            = 405,
                    HeightRequest           = 43,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start,
                    //BackgroundColor = Color.Black,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(relativeToLocalLabel, FontWeight.Normal);
                relativeToLocalLabel.SetBinding(Label.TextProperty, "RelativeToLocalCountry");
                cityListItemLayout.Children.Add(relativeToLocalLabel,
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(32 + 173 + 82);
                }),
                                                Constraint.RelativeToParent((parent) =>
                {
                    return(22 + 53);
                }));
            }

            return(cityListItemLayout);
        }
 private void SetSourceFormatToBox(FontFormat fontFormat)
 {
     switch (fontFormat)
     {
         case FontFormat.WOFF:
             comboBoxFormat.SelectedItem = "woff";
             break;
         case FontFormat.Unknown:
             comboBoxFormat.SelectedItem = "NA";
             break;
         case FontFormat.TrueType:
             comboBoxFormat.SelectedItem = "truetype";
             break;
         case FontFormat.SVGFont:
             comboBoxFormat.SelectedItem = "svg";
             break;
         case FontFormat.OpenType:
             comboBoxFormat.SelectedItem = "opentype";
             break;
         case FontFormat.EmbeddedOpenType:
             comboBoxFormat.SelectedItem = "embedded-opentype";
             break;
     }
 }
        /// <summary>
        /// Construct alarm tone row UI
        /// </summary>
        /// <param name="editType">type indicator</param>
        /// <seealso cref="AlarmToneTypes">
        public AlarmToneRow(AlarmToneTypes type)
        {
            /// Sets each row height to 120 according UX guide
            HeightRequest = 120;

            /// Checks type and set mainStr
            switch (type)
            {
            case AlarmToneTypes.AlarmMp3:
                mainStr = "alarm.mp3";
                break;

            case AlarmToneTypes.Default:
                mainStr = "Default";
                break;

            case AlarmToneTypes.RingtoneSdk:
                mainStr = "ringtone_sdk.mp3";
                break;

            default:
                mainStr = "";
                break;
            }

            /// If mainStr is not null, create a new main Label
            if (mainStr != null)
            {
                if (mainLabel == null)
                {
                    mainLabel = new Label
                    {
                        HeightRequest = 54,
                        Style         = AlarmStyle.T033,
                    };
                    // to meet To meet thin attribute for font, need to use custom feature
                    FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
                }

                /// Sets main Label with mainStr
                mainLabel.Text = mainStr;
                /// Add to layout
                Children.Add(mainLabel,
                             Constraint.RelativeToParent((parent) => { return(32); }),
                             Constraint.RelativeToParent((parent) => { return((120 - 72) / 2); }));
            }

            /// Create a new radio button for this row
            toneRadio = new RadioButton
            {
                Text          = type.ToString(),
                HeightRequest = 80,
                WidthRequest  = 80,
                /// Group name should be set same for all radio button group elements
                GroupName = "AlarmTone",
            };

            if (AlarmModel.BindableAlarmRecord.AlarmToneType == type)
            {
                toneRadio.IsSelected = true;
                oldValue             = newValue = type;
            }

            toneRadio.Selected += ToneRadio_Selected;

            Children.Add(toneRadio,
                         Constraint.RelativeToParent((parent) => (parent.X + parent.Width - (80 + 32))),
                         Constraint.RelativeToParent((parent) => { return((120 - 80) / 2); }));
        }
 private void SetSourceFormatToFont(FontFormat format)
 {
     var currentSource = _myDataSourceSources.Current as FontSource;
     if (currentSource != null)
     {
         currentSource.Format = format;
         _myDataSourceFonts.ResetCurrentItem();
     }
 }
Beispiel #28
0
 public static Font LoadFromStream(Stream stream, FontFormat format) => DriverConfiguration.Drivers.fontApi.LoadFontFromStream(stream, format);
        /// <summary>
        /// RingPage UI for Timer
        /// title label, Hour/Minute/Second labels
        /// </summary>
        private void CreateRingLabels()
        {
            Label titleLabel = new Label
            {
                Text          = "Time is up",
                Style         = TimerStyle.ATO019,
                HeightRequest = 58,
                WidthRequest  = 400,
                //BackgroundColor = Color.Orange,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(titleLabel, FontWeight.Light);
            rLayout.Children.Add(titleLabel,
                                 Constraint.RelativeToParent((parent) => { return(160); }),
                                 Constraint.RelativeToParent((parent) => { return(241 - 58); }));

            // case: display H/M/S
            hLabel = new Label
            {
                Text      = "Hours",
                Style     = TimerStyle.ATO009,
                IsVisible = false,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(hLabel, FontWeight.Normal);
            rLayout.Children.Add(hLabel,
                                 Constraint.RelativeToParent((parent) => { return(50 + 18); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            mLabel = new Label
            {
                Text      = "Minutes",
                Style     = TimerStyle.ATO009,
                IsVisible = false,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(mLabel, FontWeight.Normal);
            rLayout.Children.Add(mLabel,
                                 Constraint.RelativeToParent((parent) => { return(360 - 70); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            sLabel = new Label
            {
                Text      = "Seconds",
                Style     = TimerStyle.ATO009,
                IsVisible = false,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(sLabel, FontWeight.Normal);
            rLayout.Children.Add(sLabel,
                                 Constraint.RelativeToParent((parent) => { return(720 - 50 - 18 - 140); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            //case: display M/S
            _mLabel = new Label
            {
                Text  = "Minutes",
                Style = TimerStyle.ATO009,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(_mLabel, FontWeight.Normal);
            rLayout.Children.Add(_mLabel,
                                 Constraint.RelativeToParent((parent) => { return(360 - 120 - 50); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            _sLabel = new Label
            {
                Text  = "Seconds",
                Style = TimerStyle.ATO009,
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(_sLabel, FontWeight.Normal);
            rLayout.Children.Add(_sLabel,
                                 Constraint.RelativeToParent((parent) => { return(360 + 50); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157); }));

            counterview   = new CounterView(CounterType.COUNTER_TYPE_TIMER);
            counterLayout = counterview.GetCounterLayout();
            //counterLayout.BackgroundColor = Color.Lime;
            counterview.DisplayTime("00:00");
            rLayout.Children.Add(counterLayout,
                                 Constraint.RelativeToParent((parent) => { return(50); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); }));

            minusImage = new Image
            {
                Source          = "timer/timer_ringing_minus.png",
                WidthRequest    = 36,
                HeightRequest   = 204,
                VerticalOptions = LayoutOptions.Center,
                //BackgroundColor = Color.FromHex("#FFFAFAFA"),
                IsVisible = false,
            };

            rLayout.Children.Add(minusImage,
                                 Constraint.RelativeToParent((parent) => { return(50 - 36); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); }));

            _minusImage = new Image
            {
                Source          = "timer/timer_ringing_minus.png",
                WidthRequest    = 36,
                HeightRequest   = 204,
                VerticalOptions = LayoutOptions.Center,
                //BackgroundColor = Color.FromHex("FFFAFAFA"),
            };

            rLayout.Children.Add(_minusImage,
                                 Constraint.RelativeToParent((parent) => { return(360 - 120 - 50 - 18 - 8 - 36); }),
                                 Constraint.RelativeToParent((parent) => { return(241 + 157 + 230 - 204); }));
        }
        /// <summary>
        /// RingPage UI for Alarm
        /// Alarm Name, AM/PM label, Date & Time label
        /// </summary>
        private void CreateAlarmInfo()
        {
            Label alarmTitleLabel = new Label
            {
                Style                 = Styles.AlarmStyle.ATO006,
                HeightRequest         = 69,
                Text                  = _alarmRecord.AlarmName.Equals("") ? "Alarm" : _alarmRecord.AlarmName,
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(alarmTitleLabel, FontWeight.Light);

            Func <RelativeLayout, double> getAlarmTitleLabelWidth = (p) => alarmTitleLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(alarmTitleLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getAlarmTitleLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120); }));

            Label amLabel = new Label
            {
                Style                 = Styles.AlarmStyle.ATO006,
                HeightRequest         = 69,
                Text                  = _alarmRecord.ScheduledDateTime.ToString("tt"),
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(amLabel, FontWeight.Light);

            Func <RelativeLayout, double> getAmLabelWidth = (p) => amLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(amLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getAmLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120 + 69 + 100); }));

            Label timeLabel = new Label
            {
                Style         = Styles.AlarmStyle.ATO007,
                HeightRequest = 230,
                Text          = ((App)Application.Current).Is24hourFormat ?
                                _alarmRecord.ScheduledDateTime.ToString("HH:mm") :
                                _alarmRecord.ScheduledDateTime.ToString("hh:mm"),
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(timeLabel, FontWeight.Thin);

            Func <RelativeLayout, double> getTimeLabelWidth = (p) => timeLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(timeLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getTimeLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120 + 69 + 127); }));

            Label dateLabel = new Label
            {
                Style                 = Styles.AlarmStyle.ATO008,
                HeightRequest         = 64,
                Text                  = _alarmRecord.ScheduledDateTime.ToString("ddd, d MMMM"),
                VerticalTextAlignment = TextAlignment.Center,
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(dateLabel, FontWeight.Light);

            Func <RelativeLayout, double> getDateLabelWidth = (p) => dateLabel.Measure(rLayout.Width, rLayout.Height).Request.Width;

            rLayout.Children.Add(dateLabel,
                                 Constraint.RelativeToParent((parent) => { return(parent.Width / 2 - getDateLabelWidth(parent) / 2); }),
                                 Constraint.RelativeToParent((parent) => { return(120 + 69 + 127 + 230); }));
        }
        /// <summary>
        /// Invoked when backbutton is pressed in AlarmEditPage
        /// If there's no changes,
        ///   just go back to AlarmListPage
        /// If there's changes,
        ///   a dialog will be shown and an app user gets an opportunity to save or discard them.
        /// </summary>
        /// <returns>bool</returns>
        protected override bool OnBackButtonPressed()
        {
            // Compare : initial AlarmRecord vs. current AlarmRecord
            bool same = AlarmModel.Compare(originalRecord, AlarmModel.BindableAlarmRecord);

            if (same)
            {
                ((App)Application.Current).floatingButton.Show();
                // Just go back to the previous screen
                return(base.OnBackButtonPressed());
            }
            else
            {
                if (dialog == null)
                {
                    // Cancel button
                    Button cancelButton = new Button
                    {
                        Text = "Cancel",
                    };
                    cancelButton.Clicked += CancelButton_Clicked;

                    // Discard button
                    Button discardButton = new Button
                    {
                        Text = "Discard"
                    };
                    discardButton.Clicked += DiscardButton_Clicked;

                    Label label = new Label
                    {
                        Text     = "All changes will be discarded.",
                        FontSize = 26,
                    };
                    FontFormat.SetFontWeight(label, FontWeight.Light);

                    StackLayout content = new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Margin            = new Thickness(20, 20, 20, 20),
                        Children          =
                        {
                            label
                        },
                        WidthRequest = 720,
                    };

                    // Dialog
                    dialog = new Dialog
                    {
                        HorizontalOption = LayoutOptions.Fill,
                        Title            = "Discard change",
                        Positive         = cancelButton,
                        Neutral          = discardButton,
                        Content          = content
                    };
                }

                dialog.Show();
                return(true);
            }
        }
Beispiel #32
0
 private EPubCoreMediaType ConvertFontToMediaType(FontFormat fontFormat)
 {
     if (fontFormat == FontFormat.WOFF)
     {
         return EPubCoreMediaType.ApplicationFontWoff;
     }
     return EPubCoreMediaType.ApplicationFontMSOpen;
 }
        /// <summary>
        /// Draws alarm list
        /// </summary>
        /// <returns>Returns RelativeLayout</returns>
        protected virtual RelativeLayout Draw()
        {
            /// Need to get bindable context to assign list value
            AlarmRecord alarmData = (AlarmRecord)BindingContext;

            /// If binding context is null, can't proceed further action
            if (alarmData == null)
            {
                return(null);
            }

            alarmData.PrintProperty();

            /// Alarm item layout should be set if null
            if (alarmItemLayout == null)
            {
                // The layout of item cell
                alarmItemLayout = new RelativeLayout
                {
                    HeightRequest = 22 + 93 + 29,
                };

                // Time Label
                timeLabel = new Label()
                {
                    Text = (((App)Application.Current).Is24hourFormat) ?
                           alarmData.ScheduledDateTime.ToString("HH:mm") : alarmData.ScheduledDateTime.ToString("hh:mm"),
                    Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO001D : AlarmStyle.ATO001,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(timeLabel, FontWeight.Light);
                /// Style set for time label for normal case
                timeLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.Time));
                /// Needs to set binding context for scheduled time
                timeLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter(), LabelType.Time));
                // Added to layout
                alarmItemLayout.Children.Add(timeLabel,
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(32);
                }),
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(22);
                }));

                // AM/PM Label
                amPmLabel = new Label()
                {
                    //the text of AM/PM label
                    Text = (((App)Application.Current).Is24hourFormat) ?
                           "" : alarmData.ScheduledDateTime.ToString("tt"),
                    Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO002D : AlarmStyle.ATO002,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(amPmLabel, FontWeight.Light);
                //amPmLabel.IsVisible = (((Tizen.App)Application.Current).Is24hourFormat) ? false : true;
                amPmLabel.SetBinding(Label.IsVisibleProperty, new Binding("AlarmDateFormat", BindingMode.Default, new DateFormatToVisibleConverter()));
                // Set style depending on alarm state
                amPmLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.AmPm));
                amPmLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter(), LabelType.AmPm));
                // Added to layout
                alarmItemLayout.Children.Add(amPmLabel,
                                             Constraint.RelativeToView(timeLabel, (parent, sibling) => sibling.X + sibling.Width + 10),
                                             Constraint.RelativeToView(timeLabel, (parent, sibling) => sibling.Y + 36));

                // Repeat Image
                repeatImage = new Image
                {
                    Source        = "alarm/clock_ic_repeat.png",
                    WidthRequest  = 38,
                    HeightRequest = 38,
                };
                // Bind repeat Image's visibiliy to weekly repeating value
                repeatImage.SetBinding(Image.IsVisibleProperty, new Binding("Repeat", mode: BindingMode.Default));
                // Set repeat image's blending color on alarm state
                ImageAttributes.SetBlendColor(repeatImage, alarmData.AlarmState == AlarmStates.Inactive ? Color.FromHex("66000000") : Color.FromHex("FFFFFF"));
                repeatImage.SetBinding(ImageAttributes.BlendColorProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Repeat));
                // Added to layout
                alarmItemLayout.Children.Add(repeatImage,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => (22 + 93) - (43 + 43)));

                /// Alarm Name Label
                alamNameLabel = new Label();
                /// For alarm name label, to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(alamNameLabel, FontWeight.Normal);
                /// Bind alarm lable's style to alarm state
                alamNameLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Name));
                /// Bind label's text property to AlarmMode's AlarmName.
                alamNameLabel.SetBinding(Label.TextProperty, "AlarmName");
                // Update alarm name label's TranslationX property value according to repeat image's visibility
                alamNameLabel.SetBinding(Label.TranslationXProperty, new Binding("Repeat", BindingMode.OneWay, converter: new AlarmNameLabelPositionConverter()));
                // Bind alarm name label's visibility
                alamNameLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), false));
                //alamNameLabel.Text = alarmData.AlarmName;
                // Added to relative layout
                alarmItemLayout.Children.Add(alamNameLabel,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => (22 + 93 - (43 + 43))));

                /// WeekDays Label
                weekDaysLabel = new Label()
                {
                    FormattedText = alarmData.GetFormatted(alarmData.WeekFlag, alarmData.AlarmState < AlarmStates.Inactive ? true : false),
                    IsVisible     = !alarmData.IsVisibleDateLabel,
                    Style         = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO004D : AlarmStyle.ATO004,
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(weekDaysLabel, FontWeight.Normal);
                /// Style set for time label for normal case
                weekDaysLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Weekly));
                /// Sets binding context for weekdays label
                weekDaysLabel.SetBinding(Label.FormattedTextProperty, new Binding("WeekdayRepeatText", BindingMode.Default));
                weekDaysLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), false));
                /// Adds to relative layout
                alarmItemLayout.Children.Add(weekDaysLabel,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => (22 + 93) - 43));

                // Date label
                // DateLabel is only visible when the alarm name is empty and repeat weekly is Never.
                dateLabel = new Label
                {
                    Text = alarmData.ScheduledDateTime.ToString("ddd, d MMM"),
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(dateLabel, FontWeight.Normal);
                dateLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), true));
                dateLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.Date));
                alarmItemLayout.Children.Add(dateLabel,
                                             Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)),
                                             Constraint.RelativeToParent((parent) => 22));

                /// Switch object to represent that the alarm is active or not
                switchObj = new Switch
                {
                    HeightRequest = 72,
                    WidthRequest  = 72,
                    IsToggled     = alarmData.AlarmState == AlarmStates.Inactive ? false : true,
                };
                /// Bind IsToggled property to alarm state
                //switchObj.SetBinding(Switch.IsToggledProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.State));
                /// Adds to relative layout
                alarmItemLayout.Children.Add(switchObj,
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(720 - 104);
                }),
                                             Constraint.RelativeToParent((parent) =>
                {
                    return(22 + 93 - 72);
                }));

                /// Adds an event
                switchObj.Toggled += (s, e) =>
                {
                    //Switch sObj = s as Switch;
                    ///// Needs valid parent to proceed
                    //if (sObj.Parent == null || sObj.Parent.Parent == null)
                    //{
                    //    return;
                    //}

                    ///// Need binding context to check state
                    //AlarmRecord am = (AlarmRecord)((AlarmListCell)sObj.Parent.Parent).BindingContext;
                    //if (am == null)
                    //{
                    //    return;
                    //}
                    AlarmRecord am = (AlarmRecord)BindingContext;
                    /// Modify state and re-draw it. Redraw must be called to redraw
                    //am.AlarmState = e.Value ? AlarmStates.Active : AlarmStates.Inactive;
                    if (e.Value)
                    {
                        AlarmModel.ReactivatelAlarm(am);
                    }
                    else
                    {
                        AlarmModel.DeactivatelAlarm(am);
                    }

                    AlarmModel.PrintAll("After switch is toggled...");
                };
            }
            else
            {
                switchObj.IsVisible = true;
            }

            return(alarmItemLayout);
        }