/// <summary> /// Called on Edit.Delete command events /// </summary> /// <param name="Guid"></param> /// <param name="ID"></param> /// <param name="CustomIn"></param> /// <param name="CustomOut"></param> /// <param name="CancelDefault"></param> private void OnBeforeDeleteCommand(string Guid, int ID, Object CustomIn, Object CustomOut, ref bool CancelDefault) { if (!IsVCProject()) { return; } getSelectedItems(); if (selectedProjectItems.Count == 0) { return; } DlgRemoveDelete dlg = new DlgRemoveDelete(); var m = dlg.ShowModal(); int result = dlg.getResult(); if (result == DlgRemoveDelete.DELETE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Delete(); } catch (Exception) { } } } else if (result == DlgRemoveDelete.REMOVE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Remove(); } catch (Exception) { } } } CancelDefault = true; }
/// <summary> /// Called on Edit.Delete command events /// </summary> /// <param name="Guid"></param> /// <param name="ID"></param> /// <param name="CustomIn"></param> /// <param name="CustomOut"></param> /// <param name="CancelDefault"></param> private void OnBeforeDeleteCommand(string Guid, int ID, Object CustomIn, Object CustomOut, ref bool CancelDefault) { EnvDTE80.DTE2 _applicationObject = GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2; if (_applicationObject.ActiveWindow.Object != _applicationObject.ToolWindows.SolutionExplorer) return; Array projs = _applicationObject.ActiveSolutionProjects as Array; if (projs.Length == 0) { return; } string type = "Unknown"; try { EnvDTE.Project proj = projs.GetValue(0) as EnvDTE.Project; if (HasProperty(proj.Properties,"Kind")) type = proj.Properties.Item("Kind").Value.ToString(); } catch (Exception) { } if (!type.Equals("VCProject")) { return; } getSelectedItems(); if (selectedProjectItems.Count == 0) return; DlgRemoveDelete dlg = new DlgRemoveDelete(); var m = dlg.ShowModal(); int result = dlg.getResult(); if (result == DlgRemoveDelete.DELETE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Delete(); } catch (Exception) { } } } else if (result == DlgRemoveDelete.REMOVE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Remove(); } catch (Exception) { } } } CancelDefault = true; }
/// <summary> /// Called on Edit.Delete command events /// </summary> /// <param name="Guid"></param> /// <param name="ID"></param> /// <param name="CustomIn"></param> /// <param name="CustomOut"></param> /// <param name="CancelDefault"></param> private void OnBeforeDeleteCommand(string Guid, int ID, Object CustomIn, Object CustomOut, ref bool CancelDefault) { if (!IsVCProject()) { return; } getSelectedItems(); if (selectedProjectItems.Count == 0) return; DlgRemoveDelete dlg = new DlgRemoveDelete(); var m = dlg.ShowModal(); int result = dlg.getResult(); if (result == DlgRemoveDelete.DELETE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Delete(); } catch (Exception) { } } } else if (result == DlgRemoveDelete.REMOVE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Remove(); } catch (Exception) { } } } CancelDefault = true; }
/// <summary> /// Called on Edit.Delete command events /// </summary> /// <param name="Guid"></param> /// <param name="ID"></param> /// <param name="CustomIn"></param> /// <param name="CustomOut"></param> /// <param name="CancelDefault"></param> private void OnBeforeDeleteCommand(string Guid, int ID, Object CustomIn, Object CustomOut, ref bool CancelDefault) { EnvDTE80.DTE2 _applicationObject = GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2; if (_applicationObject.ActiveWindow.Object != _applicationObject.ToolWindows.SolutionExplorer) { return; } Array projs = _applicationObject.ActiveSolutionProjects as Array; if (projs.Length == 0) { return; } string type = "Unknown"; try { EnvDTE.Project proj = projs.GetValue(0) as EnvDTE.Project; if (HasProperty(proj.Properties, "Kind")) { type = proj.Properties.Item("Kind").Value.ToString(); } } catch (Exception) { } if (!type.Equals("VCProject")) { return; } getSelectedItems(); if (selectedProjectItems.Count == 0) { return; } DlgRemoveDelete dlg = new DlgRemoveDelete(); var m = dlg.ShowModal(); int result = dlg.getResult(); if (result == DlgRemoveDelete.DELETE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Delete(); } catch (Exception) { } } } else if (result == DlgRemoveDelete.REMOVE) { for (int i = selectedProjectItems.Count - 1; i >= 0; i--) { try { selectedProjectItems[i].Remove(); } catch (Exception) { } } } CancelDefault = true; }