private static void LoadCharWindow() { var charWindowThread = new Thread(() => { SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)); SessionManager.CurrentPlayer = new Player(); CharacterWindow = new CharacterWindow(); if (CharacterWindow.WindowSettings.Enabled) { CharacterWindow.Show(); } AddDispatcher(Thread.CurrentThread.ManagedThreadId, Dispatcher.CurrentDispatcher); Dispatcher.Run(); RemoveDispatcher(Thread.CurrentThread.ManagedThreadId); }) { Name = "Char" }; charWindowThread.SetApartmentState(ApartmentState.STA); charWindowThread.Start(); }
public static void Init() { CooldownWindow = new CooldownWindow(); CharacterWindow = new CharacterWindow(); BossGauge = new BossGageWindow(); BuffBar = new AbnormalitiesWindow(); ContextMenu = new ContextMenu(); TrayIcon = new System.Windows.Forms.NotifyIcon() { Icon = Icon.ExtractAssociatedIcon(Process.GetCurrentProcess().MainModule.FileName), Visible = true }; TrayIcon.MouseDown += NI_MouseDown; var v = Assembly.GetExecutingAssembly().GetName().Version; TrayIcon.Text = String.Format("TCC v{0}.{1}.{2}", v.Major, v.Minor, v.Build); var ForceShowButton = new MenuItem() { Header = "Force visibility on" }; ClickThruButton = new MenuItem() { Header = "Click through" }; var CloseButton = new MenuItem() { Header = "Close" }; CharacterWindowVisibilityButton = new MenuItem() { Header = "Unhide character window" }; CharacterWindowVisibilityButton.Click += (s, ev) => { CharacterWindow.Visibility = Visibility.Visible; }; CooldownWindowVisibilityButton = new MenuItem() { Header = "Unhide cooldowns bar" }; CooldownWindowVisibilityButton.Click += (s, ev) => { CooldownWindow.Visibility = Visibility.Visible; }; BossGaugeWindowVisibilityButton = new MenuItem() { Header = "Unhide boss bar" }; BossGaugeWindowVisibilityButton.Click += (s, ev) => { BossGauge.Visibility = Visibility.Visible; }; BuffBarWindowVisibilityButton = new MenuItem() { Header = "Unhide buffs bar" }; BuffBarWindowVisibilityButton.Click += (s, ev) => { BuffBar.Visibility = Visibility.Visible; }; CloseButton.Click += (s, ev) => App.CloseApp(); ClickThruButton.Click += (s, ev) => ToggleClickThru(); ForceShowButton.Click += (s, ev) => ForceShow(); ContextMenu.Items.Add(CooldownWindowVisibilityButton); ContextMenu.Items.Add(BuffBarWindowVisibilityButton); ContextMenu.Items.Add(BossGaugeWindowVisibilityButton); ContextMenu.Items.Add(CharacterWindowVisibilityButton); ContextMenu.Items.Add(new Separator()); ContextMenu.Items.Add(ClickThruButton); ContextMenu.Items.Add(CloseButton); FocusManager.FocusTimer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) }; FocusManager.FocusTimer.Tick += FocusManager.CheckForegroundWindow; FocusManager.ForegroundWindowChanged += FocusManager_ForegroundWindowChanged; }