private void UserControl_Loaded(object sender, RoutedEventArgs e) { _context = (Balloon)DataContext; _context.PropChanged += _context_RefreshEvent; _close = new Timer(_context.DisplayTime); _close.Elapsed += _close_Elapsed; Color col; switch (_context.EventType) { case EventType.MissingAb: col = Colors.Red; break; case EventType.AddRemoveAb: col = Colors.Orange; break; case EventType.Cooldown: col = Color.FromRgb(0xfd, 0x39, 0x20); break; case EventType.AFK: col = Color.FromRgb(0x2, 0xbb, 0xff); break; case EventType.Whisper: col = Color.FromRgb(0xff, 0x87, 0xb3); img.Source = BasicTeraData.Instance.ImageDatabase.Whisper.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.MatchingSuccess: col = Color.FromRgb(0x2d, 0xff, 0x73); img.Source = BasicTeraData.Instance.ImageDatabase.DoneCircle.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.ReadyCheck: col = Color.FromRgb(0x2d, 0xff, 0x73); img.Source = BasicTeraData.Instance.ImageDatabase.DoneCircle.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.OtherUserApply: col = Color.FromRgb(0x2d, 0xff, 0x73); img.Source = BasicTeraData.Instance.ImageDatabase.GroupAdd.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.Broker: col = Color.FromRgb(0xbf, 0x54, 0x26); img.Source = BasicTeraData.Instance.ImageDatabase.Money.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.PartyInvite: col = Color.FromRgb(0x2d, 0xff, 0x73); img.Source = BasicTeraData.Instance.ImageDatabase.GroupAdd.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.Trade: col = Color.FromRgb(0xbf, 0x54, 0x26); img.Source = BasicTeraData.Instance.ImageDatabase.Money.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.GenericContract: col = Color.FromRgb(0x2, 0xbb, 0xff); img.Source = BasicTeraData.Instance.ImageDatabase.Info.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.VanguardCredits: col = Color.FromRgb(0xde, 0x48, 0xf2); ellImgBrush.ImageSource = BasicTeraData.Instance.ImageDatabase.Credits.Source; break; case EventType.WakeUp: col = Color.FromRgb(0x48, 0xf2, 0x94); img.Source = BasicTeraData.Instance.ImageDatabase.Info.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; case EventType.Mention: col = Color.FromRgb(0x48, 0xf2, 0x94); img.Source = BasicTeraData.Instance.ImageDatabase.Info.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; default: col = Color.FromRgb(0x2, 0xbb, 0xff); img.Source = BasicTeraData.Instance.ImageDatabase.Info.Source; ell.Visibility = Visibility.Hidden; img.Visibility = Visibility.Visible; break; } //rect.Stroke = new SolidColorBrush(col); //(rect.Effect as DropShadowEffect).Color = col; DHeight = ActualHeight; ((UIElement)this).FindLogicalAncestor <PopupNotification>().DHeight += DHeight; var an = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(300)); this.BeginAnimation(OpacityProperty, an); _close.Start(); }
public void ShowBallon(Tuple <string, string> flash) { if (flash == null) { return; } Tray.HideBalloonTip(); if (BasicTeraData.Instance.WindowData.PopupDisplayTime >= 500) { var balloon = new Balloon(); balloon.Value(flash.Item1, flash.Item2); Tray.ShowCustomBalloon(balloon, System.Windows.Controls.Primitives.PopupAnimation.Fade, BasicTeraData.Instance.WindowData.PopupDisplayTime); } var file = Path.Combine(BasicTeraData.Instance.ResourceDirectory, "sound/", BasicTeraData.Instance.WindowData.NotifySound); if (!File.Exists(file)) { file = BasicTeraData.Instance.WindowData.NotifySound; if (!File.Exists(file)) { return; } } lock (_lock) { if (_needToStop) { return; } } try { _outputStream = new MediaFoundationReader(file); _volumeStream = new WaveChannel32(_outputStream); _volumeStream.Volume = BasicTeraData.Instance.WindowData.Volume; //Create WaveOutEvent since it works in Background and UI Threads _player = new WaveOutEvent(); //Init Player with Configured Volume Stream _player.Init(_volumeStream); _player.Play(); _needToStop = true; var timer = new System.Threading.Timer((obj) => { lock (_lock) { _needToStop = false; _player.Stop(); _player.Dispose(); _volumeStream.Dispose(); _outputStream.Dispose(); _outputStream = null; _player = null; _volumeStream = null; } }, null, BasicTeraData.Instance.WindowData.SoundNotifyDuration, System.Threading.Timeout.Infinite); } catch (Exception e) { // Get stack trace for the exception with source file information var st = new StackTrace(e, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); BasicTeraData.LogError("Sound ERROR test" + e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine + e.InnerException + Environment.NewLine + e + Environment.NewLine + "filename:" + file + Environment.NewLine + "line:" + line, false, true); } }