/// <summary>
        /// TextListCountの変更イベントハンドラ
        /// </summary>
        /// <param name="dOjd"></param>
        /// <param name="eArgs"></param>
        private static void TextListCountPropertyChanged(DependencyObject dOjd, DependencyPropertyChangedEventArgs eArgs)
        {
            try
            {
                FlyingCommentsWindow wnd = dOjd as FlyingCommentsWindow;

                // コメントを飛ばす処理を実行
                wnd?.FlyingComment();
            }
            catch (Exception ex)
            {
                _logger.Error($"ウインドウの透明化フラグの変更イベントハンドラで例外 {ex.Message}");
            }
        }
        /// <summary>
        /// ウインドウの透明化フラグの変更イベントハンドラ
        /// </summary>
        /// <param name="dOjd"></param>
        /// <param name="eArgs"></param>
        private static void StealthPropertyChanged(DependencyObject dOjd, DependencyPropertyChangedEventArgs eArgs)
        {
            try
            {
                FlyingCommentsWindow wnd = dOjd as FlyingCommentsWindow;

                // コメントウィンドウの再作成
                wnd.RenewWindow();
            }
            catch (Exception ex)
            {
                _logger.Error($"ウインドウの透明化フラグの変更イベントハンドラで例外 {ex.Message}");
            }
        }
        /// <summary>
        /// 透明化の為にウインドウの再作成
        /// ※ WindowStyleの変更はShowをする前にしか変更できないため
        /// </summary>
        private void RenewWindow()
        {
            AppModel model = DataContext as AppModel;

            if (model != null)
            {
                // 現在の状態と透明化フラグの状態に差異があるか確認
                if (
                    (model.Stealth == true && WindowStyle == WindowStyle.None) ||
                    (model.Stealth == false && WindowStyle == WindowStyle.SingleBorderWindow)

                    )
                {
                    // 差異が無い場合は、何もしない
                }
                else
                {
                    // 透明化の状態と現在のWindowの状態が異なる時

                    // 新しいWindowを作成して、自身のModelを渡す。
                    FlyingCommentsWindow newWind = new FlyingCommentsWindow(DataContext as AppModel);

                    // 位置とサイズをコピー
                    newWind.Top         = Top;
                    newWind.Left        = Left;
                    newWind.Width       = Width;
                    newWind.Height      = Height;
                    newWind.WindowState = WindowState;

                    //newWind.DataContext = DataContext;
                    //newWind.Owner = Owner;

                    // 旧ウィンドウを閉じる
                    ManualColse();

                    // 旧ウィンドウとモデルを切断
                    DataContext = null;

                    // 新ウィンドウを表示する
                    newWind.Show();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            App ap = Application.Current as App;

            DataContext = ap.Model;
            AppModel model = DataContext as AppModel;

            // ウインドウの位置とサイズを指定
            Left   = model.SettingWndRect.Left;
            Top    = model.SettingWndRect.Top;
            Width  = model.SettingWndRect.Width;
            Height = model.SettingWndRect.Height;

            //コメントウインドウを作成
            FlyingCommentsWindow newWnd = new FlyingCommentsWindow(DataContext as AppModel);

            newWnd.Show();


            // フォント選択コンボBoxにシステムのフォント一覧を設定
            m_FontName.ItemsSource = Fonts.SystemFontFamilies;
        }