コード例 #1
0
ファイル: RenameFolderCommand.cs プロジェクト: huizh/xenadmin
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            string newName = _newName;
            Folders.FixupRelativePath(ref newName);

            FolderAction action = new FolderAction(_folder, newName, FolderAction.Kind.Rename);
            action.Completed += action_Completed;
            action.RunAsync();
        }
コード例 #2
0
ファイル: Folders.cs プロジェクト: huizh/xenadmin
        public static void Unfolder(Session session, IXenObject ixmo)
        {
            if (ixmo == null)
                return;

            FolderAction action = new FolderAction(ixmo, null, FolderAction.Kind.Delete);
            if (session == null)
                action.RunAsync();
            else
                action.RunExternal(session);
        }
コード例 #3
0
ファイル: NewFolderCommand.cs プロジェクト: huizh/xenadmin
        private void Execute(Folder folder, IWin32Window ownerWindow)
        {
            IXenConnection connection;
            String name;

            // Different dialogs depending whether we're at the top level or adding a subfolder.
            // Also offer them a choice of connections if the connection they're on is Read Only
            // (although we will also sudo a Read Only command when the FolderAction is run).
            if (folder == null || folder.IsRootFolder || folder.Connection == null || CrossConnectionCommand.IsReadOnly(folder.Connection))
            {
                NameAndConnectionPrompt dialog = new NameAndConnectionPrompt();
                dialog.Text = Messages.NEW_FOLDER_DIALOG_TITLE;
                dialog.OKText = Messages.CREATE_MNEMONIC_R;
                dialog.HelpID = "NewFolderDialog";
                if (dialog.ShowDialog(ownerWindow) != DialogResult.OK)
                    return;
                name = dialog.PromptedName;
                connection = dialog.Connection;
            }
            else
            {
                name = InputPromptDialog.Prompt(ownerWindow, Messages.NEW_FOLDER_NAME, Messages.NEW_FOLDER_DIALOG_TITLE, "NewFolderDialog");
                connection = folder.Connection;
            }

            if (name == null)
                return;  // Happens if InputPromptDialog was cancelled

            List<string> newPaths = new List<string>();
            foreach (string s in name.Split(';'))
            {
                string n = s;
                Folders.FixupRelativePath(ref n);
                if (string.IsNullOrEmpty(n))
                    continue;

                newPaths.Add(Folders.AppendPath(folder == null ? Folders.PATH_SEPARATOR : folder.opaque_ref, n));
            }

            if (newPaths.Count > 0)
            {
                FolderAction action = new FolderAction(connection, FolderAction.Kind.New, newPaths.ToArray());

                Action<ActionBase> completed = null;
                completed = delegate
                {
                    action.Completed -= completed;
                    if (action.Succeeded)
                    {
                        Program.MainWindow.TrySelectNewNode(delegate(object o)
                        {
                            Folder ff = o as Folder;
                            return ff != null && newPaths[0] == ff.opaque_ref;
                        }, true, true, true);
                    }
                };

                action.Completed += completed;
                action.RunAsync();
            }
        }
コード例 #4
0
ファイル: Folders.cs プロジェクト: huizh/xenadmin
        public static void Move(Session session, IXenObject ixmo, Folder target)
        {
            if (ixmo == null || target == null)
                return;

            // First check we're not moving parent -> child
            if (target.IsChildOf(ixmo))
                return;

            // Then check the object is not already in the folder
            for (int i = 0; i < target.XenObjects.Length; i++)
            {
                if (target.XenObjects[i].opaque_ref == ixmo.opaque_ref)
                    return;
            }

            FolderAction action = new FolderAction(ixmo, target, FolderAction.Kind.Move);
            if (session == null)
                action.RunAsync();
            else
                action.RunExternal(session);
        }