コード例 #1
0
        public void ShowNotifyDialog(int timeOut, string header, string icon, string text, Helper.PLUGIN_NOTIFY_WINDOWS notifyType)
        {
            try {
                GUIWindow guiWindow = GUIWindowManager.GetWindow((int)notifyType);
                switch (notifyType)
                {
                default:
                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_AUTO:
                    if (text.Length <= 60)
                    {
                        ShowNotifyDialog(timeOut, header, icon, text, Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_NOTIFY);
                    }
                    else
                    {
                        ShowNotifyDialog(timeOut, header, icon, text, Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_TEXT);
                    }
                    break;

                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_NOTIFY:
                    GUIDialogNotify notifyDialog = (GUIDialogNotify)guiWindow;
                    notifyDialog.Reset();
                    notifyDialog.TimeOut = timeOut;
                    notifyDialog.SetImage(icon);
                    notifyDialog.SetHeading(header);
                    notifyDialog.SetText(text);
                    notifyDialog.DoModal(GUIWindowManager.ActiveWindow);
                    break;

                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_OK:
                    GUIDialogOK okDialog = (GUIDialogOK)guiWindow;
                    okDialog.Reset();
                    okDialog.SetHeading(header);
                    okDialog.SetLine(1, (text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))[0]);
                    okDialog.DoModal(GUIWindowManager.ActiveWindow);
                    break;

                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_TEXT:
                    GUIDialogText textDialog = (GUIDialogText)guiWindow;
                    textDialog.Reset();
                    try {
                        textDialog.SetImage(icon);
                    } catch (Exception e) { Debug.WriteLine(e.ToString()); }
                    textDialog.SetHeading(header);
                    textDialog.SetText(text);
                    textDialog.DoModal(GUIWindowManager.ActiveWindow);
                    break;
                }
            } catch (Exception ex) {
                Log.Error(ex);
            }
        }
コード例 #2
0
ファイル: GUIUtils.cs プロジェクト: ncmilhouse/IMDbPlus
        /// <summary>
        /// Displays a text dialog.
        /// </summary>
        public static void ShowTextDialog(string heading, string text)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                ShowTextDialogDelegate d = ShowTextDialog;
                GUIGraphicsContext.form.Invoke(d, heading, text);
                return;
            }

            GUIDialogText dlgText = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT);

            dlgText.Reset();
            dlgText.SetHeading(heading);
            dlgText.SetText(text);

            dlgText.DoModal(GUIWindowManager.ActiveWindow);
        }
コード例 #3
0
ファイル: GUIRSSFeed.cs プロジェクト: c3333/MediaPortal-1
        public override bool OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
            {
                for (int j = 0; j < NUM_STORIES; j++)
                {
                    m_feed_details[j].m_site        = "";
                    m_feed_details[j].m_title       = "";
                    m_feed_details[j].m_description = "";
                }

                base.OnMessage(message);
                LoadSettings();
                m_pSiteImage = (GUIImage)GetControl((int)Controls.CONTROL_IMAGELOGO);

                UpdateNews(true);

                return(true);
            }

            case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
            {
                SaveSettings();
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED:
            {
                int iControl = message.SenderControlId;
                if (iControl == (int)Controls.CONTROL_LIST)
                {
                    UpdateDetails();
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_CLICKED:
            {
                int iControl = message.SenderControlId;
                if (iControl == (int)Controls.CONTROL_BTNREFRESH)
                {
                    UpdateNews(true);
                }

                if (iControl == (int)Controls.CONTROL_LIST)
                {
                    String story = DownloadMainStory();

                    if (story != null)
                    {
                        GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_TEXT);
                        if (dlg != null)
                        {
                            dlg.Reset();
                            dlg.ResetAllControls();
                            dlg.SetHeading("Story");
                            dlg.SetText(story);
                            dlg.DoModal(GetID);
                        }
                    }
                }

                if (iControl == (int)Controls.CONTROL_BTNCHANNEL)
                {
                    OnSelectFeed();

                    return(true);
                }
            }
            break;
            }
            return(base.OnMessage(message));
        }
コード例 #4
0
ファイル: ScoreCenterGui.cs プロジェクト: mbekoe/scorecenter
        private void SetLiveSettings()
        {
            if (m_liveEnabled)
            {
                // stop the live
                File.Delete(Config.GetFile(Config.Dir.Config, LiveSettingsFileName));
                m_liveEnabled = false;
                SetLiveStatus();
            }
            else
            {
                // create a settings with all live settings
                var liveList = m_center.Scores.Items.Where(sc => sc.IsLive() && !sc.IsVirtual());
                if (liveList.Count() == 0)
                {
                    // no live score configure
                    GUIDialogText ww = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT);
                    ww.SetHeading("ScoreCenter");
                    ww.SetText(LocalizationManager.GetString(Labels.NoLiveScore));
                    ww.DoModal(GetID);
                }
                else
                {
                    // create new score center
                    ScoreCenter liveExport = new ScoreCenter();
                    liveExport.Parameters = m_center.Parameters;
                    liveExport.Setup      = m_center.Setup;
                    liveExport.Styles     = m_center.Styles;

                    // clone the scores
                    foreach (BaseScore sc in liveList)
                    {
                        m_center.ReadChildren(sc);
                    }

                    liveList = m_center.Scores.Items.Where(sc => sc.IsLive() && sc.IsScore());
                    var ll = new List <BaseScore>(liveList.Count());
                    foreach (BaseScore score in liveList)
                    {
                        BaseScore livescore = score.Clone(score.Id);
                        BaseScore parent    = m_center.FindScore(livescore.Parent);
                        if (parent != null)
                        {
                            // use parent icon and name for notification
                            livescore.Name  = parent.LocName;
                            livescore.Image = parent.Image;
                        }
                        livescore.ApplyRangeValue(true);
                        ll.Add(livescore);
                    }
                    liveExport.Scores       = new ScoreCenterScores();
                    liveExport.Scores.Items = ll.ToArray();

                    // create the settings
                    Tools.SaveSettings(Config.GetFile(Config.Dir.Config, LiveSettingsFileName), liveExport, false, true);

                    // update the status
                    m_liveEnabled = true;
                    SetLiveStatus();
                }
            }
        }
コード例 #5
0
        private void OnShowLogs()
        {
            string      text             = string.Empty;
            var         modules          = Proxies.LogService.GetAllModules().Result;
            string      selectedModule   = string.Empty;
            LogSeverity selectedSeverity = LogSeverity.Error;

            bool showAllSeverities = true;
            bool showAllModules    = true;

            if (modules != null && modules.Count > 1)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetHeading("Select module");
                    dlg.Add(Utility.GetLocalizedText(TextId.All));
                    foreach (string module in modules)
                    {
                        dlg.Add(module);
                    }

                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }

                    if (dlg.SelectedId > 0)
                    {
                        if (dlg.SelectedLabel > 0)
                        {
                            showAllModules = false;
                        }
                        selectedModule = dlg.SelectedLabelText;
                    }
                }
            }

            GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg2 != null)
            {
                dlg2.Reset();
                dlg2.SetHeading("Select severity");
                dlg2.Add(Utility.GetLocalizedText(TextId.All));
                dlg2.Add(LogSeverity.Error.ToString());
                dlg2.Add(LogSeverity.Fatal.ToString());
                dlg2.Add(LogSeverity.Information.ToString());
                dlg2.Add(LogSeverity.Warning.ToString());

                dlg2.DoModal(GetID);
                if (dlg2.SelectedId == -1)
                {
                    return;
                }

                if (dlg2.SelectedId > 0)
                {
                    if (dlg2.SelectedLabel > 0)
                    {
                        showAllSeverities = false;
                    }
                    switch (dlg2.SelectedLabel)
                    {
                    case 1:
                        selectedSeverity = LogSeverity.Error;
                        break;

                    case 2:
                        selectedSeverity = LogSeverity.Fatal;
                        break;

                    case 3:
                        selectedSeverity = LogSeverity.Information;
                        break;

                    case 4:
                        selectedSeverity = LogSeverity.Warning;
                        break;
                    }
                }
            }

            List <LogEntry> entries = null;

            if (showAllModules && showAllSeverities)
            {
                SortedList <DateTime, LogEntry> _entries = new SortedList <DateTime, LogEntry>();
                foreach (string module in modules)
                {
                    entries = Proxies.LogService.GetLogEntries(DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries / 2, module, null).Result.LogEntries;
                    if (entries != null && entries.Count > 0)
                    {
                        foreach (LogEntry entry in entries)
                        {
                            if (!_entries.ContainsKey(entry.LogTime))
                            {
                                _entries.Add(entry.LogTime, entry);
                            }
                        }
                    }
                }

                if (_entries != null && _entries.Count > 0)
                {
                    for (int i = _entries.Count - 1; i >= 0; i--)
                    {
                        text += "#" + _entries.Values[i].LogSeverity.ToString() + ":" + _entries.Values[i].LogTime.ToString() + ":" + _entries.Values[i].Module.ToString() + ":" + _entries.Values[i].Message + "\n";
                    }
                }
            }
            else if (!showAllModules && showAllSeverities)
            {
                entries = Proxies.LogService.GetLogEntries(DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries, selectedModule, null).Result.LogEntries;
                if (entries != null && entries.Count > 0)
                {
                    for (int i = 0; i < entries.Count; i++)
                    {
                        text += "#" + entries[i].LogSeverity.ToString() + ":" + entries[i].LogTime.ToString() + ":" + entries[i].Message + "\n";
                    }
                }
            }
            else if (showAllModules && !showAllSeverities)
            {
                entries = Proxies.LogService.GetLogEntries(DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries, null, selectedSeverity).Result.LogEntries;
                if (entries != null && entries.Count > 0)
                {
                    for (int i = 0; i < entries.Count; i++)
                    {
                        text += "#" + entries[i].LogTime.ToString() + ":" + entries[i].Module.ToString() + ":" + entries[i].Message + "\n";
                    }
                }
            }
            else if (!showAllModules && !showAllSeverities)
            {
                entries = Proxies.LogService.GetLogEntries(DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries, selectedModule, selectedSeverity).Result.LogEntries;
                if (entries != null && entries.Count > 0)
                {
                    for (int i = 0; i < entries.Count; i++)
                    {
                        text += "#" + entries[i].LogTime.ToString() + ":" + entries[i].Message + "\n";
                    }
                }
            }

            GUIDialogText dlg3 = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT);

            if (dlg3 != null)
            {
                dlg3.Reset();
                dlg3.SetHeading("Log entries");
                dlg3.SetText(text);
                dlg3.DoModal(GetID);
            }
        }