public ChatWindowTextViewModel(IChatWindowTextSetting setting) { FontSize = setting.FontSize; FontFamilyName = setting.FontFamilyName; IsFontBold = setting.IsFontBold; IsFontItalic = setting.IsFontItalic; AssignToSetting(setting); }
/// <summary> /// モデルおよび設定を用いてインスタンスを初期化します。 /// </summary> /// <param name="model">必要な描画物を実際に用意するモデル</param> /// <param name="mainWindow">位置決めに使うための親ウィンドウ</param> /// <param name="shownCharacterNameSetting">表示名の設定</param> /// <param name="textSetting">テキストのフォント設定</param> /// <param name="colorSetting">色の設定</param> /// <param name="layoutSetting">配置の設定</param> public ChatWindowViewModel( IChatWindowModel model, IMainWindow mainWindow, IShownCharacterNameSetting shownCharacterNameSetting, IChatWindowTextSetting textSetting, IChatWindowColorSetting colorSetting ) { Position = new ChatWindowPositionViewModel(model.Position); CharacterName = new ShownCharacterNameViewModel(shownCharacterNameSetting); TextFont = new ChatWindowTextViewModel(textSetting); Color = new ChatWindowColorViewModel(colorSetting); Appearance = new ChatWindowAppearanceViewModel(this); AssignToModel(model); SyncTopmostToMainWindow(mainWindow); }
private void AssignToSetting(IChatWindowTextSetting setting) { PropertyChanged += (_, e) => { if (e.PropertyName == nameof(FontSize)) { setting.FontSize = FontSize; } else if (e.PropertyName == nameof(FontFamilyName)) { setting.FontFamilyName = FontFamilyName; } else if (e.PropertyName == nameof(IsFontBold)) { setting.IsFontBold = IsFontBold; } else if (e.PropertyName == nameof(IsFontItalic)) { setting.IsFontItalic = IsFontItalic; } }; PropertyChangedEventManager.AddHandler(setting, OnModelPropertyChanged, string.Empty); }