public Drawing(string id, DrawingModel drawingModel, IAuthenticationService authService, ICacheService cache, IDatabaseService databaseService, ILogger logger) { if (!(drawingModel?.IsPublic ?? true) && drawingModel?.Owner != authService?.CurrentUser?.Id) { KickedOut?.Invoke(); return; } Id = id; Cache = cache; Logger = logger; DrawingModel = drawingModel; AuthService = authService; DatabaseService = databaseService; StrokeCollection = new SyncedStrokeCollection(Id, AuthService, databaseService, cache, logger); StrokeCollection.StrokesUpdated += () => { UpdateStrokes(); HighlightSelectedStrokes(); }; ToggleSync(); AuthService.CurrentUserChanged += (_) => ToggleSync(); AuthService.BeforeLogout += async(_) => await RemoveSelection(); AppDomain.CurrentDomain.ProcessExit += (_, __) => OnQuit().Wait(); (Strokes as INotifyCollectionChanged).CollectionChanged += OnStrokesChanged; }
private async void SyncRemoteAttributesToLocal(DrawingModel drawingModel) { if (drawingModel.IsProtected != DrawingModel.IsProtected || drawingModel.IsPublic != DrawingModel.IsPublic) { if (!IsOffline && drawingModel.Owner != AuthService.CurrentUser.Id) { if (!drawingModel.IsPublic) { await RemoveSelection(); KickedOut?.Invoke(); } else if (drawingModel.IsProtected) { await RemoveSelection(); PasswordRequested?.Invoke(); } } } DrawingModel = drawingModel; SizeChanged?.Invoke(DrawingModel.Width, DrawingModel.Height); HighlightSelectedStrokes(); }