Esempio n. 1
0
 private void RestoreWindows()
 {
     try
     {
         if (WindySerializationHelpers.RestoreWindows())
         {
             _trayIcon.ShowBalloonTip(5000,
                                      GetString("TipTitle_WindowsAutomaticallyRestored"),
                                      GetString("TipText_WindowsAutomaticallyRestored"),
                                      ToolTipIcon.Info);
         }
         else
         {
             _trayIcon.ShowBalloonTip(5000,
                                      GetString("TipTitle_NoWindowsToRestore"),
                                      GetString("TipText_NoWindowsToRestore"),
                                      ToolTipIcon.Info);
         }
     }
     catch (Exception ex)
     {
         _trayIcon.ShowBalloonTip(10000,
                                  GetString("TipTitle_CouldntRestoreWindows"),
                                  string.Format(GetString("TipText_WindowsNotAutomaticallyRestored"),
                                                ex.Message,
                                                ex.GetType()),
                                  ToolTipIcon.Error);
     }
 }
Esempio n. 2
0
        private void PopulateSavedWindows()
        {
            _savedWindows.DropDownItems.Clear();

            IEnumerable <Window> windows;

            if (WindySerializationHelpers.RestoreWindows(out windows))
            {
                _savedWindows.DropDownItems.AddRange(
                    windows.Select(
                        win =>
                        new ToolStripMenuItem(string.Format("{0} ({1}\xd7{2} @ {3},{4} - {5})", win.Title, win.Size.Width,
                                                            win.Size.Height, win.Location.X, win.Location.Y, win.State), null,
                                              (sender, args) =>
                {
                    try
                    {
                        WindyPInvokeWrappers.FocusWindow(win);
                    }
                    catch (Exception)
                    {
                        _trayIcon.ShowBalloonTip(10000,
                                                 GetString("TipTitle_CouldntShowWindow"),
                                                 GetString("TipText_CouldntShowWindow"),
                                                 ToolTipIcon.Error);
                    }
                })
                {
                    Enabled = true
                }).ToArray());
            }
            else
            {
                _savedWindows.DropDownItems.Add(new ToolStripMenuItem(GetString("NoSavedWindows"))
                {
                    Enabled = false
                });
            }
        }