public void CtxmGenerateRestoreMenuItems(MenuItem menu) { //クリア object menuReset = menu.Items[menu.Items.Count - 1]; menu.Items.Clear(); for (int i = 0; i < CmdHistorys.Count; i++) { List <IRecWorkMainData> list = CmdHistorys.Historys[i].Items; var menuItem = new MenuItem(); var s = string.Format((CmdHistorys.Historys[i].Command == EpgCmds.Delete ? "削除した{0}を復元" : "変更前の{0}を新規追加") + "(_{1}) : {2}" , new InfoSearchItem(list[0]).ViewItemName, ToAccessKey(i, 16), MenuUtil.ToAccessKeyForm(ToMenuString(list[0]))) + (list.Count > 1 ? " ほか" + (list.Count - 1) : ""); menuItem.Header = CommonUtil.LimitLenString(s, 45, 31); // 長すぎる場合は省略 if (list.Count >= 2 || (menuItem.Header as string).Length != s.Length) { s = string.Join("\r\n", list.Take(10).Select(item => ToMenuString(item))) + (list.Count > 10 ? "\r\nほか" + (list.Count - 10) : ""); menuItem.ToolTip = ViewUtil.GetTooltipBlockStandard(s); } menuItem.Command = EpgCmds.RestoreItem; menuItem.CommandParameter = new EpgCmdParam(menu.CommandParameter as EpgCmdParam); (menuItem.CommandParameter as EpgCmdParam).ID = i; menuItem.Tag = menuItem.Command; menu.Items.Add(menuItem); } menu.IsEnabled = menu.Items.Count > 0; menu.Items.Add(new Separator()); menu.Items.Add(menuReset); }
/// <summary>長すぎるとき省略してツールチップを追加する</summary> public void SetLimitLenHeader(MenuItem menu, string s, bool?useTextBlock, int max = 45, int pos = -1) { s = s ?? menu.Header as string; if (s != null && s.Length > max) { menu.ToolTip = ViewUtil.GetTooltipBlockStandard(s); s = CommonUtil.LimitLenString(s, max, pos); // 長すぎる場合は省略 } menu.Header = useTextBlock == null ? s : useTextBlock == true ? (object)new TextBlock { Text = s, Tag = s } : new Label { Content = s, Padding = new Thickness(), Tag = s }; }
/// <summary>長すぎるとき省略してツールチップを追加する</summary> public bool LimitLenHeader(MenuItem menu, int max = 45, int pos = -1) { var header = menu.Header as string; if (header == null) { return(false); } bool isLengthOver = header.Length > max; if (isLengthOver == true) { menu.ToolTip = ViewUtil.GetTooltipBlockStandard(header); header = CommonUtil.LimitLenString(header, max, pos); // 長すぎる場合は省略 } menu.Header = header; return(isLengthOver); }
public static void UpdateInfo(uint?srvStatus = null, bool updateTray = true) { if (srvStatus != null) { srvState = (uint)srvStatus; } if (Settings.Instance.ShowTray == false || updateTray == false) { return; } var sortList = CommonManager.Instance.DB.ReserveList.Values .Where(info => info.IsEnabled == true && info.IsOver() == false) .OrderBy(info => info.StartTimeActual).ToList(); bool isOnPreRec = false; string infoText = IsSrvLost == true ? "[未接続]\r\n(?)" : ""; infoText += srvState == 2 ? "EPG取得中\r\n" : ""; if (sortList.Count == 0) { infoText += "次の予約なし"; } else { if (sortList[0].IsOnRec() == true) { sortList = sortList.FindAll(info => info.IsOnRec()); infoText += "録画中:"; } else { var PreRecTime = DateTime.UtcNow.AddHours(9).AddMinutes(Settings.Instance.RecAppWakeTime); isOnPreRec = sortList[0].OnTime(PreRecTime) >= 0; if (isOnPreRec == true) //録画準備中 { sortList = sortList.FindAll(info => info.OnTime(PreRecTime) >= 0); //あまり意味無い infoText += "録画準備中:"; } else if (Settings.Instance.UpdateTaskText == true && sortList[0].OnTime(PreRecTime.AddMinutes(30)) >= 0) //30分以内に録画準備に入るもの { sortList = sortList.FindAll(info => info.OnTime(PreRecTime.AddMinutes(30)) >= 0); infoText += "まもなく録画:"; } else { sortList = sortList.Take(1).ToList(); infoText += "次の予約:"; } } //FindAll()が順次検索、OrderBy()は安定ソートなのでこれでOK ReserveData first = sortList.OrderBy(info => info.IsWatchMode).First(); infoText += first.StationName + " " + new ReserveItem(first).StartTimeShort + " " + first.Title; string endText = (sortList.Count() <= 1 ? "" : "\r\n他" + (sortList.Count() - 1).ToString()); infoText = CommonUtil.LimitLenString(infoText, 63 - endText.Length) + endText; if (first.IsWatchMode == true) { infoText = infoText.Replace("録画", "視聴"); } } taskTray.Text = infoText; if (IsSrvLost == true) { taskTray.IconUri = new Uri("pack://application:,,,/Resources/TaskIconGray.ico"); } else if (srvState == 1) { taskTray.IconUri = new Uri("pack://application:,,,/Resources/TaskIconRed.ico"); } else if (isOnPreRec == true) { taskTray.IconUri = new Uri("pack://application:,,,/Resources/TaskIconOrange.ico"); } else if (srvState == 2) { taskTray.IconUri = new Uri("pack://application:,,,/Resources/TaskIconGreen.ico"); } else { taskTray.IconUri = new Uri("pack://application:,,,/Resources/EpgTimer_Bon_Vista_blue_rev2.ico"); } }