Esempio n. 1
0
 /// <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();
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 /// <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();
 }
Esempio n. 4
0
 /// <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);
 }
Esempio n. 5
0
 /**
  * Add toaster to HTTP settings
  * <param name="settings">Toaster settings</param>
  */
 public void AddToaster(ToasterSettings settings)
 {
     if (settings != null)
     {
         ToasterSettings = settings;
     }
 }
Esempio n. 6
0
        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);
            };
        }
Esempio n. 7
0
 /**
  * Add toaster to HTTP settings
  * <param name="caption">Caption</param>
  */
 public void AddToaster(string caption)
 {
     ToasterSettings = new ToasterSettings
     {
         Caption  = caption,
         IsNeeded = true
     };
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 void ToasterSettings_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(ToasterSettings.SelectedItem is ToasterSettings setting))
     {
         return;
     }
     Settings = setting;
     OnSettingChanged();
 }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
        ToasterSettings GetToasterSettings()
        {
            ToasterSettings toasterSettings = null;

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.toasterSettingsName))
            {
                toasterSettings = _savedSettings.GetToasterSettings(Properties.Settings.Default.toasterSettingsName);
            }
            return(toasterSettings ?? Defaults.DefaultSettings.DefaultToasterSettings);
        }
Esempio n. 12
0
        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));
        }
Esempio n. 13
0
        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();
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
 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
     };
 }
Esempio n. 16
0
        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();
            }
        }
Esempio n. 17
0
        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();
        }
Esempio n. 18
0
 private string GenerateString(ToasterSettings settings)
 {
     return($"<h5>{settings.Caption}</h5><h6>{settings.Message}</h6>");
 }
Esempio n. 19
0
 public ToasterManager(ToasterSettings settings = null, Func <string, string, UIElement> getDefaultView = null, ToastAdornerSettings defaultToastSettings = null)
 {
     _settings             = settings;
     _getDefaultView       = getDefaultView;
     _defaultToastSettings = defaultToastSettings;
 }
Esempio n. 20
0
 /// <summary>
 /// Open toaster
 /// </summary>
 /// <param name="settings">Toaster Settings</param>
 public void Open(ToasterSettings settings)
 {
     _snackbar.Add(GenerateString(settings), GetType(settings));
 }