public EditKontext(List<IntPtr> excludedHandles = null) { _excludedHandles = excludedHandles ?? new List<IntPtr>(); InitializeComponent(); _kontext = new Kontext(string.Empty); icons.Images.Clear(); lstKontextItems.Items.Clear(); // Enumerate the kontext items var kontextItems = KontextEnumerator.GetAllItems(new List<IntPtr>(_excludedHandles)); if (kontextItems == null || !kontextItems.Any()) { return; } // Regenerate the icons list lstKontextItems.SmallImageList = null; foreach (var ki in kontextItems) { var icon = ki.GetIcon(); if (icon != null) icons.Images.Add(ki.Name, icon.ToBitmap()); } lstKontextItems.SmallImageList = icons; // Add all items lstKontextItems.Items.AddRange( kontextItems .Select(ki => new ListViewItem(ki.Name) { Tag = (object) ki, ImageKey = icons.Images.ContainsKey(ki.Name) ? ki.Name : string.Empty }).ToArray()); _previewer = new WindowsPreview(_previewWindow.Handle, (int) (Screen.FromHandle(Handle).WorkingArea.Width*0.2)); btnOk.Enabled = false; }
private void lstKontexts_MouseMove(object sender, MouseEventArgs e) { var itemAt = lstKontexts.GetItemAt(e.X, e.Y); if (itemAt == null) { ClearPreviewedContext(); } else { var kontext = itemAt.Tag as Kontext; if (kontext == null) { ClearPreviewedContext(); } else { if (kontext == _lastHoveredKontext) return; ClearPreviewedContext(); _lastHoveredKontext = kontext; var num = Width + 10; var top = Top; var width = (int) (Screen.FromHandle(Handle).WorkingArea.Width*0.15); foreach (var kontextItem in kontext.Items) { var previewWindow = new PreviewWindow(); var windowsPreview = new WindowsPreview(previewWindow.Handle, width); windowsPreview.SetPreviewFor(kontextItem.GetHandle()); if (top + previewWindow.Height > Screen.PrimaryScreen.WorkingArea.Height) { top = Top; num += width + 5; } previewWindow.Top = top; previewWindow.Left = num; top += previewWindow.Height + 5; if (top > Screen.PrimaryScreen.WorkingArea.Height) { top = Top; num += width + 5; } previewWindow.Show(); _previewWindows.Add(new PreviewContext { PreviewedWindow = previewWindow, WindowsPreview = windowsPreview, PreviewedKontext = kontextItem }); } } } }