protected GroupBuilderFactoryBase(IAbstractFolder folder, ISettings settings, bool groupCompletedTasks)
        {
            this.folder   = folder;
            this.settings = settings;

            this.groupCompletedTasks = groupCompletedTasks && settings.GetValue <CompletedTaskMode>(CoreSettings.CompletedTasksMode) == CompletedTaskMode.Group;
        }
 public static string GetArgSelectFolder(IAbstractFolder abstractFolder)
 {
     if (abstractFolder is ITag)
     {
         return(string.Format(TagIdFormat, abstractFolder.Id));
     }
     else if (abstractFolder is ISmartView)
     {
         return(string.Format(SmartViewIdFormat, abstractFolder.Id));
     }
     else if (abstractFolder is IView)
     {
         return(string.Format(ViewIdFormat, abstractFolder.Id));
     }
     else if (abstractFolder is IFolder)
     {
         return(string.Format(FolderIdFormat, abstractFolder.Id));
     }
     else if (abstractFolder is IContext)
     {
         return(string.Format(ContextIdFormat, abstractFolder.Id));
     }
     else
     {
         return(null);
     }
 }
 public FolderBaseEntry(IAbstractFolder folder, string parameter = null)
 {
     this.Name           = folder.Name;
     this.GroupAscending = folder.GroupAscending;
     this.Group          = folder.TaskGroup;
     this.Parameter      = parameter;
 }
Exemple #4
0
        public EditFolderViewModel(IAbstractFolder abstractFolder, IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, IPlatformService platformService, ITileManager tileManager)
            : base(workbook, navigationService, messageBoxService, platformService)
        {
            if (abstractFolder == null)
            {
                throw new ArgumentNullException("abstractFolder");
            }
            if (tileManager == null)
            {
                throw new ArgumentNullException("tileManager");
            }

            this.abstractFolder = abstractFolder;
            this.tileManager    = tileManager;

            this.Title       = abstractFolder.Name;
            this.IsAscending = abstractFolder.GroupAscending;
            this.TaskGroup   = abstractFolder.TaskGroup;

            this.SelectedColorIndex = ColorChooser.GetColorIndex(abstractFolder.Color);
            this.SelectedIcon       = abstractFolder.IconId;

            if (abstractFolder is IFolder)
            {
                var folder = (IFolder)abstractFolder;
                this.ShowInViews = folder.ShowInViews.HasValue && folder.ShowInViews.Value;
            }
        }
Exemple #5
0
        public async Task <bool> PinAsync(IAbstractFolder abstractFolder)
        {
            string tileId = LaunchArgumentsHelper.GetArgSelectFolder(abstractFolder);

            var tile = new SecondaryTile(
                tileId,
                abstractFolder.Name,
                tileId,
                SafeUri.Get("ms-appx:///Assets/Logo150.png"),
                TileSize.Wide310x150);

            tile.VisualElements.Wide310x150Logo   = SafeUri.Get("ms-appx:///Assets/Wide310x150Logo.png");
            tile.VisualElements.Square310x310Logo = SafeUri.Get("ms-appx:///Assets/Square310x310Logo.png");
            tile.VisualElements.BackgroundColor   = Colors.Transparent;

            tile.RoamingEnabled = true;

            bool isPinned = await tile.RequestCreateForSelectionAsync(GetPlacement(), Placement.Below);

            if (isPinned)
            {
                if (this.updateTileTimer != null)
                {
                    this.updateTileTimer.Start();
                }

                this.secondaryTiles.Add(tile);
                this.notificationService?.ShowNotification(string.Format(StringResources.Notification_FolderPinnedFormat, abstractFolder.Name), ToastType.Info);

                return(true);
            }

            return(false);
        }
Exemple #6
0
        public static string GetFolderIconPng(IAbstractFolder folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }

            return(string.Format(FolderIconPathFormat, folder.IconId.ToString("00")));
        }
        internal LaunchArgumentDescriptor(IAbstractFolder folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            this.Folder = folder;
            this.Type   = LaunchArgumentType.Select;
        }
Exemple #8
0
        public void SelectFolder(IAbstractFolder folder)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame != null && rootFrame.Content is MainPage)
            {
                var mainpage  = (MainPage)rootFrame.Content;
                var viewmodel = (MainPageViewModel)mainpage.DataContext;
                viewmodel.SelectedMenuItem = viewmodel.MenuItems.FirstOrDefault(m => m.Folder == folder);
            }
        }
Exemple #9
0
 public bool IsPinned(IAbstractFolder folder)
 {
     try
     {
         return(SecondaryTile.Exists(LaunchArgumentsHelper.GetArgSelectFolder(folder)));
     }
     catch (Exception ex)
     {
         LogService.Log("TileManager", $"Exception in IsPinned: {ex}");
         return(false);
     }
 }
Exemple #10
0
        public async Task <bool> UnpinAsync(IAbstractFolder folder)
        {
            if (this.IsPinned(folder))
            {
                string id     = LaunchArgumentsHelper.GetArgSelectFolder(folder);
                var    tile   = new SecondaryTile(id);
                bool   result = await tile.RequestDeleteForSelectionAsync(GetPlacement(), Placement.Below);

                if (result)
                {
                    this.secondaryTiles.Remove(t => t.TileId == id);
                    this.notificationService?.ShowNotification(string.Format(StringResources.Notification_FolderUnpinnedFormat, folder.Name), ToastType.Info);
                }

                return(result);
            }

            return(false);
        }
Exemple #11
0
        public static TaskCreationParameters GetTaskCreationParameters(this IAbstractFolder folder)
        {
            var parameters = new TaskCreationParameters();

            if (folder is ISystemView)
            {
                var view = (ISystemView)folder;
                switch (view.ViewKind)
                {
                case ViewKind.Today:
                    parameters.Due = DateTime.Today;
                    break;

                case ViewKind.Tomorrow:
                    parameters.Due = DateTime.Today.AddDays(1.0);
                    break;

                case ViewKind.Starred:
                    parameters.Priority = TaskPriority.Star;
                    break;

                case ViewKind.NoDate:
                    parameters.Due = null;
                    break;
                }
            }
            else if (folder is IFolder)
            {
                parameters.Folder = (IFolder)folder;
            }
            else if (folder is IContext)
            {
                parameters.Context = (IContext)folder;
            }
            else if (folder is ITag)
            {
                parameters.Tag = folder.Name;
            }

            return(parameters);
        }
Exemple #12
0
        public static List <ITask> SelectTasks(IAbstractFolder folder, ISettings settings)
        {
            var  groupBuilder  = GroupBuilderFactory.GetGroupBuilder(folder, settings);
            bool showCompleted = (folder is ISystemView) && ((ISystemView)folder).ViewKind == ViewKind.Completed;
            bool showTaskWithStartDateInFuture = settings.GetValue <bool>(CoreSettings.ShowFutureStartDates);

            DateTime dateTimeNow = DateTime.Now;

            var smartCollection = new SmartCollection <ITask>(
                folder.Tasks,
                groupBuilder,
                t =>
            {
                return((!(folder is ISystemView) || t.Folder.ShowInViews.HasValue && t.Folder.ShowInViews.Value) &&
                       (showCompleted || !t.IsCompleted) &&
                       (showTaskWithStartDateInFuture || (!t.Start.HasValue || t.Start.Value <= dateTimeNow)) &&
                       t.ParentId == null);            // exlude subtasks
            });

            return(smartCollection.Items.SelectMany(g => g).ToList());
        }
        public static GroupBuilder <ITask> GetGroupBuilder(IAbstractFolder folder, ISettings settings)
        {
            TaskGroup taskGroup = folder.TaskGroup;

            switch (taskGroup)
            {
            case TaskGroup.DueDate:
                return(new DueDateGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Status:
                return(new StatusGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Priority:
                return(new PriorityGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Folder:
                return(new FolderGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Action:
                return(new ActionGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Progress:
                return(new ProgressGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Context:
                return(new ContextGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.StartDate:
                return(new StartDateGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Completed:
                return(new CompletedDateGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            case TaskGroup.Modified:
                return(new ModifiedGroupBuilderFactory(folder, settings).CreateGroupBuilder());

            default:
                throw new ArgumentOutOfRangeException(nameof(folder));
            }
        }
Exemple #14
0
        protected void UpdateFolder(IAbstractFolder target)
        {
            var folder = target as IFolder;

            if (this.selectedColorIndex < 0)
            {
                this.selectedColorIndex = 0;
            }

            if (folder != null)
            {
                folder.Name   = this.Title;
                folder.Color  = ColorChooser.Colors[this.selectedColorIndex];
                folder.IconId = this.SelectedIcon;
                if (folder.IconId < 1)
                {
                    folder.IconId = 1;
                }
                folder.ShowInViews = this.ShowInViews;
            }

            target.UpdateGroupingMode(this.TaskGroup, this.isAscending);
        }
        public GeneralSettingsPageViewModel(IWorkbook workbook, INavigationService navigationService, ITileManager tileManager)
            : base(workbook, navigationService)
        {
            if (tileManager == null)
            {
                throw new ArgumentNullException(nameof(tileManager));
            }

            this.tileManager           = tileManager;
            this.defaultContextChoices = new List <IContext>(this.Workbook.Contexts);
            this.defaultContextChoices.Insert(0, null);

            this.badgeValues = new List <IAbstractFolder> {
                new Folder {
                    Name = StringResources.Settings_NoBadgeValue.ToLowerInvariant()
                }
            };
            this.badgeValues.AddRange(this.Workbook.Views);
            this.badgeValues.AddRange(this.Workbook.SmartViews);
            this.badgeValues.AddRange(this.Workbook.Folders);
            this.badgeValues.AddRange(this.Workbook.Contexts);
            this.badgeValues.AddRange(this.Workbook.Tags);

            AutoDeleteFrequency frequency = this.Settings.GetValue <AutoDeleteFrequency>(CoreSettings.AutoDeleteFrequency);

            this.selectedAutoDelete = frequency.GetDescription();

            TaskPriority priority = this.Settings.GetValue <TaskPriority>(CoreSettings.DefaultPriority);

            this.selectedDefaultPriority = priority.GetDescription();

            string badgeValue = this.Settings.GetValue <string>(CoreSettings.BadgeValue);

            if (!string.IsNullOrWhiteSpace(badgeValue))
            {
                var descriptor = LaunchArgumentsHelper.GetDescriptorFromArgument(this.Workbook, badgeValue);
                if (descriptor != null && descriptor.Folder != null)
                {
                    this.originalSelectedBadgeValue = descriptor.Folder;
                    this.selectedBadgeValue         = descriptor.Folder;
                }
            }

            if (this.selectedBadgeValue == null)
            {
                this.selectedBadgeValue = this.badgeValues[0];
            }

            int      contextId      = this.Settings.GetValue <int>(CoreSettings.DefaultContext);
            IContext defaultContext = this.Workbook.Contexts.FirstOrDefault(c => c.Id == contextId);

            if (defaultContext != null)
            {
                this.selectedDefaultContext = defaultContext;
            }

            DefaultDate defaultDueDate = this.Settings.GetValue <DefaultDate>(CoreSettings.DefaultDueDate);

            this.selectedDefaultDueDate = defaultDueDate.GetDescription();

            DefaultDate defaultStartDate = this.Settings.GetValue <DefaultDate>(CoreSettings.DefaultStartDate);

            this.selectedDefaultStartDate = defaultStartDate.GetDescription();

            CompletedTaskMode completedTaskMode = this.Settings.GetValue <CompletedTaskMode>(CoreSettings.CompletedTasksMode);

            this.selectedCompletedTaskMode = completedTaskMode.GetDescription();

            this.useGroupedDates          = this.Settings.GetValue <bool>(CoreSettings.UseGroupedDates);
            this.showNoDueWithOther       = this.Settings.GetValue <bool>(CoreSettings.IncludeNoDateInViews);
            this.showFutureStartDates     = this.Settings.GetValue <bool>(CoreSettings.ShowFutureStartDates);
            this.autoDeleteTags           = this.Settings.GetValue <bool>(CoreSettings.AutoDeleteTags);
            this.completeTaskSetsProgress = this.Settings.GetValue <bool>(CoreSettings.CompleteTaskSetProgress);
        }
Exemple #16
0
 private IList <ITask> PickTasks(IAbstractFolder abstractFolder)
 {
     return(TaskPicker.SelectTasks(abstractFolder, this.workbook.Settings).ToList());
 }
Exemple #17
0
 private FolderItemViewModel GetFolderItemViewModel(IAbstractFolder folder)
 {
     return(this.menuItems.FirstOrDefault(vm => vm.Folder == folder) as FolderItemViewModel);
 }
Exemple #18
0
        private void UpdateAbstractFolders(IAbstractFolder added, IAbstractFolder removed)
        {
            var sortedFolders = new List <IAbstractFolder>();

            sortedFolders.AddRange(this.workbook.Views.OrderBy(v => v.Order));
            sortedFolders.AddRange(this.workbook.SmartViews.OrderBy(v => v.Order));
            sortedFolders.AddRange(this.workbook.Folders.OrderBy(f => f.Order));
            sortedFolders.AddRange(this.workbook.Contexts.OrderBy(c => c.Order));
            sortedFolders.AddRange(this.workbook.Tags.OrderBy(t => t.Order));

            if (removed != null)
            {
                var target = this.GetFolderItemViewModel(removed);
                if (target != null)
                {
                    this.menuItems.Remove(target);
                }
            }
            else
            {
                if (added != null && this.menuItems.All(m => m.Folder != added))
                {
                    this.menuItems.Add(new FolderItemViewModel(this.workbook, added));
                }

                var sorted = sortedFolders
                             .Select(f => this.menuItems.FirstOrDefault(m => m.Folder == f))
                             .ToList();
                this.menuItems.ReorderFrom(sorted);
            }

            // check if we must update selected navigation menu item
            if (!this.menuItems.Contains(this.viewModel.SelectedMenuItem))
            {
                this.viewModel.SelectedMenuItem = this.menuItems.OfType <FolderItemViewModel>().FirstOrDefault();
            }

            // update separators
            this.RemoveSeparator(Constants.SeparatorSmartViewId);
            this.RemoveSeparator(Constants.SeparatorFolderId);
            this.RemoveSeparator(Constants.SeparatorContextId);
            this.RemoveSeparator(Constants.SeparatorTagId);

            bool group1 = this.workbook.Views.Any(v => v.IsEnabled);
            bool group2 = this.workbook.SmartViews.Any();
            bool group3 = this.workbook.Folders.Any();
            bool group4 = this.workbook.Contexts.Any();
            bool group5 = this.workbook.Tags.Any();

            if (group1 && (group2 || group3 || group4 || group5))
            {
                if (this.GetSeparatorIndex(Constants.SeparatorFolderId) < 0)
                {
                    this.menuItems.Insert(this.LastIndexOf(f => f is IView && !(f is ITag) && !(f is ISmartView)) + 1, new SeparatorItemViewModel(Constants.SeparatorFolderId));
                }
            }

            if (group2 && (group3 || group4 || group5))
            {
                if (this.GetSeparatorIndex(Constants.SeparatorSmartViewId) < 0)
                {
                    this.menuItems.Insert(this.LastIndexOf(f => f is ISmartView) + 1, new SeparatorItemViewModel(Constants.SeparatorSmartViewId));
                }
            }

            if (group3 && (group4 || group5))
            {
                if (this.GetSeparatorIndex(Constants.SeparatorContextId) < 0)
                {
                    this.menuItems.Insert(this.LastIndexOf(f => f is IFolder) + 1, new SeparatorItemViewModel(Constants.SeparatorContextId));
                }
            }

            if (group4 && group5)
            {
                if (this.GetSeparatorIndex(Constants.SeparatorTagId) < 0)
                {
                    this.menuItems.Insert(this.LastIndexOf(f => f is IContext) + 1, new SeparatorItemViewModel(Constants.SeparatorTagId));
                }
            }
        }
Exemple #19
0
 public StatusGroupBuilderFactory(IAbstractFolder folder, ISettings settings)
     : base(folder, settings, false)
 {
 }
Exemple #20
0
        public void UpdateTiles()
        {
            try
            {
                // update main tile
                var todayView = this.workbook.Views.FirstOrDefault(v => v.ViewKind == ViewKind.Today);
                if (todayView != null)
                {
                    var todayTasks = this.PickTasks(todayView);
                    this.SetTileContent(StringResources.SystemView_TitleToday, todayTasks, TileUpdateManager.CreateTileUpdaterForApplication());

                    bool   badgeSet         = false;
                    string badgeFolderValue = this.workbook.Settings.GetValue <string>(CoreSettings.BadgeValue);
                    if (!string.IsNullOrWhiteSpace(badgeFolderValue))
                    {
                        var descriptor = LaunchArgumentsHelper.GetDescriptorFromArgument(this.workbook, badgeFolderValue);
                        if (descriptor != null && descriptor.Folder != null)
                        {
                            var folder = descriptor.Folder;
                            this.SetBadgeValue(BadgeUpdateManager.CreateBadgeUpdaterForApplication(), this.PickTasks(folder).Count);
                            badgeSet = true;
                        }
                    }

                    if (!badgeSet)
                    {
                        this.SetBadgeValue(BadgeUpdateManager.CreateBadgeUpdaterForApplication(), 0);
                    }
                }
                else
                {
                    this.TrackEvent("Update main tile", "Could not find view today");
                }
            }
            catch (Exception ex)
            {
                TrackingManagerHelper.Exception(ex, "Error while updating main tile");
            }

            if (this.secondaryTiles == null)
            {
                this.TrackEvent("Update secondary tiles", "Secondary tiles are not loaded, skipping update");
                return;
            }

            foreach (var secondaryTile in this.secondaryTiles)
            {
                try
                {
                    TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(secondaryTile.TileId);

                    IAbstractFolder folder = LaunchArgumentsHelper.GetDescriptorFromArgument(this.workbook, secondaryTile.TileId).Folder;
                    ITask           task   = LaunchArgumentsHelper.GetDescriptorFromArgument(this.workbook, secondaryTile.TileId).Task;

                    if (folder != null)
                    {
                        var title       = folder.Name;
                        var folderTasks = this.PickTasks(folder);

                        this.SetTileContent(title, folderTasks, tileUpdater, folder);
                        this.SetBadgeValue(BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(secondaryTile.TileId), folderTasks.Count);
                    }
                    else if (task != null)
                    {
                        this.SetTileContent(task, tileUpdater);
                    }
                    else if (secondaryTile.TileId != quickAddTaskTileId)
                    {
                        // task that is linked to no folder and no task...
                        this.SetTileContent(StringResources.Message_LiveTileRemoveMe, new List <ITask>(), tileUpdater);
                    }
                }
                catch (Exception ex)
                {
                    TrackingManagerHelper.Exception(ex, "Update secondary tiles");
                }
            }
        }
Exemple #21
0
 public Task <bool> UnpinAsync(IAbstractFolder folder)
 {
     return(null);
 }
Exemple #22
0
 public bool IsPinned(IAbstractFolder folder)
 {
     return(false);
 }
Exemple #23
0
 public Task <bool> PinAsync(IAbstractFolder abstractFolder)
 {
     return(null);
 }
 public DueDateGroupBuilderFactory(IAbstractFolder folder, ISettings settings)
     : base(folder, settings, true)
 {
     this.converter = new RelativeDateConverter(settings);
 }
Exemple #25
0
        private void SetTileContent(string title, IList <ITask> tasks, TileUpdater tileUpdater, IAbstractFolder folder = null)
        {
            var tileNotification = NotificationContentBuilder.CreateTileNotification(title, tasks, folder);

            if (tileNotification != null)
            {
                tileUpdater.Update(new TileNotification(tileNotification));
            }
        }
        public static LaunchArgumentDescriptor GetDescriptorFromArgument(IWorkbook workbook, string argument)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }

            // input is 'action/task-0' or 'task-0' or 'folder-0'
            if (string.IsNullOrWhiteSpace(argument))
            {
                return(emptyDescriptor);
            }

            int itemId = -1;

            LaunchArgumentType type = LaunchArgumentType.EditTask;

            string[] parameters = argument.Split('/');
            if (parameters.Length == 2 && launchArgumentTypes.ContainsKey(parameters[0]))
            {
                type     = launchArgumentTypes[parameters[0]];
                argument = parameters[1];
            }
            else if (argument == Sync)
            {
                return(new LaunchArgumentDescriptor(LaunchArgumentType.Sync));
            }

            string[] itemDescriptor = argument.Split('-');
            if (itemDescriptor.Length != 2)
            {
                return(emptyDescriptor);
            }

            if (!int.TryParse(itemDescriptor[1], out itemId))
            {
                return(emptyDescriptor);
            }

            string itemType = itemDescriptor[0];

            if (itemType == "task")
            {
                ITask task = workbook.Tasks.FirstOrDefault(t => t.Id == itemId);
                if (task != null)
                {
                    return(new LaunchArgumentDescriptor(task, type));
                }
            }
            else if (itemType == "folder")
            {
                IAbstractFolder folder = workbook.Folders.FirstOrDefault(t => t.Id == itemId);
                if (folder != null)
                {
                    return(new LaunchArgumentDescriptor(folder));
                }
            }
            else if (itemType == "smartview")
            {
                IAbstractFolder folder = workbook.SmartViews.FirstOrDefault(t => t.Id == itemId);
                if (folder != null)
                {
                    return(new LaunchArgumentDescriptor(folder));
                }
            }
            else if (itemType == "view")
            {
                IAbstractFolder folder = workbook.Views.FirstOrDefault(t => t.Id == itemId);
                if (folder != null)
                {
                    return(new LaunchArgumentDescriptor(folder));
                }
            }
            else if (itemType == "context")
            {
                IAbstractFolder folder = workbook.Contexts.FirstOrDefault(t => t.Id == itemId);
                if (folder != null)
                {
                    return(new LaunchArgumentDescriptor(folder));
                }
            }
            else if (itemType == "tag")
            {
                IAbstractFolder folder = workbook.Tags.FirstOrDefault(t => t.Id == itemId);
                if (folder != null)
                {
                    return(new LaunchArgumentDescriptor(folder));
                }
            }

            return(emptyDescriptor);
        }
Exemple #27
0
        public FolderItemViewModel(IWorkbook workbook, IAbstractFolder folder)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            this.workbook             = workbook;
            this.settings             = workbook.Settings;
            this.settings.KeyChanged += this.OnSettingsKeyChanged;
            this.folder = folder;

            this.setTargetGroupCommand = new RelayCommand <string>(taskGroup => this.SelectedTaskGroup = TaskGroupConverter.FromName(taskGroup));
            this.contextualCommand     = new RelayCommand(this.ContextualCommandExecute);

            this.showFutureStartDates = this.workbook.Settings.GetValue <bool>(CoreSettings.ShowFutureStartDates);
            this.isDatesGrouped       = this.workbook.Settings.GetValue <bool>(CoreSettings.UseGroupedDates);
            this.hideCompletedTasks   = this.workbook.Settings.GetValue <CompletedTaskMode>(CoreSettings.CompletedTasksMode) == CompletedTaskMode.Hide;

            ISystemView view = this.folder as ISystemView;

            if (view != null)
            {
                this.viewKind = view.ViewKind;
            }
            else if (this.folder is ViewSearch)
            {
                this.viewKind = ViewKind.Search;
            }
            else
            {
                this.viewKind = ViewKind.None;
            }

            this.trackedTasks = new List <ITask>();

            this.folder.TaskAdded   += (s, e) => this.AddTask(e.Item);
            this.folder.TaskRemoved += (s, e) => this.RemoveTask(e.Item);

            this.folder.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Name")
                {
                    this.RaisePropertyChanged("Name");
                }
                else if (e.PropertyName == "TaskCount" && this.folder.HasCustomCommand)
                {
                    this.RaisePropertyChanged("HasContextualCommand");
                }
            };

            this.folder.GroupingChanged += (s, e) =>
            {
                this.smartCollection.GroupBuilder = GroupBuilderFactory.GetGroupBuilder(this.folder, this.settings);
                this.RaisePropertyChanged("DisplayFolder");
                this.RaisePropertyChanged("DisplayDue");
            };

            // the last parameter is a function which returns the folder associated with a task
            // when we group by folder, it's the folder of the task
            // otherwise (most of the time), it's the folder of this ViewModel
            this.smartCollection = new SmartCollection <ITask>(
                this.folder.Tasks,
                GroupBuilderFactory.GetGroupBuilder(this.folder, this.workbook.Settings),
                this.TaskFilter,
                this,
                task => this.folder);

            foreach (var task in this.folder.Tasks)
            {
                this.StartTrackingTask(task);
            }
        }
Exemple #28
0
 public FolderGroupBuilderFactory(IAbstractFolder folder, ISettings settings)
     : base(folder, settings, true)
 {
 }
        public static XmlDocument CreateTileNotification(string title, IList <ITask> tasks, IAbstractFolder folder = null)
        {
            string content = string.Empty;

            try
            {
                var xmlDocument = new XmlDocument();

                const string templateXml = @"
                    <tile>
                        <visual branding=""nameAndLogo"" displayName=""{0}"">
                            <binding template=""TileSmall"" hint-textStacking=""center"" branding=""none"">
                                <image placement=""peek"" src=""{3}""/>
                                <text hint-align=""center"" hint-style=""title"">{1}</text>
                            </binding>
                            <binding template=""TileMedium"">
                                {2}
                            </binding>
                            <binding template=""TileWide"" hint-lockDetailedStatus1=""{4}"" hint-lockDetailedStatus2=""{5}"" hint-lockDetailedStatus3=""{6}"">
                                <group>
                                    <subgroup hint-weight=""20"" hint-textStacking=""center"">
                                        <image src=""{3}""/>
                                    </subgroup>
                                    <subgroup hint-weight=""80"" hint-textStacking=""center"">
                                        {2}
                                    </subgroup>
                                </group>
                            </binding>
                            <binding template=""TileLarge"">
                                {2}
                            </binding>
                        </visual>
                    </tile>
                    ";

                var  builder = new StringBuilder();
                bool hasTask = false;

                string task1 = string.Empty;
                string task2 = string.Empty;
                string task3 = string.Empty;

                for (int i = 0; i < 10; i++)
                {
                    string taskName = TryGetTaskAt(tasks, i);
                    if (!string.IsNullOrWhiteSpace(taskName))
                    {
                        var safeEscapeTaskName = SafeEscape(taskName);
                        builder.AppendLine(string.Format("<text>{0}</text>", safeEscapeTaskName));
                        hasTask = true;

                        if (i == 0)
                        {
                            task1 = safeEscapeTaskName;
                        }
                        else if (i == 1)
                        {
                            task2 = safeEscapeTaskName;
                        }
                        else if (i == 2)
                        {
                            task3 = safeEscapeTaskName;
                        }
                    }
                }

                if (!hasTask)
                {
                    if (folder != null)
                    {
                        builder.AppendLine(string.Format("<text hint-style='captionsubtle' hint-wrap='true'>{0}</text>", SafeEscape(folder.EmptyHeader)));
                    }
                    else
                    {
                        builder.AppendLine(string.Format("<text hint-style='captionsubtle' hint-wrap='true'>{0}</text>", SafeEscape(StringResources.SystemView_Today_EmptyHeader)));
                    }
                }

                string displayName = SafeEscape(title);
                string counter     = tasks.Count.ToString(CultureInfo.InvariantCulture);
                string text        = builder.ToString();
                string picture     = folder != null?ResourcesLocator.GetFolderIconPng(folder) : ResourcesLocator.GetAppIconPng();

                content = string.Format(
                    templateXml,
                    displayName,   // 0
                    counter,       // 1
                    text,          // 2
                    picture,       // 3
                    task1,         // 4
                    task2,         // 5
                    task3          // 6
                    );

                xmlDocument.LoadXml(content);

                return(xmlDocument);
            }
            catch (Exception ex)
            {
                TrackingManagerHelper.Exception(ex, string.Format("Exception CreateTileNotification: {0}", content));
                return(null);
            }
        }