Ejemplo n.º 1
0
        private void UpdateTV(KfsStatusPath path, KTreeNode node)
        {
            KTreeNode self = new KTreeNode(path, m_lvImageListMgr, SrcApp.Helper);
            self.Name = path.Path;

            node.Nodes.Add(self);

            foreach (KfsStatusPath p in path.ChildTree.Values)
            {
                if (p.Status == PathStatus.Directory)
                    UpdateTV(p, self);
            }

            KfsLocalDirectory localDir = SrcApp.Share.LocalView.GetObjectByPath(path.Path) as KfsLocalDirectory;
            KfsServerDirectory serverDir = SrcApp.Share.ServerView.GetObjectByPath(path.Path) as KfsServerDirectory;
            if (localDir != null && localDir.ExpandedFlag ||
                serverDir != null && serverDir.ExpandedFlag)
            {
                self.Expand();
            }
        }
Ejemplo n.º 2
0
        private void tvFileTree_DragEnter(object sender, DragEventArgs e)
        {
            string s = "tvFileTree_DragEnter";
            try
            {
                Logging.Log(1, s);

                // Enter gate only if the drag and drop operation
                // comes from outside our program.
                if (!m_isDraggingItem)
                {
                    m_canDrop = true;

                    UInt64 c = m_uiUpdateCounter;
                    Gate.GateEntry(s);
                    if (c != m_uiUpdateCounter)
                    {
                        s += " refused, share has been modified.";
                        m_canDrop = false;
                    }
                }

                m_updateLvOnTvSelectionChange = false;

                m_dragDropTvOriginalSelectedNode = (KTreeNode)tvFileTree.SelectedNode;

                Debug.Assert(!m_isDragDropInsideControls);
                m_isDragDropInsideControls = true;

                SetTvDragDropEffect(e);
            }
            catch (Exception ex)
            {
                Base.HandleException(ex);
            }
        }
Ejemplo n.º 3
0
        private void UpdateTV()
        {
            Logging.Log("UpdateTV");
            tvFileTree.Nodes.Clear();
            bool updateTvFlag = false;
            bool updateLvFlag = true;

            m_ignoreExpandFlag = true;

            if (CanWorkOffline())
            {
                // The status view is not up to date, request an update.
                if (SrcApp.Share.StatusView.Root == null)
                    SrcApp.Share.RequestStatusViewUpdate("UpdateTV()");

                // We need to update the tree view.
                else
                    updateTvFlag = true;
            }

            if (updateTvFlag)
            {
                KfsStatusPath rootStatusPath = SrcApp.Share.StatusView.Root;
                UpdateBackgroundImage();
                // Add the TV root.
                KTreeNode root = new KTreeNode(rootStatusPath, m_lvImageListMgr, SrcApp.Helper);

                root.Name = "";

                tvFileTree.Nodes.Add(root);

                foreach (KfsStatusPath p in rootStatusPath.ChildTree.Values)
                {
                    if (p.Status == PathStatus.Directory) UpdateTV(p, root);
                }

                root.Expand();

                if (Settings.SelectedDir == "")
                {
                    tvFileTree.SelectedNode = tvFileTree.Nodes[0];
                }
                else
                {
                    TreeNode[] nodes = tvFileTree.Nodes.Find(Settings.SelectedDir, true);

                    if (nodes.Length == 1)
                        tvFileTree.SelectedNode = nodes[0];
                    else
                    {
                        // The initially selected folder was moved or deleted.
                        // Select the root. This causes an implicit update.
                        tvFileTree.SelectedNode = root;
                        updateLvFlag = false;
                    }
                }

                if (Settings.IsSelectedDirExpanded)
                    tvFileTree.SelectedNode.Expand();
            }

            m_ignoreExpandFlag = false;

            if (updateLvFlag) UpdateLV();
        }
Ejemplo n.º 4
0
 private void tvExpandCollapseHelper(KTreeNode node, bool expandFlag)
 {
     if (!HasShare() || m_ignoreExpandFlag) return;
     String path = node.KFullPath;
     KfsLocalDirectory localDir = SrcApp.Share.LocalView.GetObjectByPath(path) as KfsLocalDirectory;
     KfsServerDirectory serverDir = SrcApp.Share.ServerView.GetObjectByPath(path) as KfsServerDirectory;
     if (localDir != null) localDir.ExpandedFlag = expandFlag;
     if (serverDir != null) serverDir.ExpandedFlag = expandFlag;
     SrcApp.SetDirty("folder expansion changed");
 }
Ejemplo n.º 5
0
        private void SetTvDragDropEffect(DragEventArgs e)
        {
            // FIXME: allow MSO drop in the treeview.
            bool isKfsItem = IsDragDropKfsItem(e);
            bool isFileDrop = IsDragDropFileDrop(e);
            bool isASubDir = false;

            // Allow only KfsItem data format to be dropped in here.
            if (!(isKfsItem || isFileDrop) || !m_canDrop || !m_canDrag)
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            string srcFullPath = GetDragDropSourceDir(e);
            string dstRelativePath = GetTvDragDropDestDir(e);

            Point pt = tvFileTree.PointToClient(new Point(e.X, e.Y));
            KTreeNode nodeUnder = (KTreeNode)tvFileTree.GetNodeAt(pt);
            // See if we must select another temp item.
            if (nodeUnder != null)
            {
                // If the mouse is over a directory, select it.
                tvFileTree.SelectedNode = nodeUnder;
                m_dragDropTvTempDest = nodeUnder;
            }
            if (isKfsItem)
            {
                List<KListViewItem> dirs = DirectoriesInSelection((KListViewItem[])e.Data.GetData("KfsItem"));
                foreach (KListViewItem item in dirs)
                {
                    if (dstRelativePath.StartsWith(item.Path))
                    {
                        isASubDir = true;
                        break;
                    }
                }

                // Validate if the destination is valid.
                if (nodeUnder == null || dstRelativePath == srcFullPath || isASubDir || IsPathInDragSelection(dstRelativePath, e))
                    e.Effect = DragDropEffects.None;
                else
                    e.Effect = DragDropEffects.Copy;
            }
            else if (isFileDrop)
            {
                foreach (string p in (string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop))
                {
                    if (Directory.Exists(p) &&
                    KfsPath.GetWindowsFilePath(SrcApp.Share.MakeAbsolute(dstRelativePath), true).StartsWith(p))
                    {
                        isASubDir = true;
                        break;
                    }
                }
                if (srcFullPath == KfsPath.GetWindowsFilePath(SrcApp.Share.MakeAbsolute(dstRelativePath), false) ||
                    (IsPathInDragSelection(dstRelativePath, e)) || isASubDir)
                    e.Effect = DragDropEffects.None;
                else
                    e.Effect = DragDropEffects.Copy;
            }
        }
Ejemplo n.º 6
0
Archivo: KfsGate.cs Proyecto: tmbx/kwm
        /// <summary>
        /// Return true if the Treenode can be synchronized.
        /// </summary>
        public bool CanSynchronize(KTreeNode node)
        {
            // Assume a directory present server-side
            // can be synchronized. If nothing inside of
            // it can be synchronized, so be it.

            return node.OnServer && Share.AllowedOp != AllowedOpStatus.None;
        }
Ejemplo n.º 7
0
Archivo: KfsGate.cs Proyecto: tmbx/kwm
 /// <summary>
 /// Return true if the KTreeNode specified can be deleted or moved.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public bool CanDeleteOrMove(KTreeNode node)
 {
     return (node.Name != "" &&
             CanDeleteOrMoveInternal(Share.StatusView.GetPathArray(node.KFullPath, false)));
 }
Ejemplo n.º 8
0
Archivo: KfsGate.cs Proyecto: tmbx/kwm
 /// <summary>
 /// Return true if the Treenode specified can
 /// be added to the share.
 /// </summary>
 public bool CanAdd(KTreeNode node)
 {
     return !node.OnServer && Share.AllowedOp == AllowedOpStatus.All;
 }