Ejemplo n.º 1
0
        private static IEnumerable <Change> GetAppChanges(ValueChange <AppToken> diff)
        {
            var ids = new ChangeSet <AppId, AppToken, BookId, BookToken>(diff, diff.Select(app => app.Books));

            var result = Enumerable.Empty <Change>();

            if (diff.IsChanged(app => app.IsVisible))
            {
                var newValue = diff.NewValue.IsVisible;
                result = result.Concat(Change.SetVisibility(diff.NewValue.Id, newValue));
                if (!newValue)
                {
                    return(result);           //Don't look for other changes if the app just went invisible.
                }
            }

            if (diff.IsChanged(app => app.IsActive))
            {
                result = result.Concat(Change.SetActive(diff.NewValue.Id, diff.NewValue.IsActive));
            }

            result = result.Concat(ids.RemovedChanges)
                     .Concat(ids.AddedChanges)
                     .Concat(ids.NestedChanges(GetBookChanges));

            return(result);
        }
Ejemplo n.º 2
0
        private static IEnumerable <Change> GetBookChanges(ValueChange <BookToken> diff)
        {
            //   Debug.WriteLine($"SessionChangeAnalyzer.GetBookChanges({change})");

            var result = Enumerable.Empty <Change>();

            if (diff.IsChanged(b => b.IsActive))
            {
                result = result.Concat(Change.SetActive(diff.NewValue.Id, diff.NewValue.IsActive));
            }

            if (diff.IsChanged(b => b.IsVisible))
            {
                result = result.Concat(Change.SetVisibility(diff.NewValue.Id, diff.NewValue.IsVisible));
            }

            result = result.Concat(GetSheetCollectionChanges(diff)
                                   .Concat(GetWindowCollectionChanges(diff)));

            return(result);
        }
Ejemplo n.º 3
0
        private static IEnumerable <Change> GetSheetChanges(ValueChange <SheetToken> diff)
        {
            if (diff.IsChanged(s => s.IsActive))
            {
                yield return(Change.SetActive(diff.NewValue.Id, diff.NewValue.IsActive));
            }

            if (diff.IsChanged(s => s.IsVisible))
            {
                yield return(Change.SetVisibility(diff.NewValue.Id, diff.NewValue.IsVisible));
            }

            if (diff.IsChanged(s => s.Index))
            {
                yield return(Change.SheetSetIndex(diff.NewValue.Id, diff.NewValue.Index));
            }

            if (diff.IsChanged(s => s.TabColor))
            {
                yield return(Change.SheetTabColor(diff.NewValue.Id, diff.NewValue.TabColor));
            }
        }
Ejemplo n.º 4
0
        private static IEnumerable <Change> GetWindowChanges(ValueChange <WindowToken> diff)
        {
            if (diff.IsChanged(s => s.IsActive))
            {
                yield return(Change.SetActive(diff.NewValue.Id, diff.NewValue.IsActive));
            }

            if (diff.IsChanged(s => s.State))
            {
                yield return(Change.WindowSetState(diff.NewValue.Id, diff.NewValue.State));
            }

            if (diff.IsChanged(s => s.IsVisible))
            {
                yield return(Change.SetVisibility(diff.NewValue.Id, diff.NewValue.IsVisible));
            }

            if (diff.IsChanged(s => s.ActiveSheetId))
            {
                yield return(Change.WindowVisibleSheet(diff.NewValue.Id, diff.NewValue.ActiveSheetId));
            }
        }