Esempio n. 1
0
        public AddReserveEpgWindow()
        {
            InitializeComponent();

            //コマンドの登録
            this.CommandBindings.Add(new CommandBinding(EpgCmds.Cancel, (sender, e) => DialogResult = false));
            this.CommandBindings.Add(new CommandBinding(EpgCmds.AddInDialog, button_add_reserve_Click));

            //ボタンの設定
            var mBinds = new MenuBinds();
            mBinds.SetCommandToButton(button_cancel, EpgCmds.Cancel);
            mBinds.SetCommandToButton(button_add_reserve, EpgCmds.AddInDialog);

            //ショートカットの登録
            mBinds.ResetInputBindings(this);
        }
        public void SetData(Control ow, ListBox listbox, LVDMHelper helper, MenuBinds mbinds = null)
        {
            try
            {
                Owner   = ow;
                listBox = listbox;
                hlp     = helper;
                MenuBinds mBinds = mbinds ?? new MenuBinds();

                //マウスイベント関係
                this.listBox.PreviewMouseLeftButtonUp   += new MouseButtonEventHandler(listBox_PreviewMouseLeftButtonUp);
                this.listBox.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(listBox_PreviewMouseLeftButtonDown);
                ViewUtil.ResetItemContainerStyle(listbox);
                listbox.ItemContainerStyle.Setters.Add(new EventSetter(Mouse.MouseEnterEvent, new MouseEventHandler(listBoxItem_MouseEnter)));

                //移動などのアクションはBoxExchangeEditorのものをそのまま使用する。
                bx = new BoxExchangeEditor {
                    TargetBox = listBox
                };

                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.TopItem, (sender, e) => ItemsAction(() => bx.button_Top_Click(null, null))));
                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.UpItem, (sender, e) => ItemsAction(() => bx.button_Up_Click(null, null))));
                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.DownItem, (sender, e) => ItemsAction(() => bx.button_Down_Click(null, null))));
                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.BottomItem, (sender, e) => ItemsAction(() => bx.button_Bottom_Click(null, null))));
                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.SaveOrder, SaveOrder_handler, (sender, e) => e.CanExecute = NotSaved == true));
                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.RestoreOrder, (sender, e) => hlp.RestoreOrder(), (sender, e) => e.CanExecute = NotSaved == true));
                this.Owner.CommandBindings.Add(new CommandBinding(EpgCmds.DragCancel, (sender, e) => DragRelease()));

                mBinds.SetCommandToButton(button_top, EpgCmds.TopItem);
                mBinds.SetCommandToButton(button_up, EpgCmds.UpItem);
                mBinds.SetCommandToButton(button_down, EpgCmds.DownItem);
                mBinds.SetCommandToButton(button_bottom, EpgCmds.BottomItem);
                mBinds.SetCommandToButton(button_saveItemOrder, EpgCmds.SaveOrder);
                mBinds.SetCommandToButton(button_reloadItem, EpgCmds.RestoreOrder);
                mBinds.AddInputCommand(EpgCmds.DragCancel);//アイテムのドラッグキャンセル
                if (mbinds == null)
                {
                    mBinds.ResetInputBindings(this.Owner, this.listBox);
                }

                //コマンドだと、DragCancelしない場合に、CanExecuteを割り当てても、Handled=falseにしても、
                //Keygestureが先へ伝搬してくれないので、対処療法的だけど先に処理してしまうことにする。コマンドの意味無い‥。
                listBox.PreviewKeyDown += new KeyEventHandler((sender, e) =>
                {
                    if (Keyboard.Modifiers == ModifierKeys.None)
                    {
                        switch (e.Key)
                        {
                        case Key.Escape:
                            if (_onDrag == true)
                            {
                                EpgCmds.DragCancel.Execute(null, null);
                                //this.listBox.Items.Refresh();//壊したバインディングを修復する。モタツキ感があるので放置する。
                                e.Handled = true;
                            }
                            break;
                        }
                    }
                });
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Esempio n. 3
0
        public SearchWindow()
        {
            InitializeComponent();

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

                lstCtrl = new ListViewController <SearchItem>(this);
                lstCtrl.SetSavePath(CommonUtil.GetMemberName(() => Settings.Instance.SearchWndColumn)
                                    , CommonUtil.GetMemberName(() => Settings.Instance.SearchColumnHead)
                                    , CommonUtil.GetMemberName(() => Settings.Instance.SearchSortDirection));
                lstCtrl.SetViewSetting(listView_result, gridView_result, true, true, list_columns);
                lstCtrl.SetSelectedItemDoubleClick(EpgCmds.ShowDialog);

                //ステータス変更の設定
                lstCtrl.SetSelectionChangedEventHandler((sender, e) => this.UpdateStatus(1));

                //最初にコマンド集の初期化
                mc = new CmdExeReserve(this);
                mc.SetFuncGetSearchList(isAll => (isAll == true ? lstCtrl.dataList.ToList() : lstCtrl.GetSelectedItemsList()));
                mc.SetFuncSelectSingleSearchData(lstCtrl.SelectSingleItem);
                mc.SetFuncReleaseSelectedData(() => listView_result.UnselectAll());
                mc.recSettingView = this.recSettingView;

                //コマンド集に無いもの
                mc.AddReplaceCommand(EpgCmds.ReSearch, mc_Research);
                mc.AddReplaceCommand(EpgCmds.ReSearch2, mc_Research);
                mc.AddReplaceCommand(EpgCmds.Search, (sender, e) => SearchPg(true));
                mc.AddReplaceCommand(EpgCmds.AddInDialog, button_add_epgAutoAdd_Click);
                mc.AddReplaceCommand(EpgCmds.ChangeInDialog, button_chg_epgAutoAdd_Click, (sender, e) => e.CanExecute = winMode == SearchMode.Change);
                mc.AddReplaceCommand(EpgCmds.DeleteInDialog, button_del_epgAutoAdd_Click, (sender, e) => e.CanExecute = winMode == SearchMode.Change);
                mc.AddReplaceCommand(EpgCmds.UpItem, (sender, e) => button_up_down_Click(-1));
                mc.AddReplaceCommand(EpgCmds.DownItem, (sender, e) => button_up_down_Click(1));
                mc.AddReplaceCommand(EpgCmds.Cancel, (sender, e) => this.Close());
                mc.AddReplaceCommand(EpgCmds.ChgOnOffCheck, (sender, e) => lstCtrl.ChgOnOffFromCheckbox(e.Parameter, EpgCmds.ChgOnOff));

                //コマンド集を振り替えるもの
                mc.AddReplaceCommand(EpgCmds.JumpReserve, (sender, e) => mc_JumpTab(CtxmCode.ReserveView, true));
                mc.AddReplaceCommand(EpgCmds.JumpTuner, (sender, e) => mc_JumpTab(CtxmCode.TunerReserveView, true, Settings.Instance.TunerDisplayOffReserve == false));
                mc.AddReplaceCommand(EpgCmds.JumpTable, (sender, e) => mc_JumpTab(CtxmCode.EpgView));

                //コマンド集からコマンドを登録。
                mc.ResetCommandBindings(this, listView_result.ContextMenu);

                //コンテキストメニューを開く時の設定
                listView_result.ContextMenu.Opened += new RoutedEventHandler(mc.SupportContextMenuLoading);

                //ボタンの設定
                mBinds.View = CtxmCode.SearchWindow;
                mBinds.SetCommandToButton(button_search, EpgCmds.Search);
                mBinds.SetCommandToButton(button_add_reserve, EpgCmds.Add);
                mBinds.SetCommandToButton(button_delall_reserve, EpgCmds.DeleteAll);
                mBinds.SetCommandToButton(button_add_epgAutoAdd, EpgCmds.AddInDialog);
                mBinds.SetCommandToButton(button_chg_epgAutoAdd, EpgCmds.ChangeInDialog);
                mBinds.SetCommandToButton(button_del_epgAutoAdd, EpgCmds.DeleteInDialog);
                mBinds.SetCommandToButton(button_up_epgAutoAdd, EpgCmds.UpItem);
                mBinds.SetCommandToButton(button_down_epgAutoAdd, EpgCmds.DownItem);
                mBinds.AddInputCommand(EpgCmds.Cancel);//ショートカット登録

                //メニューの作成、ショートカットの登録
                RefreshMenu();

                //その他のショートカット(検索ダイアログ固有の設定)
                searchKeyView.InputBindings.Add(new InputBinding(EpgCmds.Search, new KeyGesture(Key.Enter)));

                //録画プリセット変更時の対応
                recSettingView.SelectedPresetChanged += new EventHandler(SetRecSettingTabHeader);

                //ウインドウ位置の復元
                if (Settings.Instance.SearchWndTop != -100)
                {
                    this.Top = Settings.Instance.SearchWndTop;
                }
                if (Settings.Instance.SearchWndLeft != -100)
                {
                    this.Left = Settings.Instance.SearchWndLeft;
                }
                if (Settings.Instance.SearchWndWidth > 0)
                {
                    this.Width = Settings.Instance.SearchWndWidth;
                }
                if (Settings.Instance.SearchWndHeight > 0)
                {
                    this.Height = Settings.Instance.SearchWndHeight;
                }
                checkBox_windowPinned.IsChecked = Settings.Instance.SearchWndPinned;

                SetSearchKey(Settings.Instance.DefSearchKey);
                SetRecSetting(Settings.Instance.RecPresetList[0].RecPresetData);

                //notify残ってれば更新。通常残ってないはず。
                ViewUtil.ReloadReserveData();

                //EPG自動予約登録と、登録された予約、および録画済みファイルとの関連付けを実装
                CommonManager.Instance.DB.EpgAutoAddUpdated += DB_EpgAutoAddUpdated;
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }