예제 #1
0
        private void FileListMnu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Name == "FLM_ViewMI")
            {
                foreach (ListViewItem it in ShelvedFilesLV.SelectedItems)
                {
                    P4.ShelvedFile shelvedFile = it.Tag as P4.ShelvedFile;
                    if (shelvedFile != null)
                    {
                        string file = shelvedFile.Path.ToString();

                        long maxPreviewSize = 1024 * ((long)Preferences.LocalSettings.GetInt("Size_files", 500));
                        long shelvedSize    = _scm.GetShelvedFileSize(_changelistId, file);
                        if (shelvedSize > maxPreviewSize)
                        {
                            string size = P4ObjectTreeListViewItem.PrettyPrintFileSize(shelvedSize);
                            string msg  = string.Format(Resources.FileExceedsMaxPreviewSizeWarning, size);
                            if (DialogResult.No == MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                            {
                                return;
                            }
                        }

                        P4.FileSpec shelvedSpec = new P4.FileSpec(shelvedFile.Path,
                                                                  new P4.ShelvedInChangelistIdVersion(_changelistId));

                        using (TempFile sourceFile = new TempFile(shelvedSpec))
                        {
                            if (_scm.GetFileVersion(sourceFile, shelvedSpec) == null)
                            {
                                MessageBox.Show(Resources.UnshelveFileDialog_CannotGetShelvedFileContentsError,
                                                Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }

                            if (Preferences.LocalSettings.GetBool("OpenShelvedFileInEditor", true))
                            {
                                EnvDTE.DTE dte = P4VsProvider.GetDTE();
                                dte.ItemOperations.OpenFile(sourceFile, null);
                            }
                            else
                            {
                                ShowFileContentsDlg dlg = new ShowFileContentsDlg();

                                dlg.TempFile = sourceFile;
                                dlg.Title    = shelvedSpec.ToString();

                                // Show modeless
                                dlg.Show();
                            }
                        }
                    }
                }
            }
        }