private static string GetUriFromFlag(AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall) { string phoneCall = isPhoneCall ? "_phone" : ""; switch (appointmentFlag) { case AppointmentEnums.AppointmentFlag.Today: return($"flag_blue_mini{phoneCall}.png"); case AppointmentEnums.AppointmentFlag.Fixed: return($"flag_red_mini{phoneCall}.png"); case AppointmentEnums.AppointmentFlag.SelectedDay: return($"flag_green_mini{phoneCall}.png"); case AppointmentEnums.AppointmentFlag.MultipleFixed: return("flag_multi_red_mini.png"); case AppointmentEnums.AppointmentFlag.FixedAndSelectedDay: return("flag_multi_red_green_mini.png"); case AppointmentEnums.AppointmentFlag.FixedAndToday: return("flag_multi_red_blue_mini.png"); case AppointmentEnums.AppointmentFlag.MultipleSelectedDay: return("flag_multi_green_mini.png"); case AppointmentEnums.AppointmentFlag.MultipleToday: return("flag_multi_blue_mini.png"); default: return(null); } }
public static string CalculateCustomerFlagIconString(AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall) { var valueReturn = "flag_grey.png"; valueReturn = GetUriFromFlag(appointmentFlag, isPhoneCall) ?? valueReturn; return(ToFlagUri(valueReturn)); }
public static string CalculateCustomerFlagIconStringForMap(AppointmentEnums.AppointmentFlag appointmentFlag, int visitsCreateRecurringAppointments, bool isPhoneCall) { var valueReturn = "map_circle_mini.png"; if (visitsCreateRecurringAppointments == 0) { valueReturn = "flag_up_red_mini.png"; } valueReturn = GetUriFromFlag(appointmentFlag, isPhoneCall) ?? valueReturn; return(ToFlagUri(valueReturn)); }
protected override Task GetRandomAccessStreamReferenceOverride(Color background, Color foregroud, string text, bool multi, AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall, int visitsCreateRecurringAppointments) { if (multi) { AddMulti(); } else { RemomveMulti(); } _polygon.Fill = new SolidColorBrush(background); _textBlock.Foreground = new SolidColorBrush(foregroud); _textBlock.Text = text + text; return(Task.CompletedTask); }
protected override async Task GetRandomAccessStreamReferenceOverride(Color background, Color foregroud, string text, bool multi, AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall, int visitsCreateRecurringAppointments) { string uriString = _switch ? CalculateCustomerFlagIconString(appointmentFlag, isPhoneCall) : CalculateCustomerFlagIconStringForMap(appointmentFlag, visitsCreateRecurringAppointments, isPhoneCall); _image.Source = new BitmapImage(new Uri(uriString)); await _manualResetEvent.WaitAsync(); if (uriString.EndsWith("map_circle_mini.png")) { SetLeft(_textBlock, 13 - text.Length * 1.5); SetTop(_textBlock, 6); } else { SetLeft(_textBlock, 2.5); SetTop(_textBlock, 5); } _switch = !_switch; _textBlock.Foreground = new SolidColorBrush(foregroud); _textBlock.Text = text + text; }
private static string GetId(Color background, Color foregroud, string text, bool multi, AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall, int visitsCreateRecurringAppointments) => $"{background}_{foregroud}_{text}_{multi}_{appointmentFlag}_{isPhoneCall}_{visitsCreateRecurringAppointments}";
protected abstract Task GetRandomAccessStreamReferenceOverride(Color background, Color foregroud, string text, bool multi, AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall, int visitsCreateRecurringAppointments);
public async Task <RandomAccessStreamReference> GetRandomAccessStreamReference(Color background, Color foregroud, string text, bool multi, AppointmentEnums.AppointmentFlag appointmentFlag, bool isPhoneCall, int visitsCreateRecurringAppointments) { if (_disposed) { return(null); } string id = GetId(background, foregroud, text, multi, appointmentFlag, isPhoneCall, visitsCreateRecurringAppointments); if (_randomAccessStreamReferenceById.ContainsKey(id)) { return(_randomAccessStreamReferenceById[id]); } await GetRandomAccessStreamReferenceOverride(background, foregroud, text, multi, appointmentFlag, isPhoneCall, visitsCreateRecurringAppointments); var inMemoryRandomAccessStream = new InMemoryRandomAccessStream(); await SaveUiElementToPngStream(inMemoryRandomAccessStream); if (_disposed) { return(null); } StorageFile storageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync($"{id}.png", CreationCollisionOption.ReplaceExisting); using (IRandomAccessStream randomAccessStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite)) { await RandomAccessStream.CopyAndCloseAsync(inMemoryRandomAccessStream.GetInputStreamAt(0), randomAccessStream.GetOutputStreamAt(0)); } _inMemoryRandomAccessStreams.Add(inMemoryRandomAccessStream); return(_randomAccessStreamReferenceById[id] = RandomAccessStreamReference.CreateFromStream(inMemoryRandomAccessStream)); }