base class for every window. It contains all methods needed for basic window management like - initialization - deitialization - render itself onscreen - processing actions like keypresses, mouse clicks/movements - processing messages Each window plugin should derive from this base class Pluginwindows should be copied in the plugins/windows folder
Inheritance: ISupportInitialize, IDisposable
    public virtual void PageLoad(int ParentID)
    {
      CloseRoutedWindow();

      _parentWindowID = ParentID;
      _parentWindow = GUIWindowManager.GetWindow(_parentWindowID);
      if (_parentWindow == null)
      {
        _parentWindowID = 0;
        return;
      }
      GUIWindowManager.IsSwitchingToNewWindow = true;
      lock (thisLock)
      {
        GUIWindowManager.RouteToWindow(GetID);
        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, _parentWindowID, 0,
                                        null);
        OnMessage(msg);
        _running = true;
      }
      GUIWindowManager.IsSwitchingToNewWindow = false;

      while (IsAnimating(AnimationType.WindowOpen) &&
             GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
      {
        GUIWindowManager.Process();
      }
    }
Exemple #2
0
        public void DoModal(int dwParentId)
        {
            //Log.Debug("TvMiniGuide: DoModal");
              _parentWindowID = dwParentId;
              _parentWindow = GUIWindowManager.GetWindow(_parentWindowID);
              if (null == _parentWindow)
              {
            //Log.Debug("TvMiniGuide: parentwindow = null");
            _parentWindowID = 0;
            return;
              }

              GUIWindowManager.IsSwitchingToNewWindow = true;
              GUIWindowManager.RouteToWindow(GetID);

              // activate this window...
              GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, -1, 0, null);
              OnMessage(msg);

              GUIWindowManager.IsSwitchingToNewWindow = false;
              _running = true;
              GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog);
              while (_running && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
              {
            GUIWindowManager.Process();
              }

              Close();
        }
    public void DoModal(int dwParentId)
    {
      _parentWindowId = dwParentId;
      _parentWindow = GUIWindowManager.GetWindow(_parentWindowId);
      if (null == _parentWindow)
      {
        _parentWindowId = 0;
        return;
      }
      GUIWindowManager.IsSwitchingToNewWindow = true;
      GUIWindowManager.RouteToWindow(GetID);
      GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog);

      // active this window... (with its own OnPageLoad)
      PageLoad();

      GUIWindowManager.IsSwitchingToNewWindow = false;
      _keyboard.IsVisible = true;
      _keyboard.Position = _keyboard.TextEntered.Length;
      while (_keyboard.IsVisible && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
      {
        GUIWindowManager.Process();
      }

      PageDestroy();
    }
    /// <summary>
    /// Do this modal
    /// </summary>
    /// <param name="dwParentId"></param>
    public void DoModal(int parentId)
    {
      _parentWindowID = parentId;
      _parentWindow = GUIWindowManager.GetWindow(_parentWindowID);
      if (null == _parentWindow)
      {
        _parentWindowID = 0;
        return;
      }

      GUIWindowManager.IsSwitchingToNewWindow = true;
      GUIWindowManager.RouteToWindow(GetID);

      // activate this window...
      GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, -1, 0, null);
      OnMessage(msg);

      GUIWindowManager.IsSwitchingToNewWindow = false;
      _running = true;
      GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog);
      while (_running && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
      {
        GUIWindowManager.Process();
        if (!GUIGraphicsContext.Vmr9Active)
        {
          Thread.Sleep(50);
        }
      }
      GUILayerManager.UnRegisterLayer(this);
    }
    public void Close()
    {
      GUIWindowManager.IsSwitchingToNewWindow = true;
      lock (this)
      {
        if (m_bDialogActive)
        {
          GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, 0, 0, null);
          OnMessage(msg);
        }

        GUIWindowManager.UnRoute();
        m_pParentWindow = null;
        m_bRunning = false;
        GUIGraphicsContext.Overlay = m_bOverlay;
      }
      GUIWindowManager.IsSwitchingToNewWindow = false;
    }
    public void PageDestroy()
    {
      if (!_keyboard._useSearchLayout && !_keyboard._password)
      {
        using (MediaPortal.Profile.MPSettings xmlwriter = new Profile.MPSettings())
        {
          xmlwriter.SetValueAsBool("general", "smsstyleinput", _keyboard.SmsStyleText);
        }
      }
      GUIWindowManager.IsSwitchingToNewWindow = true;
      lock (this)
      {
        base.OnPageDestroy(_parentWindowId);
        GUIGraphicsContext.Overlay = _previousOverlayVisible;
        Dispose();

        GUIWindowManager.UnRoute();
        _parentWindow = null;
      }
      GUIWindowManager.IsSwitchingToNewWindow = false;
      GUILayerManager.UnRegisterLayer(this);

      Log.Debug("Window: {0} deinit", ToString());
    }
    /// <summary>
    /// Removes all windows 
    /// </summary>
    public static void Clear()
    {
      CloseCurrentWindow();
      GUIGraphicsContext.Receivers -= new SendMessageHandler(SendThreadMessage);
      GUIGraphicsContext.OnNewAction -= new OnActionHandler(OnActionReceived);

      LockAndDoOnAllRegisteredWindows(window =>
                                        {
                                          window.DeInit();
                                          window.SafeDispose();
                                        });
      _routedWindow = null;
      _listThreadMessages.Clear();
      _listThreadActions.Clear();
      GUIWindow.Clear();
    }
    public override bool OnMessage(GUIMessage message)
    {
      switch (message.Message)
      {
        case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
          {
            base.OnMessage(message);
            m_pParentWindow = null;
            m_bRunning = false;
            GUIGraphicsContext.Overlay = m_bOverlay;
            //base.OnMessage(message);
            Dispose();
            DeInitControls();
            GUILayerManager.UnRegisterLayer(this);
            return true;
          }
        case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
          {
            m_bDialogActive = true;
            base.OnMessage(message);
            GUIGraphicsContext.Overlay = base.IsOverlayAllowed;
            m_pParentWindow = GUIWindowManager.GetWindow(m_dwParentWindowID);
            GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog);
          }
          return true;

        case GUIMessage.MessageType.GUI_MSG_CLICKED:
          {
            int iAction = message.Param1;
            int iControl = message.SenderControlId;
            if (btnCancel != null && iControl == (int)btnCancel.GetID)
            {
              m_bCanceled = true;
              if (!m_bBusy)
              {
                Close();
              }
            }

            if (btnYes != null && iControl == (int)btnYes.GetID)
            {
              if (!m_bBusy)
              {
                m_bBusy = true;
                FileItemMC(m_itemSourceItem);
                m_bBusy = false;
                Close();
              }
              else
              {
                m_bButtonYes = true;
              }
            }

            if (btnNo != null && iControl == (int)btnNo.GetID)
            {
              m_bButtonNo = true;
            }

            if (btnAlways != null && iControl == (int)btnAlways.GetID)
            {
              m_bAlways = true;
            }

            if (btnNever != null && iControl == (int)btnNever.GetID)
            {
              m_bNever = true;
            }
          }
          break;
      }

      if (m_pParentWindow != null)
      {
        if (message.TargetWindowId == m_pParentWindow.GetID)
        {
          return m_pParentWindow.OnMessage(message);
        }
      }
      return base.OnMessage(message);
    }
 public override void OnInit()
 {
   base.OnInit();
   // ensure that we are always the last entry in the GUIWindow.Children 
   // -> HitTest always starts from the last entry
   _parentWin = GUIWindowManager.GetWindow(_windowId);
   if (_parentWin != null)
   {
     _parentWin.Children.Remove(this);
     _parentWin.Children.Add(this);
     _isWinOverlayAllowed = _parentWin.IsOverlayAllowed;
   }
   SetDefaultControl();
   _buttonState = NextButtonStates.Activation;
 }
    public static void Replace(int windowId, GUIWindow window)
    {
      lock (thisLock)
      {
        GUIWindow existingWindow = GetWindow(windowId);

        if (existingWindow != null)
        {
          Log.Debug("WindowManager: Replaced {0} with {1}", existingWindow, window);
          ISetupForm frm = window as ISetupForm;
          if (frm != null)
          {
            for (int x = 0; x < PluginManager.SetupForms.Count; ++x)
            {
              if (((ISetupForm)PluginManager.SetupForms[x]).GetWindowId() == windowId)
              {
                Log.Debug("WindowManager: Setup...");
                PluginManager.SetupForms.RemoveAt(x);
                break;
                //PluginManager.SetupForms[x] = frm;
              }
            }
          }
          _listWindows[windowId] = window;
        }
      }
    }
Exemple #11
0
    public void History(GUIListControl _List, GUIWindow _GUI)
    {
      try
      {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(new XmlTextReader(CreateURL("api?mode=history", "output=xml", false)));

        if (xmlDoc.SelectSingleNode("history/slots") != null)
        {
          _List.Clear();

          string strItemInfo = String.Empty;

          foreach (XmlNode nodeItem in xmlDoc.SelectNodes("history/slots/slot"))
          {
            DateTime dtPubDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(double.Parse(nodeItem["completed"].InnerText));

            strItemInfo = String.Empty;

            foreach (XmlNode nodeInfo in nodeItem.SelectNodes("stage_log/slot"))
            {
              strItemInfo += ((strItemInfo.Length > 0) ? Environment.NewLine : String.Empty) + nodeInfo["name"].InnerText + ":" + Environment.NewLine;

              foreach (XmlNode nodeProgress in nodeInfo.SelectNodes("actions/item"))
              {
                strItemInfo += nodeProgress.InnerText + Environment.NewLine;
              }
            }

            MP.ListItem(_List, nodeItem["name"].InnerText, nodeItem["status"].InnerText, strItemInfo, dtPubDate, 0, String.Empty, String.Empty, 4);
          }

          GUIPropertyManager.SetProperty("#Status", "History Loaded");
        }
        else
        {
          GUIPropertyManager.SetProperty("#Status", "Error parsing XML");
        }
      }
      catch (Exception e) { MP.Error(e); }
      finally
      {
        if (_List.Count > 0)
        {
          _GUI.LooseFocus();
          _List.Focus = true;
        }
      }
    }
Exemple #12
0
    public void QueueItem(GUIListControl _List, GUIWindow _GUI)
    {
      List<GUIListItem> _Items = new List<GUIListItem>();

      if (_List.SelectedListItemIndex != 0)
      {
        _Items.Add(new GUIListItem("Move Up"));
        if (_List.Count > 1)
        {
          _Items.Add(new GUIListItem("Move to Top"));
        }
      }

      if (_List.SelectedListItemIndex != (_List.Count - 1))
      {
        _Items.Add(new GUIListItem("Move Down"));
        if (_List.Count > 1)
        {
          _Items.Add(new GUIListItem("Move to Bottom"));
        }
      }

      _Items.Add(new GUIListItem("Delete Job"));

      if (_List.ListItems[_List.SelectedListItemIndex].Label2 == "Paused")
      {
        _Items.Add(new GUIListItem("Resume Job"));
      }
      else
      {
        _Items.Add(new GUIListItem("Pause Job"));
      }

      _Items.Add(new GUIListItem("Change Category"));

      _Items.Add(new GUIListItem("Change Priority"));

      GUIListItem _Option = MP.Menu(_Items, "Job Options");
      if (_Option != null)
      {
        switch (_Option.Label)
        {
          case "Move Up":
            SendURL(CreateURL("api?mode=switch&value=" + _List.ListItems[_List.SelectedListItemIndex].Path + "&value2=" + _List.ListItems[_List.SelectedListItemIndex - 1].Path, String.Empty, false));
            break;
          case "Move Down":
            SendURL(CreateURL("api?mode=switch&value=" + _List.ListItems[_List.SelectedListItemIndex].Path + "&value2=" + _List.ListItems[_List.SelectedListItemIndex + 1].Path, String.Empty, false));
            break;
          case "Move to Top":
            SendURL(CreateURL("api?mode=switch&value=" + _List.ListItems[_List.SelectedListItemIndex].Path + "&value2=" + _List.ListItems[0].Path, String.Empty, false));
            break;
          case "Move to Bottom":
            SendURL(CreateURL("api?mode=switch&value=" + _List.ListItems[_List.SelectedListItemIndex].Path + "&value2=" + _List.ListItems[_List.Count - 1].Path, String.Empty, false));
            break;
          case "Delete Job":
            SendURL(CreateURL("api?mode=queue&name=delete&value=" + _List.ListItems[_List.SelectedListItemIndex].Path, String.Empty, false));
            break;
          case "Pause Job":
            SendURL(CreateURL("api?mode=queue&name=pause&value=" + _List.ListItems[_List.SelectedListItemIndex].Path, String.Empty, false));
            break;
          case "Resume Job":
            SendURL(CreateURL("api?mode=queue&name=resume&value=" + _List.ListItems[_List.SelectedListItemIndex].Path, String.Empty, false));
            break;
          case "Change Category":
            SendURL(CreateURL("api?mode=change_cat&value=" + _List.ListItems[_List.SelectedListItemIndex].Path + "&value2=" + SelectCategory(), String.Empty, false));
            break;
          case "Change Priority":
            SendURL(CreateURL("api?mode=queue&name=priority&value=" + _List.ListItems[_List.SelectedListItemIndex].Path + "&value2=" + SelectPriority(), String.Empty, false));
            break;
        }
        Queue(_List, _GUI, true);
      }
    }
Exemple #13
0
    public void Queue(GUIListControl _List, GUIWindow _GUI, bool refocus)
    {
        int selectedIndex = _List.SelectedListItemIndex;

        try
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(new XmlTextReader(CreateURL("api?mode=queue", "output=xml", false)));

            if (xmlDoc.SelectSingleNode("queue/slots") != null)
            {
                if (refocus)
                {
                    _List.Clear();
                }

                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
                string strJobInfo;

                int i = 0;
                foreach (XmlNode nodeItem in xmlDoc.SelectNodes("queue/slots/slot"))
                {
                    strJobInfo = "Status: " + nodeItem["status"].InnerText + Environment.NewLine + "Filename: " + nodeItem["filename"].InnerText + Environment.NewLine + "Priority: " + nodeItem["priority"].InnerText + Environment.NewLine + "Category: " + nodeItem["cat"].InnerText + Environment.NewLine + "Percentage: " + nodeItem["percentage"].InnerText + "%";

                    double mbdone = double.Parse(nodeItem["mb"].InnerText, nfi) - double.Parse(nodeItem["mbleft"].InnerText, nfi);

                    if (_List.Count > i && !refocus)
                    {
                        MP.UpdateListItem(i, _List, nodeItem["filename"].InnerText, ((nodeItem["status"].InnerText == "Paused") ? "Paused" : mbdone.ToString("N2") + " / " + double.Parse(nodeItem["mb"].InnerText, nfi).ToString("N2") + " MB"), strJobInfo, DateTime.Now, 0, String.Empty, nodeItem["nzo_id"].InnerText, 3);
                    }
                    else
                    {
                        MP.ListItem(_List, nodeItem["filename"].InnerText, ((nodeItem["status"].InnerText == "Paused") ? "Paused" : mbdone.ToString("N2") + " / " + double.Parse(nodeItem["mb"].InnerText, nfi).ToString("N2") + " MB"), strJobInfo, DateTime.Now, 0, String.Empty, nodeItem["nzo_id"].InnerText, 3);
                    }

                    ++i;
                }

                GUIPropertyManager.SetProperty("#Status", "Queue Loaded");
            }
            else
            {
                GUIPropertyManager.SetProperty("#Status", "Error parsing XML");
            }
        }
        catch (Exception e) { MP.Error(e); }
        finally
        {
            if (_List.Count > 0 && refocus)
            {
                _GUI.LooseFocus();
                _List.Focus = true;
            }
            else if (_List.IsFocused && _List.Count > selectedIndex)
            {
                _List.SelectedListItemIndex = selectedIndex;
            }
        }
    }
 public virtual void PageDestroy()
 {
   if (_running == false)
   {
     return;
   }
   GUIWindowManager.IsSwitchingToNewWindow = true;
   lock (thisLock)
   {
     GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, _parentWindowID, 0,
                                     null);
     OnMessage(msg);
     if (GUIWindowManager.RoutedWindow == GetID)
     {
       GUIWindowManager.UnRoute(); // only unroute if we still the routed window
     }
     _parentWindow = null;
     _running = false;
   }
   GUIWindowManager.IsSwitchingToNewWindow = false;
   while (IsAnimating(AnimationType.WindowClose) &&
          GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
   {
     GUIWindowManager.Process();
   }
 }
Exemple #15
0
        void Close()
        {
            GUIWindowManager.IsSwitchingToNewWindow = true;
            lock (this) {
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, 0, 0, null);
                OnMessage(msg);

                GUIWindowManager.UnRoute();
                m_pParentWindow = null;
                m_bRunning = false;
            }
            GUIWindowManager.IsSwitchingToNewWindow = false;
        }
    /// <summary>
    /// tell the window manager to unroute the current routing
    /// </summary>
    public static void UnRoute()
    {
      lock (thisLock)
      {
        if (_routedWindow != null)
        {
          Log.Debug("WindowManager: unroute to {0}:{1}->{2}:{3}",
                    _routedWindow, _routedWindow.GetID, GetWindow(ActiveWindow), ActiveWindow);

          GUIMessage msgDlg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _routedWindow.GetID, 0, 0,
                                 _routedWindow.PreviousWindowId, 0, null);
          _routedWindow.OnMessage(msgDlg);
        }
        //if (_currentWindowName != string.Empty && _routedWindow != null)
        {
          GUIPropertyManager.SetProperty("#currentmodule", _currentWindowName);
        }

        _routedWindow = null;
        _shouldRefresh = true;
      }
    }
    public override bool OnMessage(GUIMessage message)
    {
      switch (message.Message)
      {
        case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
          {
            _prevLayer = GUILayerManager.GetLayer(GUILayerManager.LayerType.Dialog);
            _prevOverlay = GUIGraphicsContext.Overlay;

            GUIGraphicsContext.Overlay = base.IsOverlayAllowed;

            GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog);

            GUIPropertyManager.SetProperty("#currentmoduleid", Convert.ToString(GUIWindowManager.ActiveWindow));
            GUIPropertyManager.SetProperty("#currentmodule", GetModuleName());
            Log.Debug("DialogWindow: {0} init", this.ToString());

            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SETFOCUS, GetID, 0, _defaultControlId, 0, 0,
                                            null);
            OnMessage(msg);

            OnPageLoad();

            return true;
          }

        case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
          {
            //base.OnMessage(message);
            // TODO: Establishes a circular loop
            // OnPageDestroy(_parentWindowID);
            OnPageDestroy(GetID); // mantis 2996: Dialog windows do not animate when closed

            _running = false;
            _parentWindowID = 0;
            _parentWindow = null;
            GUIGraphicsContext.Overlay = _prevOverlay;
            Dispose();
            DeInitControls();
            GUILayerManager.UnRegisterLayer(this);
            GUILayerManager.RegisterLayer(_prevLayer, GUILayerManager.LayerType.Dialog);

            _prevLayer = null;

            return true;
          }
      }
      return base.OnMessage(message);
    }
 public static void RouteToWindow(int dialogId)
 {
   lock (thisLock)
   {
     _shouldRefresh = true;
     _routedWindow = GetWindow(dialogId);
     Log.Debug("WindowManager: route {0}:{1}->{2}:{3}",
               GetWindow(ActiveWindow), ActiveWindow, _routedWindow, dialogId);
     _currentWindowName = GUIPropertyManager.GetProperty("#currentmodule");
   }
 }
    /// <summary>
    /// Close current window. When MediaPortal closes
    /// we need to close current window
    /// </summary>
    public static void CloseCurrentWindow()
    {
      Log.Debug("Windowmanager: closing current window");
      _isSwitchingToNewWindow = true;
      try
      {
        int fromWindowId = ActiveWindow;

        if (OnPostRenderAction != null)
        {
          OnPostRenderAction(null, null, false);
        }

        // deactivate current window
        GUIWindow pWindow = GetWindow(ActiveWindow, false);

        // deactivate any window
        if (_routedWindow != null)
        {
          GUIMessage msgDlg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _routedWindow.GetID, 0, 0,
                                             ActiveWindow, 0, null);
          _routedWindow.OnMessage(msgDlg);
          _routedWindow = null;
        }

        if (pWindow != null)
        {
          GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, ActiveWindow, 0, 0,
                                          _previousActiveWindowId, 0, null);
          pWindow.OnMessage(msg);
          if (OnDeActivateWindow != null)
          {
            OnDeActivateWindow(pWindow.GetID);
          }
        }
        _activeWindowId = -1;
      }
      finally
      {
        _isSwitchingToNewWindow = false;
      }
    }
 /// <summary>
 /// Add new window to the window manager
 /// </summary>
 /// <param name="Window">new window to add</param>
 public static void Add(ref GUIWindow Window)
 {
   if (Window == null)
   {
     return;
   }
   lock (thisLock)
   {
     if (!_listWindows.ContainsKey(Window.GetID))
     {
       //Log.Info("Add window :{0} id:{1}", Window.ToString(), Window.GetID);
       _listWindows.Add(Window.GetID, Window);
     }
     //else Log.Error("Window:{0} and window {1} have the same id's!!!", Window, _listWindows[i]);
   }
   _windowCount++;
   Window.OnAdded();
 }
Exemple #21
0
        private void Close()
        {
            GUIWindowManager.IsSwitchingToNewWindow = true;
              lock (this)
              {
            GUIMessage msg = null;
            msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, 0, 0, null);
            OnMessage(msg);

            GUIWindowManager.UnRoute();

            msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, _parentWindow.GetID, 0, 0, -1, 0, null);
            OnMessage(msg);

            GUIWindowManager.ActivateWindow(_parentWindow.GetID);

            _parentWindow = null;
              }
              GUIWindowManager.IsSwitchingToNewWindow = false;
              GUILayerManager.UnRegisterLayer(this);
        }
    private static void ActivateWindow(int newWindowId, bool replaceWindow, bool skipHistory, String loadParameter)
    {
      _isSwitchingToNewWindow = true;
      try
      {
        if (OnPostRenderAction != null)
        {
          OnPostRenderAction(null, null, false);
        }
        if (_routedWindow != null)
        {
          GUIMessage msgDlg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _routedWindow.GetID, 0, 0,
                                             newWindowId, 0, null);
          _routedWindow.OnMessage(msgDlg);
          _routedWindow = null;
        }

        GUIMessage msg;
        GUIWindow previousWindow = null;
        GUIWindow newWindow = null;
        int previousWindowID = _activeWindowId;


        // set nextwindow id
        _nextWindowID = newWindowId;
        // get active window
        previousWindow = GetWindow(ActiveWindow, false);
        // store current window settings
        if (!replaceWindow)
        {
          // push active window id to window stack
          if (newWindowId != _activeWindowId && !skipHistory)
          {
            AddNewWindowToHistory(_activeWindowId);
          }
        }
        //deactivate previous window
        if (previousWindow != null)
        {
          msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, previousWindow.GetID, 0, 0, newWindowId, 0,
                               null);
          previousWindow.OnMessage(msg);
          if (OnDeActivateWindow != null)
          {
            OnDeActivateWindow(previousWindow.GetID);
          }
          UnRoute();
          if (!replaceWindow)
          {
            _previousActiveWindowId = _activeWindowId;
          }
          _activeWindowId = -1;
        }

        #region find new window

        // find the new window
        newWindow = GetWindow(newWindowId, false);

        if (newWindow == null)
        {
          // new window doesnt exists. (maybe .xml file is invalid or doesnt exists)
          // so we go back to the previous (last active) window
          // Remove the stored (last active) window from the list cause we are going back to that window
          if ((!replaceWindow) && (_listHistory.Count > 0))
          {
            _listHistory.RemoveAt(_listHistory.Count - 1);
          }
          // Get previous window id (previous to the last active window) id
          if (_listHistory.Count <= 0)
          {
            if (_startWithBasicHome && File.Exists(GUIGraphicsContext.Skin + @"\basichome.xml"))
            {
              _previousActiveWindowId = (int)GUIWindow.Window.WINDOW_SECOND_HOME;
            }
            else
            {
              _previousActiveWindowId = (int)GUIWindow.Window.WINDOW_HOME;
            }
          }
          newWindowId = _previousActiveWindowId;
          // Check if replacement window was fault, ifso return to home          
          if (replaceWindow)
          {
            // activate HOME window
            if (_startWithBasicHome && File.Exists(GUIGraphicsContext.Skin + @"\basichome.xml"))
            {
              newWindowId = (int)GUIWindow.Window.WINDOW_SECOND_HOME;
            }
            else
            {
              newWindowId = (int)GUIWindow.Window.WINDOW_HOME;
            }
          }
          // (re)load            
          newWindow = GetWindow(newWindowId, false);
        }

        #endregion

        //activate the new window
        _activeWindowId = newWindow.GetID;
        if (OnActivateWindow != null)
        {
          OnActivateWindow(_activeWindowId);
        }
        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, _activeWindowId, 0, 0, _previousActiveWindowId,
                             0, loadParameter);
        newWindow.OnMessage(msg);
      }
      catch (Exception ex)
      {
        Log.Error("Exception: {0}", ex.ToString());
      }
      finally
      {
        _isSwitchingToNewWindow = false;
        _nextWindowID = -1;
      }
    }
    public void DoModal(int dwParentId)
    {
      m_bOverlay = GUIGraphicsContext.Overlay;
      m_dwParentWindowID = dwParentId;
      m_pParentWindow = GUIWindowManager.GetWindow(m_dwParentWindowID);
      if (null == m_pParentWindow)
      {
        m_dwParentWindowID = 0;
        return;
      }

      if (m_directory == null)
      {
        m_directory = new VirtualDirectory();
      }

      // show menu
      ShowFileMenu(m_itemSourceItem);
    }
Exemple #24
0
 public bool GetDialogInfo(GUIWindow.Window dialogWindow, ref string DialogTitle, ref string DialogHighlightedItem)
 {
   GUIListControl control = null;
   bool focus = false;
   switch (dialogWindow)
   {
     case GUIWindow.Window.WINDOW_DIALOG_YES_NO:
     case GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO:
       {
         GUIDialogYesNo window = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)dialogWindow);
         DialogTitle = string.Empty;
         foreach (object obj16 in window.controlList)
         {
           if (obj16.GetType() == typeof (GUIFadeLabel))
           {
             GUIFadeLabel label3 = obj16 as GUIFadeLabel;
             if (DialogTitle == string.Empty)
             {
               if (label3.Label != string.Empty)
               {
                 DialogTitle = label3.Label;
               }
             }
             else if (label3.Label != string.Empty)
             {
               DialogTitle = DialogTitle + " - " + label3.Label;
             }
           }
           if (obj16.GetType() == typeof (GUILabelControl))
           {
             GUILabelControl control14 = obj16 as GUILabelControl;
             if (DialogTitle == string.Empty)
             {
               if (control14.Label != string.Empty)
               {
                 DialogTitle = control14.Label;
               }
             }
             else if (control14.Label != string.Empty)
             {
               DialogTitle = DialogTitle + " - " + control14.Label;
             }
           }
           if (obj16.GetType() == typeof (GUIButtonControl))
           {
             GUIButtonControl control15 = obj16 as GUIButtonControl;
             if (!control15.Focus)
             {
               continue;
             }
             DialogHighlightedItem = control15.Description;
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_PROGRESS:
       {
         GUIDialogProgress progress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)dialogWindow);
         foreach (object obj6 in progress.controlList)
         {
           if (obj6.GetType() == typeof (GUILabelControl))
           {
             GUILabelControl control6 = obj6 as GUILabelControl;
             if (control6.GetID == 1)
             {
               DialogTitle = control6.Label;
             }
           }
         }
         foreach (object obj7 in progress.controlList)
         {
           if (obj7.GetType() == typeof (GUIProgressControl))
           {
             GUIProgressControl control7 = obj7 as GUIProgressControl;
             DialogHighlightedItem = "Progress: " + control7.Percentage.ToString() + "%";
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_SELECT:
       {
         GUIDialogSelect select = (GUIDialogSelect)GUIWindowManager.GetWindow((int)dialogWindow);
         control = null;
         focus = false;
         foreach (object obj9 in select.controlList)
         {
           if (obj9.GetType() == typeof (GUIListControl))
           {
             control = obj9 as GUIListControl;
             focus = control.Focus;
           }
         }
         if ((control != null) & focus)
         {
           string strLabel = string.Empty;
           string str5 = string.Empty;
           string strThumb = string.Empty;
           string strIndex = string.Empty;
           control.GetSelectedItem(ref strLabel, ref str5, ref strThumb, ref strIndex);
           DialogHighlightedItem = strLabel;
         }
         else
         {
           foreach (object obj10 in select.controlList)
           {
             if (obj10.GetType() == typeof (GUIButtonControl))
             {
               GUIButtonControl control10 = obj10 as GUIButtonControl;
               if (control10.Focus)
               {
                 DialogHighlightedItem = control10.Description;
               }
             }
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_OK:
       {
         GUIDialogOK gok = (GUIDialogOK)GUIWindowManager.GetWindow((int)dialogWindow);
         foreach (object obj5 in gok.controlList)
         {
           if (obj5.GetType() == typeof (GUIButtonControl))
           {
             GUIButtonControl control4 = obj5 as GUIButtonControl;
             if (control4.Focus)
             {
               DialogHighlightedItem = control4.Description;
               Settings.Instance.LogInfo(
                   "MiniDisplay.GetDialogInfo(): found WINDOW_DIALOG_OK buttoncontrol ID = {0} Label = \"{1}\" Desc = \"{2}\"",
                   control4.GetID, control4.Label, control4.Description);
             }
           }
           if (obj5.GetType() == typeof (GUIFadeLabel))
           {
             GUIFadeLabel label = obj5 as GUIFadeLabel;
             if (DialogTitle == string.Empty)
             {
               if (label.Label != string.Empty)
               {
                 DialogTitle = label.Label;
               }
             }
             else if (label.Label != string.Empty)
             {
               DialogTitle = DialogTitle + " - " + label.Label;
             }
           }
           if (obj5.GetType() == typeof (GUILabelControl))
           {
             GUILabelControl control5 = obj5 as GUILabelControl;
             if (DialogTitle == string.Empty)
             {
               if (control5.Label != string.Empty)
               {
                 DialogTitle = control5.Label;
               }
               continue;
             }
             if (control5.Label != string.Empty)
             {
               DialogTitle = DialogTitle + " - " + control5.Label;
             }
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_SELECT2:
       {
         GUIDialogSelect2 select2 = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)dialogWindow);
         control = null;
         focus = false;
         foreach (object obj11 in select2.controlList)
         {
           if (obj11.GetType() == typeof (GUIListControl))
           {
             control = obj11 as GUIListControl;
             focus = control.Focus;
           }
         }
         if ((control != null) & focus)
         {
           string str7 = string.Empty;
           string str8 = string.Empty;
           string str9 = string.Empty;
           string strIndex = string.Empty;
           control.GetSelectedItem(ref str7, ref str8, ref str9, ref strIndex);
           DialogHighlightedItem = str7;
         }
         else
         {
           foreach (object obj12 in select2.controlList)
           {
             if (obj12.GetType() == typeof (GUIButtonControl))
             {
               GUIButtonControl control11 = obj12 as GUIButtonControl;
               if (control11.Focus)
               {
                 DialogHighlightedItem = control11.Description;
               }
             }
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_MENU:
       {
         GUIDialogMenu menu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)dialogWindow);
         foreach (object obj13 in menu.controlList)
         {
           if (obj13.GetType() == typeof (GUILabelControl))
           {
             GUILabelControl control12 = obj13 as GUILabelControl;
             if (!control12.Label.Trim().ToLowerInvariant().Equals("menu"))
             {
               DialogTitle = control12.Label;
             }
           }
         }
         control = null;
         focus = false;
         foreach (object obj14 in menu.controlList)
         {
           if (obj14.GetType() == typeof (GUIListControl))
           {
             control = obj14 as GUIListControl;
             focus = control.Focus;
           }
         }
         if ((control != null) & focus)
         {
           string str10 = string.Empty;
           string str11 = string.Empty;
           string str12 = string.Empty;
           string strIndex = string.Empty;
           control.GetSelectedItem(ref str10, ref str11, ref str12, ref strIndex);
           DialogHighlightedItem = str10;
         }
         else
         {
           foreach (object obj15 in menu.controlList)
           {
             if (obj15.GetType() == typeof (GUIButtonControl))
             {
               GUIButtonControl control13 = obj15 as GUIButtonControl;
               if (control13.Focus)
               {
                 DialogHighlightedItem = control13.Description;
               }
             }
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_RATING:
       {
         GUIDialogSetRating rating = (GUIDialogSetRating)GUIWindowManager.GetWindow((int)dialogWindow);
         DialogTitle = string.Empty;
         foreach (object obj8 in rating.controlList)
         {
           if (obj8.GetType() == typeof (GUIFadeLabel))
           {
             GUIFadeLabel label2 = obj8 as GUIFadeLabel;
             if (DialogTitle == string.Empty)
             {
               if (label2.Label != string.Empty)
               {
                 DialogTitle = label2.Label;
               }
             }
             else if (label2.Label != string.Empty)
             {
               DialogTitle = DialogTitle + " - " + label2.Label;
             }
           }
           if (obj8.GetType() == typeof (GUILabelControl))
           {
             GUILabelControl control8 = obj8 as GUILabelControl;
             if (DialogTitle == string.Empty)
             {
               if (control8.Label != string.Empty)
               {
                 DialogTitle = control8.Label;
               }
             }
             else if (control8.Label != string.Empty)
             {
               DialogTitle = DialogTitle + " - " + control8.Label;
             }
           }
           if (obj8.GetType() == typeof (GUIButtonControl))
           {
             GUIButtonControl control9 = obj8 as GUIButtonControl;
             if (!control9.Focus)
             {
               continue;
             }
             DialogHighlightedItem = control9.Description;
           }
         }
         return true;
       }
     case GUIWindow.Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT:
       {
         GUIDialogMenuBottomRight right = (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)dialogWindow);
         DialogTitle = string.Empty;
         foreach (object obj2 in right.controlList)
         {
           if (obj2.GetType() == typeof (GUILabelControl))
           {
             GUILabelControl control2 = obj2 as GUILabelControl;
             if (!control2.Label.Trim().ToLowerInvariant().Equals("menu") && (control2.Label != string.Empty))
             {
               if (DialogTitle == string.Empty)
               {
                 DialogTitle = control2.Label;
               }
               else
               {
                 DialogTitle = DialogTitle + " - " + control2.Label;
               }
             }
           }
         }
         control = null;
         focus = false;
         foreach (object obj3 in right.controlList)
         {
           if (obj3.GetType() == typeof (GUIListControl))
           {
             control = obj3 as GUIListControl;
             focus = control.Focus;
           }
         }
         if ((control != null) & focus)
         {
           string str = string.Empty;
           string str2 = string.Empty;
           string str3 = string.Empty;
           string strIndex = string.Empty;
           control.GetSelectedItem(ref str, ref str2, ref str3, ref strIndex);
           DialogHighlightedItem = str;
         }
         else
         {
           foreach (object obj4 in right.controlList)
           {
             if (obj4.GetType() == typeof (GUIButtonControl))
             {
               GUIButtonControl control3 = obj4 as GUIButtonControl;
               if (control3.Focus)
               {
                 DialogHighlightedItem = control3.Description;
               }
             }
           }
         }
         return true;
       }
   }
   return false;
 }
    public virtual void PageDestroy()
    {
      if (_running == false)
      {
        return;
      }

      try
      {
        GUIWindowManager.IsSwitchingToNewWindow = true;
        if (!_destroyingPage)
        {
          _destroyingPage = true;
          GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, _parentWindowID, 0,
                                          null);
          OnMessage(msg);
          if (GUIWindowManager.RoutedWindow == GetID)
          {
            GUIWindowManager.UnRoute(); // only unroute if we still the routed window
          }
          _parentWindow = null;
          _running = false;
          _destroyingPage = false;
        }
        GUIWindowManager.IsSwitchingToNewWindow = false;
        while (IsAnimating(AnimationType.WindowClose) &&
               GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING)
        {
          GUIWindowManager.Process();
        }

      }
      catch (System.Exception ex)
      {
        _destroyingPage = false;
        Log.Error("Error during PageDestroy(): " + ex.Message);
      }
    }
    public void Show(int dwParentId)
    {
      m_dwParentWindowID = dwParentId;
      m_pParentWindow = GUIWindowManager.GetWindow(m_dwParentWindowID);

      GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, GetID, 0, null);
      GUIWindowManager.SendThreadMessage(msg);
    }
 public void SetActiveWindow(GUIWindow.Window _window)
 {
   if (base.InvokeRequired)
   {
     base.Invoke(new SetActiveWindowDelegate(this.SetActiveWindow), new object[] {_window});
   }
   this.txtActiveWindow.Text = _window.ToString();
 }