Example #1
0
 private void toolStripMenuItemNewBranch(object sender, EventArgs e)
 {
     try
     {
         // show dialog
         FormCreateBranch dlg = new FormCreateBranch();
         if (DialogResult.OK == dlg.ShowDialog())
         {
             Pic.DAL.SQLite.PPDataContext db = new Pic.DAL.SQLite.PPDataContext();
             // get parent node
             Pic.DAL.SQLite.TreeNode parentNode = Pic.DAL.SQLite.TreeNode.GetById(db, _treeNodeId);
             // create new branch
             Pic.DAL.SQLite.TreeNode nodeNew = parentNode.CreateChild(db, dlg.BranchName, dlg.BranchDescription, dlg.BranchImage);
             // redraw branch
             ShowBranch(_treeNodeId);
             // event
             if (null != TreeNodeCreated)
             {
                 TreeNodeCreated(this, new NodeEventArgs(nodeNew.ID, NodeTag.NodeType.NT_TREENODE));
             }
         }
     }
     catch (System.Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
Example #2
0
 private void toolStripMenuItemNewDocument(object sender, EventArgs e)
 {
     try
     {
         // get data context
         Pic.DAL.SQLite.PPDataContext db = new Pic.DAL.SQLite.PPDataContext();
         // get current branch node
         Pic.DAL.SQLite.TreeNode treeNode = Pic.DAL.SQLite.TreeNode.GetById(db, _treeNodeId);
         // force creation of a profile if no profile exist
         Pic.DAL.SQLite.CardboardProfile[] cardboardProfiles = Pic.DAL.SQLite.CardboardProfile.GetAll(db);
         if (cardboardProfiles.Length == 0)
         {
             FormEditProfiles dlgProfile = new FormEditProfiles();
             dlgProfile.ShowDialog();
         }
         cardboardProfiles = Pic.DAL.SQLite.CardboardProfile.GetAll(db);
         if (cardboardProfiles.Length == 0)
         {
             return; // no profile -> exit
         }
         // show document creation dialog
         FormCreateDocument dlg = new FormCreateDocument();
         // initialize dialog
         dlg.TreeNode = new NodeTag(NodeTag.NodeType.NT_TREENODE, _treeNodeId);
         if (DialogResult.OK == dlg.ShowDialog())
         {
             // redraw current branch
             ShowBranch(_treeNodeId);
             // get current document Id
             int documentId = dlg.DocumentID;
             // get TreeNode from documentID
             List <Pic.DAL.SQLite.TreeNode> listTreeNodeNew = Pic.DAL.SQLite.TreeNode.GetByDocumentId(db, dlg.DocumentID);
             if (listTreeNodeNew.Count == 0)
             {
                 _log.Error(string.Format("Failed to retrieve treeNode from document ID : {0}", dlg.DocumentID));
                 return; // -> failed to retrieve node
             }
             if (null != TreeNodeCreated)
             {
                 TreeNodeCreated(this, new NodeEventArgs(listTreeNodeNew[0].ID, NodeTag.NodeType.NT_TREENODE));
             }
         }
     }
     catch (System.Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
Example #3
0
        public void ShowBranch(NodeTag nodeTag)
        {
            // save current branch ID
            CurrentNodeTag = nodeTag;
            // clear existing buttons
            Controls.Clear();
            tooltip.RemoveAll();
            _listTreeNodes = new List <NodeTag>();

            try
            {
                Pic.DAL.SQLite.PPDataContext db     = new Pic.DAL.SQLite.PPDataContext();
                Pic.DAL.SQLite.TreeNode      branch = Pic.DAL.SQLite.TreeNode.GetById(db, nodeTag.TreeNode);

                foreach (Pic.DAL.SQLite.TreeNode tn in branch.Childrens(db))
                {
                    // annotate image
                    Image thumbnailImage = tn.Thumbnail.GetImage();

                    Pic.DAL.SQLite.Thumbnail.Annotate(thumbnailImage, tn.Name);
                    // insert node
                    _listTreeNodes.Add(
                        new NodeTag(
                            tn.IsDocument ? NodeTag.NType.NTDocument : NodeTag.NType.NTBranch
                            , tn.ID
                            , tn.Name
                            , tn.Description
                            , thumbnailImage)
                        );
                }
            }
            catch (Exception /*ex*/)
            {
            }
            i = x = y = 0;
            timer.Start();
        }
Example #4
0
 private void OnTSMenuItemNewBranch(object sender, EventArgs e)
 {
     try
     {
         // show dialog
         FormCreateBranch dlg = new FormCreateBranch();
         if (DialogResult.OK == dlg.ShowDialog())
         {
             Pic.DAL.SQLite.PPDataContext db = new Pic.DAL.SQLite.PPDataContext();
             // get parent node
             Pic.DAL.SQLite.TreeNode parentNode = Pic.DAL.SQLite.TreeNode.GetById(db, CurrentNodeTag.TreeNode);
             // create new branch
             Pic.DAL.SQLite.TreeNode nodeNew = parentNode.CreateChild(db, dlg.BranchName, dlg.BranchDescription, dlg.BranchImage);
             // redraw branch
             ShowBranch(CurrentNodeTag);
             // event
             TreeNodeCreated?.Invoke(this, new NodeEventArgs(nodeNew.ID, NodeTag.NType.NTBranch));
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }