예제 #1
0
        public static void OrganizeFileInProject(VCFileWrapper file)
        {
            if (file.RelativePath == null)
            {
                throw new InvalidOperationException("project root not set");
            }

            VCProjectWrapper project    = file.ContainingProject;
            string           filterPath = Path.GetDirectoryName(file.RelativePath);

            ContainerWrapper newParent;

            if (String.IsNullOrEmpty(filterPath))
            {
                newParent = project;
            }
            else
            {
                newParent = project.CreateFilterPath(filterPath);
            }

            if (!file.Parent.Equals(newParent))
            {
                file.Move(newParent);
            }
        }
예제 #2
0
        public static bool SaveSettings(VCProjectWrapper project)
        {
            ExtensionSettings settings     = GetSettings(project);
            XmlSerializer     serializer   = new XmlSerializer(typeof(ExtensionSettings));
            string            settingsFile = GetSettingsPath(project);

            try
            {
                TextWriter fileStream = new StreamWriter(settingsFile, false);

                try
                {
                    serializer.Serialize(fileStream, settings);
                }
                finally
                {
                    fileStream.Close();
                }
            }
            catch
            {
                MessageBox.Show("Error: Could not save VC File Utils settings!", "VC File Utils", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
예제 #3
0
        public static ExtensionSettings GetDefaultSettings(VCProjectWrapper project)
        {
            ExtensionSettings settings = new ExtensionSettings();

            settings.RelativeProjectRoot = null;
            return(settings);
        }
        protected override void OnExecute()
        {
            VCProjectWrapper project = SolutionHelper.GetProjectOfSelection(Package);

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.SelectedPath        = project.GetProjectDirectory();
            dlg.ShowNewFolderButton = false;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ExtensionSettings settings   = SettingsManager.GetSettings(project);
                string            projectDir = project.GetProjectDirectory();
                settings.RelativeProjectRoot = PathHelper.GetRelativePath(projectDir, dlg.SelectedPath + Path.DirectorySeparatorChar);
                SettingsManager.SaveSettings(project);
            }
        }
예제 #5
0
        public static ExtensionSettings GetSettings(VCProjectWrapper project)
        {
            ExtensionSettings settings;

            settingsDict.TryGetValue(project, out settings);

            if (settings == null)
            {
                string settingsFile = GetSettingsPath(project);

                if (!File.Exists(settingsFile))
                {
                    settings = GetDefaultSettings(project);
                }
                else
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ExtensionSettings));

                    try
                    {
                        TextReader fileStream = new StreamReader(settingsFile);

                        try
                        {
                            settings = (ExtensionSettings)serializer.Deserialize(fileStream);
                        }
                        finally
                        {
                            fileStream.Close();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Error: Could not load VC File Utils settings!", "VC File Utils", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        settings = GetDefaultSettings(project);
                    }
                }

                settingsDict.Add(project, settings);
            }

            return(settings);
        }
예제 #6
0
 static string GetSettingsPath(VCProjectWrapper project)
 {
     return(Path.Combine(Path.GetDirectoryName(project.ProjectFile), "vc-fileutils.settings"));
 }