Exemplo n.º 1
0
        /// <summary>
        /// Method called by FormTreeView.Load method to avoid issues while in design mode
        /// </summary>
        public void InitializeTree()
        {
            if (this.DesignMode)
            {
                return;
            }
            // disable any redrawing of the tree view.
            BeginUpdate();

            _log.Info("Loading root node");
            // load
            NodeTag[] tags = NodeTag.GetRoot();

            foreach (NodeTag tag in tags)
            {
                TreeNode tnRoot = new TreeNode(tag.Name);
                tnRoot.ImageIndex         = 15;
                tnRoot.SelectedImageIndex = 15;

                tnRoot.Tag = tag;
                tnRoot.Nodes.Add("_DUMMY_");
                this.Nodes.Add(tnRoot);
                tnRoot.Collapse();
            }

            // enable any redrawing of the tree view.
            EndUpdate();
        }
Exemplo n.º 2
0
        /// <summary>
        /// PopulateChildren : fills tree using
        /// </summary>
        /// <param name="parent">Tree node to be populated</param>
        private void PopulateChildren(TreeNode parent)
        {
            // remove _DUMMY_ tree node
            parent.Nodes.Clear();
            // populate with actual nodes
            NodeTag tag = parent.Tag as NodeTag;

            NodeTag[] childTags = tag.Chidrens;
            foreach (NodeTag t in childTags)
            {
                TreeNode tn = new TreeNode(t.Name);
                tn.ImageIndex         = TagToIndex(t);
                tn.SelectedImageIndex = TagToIndex(t);
                tn.Tag = t;
                parent.Nodes.Add(tn);
                if (t.HasChildren)
                {
                    tn.Nodes.Add(new TreeNode("_DUMMY_"));
                    tn.Collapse();
                }
                else
                {
                    tn.Expand();
                }
            }
        }
Exemplo n.º 3
0
 private NodeTag(NodeTag parent, Guid dbNodeId
                 , string dbNodeName, string dbNodeDescription
                 , int dbType, bool hasChild
                 , Guid thumGuid, string thumbExt)
 {
     _dbParent          = parent;
     _dbNodeId          = dbNodeId;
     _dbNodeName        = dbNodeName;
     _dbNodeDescription = dbNodeDescription;
     _dbType            = (NType)dbType;
     _dbHasChild        = hasChild;
     _dbThumbFile       = new FileTag(thumGuid, thumbExt);
 }
Exemplo n.º 4
0
 public void ShowBranch(NodeTag nodeTag)
 {
     if (_currentNodeTag != nodeTag)
     {
         // save current node tag
         _currentNodeTag = nodeTag;
         // clear existing buttons
         Controls.Clear();
         tooltip.RemoveAll();
         i = x = y = 0;
         // start timer
         if ((null != _currentNodeTag) && _currentNodeTag.HasChildren)
             timer.Start();
     }
 }
Exemplo n.º 5
0
        public void SelectTag(NodeTag tag)
        {
            // find node
            TreeNode tn = FindNode(null, tag);

            if (null != tn)
            {
                tn.Expand();
                // select node
                SelectedNode = tn;
            }
            else
            {
                _log.Error(string.Format("Tag {0} has no treenode", tag.ToString()));
            }
        }
Exemplo n.º 6
0
 public void ShowBranch(NodeTag nodeTag)
 {
     if (_currentNodeTag != nodeTag)
     {
         // save current node tag
         _currentNodeTag = nodeTag;
         // clear existing buttons
         Controls.Clear();
         tooltip.RemoveAll();
         i = x = y = 0;
         // start timer
         if ((null != _currentNodeTag) && _currentNodeTag.HasChildren)
         {
             timer.Start();
         }
     }
 }
Exemplo n.º 7
0
 void DocumentTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     try
     {
         NodeTag currentTag = e.Node.Tag as NodeTag;
         if (null == currentTag)
         {
         }
         else if (null != SelectionChanged)
         {
             SelectionChanged(this, e, currentTag);
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
Exemplo n.º 8
0
        public void onToolStripEditComponentCode(object sender, EventArgs e)
        {
            try
            {
                NodeTag tag = treeView.SelectedNode.Tag as NodeTag;
                if (null == tag)
                {
                    return;              // no valid tag
                }
                if (null == tag.Document)
                {
                    return;                       // not a document
                }
                string fileExt = tag.Document.File.Extension.ToLower();
                if (!string.Equals(fileExt, "dll"))
                {
                    return;                                  // not a component
                }
                string filePath = treeDiM.FileTransfer.FileTransferUtility.DownloadFile(tag.Document.File.Guid, fileExt);

                // get client
                PLMPackServiceClient client = WCFClientSingleton.Instance.Client;

                // output Guid / path
                Guid   outputGuid = Guid.NewGuid();
                string outputPath = treeDiM.FileTransfer.FileTransferUtility.BuildPath(outputGuid, fileExt);
                // form plugin editor
                FormPluginEditor editorForm = new FormPluginEditor();
                editorForm.PluginPath = filePath;
                editorForm.OutputPath = outputPath;
                if (DialogResult.OK == editorForm.ShowDialog())
                {
                    _log.Info("Component successfully modified!");
                    // clear component cache in plugin viewer
                    ComponentLoader.ClearCache();
                    // update pluginviewer
                    pluginViewCtrl.PluginPath = outputPath;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 9
0
        public static NodeTag[] GetRoot()
        {
            PLMPackServiceClient client = WCFClientSingleton.Instance.Client;

            DCTreeNode[] wrRoot = client.GetRootNodes();

            List <NodeTag> nodeTags = new List <NodeTag>();

            foreach (DCTreeNode wrNode in wrRoot)
            {
                NodeTag nt = new NodeTag(null, wrNode.ID,
                                         wrNode.Name, wrNode.Description,
                                         (int)wrNode.NodeType, true, //wrNode.HasChildrens,
                                         Guid.Empty, string.Empty);
                nodeTags.Add(nt);
            }

            return(nodeTags.ToArray());
        }
Exemplo n.º 10
0
 /// <summary>
 /// Handle user click on button and trigger event to other control
 /// </summary>
 private void btn_Click(object sender, EventArgs e)
 {
     try
     {
         Button btn = sender as Button;
         if (null == btn)
         {
             return;
         }
         NodeTag tag = btn.Tag as NodeTag;
         ShowBranch(tag);
         // trigger event
         if (null != SelectionChanged)
         {
             SelectionChanged(this, e, tag);
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
Exemplo n.º 11
0
        public TreeNode FindNode(TreeNode node, NodeTag tag)
        {
            // check with node itself
            if (null != node)
            {
                NodeTag tagNode = node.Tag as NodeTag;
                if (null != tagNode && tagNode.Equals(tag))
                {
                    return(node);
                }
            }
            // check with child nodes
            TreeNodeCollection tnCollection = null == node ? Nodes : node.Nodes;

            foreach (TreeNode tn in tnCollection)
            {
                TreeNode tnResult = FindNode(tn, tag);
                if (null != tnResult)
                {
                    return(tnResult);
                }
            }
            return(null);
        }
Exemplo n.º 12
0
 private int TagToIndex(NodeTag nt)
 {
     switch (nt.Type)
     { 
         case NodeTag.NType.NTBranch:
             return 0;
         case NodeTag.NType.NTDocument:
             {
                 string ext = nt.Document.File.Extension.ToLower();
                 if (string.Equals(ext, "des")) return 3;
                 else if (string.Equals(ext, "dxf")) return 4;
                 else if (string.Equals(ext, "pdf")) return 5;
                 else if (string.Equals(ext, "ai")) return 6;
                 else if (string.Equals(ext, "jpg")
                     || string.Equals(ext, "bmp")
                     || string.Equals(ext, "jpg")
                     || string.Equals(ext, "jpeg")
                     || string.Equals(ext, "png")) return 7;
                 else if (string.Equals(ext, "doc")) return 8;
                 else if (string.Equals(ext, "xls")) return 9;
                 else if (string.Equals(ext, "ppt")) return 10;
                 else if (string.Equals(ext, "odt")) return 11;
                 else if (string.Equals(ext, "ods")) return 12;
                 else if (string.Equals(ext, "ard")) return 13;
                 else if (string.Equals(ext, "des3")) return 14;
                 else
                     return 0;
             }
         case NodeTag.NType.NTComponent:
             return 2;
     }
     return 0;
 }
Exemplo n.º 13
0
        void OnSelectionChanged(object sender, EventArgs e, NodeTag tag)
        {
            try
            {
                // change view name (seen in tab)
                this.Text = tag.Name;

                branchView.Visible      = tag.IsBranch;
                pluginViewCtrl.Visible  = false;
                factoryViewCtrl.Visible = false;
                webBrowser4PDF.Visible  = false;

                if (tag.IsDocument || tag.IsComponent)
                {
                    string fileExt  = tag.Document.File.Extension.ToLower();
                    string filePath = treeDiM.FileTransfer.FileTransferUtility.DownloadFile(tag.Document.File.Guid, fileExt);
                    bool   isPdf    = tag.IsDocument && string.Equals(tag.Document.File.Extension, ".pdf");

                    switch (fileExt)
                    {
                    case "dll":
                        LoadComponent(filePath);
                        break;

                    case "des":
                    case "dxf":
                    case "cf2":
                        LoadDrawing(filePath, fileExt);
                        break;

                    case "pdf":
                        LoadPdf(filePath);
                        break;

                    case "png":
                    case "bmp":
                    case "jpg":
                    case "jpeg":
                        LoadImageFile(filePath);
                        break;

                    case "des3":
                    case "doc":
                    case "xls":
                    case "dwg":
                    case "ai":
                    case "sxw":
                    case "stw":
                    case "sxc":
                    case "stc":
                    case "ard":
                    default:
                        LoadUnknownFileFormat(filePath);
                        break;
                    }
                }

                if (sender != branchView)
                {
                    branchView.ShowBranch(tag);
                }
                if (sender != treeView)
                {
                    treeView.SelectTag(tag);
                }
            }
            catch (treeDiM.FileTransfer.FileTransferException ex)
            {
                _log.Error(ex.Message);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 14
0
 private NodeTag(NodeTag parent, Guid dbNodeId
     , string dbNodeName, string dbNodeDescription
     , int dbType, bool hasChild
     , Guid thumGuid, string thumbExt)
 {
     _dbParent = parent;
     _dbNodeId = dbNodeId;
     _dbNodeName = dbNodeName;
     _dbNodeDescription = dbNodeDescription;
     _dbType = (NType)dbType;
     _dbHasChild = hasChild;
     _dbThumbFile = new FileTag(thumGuid, thumbExt);
 }
Exemplo n.º 15
0
        private int TagToIndex(NodeTag nt)
        {
            switch (nt.Type)
            {
            case NodeTag.NType.NTBranch:
                return(0);

            case NodeTag.NType.NTDocument:
            {
                string ext = nt.Document.File.Extension.ToLower();
                if (string.Equals(ext, "des"))
                {
                    return(3);
                }
                else if (string.Equals(ext, "dxf"))
                {
                    return(4);
                }
                else if (string.Equals(ext, "pdf"))
                {
                    return(5);
                }
                else if (string.Equals(ext, "ai"))
                {
                    return(6);
                }
                else if (string.Equals(ext, "jpg") ||
                         string.Equals(ext, "bmp") ||
                         string.Equals(ext, "jpg") ||
                         string.Equals(ext, "jpeg") ||
                         string.Equals(ext, "png"))
                {
                    return(7);
                }
                else if (string.Equals(ext, "doc"))
                {
                    return(8);
                }
                else if (string.Equals(ext, "xls"))
                {
                    return(9);
                }
                else if (string.Equals(ext, "ppt"))
                {
                    return(10);
                }
                else if (string.Equals(ext, "odt"))
                {
                    return(11);
                }
                else if (string.Equals(ext, "ods"))
                {
                    return(12);
                }
                else if (string.Equals(ext, "ard"))
                {
                    return(13);
                }
                else if (string.Equals(ext, "des3"))
                {
                    return(14);
                }
                else
                {
                    return(0);
                }
            }

            case NodeTag.NType.NTComponent:
                return(2);
            }
            return(0);
        }
Exemplo n.º 16
0
 public TreeNode FindNode(TreeNode node, NodeTag tag)
 {
     // check with node itself
     if (null != node)
     {
         NodeTag tagNode = node.Tag as NodeTag;
         if (null != tagNode && tagNode.Equals(tag))
             return node;
     }
     // check with child nodes
     TreeNodeCollection tnCollection = null == node ? Nodes : node.Nodes;
     foreach (TreeNode tn in tnCollection)
     {
         TreeNode tnResult = FindNode(tn, tag);
         if (null != tnResult)
             return tnResult;
     }
     return null;
 }
Exemplo n.º 17
0
 public void SelectTag(NodeTag tag)
 { 
     // find node
     TreeNode tn = FindNode(null, tag);
     if (null != tn)
     {
         tn.Expand();
         // select node
         SelectedNode = tn;
     }
     else
         _log.Error(string.Format("Tag {0} has no treenode", tag.ToString()));
 }
Exemplo n.º 18
0
        public override bool Equals(object obj)
        {
            NodeTag nt = obj as NodeTag;

            return(ID == nt.ID);
        }
Exemplo n.º 19
0
        public static NodeTag[] GetRoot()
        {
            PLMPackServiceClient client = WCFClientSingleton.Instance.Client;
            DCTreeNode[] wrRoot = client.GetRootNodes();

            List<NodeTag> nodeTags = new List<NodeTag>();
            foreach (DCTreeNode wrNode in wrRoot)
            {
                NodeTag nt = new NodeTag(null, wrNode.ID,
                    wrNode.Name, wrNode.Description,
                    (int)wrNode.NodeType, true, //wrNode.HasChildrens,
                    Guid.Empty, string.Empty);
                nodeTags.Add(nt);
            }

            return nodeTags.ToArray();
        }
Exemplo n.º 20
0
        void OnSelectionChanged(object sender, EventArgs e, NodeTag tag)
        {
            try
            {
                // change view name (seen in tab)
                this.Text = tag.Name;

                branchView.Visible = tag.IsBranch;
                pluginViewCtrl.Visible = false;
                factoryViewCtrl.Visible = false;
                webBrowser4PDF.Visible = false;

                if (tag.IsDocument || tag.IsComponent)
                {
                    string fileExt = tag.Document.File.Extension.ToLower();
                    string filePath = treeDiM.FileTransfer.FileTransferUtility.DownloadFile(tag.Document.File.Guid, fileExt);
                    bool isPdf = tag.IsDocument && string.Equals(tag.Document.File.Extension, ".pdf");

                    switch (fileExt)
                    {
                        case "dll":
                            LoadComponent(filePath);
                            break;
                        case "des":
                        case "dxf":
                        case "cf2":
                            LoadDrawing(filePath, fileExt);
                            break;
                        case "pdf":
                            LoadPdf(filePath);
                            break;
                        case "png":
                        case "bmp":
                        case "jpg":
                        case "jpeg":
                            LoadImageFile(filePath);
                            break;
                        case "des3":
                        case "doc":
                        case "xls":
                        case "dwg":
                        case "ai":
                        case "sxw":
                        case "stw":
                        case "sxc":
                        case "stc":
                        case "ard":
                        default:
                            LoadUnknownFileFormat(filePath);
                            break;
                    }
                }

                if (sender != branchView) branchView.ShowBranch(tag);
                if (sender != treeView) treeView.SelectTag(tag);
            }
            catch (treeDiM.FileTransfer.FileTransferException ex)
            {
                _log.Error(ex.Message); 
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString()); 
            }
        }