/// <summary> /// Setting with url, query and path params and toaster settings /// </summary> /// <param name="url"></param> /// <param name="queryParameters"></param> /// <param name="pathParameters"></param> /// <param name="toasterSettings"></param> public HttpSettings(string url, HttpQueryParameters queryParameters, HttpPathParameters pathParameters, ToasterSettings toasterSettings) { this.SetUrl(url); this.QueryParameters = queryParameters ?? new HttpQueryParameters(); this.PathParameters = pathParameters ?? new HttpPathParameters(); this.ToasterSettings = toasterSettings ?? new ToasterSettings(); }
private Severity GetType(ToasterSettings settings) { Severity type = Severity.Normal; switch (settings.Type) { case ToasterType.Success: type = Severity.Success; break; case ToasterType.Error: type = Severity.Error; break; case ToasterType.Warning: type = Severity.Warning; break; case ToasterType.Info: type = Severity.Info; break; } return(type); }
/// <summary> /// Settins only with url. /// </summary> /// <param name="url">Url</param> public HttpSettings(string url) { this.SetUrl(url); this.QueryParameters = new HttpQueryParameters(); this.PathParameters = new HttpPathParameters(); this.ToasterSettings = new ToasterSettings(); }
/// <summary> /// Setting with url, query and path params and toaster caption /// </summary> /// <param name="url"></param> /// <param name="queryParameters"></param> /// <param name="pathParameters"></param> /// <param name="toasterCaption"></param> public HttpSettings(string url, HttpQueryParameters queryParameters, HttpPathParameters pathParameters, string toasterCaption) { this.SetUrl(url); this.QueryParameters = queryParameters ?? new HttpQueryParameters(); this.PathParameters = pathParameters ?? new HttpPathParameters(); this.ToasterSettings = string.IsNullOrEmpty(toasterCaption) ? new ToasterSettings() : new ToasterSettings(toasterCaption); }
/** * Add toaster to HTTP settings * <param name="settings">Toaster settings</param> */ public void AddToaster(ToasterSettings settings) { if (settings != null) { ToasterSettings = settings; } }
public MainWindow() { InitializeComponent(); _savedSettings = new SavedSettings(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "toast.settings")); _savedSettings.AutoSaveOnAddOrRemove = true; _savedSettings.Load(); Types.Items.Add("Custom"); Types.Items.Add("Info"); Types.Items.Add("Success"); Types.Items.Add("Warning"); Types.Items.Add("Error"); Types.SelectionChanged += (s, e) => { Properties.Settings.Default.type = Types.SelectedItem as string; Properties.Settings.Default.Save(); var type = (string)Types.SelectedItem; if (type == "Custom") { ToastSettings.IsEnabled = true; ToasterSettings.IsEnabled = true; } else { ToastSettings.IsEnabled = false; ToasterSettings.IsEnabled = false; } }; if (string.IsNullOrWhiteSpace(Properties.Settings.Default.type)) { Types.SelectedIndex = 0; } else { var index = Types.Items.IndexOf(Properties.Settings.Default.type); if (index < 0) { index = 0; } Types.SelectedIndex = index; } ToastSettings.SettingsUpdated += ToastSettingsOnSettingsUpdated; ToasterSettings.SettingsUpdated += ToastSettingsOnSettingsUpdated; Loaded += (s, e) => { var toastSettings = GetToastSettings(); var toasterSettings = GetToasterSettings(); ToastSettings.Initialize(toastSettings, _savedSettings); ToasterSettings.Initialize(toasterSettings, _savedSettings); _toaster = new Toaster(this, ToasterSettings.Settings, null, ToastSettings.Settings); }; }
/** * Add toaster to HTTP settings * <param name="caption">Caption</param> */ public void AddToaster(string caption) { ToasterSettings = new ToasterSettings { Caption = caption, IsNeeded = true }; }
public Toaster(Window window, ToasterSettings settings = null, Func <string, string, UIElement> getDefaultView = null, ToastAdornerSettings defaultToastSettings = null) { _getDefaultView = getDefaultView ?? DefaultSettings.GetDefaultToastViewFunc; _adornerLayer = GetWindowAdornerLayer(window, out var elementToAdorn); _settings = settings ?? DefaultSettings.DefaultToasterSettings; DefaultToastSettings = defaultToastSettings ?? DefaultSettings.DefaultToastSettings; ElementToAdorn = elementToAdorn; Window = window; }
void ToasterSettings_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!(ToasterSettings.SelectedItem is ToasterSettings setting)) { return; } Settings = setting; OnSettingChanged(); }
public async Task <bool> SendFriendRequestResponse(FriendRequestResponseModel model) { var toaster = new ToasterSettings("Friend request answering"); var settings = new HttpSettings($"{this._url}/request", null, null, toaster); var body = new HttpBody <FriendRequestResponseModel>(model); return(await this._httpService.Update <FriendRequestResponseModel>(settings, body)); }
ToasterSettings GetToasterSettings() { ToasterSettings toasterSettings = null; if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.toasterSettingsName)) { toasterSettings = _savedSettings.GetToasterSettings(Properties.Settings.Default.toasterSettingsName); } return(toasterSettings ?? Defaults.DefaultSettings.DefaultToasterSettings); }
public async Task <bool> RemoveFriend(string friendId) { var pathParams = new HttpPathParameters(); pathParams.Add <string>(friendId, -1); var toaster = new ToasterSettings("Friend removing"); var settings = new HttpSettings($"{this._url}", null, pathParams, toaster); return(await this._httpService.Delete(settings)); }
public void Initialize(ToasterSettings settings, SavedSettings savedSettings) { Settings = settings; _savedSettings = savedSettings; foreach (var setting in savedSettings.ToasterSettings) { ToasterSettings.Items.Add(setting); } ToasterSettings.SelectedItem = Settings; InitValues(); }
void Delete_OnClick(object sender, RoutedEventArgs e) { if (Settings.Name == "default") { return; } _savedSettings.RemoveSettings(Settings); ToasterSettings.Items.Remove(Settings); Settings = _savedSettings.ToasterSettings.FirstOrDefault(); ToasterSettings.SelectedItem = Settings; OnSettingChanged(); }
static DefaultToasterSettingsProvider() { DefaultToasterSettings = new ToasterSettings("default") { LeaveStyle = LeaveStyle.FadeOut, EnterLocation = Location.BottomRight, EnterFromDirection = Direction.Down, HorizontalAdjustment = -15, MoveDuration = 500, VerticalPadding = 15, QueueToasts = true, MoveStyle = MoveStyle.Push, MoveDirection = Direction.Up, EnterStyle = EnterStyle.SlideIn }; }
public ToasterSettingsView(ToasterSettings settings, SavedSettings savedSettings) { InitializeComponent(); _savedSettings = savedSettings; if (_savedSettings != null) { foreach (var setting in _savedSettings.ToasterSettings) { ToasterSettings.Items.Add(setting); } } foreach (var dir in Enum.GetValues(typeof(Direction)).Cast <Direction>()) { EnterFromDirection.Items.Add(dir); LeaveDirection.Items.Add(dir); MoveDirection.Items.Add(dir); } foreach (var style in Enum.GetValues(typeof(MoveStyle)).Cast <MoveStyle>()) { MoveStyle.Items.Add(style); } foreach (var style in Enum.GetValues(typeof(EnterStyle)).Cast <EnterStyle>()) { EnterStyle.Items.Add(style); } foreach (var loc in Enum.GetValues(typeof(Location)).Cast <Location>()) { ToastLocation.Items.Add(loc); } foreach (var style in Enum.GetValues(typeof(LeaveStyle)).Cast <LeaveStyle>()) { LeaveStyle.Items.Add(style); } Settings = settings; if (Settings != null) { InitValues(); } }
void SaveAs_OnClick(object sender, RoutedEventArgs e) { var getName = new GetNameView(); getName.ShowDialog(); if (string.IsNullOrWhiteSpace(getName.SelectedName)) { return; } if (_savedSettings.ToastSettings.Any(p => p.Name == getName.SelectedName)) { MessageBox.Show("A settings file with that name already exists."); return; } Settings = Settings.Clone(getName.SelectedName); SettingsName.Text = getName.SelectedName; DoSave(); _savedSettings.AddSettings(Settings); ToasterSettings.Items.Add(Settings); OnSettingChanged(); }
private string GenerateString(ToasterSettings settings) { return($"<h5>{settings.Caption}</h5><h6>{settings.Message}</h6>"); }
public ToasterManager(ToasterSettings settings = null, Func <string, string, UIElement> getDefaultView = null, ToastAdornerSettings defaultToastSettings = null) { _settings = settings; _getDefaultView = getDefaultView; _defaultToastSettings = defaultToastSettings; }
/// <summary> /// Open toaster /// </summary> /// <param name="settings">Toaster Settings</param> public void Open(ToasterSettings settings) { _snackbar.Add(GenerateString(settings), GetType(settings)); }