Пример #1
0
 private static void PlaySound(MultipleAlertItem alert)
 {
     if (alert.IsPlaySound)
     {
         MediaPlayer player = new MediaPlayer();
         Uri         uri    = new Uri("Media\\" + alert.SoundFile, UriKind.Relative);
         player.Open(uri);
         player.Play();
     }
 }
        private void AddAlert()
        {
            try
            {
                MultipleAlertItem alertItem = new MultipleAlertItem();
                if (string.IsNullOrEmpty(selectedPair))
                {
                    throw new Exception(Resources.PleaseSelectTradePair);
                }
                alertItem.PairCode = SelectedPair;


                alertItem.PriceType = PriceType;

                alertItem.AbbrNamePrices = new List <AbbrNamePrice>();
                foreach (var item in ExchangeSelectors)
                {
                    if (item.IsSelected)
                    {
                        alertItem.AbbrNamePrices.Add(new AbbrNamePrice()
                        {
                            AbbrName = item.AbbrName
                        });
                    }
                }
                if (alertItem.AbbrNamePrices.Count == 0)
                {
                    throw new Exception(Resources.AtLeastOneExchange);
                }

                alertItem.IsHighThan = IsHighThan;

                alertItem.ComparePrice = ComparePrice;

                if (AlertColorItem == null)
                {
                    throw new Exception(Resources.PleaseSelectShowColor);
                }
                SolidColorBrush brush = AlertColorItem.Background as SolidColorBrush;
                alertItem.AlertColor = brush.Color;

                alertItem.IsPlaySound = IsPlaySound;
                alertItem.SoundFile   = SelectedSoundFile;

                alertItem.IsOpen = true;

                eventAggregator.GetEvent <AddMultipleAlertItemEvent>().Publish(alertItem);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
 private void DeleteItem(MultipleAlertItem alertItem)
 {
     Alerts.Remove(alertItem);
     Save();
 }
Пример #4
0
 private void AddItem(MultipleAlertItem item)
 {
     Alerts.Add(item);
 }