Esempio n. 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            _info = new WindowSaveInfo();
            _info.ForegroundWindow = WinAPI.GetCurrentWindow();
            List <IntPtr> lst = WinAPI.GetAllWindows();
            Graph         g   = new Graph();

            foreach (IntPtr hWnd in lst)
            {
                WindowPosition wp = WindowPosition.FromHandle(hWnd);
                _info.WindowSave.Add(hWnd, wp);
                g.AddEdge(hWnd, wp.NextWindow);
            }
            _info.IterOrder = g.ToplogicalSort().Select(x => x.Handle).Reverse().ToList();
            this.btnWriteToFile.IsEnabled = true;
            this.btnLoad.IsEnabled        = true;
            this.txtCurrent.Text          = "User Save @ " + DateTime.Now;
            if (this.chkAutoSave.IsChecked.HasValue && this.chkAutoSave.IsChecked.Value)
            {
                if (!Directory.Exists(AUTOSAVE_DIR))
                {
                    Directory.CreateDirectory(AUTOSAVE_DIR);
                }
                string timeStr  = DateTime.Now.ToString("yyyyMMddhhmmssfff");
                string filename = Path.Combine(AUTOSAVE_DIR, timeStr + ".wsi");
                _info.Save(filename);
            }
        }
Esempio n. 2
0
        private void btnWriteToFile_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog()
            {
                Title  = "Save Window Info",
                Filter = "Window Save Info|*.wsi"
            };
            bool?result = sfd.ShowDialog();

            if (result.HasValue && result.Value)
            {
                string file = sfd.FileName;
                _info.Save(file);
            }
        }