Exemple #1
0
        public void SetCellsColor(int iCol1, int iCol2, int iRow1, int iRow2, MSWord.WdColor color, MSWord.WdColor text_color = MSWord.WdColor.wdColorAutomatic, int indTable = -1)
        {
            GetTableReference(indTable);

            MSWord.Cell pCell1 = m_pTable.Cell(iRow1, iCol1);
            if (pCell1 == null)
            {
                return;
            }
            MSWord.Cell pCell2 = m_pTable.Cell(iRow2, iCol2);
            if (pCell2 == null)
            {
                return;
            }

            MSWord.Range r = m_pDoc.Range(pCell1.Range.Start, pCell2.Range.End);
            r.Select();
            MSWord.Selection sel = m_pApp.Selection;
            sel.Shading.Texture = MSWord.WdTextureIndex.wdTextureNone;
            sel.Shading.ForegroundPatternColor = MSWord.WdColor.wdColorAutomatic;
            sel.Shading.BackgroundPatternColor = color;
            if (text_color != MSWord.WdColor.wdColorAutomatic)
            {
                sel.Font.Color = text_color;
            }
        }
Exemple #2
0
        /// <summary>
        /// Colors a range of text in the document with the specified color and character formatting. This is the callback function used by the Colorizer:
        /// Every time it founds a language element that must be colored, it calls back this function, that performs the formatting using the Word API. This way the Word specific code is separated from the syntax processing of the text.
        /// </summary>
        /// <param name="index">The starting position of the range that must be colored (0 is the first character of the selection, that is the text that is colorized)</param>
        /// <param name="length">The length of the range to be colored</param>
        /// <param name="color">Color to use for the range of text</param>
        /// <param name="char_format">Character formatting to use for the range of text</param>
        public void ColorRangeOfText(int index, int length, Color color, CharacterFormat char_format)
        {
            Word.WdColor wd_color = (Word.WdColor)ColorTranslator.ToOle(color);
            if (color.Name == "Control")
            {
                wd_color = Word.WdColor.wdColorAutomatic;
            }

            Word.Range range = wordApp.Selection.Range; //It must look weird, but you have to get an existing Range object first, and then narrow it down. (Range is an abstract class)
            range.SetRange(wordApp.Selection.Start + index, wordApp.Selection.Start + index + length);
            range.Font.Color = wd_color;

            if (char_format.Bold)
            {
                range.Font.Bold = 1;
            }
            if (char_format.Italic)
            {
                range.Font.Italic = 1;
            }
            if (char_format.Underlined)
            {
                range.Font.Underline = Word.WdUnderline.wdUnderlineSingle;
            }
            if (char_format.Capitalletters)
            {
                range.Font.AllCaps = 1;
            }
        }
Exemple #3
0
 public BorderInfo(MSWord.WdBorderType type, MSWord.WdLineStyle style, MSWord.WdLineWidth width, MSWord.WdColor color)
 {
     m_type  = type;
     m_style = style;
     m_width = width;
     m_color = color;
 }
Exemple #4
0
 public static void SetTableBolders(Word.Table table, Word.WdColor color)
 {
     table.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleSingle;
     table.Borders.InsideColor      = color;
     table.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
     table.Borders.OutsideColor     = color;
 }
Exemple #5
0
        void ReadVsto()
        {
            Stopwatch sw = Stopwatch.StartNew();

            _app.ScreenUpdating = false;

            Interop.Document document = _app.ActiveDocument;
            int i = 0;

            foreach (Interop.Range range in document.Range().Words)
            {
                string          a1   = range.Text;
                Interop.Font    font = range.Font;
                int             a2   = font.Fill.BackColor.RGB;
                Interop.WdColor a3   = font.Color;
                float           a4   = font.Size;
                int             a5   = font.Italic;
                int             a6   = font.Bold;
                i++;
            }

            _app.ScreenUpdating = true;

            sw.Stop();
            MessageBox.Show(sw.Elapsed.ToString(), $"VSTO: read {i}");
        }
Exemple #6
0
 /// <summary>
 /// 插入文字
 /// </summary>
 /// <param name="pText">文本信息</param>
 /// <param name="pFontSize">字体大小</param>
 /// <param name="pFontColor">字体颜色</param>
 /// <param name="pFontBold">字体粗体</param>
 /// <param name="ptextAlignment">方向</param>
 public void InsertText(string pText, int pFontSize, Microsoft.Office.Interop.Word.WdColor pFontColor, int pFontBold, Microsoft.Office.Interop.Word.WdParagraphAlignment ptextAlignment)
 {
     //设置字体样式以及方向
     this._wordApplication.Application.Selection.Font.Size  = pFontSize;
     this._wordApplication.Application.Selection.Font.Bold  = pFontBold;
     this._wordApplication.Application.Selection.Font.Color = pFontColor;
     this._wordApplication.Application.Selection.ParagraphFormat.Alignment = ptextAlignment;
     this._wordApplication.Application.Selection.TypeText(pText);
 }
Exemple #7
0
 //Set the style of words, adding size, bold, fontcolor and alignment
 public void InsertFormatText(string context, int fontSize, Word.WdColor fontColor, int fontBold, string familyName, Word.WdParagraphAlignment align)
 {
     wordApp.Application.Selection.Font.Size  = fontSize;
     wordApp.Application.Selection.Font.Bold  = fontBold;
     wordApp.Application.Selection.Font.Color = fontColor;
     wordApp.Selection.Font.Name = familyName;
     wordApp.Application.Selection.ParagraphFormat.Alignment = align;
     wordApp.Application.Selection.TypeText(context);
 }
Exemple #8
0
        /// <summary>
        /// 填充表格内容
        /// </summary>
        /// <param name="table"></param>
        public Cell AddTableContent(int row, int col
                                    , string strContent, int bold, Word.WdColor color)
        { //填充表格内容
            Cell cell = table.Cell(row, col);

            cell.Range.Text       = strContent;
            cell.Range.Bold       = bold;
            cell.Range.Font.Color = color;
            return(cell);
        }
 /// <summary>
 /// 在已经找到标签位置处插入文本
 /// </summary>
 /// <param name="txt">插入文本内容</param>
 /// <param name="txtColor">字体颜色</param>
 /// <param name="txtSize">字体大小</param>
 /// <param name="txtBold">0不加粗1加粗</param>
 /// <param name="txtName">字体样式</param>
 /// <param name="lineSpace">行间距</param>
 public void FindPositionText(string txt, Word.WdColor txtColor, float txtSize, int txtBold, string txtName, float lineSpace)
 {
     wApp.Selection.ParagraphFormat.LineSpacing = lineSpace;                                      //行间距
     wApp.Selection.Font.Color = txtColor;                                                        //字体颜色
     wApp.Selection.Font.Size  = txtSize;                                                         //字体大小
     wApp.Selection.Font.Bold  = txtBold;                                                         //0不加粗1加粗
     wApp.Selection.Font.Name  = txtName;                                                         //字体样式
     wApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;   //对齐方式
     wApp.Selection.TypeText(txt);                                                                // 插入文本
 }
Exemple #10
0
        //在书签处插入值
        /// <summary>
        /// 在标签处插入值
        /// </summary>
        /// <param name="bookmark">标签</param>
        /// <param name="value">字段</param>
        /// <param name="pFontSize">字体大小</param>
        /// <param name="pFontColor">字体颜色</param>
        /// <param name="pFontBold">字体粗体</param>
        /// <param name="ptextAlignment">字体方向</param>
        /// <returns></returns>
        public bool InsertValue(string bookmark, string value, int pFontSize, Microsoft.Office.Interop.Word.WdColor pFontColor, int pFontBold, Microsoft.Office.Interop.Word.WdParagraphAlignment ptextAlignment)
        {
            object bkObj = bookmark;

            if (wordApp.ActiveDocument.Bookmarks.Exists(bookmark))
            {
                wordApp.ActiveDocument.Bookmarks.get_Item(ref bkObj).Select();
                wordApp.Selection.Font.Size  = pFontSize;
                wordApp.Selection.Font.Color = pFontColor;
                wordApp.Selection.Font.Bold  = pFontBold;
                wordApp.Selection.ParagraphFormat.Alignment = ptextAlignment;
                wordApp.Selection.TypeText(value);
                return(true);
            }
            return(false);
        }
Exemple #11
0
        public static MSWord.Style CreateTableStyle(ref MSWord.Document wdDoc)
        {
            MSWord.WdBorderType verticalBorder = MSWord.WdBorderType.wdBorderVertical;
            MSWord.WdBorderType leftBorder     = MSWord.WdBorderType.wdBorderLeft;
            MSWord.WdBorderType rightBorder    = MSWord.WdBorderType.wdBorderRight;
            MSWord.WdBorderType topBorder      = MSWord.WdBorderType.wdBorderTop;

            MSWord.WdLineStyle doubleBorder = MSWord.WdLineStyle.wdLineStyleDouble;
            MSWord.WdLineStyle singleBorder = MSWord.WdLineStyle.wdLineStyleSingle;

            MSWord.WdTextureIndex noTexture = MSWord.WdTextureIndex.wdTextureNone;
            MSWord.WdColor        gray10    = MSWord.WdColor.wdColorGray10;
            MSWord.WdColor        gray70    = MSWord.WdColor.wdColorGray70;
            MSWord.WdColorIndex   white     = MSWord.WdColorIndex.wdWhite;

            object styleTypeTable = MSWord.WdStyleType.wdStyleTypeTable;

            MSWord.Style styl = wdDoc.Styles.Add("New Table Style", ref styleTypeTable);

            styl.Font.Name            = "Arial";
            styl.Font.Size            = 11;
            styl.Table.Borders.Enable = 1;

            MSWord.ConditionalStyle evenRowBanding = styl.Table.Condition(MSWord.WdConditionCode.wdEvenRowBanding);
            evenRowBanding.Shading.Texture = noTexture;
            evenRowBanding.Shading.BackgroundPatternColor = gray10;
            // Borders have to be set specifically for every condition.
            evenRowBanding.Borders[leftBorder].LineStyle     = doubleBorder;
            evenRowBanding.Borders[rightBorder].LineStyle    = doubleBorder;
            evenRowBanding.Borders[verticalBorder].LineStyle = singleBorder;

            MSWord.ConditionalStyle firstRow = styl.Table.Condition(MSWord.WdConditionCode.wdFirstRow);
            firstRow.Shading.BackgroundPatternColor = gray70;
            firstRow.Borders[leftBorder].LineStyle  = doubleBorder;
            firstRow.Borders[topBorder].LineStyle   = doubleBorder;
            firstRow.Borders[rightBorder].LineStyle = doubleBorder;
            firstRow.Font.Size       = 14;
            firstRow.Font.ColorIndex = white;
            firstRow.Font.Bold       = 1;

            // Set the number of rows to include in a "band".
            styl.Table.RowStripe = 1;
            return(styl);
        }
Exemple #12
0
        public void SetCellColor(int iCol, int iRow, MSWord.WdColor color, MSWord.WdColor text_color = MSWord.WdColor.wdColorAutomatic, int indTable = -1)
        {
            if (text_color == MSWord.WdColor.wdColorAutomatic && color == MSWord.WdColor.wdColorAutomatic)
            {
                return;
            }

            GetTableReference(indTable);

            MSWord.Cell pCell = m_pTable.Cell(iRow, iCol);
            if (pCell == null)
            {
                return;
            }
            pCell.Select();
            MSWord.Selection sel = m_pApp.Selection;
            sel.Shading.Texture = MSWord.WdTextureIndex.wdTextureNone;
            sel.Shading.ForegroundPatternColor = MSWord.WdColor.wdColorAutomatic;
            sel.Shading.BackgroundPatternColor = color;
            if (text_color != MSWord.WdColor.wdColorAutomatic)
            {
                sel.Font.Color = text_color;
            }
        }
Exemple #13
0
 /// <summary>
 /// Specifies whether a range has been marked for redaction.
 /// </summary>
 /// <param name="Range">The Range to check.</param>
 /// <param name="ShadingColor">The color for redaction marks in the document.</param>
 /// <returns>True if the entire range is marked for redaction, False otherwise.</returns>
 internal static bool IsMarkedRange(Word.Range Range, Word.WdColor ShadingColor)
 {
     return(Range.Font.Shading.BackgroundPatternColor == ShadingColor);
 }
Exemple #14
0
        public static void WriteVerse(byte b, byte c, byte v, bool modern, bool contiguous, Word.WdColor label = Word.WdColor.wdColorBlue)
        {
            byte   prevPunc = 0;
            var    chapter  = Ribbon.RIBBON.chIdx[b][c];
            var    records  = Ribbon.RIBBON.writ;
            UInt32 r        = chapter.writIdx;

            for (int i = 1; i < v; /**/)
            {
                r++;
                if ((records[r].tx & 0x70) == 0x20) // BoV
                {
                    i++;
                }
                if ((records[r].tx & 0x70) == 0x70) // EoC or EoB
                {
                    return;
                }
            }
            var keepr = r;
            var first = true;
            var verse = new StringBuilder();

            do
            {
                if (contiguous && ((records[r].tx & 0x70) == 0x20)) // BoV
                {
                    verse.Append(v.ToString() + (char)0x200B /* zero-width-space */);
                }
Exemple #15
0
        private void wypiszWymaganiaArch(ref int wiersz)
        {
            okno.Log(Statystyki.LogMsgType.Info, "Eksport wymagań architektonicznych");

            dajTytulRozdz("2", ref wiersz);

            int i = 1;

            //   int ii = 1;
            //       dajWymaganiaPakietuArch(d, ref i, ref ii, "", new string[] { "Arch." });


            if (modelProjektu.WymaganiaArchitektoniczneLista.Count <= 0)
            {
                word.wstawParagraf("Brak", 0);
            }
            foreach (Element e in modelProjektu.WymaganiaArchitektoniczneLista)
            {
                Wordy.Table tab = null;
                tab = word.wstawTabele("", new string[] { e.Name, "", "", "" /*, "Treść", "Status","Właściciel"*/ });
                tab.Columns[1].SetWidth(100f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[2].SetWidth(200f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[3].SetWidth(100f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[4].SetWidth(100f, Wordy.WdRulerStyle.wdAdjustNone);


                ///{"Typ","Pakiet", "Wymaganie","Status"}
                int           index  = 1;
                Wordy.WdColor kolor1 = Wordy.WdColor.wdColorBlack;
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[3].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[3].Range.Font.Bold = 0;
                tab.Rows[index].Cells[4].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[4].Range.Font.Bold = 0;
                index++;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "", "Właściciel", "Typ", "Status" }, false);
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "", "Owner", "Type", "Status" }, false);
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[2].Range.Font.Bold = 1;
                tab.Rows[index].Cells[3].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[3].Range.Font.Bold = 1;
                tab.Rows[index].Cells[4].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[4].Range.Font.Bold = 1;
                index++;
                word.wstawWierszDoTabeli("", tab, i + index, new string[] { " ", e.Author, e.Stereotype, e.Status });
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[3].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[3].Range.Font.Bold = 0;
                tab.Rows[index].Cells[4].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[4].Range.Font.Bold = 0;
                index++;

                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "Treść Wymagania", e.Notes });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "Requrement", e.Notes });
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Merge(tab.Rows[index].Cells[3]);
                tab.Rows[index].Cells[2].Merge(tab.Rows[index].Cells[3]);
                tab.Rows[index].Cells[2].SetWidth(400f, Wordy.WdRulerStyle.wdAdjustNone);

                tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                word.wstawParagraf("", 0);
                index++;
                i++;
            }
            okno.Log(Statystyki.LogMsgType.WynikOK, " elementów: " + modelProjektu.WymaganiaArchitektoniczneLista.Count + " [ok]\n");
        }
Exemple #16
0
        private string dajWymaganiaPakietuArch(Package d, ref int i, ref int ii, String pakTxt, string[] typyWymagan)
        {
            //  return ""; /////////////////////////<<<<<<<<<<-------------------------- zeby szybciej sie generowalo
            String wynik = "";

            pakTxt += d.Name;

            foreach (Package dd in d.Packages)
            {
                wynik += dajWymaganiaPakietuArch(dd, ref i, ref ii, pakTxt + " -> ", typyWymagan);
            }

            foreach (Element e in d.Elements)
            {
                if (e.Type != "Requirement")
                {
                    continue;
                }
                bool czyRobic = false;
                foreach (string typWymagania in typyWymagan)
                {
                    if (e.Stereotype == typWymagania)
                    {
                        czyRobic = true;
                        break;
                    }
                }
                if (!czyRobic)
                {
                    continue;
                }



                Wordy.Table tab = null;
                tab = word.wstawTabele("", new string[] { e.Name, "", "", "" /*, "Treść", "Status","Właściciel"*/ });
                tab.Columns[1].SetWidth(100f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[2].SetWidth(200f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[3].SetWidth(100f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[4].SetWidth(100f, Wordy.WdRulerStyle.wdAdjustNone);


                ///{"Typ","Pakiet", "Wymaganie","Status"}
                int           index  = 1;
                Wordy.WdColor kolor1 = Wordy.WdColor.wdColorBlack;
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[3].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[3].Range.Font.Bold = 0;
                tab.Rows[index].Cells[4].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[4].Range.Font.Bold = 0;
                index++;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "", "Właściciel", "Typ", "Status" }, false);
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "", "Owner", "Type", "Status" }, false);
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[2].Range.Font.Bold = 1;
                tab.Rows[index].Cells[3].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[3].Range.Font.Bold = 1;
                tab.Rows[index].Cells[4].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[4].Range.Font.Bold = 1;
                index++;
                word.wstawWierszDoTabeli("", tab, i + index, new string[] { " ", e.Author, e.Stereotype, e.Status });
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[3].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[3].Range.Font.Bold = 0;
                tab.Rows[index].Cells[4].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[4].Range.Font.Bold = 0;
                index++;

                /*  !!! to komentujemy bo nie mamy w modelu tresci wytycznych
                 * word.wstawWierszDoTabeli("", tab, i + index, new string[] { "Treść Wytycznej", "","","" });
                 * tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                 * tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                 * tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                 * tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                 * tab.Rows[index].Cells[2].Merge(tab.Rows[index].Cells[3]);
                 * tab.Rows[index].Cells[2].Merge(tab.Rows[index].Cells[3]);
                 * //  tab.Rows[index].Cells[2].SetWidth(350f, Wordy.WdRulerStyle.wdAdjustNone);
                 * //  tab.Rows[index].Cells[2].Range.Text = "To jest wytyczna architektoniczna";
                 *
                 * index++;
                 *  !!!! koniec */
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "Treść Wymagania", e.Notes });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, i + index, new string[] { "Requrement", e.Notes });
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Merge(tab.Rows[index].Cells[3]);
                tab.Rows[index].Cells[2].Merge(tab.Rows[index].Cells[3]);
                tab.Rows[index].Cells[2].SetWidth(350f, Wordy.WdRulerStyle.wdAdjustNone);
                // tab.Rows[index].Cells[2].Range.Text = "To jest wymaganie architektoniczne";
                tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                word.wstawParagraf("", 0);
                index++;
                i++;
            }

            return(wynik);
        }
Exemple #17
0
 public void SetVirtualCellColor(int FirstColumn, int LastColumn, int FirstRow, int LastRow, MSWord.WdColor color, MSWord.WdColor text_color)
 {
     for (int iCol = FirstColumn; iCol <= LastColumn; iCol++)
     {
         for (int iRow = FirstRow; iRow <= LastRow; iRow++)
         {
             m_Table[iCol - 1].m_Cells[iRow - 1].color      = color;
             m_Table[iCol - 1].m_Cells[iRow - 1].text_color = text_color;
         }
     }
 }
Exemple #18
0
 public void SetVirtualCellColor(int iCol, int iRow, MSWord.WdColor color, MSWord.WdColor text_color = MSWord.WdColor.wdColorAutomatic)
 {
     m_Table[iCol - 1].m_Cells[iRow - 1].color      = color;
     m_Table[iCol - 1].m_Cells[iRow - 1].text_color = text_color;
 }
Exemple #19
0
        public static void MakingHydroMonitorReport(HydroMonitorReportData data)
        {
            List <Word.WdColor> backgroundColorList = new List <Word.WdColor>();

            backgroundColorList.Add(Word.WdColor.wdColorSeaGreen);
            backgroundColorList.Add(Word.WdColor.wdColorLightOrange);
            backgroundColorList.Add(Word.WdColor.wdColorLightGreen);
            backgroundColorList.Add(Word.WdColor.wdColorLightYellow);

            string fileOutName = data.OutPath + "/全国主要江河水情监测报告" + DateTime.Now.ToString("yyyyMMdd");

            Word.Range range;
            object     saveWithDocument = true;
            object     missing          = Type.Missing;
            object     oMissing         = System.Reflection.Missing.Value;

            Word.Application app = new Word.Application();
            app.Visible = true;
            Word.Document doc = app.Documents.Open(data.TemplateFullPath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

            object bookmark = "日期年";

            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Year.ToString("D4");

            bookmark   = "日期月";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Month.ToString("D2");

            bookmark   = "日期日";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Day.ToString("D2");

            bookmark   = "日期时";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Hour.ToString("D2");

            bookmark   = "制作人";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportPerson;

            bookmark   = "水情截至月";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Month.ToString("D2");

            bookmark   = "水情截至日";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Day.ToString("D2");

            bookmark   = "水情截至时";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Hour.ToString("D2");

            bookmark   = "水库月";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Month.ToString("D2");

            bookmark   = "水库日";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Day.ToString("D2");

            bookmark   = "水库时";
            range      = doc.Bookmarks.get_Item(ref bookmark).Range;
            range.Text = data.ReportTime.Hour.ToString("D2");

            Word.Table tb     = doc.Tables[2]; //主要水文站实时超警水情表
            int        row    = 2;
            int        color  = 0;
            var        Basin1 = "";

            foreach (var item in data.RiverWarningGroup)
            {
                if (item.Basin == null)
                {
                    item.Basin = "";
                }

                if (!item.Basin.Equals(Basin1))
                {
                    color++;
                }

                tb.Rows.Add(oMissing);
                if (item.IsBeyond == true)  //设置该行是否超警戒需要加粗
                {
                    tb.Rows[row].Range.Bold = 1;
                }
                else
                {
                    tb.Rows[row].Range.Bold = 0;
                }
                tb.Rows[row].Range.Shading.BackgroundPatternColor = backgroundColorList[color % backgroundColorList.Count];  //设置一行的颜色
                tb.Rows[row].Cells[1].Range.Text = item.Basin;
                tb.Rows[row].Cells[2].Range.Text = item.Province;
                tb.Rows[row].Cells[3].Range.Text = item.River;
                tb.Rows[row].Cells[4].Range.Text = item.Name;
                tb.Rows[row].Cells[5].Range.Text = item.Time.ToString("MM-dd HH:MM");
                string       comp      = "";
                Word.WdColor compColor = Word.WdColor.wdColorBlack;
                if (item.ComparedBefore == Trend.Rise)
                {
                    comp      = "↑";
                    compColor = Word.WdColor.wdColorRed;
                }
                else if (item.ComparedBefore == Trend.Fall)
                {
                    comp      = "↓";
                    compColor = Word.WdColor.wdColorGreen;
                }
                else
                {
                    comp = "—";
                }
                range      = tb.Rows[row].Cells[6].Range;
                range.Text = item.Level.ToString("N2") + comp; //水位
                Word.Range colorRange = app.ActiveDocument.Range(range.End - 2, range.End - 1);
                colorRange.Font.Color                  = compColor;
                tb.Rows[row].Cells[7].Range.Text       = item.WarningLevel.ToString("N2");
                tb.Rows[row].Cells[8].Range.Text       = item.OverWarningLevel.ToString("N2");
                tb.Rows[row].Cells[8].Range.Font.Color = Word.WdColor.wdColorRed;
                row++;

                Basin1 = item.Basin;
            }

            tb  = doc.Tables[3]; //全国重点关注水库站实时水情监测表
            row = 2;

            foreach (var item in data.KeyReservoirWarning)
            {
                tb.Rows.Add(oMissing);
                tb.Rows[row].Range.Bold = 0;
                tb.Rows[row].Range.Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;  //设置一行的颜色
                tb.Rows[row].Cells[1].Range.Text = item.Name;
                tb.Rows[row].Cells[3].Range.Text = item.Time.ToString("MM-dd HH:MM");
                string       comp      = "";
                Word.WdColor compColor = Word.WdColor.wdColorBlack;
                if (item.ComparedBefore == Trend.Rise)
                {
                    comp      = "↑";
                    compColor = Word.WdColor.wdColorRed;
                }
                else if (item.ComparedBefore == Trend.Fall)
                {
                    comp      = "↓";
                    compColor = Word.WdColor.wdColorGreen;
                }
                else
                {
                    comp = "—";
                }
                range      = tb.Rows[row].Cells[2].Range;
                range.Text = item.Level.ToString("N2") + comp; //水位
                Word.Range colorRange = app.ActiveDocument.Range(range.End - 2, range.End - 1);
                colorRange.Font.Color                  = compColor;
                tb.Rows[row].Cells[4].Range.Text       = item.WarningLevel.ToString("N2");
                tb.Rows[row].Cells[5].Range.Text       = item.OverWarningLevel.ToString("N2");
                tb.Rows[row].Cells[5].Range.Font.Color = Word.WdColor.wdColorRed;
                row++;
            }

            tb  = doc.Tables[4]; //全国重点关注主要湖泊实时水情监测表
            row = 2;

            foreach (var item in data.LakeWarning)
            {
                tb.Rows.Add(oMissing);
                tb.Rows[row].Range.Bold = 0;
                tb.Rows[row].Range.Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;  //设置一行的颜色
                tb.Rows[row].Cells[1].Range.Text = item.Name;
                tb.Rows[row].Cells[3].Range.Text = item.Time.ToString("MM-dd HH:MM");
                string       comp      = "";
                Word.WdColor compColor = Word.WdColor.wdColorBlack;
                if (item.ComparedBefore == Trend.Rise)
                {
                    comp      = "↑";
                    compColor = Word.WdColor.wdColorRed;
                }
                else if (item.ComparedBefore == Trend.Fall)
                {
                    comp      = "↓";
                    compColor = Word.WdColor.wdColorGreen;
                }
                else
                {
                    comp = "—";
                }
                range      = tb.Rows[row].Cells[2].Range;
                range.Text = item.Level.ToString("N2") + comp; //水位
                Word.Range colorRange = app.ActiveDocument.Range(range.End - 2, range.End - 1);
                colorRange.Font.Color                  = compColor;
                tb.Rows[row].Cells[4].Range.Text       = item.WarningLevel.ToString("N2");
                tb.Rows[row].Cells[5].Range.Text       = item.OverWarningLevel.ToString("N2");
                tb.Rows[row].Cells[5].Range.Font.Color = Word.WdColor.wdColorRed;
                row++;
            }


            tb    = doc.Tables[5]; //主要水库实时超汛限水情表
            row   = 2;
            color = 0;
            var Basin2 = "";

            foreach (var item in data.ReservoirWarningGroup)
            {
                if (item.Basin == null)
                {
                    item.Basin = "";
                }

                if (!item.Basin.Equals(Basin2))
                {
                    color++;
                }

                tb.Rows.Add(oMissing);
                if (item.IsBeyond == true)  //设置该行是否超警戒需要加粗
                {
                    tb.Rows[row].Range.Bold = 1;
                }
                else
                {
                    tb.Rows[row].Range.Bold = 0;
                }
                tb.Rows[row].Range.Shading.BackgroundPatternColor = backgroundColorList[color % backgroundColorList.Count];  //设置一行的颜色
                tb.Rows[row].Cells[1].Range.Text = item.Basin;
                tb.Rows[row].Cells[2].Range.Text = item.Province;
                tb.Rows[row].Cells[3].Range.Text = item.River;
                tb.Rows[row].Cells[4].Range.Text = item.Name;
                tb.Rows[row].Cells[8].Range.Text = item.Time.ToString("MM-dd HH:MM");
                string       comp      = "";
                Word.WdColor compColor = Word.WdColor.wdColorBlack;
                if (item.ComparedBefore == Trend.Rise)
                {
                    comp      = "↑";
                    compColor = Word.WdColor.wdColorRed;
                }
                else if (item.ComparedBefore == Trend.Fall)
                {
                    comp      = "↓";
                    compColor = Word.WdColor.wdColorGreen;
                }
                else
                {
                    comp = "—";
                }
                range      = tb.Rows[row].Cells[9].Range;
                range.Text = item.Level.ToString("N2") + comp; //水位
                Word.Range colorRange = app.ActiveDocument.Range(range.End - 2, range.End - 1);
                colorRange.Font.Color                  = compColor;
                tb.Rows[row].Cells[6].Range.Text       = item.WarningLevel.ToString("N2");
                tb.Rows[row].Cells[7].Range.Text       = item.OverWarningLevel.ToString("N2");
                tb.Rows[row].Cells[7].Range.Font.Color = Word.WdColor.wdColorRed;
                row++;

                Basin2 = item.Basin;
            }

            doc.SaveAs2(fileOutName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
        }
Exemple #20
0
        /// <summary>
        /// Creates the paragraph formatting of the selected text using the style settings and user preferences.
        /// </summary>
        /// <param name="use_frame">determines whether the text is put in a frame</param>
        /// <param name="use_numbering">determines whether line numbering is used</param>
        public void ParagraphFormatting(bool use_frame, bool use_numbering)
        {
            Word.WdColor frameAlternatingColor_ = (Word.WdColor)ColorTranslator.ToOle(frameAlternatingColor);
            Word.WdColor frameBgColor_          = (Word.WdColor)ColorTranslator.ToOle(frameBgColor);
            Word.WdColor frameBorderColor_      = (Word.WdColor)ColorTranslator.ToOle(frameBorderColor);

            Word.Selection sel = wordApp.Selection; // just to make the code cleaner

            sel.ParagraphFormat.LineSpacing = 12.0f;
            sel.ParagraphFormat.SpaceBefore = 0.0f;
            sel.ParagraphFormat.SpaceAfter  = 0.0f;

            /* If line numbering is used, then the text block must be converted into a table, which can be quiet resource demanding */
            if (use_numbering)
            {
                object     missing = Type.Missing;
                object     dontuse = false;
                Word.Table t       = sel.ConvertToTable(Word.WdTableFieldSeparator.wdSeparateByParagraphs, ref missing, 1, ref missing, ref missing, ref missing, ref dontuse, ref dontuse, ref dontuse, ref dontuse, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                t.Columns.Add(t.Columns[1]);
                t.Columns[1].Width = 35.0f;
                t.Columns[2].Width = sel.PageSetup.PageWidth - sel.PageSetup.RightMargin - sel.PageSetup.LeftMargin - 35.0f;

                if (use_frame)
                {
                    t.Columns[1].Borders[Word.WdBorderType.wdBorderRight].LineStyle = Word.WdLineStyle.wdLineStyleSingle;
                    t.Columns[1].Borders[Word.WdBorderType.wdBorderRight].Color     = frameBorderColor_;
                    t.Columns[1].Borders[Word.WdBorderType.wdBorderRight].LineWidth = Word.WdLineWidth.wdLineWidth300pt;
                    t.Columns[1].Shading.BackgroundPatternColor = Word.WdColor.wdColorGray05;

                    int i_ = 0;
                    foreach (Word.Cell c in t.Columns[2].Cells)
                    {
                        if (frameAlternatingLines && (i_ % 2 == 1))
                        {
                            c.Shading.BackgroundPatternColor = frameAlternatingColor_;
                        }
                        else
                        {
                            c.Shading.BackgroundPatternColor = frameBgColor_;
                        }
                        c.LeftPadding = 7.0f;
                        i_++;
                    }

                    t.Borders[Word.WdBorderType.wdBorderTop].LineStyle    = Word.WdLineStyle.wdLineStyleSingle;
                    t.Borders[Word.WdBorderType.wdBorderTop].Color        = frameBorderColor_;
                    t.Borders[Word.WdBorderType.wdBorderTop].LineWidth    = Word.WdLineWidth.wdLineWidth075pt;
                    t.Borders[Word.WdBorderType.wdBorderLeft].LineStyle   = Word.WdLineStyle.wdLineStyleSingle;
                    t.Borders[Word.WdBorderType.wdBorderLeft].Color       = frameBorderColor_;
                    t.Borders[Word.WdBorderType.wdBorderLeft].LineWidth   = Word.WdLineWidth.wdLineWidth075pt;
                    t.Borders[Word.WdBorderType.wdBorderRight].LineStyle  = Word.WdLineStyle.wdLineStyleSingle;
                    t.Borders[Word.WdBorderType.wdBorderRight].Color      = frameBorderColor_;
                    t.Borders[Word.WdBorderType.wdBorderRight].LineWidth  = Word.WdLineWidth.wdLineWidth075pt;
                    t.Borders[Word.WdBorderType.wdBorderBottom].LineStyle = Word.WdLineStyle.wdLineStyleSingle;
                    t.Borders[Word.WdBorderType.wdBorderBottom].Color     = frameBorderColor_;
                    t.Borders[Word.WdBorderType.wdBorderBottom].LineWidth = Word.WdLineWidth.wdLineWidth075pt;
                }

                int i = 0;
                foreach (Word.Cell c in t.Columns[1].Cells)
                {
                    c.Range.Font.ColorIndex           = Word.WdColorIndex.wdGray50;
                    c.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
                    c.RightPadding = 7.0f;
                    c.Range.InsertAfter((i + 1).ToString() + ".");
                    i++;
                }
            }
            else if (use_frame)
            {
                sel.Paragraphs.Last.SpaceAfter   = 12.0f;
                sel.Paragraphs.First.SpaceBefore = 12.0f;

                int i_ = 0;
                foreach (Word.Paragraph p in sel.Paragraphs)
                {
                    if (frameAlternatingLines && (i_ % 2 == 1))
                    {
                        p.Shading.BackgroundPatternColor = frameAlternatingColor_;
                    }
                    else
                    {
                        p.Shading.BackgroundPatternColor = frameBgColor_;
                    }
                    i_++;
                }

                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderTop].LineStyle    = Word.WdLineStyle.wdLineStyleSingle;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderTop].Color        = frameBorderColor_;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderTop].LineWidth    = Word.WdLineWidth.wdLineWidth075pt;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderLeft].LineStyle   = Word.WdLineStyle.wdLineStyleSingle;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderLeft].Color       = frameBorderColor_;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderLeft].LineWidth   = Word.WdLineWidth.wdLineWidth300pt;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderRight].LineStyle  = Word.WdLineStyle.wdLineStyleSingle;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderRight].Color      = frameBorderColor_;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderRight].LineWidth  = Word.WdLineWidth.wdLineWidth075pt;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderBottom].LineStyle = Word.WdLineStyle.wdLineStyleSingle;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderBottom].Color     = frameBorderColor_;
                sel.ParagraphFormat.Borders[Word.WdBorderType.wdBorderBottom].LineWidth = Word.WdLineWidth.wdLineWidth075pt;

                sel.ParagraphFormat.Borders.DistanceFromLeft = 7;
            }
        }
Exemple #21
0
 public void AddSimpleHeader(string HeaderText, Word.WdParagraphAlignment wdAlign, Word.WdColor fontcolor, float fontsize)
 {
     //添加页眉
     m_WordApp.ActiveWindow.View.Type     = Word.WdViewType.wdOutlineView;
     m_WordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
     m_WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(HeaderText);
     m_WordApp.Selection.Font.Color = fontcolor;              //设置字体颜色
     m_WordApp.Selection.Font.Size  = fontsize;               //设置字体大小
     m_WordApp.Selection.ParagraphFormat.Alignment = wdAlign; //设置对齐方式
     m_WordApp.ActiveWindow.View.SeekView          = Word.WdSeekView.wdSeekMainDocument;
 }
Exemple #22
0
        public void DrawAuthor2(AuthorInfo authorInfo)
        {
            Word.WdColor fontColor = Globals.headerFontColor;
            float        fontSize  = Globals.headerFontSize;
            int          len       = 0;

            #region Writter
            Word.Range range  = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            string     writer = writerLable + authorInfo.Writer;
            if (writerLable == string.Empty)
            {
                writer = writerLable;
            }

            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            Word.ContentControl ccNull = emrTaskPane.AddSubTitle(range, " ", Word.WdColor.wdColorWhite);
            ccNull.Title        = StringGeneral.Label; // as end of emrNote content
            ccNull.Tag          = StringGeneral.RemoveFlag;
            ccNull.LockContents = false;

            if (writer.Length > 1)
            {
                if (ThisAddIn.CanOption(ElementNames.ManualSign))
                {
                    writer = writer + StringGeneral.SignSpace;
                }

                if (!ThisAddIn.CanOption(ElementNames.ShowWriter))
                {
                    writer = " ";
                }

                if (!ThisAddIn.CanOption(ElementNames.AutoSign))
                {
                    writer = writerLable + StringGeneral.SignSpace;
                }

                range.Start = ccNull.Range.End + 1;
                ccWriter    = emrTaskPane.AddContentControlTextRight(range, Globals.space6 + writer,
                                                                     null, false, fontSize, fontColor);
                ccWriter.Tag        = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccWriter.Title      = AttributeNames.Writer;
                ccWriter.Range.Font = Globals.contentFont;


                range.Start = ccWriter.Range.End + 1;
                //if (Globals.EncryptSign == true)
                //{
                //    ccWriter.Range.Text = ccWriter.Range.Text.Trim();
                //    emrTaskPane.ThisAddIn.CanOption(ElementNames.ShowWriter)Sign(range, fontSize, fontColor, "WSign");
                //}
                ccWriter.LockContentControl = true;
                ccWriter.LockContents       = true;

                string writtenDate = " ";
                if (ThisAddIn.CanOption(ElementNames.ShowWritenDate))
                {
                    writtenDate += authorInfo.WrittenDate;
                }
                ccWrittenDate = emrTaskPane.AddContentControlTextRight(range, writtenDate, null,
                                                                       false, fontSize, fontColor);
                ccWrittenDate.Tag                = StringGeneral.RemoveFlag;
                ccWrittenDate.Title              = AttributeNames.WrittenDate;
                ccWrittenDate.Range.Font         = Globals.contentFont;
                ccWrittenDate.LockContentControl = true;
                ccWrittenDate.LockContents       = true;

                len += ccWriter.Range.Text.Length + ccWrittenDate.Range.Text.Length;
            }
            #endregion
            #region Checker
            string checker = checkerLable + authorInfo.Checker;
            if (checkerLable == string.Empty)
            {
                checker = checkerLable;
            }
            if (checker.Length > 0)
            {
                if (ThisAddIn.CanOption(ElementNames.ManualSign))
                {
                    checker = checker + StringGeneral.SignSpace;
                }
                if (!ThisAddIn.CanOption(ElementNames.ShowWriter))
                {
                    checker = " ";
                }
                if (!ThisAddIn.CanOption(ElementNames.AutoSign))
                {
                    checker = checkerLable + StringGeneral.SignSpace;
                }

                range.Start = ccWriter.Range.Start - 1;
                range.End   = range.Start;
                ccChecker   = emrTaskPane.AddContentControlTextRight(range, Globals.space6 + checker, null,
                                                                     false, fontSize, fontColor);
                ccChecker.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccChecker.Title              = AttributeNames.Checker;
                ccChecker.Range.Font         = Globals.contentFont;
                ccChecker.LockContentControl = true;
                ccChecker.LockContents       = true;

                range.Start = ccChecker.Range.End + 1;
                string checkedDate = " ";
                if (ThisAddIn.CanOption(ElementNames.ShowWritenDate))
                {
                    checkedDate += authorInfo.CheckedDate;
                }
                ccCheckedDate = emrTaskPane.AddContentControlTextRight(range, checkedDate, null,
                                                                       false, fontSize, fontColor);
                ccCheckedDate.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccCheckedDate.Title              = AttributeNames.CheckedDate;
                ccCheckedDate.Range.Font         = Globals.contentFont;
                ccCheckedDate.LockContentControl = true;
                ccCheckedDate.LockContents       = true;

                len += ccChecker.Range.Text.Length + ccCheckedDate.Range.Text.Length;
            }

            #endregion
            #region FinalChecker
            string finalChecker = finalCheckerLable + authorInfo.FinalChecker;
            if (finalCheckerLable == string.Empty)
            {
                finalChecker = finalCheckerLable;
            }
            if (finalChecker.Length > 0)
            {
                if (ThisAddIn.CanOption(ElementNames.ManualSign))
                {
                    finalChecker = finalChecker + StringGeneral.SignSpace;
                }

                if (!ThisAddIn.CanOption(ElementNames.ShowWriter))
                {
                    finalChecker = " ";
                }

                if (!ThisAddIn.CanOption(ElementNames.AutoSign))
                {
                    finalChecker = finalCheckerLable + StringGeneral.SignSpace;
                }


                if (ccChecker == null)
                {
                    range.Start = ccWriter.Range.Start - 1;
                }
                else
                {
                    range.Start = ccChecker.Range.Start - 1;
                }
                range.End      = range.Start;
                ccFinalChecker = emrTaskPane.AddContentControlTextRight(range, finalChecker,
                                                                        null, false, fontSize, fontColor);
                ccFinalChecker.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccFinalChecker.Title              = AttributeNames.FinalChecker;
                ccFinalChecker.Range.Font         = Globals.contentFont;
                ccFinalChecker.LockContentControl = true;
                ccFinalChecker.LockContents       = true;

                range.Start = ccFinalChecker.Range.End + 1;
                string finalCheckedDate = " ";
                if (ThisAddIn.CanOption(ElementNames.ShowWritenDate))
                {
                    finalCheckedDate += authorInfo.FinalCheckedDate;
                }
                ccFinalCheckedDate = emrTaskPane.AddContentControlTextRight(range, finalCheckedDate,
                                                                            null, false, fontSize, fontColor);
                ccFinalCheckedDate.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccFinalCheckedDate.Title              = AttributeNames.FinalCheckedDate;
                ccFinalCheckedDate.Range.Font         = Globals.contentFont;
                ccFinalCheckedDate.LockContentControl = true;
                ccFinalCheckedDate.LockContents       = true;

                len += ccFinalChecker.Range.Text.Length + ccFinalCheckedDate.Range.Text.Length;
            }

            #endregion
            /////guojt test sourcesafe
            //int padSpace = Globals.countPerLine - len;
            //if (Globals.auditSystem == AuditSystem.A1)
            //{

            //    for (int i = 0; i < padSpace; i++) ccNull.Range.Text += "  ";
            //}
        }
Exemple #23
0
        /// <summary>
        /// Gets a list of all marked ranges in the specified range. The current selection is updated to the end of the range to scan.
        /// </summary>
        /// <param name="rangeToScan">The Range to scan.</param>
        /// <param name="ShadingColor">The color for redaction marks in the document.</param>
        /// <param name="mergeAdjacent">True to merge adjacent ranges with identical formatting, False otherwise.</param>
        /// <returns>A List of RangeDataEx objects containing each marked subrange.</returns>
        internal static List <RangeDataEx> GetAllMarkedRanges(Word.Range rangeToScan, Word.WdColor ShadingColor, bool mergeAdjacent)
        {
            object Missing             = Type.Missing;
            object CollapseStart       = Word.WdCollapseDirection.wdCollapseStart;
            object CharacterFormatting = Word.WdUnits.wdCharacterFormatting;

            int LastPosition;
            int OriginalPosition;
            List <RangeDataEx> Ranges             = new List <RangeDataEx>();
            List <RangeDataEx> RangesToDelete     = new List <RangeDataEx>();
            List <RangeDataEx> ConcatenatedRanges = new List <RangeDataEx>();

            //we don't redact comments - if that's where we are, return
            if (rangeToScan.StoryType == Word.WdStoryType.wdCommentsStory)
            {
                return(ConcatenatedRanges);
            }

            //move the selection to the beginning of the requested range
            rangeToScan.Select();

            Word.Selection CurrentSelection = rangeToScan.Application.Selection;
            CurrentSelection.Collapse(ref CollapseStart);
            OriginalPosition = CurrentSelection.Start;

            //scan for distinct ranges of formatting
            do
            {
                //update LastPosition
                LastPosition = CurrentSelection.Start;

                //move to the next position
                CurrentSelection.Move(ref CharacterFormatting, ref Missing);

                //BUG 3913: if we detect that .Move has moved us out of the scan range (which appears to happen because of a Word bug)
                // break out and don't save the current range
                if (CurrentSelection.Start < OriginalPosition)
                {
                    CurrentSelection.End = rangeToScan.End;
                    break;
                }

                //store that range
                if (CurrentSelection.Start != LastPosition && rangeToScan.End != LastPosition)
                {
                    if (mergeAdjacent)
                    {
                        Ranges.Add(new RangeDataEx(LastPosition, CurrentSelection.Start < rangeToScan.End ? CurrentSelection.Start : rangeToScan.End, new RangeDataEx())); //since we're going to merge, don't fetch the extra properties
                    }
                    else
                    {
                        Word.Font CurrentFont = CurrentSelection.Font;
                        Ranges.Add(new RangeDataEx(LastPosition, CurrentSelection.Start < rangeToScan.End ? CurrentSelection.Start : rangeToScan.End, CurrentFont.Name, CurrentFont.Size, CurrentFont.Bold, CurrentFont.Italic, CurrentSelection.OMaths.Count > 0));
                    }
                }
            }while (CurrentSelection.End <= rangeToScan.End && CurrentSelection.End > LastPosition);

            if (CurrentSelection.End != rangeToScan.End)
            {
                if (mergeAdjacent)
                {
                    Ranges.Add(new RangeDataEx(CurrentSelection.End, rangeToScan.End, new RangeDataEx())); //since we're going to merge, don't fetch the extra properties
                }
                else
                {
                    Word.Font CurrentFont = CurrentSelection.Font;
                    Ranges.Add(new RangeDataEx(CurrentSelection.End, rangeToScan.End, CurrentFont.Name, CurrentFont.Size, CurrentFont.Bold, CurrentFont.Italic, CurrentSelection.OMaths.Count > 0));
                }
            }

            //go through those ranges and check if they are marked
            foreach (RangeDataEx UniqueRange in Ranges)
            {
                rangeToScan.Start = UniqueRange.Start;
                rangeToScan.End   = UniqueRange.End;

                //remove the range from the list
                if (!IsMarkedRange(rangeToScan, ShadingColor))
                {
                    RangesToDelete.Add(UniqueRange);
                }
            }

            //clean out the list
            foreach (RangeDataEx RangeToDelete in RangesToDelete)
            {
                Ranges.Remove(RangeToDelete);
            }
            RangesToDelete.Clear();

            //concatenate ranges that are next to each other
            int?Start = null;
            int?End   = null;

            for (int i = 0; i < Ranges.Count; i++)
            {
                //set start and end points
                if (Start == null)
                {
                    Start = Ranges[i].Start;
                }
                if (End == null)
                {
                    End = Ranges[i].End;
                }

                if ((i + 1) < Ranges.Count && (mergeAdjacent || (Ranges[i].InMath && Ranges[i + 1].InMath) || Ranges[i].IdenticalTo(Ranges[i + 1])) && End == Ranges[i + 1].Start)
                {
                    End = null;
                }
                else
                {
                    ConcatenatedRanges.Add(new RangeDataEx((int)Start, (int)End, Ranges[i]));
                    Start = End = null;
                }
            }

            //return the marked ranges
            return(ConcatenatedRanges);
        }
Exemple #24
0
        //public void BecomeNormalNoteOld()
        //{
        //    AuthorInfo authorInfo;
        //    authorInfo.Writer = Globals.DoctorName;
        //    authorInfo.WrittenDate = ThisAddIn.Today().ToString(StringGeneral.DateFormat);
        //    authorInfo.Checker = "";
        //    authorInfo.ChildID = string.Empty;
        //    authorInfo.CheckedDate = "";
        //    authorInfo.FinalChecker = "";
        //    authorInfo.FinalCheckedDate = "";
        //    authorInfo.TemplateType = StringGeneral.NoneTemplate;
        //    authorInfo.TemplateName = "";
        //    authorInfo.NoteID = "";
        //    authorInfo.NoteName = "";
        //    authorInfo.WriterLable = emrTaskPane.currentNote.author.writerLable;
        //    authorInfo.CheckerLable = emrTaskPane.currentNote.author.checkerLable;
        //    authorInfo.FinalCheckerLable = emrTaskPane.currentNote.author.finalCheckerLable;

        //    DrawAuthor(authorInfo);

        //}

        public void DrawAuthor1(AuthorInfo authorInfo)
        {
            Word.WdColor fontColor = Globals.headerFontColor;
            float        fontSize  = Globals.headerFontSize;

            Word.Range range  = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            string     writer = writerLable + authorInfo.Writer;

            if (writerLable == "ЛМепЃК")
            {
                writer = " ";
            }
            range.Start    = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            ccWriter       = emrTaskPane.AddContentControlText(range, writer, null, true, fontSize, fontColor);
            ccWriter.Title = StringGeneral.Label;      // as end of emrNote content
            ccWriter.Tag   = StringGeneral.RemoveFlag; // as a note template, it will be removed

            if (writer.Length > 1)
            {
                range.Start   = ccWriter.Range.End + 1;
                ccWrittenDate = emrTaskPane.AddContentControlText(range, " " + authorInfo.WrittenDate, null,
                                                                  true, fontSize, fontColor);
                ccWrittenDate.Tag   = StringGeneral.RemoveFlag;
                ccWrittenDate.Title = AttributeNames.WrittenDate;
            }

            string checker = checkerLable + authorInfo.Checker;

            if (checker.Length > 0)
            {
                range.Start = ccWrittenDate.Range.End + 1;
                ccChecker   = emrTaskPane.AddContentControlText(range, Globals.space6 + checker, null,
                                                                true, fontSize, fontColor);
                ccChecker.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccChecker.Title = AttributeNames.Checker;
                range.Start     = ccChecker.Range.End + 1;
                ccCheckedDate   = emrTaskPane.AddContentControlText(range, " " + authorInfo.CheckedDate, null,
                                                                    true, fontSize, fontColor);
                ccCheckedDate.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccCheckedDate.Title = AttributeNames.CheckedDate;
            }
            string finalChecker = finalCheckerLable + authorInfo.FinalChecker;

            if (finalChecker.Length > 0)
            {
                if (ccChecker == null)
                {
                    range.Start = ccWriter.Range.End + 1;
                }
                else
                {
                    range.Start = ccChecker.Range.End + 1;
                }

                ccFinalChecker = emrTaskPane.AddContentControlText(range, Globals.space6 +
                                                                   finalChecker, null, true, fontSize, fontColor);
                ccFinalChecker.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccFinalChecker.Title = AttributeNames.FinalChecker;
                range.Start          = ccFinalChecker.Range.End + 1;
                ccFinalCheckedDate   = emrTaskPane.AddContentControlText(range, " " + authorInfo.FinalCheckedDate,
                                                                         null, true, fontSize, fontColor);
                ccFinalCheckedDate.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccFinalCheckedDate.Title = AttributeNames.FinalCheckedDate;
            }
        }
Exemple #25
0
 private static wordnm.WdColor convertColorToWdColor(colnm col)
 {
     wordnm.WdColor c = (wordnm.WdColor)(col.R + 0x100 * col.G + 0x10000 * col.B);
     return(c);
 }
Exemple #26
0
 public FormFindAndMark(Word.WdColor color)
 {
     ShadingColor = color;
     InitializeComponent();
 }
Exemple #27
0
        private void CheckWords(Word.Document doc, Hunspell hunspell, string selectedText, string[] khmerwords, out bool stopcheck, out bool repeatcheck, string objecttype = "", object wordobject = null)
        {
            int    startposition = 0;
            Object oMissing      = System.Reflection.Missing.Value;

            stopcheck = repeatcheck = false;

            //Check all the Khmer words from the selected line
            foreach (string khmerword in khmerwords)
            {
                DialogResult dialogResult = DialogResult.None;
                frmKhmer     frmKhmer     = null;
                String       newKhmerWord = String.Empty;

                if (!hunspell.Spell(khmerword))
                {
                    if (!ignoreAllWords.Any(ignoreAllWord => ignoreAllWord.khmerword == khmerword))
                    {
                        if (!ignoreWords.Contains(new IgnoreWord {
                            document = doc.Name, khmerword = khmerword, selectedText = selectedText, startposition = startposition, ignoreAll = false
                        }))
                        {
                            Word.Range        start = null;
                            Word.WdColorIndex highlightcolorindex = Word.WdColorIndex.wdNoHighlight;
                            Word.WdUnderline  fontunderline       = Word.WdUnderline.wdUnderlineNone;
                            Word.WdColor      fontcolor           = Word.WdColor.wdColorBlack;
                            Word.Range        selectionRange      = null;

                            //Select the erroneous word on the main document
                            if (String.IsNullOrWhiteSpace(objecttype))
                            {
                                //Set the initial selection
                                start = doc.ActiveWindow.Selection.Range;

                                //Set the search area
                                doc.ActiveWindow.Selection.Start += startposition;
                                Word.Selection searchArea = doc.ActiveWindow.Selection;

                                //Set the find object
                                Word.Find findObject = searchArea.Find;
                                findObject.ClearFormatting();
                                findObject.Text = khmerword;


                                //Find the mis-spelled word
                                findObject.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                                //Temp store the current formatting
                                highlightcolorindex = doc.ActiveWindow.Selection.Range.HighlightColorIndex;
                                fontunderline       = doc.ActiveWindow.Selection.Range.Font.Underline;
                                fontcolor           = doc.ActiveWindow.Selection.Range.Font.UnderlineColor;

                                //Highlight the selection
                                doc.ActiveWindow.Selection.Range.HighlightColorIndex = Word.WdColorIndex.wdYellow;
                                doc.ActiveWindow.Selection.Range.Font.Underline      = Word.WdUnderline.wdUnderlineWavy;
                                doc.ActiveWindow.Selection.Range.Font.UnderlineColor = Word.WdColor.wdColorRed;
                                selectionRange = doc.ActiveWindow.Selection.Range;
                                doc.ActiveWindow.Selection.Collapse();
                            }
                            else
                            {
                                if (objecttype == "table")
                                {
                                    start = ((Word.Cell)wordobject).Range;
                                }
                                else if (objecttype == "shape")
                                {
                                    start        = ((Word.Shape)wordobject).TextFrame.TextRange;
                                    start.Start += startposition;
                                }

                                //Set the find object
                                Word.Find findObject = start.Find;
                                findObject.ClearFormatting();
                                findObject.Text = khmerword;

                                //Temp store the current formatting
                                highlightcolorindex = start.HighlightColorIndex;
                                fontunderline       = start.Font.Underline;
                                fontcolor           = start.Font.UnderlineColor;

                                //Find the mis-spelled word
                                findObject.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                                //Highlight the selection
                                start.HighlightColorIndex = Word.WdColorIndex.wdYellow;
                                start.Font.Underline      = Word.WdUnderline.wdUnderlineWavy;
                                start.Font.UnderlineColor = Word.WdColor.wdColorRed;
                                start.Select();
                            }

                            bool isObject = !String.IsNullOrWhiteSpace(objecttype);
                            frmKhmer     = new frmKhmer(selectedText, khmerword, startposition, hunspell.Suggest(khmerword), isObject);
                            dialogResult = frmKhmer.ShowDialog();

                            //Select the line again
                            if (String.IsNullOrWhiteSpace(objecttype))
                            {
                                //Revert the highlights
                                selectionRange.Select();
                                doc.ActiveWindow.Selection.Range.HighlightColorIndex = highlightcolorindex;
                                doc.ActiveWindow.Selection.Range.Font.Underline      = fontunderline;
                                doc.ActiveWindow.Selection.Range.Font.UnderlineColor = fontcolor;

                                if (dialogResult != DialogResult.Abort)
                                {
                                    start.Select();
                                }
                            }
                            else
                            {
                                start.HighlightColorIndex = highlightcolorindex;
                                start.Font.Underline      = fontunderline;
                                start.Font.UnderlineColor = fontcolor;

                                if (dialogResult != DialogResult.Abort)
                                {
                                    if (objecttype == "table")
                                    {
                                        ((Word.Cell)wordobject).Select();
                                    }
                                    else if (objecttype == "shape")
                                    {
                                        ((Word.Shape)wordobject).Select();
                                    }
                                }
                            }
                        }
                    }
                }

                #region Cancel Button Clicked
                //Return if the user hits Cancel Button
                if (dialogResult == DialogResult.Cancel || dialogResult == DialogResult.Abort)
                {
                    stopcheck   = true;
                    repeatcheck = false;
                    return;
                }
                #endregion

                #region Ignore or Ignore All Clicked
                //Ignore the word
                if (dialogResult == DialogResult.Ignore)
                {
                    if (frmKhmer.ignoreAll)
                    {
                        ignoreAllWords.Add(new IgnoreWord {
                            khmerword = khmerword, ignoreAll = frmKhmer.ignoreAll
                        });
                    }
                    else
                    {
                        ignoreWords.Add(new IgnoreWord {
                            document = doc.Name, khmerword = khmerword, selectedText = selectedText, startposition = startposition
                        });
                    }
                }
                #endregion

                #region Change or Change All Clicked
                if (dialogResult == DialogResult.Yes)
                {
                    if (String.IsNullOrWhiteSpace(objecttype))
                    {
                        //Set the initial selection
                        Word.Range start = doc.ActiveWindow.Selection.Range;

                        //Set the searcharea
                        if (frmKhmer.changeAll)
                        {
                            doc.Content.Select();
                        }
                        Word.Selection searchArea = doc.ActiveWindow.Selection;

                        //Set the find object
                        Word.Find findObject = searchArea.Find;
                        findObject.ClearFormatting();
                        findObject.Text = khmerword;
                        findObject.Replacement.ClearFormatting();
                        findObject.Replacement.Text = frmKhmer.selectedSuggestion;

                        object replaceAll = frmKhmer.changeAll ? Word.WdReplace.wdReplaceAll : Word.WdReplace.wdReplaceOne;

                        findObject.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                        newKhmerWord = frmKhmer.selectedSuggestion;

                        //Set back the selection
                        start.Select();

                        //Set repeatcheck to true
                        if (frmKhmer.changeAll)
                        {
                            stopcheck   = false;
                            repeatcheck = true;
                            return;
                        }
                    }
                    else
                    {
                        var resultingText = selectedText.Replace(khmerword, frmKhmer.selectedSuggestion);

                        if (objecttype == "table")
                        {
                            Word.Range range = ((Word.Cell)wordobject).Range;
                            range.Text = resultingText;
                        }
                        else if (objecttype == "shape")
                        {
                            Word.Shape shape = (Word.Shape)wordobject;
                            shape.TextFrame.TextRange.Text = resultingText;
                        }

                        stopcheck   = false;
                        repeatcheck = true;
                        return;
                    }
                }
                #endregion

                startposition += String.IsNullOrWhiteSpace(newKhmerWord) ? khmerword.Length : newKhmerWord.Length;
            }
        }
Exemple #28
0
        private String dajInterfejsyRealizacjaOpis(Package pakiet, ref int nrRozdz, int lp, Package pakietSystemu)
        {
            String w = "";

            w += "<div class=\"img\">";

            Package pakietInterfejs = EAUtils.utworzPakietGdyBrak(ref pakiet, "Realizowane interfejsy", "");
            int     licznik         = 0;

            foreach (Element e1 in pakietInterfejs.Elements)
            {
                foreach (Method m1 in e1.Methods)
                {
                    licznik++;
                }
            }
            if (licznik == 0)
            {
                w += "\nSystem nie dostarcza interfejsów.\n<BR>";
                if (jezykPolski)
                {
                    word.wstawParagraf("System nie dostarcza interfejsów.", word.stylNorm);
                }
                else
                {
                    word.wstawParagraf("The system does not realize any interfaces.", word.stylNorm);
                }
                return(w + "</div>");
            }



            int i = 1;

            Wordy.WdColor kolor1 = Wordy.WdColor.wdColorBlack;


            foreach (Element e in pakietInterfejs.Elements)
            {
                word.wstawParagraf(nrRozdz + "." + lp + "." + i + " " + e.Name, 3);
                Wordy.Table tab = word.wstawTabele("", new string[] { e.Name, "" });
                tab.Columns[1].SetWidth(200f, Wordy.WdRulerStyle.wdAdjustNone);
                tab.Columns[2].SetWidth(300f, Wordy.WdRulerStyle.wdAdjustNone);
                /// nagłówek
                //tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[1].Cells[1].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[1].Cells[2].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[1].Cells[1].Range.Font.Bold = 1;
                tab.Rows[1].Cells[1].Range.Font.Name = "Calibri";

                int index = 2;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Opis", e.Notes });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Description", e.Notes });
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                index++;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Technologia", e.Stereotype });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Technology", e.Stereotype });
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                index++;
                string dostawca = "";
                foreach (Connector c in e.Connectors)
                {
                    if (c.Type == "Realisation")
                    {
//                        Element realizator = Repo.GetElementByID(c.ClientID);
                        Element realizator = modelProjektu.Repozytorium.GetElementByID(c.ClientID);
                        dostawca += realizator.Name + ", ";
                    }
                }
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Dostawca", dostawca });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Provider", dostawca });
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                index++;
                string konsument = "";
                foreach (Connector c in e.Connectors)
                {
                    if (c.Type == "Usage")
                    {
                        // Element kons = Repo.GetElementByID(c.ClientID);
                        Element kons = modelProjektu.Repozytorium.GetElementByID(c.ClientID);
                        konsument += kons.Name + ", ";
                    }
                }
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Konsument", konsument });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Consumer", konsument });
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                index++;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Operacje", "" }, false);
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Operations", "" }, false);
                }
                //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = kolor1;
                index++;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Nazwa operacji", "Opis" });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Operation name", "Description" });
                }
                //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                index++;

                foreach (Method m in e.Methods)
                {
                    //  i++;
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "&lt;&lt;" + m.Stereotype + "&gt;&gt;\n" + m.Name, m.Notes });
                    //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    index++;
                }
                if (e.Methods.Count <= 0)
                {
                    if (jezykPolski)
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "Brak operacji", "" }, false);
                    }
                    else
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "None", "" }, false);
                    }
                    //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    index++;
                }
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Atrybuty", "" }, false);
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Atributes", "" }, false);
                }
                //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = kolor1;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = kolor1;
                index++;
                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Nazwa atrybutu", "Opis" });
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Atribute name", "Description" });
                }
                //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                index++;
                foreach (EA.Attribute a in e.Attributes)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { a.Name, a.Notes });
                    //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    index++;
                }
                if (e.Attributes.Count <= 0)
                {
                    if (jezykPolski)
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "Brak atrybutów", "" }, false);
                    }
                    else
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "None", "" }, false);
                    }
                    //  tab.Rows[index].Cells[1].Merge(tab.Rows[1].Cells[2]);
                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                    index++;
                }

                if (jezykPolski)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Parametry dla operacji:", "" }, false);
                }
                else
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { "Operation parameters:", "" }, false);
                }
                tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                tab.Rows[index].Cells[1].Range.Font.Name = "Calibri";
                index++;

                foreach (Method m in e.Methods)
                {
                    word.wstawWierszDoTabeli("", tab, index, new string[] { m.Name, "" }, false);
                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = kolor1;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = kolor1;
                    index++;
                    if (jezykPolski)
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "Nazwa parametru : Typ danych", "Opis" });
                    }
                    else
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "Parameter name : Type", "Description" });
                    }
                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorGray25;
                    index++;

                    if (m.Parameters.Count <= 0)
                    {
                        if (jezykPolski)
                        {
                            word.wstawWierszDoTabeli("", tab, index, new string[] { "Brak parametrów dla operacji", "" }, false);
                        }
                        else
                        {
                            word.wstawWierszDoTabeli("", tab, index, new string[] { "None", "" }, false);
                        }
                        tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                        tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                        tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                        tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                        index++;
                    }
                    else
                    {
                        foreach (EA.Parameter par in m.Parameters)
                        {
                            word.wstawWierszDoTabeli("", tab, index, new string[] { par.Name + " " + par.Type, par.Notes });
                            tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                            tab.Rows[index].Cells[1].Range.Font.Bold = 0;
                            tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                            tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = Wordy.WdColor.wdColorWhite;
                            index++;
                        }
                    }
                }
                /// dodanie opisu
                /// jesli jest załączony
                string d = e.GetLinkedDocument();
                if (d.Length > 0)
                {
                    if (jezykPolski)
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "Dodatowy opis interfejsu", "" }, false);
                    }
                    else
                    {
                        word.wstawWierszDoTabeli("", tab, index, new string[] { "Additional description", "" }, false);
                    }

                    tab.Rows[index].Cells[1].Shading.BackgroundPatternColor = kolor1;
                    tab.Rows[index].Cells[1].Range.Font.Bold = 1;
                    tab.Rows[index].Cells[2].Range.Font.Bold = 0;
                    tab.Rows[index].Cells[2].Shading.BackgroundPatternColor = kolor1;
                    index++;

                    //tu fragment prawdopodobnie zjebany bo mergowanie coś średnio bangla i potem tabela
                    //może się rozjechać, dlatego bez tabeli
                    word.wstawZalacznikRTF(e);
                    // koniec zjebu
                }
                i++;
            }

            return(w + "</div>\n");
        }
Exemple #29
0
 /// <summary>
 /// Establece el estilo de la arista de una celda.
 /// </summary>
 /// <param name="cell">Celda a formatear.</param>
 /// <param name="style">Estilo de la línea.</param>
 /// <param name="borderType">Arista a colorear.</param>
 /// <param name="color">Color de la línea.</param>
 private void SetCellBorder(Word.Cell cell, Word.WdLineStyle style = Word.WdLineStyle.wdLineStyleSingle, Word.WdBorderType borderType = Word.WdBorderType.wdBorderBottom, Word.WdColor color = Word.WdColor.wdColorBlack)
 {
     Word.Border border = cell.Borders[borderType];
     border.Visible   = true;
     border.LineStyle = style;
     border.LineWidth = Word.WdLineWidth.wdLineWidth050pt;
     border.Color     = color;
 }