Ejemplo n.º 1
0
        private void EpgTabMove()
        {
            if (dragUid == null)
            {
                return;
            }

            Point pt = Mouse.GetPosition(tabControl);

            pt.X = Math.Min(pt.X, tabControl.DesiredSize.Width - 5);//右範囲外の処理。

            var trg = tabControl.GetPlacementItem(pt) as EpgTabItem;

            if (trg == null || trg.Uid == dragUid)
            {
                return;
            }

            EpgTabItem tab = Tabs.FirstOrDefault(t => t.Uid == dragUid);
            int        pos = tabControl.Items.IndexOf(trg);

            if (tab == null || pos < 0)
            {
                return;
            }

            OnMoveTab = true;
            tabControl.Items.Remove(tab);
            tabControl.Items.Insert(pos, tab);
            tabControl.SelectedItem = tab;
            OnMoveTab = false;

            //設定更新
            Func <List <CustomEpgTabInfo>, bool> updatesList = (list) =>
            {
                CustomEpgTabInfo info = list.Find(ti => ti.ID == tab.Info.ID);
                int idx = list.FindIndex(ti => ti.ID == trg.Info.ID);
                if (info != null && idx >= 0)
                {
                    list.Remove(info);
                    list.Insert(idx, info);
                }
                return(info != null && idx >= 0);
            };

            if (updatesList(tabInfo) && Settings.Instance.UseCustomEpgView && updatesList(Settings.Instance.CustomEpgTabList))
            {
                SettingWindow.UpdatesInfo("番組表関連の変更");
            }
        }
Ejemplo n.º 2
0
        private void MenuCmdsExecute(object sender, RoutedEventArgs e)
        {
            try
            {
                string      selectID = null;
                List <bool> infoBack = tabInfo.Select(info => info.IsVisible).ToList();
                var         menu     = sender as MenuItem;

                if (menu.Tag is RoutedUICommand)
                {
                    EpgTabItem tab = Tabs.FirstOrDefault(ti => ti.Uid == menu.Uid);
                    if (tab != null && tab.view != null)
                    {
                        (menu.Tag as RoutedUICommand).Execute(menu.CommandParameter, tab.view);
                    }
                    return;
                }
                switch (menu.Tag as edvCmds?)
                {
                case edvCmds.Setting:
                    ViewUtil.MainWindow.OpenSettingDialog(SettingWindow.SettingMode.EpgSetting, menu.Uid);
                    return;

                case edvCmds.ResetAll:
                    this.UpdateSetting(true);
                    return;

                case edvCmds.ModeChange:
                    Settings.Instance.UseCustomEpgView = !Settings.Instance.UseCustomEpgView;
                    SettingWindow.UpdatesInfo("番組表関連の変更");
                    this.UpdateSetting(true);
                    return;

                case edvCmds.All:
                    tabInfo.ForEach(ti => ti.IsVisible = true);
                    break;

                case edvCmds.DeleteAll:
                    tabInfo.ForEach(ti => ti.IsVisible = false);
                    break;

                //case edvCmds.Delete://現在のところVisibleChangeと同じになる
                case edvCmds.VisibleChange:
                    if (Settings.Instance.EpgTabMoveCheckEnabled == true || tabControl.Items.Count == 0)
                    {
                        selectID = menu.Uid;
                    }
                    var info = get_tabInfo(menu.Uid);
                    if (info != null)
                    {
                        info.IsVisible = !info.IsVisible;
                    }
                    break;

                case edvCmds.NameTabChange:
                    EpgTabItem tab = Tabs.FirstOrDefault(ti => ti.Uid == menu.Uid);
                    if (tab != null)
                    {
                        tab.IsSelected = true;
                    }
                    return;

                case edvCmds.NameTabVisible:
                    Settings.Instance.EpgNameTabEnabled = !Settings.Instance.EpgNameTabEnabled;
                    SettingWindow.UpdatesInfo("番組表関連の変更");
                    TabModeSet();
                    return;

                case edvCmds.ViewModeTabVisible:
                    Settings.Instance.EpgViewModeTabEnabled = !Settings.Instance.EpgViewModeTabEnabled;
                    SettingWindow.UpdatesInfo("番組表関連の変更");
                    TabModeSet();
                    return;

                case edvCmds.MoveCheckedTab:
                    Settings.Instance.EpgTabMoveCheckEnabled = !Settings.Instance.EpgTabMoveCheckEnabled;
                    SettingWindow.UpdatesInfo("番組表関連の変更");
                    return;
                }

                if (Settings.Instance.UseCustomEpgView == true)
                {
                    List <bool> infoNew = tabInfo.Select(info => info.IsVisible).ToList();
                    if (infoBack.Count != infoNew.Count || infoBack.Zip(infoNew, (v1, v2) => v1 ^ v2).Any(v => v) == true)
                    {
                        SettingWindow.UpdatesInfo("番組表関連の変更");
                    }
                }

                int pos = 0;
                foreach (var info in tabInfo)
                {
                    EpgTabItem tab = Tabs.FirstOrDefault(ti => ti.Uid == info.Uid);
                    if (info.IsVisible == false)
                    {
                        tabControl.Items.Remove(tab);
                    }
                    else
                    {
                        if (tab == null)
                        {
                            tabControl.Items.Insert(pos, new EpgTabItem(info, selectID));
                        }
                        pos++;
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Ejemplo n.º 3
0
        private void epgView_ViewSettingClick(EpgViewBase sender, int param)
        {
            try
            {
                EpgTabItem tab = Tabs.FirstOrDefault(ti => ti.view == sender);
                if (tab == null)
                {
                    return;
                }

                if (param < -2 || 2 < param)
                {
                    return;
                }

                CustomEpgTabInfo info = null;
                if (param == -1)
                {
                    //表示設定変更ダイアログから
                    var dlg = new EpgDataViewSettingWindow(tab.Info);
                    dlg.Owner = CommonUtil.GetTopWindow(this);
                    dlg.SetTryMode(Settings.Instance.UseCustomEpgView == false);
                    if (dlg.ShowDialog() == false)
                    {
                        return;
                    }

                    info = dlg.GetSetting();
                    if (info.Uid != tab.Uid)
                    {
                        return;                     //保険
                    }
                    //設定の保存。
                    if (Settings.Instance.UseCustomEpgView == true && Settings.Instance.TryEpgSetting == false &&
                        info.ID >= 0 && info.ID < tabInfo.Count && info.ID < Settings.Instance.CustomEpgTabList.Count)
                    {
                        tabInfo[info.ID] = info;
                        Settings.Instance.CustomEpgTabList[info.ID] = info;
                        Settings.SaveToXmlFile();
                        SettingWindow.UpdatesInfo("番組表関連の変更");
                    }

                    if (info.IsVisible == false)
                    {
                        tabControl.Items.Remove(tab);
                        return;
                    }
                }
                else if (param == -2)
                {
                    info = tabInfo.Find(tinfo => tinfo.ID == tab.Info.ID);
                    if (info == null)
                    {
                        return;
                    }
                }

                //選択用タブの選択を切り替え。
                tab_viewMode_Change(info != null ? info.ViewMode : param);

                tab.UpdateContent(info, param);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }