Exemple #1
0
        public void ChangeMenu(FolderViewModel currentFolderViewModel, IList iconButtons, IList menuItems)
        {
            switch (currentFolderViewModel.CurrentDisplayMode)
            {
            case DriveDisplayMode.FolderLink:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.Download, UiResources.Import, UiResources.Cancel },
                    new[] { UiResources.Refresh, UiResources.Sort, UiResources.MultiSelect });
                break;
            }

            case DriveDisplayMode.MultiSelect:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.Download, UiResources.Import },
                    new[] { UiResources.SelectAll, UiResources.DeselectAll, UiResources.Cancel });
                break;
            }

            default:
                throw new ArgumentOutOfRangeException("currentFolderViewModel");
            }
        }
Exemple #2
0
        public void ChangeMenu(FolderViewModel currentFolderViewModel, IList iconButtons, IList menuItems)
        {
            switch (currentFolderViewModel.CurrentDisplayMode)
            {
            case DriveDisplayMode.CloudDrive:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.Upload, UiResources.AddFolder, UiResources.UI_OpenLink },
                    new [] { UiResources.Refresh, UiResources.Sort, UiResources.MultiSelect });
                break;
            }

            case DriveDisplayMode.CopyOrMoveItem:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.AddFolder, UiResources.Copy, UiResources.Move, UiResources.Cancel },
                    null);
                break;
            }

            case DriveDisplayMode.MultiSelect:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.Download, String.Format("{0}/{1}", UiResources.Copy, UiResources.Move), UiResources.Remove },
                    new[] { UiResources.SelectAll, UiResources.DeselectAll, UiResources.Cancel });
                break;
            }

            case DriveDisplayMode.RubbishBin:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.ClearRubbishBin },
                    new[] { UiResources.Refresh, UiResources.Sort, UiResources.MultiSelect });
                break;
            }

            case DriveDisplayMode.ImportItem:
            {
                this.TranslateAppBarItems(
                    iconButtons.Cast <ApplicationBarIconButton>().ToList(),
                    menuItems.Cast <ApplicationBarMenuItem>().ToList(),
                    new[] { UiResources.AddFolder, UiResources.Import, UiResources.Cancel },
                    null);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException("currentFolderViewModel");
            }
        }
Exemple #3
0
        public void Initialize(FolderViewModel parentFolder)
        {
            ParentFolder = parentFolder;

            PreviewItems = new ObservableCollection <ImageNodeViewModel>(
                ParentFolder.ItemCollection.Items.Where(n => n is ImageNodeViewModel).Cast <ImageNodeViewModel>());

            ParentFolder.ItemCollection.Items.CollectionChanged += (sender, args) =>
            {
                if (args.Action != NotifyCollectionChangedAction.Remove)
                {
                    return;
                }

                var removedNode = (NodeViewModel)args.OldItems[0];

                PreviewItems.Remove(PreviewItems.FirstOrDefault(n =>
                                                                n.OriginalMNode.getBase64Handle() == removedNode.OriginalMNode.getBase64Handle()));
            };

            SelectedPreview = ParentFolder.FocusedNode as ImageNodeViewModel;
        }
        public PreviewImageViewModel(MegaSDK megaSdk, AppInformation appInformation, FolderViewModel folderViewModel)
            : base(megaSdk, appInformation)
        {
            _foderViewModel = folderViewModel;

            if (_foderViewModel == null)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.GetPreviewFailed_Title,
                        AppMessages.GetPreviewFailed,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                });

                return;
            }

            PreviewItems = new ObservableCollection <ImageNodeViewModel>(
                _foderViewModel.ChildNodes.Where(n => n is ImageNodeViewModel).Cast <ImageNodeViewModel>());

            _foderViewModel.ChildNodes.CollectionChanged += (sender, args) =>
            {
                if (args.Action != NotifyCollectionChangedAction.Remove)
                {
                    return;
                }

                var removedNode = (NodeViewModel)args.OldItems[0];

                PreviewItems.Remove(PreviewItems.FirstOrDefault(n => n.OriginalMNode.getBase64Handle() ==
                                                                removedNode.OriginalMNode.getBase64Handle()));
            };

            SelectedPreview = (ImageNodeViewModel)_foderViewModel.FocusedNode;
        }
Exemple #5
0
        public void Create(FolderViewModel folder)
        {
            this.Items.Clear();

            // Top root nodes have no breadcrumbs
            if (folder.FolderRootNode == null ||
                folder.FolderRootNode.Type == MNodeType.TYPE_ROOT ||
                folder.FolderRootNode.Type == MNodeType.TYPE_RUBBISH)
            {
                return;
            }

            this.Items.Add(folder.FolderRootNode);

            MNode parentNode = this.MegaSdk.getParentNode(folder.FolderRootNode.OriginalMNode);

            while (parentNode != null &&
                   parentNode.getType() != MNodeType.TYPE_ROOT &&
                   parentNode.getType() != MNodeType.TYPE_RUBBISH)
            {
                this.Items.Insert(0, NodeService.CreateNew(this.MegaSdk, App.AppInformation, parentNode, folder));
                parentNode = this.MegaSdk.getParentNode(parentNode);
            }
        }
Exemple #6
0
        protected NodeViewModel(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, FolderViewModel parent,
                                ObservableCollection <IBaseNode> parentCollection = null, ObservableCollection <IBaseNode> childCollection = null)
            : base(megaSdk)
        {
            this.AccessLevel = new AccessLevelViewModel();

            this.Parent = parent;
            this.ParentContainerType = parent != null ? Parent.Type : ContainerType.FileLink;
            this.ParentCollection    = parentCollection;
            this.ChildCollection     = childCollection;

            this.CopyOrMoveCommand           = new RelayCommand(CopyOrMove);
            this.DownloadCommand             = new RelayCommand(Download);
            this.GetLinkCommand              = new RelayCommandAsync <bool, bool>(GetLinkAsync);
            this.ImportCommand               = new RelayCommand(Import);
            this.PreviewCommand              = new RelayCommand(Preview);
            this.RemoveCommand               = new RelayCommand(Remove);
            this.RemoveLinkCommand           = new RelayCommandAsync <bool>(RemoveLinkAsync);
            this.RenameCommand               = new RelayCommand(Rename);
            this.RestoreCommand              = new RelayCommand(Restore);
            this.OpenInformationPanelCommand = new RelayCommand(OpenInformationPanel);

            Update(megaNode);
            SetDefaultValues();

            Transfer        = new TransferObjectModel(megaSdk, this, MTransferType.TYPE_DOWNLOAD, LocalDownloadPath);
            OfflineTransfer = new TransferObjectModel(megaSdk, this, MTransferType.TYPE_DOWNLOAD, OfflinePath);
        }
Exemple #7
0
 public ImageNodeViewModel(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, FolderViewModel parent,
                           ObservableCollection <IBaseNode> parentCollection = null, ObservableCollection <IBaseNode> childCollection = null)
     : base(megaSdk, appInformation, megaNode, parent, parentCollection, childCollection)
 {
     // Default false for preview slide
     InViewingRange = false;
 }
        public FolderNodeViewModel(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, FolderViewModel parent,
                                   ObservableCollection <IBaseNode> parentCollection = null, ObservableCollection <IBaseNode> childCollection = null)
            : base(megaSdk, appInformation, megaNode, parent, parentCollection, childCollection)
        {
            this.ShareCommand = new RelayCommand(Share);
            this.RemoveSharedAccessCommand = new RelayCommand(RemoveSharedAccess);

            this.Update(megaNode);
        }
Exemple #9
0
 public FileNodeViewModel(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, FolderViewModel parent,
                          ObservableCollection <IBaseNode> parentCollection = null, ObservableCollection <IBaseNode> childCollection = null)
     : base(megaSdk, appInformation, megaNode, parent, parentCollection, childCollection)
 {
     this.DefaultImagePathData = ImageService.GetDefaultFileTypePathData(Name);
 }