public override void Refresh() { TaskModel task = Task; if (task == null) { return; } DataContext = task; TaskTileSettings settings = task.TileSettings ?? Settings.Current.DefaultTaskTileSettings; // Název if (settings.ShowTitle) { TitleWrapper.Visibility = Visibility.Visible; Title.FontSize = settings.LineHeight * 0.72; Title.LineHeight = settings.LineHeight; Title.Text = task.Title; Title.TextWrapping = settings.TitleOnOneLine ? TextWrapping.NoWrap : TextWrapping.Wrap; } else { TitleWrapper.Visibility = Visibility.Collapsed; } // Date bool showDate = settings.ShowDate && task.HasDueDate; InfoWrapper.Visibility = showDate ? Visibility.Visible : Visibility.Collapsed; if (showDate) { Info.Height = settings.LineHeight; Date.Text = task.ActualDueDate.Value.ToShortDateString(); } // Podúkoly Subtasks.Children.Clear(); List <Subtask> subtasks = new List <Subtask>(task.Subtasks.Where(s => settings.ShowCompletedSubtasks || !s.IsCompleted)); Subtasks.Visibility = subtasks.Count > 0 ? Visibility.Visible : Visibility.Collapsed; foreach (Subtask subtask in subtasks.Take((336 / (int)settings.LineHeight) + 1)) { SubtaskControl sc = new SubtaskControl(subtask); sc.Refresh(settings.LineHeight); Subtasks.Children.Add(sc); } // Detail Detail.Visibility = !string.IsNullOrWhiteSpace(task.Detail) ? Visibility.Visible : Visibility.Collapsed; if (!string.IsNullOrWhiteSpace(task.Detail)) { Detail.FontSize = settings.LineHeight * 0.65; Detail.Text = task.Detail; } // Pozadí LayoutRoot.Background = new SolidColorBrush(Colors.Transparent); //LayoutRoot.Background = new SolidColorBrush(task.Color) { Opacity = settings.BackgroundOpacity }; }
public override void Refresh() { TaskModel task = Task; if (task == null) { return; } DataContext = task; TaskTileSettings settings = task.TileSettings ?? Settings.Current.DefaultTaskTileSettings; // Název if (settings.ShowTitle) { TitleWrapper.Visibility = Visibility.Visible; Title.FontSize = settings.LineHeight * 0.72; Title.LineHeight = settings.LineHeight; Title.Text = task.Title; Title.TextWrapping = settings.TitleOnOneLine ? TextWrapping.NoWrap : TextWrapping.Wrap; } else { TitleWrapper.Visibility = Visibility.Collapsed; } // Date bool showDate = settings.ShowDate && task.HasDueDate; InfoWrapper.Visibility = showDate ? Visibility.Visible : Visibility.Collapsed; if (showDate) { Info.Height = settings.LineHeight; Date.Text = task.ActualDueDate.Value.ToShortDateString(); } // Podúkoly + Detail Subtasks1.Children.Clear(); Subtasks2.Children.Clear(); ShowSecondColumn(); List <Subtask> subtasks = new List <Subtask>(task.Subtasks.Where(s => settings.ShowCompletedSubtasks || !s.IsCompleted)); int maxColumnItems = (int)Math.Round(336 / settings.LineHeight); if (settings.ShowTitle) { maxColumnItems--; } if (showDate) { maxColumnItems--; } bool subtaksOnTwoColumns = subtasks.Count > maxColumnItems; bool showSubtasks = subtasks.Count > 0; if (showSubtasks) { if (!subtaksOnTwoColumns && string.IsNullOrWhiteSpace(task.Detail)) { HideSecondColumn(); } Subtasks1.Visibility = Visibility.Visible; foreach (Subtask subtask in subtasks.Take(maxColumnItems)) { SubtaskControl sc = new SubtaskControl(subtask); sc.Refresh(settings.LineHeight); Subtasks1.Children.Add(sc); } Subtasks2.Visibility = subtaksOnTwoColumns ? Visibility.Visible : Visibility.Collapsed; if (subtaksOnTwoColumns) { foreach (Subtask subtask in subtasks.Skip(maxColumnItems).Take(maxColumnItems)) { SubtaskControl sc = new SubtaskControl(subtask); sc.Refresh(settings.LineHeight); Subtasks2.Children.Add(sc); } } Detail2.FontSize = settings.LineHeight * 0.65; Detail2.Text = task.Detail; Detail1.Visibility = Visibility.Collapsed; } else { Subtasks1.Visibility = Visibility.Collapsed; Subtasks2.Visibility = Visibility.Collapsed; Detail1.Visibility = Visibility.Visible; Detail1.FontSize = settings.LineHeight * 0.65; Detail1.Text = task.Detail; HideSecondColumn(); } // Pozadí LayoutRoot.Background = new SolidColorBrush(Colors.Transparent); //LayoutRoot.Background = new SolidColorBrush(task.Color) { Opacity = settings.BackgroundOpacity }; }