/// <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; }
/// <summary> /// デバイスマネージャと設定を指定して新しいShellウィンドウを作成します. /// </summary> public ShellWindow( GraphicDeviceManager deviceManager, ShellHookWindow shellHook, ShellGlobalConfig globalConfig) { ShowActivated = false; _deviceManager = deviceManager; _shellHook = shellHook; _globalConfig = globalConfig; globalConfig.Substituted += globalConfig_Substituted; // フックの登録 shellHook.WindowActivated += shellHook_WindowActivated; // ウィンドウサイズの決定 var wndSize = new Size(1, 1); //// // 描画用コンテキストの準備 // レンダーコンテキストの作成 _renderContext = RenderContext.CreateContext(deviceManager); // GDI互換コンテクストの初期化 _gdiContext = new GdiCompatibleContext(deviceManager); _gdiContext.TargetsInitialized += context_TargetsInitialized; _gdiContext.TargetsDestroying += context_TargetsDestroying; // MMF描画コンテクストの初期化 var camera = new BasicCamera(new Vector3(0, 0, -1000), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); var projection = new OrthogonalProjectionMatrixProvider(); projection.InitializeProjection( wndSize.Width / globalConfig.PixelPerUnitLength, wndSize.Height / globalConfig.PixelPerUnitLength, 1, 2000); var matrixManager = new MatrixManager(new BasicWorldMatrixProvider(), camera, projection); _textureTargetContext = new TextureTargetContext(_renderContext, matrixManager, wndSize, new SampleDescription(globalConfig.MultiSampleCount, globalConfig.MultiSampleQuality)) { BackgroundColor = new Color4(0) }; _renderContext.LightManager = new LightMatrixManager(_textureTargetContext.MatrixManager); _renderContext.Timer = new MotionTimer(_renderContext); _renderContext.UpdateRequireWorlds.Add(_textureTargetContext.WorldSpace); // ウィンドウサイズの適用 Size = wndSize; Opacity = _globalConfig.Opacity; // 追加のフラグを指定して作成 WindowStylesEx extra = WindowStylesEx.ToolWindow | WindowStylesEx.TopMost; if (globalConfig.PerviousMouse) { extra |= WindowStylesEx.Transparent; } base.Create(extra); }
/// <summary> /// 入力ログファイルを指定して,インスタンスを初期化します. /// </summary> /// <param name="inputLogFile">入力のログファイル</param> /// <param name="shellHook">シェルフックウィンドウ</param> /// <param name="config">設定</param> public UserInputWindow(string inputLogFile, ShellHookWindow shellHook, UserInputConfig config) { _logFile = inputLogFile; _shellHook = shellHook; _config = config; shellHook.WindowActivated += shellHook_WindowActivated; InitializeComponent(); // フックの開始 _hookProc = HookCallback; // アンマネージに渡すデリゲートのライフタイムは自分で管理する! _hHook = User.SetWindowsHookEx(WindowsHook.KeyboardLL, _hookProc, IntPtr.Zero, 0); }