Example #1
0
        /// <summary>APIの処理を実際に担当できるサブモジュールを用いてインスタンスを初期化します。</summary>
        /// <param name="window">キャラ表示ウィンドウ</param>
        /// <param name="character">実際のキャラクター</param>
        /// <param name="voiceOperator">発声処理器</param>
        /// <param name="chatWindow">チャット枠</param>
        /// <param name="requestor">スクリプト実行要求器</param>
        /// <param name="setting">設定事項</param>
        /// <param name="characterName">キャラクター名</param>
        public ScriptApi(
            IMainWindow window,
            IHarrietCharacter character,
            IVoiceOperator voiceOperator,
            IChatWindowModel chatWindow,
            IScriptRequestor requestor,
            CharacterSetting setting,
            IScriptApiSetting scriptApiSetting,
            string characterName
            )
        {
            this.Window = window;
            this.Character = character;
            this._voiceOperater = voiceOperator;
            this.ChatWindow = chatWindow;
            this.CharacterName = characterName;
            this.Setting = new SettingWindowViewModel(setting);
            this.ScriptRequest = requestor;

            _keyboardHook = new KeyboardHook(OnKeyboardUpDown);

            ////プラグインがあったら拾い、無かったら無視
            //try
            //{
            //    TextConverter = TextToPronounceConverterLoader.Load().FirstOrDefault() ??
            //                    new ImeTextConverter(); 
            //}
            //catch(Exception)
            //{
            //    TextConverter = new ImeTextConverter();
            //}

            _scriptApiSetting = scriptApiSetting;
        }
Example #2
0
        /// <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);
        }
Example #3
0
        private void AssignToModel(IChatWindowModel chatWindow)
        {
            PropertyChangedEventManager.AddHandler(
                chatWindow,
                (_, __) => Content = chatWindow.Content,
                nameof(chatWindow.Content));

            WeakEventManager<IChatWindowModel, EventArgs>.AddHandler(
                chatWindow,
                nameof(chatWindow.Closing),
                (_, __) => Close()
                );

            WeakEventManager<IChatWindowModel, EventArgs>.AddHandler(
                chatWindow,
                nameof(chatWindow.HideRequested),
                (_, __) => Appearance.HideCommand.Execute()
                );

            GoNextRequested += (_, __) => chatWindow.Flush();
        }