internal static void FileProjectSharingLocation(Form dialogOwner, FwApp fwApp)
{
Debug.Assert(fwApp.Cache.ProjectId.IsLocal);
using (ProjectLocationSharingDlg dlg = new ProjectLocationSharingDlg(fwApp, fwApp.Cache))
{
if (dlg.ShowDialog(dialogOwner) != DialogResult.OK)
return;
string projectPath = fwApp.Cache.ProjectId.Path;
string parentDirectory = Path.GetDirectoryName(fwApp.Cache.ProjectId.ProjectFolder);
string projectsDirectory = FwDirectoryFinder.ProjectsDirectory;
if (!MiscUtils.IsUnix)
{
parentDirectory = parentDirectory.ToLowerInvariant();
projectsDirectory = projectsDirectory.ToLowerInvariant();
}
if (dlg.ProjectsSharedChecked)
{
// We now want projects shared. The only way we would be allowed to change the project folder is if it
// previously was not shared. If that's the case, change it before we switch.
if (!ClientServerServices.Current.Local.ShareMyProjects)
UpdateProjectsLocation(dlg.ProjectsFolder, fwApp, projectPath);
if (!MiscUtils.IsUnix)
projectsDirectory = FwDirectoryFinder.ProjectsDirectory.ToLowerInvariant();
if (UpdateProjectsSharing(true, dialogOwner, fwApp, projectPath, parentDirectory, projectsDirectory))
{
using (var dlgShare = new ShareProjectsFolderDlg())
dlgShare.ShowDialog();
}
}
else
{
// We don't now want projects shared. Make sure we turn it off before possibly also changing the directory.
UpdateProjectsSharing(false, dialogOwner, fwApp, projectPath, parentDirectory, projectsDirectory);
UpdateProjectsLocation(dlg.ProjectsFolder, fwApp, projectPath);
}
}
}