示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Application.DoEvents();
            int DocPageNumber = DS.GetPageNumber(Doc);

            settings.trackChange(Doc, false);
            string[] vars = new string[9];
            vars[1] = addVar("last_page_rivision", this.page_rev);
            vars[2] = addVar("last_date_rivision", this.date_rev);
            vars[3] = addVar("last_issue", this.issueText);
            vars[4] = addVar("last_effective_date", this.effectiveText);
            vars[5] = addVar("last_text1_value", this.text1_text);
            vars[6] = addVar("last_text2_value", this.text2_text);
            vars[7] = addVar("last_text3_value", this.text3_text);
            vars[8] = addVar("last_text4_value", this.text4_text);
            if (checkBox1.Checked)
            {
                DialogResult dialogResult = MessageBox.Show("Be aware this action will override all existing Dates and Rivisions data in all Pages. are you sure?", "Update all Doc?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    string edoc_page_text = "";
                    for (int i = 0; i < pageView.Items.Count; i++)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        edoc_page_text = "edocs_Page" + pageView.CheckedItems[i].SubItems[0].Text + "_page";
                        try {
                            vars[0] = Doc.Variables[edoc_page_text].Value;
                            saveChanges(vars, i);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
            }
            else
            {
                string edoc_page_text = "";
                for (int i = 0; i < pageView.CheckedItems.Count; i++)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    edoc_page_text = "edocs_Page" + pageView.CheckedItems[i].SubItems[0].Text + "_page";
                    try
                    {
                        vars[0] = Doc.Variables[edoc_page_text].Value;
                        saveChanges(vars, i);
                    }
                    catch
                    {
                        continue;
                    }
                }
                Cursor.Current = Cursors.Default;
            }
            Cursor.Current = Cursors.Default;
            pageView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            DS.UpDateFields();
        }
示例#2
0
        public static void ProcessMonitoring(Word.Document Doc)
        {
            DocSettings DS = new DocSettings(Doc);

            for (int i = 1; i <= DS.GetPageNumber(Doc); i++)
            {
                DS.changePageData(i);
            }
            DS.UpDateFields();
        }
示例#3
0
        public static void process_doc(Word.Document Doc, string type)
        {
            DocSettings DS = new DocSettings(Doc);

            DS.IsAlert = true;
            int DocPageNumber = DS.GetPageNumber(Doc);

            System.Diagnostics.Debug.WriteLine("DocPageNumber process doc - " + DocPageNumber);
            if (DS.PageNumberFromHeaders(DocPageNumber, type))
            {
                if (settings.monitorDoc)
                {
                    DS.processMonitoring();
                    settings.monitorDoc = false;
                }
            }
            DS.UpDateFields();;
            trackChange(Doc, false);
            Doc.Application.ActiveWindow.VerticalPercentScrolled = 0;
            Globals.ThisAddIn.m_Ribbon.ribbon.InvalidateControl("toggleButton_ribbon");
            Globals.ThisAddIn.m_Ribbon.ribbon.InvalidateControl("rev_cbo");
            Globals.ThisAddIn.m_Ribbon.ribbon.InvalidateControl("date_cbo");
        }
示例#4
0
        public static int BuildTable_ListOfEffctivePage(DocSettings DS, Word.Table tbl, int PageNum, int FirstHeaderPage)
        {
            int pagesSum = 1;

            PageNum = PageNum - FirstHeaderPage;
            int startPageNumber = PageNum;
            int RowToadd        = 0;

            while (pagesSum * 2 < PageNum)
            {
                if (settings.alert.worker.CancellationPending)
                {
                    return(-1);
                }
                RowToadd = (PageNum / 2) - pagesSum;
                if (PageNum % 2 != 0)
                {
                    RowToadd = RowToadd + 1;
                }

                tbl.Rows[tbl.Rows.Count].Select();
                DS.Doc.Application.Selection.InsertRowsBelow(RowToadd);
                pagesSum = tbl.Rows.Count - 2;
                PageNum  = DS.GetPageNumber() - FirstHeaderPage;
            }

            if (PageNum % 2 != 0)
            {
                tbl.Cell(tbl.Rows.Count, 5).Range.Text = "x";
                tbl.Cell(tbl.Rows.Count, 6).Range.Text = "x";
                tbl.Cell(tbl.Rows.Count, 7).Range.Text = "x";
                tbl.Cell(tbl.Rows.Count, 8).Range.Text = "x";
            }

            return(PageNum - startPageNumber);
        }
示例#5
0
        private void PageRevisionFrm_Load(object sender, EventArgs e)
        {
            DS = new DocSettings(Doc);
            settings.trackChange(Doc, false);
            int    DocPageNumber     = DS.GetPageNumber(Doc);
            string pageRev           = "";
            string eDocPage          = "";
            string pageDate          = "";
            string pageIssue         = "";
            string pageEffectiveDate = "";
            string text1             = "";
            string text2             = "";
            string text3             = "";
            string text4             = "";

            firstClickItemIndex = 0;
            try
            {
                this.date_rev.Text = Doc.Variables["last_date_rivision"].Value;
            }
            catch  { }
            try
            {
                this.page_rev.Text = Doc.Variables["last_page_rivision"].Value;
            }
            catch {  }
            try
            {
                this.issueText.Text = Doc.Variables["last_issue"].Value;
            }
            catch { }
            try
            {
                this.effectiveText.Text = Doc.Variables["last_effective_date"].Value;
            }
            catch { }
            try
            {
                this.text1_text.Text = Doc.Variables["last_text1_value"].Value;
            }
            catch { }
            try
            {
                this.text2_text.Text = Doc.Variables["last_text2_value"].Value;
            }
            catch { }

            try
            {
                this.text3_text.Text = Doc.Variables["last_text3_value"].Value;
            }
            catch { }
            try
            {
                this.text4_text.Text = Doc.Variables["last_text4_value"].Value;
            }
            catch { }
            for (int i = 1; i <= DocPageNumber; i++)
            {
                Cursor.Current = Cursors.WaitCursor;
                pageRev        = getVarString("rev", i);

                try {
                    string pageTemplate = Doc.Variables["pageTemplate"].Value;

                    switch (pageTemplate)
                    {
                    case "X-P1":
                        eDocPage = getVarString("X-P1", i);
                        break;

                    case "X-P-1":
                        eDocPage = getVarString("X-P-1", i);
                        break;

                    case "X1":
                        eDocPage = getVarString("X1", i);
                        break;
                    }
                }
                catch {
                    eDocPage = getVarString("page", i);
                }

                pageDate          = getVarString("date", i);
                pageIssue         = getVarString("issue", i);
                pageEffectiveDate = getVarString("effective", i);
                text1             = getVarString("text1", i);
                text2             = getVarString("text2", i);
                text3             = getVarString("text3", i);
                text4             = getVarString("text4", i);
                string[] row          = { i.ToString(), eDocPage, pageRev, pageDate, pageIssue, pageEffectiveDate, text1, text2, text3, text4 };
                var      listViewItem = new ListViewItem(row);
                pageView.Items.Add(listViewItem);
            }
            pageView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            Cursor.Current = Cursors.Default;
            settings.trackChange(Doc, true);
        }
示例#6
0
        public static void init_ListOfE_New(Word.Document RealDoc)
        {
            // JUST FOR ADD PAGES TO
            //BuildTable_ListOfEffctive_BigData(RealDoc, RealDoc.Tables[2]);
            // return;
            //END OF BIG DATA
            Object      SelectionNext;
            DocSettings DS = new DocSettings(RealDoc);

            SelectionNext = RealDoc.Application.Selection.End;
            Word.Range rangeForToCopy = RealDoc.Range(ref SelectionNext, ref SelectionNext);
            int        pageSize       = 4;

            if (rangeForToCopy.PageSetup.PaperSize == Word.WdPaperSize.wdPaperA5)
            {
                pageSize = 5;
            }
            int    currentPageNum      = Convert.ToInt32(RealDoc.Application.Selection.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndPageNumber));
            object currentPageNumToRef = currentPageNum;

            Word.Document DocOfE = null;
            try
            {
                DocOfE = Globals.ThisAddIn.Application.Documents.Add(LOEPPath(pageSize));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something Went Wrong - " + ex.Message);
                OpenFileDialog openFile = new OpenFileDialog();
                openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                openFile.Title            = "Select Word Template";
                openFile.FileName         = "";
                openFile.Filter           = "Word Documents (*.doc;*.docx)|*.doc;*.docx";
                if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    DocOfE = Globals.ThisAddIn.Application.Documents.Add(openFile.FileName);
                }
                else
                {
                    settings.alert.Close();
                }
            }
            Cursor.Current = Cursors.WaitCursor;
            DocOfE.Tables[1].Range.Copy();
            rangeForToCopy.PasteAndFormat(Word.WdRecoveryType.wdFormatOriginalFormatting);
            try
            {
                int DocPageNumber = DS.GetPageNumber(RealDoc);
                RealDoc.Activate();
                int FirstHeaderPage = 0;
                int pageToDo        = BuildTable_ListOfEffctivePage(DS, rangeForToCopy.Tables[1], DocPageNumber, FirstHeaderPage);
                copyCellsToTable(rangeForToCopy.Tables[1], DocOfE.Tables[2], (DocPageNumber + pageToDo - FirstHeaderPage), FirstHeaderPage);
                DocOfE.Close(ref saveOption, ref originalFormat, ref routeDocument);
                if (pageToDo > 0)
                {
                    try
                    {
                        string PageString = RealDoc.Variables["edocs_Page" + currentPageNum + "_page"].Value;
                        string PageRev    = RealDoc.Variables["edocs_Page" + PageString + "_rev"].Value;
                        string PageDate   = RealDoc.Variables["edocs_Page" + PageString + "_date"].Value;
                        for (int i = currentPageNum + 1; i <= currentPageNum + pageToDo; i++)
                        {
                            string PageString2 = RealDoc.Variables["edocs_Page" + i + "_page"].Value;
                            RealDoc.Variables["edocs_Page" + PageString2 + "_rev"].Value  = PageRev;
                            RealDoc.Variables["edocs_Page" + PageString2 + "_date"].Value = PageDate;
                        }
                    }
                    catch { }
                }
                try { string test1 = RealDoc.Variables["processType"].Value; }
                catch { RealDoc.Variables.Add("processType", "styles"); }
                if (pageToDo == -1 || !DS.PageNumberFromHeaders(DocPageNumber + pageToDo, RealDoc.Variables["processType"].Value))
                {
                    RealDoc.Application.ScreenUpdating = true;
                }
                RealDoc.Application.Selection.GoTo(ref what, ref which, ref currentPageNumToRef, ref missing);
                trackChange(RealDoc, true);
            }
            catch (Exception ex)
            {
                trackChange(RealDoc, true);
                RealDoc.Application.ScreenUpdating = true;
                MessageBox.Show("Something Went Wrong - " + ex.Message);
                settings.alert.Close();
            }
            Cursor.Current = Cursors.Default;
            rangeForToCopy.Tables[1].Range.Fields.Locked = 0;
            rangeForToCopy.Tables[1].Range.Fields.Update();
            DS.UpDateFields();
        }