Synchronizing calendars for gmail and some events.

This commit is contained in:
Burak Kaan Köse
2024-12-27 00:18:46 +01:00
parent 1668dfcce6
commit fbc3ca4517
44 changed files with 1030 additions and 320 deletions

View File

@@ -12,7 +12,11 @@ using Wino.Activation;
using Wino.Calendar.Activation;
using Wino.Calendar.Services;
using Wino.Calendar.ViewModels;
using Wino.Core.Domain;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Exceptions;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Synchronization;
using Wino.Core.UWP;
using Wino.Messaging.Client.Connection;
using Wino.Messaging.Server;
@@ -20,7 +24,7 @@ using Wino.Services;
namespace Wino.Calendar
{
public sealed partial class App : WinoApplication, IRecipient<NewSynchronizationRequested>
public sealed partial class App : WinoApplication, IRecipient<NewCalendarSynchronizationRequested>
{
public override string AppCenterKey => "dfdad6ab-95f9-44cc-9112-45ec6730c49e";
@@ -101,13 +105,6 @@ namespace Wino.Calendar
protected override ActivationHandler<IActivatedEventArgs> GetDefaultActivationHandler()
=> new DefaultActivationHandler();
public void Receive(NewSynchronizationRequested message)
{
}
protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{
base.OnBackgroundActivated(args);
@@ -142,5 +139,20 @@ namespace Wino.Calendar
AppServiceConnectionManager.Connection = null;
}
public async void Receive(NewCalendarSynchronizationRequested message)
{
try
{
var synchronizationResultResponse = await AppServiceConnectionManager.GetResponseAsync<CalendarSynchronizationResult, NewCalendarSynchronizationRequested>(message);
synchronizationResultResponse.ThrowIfFailed();
}
catch (WinoServerException serverException)
{
var dialogService = Services.GetService<ICalendarDialogService>();
dialogService.InfoBarMessage(Translator.Info_SyncFailedTitle, serverException.Message, InfoBarMessageType.Error);
}
}
}
}

View File

@@ -129,7 +129,9 @@ namespace Wino.Calendar.Controls
var childMeasurement = _measurements[child.Item.Id];
double childHeight = Math.Max(0, GetChildHeight(child.Item.StartTime, child.Item.EndTime));
// TODO Math.Max(0, GetChildHeight(child.Item.StartTime, child.Item.EndTime));
// Recurring events may not have an end time. We need to calculate the height based on the start time and duration.
double childHeight = 50;
double childWidth = Math.Max(0, GetChildWidth(childMeasurement, finalSize.Width));
double childTop = Math.Max(0, GetChildTopMargin(child.Item.StartTime, availableHeight));
double childLeft = Math.Max(0, GetChildLeftMargin(childMeasurement, availableWidth));

View File

@@ -19,7 +19,7 @@
<SolidColorBrush x:Key="CalendarFieldSelectedBackgroundBrush">#121212</SolidColorBrush>
<SolidColorBrush x:Key="WinoCalendarViewBorderBrush">#3d3d3d</SolidColorBrush>
<SolidColorBrush x:Key="WinoCalendarViewVisibleDayBackgroundBrush">#30336b</SolidColorBrush>
<SolidColorBrush x:Key="WinoCalendarViewVisibleDayBackgroundBrush">#4b4b4b</SolidColorBrush>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,6 @@ using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls;
using Wino.Calendar.Args;
using Wino.Calendar.Views.Abstract;
using Wino.Core.Domain.Models.Calendar;
using Wino.Messaging.Client.Calendar;
namespace Wino.Calendar.Views
@@ -30,24 +29,15 @@ namespace Wino.Calendar.Views
{
selectedDateTime = e.ClickedDate;
// TODO: Popup is not positioned well on daily view.
TeachingTipPositionerGrid.Width = e.CellSize.Width;
TeachingTipPositionerGrid.Height = e.CellSize.Height;
Canvas.SetLeft(TeachingTipPositionerGrid, e.PositionerPoint.X);
Canvas.SetTop(TeachingTipPositionerGrid, e.PositionerPoint.Y);
WeakReferenceMessenger.Default.Send(new CalendarEventAdded(new CalendarItem(selectedDateTime.Value, default)));
//var t = new Flyout()
//{
// Content = new TextBlock() { Text = "Create event" }
//};
//t.ShowAt(TeachingTipPositionerGrid, new FlyoutShowOptions()
//{
// ShowMode = FlyoutShowMode.Transient,
// Placement = FlyoutPlacementMode.Right
//});
// TODO: End time can be from settings.
// WeakReferenceMessenger.Default.Send(new CalendarEventAdded(new CalendarItem(selectedDateTime.Value, selectedDateTime.Value.AddMinutes(30))));
NewEventTip.IsOpen = true;
}
@@ -71,7 +61,7 @@ namespace Wino.Calendar.Views
var eventEndDate = selectedDateTime.Value.Add(EventTimePicker.Time);
// Create the event.
WeakReferenceMessenger.Default.Send(new CalendarEventAdded(new CalendarItem(selectedDateTime.Value, eventEndDate)));
// WeakReferenceMessenger.Default.Send(new CalendarEventAdded(new CalendarItem(selectedDateTime.Value, eventEndDate)));
}
}
}