Example #1
0
 public static void Initialize(PackageContext context)
 {
     if (initializationException == null)
     {
         ReadRegistrySettings(context);
     }
     else
     {
         string title   = context.NativeResources.GetString(ResourceId.IDS_E_TRACELOG_CREATION_TITLE, LogPath);
         string message = context.NativeResources.GetString(ResourceId.IDS_E_TRACELOG_CREATION, initializationException.Message);
         context.ShowErrorMessageBox(title, message);
     }
 }
Example #2
0
        /// <summary>
        /// Deletes the file or folder from the disk. Folders will be recursively deleted.
        /// </summary>
        public virtual void Delete()
        {
            // Don't delete if we're not supposed to.
            if (!this.CanDelete)
            {
                return;
            }

            // First ask the user if he really wants to delete the item.
            PackageContext        context   = Package.Instance.Context;
            NativeResourceManager resources = context.NativeResources;
            string             title        = resources.GetString(ResourceId.IDS_DELETECONFIRMATION_TITLE, this.Caption);
            string             message      = resources.GetString(ResourceId.IDS_DELETECONFIRMATION, this.Caption);
            VsMessageBoxResult result       = context.ShowMessageBox(title, message, OLEMSGBUTTON.OLEMSGBUTTON_YESNO, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, OLEMSGICON.OLEMSGICON_WARNING);

            if (result == VsMessageBoxResult.No)
            {
                return;
            }

            // Close the node first.
            this.Close();

            // Remove the node from the project.
            this.RemoveFromProject();

            // Attempt the delete the node from disk.
            try
            {
                if (this.IsFolder && Directory.Exists(this.AbsolutePath))
                {
                    Directory.Delete(this.AbsolutePath, true);
                }
                else if (this.IsFile && File.Exists(this.AbsolutePath))
                {
                    // Make sure the file is not read only, hidden, etc.
                    File.SetAttributes(this.AbsolutePath, FileAttributes.Normal);
                    File.Delete(this.AbsolutePath);
                }
            }
            catch (Exception e)
            {
                title   = resources.GetString(ResourceId.IDS_E_DELETEFROMPROJECT_TITLE);
                message = resources.GetString(ResourceId.IDS_E_DELETEFROMPROJECT, e.Message);
                context.ShowErrorMessageBox(title, message);
            }
        }
Example #3
0
 public static void Initialize(PackageContext context)
 {
     if (initializationException == null)
     {
         ReadRegistrySettings(context);
     }
     else
     {
         string title = context.NativeResources.GetString(ResourceId.IDS_E_TRACELOG_CREATION_TITLE, LogPath);
         string message = context.NativeResources.GetString(ResourceId.IDS_E_TRACELOG_CREATION, initializationException.Message);
         context.ShowErrorMessageBox(title, message);
     }
 }