Example #1
0
 public ChangeConfigurationMenuCommand(SyncRelationshipViewModel relationship)
 //: base("CHANGE CONFIGURATION", "/SyncPro.UI;component/Resources/Graphics/tools_16.png")
     : base("CHANGE", "/SyncPro.UI;component/Resources/Graphics/tools_16.png")
 {
     this.relationship = relationship;
     this.ToolTip      = "Change the configuration of this sync relationship";
 }
Example #2
0
 public RestoreItemMenuCommand(IFolderNodeViewModel nodeViewModel, SyncRelationshipViewModel relationship)
     : base("RESTORE FILE", "/SyncPro.UI;component/Resources/Graphics/install_16.png")
 {
     this.nodeViewModel = nodeViewModel;
     this.relationship  = relationship;
     this.nodeViewModel.PropertyChanged += this.NodeViewModelPropertyChanged;
 }
Example #3
0
        public SyncEntryViewModel(NavigationNodeViewModel navigationNodeViewModel, SyncEntry syncEntry, SyncRelationshipViewModel syncRelationship)
        {
            this.navigationNodeViewModel = navigationNodeViewModel;
            this.syncRelationship        = syncRelationship;
            this.SyncEntry = syncEntry;

            this.Name              = syncEntry.Name;
            this.LastModified      = syncEntry.EntryLastUpdatedDateTimeUtc;
            this.Size              = Convert.ToUInt64(syncEntry.OriginalSize);
            this.IsDirectory       = syncEntry.Type == SyncEntryType.Directory;
            this.SelectItemCommand = new DelegatedCommand(o => this.SelectItem());

            if (this.IsDirectory)
            {
                var fileInfo = FileInfoCache.GetFolderInfo();
                this.IconImageSource = fileInfo.SmallIcon;
                this.LargeIcon       = fileInfo.LargeIcon;
                this.TypeName        = "Folder";
                return;
            }

            int      lastIndex2 = this.Name.LastIndexOf(".", StringComparison.Ordinal);
            FileInfo fileInfo2  = FileInfoCache.GetFileInfo(this.Name.Substring(lastIndex2).ToLowerInvariant());

            this.IconImageSource = fileInfo2.SmallIcon;
            this.TypeName        = fileInfo2.TypeName;
        }
        public SyncHistoryNodeViewModel(NavigationNodeViewModel parent, SyncRelationshipViewModel relationship)
            : base(parent, relationship)
        {
            this.relationship    = relationship;
            this.Name            = "Synchronization History";
            this.IconImageSource = "/SyncPro.UI;component/Resources/Graphics/history_16.png";

            foreach (SyncJobViewModel syncJobViewModel in relationship.SyncJobHistory)
            {
                this.AddSyncJobHistory(syncJobViewModel);
            }

            relationship.SyncJobHistory.CollectionChanged += (sender, args) =>
            {
                if (args.Action == NotifyCollectionChangedAction.Add)
                {
                    foreach (SyncJobViewModel syncJobViewModel in args.NewItems.OfType <SyncJobViewModel>())
                    {
                        App.DispatcherInvoke(() =>
                        {
                            this.AddSyncJobHistory(syncJobViewModel);
                        });
                    }
                }
            };
        }
        public SearchResultsNodeViewModel(NavigationNodeViewModel parent, SyncRelationshipViewModel relationship)
            : base(parent, relationship)
        {
            this.Name            = "Search Results";
            this.IconImageSource = "/SyncPro.UI;component/Resources/Graphics/search_16.png";

            this.MenuCommands.Add(new ClosePanelMenuCommand(relationship, this));
        }
        public SyncFoldersNodeViewModel(NavigationNodeViewModel parent, SyncRelationshipViewModel syncRelationship, SyncEntry syncEntry)
            : base(parent, null, LazyLoadPlaceholderNodeViewModel.Instance)
        {
            this.syncRelationship = syncRelationship;
            this.syncEntry        = syncEntry;
            this.Name             = syncEntry.Name;
            this.IconImageSource  = "/SyncPro.UI;component/Resources/Graphics/folder_open_16.png";

            this.MenuCommands.Add(new RestoreItemMenuCommand(this, this.syncRelationship));
        }
        public FilesAndFoldersNodeViewModel(NavigationNodeViewModel parent, SyncRelationshipViewModel syncRelationship)
            : base(parent, syncRelationship, LazyLoadPlaceholderNodeViewModel.Instance)
        {
            this.syncRelationship = syncRelationship;
            this.Name             = "Files & Folders";
            this.IconImageSource  = "/SyncPro.UI;component/Resources/Graphics/folder_open_16.png";

            this.MenuCommands.Add(new RestoreItemMenuCommand(this, this.syncRelationship));

            this.syncRelationship.JobFinished += this.SyncRelationshipJobFinished;
        }
Example #8
0
        public static GoogleDriveAdapterViewModel CreateFromRelationship(SyncRelationshipViewModel relationship, bool isSourceAdapter)
        {
            ISyncTargetViewModel        existingAdapter = isSourceAdapter ? relationship.SyncSourceAdapter : relationship.SyncDestinationAdapter;
            GoogleDriveAdapterViewModel model           = existingAdapter as GoogleDriveAdapterViewModel;

            if (model != null)
            {
                return(model);
            }

            return(relationship.CreateAdapterViewModel <GoogleDriveAdapterViewModel>());
        }
        public SyncRelationshipNodeViewModel(NavigationNodeViewModel parent, SyncRelationshipViewModel relationship) 
            : base(parent, relationship)
        {
            Debug.Assert(relationship != null, "relationship != null");

            this.Relationship = relationship;
            this.Name = relationship.Name;
            this.IconImageSource = "/SyncPro.UI;component/Resources/Graphics/sort2_16.png";
            this.IsExpanded = true; // Expanded by default
            this.IsExpanderVisible = false;

            // Add the default child navigation nodes for this relationship
            this.Children.Add(new SyncHistoryNodeViewModel(this, relationship));
            this.Children.Add(new FilesAndFoldersNodeViewModel(this, relationship));

            this.MenuCommands.Add(new ChangeConfigurationMenuCommand(relationship));
            this.MenuCommands.Add(new RemoveRelationshipMenuCommand(relationship));
            this.MenuCommands.Add(new AnalyzeRelationshipMenuCommand(relationship));
            this.MenuCommands.Add(new BeginSyncMenuCommand(relationship));

            if (this.Relationship.SyncSourceAdapter.AdapterBase is WindowsFileSystemAdapter)
            {
                this.MenuCommands.Add(
                    new OpenFolderMenuCommand(this.Relationship.SyncSourceAdapter));
            }

            if (this.Relationship.SyncDestinationAdapter.AdapterBase is WindowsFileSystemAdapter)
            {
                this.MenuCommands.Add(
                    new OpenFolderMenuCommand(this.Relationship.SyncDestinationAdapter));
            }

            this.Relationship.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(this.Relationship.State))
                {
                    this.SetNavigationState();

                    // State changes for the relationship almost always require that the UI be updated after the 
                    // state change occurs. Rather than tracking down all of the places where this would be 
                    // needed, simply handle it here.
                    App.DispatcherInvoke(CommandManager.InvalidateRequerySuggested);
                }

                if (args.PropertyName == nameof(this.Relationship.Name))
                {
                    this.Name = this.Relationship.Name;
                }
            };

            this.SetNavigationState();
        }
        public SyncRelationshipView()
        {
            this.InitializeComponent();

            this.DataContextChanged += async(sender, args) =>
            {
                SyncRelationshipViewModel viewModel = this.DataContext as SyncRelationshipViewModel;
                if (viewModel != null)
                {
                    await viewModel.CalculateRelationshipMetadataAsync();
                }
            };
        }
Example #11
0
        public SyncJobPanelViewModel(SyncRelationshipViewModel relationship)
        {
            this.Relationship = relationship;

            this.FileDisplayMode = SyncJobFilesViewMode.Flat;

            this.Relationship.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(this.Relationship.ActiveJob))
                {
                    CommandManager.InvalidateRequerySuggested();
                }
            };
        }
Example #12
0
        public BeginSyncMenuCommand(SyncRelationshipViewModel relationship)
            : base("SYNCHRONIZE", "/SyncPro.UI;component/Resources/Graphics/refresh_update_16.png")
        {
            this.relationship = relationship;

            this.relationship.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(this.relationship.ActiveJob))
                {
                    this.UpdateState();
                }
            };

            this.UpdateState();
        }
        public static OneDriveAdapterViewModel CreateFromRelationship(SyncRelationshipViewModel relationship, bool isSourceAdapter)
        {
            ISyncTargetViewModel     existingAdapter = isSourceAdapter ? relationship.SyncSourceAdapter : relationship.SyncDestinationAdapter;
            OneDriveAdapterViewModel model           = existingAdapter as OneDriveAdapterViewModel;

            if (model != null)
            {
                return(model);
            }

            OneDriveAdapterViewModel adapterViewModel = relationship.CreateAdapterViewModel <OneDriveAdapterViewModel>();

            // If we are creating a new adapter view model (and adapter), set the IsOriginator property
            adapterViewModel.Adapter.Configuration.IsOriginator = isSourceAdapter;

            return(adapterViewModel);
        }
Example #14
0
        protected override void InvokeCommand(object obj)
        {
            SyncRelationship newRelationship = SyncRelationship.Create();

            newRelationship.Description =
                string.Format("Sync relationship created on {0:MM/dd/yyyy} at {0:h:mm tt}", DateTime.Now);

            // The relationship object is not populated, so dont load the context in the view model
            SyncRelationshipViewModel syncRelationshipViewModel = new SyncRelationshipViewModel(newRelationship, false);

            RelationshipEditorViewModel viewModel = new RelationshipEditorViewModel(syncRelationshipViewModel, false);
            EditorWindow editorWindow             = new EditorWindow {
                DataContext = viewModel
            };

            editorWindow.ShowDialog();
        }
        public static WindowsFileSystemAdapterViewModel CreateFromRelationship(SyncRelationshipViewModel relationship, bool isSourceAdapter)
        {
            ISyncTargetViewModel existingAdapter    = isSourceAdapter ? relationship.SyncSourceAdapter : relationship.SyncDestinationAdapter;
            WindowsFileSystemAdapterViewModel model = existingAdapter as WindowsFileSystemAdapterViewModel;

            if (model != null)
            {
                return(model);
            }

            // Create a temporary adapter. This will only be committed to the DB when the user actually creates the relationship.
            WindowsFileSystemAdapterViewModel adapterViewModel = relationship.CreateAdapterViewModel <WindowsFileSystemAdapterViewModel>();

            // If we are creating a new adapter view model (and adapter), set the IsOriginator property
            adapterViewModel.Adapter.Configuration.IsOriginator = isSourceAdapter;

            return(adapterViewModel);
        }
Example #16
0
        public AnalyzeJobPanelViewModel(SyncRelationshipViewModel relationship)
        {
            this.Relationship        = relationship;
            this.BeginAnalyzeCommand = new DelegatedCommand(this.BeginAnalyze, this.CanBeginAnalyze);
            this.BeginSyncCommand    = new DelegatedCommand(this.BeginSync, this.CanBeginAnalyze);
            this.CancelJobCommand    = new DelegatedCommand(this.CancelJob, this.CanCancelJob);

            this.FileDisplayMode = SyncJobFilesViewMode.Flat;

            this.Relationship.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(this.Relationship.ActiveJob))
                {
                    var activeJobViewModel = this.Relationship.ActiveJob as AnalyzeJobViewModel;
                    if (activeJobViewModel != null && activeJobViewModel.Job == this.promisedJob)
                    {
                        this.AnalyzeJobViewModel = activeJobViewModel;
                    }

                    App.DispatcherInvoke(CommandManager.InvalidateRequerySuggested);
                }
            };
        }
 public RemoveRelationshipMenuCommand(SyncRelationshipViewModel relationship)
     : base("REMOVE", "/SyncPro.UI;component/Resources/Graphics/delete_16.png")
 {
     this.relationship = relationship;
 }
Example #18
0
 public ClosePanelMenuCommand(SyncRelationshipViewModel relationship, NavigationNodeViewModel navigationNodeViewModel)
     : base("CLOSE", "/SyncPro.UI;component/Resources/Graphics/close_window_16.png")
 {
     this.relationship = relationship;
     this.viewModel    = navigationNodeViewModel;
 }
Example #19
0
 public AnalyzeRelationshipMenuCommand(SyncRelationshipViewModel relationship)
     : base("ANALYZE", "/SyncPro.UI;component/Resources/Graphics/select_invert_16.png")
 {
     this.relationship = relationship;
 }