Ejemplo n.º 1
0
        private void LoadBindings()
        {
            this.treeView1.Nodes.Clear();

            this.treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText;
            this.treeView1.DrawNode += new DrawTreeNodeEventHandler(DrawNode);

            Methods _methods = new Methods();
            TemplateCustomXML tXML = _methods.ReadXML<TemplateCustomXML>(Globals.ThisAddIn.Application.ActiveDocument);
            Tools.Models.Template _temp = null;
            if (tXML != null)
            {
                _temp = _temp = ThisAddIn._document<Tools.Models.Template>(tXML.TemplateID);// 
                
                _temp.AutoDocuments.ForEach(au =>
                {
                    au = _unitOfWork.AutoDocumentRepository.FindBy(id => id.AutoDocumentID == au.AutoDocumentID, "BookMarkDatas");

                    TreeNode document = new TreeNode(au.Name);
                    document.Name = au.AutoDocumentID;


                    _temp.BookMarks.ForEach(bkmk =>
                    {
                        var bkd = au.BookMarkDatas.Where(aubd => aubd.BookMarkID == bkmk.BookMarkID).FirstOrDefault();
                        if (bkd == null)
                        {
                            var node = new TreeNode(bkmk.BookmarkName);
                            node.Tag = bkmk.BookmarkName;
                            node.Name = bkmk.BookMarkID;
                            node.ForeColor = System.Drawing.Color.Red;
                            document.Nodes.Add(node);

                            // document.ForeColor = System.Drawing.Color.Black;
                            document.ForeColor = System.Drawing.Color.Red;

                        }
                        else
                        {
                            var node = new TreeNode((bkmk.BookmarkName + " = " + bkd.BookMarkValue));
                            node.Tag = bkmk.BookmarkName;
                            node.Name = bkmk.BookMarkID;
                            document.Nodes.Add(node);

                        }


                    });

                    document.Checked = document.Nodes.Descendants().Where(n => n.ForeColor == System.Drawing.Color.Red).Any() ? false : true;
                    this.treeView1.Nodes.Add(document);
                    this.treeView1.CheckBoxes = true;

                });
            }
            
        }
Ejemplo n.º 2
0
        public void AutoDocSaveFolder(Office.IRibbonControl control)
        {
            //System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog();
            //save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //save.RestoreDirectory = true;

            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //System.Windows.Forms.MessageBox.Show(fbd.SelectedPath);
                Methods _methods = new Methods();
                TemplateCustomXML tXML = _methods.ReadXML<TemplateCustomXML>(Globals.ThisAddIn.Application.ActiveDocument);
                Tools.Models.Template _temp = null;
                if (tXML != null) _temp = _temp = ThisAddIn._document<Tools.Models.Template>(tXML.TemplateID);//

                _temp.AutoDocumentsPath = fbd.SelectedPath;
                ThisAddIn._unitOfWork.Save();
            }
        }
Ejemplo n.º 3
0
        private void LoadDocumentButtons()
        {
            Methods _methods = new Methods();
            TemplateCustomXML tXML = _methods.ReadXML<TemplateCustomXML>(Globals.ThisAddIn.Application.ActiveDocument);
            Template _temp = null;
            if (tXML != null) _temp = _temp = ThisAddIn._document<Template>(tXML.TemplateID);//

            foreach (AutoDocument autoD in _temp.AutoDocuments)
            {
                Button lb1 = new Button();
                lb1.Text = autoD.Name;
                lb1.AutoSize = true;
                lb1.Name = autoD.AutoDocumentID;
                lb1.Click += new EventHandler(ButtonClick);
                flowLayoutPanel1.Controls.Add(lb1);
            }

            for (int i = 1; i <= (_temp.Number - _temp.AutoDocuments.Count()); i++)
            {
                Button lb1 = new Button();
                lb1.Text = "Unnamed Document " + i;
                lb1.AutoSize = true;
                lb1.Name = "";
                lb1.Click += new EventHandler(ButtonClick);
                flowLayoutPanel1.Controls.Add(lb1);
            }
        }