/// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private async void MenuItemCallback(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Settings.Default.AnidePath))
            {
                var dlg = new ConfigurationDialog();
                dlg.ShowModal();
            }

            if (string.IsNullOrEmpty(Settings.Default.AnidePath))
            {
                return;
            }

            try
            {
                var envDte = await GetServiceAsync(typeof(DTE)) as DTE;

                var projectItem = envDte.SelectedItems.OfType <SelectedItem>().First().ProjectItem;
                var project     = projectItem.ContainingProject; //it should have at least one item
                var fileName    = project.FileName;

                var synchronizer = new ProjectsSynchronizer(fileName, Settings.Default.AnidePath);
                await synchronizer.MakeResourcesSubdirectoriesAndFilesLowercase(async() => await AskPermissionToChangeCsProj());
                await ShowSuggestionsAsync();

                synchronizer.Sync(projectItem.FileCount > 0 ? projectItem.FileNames[0] : string.Empty);
                project.Save();
            }
            catch (OperationCanceledException)
            {
            }
            catch (CsprojEditFailedException exc)
            {
                await ShowErrorDuringSync(".csproj edit failed: {0} ", exc);
            }
            catch (FileRenameToLowercaseException exc)
            {
                await ShowErrorDuringSync("Renaming {0} to lowercase failed: {1}", exc.FileName, exc);
            }
            catch (Exception exc)
            {
                await ShowErrorDuringSync("General failure: {0}", exc);
            }
        }
示例#2
0
        private void SettingsMenuItemCallback(object sender, EventArgs e)
        {
            var dlg = new ConfigurationDialog();

            dlg.ShowModal();
        }
 private void SettingsMenuItemCallback(object sender, EventArgs e)
 {
     var dlg = new ConfigurationDialog();
     dlg.ShowModal();
 }
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private async void MenuItemCallback(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Settings.Default.AnidePath))
            {
                var dlg = new ConfigurationDialog();
                dlg.ShowModal();
            }

            if (string.IsNullOrEmpty(Settings.Default.AnidePath))
                return;

            try
            {
                var envDte = GetService(typeof(DTE)) as DTE;
                var projectItem = envDte.SelectedItems.OfType<SelectedItem>().First().ProjectItem;
                var project = projectItem.ContainingProject; //it should have at least one item
                var fileName = project.FileName;

                var synchronizer = new ProjectsSynchronizer(fileName, Settings.Default.AnidePath);
                await synchronizer.MakeResourcesSubdirectoriesAndFilesLowercase(async () => AskPermissionToChangeCsProj());
                ShowSuggestions();
                synchronizer.Sync(projectItem.FileCount > 0 ? projectItem.FileNames[0] : string.Empty);
                project.Save();
            }
            catch (OperationCanceledException)
            {
            }
            catch (CsprojEditFailedException exc)
            {
                ShowErrorDuringSync(".csproj edit failed: {0} ", exc);
            }
            catch (FileRenameToLowercaseException exc)
            {
                ShowErrorDuringSync("Renaming {0} to lowercase failed: {1}", exc.FileName, exc);
            }
            catch (Exception exc)
            {
                ShowErrorDuringSync("General failure: {0}", exc);
            }
        }