Compare commits
1 Commits
feature/Da
...
fix/win2d-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1463dfeb9 |
@@ -142,7 +142,5 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel
|
||||
};
|
||||
|
||||
var synchronizationResponse = await WinoServerConnectionManager.GetResponseAsync<CalendarSynchronizationResult, NewCalendarSynchronizationRequested>(new NewCalendarSynchronizationRequested(synchronizationOptions, SynchronizationSource.Client));
|
||||
accountCreationDialog.Complete(cancel: false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,20 +237,20 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
|
||||
{
|
||||
var durationSeconds = (QuickEventEndTime - QuickEventStartTime).TotalSeconds;
|
||||
|
||||
//var testCalendarItem = new CalendarItem
|
||||
//{
|
||||
// CalendarId = SelectedQuickEventAccountCalendar.Id,
|
||||
// StartDate = QuickEventStartTime,
|
||||
// DurationInSeconds = durationSeconds,
|
||||
// CreatedAt = DateTime.UtcNow,
|
||||
// Description = string.Empty,
|
||||
// Location = Location,
|
||||
// Title = EventName,
|
||||
// Id = Guid.NewGuid()
|
||||
//};
|
||||
var testCalendarItem = new CalendarItem
|
||||
{
|
||||
CalendarId = SelectedQuickEventAccountCalendar.Id,
|
||||
StartDate = QuickEventStartTime,
|
||||
DurationInSeconds = durationSeconds,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
Description = string.Empty,
|
||||
Location = Location,
|
||||
Title = EventName,
|
||||
Id = Guid.NewGuid()
|
||||
};
|
||||
|
||||
//IsQuickEventDialogOpen = false;
|
||||
//await _calendarService.CreateNewCalendarItemAsync(testCalendarItem, null);
|
||||
IsQuickEventDialogOpen = false;
|
||||
await _calendarService.CreateNewCalendarItemAsync(testCalendarItem, null);
|
||||
|
||||
// TODO: Create the request with the synchronizer.
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ public partial class CalendarItemViewModel : ObservableObject, ICalendarItem, IC
|
||||
|
||||
public IAccountCalendar AssignedCalendar => CalendarItem.AssignedCalendar;
|
||||
|
||||
public DateTime StartDate => CalendarItem.StartDate;
|
||||
public DateTime StartDate { get => CalendarItem.StartDate; set => CalendarItem.StartDate = value; }
|
||||
|
||||
public DateTime EndDate => CalendarItem.EndDate;
|
||||
|
||||
public double DurationInSeconds => CalendarItem.DurationInSeconds;
|
||||
public double DurationInSeconds { get => CalendarItem.DurationInSeconds; set => CalendarItem.DurationInSeconds = value; }
|
||||
|
||||
public ITimePeriod Period => CalendarItem.Period;
|
||||
|
||||
|
||||
@@ -17,23 +17,24 @@ public class CalendarItem : ICalendarItem
|
||||
public string Description { get; set; }
|
||||
public string Location { get; set; }
|
||||
|
||||
public string StartTimeOffset { get; set; }
|
||||
public string EndTimeOffset { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
public DateTimeOffset StartDateTimeOffset => DateTimeOffset.Parse(StartTimeOffset);
|
||||
public DateTimeOffset EndDateTimeOffsete => DateTimeOffset.Parse(EndTimeOffset);
|
||||
public DateTime EndDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return StartDate.AddSeconds(DurationInSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime StartDate => StartDateTimeOffset.DateTime;//TimeZoneInfo.ConvertTime(StartDateTimeOffset, TimeZoneInfo.Local).DateTime;
|
||||
public DateTime EndDate => EndDateTimeOffsete.DateTime;// TimeZoneInfo.ConvertTime(, TimeZoneInfo.Local).DateTime;
|
||||
public TimeSpan StartDateOffset { get; set; }
|
||||
public TimeSpan EndDateOffset { get; set; }
|
||||
|
||||
private ITimePeriod _period;
|
||||
public ITimePeriod Period
|
||||
{
|
||||
get
|
||||
{
|
||||
// Period must be loaded by user's current UI culture based on StartDateTimeOffset and EndDateTimeOffset
|
||||
// Get the time zone corresponding to the current culture
|
||||
|
||||
_period ??= new TimeRange(StartDate, EndDate);
|
||||
|
||||
return _period;
|
||||
@@ -93,7 +94,7 @@ public class CalendarItem : ICalendarItem
|
||||
}
|
||||
}
|
||||
|
||||
public double DurationInSeconds => Period.Duration.TotalSeconds;
|
||||
public double DurationInSeconds { get; set; }
|
||||
public string Recurrence { get; set; }
|
||||
|
||||
public string OrganizerDisplayName { get; set; }
|
||||
@@ -143,7 +144,7 @@ public class CalendarItem : ICalendarItem
|
||||
/// </summary>
|
||||
public Guid EventTrackingId => IsOccurrence ? RecurringCalendarItemId.Value : Id;
|
||||
|
||||
public CalendarItem CreateRecurrence(DateTimeOffset startDateOffset, DateTimeOffset endDateOffset)
|
||||
public CalendarItem CreateRecurrence(DateTime startDate, double durationInSeconds)
|
||||
{
|
||||
// Create a copy with the new start date and duration
|
||||
|
||||
@@ -153,8 +154,8 @@ public class CalendarItem : ICalendarItem
|
||||
Title = Title,
|
||||
Description = Description,
|
||||
Location = Location,
|
||||
StartTimeOffset = startDateOffset.ToString("o"),
|
||||
EndTimeOffset = endDateOffset.ToString("o"),
|
||||
StartDate = startDate,
|
||||
DurationInSeconds = durationInSeconds,
|
||||
Recurrence = Recurrence,
|
||||
OrganizerDisplayName = OrganizerDisplayName,
|
||||
OrganizerEmail = OrganizerEmail,
|
||||
@@ -167,6 +168,8 @@ public class CalendarItem : ICalendarItem
|
||||
Status = Status,
|
||||
CustomEventColorHex = CustomEventColorHex,
|
||||
HtmlLink = HtmlLink,
|
||||
StartDateOffset = StartDateOffset,
|
||||
EndDateOffset = EndDateOffset,
|
||||
RemoteEventId = RemoteEventId,
|
||||
IsHidden = IsHidden,
|
||||
IsLocked = IsLocked,
|
||||
|
||||
@@ -8,9 +8,9 @@ public interface ICalendarItem
|
||||
string Title { get; }
|
||||
Guid Id { get; }
|
||||
IAccountCalendar AssignedCalendar { get; }
|
||||
DateTime StartDate { get; }
|
||||
DateTime StartDate { get; set; }
|
||||
DateTime EndDate { get; }
|
||||
double DurationInSeconds { get; }
|
||||
double DurationInSeconds { get; set; }
|
||||
ITimePeriod Period { get; }
|
||||
|
||||
bool IsAllDayEvent { get; }
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas.Printing;
|
||||
using Windows.Data.Pdf;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.Graphics.Printing;
|
||||
using Windows.Graphics.Printing.OptionDetails;
|
||||
using Windows.Storage.Streams;
|
||||
@@ -135,6 +136,11 @@ public class PrintService : IPrintService
|
||||
|
||||
private async void OnDocumentTaskOptionsChanged(CanvasPrintDocument sender, CanvasPrintTaskOptionsChangedEventArgs args)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged starting...");
|
||||
DisplayInformation di = DisplayInformation.GetForCurrentView();
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.RawPixelsPerViewPixel: {di.RawPixelsPerViewPixel}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.LogicalDpi: {di.LogicalDpi}");
|
||||
|
||||
var deferral = args.GetDeferral();
|
||||
|
||||
try
|
||||
@@ -142,6 +148,10 @@ public class PrintService : IPrintService
|
||||
await LoadPDFPageBitmapsAsync(sender);
|
||||
|
||||
var pageDesc = args.PrintTaskOptions.GetPageDescription(1);
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Width (DIPs): {pageDesc.PageSize.Width}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Height (DIPs): {pageDesc.PageSize.Height}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiX: {pageDesc.DpiX}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiY: {pageDesc.DpiY}");
|
||||
var newPageSize = pageDesc.PageSize.ToVector2();
|
||||
|
||||
if (pageSize == newPageSize && pageCount != -1)
|
||||
@@ -176,6 +186,10 @@ public class PrintService : IPrintService
|
||||
// Calculate the page count
|
||||
bitmapCount = bitmaps.Count;
|
||||
pageCount = (int)Math.Ceiling(bitmapCount / (double)bitmapsPerPage);
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated columns: {columns}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated rows: {rows}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated bitmapsPerPage: {bitmapsPerPage}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated pageCount: {pageCount}");
|
||||
sender.SetPageCount((uint)pageCount);
|
||||
|
||||
// Set the preview page to the one that has the item that was currently displayed in the last preview
|
||||
@@ -185,11 +199,31 @@ public class PrintService : IPrintService
|
||||
{
|
||||
deferral.Complete();
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged finished.");
|
||||
}
|
||||
|
||||
|
||||
private async Task LoadPDFPageBitmapsAsync(CanvasPrintDocument sender)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync starting...");
|
||||
DisplayInformation displayInfo = DisplayInformation.GetForCurrentView();
|
||||
float rawPixelsPerViewPixel = (float)displayInfo.RawPixelsPerViewPixel;
|
||||
if (rawPixelsPerViewPixel == 0)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Warning: RawPixelsPerViewPixel was 0, defaulting to 1.0f");
|
||||
rawPixelsPerViewPixel = 1.0f; // Sanity check
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.RawPixelsPerViewPixel: {rawPixelsPerViewPixel}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.LogicalDpi: {displayInfo.LogicalDpi}");
|
||||
|
||||
float printerDpi = sender.Dpi;
|
||||
if (printerDpi == 0)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Warning: sender.Dpi (printerDpi) was 0, defaulting to 96.0f");
|
||||
printerDpi = 96.0f; // Sanity check
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] sender.Dpi (CanvasPrintDocument.Dpi, used as PrinterDPI): {printerDpi}");
|
||||
|
||||
ClearBitmaps();
|
||||
|
||||
bitmaps ??= new List<CanvasBitmap>();
|
||||
@@ -197,10 +231,39 @@ public class PrintService : IPrintService
|
||||
for (int i = 0; i < pdfDocument.PageCount; i++)
|
||||
{
|
||||
var page = pdfDocument.GetPage((uint)i);
|
||||
var stream = new InMemoryRandomAccessStream();
|
||||
await page.RenderToStreamAsync(stream);
|
||||
var bitmap = await CanvasBitmap.LoadAsync(sender, stream);
|
||||
bitmaps.Add(bitmap);
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Processing page.Index: {page.Index}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Width (PDF points): {page.Dimensions.MediaBox.Width}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Height (PDF points): {page.Dimensions.MediaBox.Height}");
|
||||
|
||||
double pageWidthInPoints = page.Dimensions.MediaBox.Width;
|
||||
double pageHeightInPoints = page.Dimensions.MediaBox.Height;
|
||||
|
||||
double pageWidthInInches = pageWidthInPoints / 72.0;
|
||||
double pageHeightInInches = pageHeightInPoints / 72.0;
|
||||
|
||||
// Calculate the desired pixel dimensions of the bitmap based on printer DPI
|
||||
uint targetPixelWidth = (uint)(pageWidthInInches * printerDpi);
|
||||
uint targetPixelHeight = (uint)(pageHeightInInches * printerDpi);
|
||||
|
||||
// Calculate DestinationWidth/Height for PdfPageRenderOptions in DIPs
|
||||
PdfPageRenderOptions options = new PdfPageRenderOptions();
|
||||
options.DestinationWidth = (uint)(targetPixelWidth / rawPixelsPerViewPixel);
|
||||
options.DestinationHeight = (uint)(targetPixelHeight / rawPixelsPerViewPixel);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, Calculated PdfPageRenderOptions.DestinationWidth (DIPs): {options.DestinationWidth}, DestinationHeight (DIPs): {options.DestinationHeight}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, TargetPixelWidth: {targetPixelWidth}, TargetPixelHeight: {targetPixelHeight}");
|
||||
|
||||
using (var stream = new InMemoryRandomAccessStream())
|
||||
{
|
||||
await page.RenderToStreamAsync(stream, options); // Use the options
|
||||
var bitmap = await CanvasBitmap.LoadAsync(sender, stream);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Width: {bitmap.SizeInPixels.Width}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Height: {bitmap.SizeInPixels.Height}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.Dpi: {bitmap.Dpi}");
|
||||
|
||||
bitmaps.Add(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
largestBitmap = Vector2.Zero;
|
||||
@@ -210,6 +273,7 @@ public class PrintService : IPrintService
|
||||
largestBitmap.X = Math.Max(largestBitmap.X, (float)bitmap.Size.Width);
|
||||
largestBitmap.Y = Math.Max(largestBitmap.Y, (float)bitmap.Size.Height);
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync finished.");
|
||||
}
|
||||
|
||||
|
||||
@@ -262,4 +326,153 @@ public class PrintService : IPrintService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- START SIMULATION CODE ---
|
||||
private async Task RunSimulationAsync(float simulatedRawPixelsPerViewPixel, string callingMethodName)
|
||||
{
|
||||
// --- Simulate LoadPDFPageBitmapsAsync ---
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] SIMULATING from {callingMethodName} for {simulatedRawPixelsPerViewPixel}");
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync starting...");
|
||||
|
||||
// Mock DisplayInformation
|
||||
float actualRawPixelsPerViewPixel = simulatedRawPixelsPerViewPixel; // Override
|
||||
if (actualRawPixelsPerViewPixel == 0)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Warning: actualRawPixelsPerViewPixel was 0, defaulting to 1.0f");
|
||||
actualRawPixelsPerViewPixel = 1.0f; // Sanity check
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.RawPixelsPerViewPixel: {actualRawPixelsPerViewPixel}");
|
||||
// LogicalDpi is not directly used in calculations we are testing, so we can use a placeholder.
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.LogicalDpi: 96.0f (Simulated)");
|
||||
|
||||
|
||||
// Mock CanvasPrintDocument sender for DPI
|
||||
float printerDpi = 300.0f; // As per subtask
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] sender.Dpi (CanvasPrintDocument.Dpi, used as PrinterDPI): {printerDpi}");
|
||||
|
||||
// Clear any previous simulation state for bitmaps
|
||||
// In a real scenario, ClearBitmaps() would be called. Here we just reset relevant fields.
|
||||
this.bitmaps.Clear(); // Assuming 'bitmaps' is the List<CanvasBitmap>
|
||||
this.largestBitmap = Vector2.Zero;
|
||||
|
||||
|
||||
// Simulate pdfDocument.PageCount = 1 and loop once
|
||||
int simulatedPageCount = 1;
|
||||
for (int i = 0; i < simulatedPageCount; i++)
|
||||
{
|
||||
// Mock PdfPage
|
||||
uint pageIndex = (uint)i;
|
||||
double pageWidthInPoints = 612.0; // Letter size
|
||||
double pageHeightInPoints = 792.0; // Letter size
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Processing page.Index: {pageIndex}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Width (PDF points): {pageWidthInPoints}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Height (PDF points): {pageHeightInPoints}");
|
||||
|
||||
double pageWidthInInches = pageWidthInPoints / 72.0;
|
||||
double pageHeightInInches = pageHeightInPoints / 72.0;
|
||||
|
||||
uint targetPixelWidth = (uint)(pageWidthInInches * printerDpi);
|
||||
uint targetPixelHeight = (uint)(pageHeightInInches * printerDpi);
|
||||
|
||||
PdfPageRenderOptions options = new PdfPageRenderOptions();
|
||||
options.DestinationWidth = (uint)(targetPixelWidth / actualRawPixelsPerViewPixel);
|
||||
options.DestinationHeight = (uint)(targetPixelHeight / actualRawPixelsPerViewPixel);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, Calculated PdfPageRenderOptions.DestinationWidth (DIPs): {options.DestinationWidth}, DestinationHeight (DIPs): {options.DestinationHeight}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, TargetPixelWidth: {targetPixelWidth}, TargetPixelHeight: {targetPixelHeight}");
|
||||
|
||||
// Mock CanvasBitmap properties (as we can't actually render)
|
||||
uint mockBitmapSizeInPixelsWidth = targetPixelWidth;
|
||||
uint mockBitmapSizeInPixelsHeight = targetPixelHeight;
|
||||
float mockBitmapDpi = printerDpi;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Width: {mockBitmapSizeInPixelsWidth} (Simulated)");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Height: {mockBitmapSizeInPixelsHeight} (Simulated)");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.Dpi: {mockBitmapDpi} (Simulated)");
|
||||
|
||||
// Simulate adding to bitmaps list and tracking largest
|
||||
// We don't add a real CanvasBitmap, just update what's needed for OnDocumentTaskOptionsChanged
|
||||
this.largestBitmap.X = Math.Max(this.largestBitmap.X, mockBitmapSizeInPixelsWidth);
|
||||
this.largestBitmap.Y = Math.Max(this.largestBitmap.Y, mockBitmapSizeInPixelsHeight);
|
||||
// bitmaps.Add(null); // Not adding real bitmaps
|
||||
}
|
||||
this.bitmapCount = simulatedPageCount; // Set based on simulation
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync finished.");
|
||||
|
||||
// --- Simulate OnDocumentTaskOptionsChanged ---
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged starting...");
|
||||
// DisplayInformation logs already done in LoadPDFPageBitmapsAsync simulation part
|
||||
|
||||
// Mock PageDescription (from PrintTaskOptions)
|
||||
// For Letter paper (8.5x11 inches) at 300 DPI:
|
||||
// Pixel size = (8.5*300) x (11*300) = 2550 x 3300 pixels
|
||||
// DIP size = (PixelSize / rawPixelsPerViewPixel)
|
||||
float pageDescPageSizeWidth = (2550.0f / actualRawPixelsPerViewPixel);
|
||||
float pageDescPageSizeHeight = (3300.0f / actualRawPixelsPerViewPixel);
|
||||
float pageDescDpiX = 300.0f;
|
||||
float pageDescDpiY = 300.0f;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Width (DIPs): {pageDescPageSizeWidth} (Simulated)");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Height (DIPs): {pageDescPageSizeHeight} (Simulated)");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiX: {pageDescDpiX} (Simulated)");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiY: {pageDescDpiY} (Simulated)");
|
||||
|
||||
this.pageSize = new Vector2(pageDescPageSizeWidth, pageDescPageSizeHeight);
|
||||
// sender.InvalidatePreview(); // Cannot call
|
||||
|
||||
// Calculate the new layout
|
||||
var printablePageSize = this.pageSize * 0.9f; // Assuming default behavior
|
||||
this.imagePadding = new Vector2(64, 64); // Default from class
|
||||
this.cellSize = this.largestBitmap + this.imagePadding;
|
||||
|
||||
var cellsPerPage = printablePageSize / this.cellSize;
|
||||
|
||||
this.columns = Math.Max(1, (int)Math.Floor(cellsPerPage.X));
|
||||
this.rows = Math.Max(1, (int)Math.Floor(cellsPerPage.Y));
|
||||
this.bitmapsPerPage = this.columns * this.rows;
|
||||
this.pageCount = (int)Math.Ceiling(this.bitmapCount / (double)this.bitmapsPerPage);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated columns: {this.columns}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated rows: {this.rows}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated bitmapsPerPage: {this.bitmapsPerPage}");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated pageCount: {this.pageCount}");
|
||||
// sender.SetPageCount((uint)this.pageCount); // Cannot call
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged finished.");
|
||||
System.Diagnostics.Debug.WriteLine($"[PrintService] SIMULATION END for {simulatedRawPixelsPerViewPixel}");
|
||||
System.Diagnostics.Debug.WriteLine("---"); // Separator
|
||||
}
|
||||
|
||||
public async Task SimulatePrintScalingAsync()
|
||||
{
|
||||
// Temporarily store and clear global state that might interfere
|
||||
var originalBitmaps = new List<CanvasBitmap>(this.bitmaps);
|
||||
var originalLargestBitmap = this.largestBitmap;
|
||||
var originalPageSize = this.pageSize;
|
||||
var originalCellSize = this.cellSize;
|
||||
int originalBitmapCount = this.bitmapCount;
|
||||
int originalColumns = this.columns;
|
||||
int originalRows = this.rows;
|
||||
int originalBitmapsPerPage = this.bitmapsPerPage;
|
||||
int originalPageCount = this.pageCount;
|
||||
|
||||
|
||||
await RunSimulationAsync(1.0f, nameof(SimulatePrintScalingAsync));
|
||||
await RunSimulationAsync(1.25f, nameof(SimulatePrintScalingAsync));
|
||||
await RunSimulationAsync(1.5f, nameof(SimulatePrintScalingAsync));
|
||||
|
||||
// Restore original state if necessary, though for this task it's just about logs
|
||||
this.bitmaps = originalBitmaps;
|
||||
this.largestBitmap = originalLargestBitmap;
|
||||
this.pageSize = originalPageSize;
|
||||
this.cellSize = originalCellSize;
|
||||
this.bitmapCount = originalBitmapCount;
|
||||
this.columns = originalColumns;
|
||||
this.rows = originalRows;
|
||||
this.bitmapsPerPage = originalBitmapsPerPage;
|
||||
this.pageCount = originalPageCount;
|
||||
}
|
||||
// --- END SIMULATION CODE ---
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public static class GoogleIntegratorExtensions
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public static DateTimeOffset GetEventDateTimeOffset(EventDateTime calendarEvent)
|
||||
public static DateTimeOffset? GetEventDateTimeOffset(EventDateTime calendarEvent)
|
||||
{
|
||||
if (calendarEvent != null)
|
||||
{
|
||||
@@ -212,7 +212,7 @@ public static class GoogleIntegratorExtensions
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Invalid date format in Google Calendar event date.");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -66,6 +66,12 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
|
||||
var eventStartDateTimeOffset = GoogleIntegratorExtensions.GetEventDateTimeOffset(calendarEvent.Start);
|
||||
var eventEndDateTimeOffset = GoogleIntegratorExtensions.GetEventDateTimeOffset(calendarEvent.End);
|
||||
|
||||
double totalDurationInSeconds = 0;
|
||||
|
||||
if (eventStartDateTimeOffset != null && eventEndDateTimeOffset != null)
|
||||
{
|
||||
totalDurationInSeconds = (eventEndDateTimeOffset.Value - eventStartDateTimeOffset.Value).TotalSeconds;
|
||||
}
|
||||
|
||||
CalendarItem calendarItem = null;
|
||||
|
||||
@@ -74,6 +80,12 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
|
||||
// Exceptions of parent events might not have all the fields populated.
|
||||
// We must use the parent event's data for fields that don't exists.
|
||||
|
||||
// Update duration if it's not populated.
|
||||
if (totalDurationInSeconds == 0)
|
||||
{
|
||||
totalDurationInSeconds = parentRecurringEvent.DurationInSeconds;
|
||||
}
|
||||
|
||||
var organizerMail = GetOrganizerEmail(calendarEvent, organizerAccount);
|
||||
var organizerName = GetOrganizerName(calendarEvent, organizerAccount);
|
||||
|
||||
@@ -84,8 +96,10 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
Description = calendarEvent.Description ?? parentRecurringEvent.Description,
|
||||
Id = Guid.NewGuid(),
|
||||
StartTimeOffset = eventStartDateTimeOffset.ToString("o"),
|
||||
EndTimeOffset = eventEndDateTimeOffset.ToString("o"),
|
||||
StartDate = eventStartDateTimeOffset.Value.DateTime,
|
||||
StartDateOffset = eventStartDateTimeOffset.Value.Offset,
|
||||
EndDateOffset = eventEndDateTimeOffset?.Offset ?? parentRecurringEvent.EndDateOffset,
|
||||
DurationInSeconds = totalDurationInSeconds,
|
||||
Location = string.IsNullOrEmpty(calendarEvent.Location) ? parentRecurringEvent.Location : calendarEvent.Location,
|
||||
|
||||
// Leave it empty if it's not populated.
|
||||
@@ -106,14 +120,22 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
|
||||
// This is a parent event creation.
|
||||
// Start-End dates are guaranteed to be populated.
|
||||
|
||||
if (eventStartDateTimeOffset == null || eventEndDateTimeOffset == null)
|
||||
{
|
||||
Log.Error("Failed to create parent event because either start or end date is not specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
calendarItem = new CalendarItem()
|
||||
{
|
||||
CalendarId = assignedCalendar.Id,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
Description = calendarEvent.Description,
|
||||
Id = Guid.NewGuid(),
|
||||
StartTimeOffset = eventStartDateTimeOffset.ToString("o"),
|
||||
EndTimeOffset = eventEndDateTimeOffset.ToString("o"),
|
||||
StartDate = eventStartDateTimeOffset.Value.DateTime,
|
||||
StartDateOffset = eventStartDateTimeOffset.Value.Offset,
|
||||
EndDateOffset = eventEndDateTimeOffset.Value.Offset,
|
||||
DurationInSeconds = totalDurationInSeconds,
|
||||
Location = calendarEvent.Location,
|
||||
Recurrence = GoogleIntegratorExtensions.GetRecurrenceString(calendarEvent),
|
||||
Status = GetStatus(calendarEvent.Status),
|
||||
|
||||
@@ -61,21 +61,18 @@ public class OutlookChangeProcessor(IDatabaseService databaseService,
|
||||
DateTimeOffset eventStartDateTimeOffset = OutlookIntegratorExtensions.GetDateTimeOffsetFromDateTimeTimeZone(calendarEvent.Start);
|
||||
DateTimeOffset eventEndDateTimeOffset = OutlookIntegratorExtensions.GetDateTimeOffsetFromDateTimeTimeZone(calendarEvent.End);
|
||||
|
||||
|
||||
var durationInSeconds = (eventEndDateTimeOffset - eventStartDateTimeOffset).TotalSeconds;
|
||||
|
||||
savingItem.RemoteEventId = calendarEvent.Id;
|
||||
savingItem.StartTimeOffset = eventStartDateTimeOffset.ToString("O");
|
||||
savingItem.EndTimeOffset = eventEndDateTimeOffset.ToString("O");
|
||||
savingItem.StartDate = eventStartDateTimeOffset.DateTime;
|
||||
savingItem.StartDateOffset = eventStartDateTimeOffset.Offset;
|
||||
savingItem.EndDateOffset = eventEndDateTimeOffset.Offset;
|
||||
savingItem.DurationInSeconds = durationInSeconds;
|
||||
|
||||
savingItem.Title = calendarEvent.Subject;
|
||||
savingItem.Description = calendarEvent.Body?.Content;
|
||||
savingItem.Location = calendarEvent.Location?.DisplayName;
|
||||
|
||||
if (savingItem.Title.Contains("Atatürk"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (calendarEvent.Type == EventType.Exception && !string.IsNullOrEmpty(calendarEvent.SeriesMasterId))
|
||||
{
|
||||
// This is a recurring event exception.
|
||||
|
||||
@@ -160,7 +160,7 @@ public class CalendarService : BaseDatabaseService, ICalendarService
|
||||
// There is no exception for the period.
|
||||
// Change the instance StartDate and Duration.
|
||||
|
||||
var recurrence = ev.CreateRecurrence(occurrence.Period.StartTime.Value, occurrence.Period.EndTime.Value);
|
||||
var recurrence = ev.CreateRecurrence(occurrence.Period.StartTime.Value, occurrence.Period.Duration.TotalSeconds);
|
||||
|
||||
result.Add(recurrence);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user