private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            //toggle tree node on click
            if (e.Node.GetType() == typeof(SyncFileTreeViewNode))
            {
                return;
            }

            SyncDirTreeViewNode dirNode = (SyncDirTreeViewNode)e.Node;

            dirNode.Toggle();
        }
        /// <summary>
        /// update or create treenode if it is visible
        /// </summary>
        /// <param name="ei">element info</param>
        /// <param name="invoke">if the operations on treeview should be invoked</param>
        private void UpdateTreeNodeIfVisible(MyElementInfo ei, bool invoke)
        {
            TreeNodeCollection  tnc      = treeView1.Nodes;
            SyncDirTreeViewNode treeNode = null;

            for (int i = 1; i < ei.TreePath.Count; i++)
            {
                treeNode = (SyncDirTreeViewNode)tnc[ei.TreePath[i].Info.Name];
                if (treeNode == null)
                {
                    return;
                }

                //check if treenode is visible
                bool   expanded = false;
                Action ae       = new Action(() => expanded = treeNode.IsExpanded);
                if (invoke)
                {
                    treeView1.Invoke(ae);
                }
                else
                {
                    ae();
                }
                if (!expanded)
                {
                    return;
                }

                //update tree node (according to the status of ei)
                treeNode.ChildStatus = ei.SyncElementInfo.SyncStatus;
                Action a = new Action(treeNode.Update);
                if (invoke)
                {
                    treeView1.Invoke(a);
                }
                else
                {
                    a();
                }

                tnc = treeNode.Nodes;
            }

            if (ei.ElementTreeViewNode == null)
            {
                //create treenode
                if (ei.GetType() == typeof(MyFileInfo))
                {
                    ei.ElementTreeViewNode = new SyncFileTreeViewNode((MyFileInfo)ei);
                }
                else
                {
                    ei.ElementTreeViewNode = new SyncDirTreeViewNode((MyDirInfo)ei);
                }

                Action aa = new Action(() => tnc.Add(ei.ElementTreeViewNode));
                if (invoke)
                {
                    treeView1.Invoke(aa);
                }
                else
                {
                    aa();
                }
            }

            //update result tree node
            Action au = new Action(ei.ElementTreeViewNode.Update);

            if (invoke)
            {
                treeView1.Invoke(au);
            }
            else
            {
                au();
            }
        }