Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        // Folder action changed events

        private void FolderUi_PathChanged(object sender, RoutedEventArgs e)
        {
            if (!eventBlock)
            {
                FolderAction action = (FolderAction)Shortcut.Actions[0];
                action.Path = FolderUi_Path.Text;
            }

            eventBlock = false;
        }
        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();
        }
Beispiel #4
0
 private void SetTestOutputFolders(FolderAction folderAction)
 {
     utilities.ForEach(u =>
     {
         var directory = Path.Combine(TestOutputFolder, u);
         directory.ManageTestOutputFolders(folderAction);
         if (folderAction == FolderAction.Create)
         {
             settings.Add(new Settings {
                 Context = 1, SettingName = u, Value = Path.Combine(TestOutputFolder, u), system_type_id = 167
             });
         }
     });
 }
        public static void ExecuteShortcut(Shortcut shortcut)
        {
            foreach (Action action in shortcut.Actions)
            {
                switch (action.Type)
                {
                case "command":
                    CommandAction ca = action as CommandAction;
                    System.Diagnostics.Process          process   = new System.Diagnostics.Process();
                    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                    if (!ca.KeepOpen)
                    {
                        startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                        startInfo.Arguments   = $"/C {ca.Command}";
                    }
                    else
                    {
                        startInfo.Arguments = $"/k {ca.Command}";
                    }

                    startInfo.FileName = "cmd.exe";
                    process.StartInfo  = startInfo;
                    process.Start();
                    break;

                case "file":
                    FileAction fa = action as FileAction;
                    System.Diagnostics.Process.Start(fa.Path);
                    break;

                case "folder":
                    FolderAction foa = action as FolderAction;
                    System.Diagnostics.Process.Start(foa.Path);
                    break;

                case "software":
                    SoftwareAction sa = action as SoftwareAction;
                    System.Diagnostics.Process.Start(sa.Path);
                    break;

                case "website":
                    WebsiteAction wa = action as WebsiteAction;
                    System.Diagnostics.Process.Start(wa.Url);
                    break;
                }
            }
        }
Beispiel #6
0
        private void SetFieldValuesFromShortcut()
        {
            eventBlock                         = true;
            ShortcutTitleName.Text             = $"{Enum.GetName(typeof(ShortcutType), ShortcutType)} Action";
            eventBlock                         = true;
            ShortcutTypeComboBox.SelectedIndex = (int)ShortcutType;

            switch (ShortcutType)
            {
            case ShortcutType.Web:
                WebsiteAction webaction = (WebsiteAction)Shortcut.Actions[0];
                eventBlock           = true;
                WebsiteUriField.Text = webaction.Url;
                eventBlock           = true;
                break;

            case ShortcutType.File:
                FileAction fileAction = (FileAction)Shortcut.Actions[0];
                eventBlock       = true;
                FileUi_Path.Text = fileAction.Path;
                break;

            case ShortcutType.Folder:
                FolderAction folderAction = (FolderAction)Shortcut.Actions[0];
                eventBlock         = true;
                FolderUi_Path.Text = folderAction.Path;
                break;

            case ShortcutType.Software:
                SoftwareAction softwareAction = (SoftwareAction)Shortcut.Actions[0];
                eventBlock           = true;
                SoftwareUi_Path.Text = softwareAction.Path;
                break;

            case ShortcutType.Command:
                CommandAction comaction = (CommandAction)Shortcut.Actions[0];
                eventBlock                   = true;
                CommandUi_Comand.Text        = comaction.Command;
                eventBlock                   = true;
                CommandUi_KeepOpen.IsChecked = comaction.KeepOpen;
                break;
            }

            eventBlock = false;
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        public static void ManageTestOutputFolders(this string directory, FolderAction folderAction)
        {
            switch (folderAction)
            {
            case FolderAction.Create:
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                break;

            case FolderAction.Delete:
                if (Directory.Exists(directory))
                {
                    Directory.Delete(directory, true);
                }
                break;
            }
        }
Beispiel #9
0
        private void FolderUi_PathSelectPressed(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog openFolderDialog = new System.Windows.Forms.FolderBrowserDialog();
            openFolderDialog.Description = "Select the directory for the shortcut to open.";
            System.Windows.Forms.DialogResult result = openFolderDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(openFolderDialog.SelectedPath))
                {
                    FolderAction action = (FolderAction)Shortcut.Actions[0];
                    action.Path = openFolderDialog.SelectedPath;

                    if (FolderUi_Path.Text != openFolderDialog.SelectedPath)
                    {
                        eventBlock         = true;
                        FolderUi_Path.Text = openFolderDialog.SelectedPath;
                    }
                }
            }
        }
Beispiel #10
0
        /// <inheritdoc />
        public override BlockBase FromLS(string line)
        {
            // Trim the line
            var input = line.Trim();

            // Parse the label
            if (input.StartsWith("#"))
            {
                Label = LineParser.ParseLabel(ref input);
            }

            // Parse the function
            Group = (UtilityGroup)LineParser.ParseEnum(ref input, "Group", typeof(UtilityGroup));

            // Parse specific function parameters
            switch (Group)
            {
            case UtilityGroup.List:

                ListName   = LineParser.ParseLiteral(ref input, "List Name");
                ListAction = (ListAction)LineParser.ParseEnum(ref input, "List Action", typeof(ListAction));

                switch (ListAction)
                {
                case ListAction.Join:
                    Separator = LineParser.ParseLiteral(ref input, "Separator");
                    break;

                case ListAction.Sort:
                    while (LineParser.Lookahead(ref input) == TokenType.Boolean)
                    {
                        LineParser.SetBool(ref input, this);
                    }
                    break;

                case ListAction.Concat:
                case ListAction.Zip:
                case ListAction.Map:
                    SecondListName = LineParser.ParseLiteral(ref input, "Second List Name");
                    break;

                case ListAction.Add:
                    ListItem  = LineParser.ParseLiteral(ref input, "Item");
                    ListIndex = LineParser.ParseLiteral(ref input, "Index");
                    break;

                case ListAction.Remove:
                    ListIndex = LineParser.ParseLiteral(ref input, "Index");
                    break;

                case ListAction.RemoveValues:
                    ListElementComparer = LineParser.ParseEnum(ref input, "Comparer", typeof(Comparer));
                    ListComparisonTerm  = LineParser.ParseLiteral(ref input, "Comparison Term");
                    break;
                }
                break;

            case UtilityGroup.Variable:
                VarName   = LineParser.ParseLiteral(ref input, "Var Name");
                VarAction = (VarAction)LineParser.ParseEnum(ref input, "Var Action", typeof(VarAction));

                switch (VarAction)
                {
                case VarAction.Split:
                    SplitSeparator = LineParser.ParseLiteral(ref input, "SplitSeparator");
                    break;
                }
                break;

            case UtilityGroup.Conversion:
                ConversionFrom = (Encoding)LineParser.ParseEnum(ref input, "Conversion From", typeof(Encoding));
                ConversionTo   = (Encoding)LineParser.ParseEnum(ref input, "Conversion To", typeof(Encoding));
                InputString    = LineParser.ParseLiteral(ref input, "Input");
                break;

            case UtilityGroup.File:
                FilePath   = LineParser.ParseLiteral(ref input, "File Name");
                FileAction = (FileAction)LineParser.ParseEnum(ref input, "File Action", typeof(FileAction));

                switch (FileAction)
                {
                case FileAction.Write:
                case FileAction.WriteLines:
                case FileAction.Append:
                case FileAction.AppendLines:
                case FileAction.Copy:
                case FileAction.Move:
                    InputString = LineParser.ParseLiteral(ref input, "Input String");
                    break;
                }
                break;

            case UtilityGroup.Folder:
                FolderPath   = LineParser.ParseLiteral(ref input, "Folder Name");
                FolderAction = (FolderAction)LineParser.ParseEnum(ref input, "Folder Action", typeof(FolderAction));
                break;
            }

            // Try to parse the arrow, otherwise just return the block as is with default var name and var / cap choice
            if (LineParser.ParseToken(ref input, TokenType.Arrow, false) == string.Empty)
            {
                return(this);
            }

            // Parse the VAR / CAP
            try
            {
                var varType = LineParser.ParseToken(ref input, TokenType.Parameter, true);
                if (varType.ToUpper() == "VAR" || varType.ToUpper() == "CAP")
                {
                    IsCapture = varType.ToUpper() == "CAP";
                }
            }
            catch { throw new ArgumentException("Invalid or missing variable type"); }

            // Parse the variable/capture name
            try { VariableName = LineParser.ParseToken(ref input, TokenType.Literal, true); }
            catch { throw new ArgumentException("Variable name not specified"); }

            return(this);
        }
        public ValidationError IsValid()
        {
            if (string.IsNullOrEmpty(Name))
            {
                return(new ValidationError("Shortcut Name Cannot be Empty.", this));
            }

            foreach (Action action in Actions)
            {
                switch (action.Type)
                {
                case "command":
                    CommandAction   a1    = action as CommandAction;
                    ValidationError a1Err = a1.IsValid();
                    if (a1Err != null)
                    {
                        a1Err.Shortcut = this;
                        return(a1Err);
                    }

                    break;

                case "file":
                    FileAction      a2    = action as FileAction;
                    ValidationError a2Err = a2.IsValid();
                    if (a2Err != null)
                    {
                        a2Err.Shortcut = this;
                        return(a2Err);
                    }

                    break;

                case "folder":
                    FolderAction    a3    = action as FolderAction;
                    ValidationError a3Err = a3.IsValid();
                    if (a3Err != null)
                    {
                        a3Err.Shortcut = this;
                        return(a3Err);
                    }

                    break;

                case "software":
                    SoftwareAction  a4    = action as SoftwareAction;
                    ValidationError a4Err = a4.IsValid();
                    if (a4Err != null)
                    {
                        a4Err.Shortcut = this;
                        return(a4Err);
                    }

                    break;

                case "website":
                    WebsiteAction   a5    = action as WebsiteAction;
                    ValidationError a5Err = a5.IsValid();
                    if (a5Err != null)
                    {
                        a5Err.Shortcut = this;
                        return(a5Err);
                    }

                    break;
                }
            }

            return(null);
        }
        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();
            }
        }
Beispiel #13
0
        private void SetFieldValuesFromShortcut()
        {
            eventBlock                         = true;
            ShortcutNameField.Text             = Shortcut.Name;
            ShortcutTitleName.Text             = Shortcut.Name;
            eventBlock                         = true;
            ShortcutTypeComboBox.SelectedIndex = (int)ShortcutType;
            if (!string.IsNullOrEmpty(Shortcut.IconPath))
            {
                if (!File.Exists(Shortcut.IconPath))
                {
                    Shortcut.IconPath    = string.Empty;
                    ShotcutNameText.Text = "No icon selected.";
                }
                else
                {
                    ShotcutNameText.Text = Path.GetFileName(Shortcut.IconPath);
                }
            }
            else
            {
                ShotcutNameText.Text = "No icon selected.";
            }

            switch (ShortcutType)
            {
            case ShortcutType.Web:
                WebsiteAction webaction = (WebsiteAction)Shortcut.Actions[0];
                eventBlock           = true;
                WebsiteUriField.Text = webaction.Url;
                eventBlock           = true;
                break;

            case ShortcutType.File:
                FileAction fileAction = (FileAction)Shortcut.Actions[0];
                eventBlock       = true;
                FileUi_Path.Text = fileAction.Path;
                break;

            case ShortcutType.Folder:
                FolderAction folderAction = (FolderAction)Shortcut.Actions[0];
                eventBlock         = true;
                FolderUi_Path.Text = folderAction.Path;
                break;

            case ShortcutType.Software:
                SoftwareAction softwareAction = (SoftwareAction)Shortcut.Actions[0];
                eventBlock           = true;
                SoftwareUi_Path.Text = softwareAction.Path;
                break;

            case ShortcutType.Command:
                CommandAction comaction = (CommandAction)Shortcut.Actions[0];
                eventBlock                   = true;
                CommandUi_Comand.Text        = comaction.Command;
                eventBlock                   = true;
                CommandUi_KeepOpen.IsChecked = comaction.KeepOpen;
                break;

            case ShortcutType.Multi:
                break;
            }

            eventBlock = false;
        }
Beispiel #14
0
 public FolderEvent(string folderName, FolderAction action)
 {
     FolderName = folderName;
     Action = action;
 }