コード例 #1
0
        private async void GetNotificationPositionsAsync()
        {
            var localNotificationPositions = new ObservableCollection <NameValue>();

            await Task.Run(() =>
            {
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Bottom_Left"), Value = (int)NotificationPosition.BottomLeft
                });
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Top_Left"), Value = (int)NotificationPosition.TopLeft
                });
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Top_Right"), Value = (int)NotificationPosition.TopRight
                });
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Bottom_Right"), Value = (int)NotificationPosition.BottomRight
                });
            });

            this.NotificationPositions = localNotificationPositions;

            NameValue localSelectedNotificationPosition = null;

            await Task.Run(() => localSelectedNotificationPosition = NotificationPositions.Where((np) => np.Value == XmlSettingsClient.Instance.Get <int>("Behaviour", "NotificationPosition")).Select((np) => np).First());

            this.SelectedNotificationPosition = localSelectedNotificationPosition;
        }
コード例 #2
0
 /// <summary>
 /// Sets the notification position.
 /// </summary>
 /// <param name="notificationPositions">The notification positions.</param>
 /// <param name="resubscribeOnly">if set to <c>true</c> [resubscribe only].</param>
 protected virtual void SetNotificationPosition(IEnumerable <INotificationPosition> notificationPositions = null, bool resubscribeOnly = false)
 {
     isNotificationPositionReloading = true;
     if (!resubscribeOnly && notificationPositions != null)
     {
         NotificationPositions = notificationPositions.ToAvaloniaList();
     }
     notificationPositionChanged?.Dispose();
     notificationPositionChanged = this.WhenAnyValue(p => p.NotificationPosition).Where(p => !isNotificationPositionReloading).Subscribe(s =>
     {
         foreach (var item in NotificationPositions)
         {
             item.IsSelected = item == s;
         }
         SaveNotificationOption();
     }).DisposeWith(Disposables);
     if (!resubscribeOnly && notificationPositions != null)
     {
         NotificationPosition = NotificationPositions.FirstOrDefault(p => p.IsSelected);
     }
     isNotificationPositionReloading = false;
 }