コード例 #1
0
 public int GetFontSize(AdaptiveFontStyle fontStyle, AdaptiveTextSize requestedSize)
 {
     return(FontStyles.GetFontStyle(fontStyle).FontSizes.GetFontSize(requestedSize)
            ?? FontStyles.Default.FontSizes.GetFontSize(requestedSize)
            ?? FontSizes.GetFontSize(requestedSize)
            ?? FontSizesConfig.GetDefaultFontSize(requestedSize));
 }
コード例 #2
0
        public static Font GetFontBySize(FontSizes fnSize)
        {
            switch (fnSize)
            {
            case FontSizes.Smallest:
                return(ThemeManager.SmallestFont);

            case FontSizes.Small:
                return(ThemeManager.SmallFont);

            case FontSizes.Large:
                return(ThemeManager.LargeFont);

            case FontSizes.VeryLarge:
                return(ThemeManager.VeryLargeFont);

            case FontSizes.NormalBold:
                return(ThemeManager.NormalBoldFont);

            case FontSizes.ExtremeLarge:
                return(ThemeManager.ExtremeLargeFont);
            }

            return(ThemeManager.NormalFont);
        }
コード例 #3
0
        public static void SetFont(Control ctl, FontSizes size, bool recursive = false)
        {
            try
            {
                if (ctl != null)
                {
                    if (recursive && ctl.Controls != null)
                    {
                        foreach (Control child in ctl.Controls)
                        {
                            SetFont(child, size);
                        }
                    }

                    Font f       = ThemeManager.GetFontBySize(size);
                    Font newFont = new Font(f, f.Style);

                    if (newFont != null)
                    {
                        ctl.Font = newFont;
                        if (ctl is DataGridView)
                        {
                            (ctl as DataGridView).ColumnHeadersDefaultCellStyle.Font = newFont;
                            (ctl as DataGridView).RowTemplate.DefaultCellStyle.Font  = newFont;
                        }
                    }
                }
            }
            catch
            {
            }
        }
コード例 #4
0
        public float GetFontSize(FontSizes size)
        {
            switch (size)
            {
            case FontSizes.Header1:
                return(H1Size);

            case FontSizes.Header2:
                return(H2Size);

            case FontSizes.Header3:
                return(H3Size);

            case FontSizes.Body:
                return(BodySize);

            case FontSizes.Small:
                return(SmallSize);

            case FontSizes.Button:
                return(ButtonSize);

            default:
                return(0);
            }
        }
コード例 #5
0
        public void UpdateFontSize(FontSize fontSize)
        {
            FontSizes.ReCalculateFontSizes(fontSize);

            updateFontSizes?.Invoke();
            ReConfigureSettingsPage();
        }
コード例 #6
0
        public static Label NewLabelString(string text = "", string fontSize = VariablesGlobal.TEXT_SIZE_MEDIUM)
        {
            Label label = new Label {
                Text = text
            };

            label.FontSize = FontSizes.DeviceNamedFontSize(fontSize, label);

            return(label);
        }
コード例 #7
0
        public static Label NewLabelFormattedString(FormattedString formattedText, string fontSize = VariablesGlobal.TEXT_SIZE_MEDIUM)
        {
            Label label = new Label {
                FormattedText = formattedText
            };

            label.FontSize = FontSizes.DeviceNamedFontSize(fontSize, label);

            return(label);
        }
コード例 #8
0
 private bool CheckDefaultFontSize(DocDefaults defaultStyles, StringBuilder comment)
 {
     if (defaultStyles.RunPropertiesDefault?.RunPropertiesBaseStyle?.FontSize == null ||
         !FontSizes.Contains(defaultStyles.RunPropertiesDefault.RunPropertiesBaseStyle.FontSize.Val.ToString()))
     {
         return(false);
     }
     comment.AppendLine(Resources.CheckFontSize);
     return(true);
 }
コード例 #9
0
        public static Entry NewEntry(string text = "", string fontSize = VariablesGlobal.TEXT_SIZE_MEDIUM)
        {
            Entry entry = new Entry
            {
                Text = text,
            };

            entry.FontSize = FontSizes.DeviceNamedFontSize(fontSize, entry);

            return(entry);
        }
コード例 #10
0
        public static Editor NewEditor(string text = "", string fontSize = VariablesGlobal.TEXT_SIZE_MEDIUM, double margin = 0)
        {
            Editor editor = new Editor
            {
                Text   = text,
                Margin = margin,
            };

            editor.FontSize = FontSizes.DeviceNamedFontSize(fontSize, editor);

            return(editor);
        }
コード例 #11
0
        public static Span NewSpan(string text = "", string fontSize = VariablesGlobal.TEXT_SIZE_MEDIUM, FontAttributes fontAttributes = FontAttributes.None, string foregroundColour = "")
        {
            Span span = new Span
            {
                Text           = text,
                FontAttributes = fontAttributes,
            };

            span.ForegroundColor = Validation.ValidateHexCode(foregroundColour);
            span.FontSize        = FontSizes.DeviceNamedFontSize(fontSize, span);

            return(span);
        }
コード例 #12
0
        // Update font size at editor time. Use LateUpdate to avoid conflicts with child classes.
        void LateUpdate()
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (_previousFontSize != FontSize)
            {
                _previousFontSize = FontSize;
                ApplyFontSettings();
            }
        }
コード例 #13
0
 private void PopulateFontSizes()
 {
     for (int i = 8; i <= 28; i++)
     {
         if (i > 12)
         {
             i++;
         }
         FontSizes.Add(i);
     }
     FontSizes.Add(36);
     FontSizes.Add(48);
     FontSizes.Add(72);
 }
コード例 #14
0
        public OPMEditableComboBox()
            : base()
        {
            base.FlatStyle     = FlatStyle.Standard;
            base.DropDownStyle = ComboBoxStyle.DropDown;

            //this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.DoubleBuffered = true;

            this.FontSize = FontSizes.Normal;
        }
コード例 #15
0
        public OPMEditableComboBox()
            : base()
        {
            base.FlatStyle = FlatStyle.Standard;
            base.DropDownStyle = ComboBoxStyle.DropDown;

            //this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.DoubleBuffered = true;

            this.FontSize = FontSizes.Normal;
        }
コード例 #16
0
ファイル: Font.cs プロジェクト: x3nx1a/SadConsole
        private void Initialize(FontMaster masterFont, FontSizes fontMultiple)
        {
            Master        = masterFont;
            FontImage     = masterFont.Image;
            MaxGlyphIndex = masterFont.Rows * masterFont.Columns - 1;

            switch (fontMultiple)
            {
            case FontSizes.Quarter:
                Size = new Point((int)(masterFont.GlyphWidth * 0.25), (int)(masterFont.GlyphHeight * 0.25));
                break;

            case FontSizes.Half:
                Size = new Point((int)(masterFont.GlyphWidth * 0.5), (int)(masterFont.GlyphHeight * 0.5));
                break;

            case FontSizes.One:
                Size = new Point(masterFont.GlyphWidth, masterFont.GlyphHeight);
                break;

            case FontSizes.Two:
                Size = new Point(masterFont.GlyphWidth * 2, masterFont.GlyphHeight * 2);
                break;

            case FontSizes.Three:
                Size = new Point(masterFont.GlyphWidth * 3, masterFont.GlyphHeight * 3);
                break;

            case FontSizes.Four:
                Size = new Point(masterFont.GlyphWidth * 4, masterFont.GlyphHeight * 4);
                break;

            default:
                break;
            }

            if (Size.X == 0 || Size.Y == 0)
            {
                throw new ArgumentException($"This font cannot use size {fontMultiple.ToString()}, at least one axis is 0.", "fontMultiple");
            }

            SizeMultiple    = fontMultiple;
            Name            = masterFont.Name;
            GlyphRects      = masterFont.GlyphIndexRects;
            SolidGlyphIndex = masterFont.SolidGlyphIndex;
            Rows            = masterFont.Rows;
            Columns         = masterFont.Columns;
        }
コード例 #17
0
        protected virtual void OnEnable()
        {
            _text = GetComponent <TextMeshProUGUI>();
            _languageController = GetComponentInParent <LanguageController>();
            _fontController     = FindObjectOfType <FontController>();

            if (!Application.isPlaying)
            {
                return;
            }

            if (_languageController != null)
            {
                _languageController.LanguageChanged += LanguageController_LanguageChanged;
                LanguageController.PropertyChanged  += LanguageController_PropertyChanged;
            }
            else
            {
                Debug.LogWarningFormat("[{0}] {1} must be parented to a {2}.", GetType(), gameObject.name, typeof(LanguageController));
            }

            _previousFontSize = FontSize;
            UpdateText();
        }
コード例 #18
0
ファイル: TextureManager.cs プロジェクト: armonistan/dot-wars
        public void DrawString(SpriteBatch sB, String message, Vector2 loc, Color color, FontSizes fS, bool centered)
        {
            SpriteFont temp;

            switch (fS)
            {
            case FontSizes.tiny:
                temp = tinyFont;
                break;

            case FontSizes.small:
                temp = smallFont;
                break;

            case FontSizes.big:
                temp = bigFont;
                break;

            default:
                throw new ArgumentOutOfRangeException("fS");
            }

            if (centered)
            {
                float offsetX = temp.MeasureString(message).X / 2;
                loc.X -= offsetX;

                float offsetY = temp.MeasureString(message).Y / 2;
                loc.Y -= offsetY;
            }

            sB.DrawString(temp, message, loc, color);
        }
コード例 #19
0
 public static Entry Font(this Entry entry, FontSizes size)
 {
     entry.FontSize = (double)size; return(entry);
 }
コード例 #20
0
ファイル: Font.cs プロジェクト: x3nx1a/SadConsole
 internal Font(FontMaster masterFont, FontSizes fontMultiple)
 {
     Initialize(masterFont, fontMultiple);
 }
コード例 #21
0
 public static Label Font(this Label label, FontSizes size)
 {
     label.FontSize = (double)size; return(label);
 }
コード例 #22
0
ファイル: ThemeManager.cs プロジェクト: rraguso/protone-suite
        public static Font GetFontBySize(FontSizes fnSize)
        {
            switch (fnSize)
            {
                case FontSizes.Smallest:
                    return ThemeManager.SmallestFont;
                case FontSizes.Small:
                    return ThemeManager.SmallFont;
                case FontSizes.Large:
                    return ThemeManager.LargeFont;
                case FontSizes.VeryLarge:
                    return ThemeManager.VeryLargeFont;
                case FontSizes.NormalBold:
                    return ThemeManager.NormalBoldFont;
                case FontSizes.ExtremeLarge:
                    return ThemeManager.ExtremeLargeFont;
            }

            return ThemeManager.NormalFont;
        }
コード例 #23
0
 public static Entry Font(this Entry entry, FontSizes size, FontAttributes attributes) => entry.Font(size).Font(attributes);
コード例 #24
0
        /// <summary>
        /// Loads the class from the specified filname.
        /// </summary>
        /// <param name="filname">The filname.</param>
        /// <remarks>Documented by Dev05, 2007-08-03</remarks>
        public void Load(string filname)
        {
            Stream        inputStream = File.OpenRead(filname);
            XmlSerializer serializer  = new XmlSerializer(typeof(Settings));
            Settings      tmpSettings;

            try
            {
                tmpSettings = (Settings)serializer.Deserialize(inputStream);

                ActualCard = tmpSettings.ActualCard;
                Dictionary = tmpSettings.Dictionary;
                FontSize   = tmpSettings.FontSize;

                Side           = tmpSettings.Side;
                Sentence       = tmpSettings.Sentence;
                RecordingOrder = tmpSettings.RecordingOrder;
                ActualStep     = tmpSettings.ActualStep;

                RecordQuestion        = tmpSettings.RecordQuestion;
                RecordQuestionExample = tmpSettings.RecordQuestionExample;
                RecordAnswer          = tmpSettings.RecordAnswer;
                RecordAnswerExample   = tmpSettings.RecordAnswerExample;

                StartDelay   = tmpSettings.StartDelay;
                StopDelay    = tmpSettings.StopDelay;
                DelaysActive = tmpSettings.DelaysActive;

                CodecSettings   = tmpSettings.CodecSettings;
                SelectedEncoder = tmpSettings.SelectedEncoder;
                SamplingRate    = tmpSettings.SamplingRate;
                Channels        = tmpSettings.Channels;

                AdvancedView       = tmpSettings.AdvancedView;
                KeyboardLayout     = tmpSettings.KeyboardLayout;
                AskLayoutAtStartup = tmpSettings.AskLayoutAtStartup;
                PresenterActivated = tmpSettings.PresenterActivated;

                AllowMultipleAssignment = tmpSettings.AllowMultipleAssignment;

                NumLockSwitchSleepTime = tmpSettings.NumLockSwitchSleepTime;

                foreach (KeyValuePair <Keys, Function> keyValuePair in tmpSettings.KeyFunctions)
                {
                    KeyFunctions[keyValuePair.Key] = keyValuePair.Value;
                }
                foreach (KeyValuePair <Keys, Function> keyValuePair in tmpSettings.KeyboardFunctions)
                {
                    KeyboardFunctions[keyValuePair.Key] = keyValuePair.Value;
                }

                if (tmpSettings.PresenterKeyFunctions.Count > 0)
                {
                    PresenterKeyFunctions.Clear();
                    foreach (KeyValuePair <Keys, Function> keyValuePair in tmpSettings.PresenterKeyFunctions)
                    {
                        PresenterKeyFunctions.Add(keyValuePair.Key, keyValuePair.Value);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                inputStream.Close();
            }
        }
コード例 #25
0
ファイル: Font.cs プロジェクト: Thraka/SadConsole
        private void Initialize(FontMaster masterFont, FontSizes fontMultiple)
        {
            FontImage = masterFont.Image;
            MaxGlyphIndex = masterFont.Rows * masterFont.Columns - 1;

            switch (fontMultiple)
            {
                case FontSizes.Quarter:
                    Size = new Point((int)(masterFont.GlyphWidth * 0.25), (int)(masterFont.GlyphHeight * 0.25));
                    break;
                case FontSizes.Half:
                    Size = new Point((int)(masterFont.GlyphWidth * 0.5), (int)(masterFont.GlyphHeight * 0.5));
                    break;
                case FontSizes.One:
                    Size = new Point(masterFont.GlyphWidth, masterFont.GlyphHeight);
                    break;
                case FontSizes.Two:
                    Size = new Point(masterFont.GlyphWidth * 2, masterFont.GlyphHeight * 2);
                    break;
                case FontSizes.Three:
                    Size = new Point(masterFont.GlyphWidth * 3, masterFont.GlyphHeight * 3);
                    break;
                case FontSizes.Four:
                    Size = new Point(masterFont.GlyphWidth * 4, masterFont.GlyphHeight * 4);
                    break;
                default:
                    break;
            }

            if (Size.X == 0 || Size.Y == 0)
                throw new ArgumentException($"This font cannot use size {fontMultiple.ToString()}, at least one axis is 0.", "fontMultiple");

            SizeMultiple = fontMultiple;
            Name = masterFont.Name;
            GlyphIndexRects = masterFont.GlyphIndexRects;
            SolidGlyphIndex = masterFont.SolidGlyphIndex;
            Rows = masterFont.Rows;
            Columns = masterFont.Columns;
        }
コード例 #26
0
        public void DoCheck(WordprocessingDocument document)
        {
            //Получить текущие стили
            var defaultStyles = document.GetDefaultStyles();
            var allStyles     = document.GetStyles();

            //Собрать все параграфы
            var paragraphs = document.MainDocumentPart.Document.Body.Descendants <Paragraph>();

            foreach (var paragraph in paragraphs)
            {
                foreach (var run in paragraph.Descendants <Run>())
                {
                    var comment       = new StringBuilder();
                    var runProperties = run.Descendants <RunProperties>();

                    bool fontSizeErr    = !(FontSizes.Length > 0);
                    bool runFontsErr    = !(RunFontsNames.Length > 0);
                    bool lineSpacingErr = !(LineSpacing.Length > 0);

                    foreach (var rp in runProperties)
                    {
                        if (!fontSizeErr && rp.FontSize != null)
                        {
                            if (!FontSizes.Contains(rp.FontSize.Val.ToString()))
                            {
                                comment.AppendLine(Resources.CheckFontSize);
                                fontSizeErr = true;
                            }
                        }
                        else if (!fontSizeErr && rp.RunStyle != null)
                        {
                            var currentStyle = allStyles.FindById(rp.RunStyle.Val);
                            if (currentStyle == null)
                            {
                                continue;
                            }

                            var fontSize = FindFirstFontSize(currentStyle, allStyles);
                            if (fontSize != null && !FontSizes.Contains(fontSize))
                            {
                                comment.AppendLine(Resources.CheckFontSize);
                                fontSizeErr = true;
                            }
                            else
                            {
                                fontSizeErr = CheckDefaultFontSize(defaultStyles, comment);
                            }
                        }
                        else if (!fontSizeErr)
                        {
                            fontSizeErr = CheckDefaultFontSize(defaultStyles, comment);
                        }



                        if (!runFontsErr && rp.RunFonts != null)
                        {
                            if ((rp.RunFonts.Ascii != null && rp.RunFonts.Ascii.HasValue && !RunFontsNames.Contains(rp.RunFonts.Ascii.Value)) ||
                                (rp.RunFonts.ComplexScript != null && rp.RunFonts.ComplexScript.HasValue &&
                                 !RunFontsNames.Contains(rp.RunFonts.ComplexScript.Value)) ||
                                (rp.RunFonts.HighAnsi != null && rp.RunFonts.HighAnsi.HasValue && !RunFontsNames.Contains(rp.RunFonts.HighAnsi.Value)))
                            {
                                comment.AppendLine(Resources.CheckFont);
                                fontSizeErr = true;
                            }
                        }
                        else if (!runFontsErr && rp.RunStyle != null)
                        {
                            var currentStyle = allStyles.FindById(rp.RunStyle.Val);
                            if (currentStyle == null)
                            {
                                continue;
                            }

                            var runFonts = FindFonts(currentStyle, allStyles);
                            if (runFonts != null &&
                                (
                                    (runFonts.Ascii != null && runFonts.Ascii.HasValue && !RunFontsNames.Contains(runFonts.Ascii.Value)) ||
                                    (runFonts.ComplexScript != null && runFonts.ComplexScript.HasValue &&
                                     !RunFontsNames.Contains(runFonts.ComplexScript.Value))
                                ))
                            {
                                comment.AppendLine(Resources.CheckFont);
                                runFontsErr = true;
                            }
                            else
                            {
                                runFontsErr = CheckDefaultRunFonts(defaultStyles, comment);
                            }
                        }
                        else if (!runFontsErr)
                        {
                            runFontsErr = CheckDefaultRunFonts(defaultStyles, comment);
                        }
                        //Otstupi

                        if (!lineSpacingErr && rp.Spacing != null)
                        {
                            if (!LineSpacing.Contains(rp.Spacing.Val.ToString()))
                            {
                                comment.AppendLine(Resources.CheckLineSpacing);
                                fontSizeErr = true;
                            }
                        }
                        else if (!fontSizeErr && rp.RunStyle != null)
                        {
                            var currentStyle = allStyles.FindById(rp.RunStyle.Val);
                            if (currentStyle == null)
                            {
                                continue;
                            }


                            //Тут остановился. Ищем межстрочний интервал
                            var fontSize = FindFirstFontSize(currentStyle, allStyles);
                            if (fontSize != null && !FontSizes.Contains(fontSize))
                            {
                                comment.AppendLine(Resources.CheckFontSize);
                                fontSizeErr = true;
                            }
                            else
                            {
                                fontSizeErr = CheckDefaultFontSize(defaultStyles, comment);
                            }
                        }
                        else if (!fontSizeErr)
                        {
                            fontSizeErr = CheckDefaultFontSize(defaultStyles, comment);
                        }
                    }

                    //Добавим коммент
                    if (comment.Length > 0)
                    {
                        document.AddCommentNearElement(run, _author, comment.ToString());
                    }
                }
            }


            //Проверить интервалы
        }
コード例 #27
0
ファイル: Font.cs プロジェクト: Thraka/SadConsole
 internal Font(FontMaster masterFont, FontSizes fontMultiple)
 {
     Initialize(masterFont, fontMultiple);
 }
コード例 #28
0
        public override void LoadAsync()
        {
            //Task.Factory.StartNew(() =>
            //    {
                    lock (UserVMs)
                    {
                        var users = RoomClient.GetRoomUsers(RoomVM.Id);
                        if (users != null && users.Length > 0)
                        {
                            foreach (var user in users)
                            {
                                UserEntered(user, false);
                            }
                        }
                    }

                    var micUsers = RoomClient.GetMicUsers(RoomVM.Id, MicType.Public);
                    if (micUsers != null && micUsers.Count > 0)
                    {
                        if (micUsers.ContainsKey(0) && micUsers[0].MicStatus != MicStatusMessage.MicStatus_Off)
                        {
                            FirstMicUserVM = UserVMs.FirstOrDefault(u => u.Id == micUsers[0].UserId);
                            FirstMicUserVM.OnMic(MicType.Public, 0, micUsers[0].StreamGuid, micUsers[0].MicStatus);
                            if ((FirstMicUserVM.MicStatus & MicStatusMessage.MicStatus_Audio) != MicStatusMessage.MicStatus_Off)
                            {
                                StartAudioPlaying(FirstMicUserVM.Id);
                            }
                        }
                        if (micUsers.ContainsKey(1) && micUsers[1].MicStatus != MicStatusMessage.MicStatus_Off)
                        {
                            SecondMicUserVM = UserVMs.FirstOrDefault(u => u.Id == micUsers[1].UserId);
                            SecondMicUserVM.OnMic(MicType.Public, 1, micUsers[1].StreamGuid, micUsers[1].MicStatus);
                            if ((SecondMicUserVM.MicStatus & MicStatusMessage.MicStatus_Audio) != MicStatusMessage.MicStatus_Off)
                            {
                                StartAudioPlaying(SecondMicUserVM.Id);
                            }
                        }
                        if (micUsers.ContainsKey(2) && micUsers[2].MicStatus != MicStatusMessage.MicStatus_Off)
                        {
                            ThirdMicUserVM = UserVMs.FirstOrDefault(u => u.Id == micUsers[2].UserId);
                            ThirdMicUserVM.OnMic(MicType.Public, 2, micUsers[2].StreamGuid, micUsers[2].MicStatus);
                            if ((ThirdMicUserVM.MicStatus & MicStatusMessage.MicStatus_Audio) != MicStatusMessage.MicStatus_Off)
                            {
                                StartAudioPlaying(ThirdMicUserVM.Id);
                            }
                        }
                    }


                    micUsers = RoomClient.GetMicUsers(RoomVM.Id, MicType.Private);
                    if (micUsers != null && micUsers.Count > 0)
                    {
                        foreach (var mic in micUsers.Values)
                        {
                            if (mic.MicStatus != MicStatusMessage.MicStatus_Off)
                            {
                                var uvm = UserVMs.FirstOrDefault(u => u.Id == mic.UserId);
                                if (uvm != null)
                                {
                                    PrivateMicUserVMs.Add(uvm);
                                    uvm.OnMic(MicType.Private, mic.MicIndex, mic.StreamGuid, mic.MicStatus);
                                    if ((uvm.MicStatus & MicStatusMessage.MicStatus_Audio) != MicStatusMessage.MicStatus_Off)
                                    {
                                        StartAudioPlaying(uvm.Id);
                                    }
                                }
                            }
                        }
                    }

                    micUsers = RoomClient.GetMicUsers(RoomVM.Id, MicType.Secret);
                    if (micUsers != null && micUsers.Count > 0)
                    {
                        foreach (var mic in micUsers.Values)
                        {
                            if (mic.MicStatus != MicStatusMessage.MicStatus_Off)
                            {
                                var uvm = UserVMs.FirstOrDefault(u => u.Id == mic.UserId);
                                if (uvm != null)
                                {
                                    SecretMicUserVMs.Add(uvm);
                                    uvm.OnMic(MicType.Secret, mic.MicIndex, mic.StreamGuid, mic.MicStatus);
                                    if ((uvm.MicStatus & MicStatusMessage.MicStatus_Audio) != MicStatusMessage.MicStatus_Off)
                                    {
                                        StartAudioPlaying(uvm.Id);
                                    }
                                }
                            }
                        }
                    }

                    RoomMessage msg = RoomClient.GetRoomMessage(RoomMessageType.GiftMessage);
                    if (msg != null)
                    {
                        UserViewModel sender = null;
                        UserViewModel receiver = null;
                        lock (UserVMs)
                        {
                            sender = UserVMs.FirstOrDefault(u => u.Id == msg.SenderId);
                            if (sender == null)
                            {
                                sender = ApplicationVM.LocalCache.AllUserVMs[msg.SenderId];
                                if (sender == null)
                                {
                                    var usr = RoomClient.GetUser(msg.SenderId);
                                    if (usr != null)
                                    {
                                        sender = new UserViewModel(usr);
                                        sender.Initialize();
                                        ApplicationVM.LocalCache.AllUserVMs[msg.SenderId] = sender;
                                    }
                                }
                                else 
                                {
                                    if (!sender.IsInitialized)
                                    {
                                        sender.Initialize();
                                    }
                                }
                            }
                            receiver = UserVMs.FirstOrDefault(u => u.Id == msg.ReceiverId);
                            if (receiver == null)
                            {
                                receiver = ApplicationVM.LocalCache.AllUserVMs[msg.ReceiverId];
                                if (receiver == null)
                                {
                                    var usr = RoomClient.GetUser(msg.ReceiverId);
                                    if (usr != null)
                                    {
                                        receiver = new UserViewModel(usr);
                                        receiver.Initialize();
                                        ApplicationVM.LocalCache.AllUserVMs[msg.ReceiverId] = receiver;
                                    }
                                }
                                else
                                {
                                    if (!receiver.IsInitialized)
                                    {
                                        receiver.Initialize();
                                    }
                                }
                            }
                        }
                        GiftViewModel gift = ApplicationVM.LocalCache.AllGiftVMs.FirstOrDefault(g => g.Id == msg.ItemId);
                        if (sender != null && receiver != null && gift != null)
                        {
                            string header = "<img title='" + sender.RoleVM.Name + "' src='" + sender.ImageVM.StaticImageFile + "'><u style='color:gold;margin-right:10px'><span  onclick='window.external.SelectUser(" + sender.Id + ")'" +
                                       " oncontextmenu='window.external.SelectUser(" + sender.Id + ")'/>" + sender.NickName + "(" + sender.Id + ")" + "</span></u></img> 送给 " +
                                       "<img title='" + receiver.RoleVM.Name + "' src='" + receiver.ImageVM.StaticImageFile + "'><u style='color:purple;margin-left:10px;margin-right:10px'><span onclick='window.external.SelectUser(" + receiver.Id + ")'" +
                                       "oncontextmenu='window.external.SelectUser(" + receiver.Id + ")'/>" + receiver.NickName + "(" + receiver.Id + ")" + "</span></u></img>";
                            string htmlmsg = string.Empty;
                            htmlmsg += "<img style='margin-left:20px;margin-right:20px;' src='" + gift.ImageVM.DynamicImageFile + "'/>";
                            htmlmsg += header + msg.Count + gift.Unit + gift.Name +
                                "<span style='color:blue'>" + msg.Time + "</span>";
                            CallJavaScript("ScrollMessage", htmlmsg);
                        }
                    }

                    XmlLanguage enus = XmlLanguage.GetLanguage("en-us");
                    XmlLanguage zhcn = XmlLanguage.GetLanguage("zh-cn");
                    string fontname = "";
                    foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
                    {
                        if (fontfamily.FamilyNames.ContainsKey(zhcn))
                        {
                            fontfamily.FamilyNames.TryGetValue(zhcn, out fontname);
                            FontFamilies.Insert(0, fontname);
                        }
                        else if (fontfamily.FamilyNames.ContainsKey(enus))
                        {
                            fontfamily.FamilyNames.TryGetValue(enus, out fontname);
                            FontFamilies.Add(fontname);
                        }
                    }

                    FontSizes.Add(14);
                    FontSizes.Add(16);
                    FontSizes.Add(18);
                    FontSizes.Add(20);
                    FontSizes.Add(22);
                    FontSizes.Add(24);
                    FontSizes.Add(28);
                    FontSizes.Add(32);
                    FontSizes.Add(36);

                    CallJavaScript("InitUsers", UsersJson);
                    CallJavaScript("InitFonts", FontFamiliesJson, FontSizesJson);
                    CallJavaScript("InitStamp", StampImagesJson);
                    for (int i = 0; i < MotionImagesJson.Count; i++)
                    {
                        CallJavaScript("InitFaceTab", MotionImagesJson[i], i == MotionImagesJson.Count - 1);
                    }
                    
                    CallJavaScript("InitMoneyForHorn", ApplicationVM.LocalCache.HornMsgMoney, ApplicationVM.LocalCache.HallHornMsgMoney, ApplicationVM.LocalCache.GlobalHornMsgMoney);

                    int scoreToMoney = 0;
                    if (ApplicationVM.LocalCache.AllExchangeRateVMs.Count > 0)
                    {
                        try
                        {
                            var exchangeVM = ApplicationVM.LocalCache.AllExchangeRateVMs.OrderBy(r => r).Where(r =>
                                Convert.ToDateTime(r.ValidTime) >= (DateTime.Now)).ToList().FirstOrDefault();
                            if (exchangeVM != null)
                            {
                                scoreToMoney = exchangeVM.ScoreToMoney;
                            }
                        }
                        catch (Exception ex)
                        { }
                    }

                    CallJavaScript("InitExchangeRate", scoreToMoney);
                    
                //});
        }
コード例 #29
0
 public static Button Font(this Button button, FontSizes size)
 {
     button.FontSize = (double)size; return(button);
 }
コード例 #30
0
 public static Button Font(this Button button, FontSizes size, FontAttributes attributes) => button.Font(size).Font(attributes);
コード例 #31
0
ファイル: ThemeManager.cs プロジェクト: rraguso/protone-suite
        public static void SetFont(Control ctl, FontSizes size, bool recursive = false)
        {
            try
            {
                if (ctl != null)
                {
                    if (recursive && ctl.Controls != null)
                    {
                        foreach (Control child in ctl.Controls)
                        {
                            SetFont(child, size);
                        }
                    }

                    Font f = ThemeManager.GetFontBySize(size);
                    Font newFont = new Font(f, f.Style);

                    if (newFont != null)
                    {
                        ctl.Font = newFont;
                        if (ctl is DataGridView)
                        {
                            (ctl as DataGridView).ColumnHeadersDefaultCellStyle.Font = newFont;
                            (ctl as DataGridView).RowTemplate.DefaultCellStyle.Font = newFont;
                        }
                    }
                }
            }
            catch
            {
            }
        }
コード例 #32
0
 public static Label Font(this Label label, FontSizes size, FontAttributes attributes) => label.Font(size).Font(attributes);
コード例 #33
0
 private void AddCustomFontSize(int value)
 {
     FontSizes.Add(value);
     // Automatically set as selected font size
     SelectedFontSize = value;
 }
コード例 #34
0
ファイル: Settings.cs プロジェクト: Stoner19/Memory-Lifter
        /// <summary>
        /// Loads the class from the specified filname.
        /// </summary>
        /// <param name="filname">The filname.</param>
        /// <remarks>Documented by Dev05, 2007-08-03</remarks>
        public void Load(string filname)
        {
            Stream inputStream = File.OpenRead(filname);
            XmlSerializer serializer = new XmlSerializer(typeof(Settings));
            Settings tmpSettings;
            try
            {
                tmpSettings = (Settings)serializer.Deserialize(inputStream);

                ActualCard = tmpSettings.ActualCard;
                Dictionary = tmpSettings.Dictionary;
                FontSize = tmpSettings.FontSize;

                Side = tmpSettings.Side;
                Sentence = tmpSettings.Sentence;
                RecordingOrder = tmpSettings.RecordingOrder;
                ActualStep = tmpSettings.ActualStep;

                RecordQuestion = tmpSettings.RecordQuestion;
                RecordQuestionExample = tmpSettings.RecordQuestionExample;
                RecordAnswer = tmpSettings.RecordAnswer;
                RecordAnswerExample = tmpSettings.RecordAnswerExample;

                StartDelay = tmpSettings.StartDelay;
                StopDelay = tmpSettings.StopDelay;
                DelaysActive = tmpSettings.DelaysActive;

                CodecSettings = tmpSettings.CodecSettings;
                SelectedEncoder = tmpSettings.SelectedEncoder;
                SamplingRate = tmpSettings.SamplingRate;
                Channels = tmpSettings.Channels;

                AdvancedView = tmpSettings.AdvancedView;
                KeyboardLayout = tmpSettings.KeyboardLayout;
                AskLayoutAtStartup = tmpSettings.AskLayoutAtStartup;
                PresenterActivated = tmpSettings.PresenterActivated;

                AllowMultipleAssignment = tmpSettings.AllowMultipleAssignment;

                NumLockSwitchSleepTime = tmpSettings.NumLockSwitchSleepTime;

                foreach (KeyValuePair<Keys, Function> keyValuePair in tmpSettings.KeyFunctions)
                    KeyFunctions[keyValuePair.Key] = keyValuePair.Value;
                foreach (KeyValuePair<Keys, Function> keyValuePair in tmpSettings.KeyboardFunctions)
                    KeyboardFunctions[keyValuePair.Key] = keyValuePair.Value;

                if (tmpSettings.PresenterKeyFunctions.Count > 0)
                {
                    PresenterKeyFunctions.Clear();
                    foreach (KeyValuePair<Keys, Function> keyValuePair in tmpSettings.PresenterKeyFunctions)
                        PresenterKeyFunctions.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                inputStream.Close();
            }
        }