private void _2DRadarToggle(object sender, RoutedEventArgs e)
        {
            ToggleButton b = (ToggleButton)sender;

            if (b.IsChecked.GetValueOrDefault())
            {
                this.cts = new CancellationTokenSource();
                this.RadarOverlayThread = new Thread(delegate()
                {
                    this.ro         = new RadarOverlay(this.cts.Token);
                    ProcessSharp ps = new ProcessSharp(Program.mem.Process.Id, MemoryType.Remote);
                    this.ro.Initialize(ps.WindowFactory.MainWindow);
                    this.ro.Enable();
                    Dispatcher.Run();
                })
                {
                    IsBackground = true
                };
                this.RadarOverlayThread.SetApartmentState(ApartmentState.STA);
                this.RadarOverlayThread.Start();
                Task.Run(async delegate()
                {
                    await Task.Delay(1000).ConfigureAwait(false);
                    if (!this.cts.IsCancellationRequested && !Settings.Default.RadarEnableClickthru)
                    {
                        RadarOverlay radarOverlay2 = this.ro;
                        if (radarOverlay2 != null)
                        {
                            radarOverlay2.MakeClickable();
                        }
                    }
                });
                return;
            }
            bool?isChecked = b.IsChecked;
            bool flag      = true;

            if (!(isChecked.GetValueOrDefault() == flag & isChecked != null))
            {
                CancellationTokenSource cancellationTokenSource = this.cts;
                if (cancellationTokenSource != null)
                {
                    cancellationTokenSource.Cancel();
                }
                RadarOverlay radarOverlay = this.ro;
                if (radarOverlay != null)
                {
                    radarOverlay.Dispose();
                }
                this.ro = null;
            }
        }
예제 #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             if (cts != null && !cts.IsCancellationRequested)
             {
                 cts.Cancel();
                 Thread.Sleep(1000 / Properties.Settings.Default.RadarMaxFrameRate * 2);
             }
             if (cts != null)
             {
                 cts.Dispose();
             }
             if (ro != null)
             {
                 ro.Dispose();
             }
         }
         ro            = null;
         disposedValue = true;
     }
 }
예제 #3
0
        private void _2DRadarToggle(object sender, RoutedEventArgs e)
        {
            ToggleButton b = (ToggleButton)sender;

            if (b.IsChecked ?? false)
            {
                cts = new CancellationTokenSource();
                RadarOverlayThread = new Thread(() =>
                {
                    ro = new RadarOverlay(cts.Token);
                    ProcessSharp ps = new ProcessSharp(Program.mem.Process.Id, Process.NET.Memory.MemoryType.Remote);
                    ro.Initialize(ps.WindowFactory.MainWindow);
                    ro.Enable();
                    System.Windows.Threading.Dispatcher.Run();
                })
                {
                    IsBackground = true
                };
                RadarOverlayThread.SetApartmentState(ApartmentState.STA);
                RadarOverlayThread.Start();
                Task.Factory.StartNew(async() =>
                {
                    await Task.Delay(1000);
                    if (!cts.IsCancellationRequested && !Properties.Settings.Default.RadarEnableClickthru)
                    {
                        ro?.MakeClickable();
                    }
                });
            }
            else if (b.IsChecked != true)
            {
                cts?.Cancel();
                ro?.Dispose();
                ro = null;
            }
        }