Esempio n. 1
0
        public InfoWindow(InfoWindowViewModel dataContext)
        {
            InitializeComponent();

            notifyIcon.Icon        = Properties.Resources.TaskIconInfo;
            notifyIcon.Text        = "予約簡易表示 (EpgTimer)";
            notifyIcon.MouseClick += NotifyIcon_MouseClick;
            notifyIcon.Visible     = true;

            // notify icon用メニューの設定
            var menu = new System.Windows.Forms.ContextMenuStrip();

            ToolStripMenuItem topmostMenu = new ToolStripMenuItem();

            topmostMenu.Text    = "最前面に表示";
            topmostMenu.Checked = dataContext.IsTopMost;
            topmostMenu.Click  += (s, e) => { dataContext.IsTopMost = !dataContext.IsTopMost; };
            menu.Items.Add(topmostMenu);

            ToolStripMenuItem bottommostMenu = new ToolStripMenuItem();

            bottommostMenu.Text    = "最背面に表示";
            bottommostMenu.Checked = dataContext.IsBottomMost;
            bottommostMenu.Click  += (s, e) => { dataContext.IsBottomMost = !dataContext.IsBottomMost; };
            menu.Items.Add(bottommostMenu);

            ToolStripMenuItem closeMenu = new ToolStripMenuItem();

            closeMenu.Text   = "消す";
            closeMenu.Click += (s, e) => TrueClose();
            menu.Items.Add(closeMenu);
            notifyIcon.ContextMenuStrip = menu;

            // notify icon用メニュー内の checkbox 更新用イベントハンドラ追加
            dataContextChanged = (object sender, PropertyChangedEventArgs e) =>
            {
                switch (e.PropertyName)
                {
                case "IsTopMost": topmostMenu.Checked = dataContext.IsTopMost; break;

                case "IsBottomMost": bottommostMenu.Checked = dataContext.IsBottomMost; break;
                }
            };
            dataContext.PropertyChanged += dataContextChanged;

            //リストビュー関連の設定
            //var list_columns = Resources["ReserveItemViewColumns"] as GridViewColumnList;
            ////list_columns.AddRange(Resources["RecSettingViewColumns"] as GridViewColumnList);
            var progress_list_columns = Resources["ProgressStatusItemViewColumns"] as GridViewColumnList;

            lstCtrl = new ListViewController <ReserveItem>(this);
            lstCtrl.SetSavePath(CommonUtil.GetMemberName(() => Settings.Instance.InfoWindowListColumn));
            lstCtrl.SetViewSetting(listView_InfoWindow, girdView_InfoWindow, false, false, progress_list_columns, null, false);

            MouseLeftButtonDown += (s, e) => { DragMove(); };
            UpdateWindowState();

            DataContext = dataContext;
        }
Esempio n. 2
0
        public InfoWindow(InfoWindowViewModel dataContext)
        {
            InitializeComponent();

            notifyIcon.Icon = Properties.Resources.TaskIconInfo;
            notifyIcon.Text = "予約簡易表示 (EpgTimer)";
            notifyIcon.MouseClick += NotifyIcon_MouseClick;
            notifyIcon.Visible = true;

            // notify icon用メニューの設定
            var menu = new System.Windows.Forms.ContextMenuStrip();

            ToolStripMenuItem topmostMenu = new ToolStripMenuItem();
            topmostMenu.Text = "最前面に表示";
            topmostMenu.Checked = dataContext.IsTopMost;
            topmostMenu.Click += (s, e) => { dataContext.IsTopMost = !dataContext.IsTopMost; };
            menu.Items.Add(topmostMenu);

            ToolStripMenuItem bottommostMenu = new ToolStripMenuItem();
            bottommostMenu.Text = "最背面に表示";
            bottommostMenu.Checked = dataContext.IsBottomMost;
            bottommostMenu.Click += (s, e) => { dataContext.IsBottomMost = !dataContext.IsBottomMost; };
            menu.Items.Add(bottommostMenu);

            ToolStripMenuItem closeMenu = new ToolStripMenuItem();
            closeMenu.Text = "消す";
            closeMenu.Click += (s, e) => TrueClose();
            menu.Items.Add(closeMenu);
            notifyIcon.ContextMenuStrip = menu;

            // notify icon用メニュー内の checkbox 更新用イベントハンドラ追加
            dataContextChanged = (object sender, PropertyChangedEventArgs e) =>
            {
                switch (e.PropertyName)
                {
                    case "IsTopMost": topmostMenu.Checked = dataContext.IsTopMost; break;
                    case "IsBottomMost": bottommostMenu.Checked = dataContext.IsBottomMost; break;
                }
            };
            dataContext.PropertyChanged += dataContextChanged;

            //リストビュー関連の設定
            //var list_columns = Resources["ReserveItemViewColumns"] as GridViewColumnList;
            ////list_columns.AddRange(Resources["RecSettingViewColumns"] as GridViewColumnList);
            var progress_list_columns = Resources["ProgressStatusItemViewColumns"] as GridViewColumnList;

            lstCtrl = new ListViewController<ReserveItem>(this);
            lstCtrl.SetSavePath(CommonUtil.GetMemberName(() => Settings.Instance.InfoWindowListColumn));
            lstCtrl.SetViewSetting(listView_InfoWindow, girdView_InfoWindow, false, false, progress_list_columns, null, false);

            MouseLeftButtonDown += (s, e) => { DragMove(); };
            UpdateWindowState();

            DataContext = dataContext;
        }
Esempio n. 3
0
        public InfoWindow(InfoWindowViewModel dataContext)
        {
            InitializeComponent();

            notifyIcon.Icon = Properties.Resources.TaskIconInfo;
            notifyIcon.Text = "予約簡易表示 (EpgTimer)";
            notifyIcon.MouseClick += NotifyIcon_MouseClick;
            notifyIcon.Visible = true;

            var menu = new System.Windows.Forms.ContextMenuStrip();
            ToolStripMenuItem closeMenu = new ToolStripMenuItem();
            closeMenu.Text = "消す";
            closeMenu.Click += (s, e) => TrueClose();
            menu.Items.Add(closeMenu);
            notifyIcon.ContextMenuStrip = menu;

            DataContext = dataContext;
        }
Esempio n. 4
0
        public MainWindow()
        {
            Settings.LoadFromXmlFile();
            CommonManager.Instance.NWMode = Settings.Instance.NWMode;

            CommonManager.Instance.MM.ReloadWorkData();
            CommonManager.Instance.ReloadCustContentColorList();
            Settings.Instance.ReloadOtherOptions();

            CommonUtil.ApplyStyle(Settings.Instance.NoStyle == 0 ? Settings.Instance.StyleXamlPath : null);

            SemaphoreSecurity ss = new SemaphoreSecurity();
            ss.AddAccessRule(new SemaphoreAccessRule("Everyone", SemaphoreRights.FullControl, AccessControlType.Allow));
            semaphore = new Semaphore(int.MaxValue, int.MaxValue, "Global\\EpgTimer_Bon3", out firstInstance, ss);
            semaphore.WaitOne(0);
            if (!firstInstance && Settings.Instance.ApplyMultiInstance == false)
            {
                ConnectSrv();
                DisconnectServer();

                semaphore.Release();
                semaphore.Close();
                semaphore = null;

                CloseCmd();
                return;
            }

            InitializeComponent();

            #if DEBUG
            appName += "(debug)";
            #endif

            initExe = true;

            try
            {
                infoWindowViewModel = new InfoWindowViewModel();

                // 多重起動時は最小化しない
                if (firstInstance && Settings.Instance.WakeMin == true)
                {
                    // Icon化起動すると Windows_Loaded イベントが来ないので
                    // InitializeComponent 後に ConnectCmd しておく。
                    Dispatcher.BeginInvoke(new Action(() =>
                                            ConnectCmd(Settings.Instance.NWMode && Settings.Instance.WakeReconnectNW == false)
                                            ), DispatcherPriority.Loaded);

                    if (Settings.Instance.ShowTray && Settings.Instance.MinHide)
                    {
                        this.Visibility = Visibility.Hidden;
                    }
                    else
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            this.WindowState = System.Windows.WindowState.Minimized;
                            minimizedStarting = true;
                        }));
                    }
                }

                //ウインドウ位置の復元
                if (Settings.Instance.MainWndTop != -100)
                {
                    this.Top = Settings.Instance.MainWndTop;
                }
                if (Settings.Instance.MainWndLeft != -100)
                {
                    this.Left = Settings.Instance.MainWndLeft;
                }
                if (Settings.Instance.MainWndWidth != -100)
                {
                    this.Width = Settings.Instance.MainWndWidth;
                }
                if (Settings.Instance.MainWndHeight != -100)
                {
                    this.Height = Settings.Instance.MainWndHeight;
                }
                this.WindowState = Settings.Instance.LastWindowState;

                //上のボタン
                Action<string, Action> ButtonGen = (key, handler) =>
                {
                    Button btn = new Button();
                    btn.MinWidth = 75;
                    btn.Margin = new Thickness(2, 2, 2, 5);
                    btn.Click += (sender, e) => handler();
                    btn.Content = key;
                    buttonList.Add(key, btn);
                };
                ButtonGen("設定", OpenSettingDialog);
                ButtonGen("再接続", OpenConnectDialog);
                ButtonGen("再接続(前回)", () => ConnectCmd());
                ButtonGen("検索", OpenSearchDialog);
                ButtonGen("スタンバイ", () => SuspendCmd(1));
                ButtonGen("休止", () => SuspendCmd(2));
                ButtonGen("終了", CloseCmd);
                ButtonGen("EPG取得", EpgCapCmd);
                ButtonGen("EPG再読み込み", EpgReloadCmd);
                ButtonGen("NetworkTV終了", NwTVEndCmd);
                ButtonGen("情報通知ログ", OpenNotifyLogDialog);
                ButtonGen("予約簡易表示", () => ShowInfoWindow());
                ButtonGen("カスタム1", () => CustumCmd(1));
                ButtonGen("カスタム2", () => CustumCmd(2));
                ButtonGen("カスタム3", () => CustumCmd(3));

                //検索ボタンは他と共通でショートカット割り振られているので、その部分はコマンド側で処理する。
                this.CommandBindings.Add(new CommandBinding(EpgCmds.Search, (sender, e) => CommonButtons_Click("検索")));
                mBinds.AddInputCommand(EpgCmds.Search);
                SetSearchButtonTooltip(buttonList["検索"]);

                StatusbarReset();//ステータスバーリセット

                if(Settings.Instance.InfoWindowEnabled)
                {
                    ShowInfoWindow();
                }

                //タスクトレイの表示
                taskTray = new TaskTrayClass(this);
                if (CommonManager.Instance.NWMode == true && Settings.Instance.ChkSrvRegistTCP == true)
                {
                    taskTray.Icon = TaskIconSpec.TaskIconGray;
                }
                else
                {
                    taskTray.Icon = TaskIconSpec.TaskIconBlue;
                }
                taskTray.ContextMenuClick += (sender, e) => CommonButtons_Click(sender as string);

                ResetMainView();

                //初期タブ選択
                switch (Settings.Instance.StartTab)
                {
                    //case CtxmCode.ReserveView:
                    //    this.tabItem_reserve.IsSelected = true;
                    //    break;
                    case CtxmCode.TunerReserveView:
                        this.tabItem_tunerReserve.IsSelected = true;
                        break;
                    case CtxmCode.RecInfoView:
                        this.tabItem_recinfo.IsSelected = true;
                        break;
                    case CtxmCode.EpgAutoAddView:
                        this.tabItem_AutoAdd.IsSelected = true;
                    //    this.autoAddView.tabItem_epgAutoAdd.IsSelected = true;
                        break;
                    case CtxmCode.ManualAutoAddView:
                        this.tabItem_AutoAdd.IsSelected = true;
                        this.autoAddView.tabItem_manualAutoAdd.IsSelected = true;
                        break;
                    case CtxmCode.EpgView:
                        this.tabItem_epg.IsSelected = true;
                        break;
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.Log(ex);
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 5
0
        public MainWindow()
        {
            Settings.LoadFromXmlFile();
            CommonManager.Instance.NWMode = Settings.Instance.NWMode;

            CommonManager.Instance.MM.ReloadWorkData();
            CommonManager.Instance.ReloadCustContentColorList();

            if (Settings.Instance.NoStyle == 0)
            {
                if (System.IO.File.Exists(System.Reflection.Assembly.GetEntryAssembly().Location + ".rd.xaml"))
                {
                    //ResourceDictionaryを定義したファイルがあるので本体にマージする
                    try
                    {
                        App.Current.Resources.MergedDictionaries.Add(
                            (ResourceDictionary)System.Windows.Markup.XamlReader.Load(
                                System.Xml.XmlReader.Create(System.Reflection.Assembly.GetEntryAssembly().Location + ".rd.xaml")));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else
                {
                    //既定のテーマ(Aero)をマージする
                    App.Current.Resources.MergedDictionaries.Add(
                        Application.LoadComponent(new Uri("/PresentationFramework.Aero, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;component/themes/aero.normalcolor.xaml", UriKind.Relative)) as ResourceDictionary
                        );
                }
            }

            SemaphoreSecurity ss = new SemaphoreSecurity();
            ss.AddAccessRule(new SemaphoreAccessRule("Everyone", SemaphoreRights.FullControl, AccessControlType.Allow));
            semaphore = new Semaphore(int.MaxValue, int.MaxValue, "Global\\EpgTimer_Bon2", out firstInstance, ss);
            semaphore.WaitOne(0);
            if (!firstInstance)
            {
                CheckCmdLine();

                if (Settings.Instance.ApplyMultiInstance == false)
                {
                    semaphore.Release();
                    semaphore.Close();
                    semaphore = null;

                    CloseCmd();
                    return;
                }
            }

            InitializeComponent();

            initExe = true;

            try
            {
                // 多重起動時は最小化しない
                if (firstInstance && Settings.Instance.WakeMin == true)
                {
                    // Icon化起動すると Windows_Loaded イベントが来ないので
                    // InitializeComponent 後に ConnectCmd しておく。
                    if (Settings.Instance.NWMode == false || Settings.Instance.WakeReconnectNW == true)
                    {
                        ConnectCmd(false);
                    }

                    if (Settings.Instance.ShowTray && Settings.Instance.MinHide)
                    {
                        this.Visibility = Visibility.Hidden;
                    }
                    else
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            this.WindowState = System.Windows.WindowState.Minimized;
                        }));
                    }
                }

                //ウインドウ位置の復元
                if (Settings.Instance.MainWndTop != -100)
                {
                    this.Top = Settings.Instance.MainWndTop;
                }
                if (Settings.Instance.MainWndLeft != -100)
                {
                    this.Left = Settings.Instance.MainWndLeft;
                }
                if (Settings.Instance.MainWndWidth != -100)
                {
                    this.Width = Settings.Instance.MainWndWidth;
                }
                if (Settings.Instance.MainWndHeight != -100)
                {
                    this.Height = Settings.Instance.MainWndHeight;
                }
                this.WindowState = Settings.Instance.LastWindowState;

                //上のボタン
                Action<string, RoutedEventHandler> ButtonGen = (key, handler) =>
                {
                    Button btn = new Button();
                    btn.MinWidth = 75;
                    btn.Margin = new Thickness(2, 2, 2, 5);
                    if (handler != null) btn.Click += new RoutedEventHandler(handler);
                    btn.Content = key;
                    buttonList.Add(key, btn);
                };
                ButtonGen("設定", settingButton_Click);
                ButtonGen("検索", null);
                ButtonGen("終了", closeButton_Click);
                ButtonGen("スタンバイ", standbyButton_Click);
                ButtonGen("休止", suspendButton_Click);
                ButtonGen("EPG取得", epgCapButton_Click);
                ButtonGen("EPG再読み込み", epgReloadButton_Click);
                ButtonGen("カスタム1", custum1Button_Click);
                ButtonGen("カスタム2", custum2Button_Click);
                ButtonGen("NetworkTV終了", nwTVEndButton_Click);
                ButtonGen("情報通知ログ", logViewButton_Click);
                ButtonGen("再接続", connectButton_Click);
                ButtonGen("予約簡易表示", showInfoWindowButton_Click);

                //検索ボタンは他と共通でショートカット割り振られているので、コマンド側で処理する。
                this.CommandBindings.Add(new CommandBinding(EpgCmds.Search, searchButton_Click));
                mBinds.SetCommandToButton(buttonList["検索"], EpgCmds.Search);
                RefreshButton();

                ResetButtonView();

                //タスクトレイの表示
                taskTray = new TaskTrayClass(this);
                taskTray.Icon = Properties.Resources.TaskIconBlue;
                taskTray.Visible = Settings.Instance.ShowTray;
                taskTray.ContextMenuClick += new EventHandler(taskTray_ContextMenuClick);
                taskTray.Text = GetTaskTrayReserveInfoText();
                ResetTaskMenu();

                CheckCmdLine();

                // 設定から情報を読み取るので設定をロードした後作る
                infoWindowViewModel = new InfoWindowViewModel();
                if(Settings.Instance.InfoWindowEnabled)
                {
                    ShowInfoWindow();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }