private SystemListView GetDesktopListView() { SystemWindow[] sws = SystemWindow.FilterToplevelWindows(delegate(SystemWindow sw) { return(sw.ClassName == "Progman" && sw.Title == "Program Manager" && sw.Process.ProcessName == "explorer"); }); if (sws.Length != 1) { MessageBox.Show("Could not find Desktop window"); return(null); } sws = sws[0].FilterDescendantWindows(false, delegate(SystemWindow sw) { return(sw.ClassName == "SysListView32" && sw.Title == "FolderView"); }); if (sws.Length != 1) { MessageBox.Show("Could not find Desktop window"); return(null); } SystemListView slv = SystemListView.FromSystemWindow(sws[0]); if (slv == null) { MessageBox.Show("No desktop icons found"); } return(slv); }
private void restore_Click(object sender, EventArgs e) { SystemListView desktop = GetDesktopListView(); if (desktop == null) { return; } string f = filename.Text + ".deskicon"; if (!File.Exists(f)) { MessageBox.Show("File not found", "DeskIconRestore", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } using (StreamReader sr = new StreamReader(new FileStream(f, FileMode.Open, FileAccess.Read))) { while (!sr.EndOfStream) { string line = sr.ReadLine(); PlaceDesktopIcon(desktop, line); } } Dispose(); }
static void Main(string[] args) { // Create a SystemWindow object from the HWND of the ListView SystemWindow lvWindow = new SystemWindow((IntPtr)0x6d1d38); // Create a ListView object from the SystemWindow object var lv = SystemListView.FromSystemWindow(lvWindow); // Read text from a row var text = lv[0].Title; }
public void SystemListView_ShowExactlyWorldSystems() { var listView = new SystemListView( new TreeViewState(), new MultiColumnHeader(SystemListView.GetHeaderState()), (manager, world) => { }, () => World.Active); var managerItems = listView.GetRows().Where(x => listView.managersById.ContainsKey(x.id)).Select(x => listView.managersById[x.id]); Assert.AreEqual(World.Active.BehaviourManagers.Count(), managerItems.Intersect(World.Active.BehaviourManagers).Count()); }
public void Add(string _hwnd) { IntPtr hwnd = (IntPtr)Convert.ToInt32(_hwnd, 16); lvWindow = new SystemWindow(hwnd); lv = SystemListView.FromSystemWindow(lvWindow); MyHook = new Hook(HookType.WH_CALLWNDPROC, false, false); MyHook.Callback += MyHookCallback; MyHook.StartHook(); }
public static SystemListView GetSystemListView(SystemWindow systemWindow) { var systemListView = SystemListView.FromSystemWindow(systemWindow); if (systemListView == null) { Log.WriteLine("There were no desktop icons."); } return(systemListView); }
public void SystemListView_CanCreateWithNullWorld() { SystemListView listView; var states = new List <TreeViewState>(); var stateNames = new List <string>(); Assert.DoesNotThrow(() => { listView = SystemListView.CreateList(states, stateNames, SetSystemSelection, () => null, () => true); listView.Reload(); }); }
public void SystemListView_ShowExactlyWorldSystems() { var listView = new SystemListView( new TreeViewState(), new MultiColumnHeader(SystemListView.GetHeaderState()), (system, world) => { }, () => World2, () => true); var systemItems = listView.GetRows().Where(x => listView.systemsById.ContainsKey(x.id)).Select(x => listView.systemsById[x.id]); var systemList = systemItems.ToList(); Assert.AreEqual(World2.Systems.Count(), systemList.Intersect(World2.Systems).Count()); }
public void SystemListView_NullWorldShowsAllSystems() { var listView = new SystemListView( new TreeViewState(), new MultiColumnHeader(SystemListView.GetHeaderState()), (manager, world) => { }, () => null); var managerItems = listView.GetRows().Where(x => listView.managersById.ContainsKey(x.id)).Select(x => listView.managersById[x.id]); var allManagers = new List <ScriptBehaviourManager>(); foreach (var world in World.AllWorlds) { allManagers.AddRange(world.BehaviourManagers); } Assert.AreEqual(allManagers.Count, allManagers.Intersect(managerItems).Count()); }
private void PlaceDesktopIcon(SystemListView desktop, string line) { string[] fields = line.Split(':'); if (fields.Length != 3) { return; } for (int i = 0; i < desktop.Count; i++) { if (desktop[i].Title == fields[0]) { desktop[i].Position = new Point(int.Parse(fields[1]), int.Parse(fields[2])); return; } } }
public void SystemListView_NullWorldShowsAllSystems() { var listView = new SystemListView( new TreeViewState(), new MultiColumnHeader(SystemListView.GetHeaderState()), (system, world) => { }, () => null, () => true); var systemItems = listView.GetRows().Where(x => listView.systemsById.ContainsKey(x.id)).Select(x => listView.systemsById[x.id]); var allSystems = new List <ComponentSystemBase>(); allSystems.AddRange(World.Systems); allSystems.AddRange(World2.Systems); var systemList = systemItems.ToList(); Assert.AreEqual(allSystems.Count(x => !(x is ComponentSystemGroup)), allSystems.Intersect(systemList).Count()); }
public void SystemListView_NullWorldShowsAllSystems() { var listView = new SystemListView( new TreeViewState(), new MultiColumnHeader(SystemListView.GetHeaderState()), (manager, world) => { }, () => null, () => true); var managerItems = listView.GetRows().Where(x => listView.managersById.ContainsKey(x.id)).Select(x => listView.managersById[x.id]); var allManagers = new List <ScriptBehaviourManager>(); allManagers.AddRange(World.Active.BehaviourManagers); allManagers.AddRange(World2.BehaviourManagers); var managerList = managerItems.ToList(); Assert.AreEqual(allManagers.Count(x => !(x is EntityManager || x is ComponentSystemGroup)), allManagers.Intersect(managerList).Count()); }
public void SystemListView_ShowExactlyWorldSystems() { var listView = new SystemListView( new TreeViewState(), new MultiColumnHeader(SystemListView.GetHeaderState()), (system, world) => { }, () => World2, () => true); var systemItems = listView.GetRows().Where(x => listView.systemsById.ContainsKey(x.id)).Select(x => listView.systemsById[x.id]); var systemList = systemItems.ToList(); var world2Systems = new List <ComponentSystemBase>(); foreach (var system in World2.Systems) { world2Systems.Add(system); } Assert.That(world2Systems, Is.EquivalentTo(systemList.Intersect(world2Systems))); }
public SystemListViewElement(int id, int depth, World world) : base(id, depth) { var headerState = BuildHeaderState(false); if (MultiColumnHeaderState.CanOverwriteSerializedFields(systemMultiColumnHeaderState, headerState)) { MultiColumnHeaderState.OverwriteSerializedFields(systemMultiColumnHeaderState, headerState); } systemMultiColumnHeaderState = headerState; var systemMultiColumnHeader = new MultiColumnHeader(headerState); if (systemTreeViewState == null) { systemTreeViewState = new TreeViewState(); } systemMultiColumnHeader.ResizeToFit(); SystemListView = new SystemListView(systemTreeViewState, systemMultiColumnHeader, world); SystemListView.UpdateIfNecessary(); }
private string[] GetDesktopIcons() { SystemListView desktop = GetDesktopListView(); if (desktop == null) { return(null); } string[] result = new string[desktop.Count]; string[] titles = new string[desktop.Count]; for (int i = 0; i < desktop.Count; i++) { Point p = desktop[i].Position; if (Array.IndexOf <string>(titles, desktop[i].Title) != -1) { MessageBox.Show("Warning: Duplicate icon name '" + desktop[i].Title + "'", "DeskIconRestore", MessageBoxButtons.OK, MessageBoxIcon.Information); } titles[i] = desktop[i].Title; result[i] = titles[i] + ":" + p.X + ":" + p.Y; } return(result); }
internal override WindowContent ParseContent(SystemWindow sw) { uint LVM_GETITEMCOUNT = (0x1000 + 4); int cnt = sw.SendGetMessage(LVM_GETITEMCOUNT); if (cnt == 0 && sw.ClassName != "SysListView32") { throw new Exception(); } try { SystemListView slv = SystemListView.FromSystemWindow(sw); // are there column headers? string[] hdr = null; SystemListViewColumn[] columns = slv.Columns; if (columns.Length > 0) { hdr = new string[columns.Length]; for (int i = 0; i < hdr.Length; i++) { hdr[i] = columns[i].Title; } } int itemCount = slv.Count; List <string> values = new List <string>(); for (int i = 0; i < itemCount; i++) { SystemListViewItem item = slv[i]; string name = item.Title; if (hdr != null) { for (int j = 1; j < hdr.Length; j++) { SystemListViewItem subitem = slv[i, j]; name += "\t" + subitem.Title; } } values.Add(name); } if (hdr != null) { string lines = "", headers = ""; foreach (string h in hdr) { if (lines.Length > 0) { lines += "\t"; } if (headers.Length > 0) { headers += "\t"; } headers += h; lines += ListContent.Repeat('~', h.Length); } values.Insert(0, lines); values.Insert(0, headers); return(new ListContent("DetailsListView", -1, null, values.ToArray())); } else { return(new ListContent("ListView", -1, null, values.ToArray())); } } catch { // fallback to slower accessible object method } SystemAccessibleObject o = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT); if (o.RoleIndex == 33) { // are there column headers? int cs = o.Children.Length; string[] hdr = null; if (cs > 0) { SystemAccessibleObject headers = o.Children[cs - 1]; if (headers.RoleIndex == 9 && headers.Window != sw) { SystemAccessibleObject hdrL = SystemAccessibleObject.FromWindow(headers.Window, AccessibleObjectID.OBJID_CLIENT); hdr = new string[hdrL.Children.Length]; for (int i = 0; i < hdr.Length; i++) { if (hdrL.Children[i].RoleIndex != 25) { hdr = null; break; } hdr[i] = hdrL.Children[i].Name; } if (hdr != null) { cs--; } } } List <string> values = new List <string>(); for (int i = 0; i < cs; i++) { if (o.Children[i].RoleIndex == 34) { string name = o.Children[i].Name; if (hdr != null) { try { string cols = o.Children[i].Description; if (cols == null && values.Count == 0) { hdr = null; } else { string tmpCols = "; " + cols; List <string> usedHdr = new List <string>(); foreach (string header in hdr) { string h = "; " + header + ": "; if (tmpCols.Contains(h)) { usedHdr.Add(header); tmpCols = tmpCols.Substring(tmpCols.IndexOf(h) + h.Length); } } foreach (string header in hdr) { name += "\t"; if (usedHdr.Count > 0 && usedHdr[0] == header) { if (!cols.StartsWith(header + ": ")) { throw new Exception(); } cols = cols.Substring(header.Length + 1); string elem; if (usedHdr.Count > 1) { int pos = cols.IndexOf("; " + usedHdr[1] + ": "); elem = cols.Substring(0, pos); cols = cols.Substring(pos + 2); } else { elem = cols; cols = ""; } name += elem; usedHdr.RemoveAt(0); } } } } catch (COMException ex) { if (ex.ErrorCode == -2147352573 && values.Count == 0) { hdr = null; } else { throw ex; } } } values.Add(name); } } if (hdr != null) { string lines = "", headers = ""; foreach (string h in hdr) { if (lines.Length > 0) { lines += "\t"; } if (headers.Length > 0) { headers += "\t"; } headers += h; lines += ListContent.Repeat('~', h.Length); } values.Insert(0, lines); values.Insert(0, headers); return(new ListContent("DetailsListView", -1, null, values.ToArray())); } else { return(new ListContent("ListView", -1, null, values.ToArray())); } } else { return(new ListContent("EmptyListView", -1, null, new string[0])); } }
public DesktopIconSetter() { var mainSystemWindow = MainSystemWindowGetter.GetMainSystemWindow(); _systemListView = SystemListViewGetter.GetSystemListView(mainSystemWindow); }