private void RadarBGOpacityTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textbox = sender as TextBox;
            byte    value;

            if (!byte.TryParse(textbox.Text, out value))
            {
                textbox.Text = 0.ToString(CultureInfo.CurrentCulture);
                return;
            }
            if (value > 100)
            {
                textbox.Text = 100.ToString(CultureInfo.CurrentCulture);
            }
            else if (value < 0)
            {
                textbox.Text = 0.ToString(CultureInfo.CurrentCulture);
            }
            RadarOverlay radarOverlay = this.ro;

            if (radarOverlay == null)
            {
                return;
            }
            radarOverlay.SetBackgroundOpacity();
        }
        private void RadarMaxFrameRateTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textbox = sender as TextBox;
            byte    value;

            if (!byte.TryParse(textbox.Text, out value))
            {
                textbox.Text = 30.ToString(CultureInfo.CurrentCulture);
                return;
            }
            if (value > 144)
            {
                textbox.Text = 144.ToString(CultureInfo.CurrentCulture);
            }
            else if (value < 1)
            {
                textbox.Text = 1.ToString(CultureInfo.CurrentCulture);
            }
            RadarOverlay radarOverlay = this.ro;

            if (radarOverlay == null)
            {
                return;
            }
            radarOverlay.SetNewFrameRate();
        }
        private void ResizeCheckBox_Unchecked_1(object sender, RoutedEventArgs e)
        {
            RadarOverlay radarOverlay = this.ro;

            if (radarOverlay == null)
            {
                return;
            }
            radarOverlay.EnableResizeMode();
        }
        private void ClickthruCheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            RadarOverlay radarOverlay = this.ro;

            if (radarOverlay == null)
            {
                return;
            }
            radarOverlay.MakeClickable();
        }
        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;
            }
        }
Exemple #6
0
        private void loadPointR()
        {
            //first section
            {
                string path = @"พิกัดเรดาร์.txt";
                if (File.Exists(path))
                {
                    using (StreamReader sr = new StreamReader(path))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            Console.WriteLine(line);
                            //PointLatLng pointR = PositionConverter.ParsePointFromString(line);
                            //pointRader = pointR;
                            //textBoxPositionR.Text = PositionConverter.ParsePointToString(pointR, comboBoxScale.Text);
                        }
                    }
                }
                else
                {
                    using (StreamWriter writer = new StreamWriter(path, true))
                    {
                        writer.WriteLine("13.75, 100.517");
                        //textBoxPositionR.Text = "13.75, 100.517";
                        writer.Close();
                    }
                }
            }
            string name     = "Test";
            int    interval = 140;//Convert.ToInt32(textBoxRadarInterval.Text);

            radarP = new RadarOverlay(name, Radar);
            int x = 0;

            //Int32.TryParse(textBoxRadarRadius.Text, out x);
            radarP.InitialRadar(PositionConverter.ParsePointFromString("13.75, 100.517"), x, interval);
            radars.Add(name, radarP);
        }
Exemple #7
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;
     }
 }
Exemple #8
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;
            }
        }