예제 #1
0
파일: Report.cs 프로젝트: mguerrer/Salma
        private void SetProjectTextWithUrl(string projectName, string title)
        {
            Object styleTitle = WdBuiltinStyle.wdStyleTitle;
            var    pt         = OfficeHelper.CreateParagraphRange(ref document);

            pt.Text = projectName + " " + title;
            pt.set_Style(ref styleTitle);
            pt.SetRange(pt.Characters.First.Start, pt.Characters.First.Start + projectName.Length);
            pt.Select();

            var link = (tfsManager.tfsVersion == TfsVersion.Tfs2011 ? string.Format("{0}/{1}", TfsManager.Instance.collection.Uri, projectName) : string.Format("{0}/web/", TfsManager.Instance.GetTfsUrl()));

            pt.Hyperlinks.Add(pt, link);
            document.Content.InsertParagraphAfter();

            var RevisionPar = OfficeHelper.CreateParagraphRange(ref document);

            if (revisionDate != null)
            {
                RevisionPar.Text        = string.Format("{0}: {1}", WordToTFS.Properties.Resources.QueryReport_RevisionDate_Text, revisionDate.Value.ToShortDateString());
                RevisionPar.Font.Name   = "Calibri";
                RevisionPar.Font.Size   = 11;
                RevisionPar.Font.Color  = WdColor.wdColorBlueGray;
                RevisionPar.Font.Italic = -1;
                document.Content.InsertParagraphAfter();
            }
        }
예제 #2
0
        /// <summary>
        /// Set Matrix Title
        /// </summary>
        /// <param name="projectName">
        /// </param>
        /// <param name="title">
        /// </param>
        private void SetMatrixTitle(string projectName, string title)
        {
            object styleTitle = WdBuiltinStyle.wdStyleTitle;
            Range  parRange   = OfficeHelper.CreateParagraphRange(ref document);

            parRange.Text = projectName + " " + title;
            parRange.set_Style(ref styleTitle);
            parRange.SetRange(parRange.Characters.First.Start, parRange.Characters.First.Start + projectName.Length);
            parRange.Select();
            switch (tfsManager.tfsVersion)
            {
            case TfsVersion.Tfs2011:
            {
                parRange.Hyperlinks.Add(parRange, string.Format("{0}/{1}", tfsManager.collection.Name, projectName));
            }
            break;

            case TfsVersion.Tfs2010:
            {
                parRange.Hyperlinks.Add(parRange, string.Format("{0}/web/Index.aspx?pguid={1}", tfsManager.GetTfsUrl(), tfsManager.GetProject(projectName).Guid));
            }
            break;
            }
            document.Content.InsertParagraphAfter();

            string DateFrom = string.Empty;
            string DateTo   = string.Empty;

            if (matrixReportData.DateFrom != null)
            {
                DateFrom = String.Format("{0}: {1}", WordToTFS.Properties.Resources.MatrixReport_Date_From, matrixReportData.DateFrom.Value.ToShortDateString());
            }
            if (matrixReportData.DateTo != null)
            {
                DateTo = String.Format("{0}: {1}", WordToTFS.Properties.Resources.MatrixReport_Date_To, matrixReportData.DateTo.Value.ToShortDateString());
            }
            else
            {
                DateTo = String.Format("{0}: {1}", WordToTFS.Properties.Resources.MatrixReport_Date_To, DateTime.Now.ToShortDateString());
            }
            if (matrixReportData.DateFrom == null && matrixReportData.DateTo == null)
            {
                DateFrom = String.Format("{0}: {1}", WordToTFS.Properties.Resources.MatrixReport_Date, DateTime.Now.ToShortDateString());
                DateTo   = string.Empty;
            }

            Range addInform = OfficeHelper.CreateParagraphRange(ref document);

            addInform.Font.Name   = "Calibri";
            addInform.Font.Size   = 11;
            addInform.Font.Color  = WdColor.wdColorBlueGray;
            addInform.Font.Italic = -1;
            addInform.Text        = String.Format("{0}: {1}             {2}          {3}", WordToTFS.Properties.Resources.MatrixReport_Link_Type, matrixReportData.RelatedSelectedItem, DateFrom, DateTo);
            addInform.Select();
            document.Content.InsertParagraphAfter();
        }
예제 #3
0
파일: Report.cs 프로젝트: mguerrer/Salma
        private void SetMetadataText(string text)
        {
            Range par = OfficeHelper.CreateParagraphRange(ref document);

            par.Font.Name   = "Calibri";
            par.Font.Size   = 11;
            par.Font.Color  = WdColor.wdColorBlueGray;
            par.Font.Italic = -1;
            par.Text        = text;
            par.ParagraphFormat.SpaceAfter  = 0;
            par.ParagraphFormat.SpaceBefore = 0;
            document.Content.InsertParagraphAfter();
        }
예제 #4
0
        /// <summary>
        /// Draw Table
        /// </summary>
        /// <param name="projectName">
        /// </param>
        /// <param name="workItemsInRow">
        /// </param>
        /// <param name="workItemsInColumn">
        /// </param>
        private void DrawTable(string projectName, List <WorkItem> workItemsInRow, List <WorkItem> workItemsInColumn)
        {
            const int TITLE_ROW_INDEX                = 1;
            const int HEADER_ROW_INDEX               = 2;
            const int VERTICAL_STATUS_ROW_INDEX      = 3;
            const int DESCRIPTION_ROW_INDEX          = 4;
            const int PROJECT_COLUMN_INDEX           = 1;
            const int HORIZONTAL_STATUS_COLUMN_INDEX = 2;
            const int ROW_SHIFT = 5;
            const int COL_SHIFT = 3;

            // for additional info see here: "http://msdn.microsoft.com/en-us/library/office/aa537149(v=office.11).aspx"
            object objDefaultBehaviorWord8 = WdDefaultTableBehavior.wdWord8TableBehavior;
            object objAutoFitFixed         = WdAutoFitBehavior.wdAutoFitFixed;

            var parRange = OfficeHelper.CreateParagraphRange(ref document);

            parRange.Text = BuildDataString(workItemsInRow, workItemsInColumn);
            try
            {
                Table table = parRange.ConvertToTable(AutoFitBehavior: objAutoFitFixed, DefaultTableBehavior: objDefaultBehaviorWord8);

                table.set_Style(WdBuiltinStyle.wdStyleTableLightGrid);

                table.Select();
                Selection sel = document.Application.Selection;
                if (sel != null)
                {
                    sel.Font.Bold = 0;
                    sel.Cells.VerticalAlignment   = WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                    sel.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
                }

                // style titles

                sel = SelectCells(table, 1, 3, 1, workItemsInColumn.Count + 2); // 2 cells is a title for items in rows.

                if (sel != null)
                {
                    sel.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
                    sel.Font.Size    = sel.Range.Font.Size - 1;
                    sel.Font.Bold    = 1;
                    sel.Orientation  = WdTextOrientation.wdTextOrientationUpward;
                    sel.Cells.Height = 100;
                    sel.EscapeKey();
                }
                // Set workItems types as bold
                sel = SelectCells(table, 1, 1, 4, 1);
                if (sel != null)
                {
                    sel.Font.Bold = 1;
                    sel.EscapeKey();
                }

                // Add hyperlinks to work items in column
                Parallel.For(0, workItemsInColumn.Count, i => table.Columns[i + COL_SHIFT].Cells[2].Range.Hyperlinks.Add(table.Columns[i + COL_SHIFT].Cells[2].Range, tfsManager.GetWorkItemLink(workItemsInColumn[i].Id, projectName)));

                // Add hyperlinks to work items in row
                Parallel.For(0, workItemsInRow.Count, i => table.Rows[i + ROW_SHIFT].Cells[1].Range.Hyperlinks.Add(table.Rows[i + ROW_SHIFT].Cells[1].Range, tfsManager.GetWorkItemLink(workItemsInRow[i].Id, projectName)));


                table.Rows[DESCRIPTION_ROW_INDEX].Cells[PROJECT_COLUMN_INDEX].Merge(table.Rows[DESCRIPTION_ROW_INDEX].Cells[PROJECT_COLUMN_INDEX + 1]);
                table.Rows[2].Cells[1].Merge(table.Rows[2].Cells[2]);
                table.Rows[1].Cells[1].Merge(table.Rows[1].Cells[2]);
                table.Rows[1].Cells[1].Merge(table.Rows[2].Cells[1]);
                table.Cell(3, 1).Merge(table.Cell(3, 2));
                table.Cell(3, 1).Merge(table.Cell(1, 1));
                //// Merge rows
                //table.Rows[4].Cells[1].Merge(table.Rows[4].Cells[2]);
                //sel = SelectCells(table, 1, 1, 3, 2);
                //if (sel != null)
                //{
                //    sel.Cells.Merge();
                //}

                document.Content.InsertParagraphAfter();
            }
            catch (Exception ex)
            {
            }
        }