コード例 #1
0
        public static void Run(string filepath)
        {
            List <RestoreWindowProps> windows = JsonConvert.DeserializeObject <List <RestoreWindowProps> >(File.ReadAllText(filepath));

            Utils.GetWindows()
            .ForEach(wh =>
            {
                WindowProps props = WindowProps.CreateFromHandle(wh);
                if (props == null)
                {
                    return;
                }

                RestoreWindowProps storedProps = windows.FirstOrDefault(p => p.Matches(props));
                if (storedProps != null)
                {
                    Console.WriteLine($"Restoring {props.Caption} to");
                    Console.WriteLine(JsonConvert.SerializeObject(storedProps.Rect, Formatting.Indented));
                    wh.SetWindowRect(storedProps.Rect);
                    if (storedProps.ZOrder != null)
                    {
                        wh.SetZPosition(storedProps.ZOrder.Value);
                    }
                }
            });
        }
コード例 #2
0
        public static void Run(string filepath)
        {
            List <WindowProps> windows = Utils.GetWindows().Select(wh => WindowProps.CreateFromHandle(wh)).Where(p => p != null).ToList();

            File.WriteAllText(filepath, JsonConvert.SerializeObject(windows, Formatting.Indented));
        }