/// <summary> /// 基本ディレクトリを指定してマネージャを初期化します. /// </summary> /// <param name="path">バルーンのある基本ディレクトリ.</param> public BaloonManager(string path, ShellHookWindow shellHook, BaloonGlobalConfig globalConfig) { rootDir = path; this.shellHook = shellHook; this.globalConfig = globalConfig; var serializer = new XmlSerializer(typeof(BaloonConfig)); foreach (string dir in Directory.EnumerateDirectories(rootDir)) { try { using (var r = new StreamReader(dir + @"\description.xml")) { var config = (BaloonConfig)serializer.Deserialize(r); config.BaseDirectory = dir; configs.Add(config.Guid, config); } } catch (FileNotFoundException) { } // ファイル見つからない catch (InvalidOperationException) { } // シリアライズ失敗 } }
/// <summary> /// 新しいインスタンスを初期化します. /// </summary> public BaloonWindow(BaloonConfig config, ShellHookWindow shellHook, BaloonGlobalConfig globalConfig) { this._globalConfig = globalConfig; this._config = config; this._shellHook = shellHook; InitializeComponent(); // 段落を設定 _paragraph = new Paragraph(); document.Blocks.Add(_paragraph); // タイムアウトタイマーの初期化 _timeoutTimer = new DispatcherTimer( TimeSpan.FromSeconds(globalConfig.TimeoutInSecond), DispatcherPriority.Normal, (object _, EventArgs __) => { _timeoutTimer.Stop(); Hide(); }, Dispatcher) { IsEnabled = false }; GetStoryboard("fadeout").Completed += Fadeout_Completed; }