Example #1
0
        public static bool ChangeMapping(Workspace workspace, TfsContext tfs, WorkingFolder folder)
        {
            if (workspace == null)
            {
                return(false);
            }

            var dlg = new CreateMappingDialog(tfs, workspace, folder.ServerItem, folder.LocalItem)
            {
                Text       = "Change Mapping",
                ServerItem = folder.ServerItem,
                LocalItem  = folder.LocalItem
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string serverItem = dlg.ServerItem;
                string localItem  = dlg.LocalItem;
                if (serverItem.StartsWith("$"))
                {
                    try
                    {
                        workspace.DeleteMapping(folder);
                        workspace.Map(serverItem, localItem);
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                return(false);
            }
            return(false);
        }
Example #2
0
        public static bool CreateNewMapping(Workspace workspace, TfsContext tfs)
        {
            if (workspace == null)
            {
                return(false);
            }
            //var p = listViewDetails.Items.ToEnumerable().Select(item => item.SubItems[1]).OrderBy(item => item.Name);
            string defaultServerDir = workspace.Folders.FindMatchingServerBasePath();
            string defaultLocalDir  = workspace.Folders.FindMatchingLocalBasePath();

            var dlg = new CreateMappingDialog(tfs, workspace, defaultServerDir, defaultLocalDir);

            if (!String.IsNullOrEmpty(defaultLocalDir))
            {
                dlg.LocalItem = Path.GetDirectoryName(defaultLocalDir);
            }
            if (!String.IsNullOrEmpty(defaultServerDir))
            {
                dlg.ServerItem = defaultServerDir;
            }
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string serverItem = dlg.ServerItem;
                string localItem  = dlg.LocalItem;
                if (serverItem.StartsWith("$"))
                {
                    try
                    {
                        workspace.Map(serverItem, localItem);
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                return(false);
            }
            return(false);
        }