/// <summary> /// Saves the state of opened windows, urls, etc to preferences /// so that state can be restored when the app is restarted. /// </summary> private void SaveSession() { if (ServiceManager.Preferences.GetIntPref("browser.homepage.mode") == 2) { bool isLastPageOnly = ServiceManager.Preferences.GetIntPref("browser.session.windowmode") == 0; WindowMediator wm = ServiceManager.WindowMediator; IEnumerator browsers = wm.GetEnumeratorForType("BrowserWindow"); int count = 0; while (browsers.MoveNext()) { if (isLastPageOnly && count > 0) { // XXX need to |getMostRecentWindow| instead of just taking the first. break; } BrowserWindow currWindow = browsers.Current as BrowserWindow; String pref = "browser.session.windows."; pref += currWindow.Type + count++; ServiceManager.Preferences.SetStringPref(pref, currWindow.URL); ServiceManager.Preferences.SetIntPref(pref + ".left", currWindow.Left); ServiceManager.Preferences.SetIntPref(pref + ".top", currWindow.Top); ServiceManager.Preferences.SetIntPref(pref + ".width", currWindow.Width); ServiceManager.Preferences.SetIntPref(pref + ".height", currWindow.Height); } // XXX need to save session histories. } }
public ViewModel(WindowMediator contrastMediator, WindowMediator rotateMediator, WindowMediator resizeMediator, WindowMediator filterWindowMediator) { OpenImageCommand = new RelayCommand(OpenImage, s => IsView); OpenedImage = new ImageStorageModel(); NextCommand = new RelayCommand(s => ++ CurrentIndex, s => OpenedImage.IsNext && IsView); PrevCommand = new RelayCommand(s => -- CurrentIndex, s => OpenedImage.IsPrev && IsView); RemoveCommand = new RelayCommand(RemoveImage, s => !OpenedImage.IsEmpty); SaveCommand = new RelayCommand(SaveImage, s => IsEdit); RotateCommand = new RelayCommand(OpenRotate, s => !OpenedImage.IsEmpty); ResizeCommand = new RelayCommand(OpenResize, s => !OpenedImage.IsEmpty); ContrastAndBrightnessCommand = new RelayCommand(OpenBrightness, s => !OpenedImage.IsEmpty); DetectFaceCommand = new RelayCommand(DetectFace, s => !OpenedImage.IsEmpty); PalettingCommand = new RelayCommand(Paletting, s => !OpenedImage.IsEmpty); FilterCommand = new RelayCommand(Filter, s => !OpenedImage.IsEmpty); GrayscaleCommand = new RelayCommand(Grayscale, s => !OpenedImage.IsEmpty); ContrastAndBrightnessWindowContrastMediator = contrastMediator; RotateWindowMediator = rotateMediator; ResizeWindowMediator = resizeMediator; FilterWindowMediator = filterWindowMediator; ContrastAndBrightnessWindowContrastMediator.OnClose += BrigthnessWindowClosed; RotateWindowMediator.OnClose += RotateClosed; ResizeWindowMediator.OnClose += ResizeWindowClosed; FilterWindowMediator.OnClose += FilterClosed; BrightnessViewModel.PropertyChanged += BrigthnessChanged; RotateViewModel.PropertyChanged += RotateChanged; OpenedImage.PropertyChanged += UpdateCurrentView; }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); var ws = WindowMediator.GetEnumerator(null); wmWindowCount = 0; while (ws.MoveNext()) { wmWindowCount++; } ws = Gecko.Services.WindowWatcher.GetWindowEnumerator(); wwWindowCount = 0; while (ws.MoveNext()) { wwWindowCount++; } browser1 = new GeckoWebBrowser(); var unused = browser1.Handle; browser2 = new GeckoWebBrowser(); unused = browser2.Handle; Assert.IsNotNull(browser1); Assert.IsNotNull(browser2); }
protected void Init() { WindowMediator wm = ServiceManager.WindowMediator; wm.RegisterWindow(this); this.Closed += new EventHandler(OnClosed); this.Activated += new EventHandler(OnActivated); }
protected void OnTreeDoubleClick(Object sender, EventArgs e) { ManticoreTreeNode node = mBookmarksTree.SelectedNode as ManticoreTreeNode; Bookmarks bmks = ServiceManager.Bookmarks; String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url"); if (bookmarkURL != "") { WindowMediator wm = ServiceManager.WindowMediator; BrowserWindow window = wm.GetMostRecentWindow("BrowserWindow") as BrowserWindow; if (window != null) { window.LoadURL(bookmarkURL); } } }
private static void OnUpdate() { Dictionary <string, WindowMediator.WindowCacheData> .Enumerator enumerator = WindowMediator.mCacheUIPanel.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <string, WindowMediator.WindowCacheData> current = enumerator.Current; WindowMediator.WindowCacheData data = current.Value; if (Facade.Instance.RetrieveMediator(data.name) == null) { KeyValuePair <string, WindowMediator.WindowCacheData> pair2 = enumerator.Current; if ((Time.realtimeSinceStartup - pair2.Value.lasttime) > 180f) { WindowMediator.RemoveCache(data.name); break; } } } }
public MainWindow() { InitializeComponent(); var contrastWindow = new WindowMediator { CreateWindow = () => new ContrastAndBrightness() }; var rotateWindow = new WindowMediator { CreateWindow = () => new RotateWindow() }; var resizeWindow = new WindowMediator { CreateWindow = () => new ResizeWindow() }; var filterWindow = new WindowMediator { CreateWindow = () => new FilterWindow() }; DataContext = new ViewModel.ViewModel(contrastWindow, rotateWindow, resizeWindow, filterWindow); }
public void WindowMediator_GetWindows() { browser1.LoadHtml("<p>1", urls[0]); browser1.NavigateFinishedNotifier.BlockUntilNavigationFinished(); browser2.LoadHtml("<p>2", urls[1]); browser2.NavigateFinishedNotifier.BlockUntilNavigationFinished(); Assert.AreEqual(urls[1], new GeckoWindow(WindowMediator.GetMostRecentWindow(null)).Document.Uri); var ws = WindowMediator.GetEnumerator(null); int i = 0; while (ws.MoveNext()) { if (i >= wmWindowCount) { Assert.AreEqual(urls[i - wmWindowCount], ws.Current.Document.Uri); } i++; } Assert.AreEqual(urls.Length, i - wmWindowCount); }
public void OnActivated(Object sender, EventArgs e) { WindowMediator wm = ServiceManager.WindowMediator; wm.SetMostRecentWindow(this); }
public void OnClosed(Object sender, EventArgs e) { WindowMediator wm = ServiceManager.WindowMediator; wm.UnregisterWindow(this); }