public void HandleOpenEntityMetadataExplorer(ConnectionData connectionData, EnvDTE.SelectedItem selectedItem) { string selection = string.Empty; if (selectedItem == null) { selection = GetSelectedText(); } HandleOpenEntityMetadataExplorer(connectionData, selection, selectedItem); }
public void HandleExportGlobalOptionSets(ConnectionData connectionData, EnvDTE.SelectedItem selectedItem) { string selection = string.Empty; if (selectedItem == null) { selection = GetSelectedText(); } HandleExportGlobalOptionSets(connectionData, selection, selectedItem); }
public void HandleSdkMessageRequestTree(ConnectionData connectionData, EnvDTE.SelectedItem selectedItem) { string selection = string.Empty; if (selectedItem == null) { selection = GetSelectedText(); } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartShowingSdkMessageRequestTree(conn, commonConfig, selection, null, selectedItem)); }
public ItemInfo(EnvDTE.SelectedItem selItem) { m_FilePath = string.Empty; m_HasPath = false; m_Name = selItem.Name; m_IsSelected = true; if (selItem is EnvDTE.UIHierarchyItem) { m_Object = (selItem as EnvDTE.UIHierarchyItem).Object; } }
private async Task ExportingPluginConfigurationIntoFolder(EnvDTE.SelectedItem selectedItem, Model.ConnectionData connectionData, Model.CommonConfiguration commonConfig) { var service = await ConnectAndWriteToOutputAsync(connectionData); if (service == null) { return; } string filePath = string.Empty; //filePath = CreatePluginDescription(connectionData, service, commonConfig.FolderForExport, commonConfig.PluginConfigurationFileName, connectionData.Name); if (selectedItem.ProjectItem != null) { string folder = selectedItem.ProjectItem.FileNames[1]; filePath = await CreatePluginDescription(connectionData, service, commonConfig); File.SetAttributes(filePath, FileAttributes.ReadOnly); selectedItem.ProjectItem.ProjectItems.AddFromFileCopy(filePath); selectedItem.ProjectItem.ContainingProject.Save(); } else if (selectedItem.Project != null) { string relativePath = DTEHelper.GetRelativePath(selectedItem.Project); string solutionPath = Path.GetDirectoryName(selectedItem.DTE.Solution.FullName); string folder = Path.Combine(solutionPath, relativePath); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } filePath = await CreatePluginDescription(connectionData, service, commonConfig); File.SetAttributes(filePath, FileAttributes.ReadOnly); selectedItem.Project.ProjectItems.AddFromFile(filePath); } this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); service.TryDispose(); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { // The selected item can be a Solution, Project, meta ProjectItem or file ProjectItem // Don't update the tool window if the selection has not changed if (itemidOld == itemidNew) { return(VSConstants.E_NOTIMPL); } // Don't update the tool window if it doesn't exist if (toolWindow == null) { return(VSConstants.E_NOTIMPL); } // Don't update the tool window if it isn't visible IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame; if (windowFrame.IsVisible() == VSConstants.S_FALSE) { return(VSConstants.E_NOTIMPL); } Debug.WriteLine(itemidOld + "->" + itemidNew); EnvDTE.SelectedItem si = dte.SelectedItems.Item(1); EnvDTE.ProjectItem item = si.ProjectItem; // Solutions and Projects don't have ProjectItems if (item != null && item.FileCount != 0) { string filePath = item.FileNames[0]; // Only update for project items that exist (Not all of them do). if (File.Exists(filePath)) { UpdateToolWindow(filePath); return(VSConstants.E_NOTIMPL); } } ClearToolWindow(); return(VSConstants.E_NOTIMPL); }
/// <summary> /// static helper to retrieve the underlying item form a EnvDTE.SelectedItem /// </summary> /// <param name="selected"></param> /// <returns></returns> private static object GetSelectedItemObject(EnvDTE.SelectedItem selected) { if (selected.ProjectItem != null) { return(selected.ProjectItem); } else if (selected.Project != null) { ////if (selected.Project.Object != null) //if (selected.Project.Kind == EnvDTE80.ProjectKinds.vsProjectKindSolutionFolder) //{ // return selected.Project; //.Object; //} return(selected.Project); } return(selected.Collection.Cast <object>().FirstOrDefault()); }
public ExplorersHelper( IWriteToOutput iWriteToOutput , CommonConfiguration commonConfig , Func<Task<IOrganizationServiceExtented>> getService , EnvDTE.SelectedItem selectedItem , Func<string> getEntityName = null , Func<string> getGlobalOptionSetName = null , Func<string> getWorkflowName = null , Func<string> getSystemFormName = null , Func<string> getSavedQueryName = null , Func<string> getSavedQueryVisualizationName = null , Func<string> getSiteMapName = null , Func<string> getReportName = null , Func<string> getWebResourceName = null , Func<string> getPluginAssemblyName = null , Func<string> getOtherPrivilegeName = null , Func<string> getMessageName = null , Func<string> getPluginTypeName = null , Func<string> getRoleName = null , Func<Guid, IEnumerable<EntityMetadata>> getEntityMetadataList = null , Func<Guid, IEnumerable<Privilege>> getOtherPrivilegesList = null , Func<Guid, IEnumerable<OptionSetMetadata>> getGlobalOptionSetMetadataList = null ) : this(iWriteToOutput, commonConfig, getService , getEntityName , getGlobalOptionSetName , getWorkflowName , getSystemFormName , getSavedQueryName , getSavedQueryVisualizationName , getSiteMapName , getReportName , getWebResourceName , getPluginAssemblyName , getOtherPrivilegeName , getMessageName , getPluginTypeName , getRoleName , getEntityMetadataList , getOtherPrivilegesList , getGlobalOptionSetMetadataList ) { this._selectedItem = selectedItem; }
public async Task ExecuteExportingPluginConfigurationIntoFolder(EnvDTE.SelectedItem selectedItem, ConnectionData connectionData, CommonConfiguration commonConfig) { string operation = string.Format(Properties.OperationNames.ExportingPluginConfigurationXmlIntoFolderFormat1, connectionData?.Name); this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation); try { await ExportingPluginConfigurationIntoFolder(selectedItem, connectionData, commonConfig); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } finally { this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation); } }
protected static void AddFileToVSProject(EnvDTE.SelectedItem _selectedItem, string filePath) { if (_selectedItem == null) { return; } if (_selectedItem.ProjectItem != null) { _selectedItem.ProjectItem.ProjectItems.AddFromFileCopy(filePath); _selectedItem.ProjectItem.ContainingProject.Save(); } else if (_selectedItem.Project != null) { _selectedItem.Project.ProjectItems.AddFromFile(filePath); _selectedItem.Project.Save(); } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (_dte == null) { return; } EnvDTE.SelectedItem item = _dte.SelectedItems.Item(1); string message = $"Selected File is {item.ProjectItem.Name}"; string title = "File Context Menu Command"; // Show a message box VsShellUtilities.ShowMessageBox( this.package, message, title, OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); }
private async Task ShowingSdkMessageRequestTree(ConnectionData connectionData, CommonConfiguration commonConfig, string entityFilter, string messageFilter, EnvDTE.SelectedItem selectedItem) { if (connectionData == null) { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.NoCurrentCRMConnection); return; } this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectingToCRM); this._iWriteToOutput.WriteToOutput(connectionData, connectionData.GetConnectionDescription()); // Подключаемся к CRM. var service = await QuickConnection.ConnectAsync(connectionData); if (service == null) { _iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectionFailedFormat1, connectionData.Name); return; } this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.CurrentServiceEndpointFormat1, service.CurrentServiceEndpoint); WindowHelper.OpenSdkMessageRequestTreeWindow(this._iWriteToOutput, service, commonConfig, null, false, selectedItem, entityFilter, messageFilter); }
public async Task ExecuteShowingSdkMessageRequestTree(ConnectionData connectionData, CommonConfiguration commonConfig, string entityFilter, string messageFilter, EnvDTE.SelectedItem selectedItem) { string operation = string.Format(Properties.OperationNames.ShowingSdkMessageRequestTreeFormat1, connectionData?.Name); this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation); try { await ShowingSdkMessageRequestTree(connectionData, commonConfig, entityFilter, messageFilter, selectedItem); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } finally { this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation); } }
private async Task OpeningSystemFormExplorer(ConnectionData connectionData, CommonConfiguration commonConfig, string selection, EnvDTE.SelectedItem selectedItem) { if (connectionData == null) { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.NoCurrentCRMConnection); return; } this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectingToCRM); this._iWriteToOutput.WriteToOutput(connectionData, connectionData.GetConnectionDescription()); // Подключаемся к CRM. var service = await QuickConnection.ConnectAsync(connectionData); if (service == null) { _iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectionFailedFormat1, connectionData.Name); return; } this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.CurrentServiceEndpointFormat1, service.CurrentServiceEndpoint); WindowHelper.OpenSystemFormWindow(this._iWriteToOutput, service, commonConfig, string.Empty, selection, selectedItem); }
public async Task ExecuteOpeningSystemFormExplorer(ConnectionData connectionData, CommonConfiguration commonConfig, string selection, EnvDTE.SelectedItem selectedItem) { string operation = string.Format(Properties.OperationNames.ExportingSystemFormXmlFormat1, connectionData?.Name); this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation); try { await OpeningSystemFormExplorer(connectionData, commonConfig, selection, selectedItem); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } finally { this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation); } }
public async Task ExecuteCreatingFileWithGlobalOptionSets(ConnectionData connectionData, CommonConfiguration commonConfig, string selection, EnvDTE.SelectedItem selectedItem) { await ConnectAndExecuteActionAsync(connectionData , Properties.OperationNames.OpeningGlobalOptionSetsExplorerFormat1 , (service) => WindowHelper.OpenGlobalOptionSetsExplorer(this._iWriteToOutput, service, commonConfig, selection, selectedItem) ); }
public async Task ExecuteOpeningSystemFormExplorer(ConnectionData connectionData, CommonConfiguration commonConfig, string entityName, string selection, EnvDTE.SelectedItem selectedItem) { await ConnectAndExecuteActionAsync(connectionData , Properties.OperationNames.ExportingSystemFormXmlFormat1 , (service) => WindowHelper.OpenSystemFormExplorer(this._iWriteToOutput, service, commonConfig, entityName, selection, selectedItem) ); }
public async Task ExecuteOpeningSolutionExlorerWindow(ConnectionData connectionData, CommonConfiguration commonConfig, EnvDTE.SelectedItem selectedItem) { await ConnectAndExecuteActionAsync(connectionData , Properties.OperationNames.SolutionExplorerFormat1 , (service) => WindowHelper.OpenExplorerSolutionExplorer(this._iWriteToOutput, service, commonConfig, null, null, selectedItem) ); }
private async Task ExportingPluginConfigurationIntoFolder(EnvDTE.SelectedItem selectedItem, ConnectionData connectionData, CommonConfiguration commonConfig) { if (connectionData == null) { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.NoCurrentCRMConnection); return; } this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectingToCRM); this._iWriteToOutput.WriteToOutput(connectionData, connectionData.GetConnectionDescription()); // Подключаемся к CRM. var service = await QuickConnection.ConnectAsync(connectionData); if (service == null) { _iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectionFailedFormat1, connectionData.Name); return; } this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.CurrentServiceEndpointFormat1, service.CurrentServiceEndpoint); string filePath = string.Empty; //filePath = CreatePluginDescription(connectionData, service, commonConfig.FolderForExport, commonConfig.PluginConfigurationFileName, connectionData.Name); if (selectedItem.ProjectItem != null) { string folder = selectedItem.ProjectItem.FileNames[1]; filePath = await CreatePluginDescription(connectionData, service, commonConfig); File.SetAttributes(filePath, FileAttributes.ReadOnly); selectedItem.ProjectItem.ProjectItems.AddFromFileCopy(filePath); selectedItem.ProjectItem.ContainingProject.Save(); } else if (selectedItem.Project != null) { string relativePath = DTEHelper.GetRelativePath(selectedItem.Project); string solutionPath = Path.GetDirectoryName(selectedItem.DTE.Solution.FullName); string folder = Path.Combine(solutionPath, relativePath); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } filePath = await CreatePluginDescription(connectionData, service, commonConfig); File.SetAttributes(filePath, FileAttributes.ReadOnly); selectedItem.Project.ProjectItems.AddFromFile(filePath); } this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); }
public void HandleOpenEntityMetadataExplorer(ConnectionData connectionData, string filter, EnvDTE.SelectedItem selectedItem) { GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartOpeningEntityMetadataExplorer(conn, commonConfig, filter, selectedItem)); }
public async Task ExecuteShowingSdkMessageRequestTree(ConnectionData connectionData, CommonConfiguration commonConfig, string entityFilter, string messageFilter, EnvDTE.SelectedItem selectedItem) { await ConnectAndExecuteActionAsync(connectionData , Properties.OperationNames.ShowingSdkMessageRequestTreeFormat1 , (service) => WindowHelper.OpenSdkMessageRequestTree(this._iWriteToOutput, service, commonConfig, null, false, selectedItem, entityFilter, messageFilter) ); }
public WindowExplorerGlobalOptionSets( IWriteToOutput iWriteToOutput , IOrganizationServiceExtented service , CommonConfiguration commonConfig , IEnumerable <OptionSetMetadata> optionSets , string filterEntityName , string selection , string filePath , bool isJavaScript , EnvDTE.SelectedItem selectedItem ) { this.IncreaseInit(); InputLanguageManager.SetInputLanguage(this, CultureInfo.CreateSpecificCulture("en-US")); this._iWriteToOutput = iWriteToOutput; this._commonConfig = commonConfig; this._filePath = filePath; this._isJavaScript = isJavaScript; this._selectedItem = selectedItem; _connectionCache[service.ConnectionData.ConnectionId] = service; BindingOperations.EnableCollectionSynchronization(service.ConnectionData.ConnectionConfiguration.Connections, sysObjectConnections); if (optionSets != null) { _cacheOptionSetMetadata[service.ConnectionData.ConnectionId] = optionSets; } InitializeComponent(); LoadEntityNames(cmBEntityName, service.ConnectionData); var child = new ExportGlobalOptionSetMetadataOptionsControl(_commonConfig); child.CloseClicked += Child_CloseClicked; this._optionsPopup = new Popup { Child = child, PlacementTarget = toolBarHeader, Placement = PlacementMode.Bottom, StaysOpen = false, Focusable = true, }; LoadFromConfig(); if (!string.IsNullOrEmpty(_filePath)) { txtBFolder.IsReadOnly = true; txtBFolder.Background = SystemColors.InactiveSelectionHighlightBrush; txtBFolder.Text = Path.GetDirectoryName(_filePath); } else if (this._selectedItem != null) { string exportFolder = string.Empty; if (_selectedItem.ProjectItem != null) { exportFolder = _selectedItem.ProjectItem.FileNames[1]; } else if (_selectedItem.Project != null) { string relativePath = DTEHelper.GetRelativePath(_selectedItem.Project); string solutionPath = Path.GetDirectoryName(_selectedItem.DTE.Solution.FullName); exportFolder = Path.Combine(solutionPath, relativePath); } if (!Directory.Exists(exportFolder)) { Directory.CreateDirectory(exportFolder); } txtBFolder.IsReadOnly = true; txtBFolder.Background = SystemColors.InactiveSelectionHighlightBrush; txtBFolder.Text = exportFolder; } else { Binding binding = new Binding { Path = new PropertyPath(nameof(CommonConfiguration.FolderForExport)), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay, }; BindingOperations.SetBinding(txtBFolder, TextBox.TextProperty, binding); txtBFolder.DataContext = _commonConfig; } cmBEntityName.Text = filterEntityName; txtBFilter.Text = selection; txtBFilter.SelectionLength = 0; txtBFilter.SelectionStart = txtBFilter.Text.Length; txtBFilter.Focus(); _itemsSource = new ObservableCollection <OptionSetMetadataListViewItem>(); lstVwOptionSets.ItemsSource = _itemsSource; UpdateButtonsEnable(); cmBCurrentConnection.ItemsSource = service.ConnectionData.ConnectionConfiguration.Connections; cmBCurrentConnection.SelectedItem = service.ConnectionData; this.DecreaseInit(); ShowExistingOptionSets(); }
public void HandleExportGlobalOptionSets(ConnectionData connectionData, string selection, EnvDTE.SelectedItem selectedItem) { GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartCreatingFileWithGlobalOptionSets(conn, commonConfig, selection, selectedItem)); }