예제 #1
0
        private void StackMenu_Drop(object sender, DragEventArgs e)
        {
            Menu            dropContainer = sender as Menu;
            SystemDirectory replacedDir   = dropContainer.DataContext as SystemDirectory;

            String[] fileNames = e.Data.GetData(DataFormats.FileDrop) as String[];
            if (fileNames != null)
            {
                foreach (String fileName in fileNames)
                {
                    if (StacksManager.AddLocation(fileName))
                    {
                        int dropIndex = StacksManager.StackLocations.IndexOf(replacedDir);
                        StacksManager.StackLocations.Move(StacksManager.StackLocations.Count - 1, dropIndex);
                    }
                }
            }
            else if (e.Data.GetDataPresent(typeof(SystemDirectory)))
            {
                SystemDirectory dropData = e.Data.GetData(typeof(SystemDirectory)) as SystemDirectory;

                int initialIndex = StacksManager.StackLocations.IndexOf(dropData);
                int dropIndex    = StacksManager.StackLocations.IndexOf(replacedDir);
                StacksManager.StackLocations.Move(initialIndex, dropIndex);
            }

            e.Handled = true;
        }
예제 #2
0
        public static void PerformAction(string verb, string fileName)
        {
            if (verb == "open")
            {
                if (Startup.DesktopWindow != null)
                    Startup.DesktopWindow.IsOverlayOpen = false;

                Interop.Shell.StartProcess(fileName);

                return;
            }
            else if (verb == "openwith")
            {
                if (Startup.DesktopWindow != null)
                    Startup.DesktopWindow.IsOverlayOpen = false;

                Interop.Shell.ShowOpenWithDialog(fileName);

                return;
            }
            else if (verb == "delete")
            {
                string displayName = Interop.Shell.GetDisplayName(fileName);
                bool? deleteChoice = CairoMessage.ShowOkCancel(String.Format(Localization.DisplayString.sDesktop_DeleteInfo, displayName), Localization.DisplayString.sDesktop_DeleteTitle, "Resources/cairoIcon.png", Localization.DisplayString.sInterface_Delete, Localization.DisplayString.sInterface_Cancel);
                if (deleteChoice.HasValue && deleteChoice.Value)
                {
                    Interop.Shell.SendToRecycleBin(fileName);
                }
                return;
            }
            else if (verb == "properties")
            {
                Interop.Shell.ShowFileProperties(fileName);
                Startup.DesktopWindow.IsOverlayOpen = false;

                return;
            }
            else if (verb == "copy")
            {
                StringCollection scPath = new StringCollection();
                scPath.Add(fileName);
                System.Windows.Forms.Clipboard.SetFileDropList(scPath);
                return;
            }
            else if (verb == "addStack")
            {
                StacksManager.AddLocation(fileName);
                return;
            }
            else if (verb == "removeStack")
            {
                StacksManager.StackLocations.Remove(new SystemDirectory(fileName, _dispatcher));
                return;
            }
        }
예제 #3
0
        private void locationDisplay_Drop(object sender, DragEventArgs e)
        {
            String[] fileNames = e.Data.GetData(DataFormats.FileDrop) as String[];
            if (fileNames != null)
            {
                foreach (String fileName in fileNames)
                {
                    StacksManager.AddLocation(fileName);
                }
            }
            else if (e.Data.GetDataPresent(typeof(SystemDirectory)))
            {
                SystemDirectory dropData = e.Data.GetData(typeof(SystemDirectory)) as SystemDirectory;

                int initialIndex = StacksManager.StackLocations.IndexOf(dropData);
                StacksManager.StackLocations.Move(initialIndex, StacksManager.StackLocations.Count - 1);
            }

            e.Handled = true;
        }
예제 #4
0
        public static void Icon_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item        = sender as MenuItem;
            string   tag         = item.Tag as string;
            string   verb        = tag.Substring(0, tag.IndexOf('|'));
            string   fileName    = tag.Substring(tag.IndexOf('|') + 1);
            string   displayName = Interop.Shell.GetDisplayName(fileName);

            if (verb == "open")
            {
                if (Startup.DesktopWindow != null)
                {
                    Startup.DesktopWindow.IsOverlayOpen = false;
                }

                Interop.Shell.StartProcess(fileName);

                return;
            }
            else if (verb == "openwith")
            {
                if (Startup.DesktopWindow != null)
                {
                    Startup.DesktopWindow.IsOverlayOpen = false;
                }

                Interop.Shell.ShowOpenWithDialog(fileName);

                return;
            }
            else if (verb == "delete")
            {
                bool?deleteChoice = CairoMessage.ShowOkCancel(String.Format(Localization.DisplayString.sDesktop_DeleteInfo, displayName), Localization.DisplayString.sDesktop_DeleteTitle, "Resources/cairoIcon.png", Localization.DisplayString.sInterface_Delete, Localization.DisplayString.sInterface_Cancel);
                if (deleteChoice.HasValue && deleteChoice.Value)
                {
                    Interop.Shell.SendToRecycleBin(fileName);
                }
                return;
            }
            else if (verb == "properties")
            {
                Interop.Shell.ShowFileProperties(fileName);
                Startup.DesktopWindow.IsOverlayOpen = false;

                return;
            }
            else if (verb == "copy")
            {
                StringCollection scPath = new StringCollection();
                scPath.Add(fileName);
                System.Windows.Forms.Clipboard.SetFileDropList(scPath);
                return;
            }
            else if (verb == "addStack")
            {
                StacksManager.AddLocation(fileName);
                return;
            }
            else if (verb == "rename")
            {
                DockPanel parent = ((Button)((ContextMenu)item.Parent).PlacementTarget).Content as DockPanel;
                TextBox   rename = parent.FindName("txtRename") as TextBox;
                Border    label  = parent.FindName("bdrFilename") as Border;

                rename.Visibility = Visibility.Visible;
                label.Visibility  = Visibility.Collapsed;
                rename.Focus();
                rename.SelectAll();
                return;
            }

            if (Startup.DesktopWindow != null)
            {
                Startup.DesktopWindow.IsOverlayOpen = false;
            }

            Interop.Shell.StartProcess(fileName, "", verb);
        }
예제 #5
0
        public static void PerformAction(string verb, string fileName)
        {
            if (verb == "open")
            {
                if (Startup.DesktopWindow != null)
                {
                    Startup.DesktopWindow.IsOverlayOpen = false;
                }

                Interop.Shell.StartProcess(fileName);

                return;
            }
            else if (verb == "openwith")
            {
                if (Startup.DesktopWindow != null)
                {
                    Startup.DesktopWindow.IsOverlayOpen = false;
                }

                Interop.Shell.ShowOpenWithDialog(fileName);

                return;
            }
            else if (verb == "delete")
            {
                string displayName  = Interop.Shell.GetDisplayName(fileName);
                bool?  deleteChoice = CairoMessage.ShowOkCancel(String.Format(Localization.DisplayString.sDesktop_DeleteInfo, displayName), Localization.DisplayString.sDesktop_DeleteTitle, "Resources/cairoIcon.png", Localization.DisplayString.sInterface_Delete, Localization.DisplayString.sInterface_Cancel);
                if (deleteChoice.HasValue && deleteChoice.Value)
                {
                    Interop.Shell.SendToRecycleBin(fileName);
                }
                return;
            }
            else if (verb == "properties")
            {
                Interop.Shell.ShowFileProperties(fileName);
                Startup.DesktopWindow.IsOverlayOpen = false;

                return;
            }
            else if (verb == "copy")
            {
                StringCollection scPath = new StringCollection();
                scPath.Add(fileName);
                System.Windows.Forms.Clipboard.SetFileDropList(scPath);
                return;
            }
            else if (verb == "addStack")
            {
                StacksManager.AddLocation(fileName);
                return;
            }
            else if (verb == "removeStack")
            {
                StacksManager.StackLocations.Remove(new SystemDirectory(fileName, _dispatcher));
                return;
            }
            else if (verb == "openWithShell")
            {
                FolderHelper.OpenWithShell(fileName);
            }
            else if (verb == "personalize")
            {
                if (Startup.IsCairoRunningAsShell)
                {
                    CairoSettingsWindow.Instance.Show();
                    CairoSettingsWindow.Instance.Activate();
                    CairoSettingsWindow.Instance.TabDesktop.IsSelected = true;
                }
                else
                {
                    Interop.Shell.StartProcess("Rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,2");
                }
            }
            else if (verb == "displaySettings")
            {
                Interop.Shell.StartProcess("Rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,3");
            }
            else
            {
                Interop.Shell.StartProcess(fileName, "", verb);
            }
        }
예제 #6
0
        public static void Icon_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item     = sender as MenuItem;
            string   tag      = item.Tag as string;
            string   verb     = tag.Substring(0, tag.IndexOf('|'));
            string   fileName = tag.Substring(tag.IndexOf('|') + 1);
            string   displayName;

            if (Settings.ShowFileExtensions)
            {
                displayName = Path.GetFileName(fileName);
            }
            else
            {
                displayName = Path.GetFileNameWithoutExtension(fileName);
            }

            if (verb == "open")
            {
                Interop.Shell.StartProcess(fileName);
                return;
            }
            else if (verb == "openwith")
            {
                Interop.Shell.ShowOpenWithDialog(fileName);
                return;
            }
            else if (verb == "delete")
            {
                bool?deleteChoice = CairoMessage.ShowOkCancel("\"" + displayName + "\" will be sent to the Recycle Bin.", "Are you sure you want to delete this?", "Resources/cairoIcon.png", "Delete", "Cancel");
                if (deleteChoice.HasValue && deleteChoice.Value)
                {
                    Interop.Shell.SendToRecycleBin(fileName);
                }
                return;
            }
            else if (verb == "properties")
            {
                Interop.Shell.ShowFileProperties(fileName);
                return;
            }
            else if (verb == "copy")
            {
                StringCollection scPath = new StringCollection();
                scPath.Add(fileName);
                System.Windows.Forms.Clipboard.SetFileDropList(scPath);
                return;
            }
            else if (verb == "addStack")
            {
                StacksManager.AddLocation(fileName);
                return;
            }
            else if (verb == "rename")
            {
                DockPanel parent = ((Button)((ContextMenu)item.Parent).PlacementTarget).Content as DockPanel;
                TextBox   rename = parent.FindName("txtRename") as TextBox;
                Border    label  = parent.FindName("bdrFilename") as Border;

                rename.Visibility = Visibility.Visible;
                label.Visibility  = Visibility.Collapsed;
                rename.Focus();
                rename.SelectAll();
                return;
            }

            Interop.Shell.StartProcess(fileName, "", verb);
        }