private void DockIconContainer_MouseDown(object sender, MouseButtonEventArgs e) { MouseDown = true; startPos = e.GetPosition(null); draggedIcon = GetSelectedIcon(); if (draggedIcon != null) { container.CaptureMouse(); } }
private void Dispose() { MouseDown = false; IsDragging = false; draggedIcon = null; draggedIconImage = null; placeholder = null; startPos = new Point(0, 0); offset = new Point(0, 0); lastCount = -1; }
private void PlaceDraggedIcon() { int index = container.Children.IndexOf(placeholder); container.Children.Remove(placeholder); canvas.Children.Remove(draggedIconImage); var windows = draggedIcon.Windows; draggedIcon = new DockIcon(draggedIcon.Info); foreach (var w in windows) { draggedIcon.Windows.Add(w); } container.Children.Insert(index, draggedIcon); }
static DockSpace() { top = new DockIcon("top"); bottom = new DockIcon("bottom"); left = new DockIcon("left"); right = new DockIcon("right"); topWin = new Window(new Vector2(windowBorder, 24), new Vector2(Globals.screenWidth, 0), ""); bottomWin = new Window(new Vector2(windowBorder, Globals.screenHeight - windowBorder), new Vector2(Globals.screenWidth, 0), ""); rightWin = new Window(new Vector2(Globals.screenWidth - windowBorder, 0), new Vector2(0, Globals.screenHeight), ""); leftWin = new Window(new Vector2(windowBorder, 0), new Vector2(0, Globals.screenHeight), ""); WindowFraming[0] = topWin; WindowFraming[1] = bottomWin; WindowFraming[2] = rightWin; WindowFraming[3] = leftWin; }
private void DockIconContainer_DragEnter(object sender, DragEventArgs e) { dragInProgress = true; if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } // Note that you can have more than one file. if (dragIndex == -1) { var files = (string[])e.Data.GetData(DataFormats.FileDrop); dragItem = new DockIcon(new IconModel { Path = files[0], Name = Path.GetFileNameWithoutExtension(files[0]) }); dragIndex = container.GetDropIndex(e.GetPosition(container).X - VMLocator.Main.OuterIconWidth / 2); container.Children.Insert(dragIndex, dragItem); } }
private void MouseReleased(Point pos) { if (draggedIcon == null || !MouseDown) { return; } MouseDown = false; if (IsDragging) { if (container.IsPositionWithinBounds(pos)) { draggedIcon.Info.Pinned = true; PlaceDraggedIcon(); } else { AnimationTools.FadeOut(0.2, draggedIconImage, 0, () => canvas.Children.Remove(draggedIconImage)); if (draggedIcon.Windows.Any()) { DockIcon icon = new DockIcon(draggedIcon.Info); foreach (Window w in draggedIcon.Windows) { icon.Windows.Add(w); } icon.Info.Pinned = false; container.Children.Add(icon); } } if (SettingsManager.Settings.SaveAutomatically) { container.SaveSettings(); } } else { draggedIcon.Run(); } Dispose(); container.ReleaseMouseCapture(); }
void Manager_WindowAdded(object sender, Handlers.WindowEventArgs e) { container.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { var foundItems = container.Children.OfType <DockIcon>().Select(el => el).Where( icon => PathTools.SamePath(icon.Info.Path, e.Window.FileName)); DockIcon windowIcon = null; if (foundItems.Any()) { windowIcon = foundItems.First(); } if (!foundItems.Any() || (windowIcon != null && windowIcon.Windows.Count > 0)) { windowIcon = new DockIcon(new IconInfo() { Name = Path.GetFileName(e.Window.FileName), Path = e.Window.FileName, Pinned = false }); container.Children.Add(windowIcon); } windowIcon.Windows.Add(e.Window); })); }
private void EndDrag() { dragItem = null; dragIndex = -1; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); StartupPath = System.Windows.Forms.Application.StartupPath + '\\'; DockIcon.Register(StartupPath + "Container-Empty.png", null, false); if (!DockIcon.IsRegistered) { Shutdown(); return; } DockIcon.KeepInDock = true; DockIcon.Exposable = false; DockIcon.Activatable = true; Settings.Initialize(DockIcon.SettingsPath + "settings.xml"); #region Get Previous Icon var iconName = DockIcon.IconName; if (string.IsNullOrEmpty(iconName)) { iconName = StartupPath + "Container-Empty.png"; } if (string.IsNullOrEmpty(Settings.Icon) || ((iconName != StartupPath + "Container-Empty.png") && (iconName != StartupPath + "Container-Opened.png"))) { Settings.Icon = iconName; Settings.Save(); } #endregion #region Init Path Path = Settings.Path; if (!Directory.Exists(Path)) { Path = StartupPath; } if (Path.LastIndexOf('\\') < Path.Length - 1) { Path += '\\'; } #endregion #region Start With View Mode if ((e.Args.Length >= 3) && (e.Args[0] == "-viewMode")) { Path = e.Args[2]; if (Path.LastIndexOf('\\') < Path.Length - 1) { Path += '\\'; } if (!((e.Args.Length == 4) && (e.Args[3] == "-notSetPath"))) { Settings.Path = Path; } Directories = Directory.GetDirectories(Path); Files = Directory.GetFiles(Path); DockIcon.Title = null; DockIcon.AddFolderWatcher(1, DockIcon.FolderWatcherActions.FileAdded | DockIcon.FolderWatcherActions.FileModified | DockIcon.FolderWatcherActions.FolderAdded, Path); switch (e.Args[1]) { case "fan": ViewMode = ViewModeEnum.Fan; MainWindow = new ContainerPublic.FanView(); break; case "list": ViewMode = ViewModeEnum.List; Shutdown(); return; //break; default: ViewMode = ViewModeEnum.Grid; MainWindow = new ContainerPublic.GridView(); break; } MainWindow.Show(); return; } #endregion #region Dropped files & directories into the stack if ((e.Args.Length > 0) && !((e.Args.Length == 1) && Directory.Exists(e.Args[0]))) { var droppedFiles = true; foreach (var file in e.Args) { if (!File.Exists(file) && !Directory.Exists(file)) { droppedFiles = false; break; } } if (droppedFiles) { var fileOperation = new SHFileOpStruct(); fileOperation.hwnd = IntPtr.Zero; fileOperation.wFunc = FO_Func.FO_MOVE; if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control) { fileOperation.wFunc = FO_Func.FO_COPY; } fileOperation.pFrom = StringArrayToMultiString(e.Args); fileOperation.pTo = StringArrayToMultiString(new string[] { Path }); fileOperation.hNameMappings = IntPtr.Zero; fileOperation.fAnyOperationsAborted = 0; fileOperation.fFlags = 0; fileOperation.lpszProgressTitle = null; SHFileOperation(ref fileOperation); Shutdown(); return; } } #endregion #region Start With Directory if ((e.Args.Length > 0) && Directory.Exists(e.Args[0])) { Path = e.Args[0]; if (Path.LastIndexOf('\\') < Path.Length - 1) { Path += '\\'; } if (!((e.Args.Length == 2) && (e.Args[1] == "-notSetPath"))) { Settings.Path = Path; } } #endregion #region Default Directories = Directory.GetDirectories(Path); Files = Directory.GetFiles(Path); if (Directories.Length + Files.Length <= FanView.MaxItems) { ViewMode = ViewModeEnum.Fan; } else if (Directories.Length + Files.Length <= GridView.MaxItems) { ViewMode = ViewModeEnum.Grid; } else { //ViewMode = ViewModeEnum.List; ViewMode = ViewModeEnum.Grid; } DockIcon.Title = null; DockIcon.AddFolderWatcher(1, DockIcon.FolderWatcherActions.FileAdded | DockIcon.FolderWatcherActions.FileModified | DockIcon.FolderWatcherActions.FolderAdded, Path); switch (ViewMode) { case ViewModeEnum.Fan: MainWindow = new ContainerPublic.FanView(); break; case ViewModeEnum.List: Shutdown(); return; //break; default: MainWindow = new ContainerPublic.GridView(); break; } MainWindow.Show(); #endregion }