///////////////////////////////////////////////////////////////////////////// // Overriden Package Implementation #region Package Members /// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); DeleteLines.Initialize(this); MoveLinesDown.Initialize(this); MoveLinesUp.Initialize(this); ToggleComments.Initialize(this); CopyLinesDown.Initialize(this); CopyLinesUp.Initialize(this); PasteImage.Initialize(this); RegisterHandler(); }
private void btnOK_Click(object sender, EventArgs e) { Filename = txtFilename.Text; Folder = txtFolder.Text; AltText = txtAltText.Text; FullFolderPath = Path.Combine(BaseDir, Folder); FullFilePath = Path.Combine(FullFolderPath, Filename); RelativeFilePath = PasteImage.GetRelativePath(BaseDir, FullFilePath); if (string.IsNullOrWhiteSpace(Filename)) { MessageBox.Show(this, @"Filename can not be null or empty", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtFilename.Focus(); return; } if (!Directory.Exists(FullFolderPath)) { var dialogResult = MessageBox.Show(this, @"destination folder does not exists, do you really want to create it? " + Folder, @"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.No) { return; } Directory.CreateDirectory(FullFolderPath); } else if (File.Exists(FullFilePath)) { var dialogResult = MessageBox.Show(this, @"destination file already exists, do you really want to replace it? " + RelativeFilePath, @"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.No) { return; } } var cache = History[BaseFilename]; cache.Folder = Folder; cache.Folders.Add(Folder); DialogResult = DialogResult.OK; Close(); }
private void btnSelectFolder_Click(object sender, EventArgs e) { var currentDir = Path.Combine(BaseDir, txtFolder.Text); var dlg = new FolderBrowserDialog() { ShowNewFolderButton = true, SelectedPath = Directory.Exists(currentDir) ? currentDir : BaseDir, }; var dlgResult = dlg.ShowDialog(this); if (dlgResult != DialogResult.OK) { return; } txtFolder.Text = PasteImage.GetRelativePath(new DirectoryInfo(BaseDir), new DirectoryInfo(dlg.SelectedPath)); }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static void Initialize(Package package) { Instance = new PasteImage(package); }