コード例 #1
0
        public void Update(MNode megaNode, ContainerType parentContainerType)
        {
            OriginalMNode            = megaNode;
            this.Handle              = megaNode.getHandle();
            this.Base64Handle        = megaNode.getBase64Handle();
            this.Type                = megaNode.getType();
            this.ParentContainerType = parentContainerType;
            this.Name                = megaNode.getName();
            this.Size                = MegaSdk.getSize(megaNode);
            this.SizeText            = this.Size.ToStringAndSuffix(2);
            this.IsExported          = megaNode.isExported();
            this.CreationTime        = ConvertDateToString(megaNode.getCreationTime()).ToString("dd MMM yyyy");

            if (this.Type == MNodeType.TYPE_FILE)
            {
                this.ModificationTime = ConvertDateToString(megaNode.getModificationTime()).ToString("dd MMM yyyy");
            }
            else
            {
                this.ModificationTime = this.CreationTime;
            }

            if (!SdkService.MegaSdk.isInShare(megaNode) && this.ParentContainerType != ContainerType.PublicLink &&
                this.ParentContainerType != ContainerType.InShares && this.ParentContainerType != ContainerType.ContactInShares &&
                this.ParentContainerType != ContainerType.FolderLink)
            {
                CheckAndUpdateSFO(megaNode);
            }
        }
コード例 #2
0
ファイル: NodeViewModel.cs プロジェクト: chsergey/sdk
        public NodeViewModel(MegaSDK megaSdk, MNode baseNode)
        {
            this._megaSdk = megaSdk;
            this._baseNode = baseNode;
            this.Name = baseNode.getName();
            this.Size = baseNode.getSize();
            this.CreationTime = ConvertDateToString(_baseNode.getCreationTime()).ToString("dd MMM yyyy");
            this.ModificationTime = ConvertDateToString(_baseNode.getModificationTime()).ToString("dd MMM yyyy");
            this.SizeAndSuffix = Size.ToStringAndSuffix();
            this.Type = baseNode.getType();
            this.NumberOfFiles = this.Type != MNodeType.TYPE_FOLDER ? null : String.Format("{0} {1}", this._megaSdk.getNumChildren(this._baseNode), UiResources.Files);

            if (this.Type == MNodeType.TYPE_FOLDER || this.Type == MNodeType.TYPE_FILE)                
                this.ThumbnailImageUri = new Uri((String)new FileTypeToImageConverter().Convert(this, null, null, null), UriKind.Relative);
        }
コード例 #3
0
        public NodeViewModel(MegaSDK megaSdk, MNode baseNode)
        {
            this._megaSdk         = megaSdk;
            this._baseNode        = baseNode;
            this.Name             = baseNode.getName();
            this.Size             = baseNode.getSize();
            this.CreationTime     = ConvertDateToString(_baseNode.getCreationTime()).ToString("dd MMM yyyy");
            this.ModificationTime = ConvertDateToString(_baseNode.getModificationTime()).ToString("dd MMM yyyy");
            this.SizeAndSuffix    = Size.ToStringAndSuffix();
            this.Type             = baseNode.getType();
            this.NumberOfFiles    = this.Type != MNodeType.TYPE_FOLDER ? null : String.Format("{0} {1}", this._megaSdk.getNumChildren(this._baseNode), UiResources.Files);

            if (this.Type == MNodeType.TYPE_FOLDER || this.Type == MNodeType.TYPE_FILE)
            {
                this.ThumbnailImageUri = new Uri((String) new FileTypeToImageConverter().Convert(this, null, null, null), UriKind.Relative);
            }
        }
コード例 #4
0
ファイル: NodeViewModel.cs プロジェクト: rrsc/uwp
        /// <summary>
        /// Update core data associated with the SDK MNode object
        /// </summary>
        /// <param name="megaNode">Node to update</param>
        /// <param name="externalUpdate">Indicates if is an update external to the app. For example from an `onNodesUpdate`</param>
        public virtual void Update(MNode megaNode, bool externalUpdate = false)
        {
            this.OriginalMNode          = megaNode;
            this.Handle                 = megaNode.getHandle();
            this.RestoreHandle          = megaNode.getRestoreHandle();
            this.RestoreNode            = this.MegaSdk.getNodeByHandle(megaNode.getRestoreHandle());
            this.Base64Handle           = megaNode.getBase64Handle();
            this.Type                   = megaNode.getType();
            this.Name                   = megaNode.getName();
            this.Size                   = this.MegaSdk.getSize(megaNode);
            this.CreationTime           = ConvertDateToString(megaNode.getCreationTime()).DateToString();
            this.TypeText               = this.GetTypeText();
            this.LinkExpirationTime     = megaNode.getExpirationTime();
            this.AccessLevel.AccessType = (MShareType)this.MegaSdk.getAccess(megaNode);

            // Needed to filtering when the change is done inside the app or externally and is received by an `onNodesUpdate`
            if (!externalUpdate || megaNode.hasChanged((int)MNodeChangeType.CHANGE_TYPE_PUBLIC_LINK))
            {
                this.IsExported = megaNode.isExported();
                this.ExportLink = this.IsExported ? megaNode.getPublicLink(true) : null;
            }

            if (this.Type == MNodeType.TYPE_FILE)
            {
                this.ModificationTime = ConvertDateToString(megaNode.getModificationTime()).DateToString();
            }
            else
            {
                this.ModificationTime = this.CreationTime;
            }

            if (ParentContainerType != ContainerType.FileLink && ParentContainerType != ContainerType.FolderLink)
            {
                CheckAndUpdateOffline(megaNode);
            }
        }