private void TrayConfiguration() { _trayIcon = new NotifyIcon { Icon = BasicTeraData.Instance.ImageDatabase.Tray, Visible = true, Text = "Shinra Meter V" + UpdateManager.Version + ": No server" }; _trayIcon.Click += TrayIconOnClick; var reset = new MenuItem { Text = "Reset" }; reset.Click += ResetOnClick; var exit = new MenuItem { Text = "Close" }; exit.Click += ExitOnClick; var wiki = new MenuItem { Text = "Wiki" }; wiki.Click += WikiOnClick; var patch = new MenuItem { Text = "Patch note" }; patch.Click += PatchOnClick; var issues = new MenuItem { Text = "Report issue" }; issues.Click += IssuesOnClick; var forum = new MenuItem { Text = "Forum" }; forum.Click += ForumOnClick; _clickThrou = new MenuItem { Text = "Activate click throu" }; _clickThrou.Click += ClickThrouOnClick; var context = new ContextMenu(); context.MenuItems.Add(_clickThrou); context.MenuItems.Add(reset); context.MenuItems.Add(wiki); context.MenuItems.Add(patch); context.MenuItems.Add(issues); context.MenuItems.Add(forum); context.MenuItems.Add(exit); _trayIcon.ContextMenu = context; }
public void Update(StatsSummary nstatsSummary, Database.Structures.Skills nskills, List <NpcEntity> nentities, bool ntimedEncounter, AbnormalityStorage nabnormals, ConcurrentDictionary <string, NpcEntity> nbossHistory, List <ChatMessage> nchatbox, int npacketWaiting, NotifyFlashMessage nflash) { NetworkController.UpdateUiHandler changeUi = delegate(StatsSummary statsSummary, Database.Structures.Skills skills, List <NpcEntity> entities, bool timedEncounter, AbnormalityStorage abnormals, ConcurrentDictionary <string, NpcEntity> bossHistory, List <ChatMessage> chatbox, int packetWaiting, NotifyFlashMessage flash) { Scroller.MaxHeight = BasicTeraData.Instance.WindowData.NumberOfPlayersDisplayed * 30; UpdateComboboxEncounter(entities, statsSummary.EntityInformation.Entity); _entityStats.Update(statsSummary.EntityInformation, abnormals); _windowHistory.Update(bossHistory); _chatbox?.Update(chatbox); NotifyIcon.ShowBallon(flash); NotifyIcon.UpdatePacketWaiting(packetWaiting); PartyDps.Content = FormatHelpers.Instance.FormatValue(statsSummary.EntityInformation.Interval == 0 ? statsSummary.EntityInformation.TotalDamage : statsSummary.EntityInformation.TotalDamage * TimeSpan.TicksPerSecond / statsSummary.EntityInformation.Interval) + LP.PerSecond; var visiblePlayerStats = new HashSet <Player>(); var statsDamage = statsSummary.PlayerDamageDealt; var statsHeal = statsSummary.PlayerHealDealt; foreach (var playerStats in statsDamage) { PlayerStats playerStatsControl; Controls.TryGetValue(playerStats.Source, out playerStatsControl); if (playerStats.Amount == 0) { continue; } visiblePlayerStats.Add(playerStats.Source); if (playerStatsControl != null) { continue; } playerStatsControl = new PlayerStats(playerStats, statsHeal.FirstOrDefault(x => x.Source == playerStats.Source), statsSummary.EntityInformation, skills, abnormals.Get(playerStats.Source)); Controls.Add(playerStats.Source, playerStatsControl); } var invisibleControls = Controls.Where(x => !visiblePlayerStats.Contains(x.Key)).ToList(); foreach (var invisibleControl in invisibleControls) { Controls[invisibleControl.Key].CloseSkills(); Controls.Remove(invisibleControl.Key); } TotalDamage.Content = FormatHelpers.Instance.FormatValue(statsSummary.EntityInformation.TotalDamage); if (BasicTeraData.Instance.WindowData.ShowTimeLeft && statsSummary.EntityInformation.TimeLeft > 0) { var interval = TimeSpan.FromSeconds(statsSummary.EntityInformation.TimeLeft / TimeSpan.TicksPerSecond); Timer.Content = interval.ToString(@"mm\:ss"); Timer.Foreground = System.Windows.Media.Brushes.LightCoral; } else { var interval = TimeSpan.FromSeconds(statsSummary.EntityInformation.Interval / TimeSpan.TicksPerSecond); Timer.Content = interval.ToString(@"mm\:ss"); if (statsSummary.EntityInformation.Interval == 0 && BasicTeraData.Instance.WindowData.ShowTimeLeft) { Timer.Foreground = System.Windows.Media.Brushes.LightCoral; } else { Timer.Foreground = System.Windows.Media.Brushes.White; } } Players.Items.Clear(); foreach (var item in statsDamage) { if (!Controls.ContainsKey(item.Source)) { continue; } if (Players.Items.Contains(Controls[item.Source])) { BasicTeraData.LogError("duplicate playerinfo: \r\n" + String.Join("\r\n ", statsDamage.Select(x => x.Source.ToString() + " -> " + x.Amount)), false, true); continue; } Players.Items.Add(Controls[item.Source]); Controls[item.Source].Repaint(item, statsHeal.FirstOrDefault(x => x.Source == item.Source), statsSummary.EntityInformation, skills, abnormals.Get(item.Source), timedEncounter); } if (BasicTeraData.Instance.WindowData.InvisibleUi) { if (Controls.Count > 0 && !ForceWindowVisibilityHidden) { Visibility = Visibility.Visible; } if (Controls.Count == 0) { Visibility = Visibility.Hidden; } } else { if (!ForceWindowVisibilityHidden) { Visibility = Visibility.Visible; } } if (ActualWidth != _oldWidth) // auto snap to right screen border on width change { Screen screen = Screen.FromHandle(new WindowInteropHelper(Window.GetWindow(this)).Handle); // Transform screen point to WPF device independent point PresentationSource source = PresentationSource.FromVisual(this); if (source?.CompositionTarget == null) { return; } double dx = source.CompositionTarget.TransformToDevice.M11; if (Math.Abs(screen.WorkingArea.X + screen.WorkingArea.Width - (Left + _oldWidth) * dx) < 50) //snap at 50 px { Left = Left + _oldWidth - ActualWidth; } _oldWidth = ActualWidth; } }; Dispatcher.Invoke(changeUi, nstatsSummary, nskills, nentities, ntimedEncounter, nabnormals, nbossHistory, nchatbox, npacketWaiting, nflash); }
//private readonly SystemTray _systemTray; public MainWindow() { InitializeComponent(); // Handler for exceptions in threads behind forms. App.SplashScreen?.SetText("Initializing main window..."); Application.ThreadException += GlobalThreadExceptionHandler; if (BasicTeraData.Instance.WindowData.InvisibleUi) { Visibility = Visibility.Hidden; } System.Windows.Application.Current.Resources["Scale"] = BasicTeraData.Instance.WindowData.Scale; if (BasicTeraData.Instance.WindowData.LowPriority) { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle; } TeraSniffer.Instance.Enabled = true; TeraSniffer.Instance.Warning += PcapWarning; PacketProcessor.Instance.Connected += HandleConnected; PacketProcessor.Instance.TickUpdated += Update; PacketProcessor.Instance.SetClickThrouAction += SetClickThrou; PacketProcessor.Instance.UnsetClickThrouAction += UnsetClickThrou; PacketProcessor.Instance.GuildIconAction += InstanceOnGuildIconAction; PacketProcessor.Instance.PauseAction += PauseState; _dispatcherTimer = new DispatcherTimer(); _dispatcherTimer.Tick += UpdateKeyboard; _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); _dispatcherTimer.Start(); if (BasicTeraData.Instance.WindowData.EnableOverlay) { DXrender = new D3D9Render.Renderer(); } EntityStatsImage.Source = BasicTeraData.Instance.ImageDatabase.EntityStats.Source; Chrono.Source = BasicTeraData.Instance.ImageDatabase.Chronobar.Source; Chrono.ToolTip = LP.MainWindow_Only_boss; CloseWindow.Source = BasicTeraData.Instance.ImageDatabase.Close.Source; History.Source = BasicTeraData.Instance.ImageDatabase.History.Source; Config.Source = BasicTeraData.Instance.ImageDatabase.Config.Source; Chatbox.Source = BasicTeraData.Instance.ImageDatabase.Chat.Source; BossGageImg.Source = BasicTeraData.Instance.ImageDatabase.BossGage.Source; HideNamesImage.Source = BasicTeraData.Instance.ImageDatabase.HideNicknames.Source; HideNames.ToolTip = LP.Blur_player_names; ListEncounter.PreviewKeyDown += ListEncounterOnPreviewKeyDown; UpdateComboboxEncounter(new List <NpcEntity>(), null); Title = "Shinra Meter V" + UpdateManager.Version; BackgroundColor.Opacity = BasicTeraData.Instance.WindowData.MainWindowOpacity; Topmost = BasicTeraData.Instance.WindowData.Topmost; ShowInTaskbar = !BasicTeraData.Instance.WindowData.Topmost; Scroller.MaxHeight = BasicTeraData.Instance.WindowData.NumberOfPlayersDisplayed * 30; _entityStats = new EntityStatsMain() { Scale = BasicTeraData.Instance.WindowData.DebuffsStatus.Scale, DontClose = true }; _bossGageBar = new BossGageWindow() { Scale = BasicTeraData.Instance.WindowData.BossGageStatus.Scale, DontClose = true }; _popupNotification = new PopupNotification() { DontClose = true }; _windowHistory = new TeradpsHistory(new ConcurrentDictionary <UploadData, NpcEntity>()) { Scale = BasicTeraData.Instance.WindowData.BossGageStatus.Scale, DontClose = true }; KeyboardHook.Instance.SwitchTopMost += delegate { NotifyIcon.SwitchStayTop(); }; SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding); NotifyIcon.Initialize(this); NotifyIcon.InitializeServerList(PacketProcessor.Instance.Initialize()); if (BasicTeraData.Instance.WindowData.ClickThrou) { SetClickThrou(); } }
private void TrayConfiguration() { _trayIcon = new NotifyIcon { Icon = BasicTeraData.Instance.ImageDatabase.Tray, Visible = true, Text = "Shinra Meter V" + UpdateManager.Version + ": No server" }; _trayIcon.Click += TrayIconOnClick; _trayIcon.DoubleClick += _trayIcon_DoubleClick; var reset = new MenuItem { Text = "Reset" }; reset.Click += ResetOnClick; var exit = new MenuItem { Text = "Close" }; exit.Click += ExitOnClick; var wiki = new MenuItem { Text = "Wiki" }; wiki.Click += WikiOnClick; var patch = new MenuItem { Text = "Patch note" }; patch.Click += PatchOnClick; var issues = new MenuItem { Text = "Report issue" }; issues.Click += IssuesOnClick; var forum = new MenuItem { Text = "Forum" }; forum.Click += ForumOnClick; var teradps = new MenuItem { Text = "TeraDps.io" }; teradps.Click += TeraDpsOnClick; var excel = new MenuItem { Text = "Excel export" }; excel.Click += ExcelOnClick; excel.Checked = BasicTeraData.Instance.WindowData.Excel; var siteExport = new MenuItem { Text = "Site export" }; siteExport.Click += SiteOnClick; siteExport.Checked = BasicTeraData.Instance.WindowData.SiteExport; var party = new MenuItem { Text = "Count only party members" }; party.Click += PartyOnClick; party.Checked = BasicTeraData.Instance.WindowData.PartyOnly; _clickThrou = new MenuItem { Text = "Activate click throu" }; _clickThrou.Click += ClickThrouOnClick; _switchNoStatsVisibility = new MenuItem { Text = "Invisible when no stats" }; _switchNoStatsVisibility.Click += SwitchNoStatsVisibility; _switchNoStatsVisibility.Checked = BasicTeraData.Instance.WindowData.InvisibleUI; _alwaysOn = new MenuItem { Text = "Show always" }; _alwaysOn.Click += _trayIcon_DoubleClick; _alwaysOn.Checked = BasicTeraData.Instance.WindowData.AlwaysVisible; var context = new ContextMenu(); context.MenuItems.Add(_clickThrou); context.MenuItems.Add(_switchNoStatsVisibility); context.MenuItems.Add(_alwaysOn); context.MenuItems.Add(reset); context.MenuItems.Add(wiki); context.MenuItems.Add(patch); context.MenuItems.Add(issues); context.MenuItems.Add(forum); context.MenuItems.Add(teradps); context.MenuItems.Add(excel); context.MenuItems.Add(siteExport); context.MenuItems.Add(party); context.MenuItems.Add(exit); _trayIcon.ContextMenu = context; }