Ejemplo n.º 1
0
        /// <summary>
        /// update tab "Sync Element Info" in Form
        /// </summary>
        private void UpdateSyncElementInfo()
        {
            SyncElementTreeViewNode node = (SyncElementTreeViewNode)treeView1.SelectedNode;

            if (node == null)
            {
                return;
            }
            MyElementInfo ei = node.ElementInfo;

            label_sei_type.Text = ei.GetType() == typeof(MyFileInfo) ? "File" : "Dir";
            label_sei_name.Text = ei.Name;

            if (ei.SyncElementInfo != null)
            {
                label_sei_path1.Text = ei.SyncElementInfo.AbsolutePath1;
                label_sei_path2.Text = ei.SyncElementInfo.AbsolutePath2;

                SyncElementExecutionInfo seei = ei.SyncElementInfo.SyncExecutionInfo;
                if (seei != null)
                {
                    label_sei_direction.Text = seei.Direction.ToString();
                    label_sei_remove.Text    = seei.Remove ? "Yes" : "No";

                    label_sei_startTime.Text = seei.SyncStart != null?seei.SyncStart.Value.ToString(@"hh\:mm\:ss") : "";

                    label_sei_endTime.Text = seei.SyncEnd != null?seei.SyncEnd.Value.ToString(@"hh\:mm\:ss") : "";

                    label_sei_duration.Text = $"{seei.SyncDuration.TotalSeconds}s";
                }
                else
                {
                    label_sei_direction.Text = "";
                    label_sei_remove.Text    = "";
                    label_sei_startTime.Text = "";
                    label_sei_endTime.Text   = "";
                    label_sei_duration.Text  = "";
                }

                label_sei_syncStatus.Text = Enum.GetName(typeof(SyncElementStatus), ei.SyncElementInfo.SyncStatus);

                if (ei.SyncElementInfo.IsConflicted)
                {
                    textBox_sei_info.Text = $"{Enum.GetName(typeof(ConflictType), ei.SyncElementInfo.ConflictInfo.Type)}, {ei.SyncElementInfo.ConflictInfo.Message}";
                }
                else
                {
                    textBox_sei_info.Text = "";
                }
            }
            else
            {
                label_sei_path1.Text      = "";
                label_sei_path2.Text      = "";
                label_sei_syncStatus.Text = "";
            }
        }
Ejemplo n.º 2
0
        private TreeNode getTreeNode(MyElementInfo ei)
        {
            TreeNodeCollection tnc = treeView1.Nodes;
            TreeNode           treeNode;

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

                tnc = treeNode.Nodes;
            }

            return(tnc[ei.Name]);
        }
Ejemplo n.º 3
0
        /// <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();
            }
        }