Esempio n. 1
0
        static void GetItems(MegaApiClient client, INode node, ExplorerNode Enode)
        {
            foreach (INode child in client.GetNodes(node))
            {
                ExplorerNode c = new ExplorerNode();
                c.Info.ID         = child.Id;
                c.Info.Name       = child.Name;
                c.Info.DateMod    = child.LastModificationDate;
                c.Info.MegaCrypto = new MegaKeyCrypto(child as INodeCrypto);
                switch (child.Type)
                {
                case NodeType.File:
                    c.Info.Size = child.Size;
                    Enode.AddChild(c);
                    break;

                case NodeType.Directory:
                    c.Info.Size = -1;
                    Enode.AddChild(c);
                    break;

                default: break;
                }
            }
        }
Esempio n. 2
0
        public static ExplorerNode GetListFileFolder(ExplorerNode node)
        {
            string path = node.GetFullPathString();

            node.Child.Clear();
            foreach (string item in Directory.GetDirectories(path))
            {
                DirectoryInfo info = new DirectoryInfo(item);
                if (CheckAttribute(info.Attributes, FileAttributes.System) | CheckAttribute(info.Attributes, FileAttributes.Offline))
                {
                    continue;
                }
                ExplorerNode f = new ExplorerNode();
                f.Info.Name    = info.Name;
                f.Info.Size    = -1;
                f.Info.DateMod = info.LastWriteTime;
                node.AddChild(f);
            }
            foreach (string item in Directory.GetFiles(path))
            {
                FileInfo info = new FileInfo(item);
                if (CheckAttribute(info.Attributes, FileAttributes.System) | CheckAttribute(info.Attributes, FileAttributes.Offline))
                {
                    continue;
                }
                ExplorerNode f = new ExplorerNode();
                f.Info.Name    = info.Name;
                f.Info.Size    = info.Length;
                f.Info.DateMod = info.LastWriteTime;
                node.AddChild(f);
            }
            return(node);
        }
Esempio n. 3
0
        void uploadfile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect      = true;
            ofd.Filter           = PCPath.FilterAllFiles;
            ofd.InitialDirectory = PCPath.Mycomputer;
            DialogResult result = ofd.ShowDialog();

            if (result != DialogResult.OK | result != DialogResult.Yes)
            {
                return;
            }
            List <ExplorerNode> items = new List <ExplorerNode>();
            ExplorerNode        root  = ExplorerNode.GetNodeFromDiskPath(System.IO.Path.GetDirectoryName(ofd.FileNames[0]));

            foreach (string s in ofd.SafeFileNames)
            {
                ExplorerNode n = new ExplorerNode();
                n.Info.Name = s;
                root.AddChild(n);
                FileInfo info = new FileInfo(n.GetFullPathString());
                n.Info.Size    = info.Length;
                n.Info.DateMod = info.LastWriteTime;
                items.Add(n);
            }
            Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.TransferItems(items, root, managerexplorernodes.NodeWorking(), false);
        }
Esempio n. 4
0
        public bool MoveItem(ExplorerNode node, ExplorerNode newparent, string newname = null, bool Copy = false)
        {
            CheckThread(false);
            if (node.GetRoot == newparent.GetRoot)
            {
                bool flag = false;
                switch (node.GetRoot.NodeType.Type)
                {
                case CloudType.Dropbox: flag = Dropbox.Move(node, newparent, newname); break;

                case CloudType.GoogleDrive: GoogleDrive.MoveItem(node, newparent, newname).parents.ForEach(s => { if (!flag && s.id == newparent.Info.ID)
                                                                                                                  {
                                                                                                                      flag = true;
                                                                                                                  }
                                                                                                           }); break;

                case CloudType.LocalDisk: flag = LocalDisk.Move(node, newparent, newname); break;

                case CloudType.Mega:
                default: throw new Exception("CloudType not support (" + node.GetRoot.NodeType.Type.ToString() + ").");
                }
                if (flag)
                {
                    node.Parent.RemoveChild(node);
                    newparent.AddChild(node);
                }
                return(flag);
            }
            else
            {
                throw new Exception("Root not match.");
            }
        }
Esempio n. 5
0
        private void uploadFileToHereToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect      = true;
            ofd.Filter           = PCPath.FilterAllFiles;
            ofd.InitialDirectory = PCPath.Mycomputer;

            DialogResult result = ofd.ShowDialog();

            if (result == DialogResult.OK | result == DialogResult.Yes)
            {
                List <ExplorerNode> list_item_from = new List <ExplorerNode>();

                string       root     = Path.GetDirectoryName(ofd.FileNames[0]);
                ExplorerNode rootnode = ExplorerNode.GetNodeFromDiskPath(root);
                foreach (string a in ofd.SafeFileNames)
                {
                    FileInfo     info = new FileInfo(root + "\\" + a);
                    ExplorerNode n    = new ExplorerNode();
                    n.Info.Name = a;
                    n.Info.Size = info.Length;
                    rootnode.AddChild(n);
                    list_item_from.Add(n);
                }
                Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.TransferItems(list_item_from, rootnode,
                                                                                       ((UC_LVitem)tabControl1.SelectedTab.Controls[0]).managerexplorernodes.NodeWorking(), false);
            }
        }
Esempio n. 6
0
        void CreateFolder(object obj)
        {
            ExplorerNode n = new ExplorerNode();

            n.Info.Name = (string)obj;
            parent.AddChild(n);
            Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.CreateFolder(n);
            Dispatcher.Invoke(new Action(() => this.Close()));
        }
Esempio n. 7
0
        void RecieveCode(IAsyncResult rs)
        {
            HttpListenerContext ls = listener.EndGetContext(rs);

            HttpListenerRequest request = ls.Request;
            string cloudname            = request.QueryString.Get("cloudname");
            string id    = request.QueryString.Get("id");
            string path  = request.QueryString.Get("path");
            string email = request.QueryString.Get("email");
            string range = request.Headers.Get("Range");

            CloudType    type = CloudType.Folder;
            Stream       stream;
            long         start_range = -1;
            long         end_range   = -1;
            ExplorerNode filenode    = null;

            if (range != null)
            {
                string[] range_arr = range.Split('-');
                long.TryParse(range_arr[0], out start_range);
                long.TryParse(range_arr[1], out end_range);
            }

            if (cloudname != null && id != null && Enum.TryParse <CloudType>(cloudname, out type) && type != CloudType.LocalDisk && type != CloudType.Folder)
            {
                if (email == null)
                {
                    email = AppSetting.settings.GetDefaultCloud(type);
                }
                ExplorerNode rootnode = AppSetting.settings.GetCloudRootNode(email, type);
                filenode = new ExplorerNode(new NodeInfo()
                {
                    ID = id
                });
                rootnode.AddChild(filenode);
            }
            else if (path != null && File.Exists(path))
            {
                type     = CloudType.LocalDisk;
                filenode = ExplorerNode.GetNodeFromDiskPath(path);
            }
            else//return 404 not found
            {
            }

            stream = AppSetting.ManageCloud.GetFileStream(filenode, start_range, end_range, false);//mega need cal chunk and size file

            HttpListenerResponse response = ls.Response;
        }