コード例 #1
0
ファイル: PrintWorkItem.cs プロジェクト: pwibeck/Scrumy
 public PrintWorkItem(WorkItem workItem, Settings settings, TfsHelper tfsHelper, int x, int y, int width,
     int height)
 {
     this.x = x;
     this.y = y;
     this.width = width;
     this.height = height;
     padding = 10;
     textPrintArea = new RectangleF(x + padding, y + padding, width - (padding*2), height - (padding*2));
     cardArea = new RectangleF(x, y, width, height);
     item = workItem;
     this.settings = settings;
     this.tfsHelper = tfsHelper;
 }
コード例 #2
0
        private void PrintItemCallback(object sender, EventArgs e)
        {
            TeamFoundationServerExt tfsExt = (TeamFoundationServerExt)Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");

            IWorkItemTrackingDocument doc = GetActiveDocument();
            int[] selectedItemIds = ((IResultsDocument)doc).SelectedItemIds;
            doc.Release(this);

            PrintDialog printDialog = new PrintDialog();
            TfsHelper tfsHelper = new TfsHelper(new Uri(tfsExt.ActiveProjectContext.DomainUri), tfsExt.ActiveProjectContext.ProjectName);
            Settings settings = new Settings();
            settings.LoadSettings();
            ItemsDocument printDoc = new ItemsDocument(settings, tfsHelper);
            foreach (var workItem in tfsHelper.GetWorkItems(selectedItemIds))
            {
                printDoc.AddWorkItem(workItem);
            }

            printDialog.Document = printDoc;
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    printDialog.Document.Print();
                }
                catch (Win32Exception)
                {
                    IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                    Guid clsid = Guid.Empty;
                    int result;
                    Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
                               0,
                               ref clsid,
                               "Print item error",
                               "Not possible to print. Try to restart 'Print Spooler'",
                               string.Empty,
                               0,
                               OLEMSGBUTTON.OLEMSGBUTTON_OK,
                               OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                               OLEMSGICON.OLEMSGICON_INFO,
                               0,        // false
                               out result));
                }
            }
        }
コード例 #3
0
ファイル: ItemsDocument.cs プロジェクト: pwibeck/Scrumy
 public ItemsDocument(Settings settings, TfsHelper tfsHelper)
 {
     this.settings = settings;
     this.tfsHelper = tfsHelper;
 }