123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using Comal.Classes;
- using InABox.WPF;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Input;
- namespace PRSDesktop;
- public partial class KanbanResources : ResourceDictionary
- {
- public static KanbanResources Resources = new KanbanResources();
- private static RoutedCommand editTask = new RoutedCommand();
- private static RoutedCommand selectTask = new RoutedCommand();
- private static RoutedCommand openTaskMenu = new RoutedCommand();
- public class OpenTaskMenuCommandArgs
- {
- public TaskModel Model { get; set; }
- public ContextMenu Menu { get; set; }
- public OpenTaskMenuCommandArgs(TaskModel model, ContextMenu menu)
- {
- Model = model;
- Menu = menu;
- }
- }
- public static RoutedCommand EditTask => editTask;
- public static RoutedCommand SelectTask => selectTask;
- public static RoutedCommand OpenTaskMenu => openTaskMenu;
- private void Border_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- if (sender is not FrameworkElement element || element.Tag is not TaskModel model) return;
- if(e.ClickCount > 1)
- {
- EditTask.Execute(model, element);
- }
- }
- private void CheckBox_Checked(object sender, RoutedEventArgs e)
- {
- if (sender is not FrameworkElement element || element.Tag is not TaskModel model) return;
- SelectTask.Execute(model, element);
- }
- private void TaskMenu_Opened(object sender, ContextMenuEventArgs e)
- {
- if (sender is not FrameworkElement element || element.Tag is not TaskModel model) return;
- OpenTaskMenu.Execute(new OpenTaskMenuCommandArgs(model, element.ContextMenu), element);
- }
- private void Border_MouseMove(object sender, MouseEventArgs e)
- {
- if(sender is not Border border)
- {
- return;
- }
- if ((sender as FrameworkElement)?.Tag is not TaskModel model) return;
- if (e.LeftButton == MouseButtonState.Pressed && !model.Locked)
- {
- DragDrop.DoDragDrop(border, model, DragDropEffects.Move);
- }
- }
- }
- public enum KanbanViewMode
- {
- Full,
- Compact
- }
- public class ViewModeToKanbanTemplateConverter : IValueConverter
- {
- public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if(value is not KanbanViewMode mode)
- {
- return null;
- }
- if(mode == KanbanViewMode.Full)
- {
- return KanbanResources.Resources["FullKanban"] as DataTemplate;
- }
- else
- {
- return KanbanResources.Resources["CompactKanban"] as DataTemplate;
- }
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class KanbanStatusToStringConverter : AbstractConverter<KanbanStatus, string>
- {
- public override string Convert(KanbanStatus value)
- {
- return value switch
- {
- KanbanStatus.InProgress => "In Progress",
- KanbanStatus.Waiting => "Waiting for Others",
- KanbanStatus.Complete => "Completed",
- KanbanStatus.Open or _ => "To Do",
- };
- }
- }
|