private void OnPreTick(object sender, EventArgs eventArgs)
        {
            // Only want to set them up once.
            if (!_isSetup)
            {
                SetUp();
                _isSetup = true;
            }

            var activated = TargetWindow.IsActivated;
            var visible   = OverlayWindow.IsVisible;

            // Ensure window is shown or hidden correctly prior to updating
            //if (!activated && visible)
            //{
            //    OverlayWindow.Hide();
            //}

            //else if (activated && !visible)
            //{
            //    OverlayWindow.Show();
            //}
            if (!visible)
            {
                OverlayWindow.Show();
            }
            //else { OverlayWindow.Hide(); }
        }
Пример #2
0
        public override void Initialize(IWindow targetWindow)
        {
            // Set target window by calling the base method
            base.Initialize(targetWindow);
            _targetWindow = targetWindow;
            OverlayWindow = new OverlayWindow(targetWindow)
            {
                Title         = GetType().Name,
                ShowInTaskbar = false
            };

            OverlayWindow.Loaded += OverlayWindow_Loaded;
            OverlayWindow.MouseLeftButtonDown += OverlayWindow_MouseLeftButtonDown;
            OverlayWindow.MouseLeftButtonUp   += OverlayWindow_MouseLeftButtonUp;
            OverlayWindow.MouseMove           += OverlayWindow_MouseMove;
            OverlayWindow.SizeChanged         += OverlayWindow_SizeChanged;
            // Set up update interval and register events for the tick engine.
            _tickEngine.Interval = (1000 / Properties.Settings.Default.RadarMaxFrameRate).Milliseconds();
            _tickEngine.PreTick += OnPreTick;
            _tickEngine.Tick    += OnTick;
            dispatcher           = new DispatcherTimer();
            dispatcher.Tick     += Dispatcher_Tick;
            dispatcher.Interval  = _tickEngine.Interval;
            dispatcher.Start();
        }
Пример #3
0
        public override void Initialize(IWindow targetWindow)
        {
            // Set target window by calling the base method
            base.Initialize(targetWindow);

            OverlayWindow = new OverlayWindow(targetWindow);

            // For demo, show how to use settings
            var current = Settings.Current;
            var type    = GetType();

            current.UpdateRate  = 1000 / 60;
            current.Author      = GetAuthor(type);
            current.Description = GetDescription(type);
            current.Identifier  = GetIdentifier(type);
            current.Name        = GetName(type);
            current.Version     = GetVersion(type);

            // File is made from above info
            Settings.Save();
            Settings.Load();

            // Set up update interval and register events for the tick engine.
            _tickEngine.Interval = Settings.Current.UpdateRate.Milliseconds();
            _tickEngine.PreTick += OnPreTick;
            _tickEngine.Tick    += OnTick;
        }
Пример #4
0
        // Random shapes.. thanks Julian ^_^
        private void SetUp()
        {
            _polygon = new Polygon {
                Points = new PointCollection(5)
                {
                    new Point(100, 150),
                    new Point(120, 130),
                    new Point(140, 150),
                    new Point(140, 200),
                    new Point(100, 200)
                },
                Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 255)),
                Fill   =
                    new RadialGradientBrush(
                        Color.FromRgb(255, 255, 0),
                        Color.FromRgb(255, 0, 255))
            };

            OverlayWindow.Add(_polygon);

            // Create a line
            _line = new Line {
                X1              = 100,
                X2              = 300,
                Y1              = 200,
                Y2              = 200,
                Stroke          = new SolidColorBrush(Color.FromRgb(0, 255, 0)),
                StrokeThickness = 2
            };

            OverlayWindow.Add(_line);

            // Create an ellipse (circle)
            _ellipse = new Ellipse {
                Width  = 15,
                Height = 15,
                Margin = new Thickness(300, 300, 0, 0),
                Stroke =
                    new SolidColorBrush(Color.FromRgb(0, 255, 255))
            };

            OverlayWindow.Add(_ellipse);

            // Create a rectangle
            _rectangle = new Rectangle {
                RadiusX = 2,
                RadiusY = 2,
                Width   = 50,
                Height  = 100,
                Margin  = new Thickness(400, 400, 0, 0),
                Stroke  = new SolidColorBrush(Color.FromRgb(255, 0, 0)),
                Fill    =
                    new SolidColorBrush(Color.FromArgb(100, 255, 255,
                                                       255))
            };

            OverlayWindow.Add(_rectangle);
        }
Пример #5
0
 void OnTick(object sender, EventArgs eventArgs)
 {
     // This will only be true if the target window is active
     // (or very recently has been, depends on your update rate)
     if (OverlayWindow.IsVisible)
     {
         OverlayWindow.Update();
     }
 }
Пример #6
0
 private void OverlayWindow_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (NativeMethods.GetWindowRect(_targetWindow.Handle, out NativeMethods.RECT trect))
     {
         Properties.Settings.Default.RadarWindowOffset = new System.Drawing.Point((int)(OverlayWindow.Left - trect.Left), (int)(OverlayWindow.Top - trect.Top));
         Properties.Settings.Default.Save();
     }
     MouseDown = false;
     OverlayWindow.ReleaseMouseCapture();
 }
Пример #7
0
        private void SetUp()
        {
            overlay1 = new System.Windows.Controls.Image();
            BitmapImage bi3 = new BitmapImage();

            bi3.BeginInit();
            bi3.UriSource = new Uri(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.StartupPath) + "\\panel1.bmp", UriKind.RelativeOrAbsolute);
            bi3.EndInit();
            overlay1.Stretch = Stretch.Fill;
            overlay1.Source  = bi3;
            OverlayWindow.Add(overlay1);
        }
Пример #8
0
        public override void Initialize(IWindow targetWindow)
        {
            // Set target window by calling the base method
            base.Initialize(targetWindow);

            OverlayWindow = new OverlayWindow(targetWindow)
            {
                ShowInTaskbar = false
            };

            _tickEngine.Interval = TimeSpan.FromMilliseconds(1000 / 60f);
            _tickEngine.PreTick += OnPreTick;
            _tickEngine.Tick    += OnTick;
        }
Пример #9
0
        private void OnPreTick(object sender, EventArgs eventArgs)
        {
            var activated = TargetWindow.IsActivated;
            var visible   = OverlayWindow.IsVisible;

            // Ensure window is shown or hidden correctly prior to updating
            if (!activated && visible)
            {
                OverlayWindow.Hide();
            }
            else if (activated && !visible)
            {
                OverlayWindow.Show();
            }
        }
Пример #10
0
        public override void Initialize(IWindow targetWindow)
        {
            // Set target window by calling the base method
            base.Initialize(targetWindow);
            Initialized = true;
#if DEBUG
            Console.WriteLine("Overlay: Initialize");
#endif
            OverlayWindow = new OverlayWindow(targetWindow);

            // Set up update interval and register events for the tick engine.
            _tickEngine.Interval = (1000 / 30).Milliseconds();
            _tickEngine.PreTick += OnPreTick;
            _tickEngine.Tick    += OnTick;

            OverlayWindow.Draw += OnDraw;
        }
Пример #11
0
        public override void Disable()
        {
#if DEBUG
            Console.WriteLine("Overlay: Disable");
#endif
            IsEnabled             = false;
            _tickEngine.IsTicking = false;

            displayPrimes = new List <DisplayPrime>();
            DrawPrimesText();

            if (OverlayWindow != null)
            {
                OverlayWindow.Hide();
            }

            base.Disable();
        }
Пример #12
0
        void OnPreTick(object sender, EventArgs eventArgs)
        {
            // Only want to set them up once.
            if (!_isSetup)
            {
                SetUp();
                _isSetup = true;
            }

            // Ensure window is shown or hidden correctly prior to updating
            if ((TargetWindow.IsActivated && !OverlayWindow.IsVisible) || ApplicationIsActivated())
            {
                OverlayWindow.Show();
            }
            else if ((!TargetWindow.IsActivated && OverlayWindow.IsVisible))
            {
                OverlayWindow.Hide();
            }
        }
Пример #13
0
        // Clear objects
        public override void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            if (IsEnabled)
            {
                Disable();
            }

            OverlayWindow?.Hide();
            OverlayWindow?.Close();
            OverlayWindow = null;
            _tickEngine.Stop();
            Settings.Save();

            base.Dispose();
            _isDisposed = true;
        }
Пример #14
0
        // Clear objects
        public override void Dispose()
        {
#if DEBUG
            Console.WriteLine("Overlay: Dispose");
#endif
            if (_isDisposed)
            {
                return;
            }

            if (IsEnabled)
            {
                Disable();
            }

            OverlayWindow?.Hide();
            OverlayWindow?.Close();
            OverlayWindow = null;
            _tickEngine.Stop();

            base.Dispose();
            _isDisposed = true;
        }
Пример #15
0
        // Clear objects
        public override void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            try {
                if (IsEnabled)
                {
                    Disable();
                }

                OverlayWindow?.Hide();
                OverlayWindow?.Close();
                OverlayWindow = null;
                _tickEngine.Stop();

                base.Dispose();
                _isDisposed = true;
            } catch {
                // ignored
            }
        }
Пример #16
0
 private void OverlayWindow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     MouseDown = true;
     DragStart = e.GetPosition(OverlayWindow);
     OverlayWindow.CaptureMouse();
 }
        // Random shapes.. thanks Julian ^_^
        private void SetUp()
        {
            button = new System.Windows.Controls.Button
            {
                Margin  = new Thickness(0, 41, 0, 0),
                Width   = 70,
                Height  = 50,
                Content = "Click me"
            };
            button.MouseEnter += (s, e) =>
            {
                MessageBox.Show("Clicked overlay");
            };
            OverlayWindow.Add(button);
            #region shapes
            //_polygon = new Polygon
            //{
            //    Points = new PointCollection(5) {
            //        new Point(100, 150),
            //        new Point(120, 130),
            //        new Point(140, 150),
            //        new Point(140, 200),
            //        new Point(100, 200)
            //    },
            //    Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 255)),
            //    Fill =
            //        new RadialGradientBrush(
            //            Color.FromRgb(255, 255, 0),
            //            Color.FromRgb(255, 0, 255))
            //};

            //OverlayWindow.Add(_polygon);

            // Create a line
            //_line = new Line
            //{
            //    X1 = 100,
            //    X2 = 300,
            //    Y1 = 200,
            //    Y2 = 200,
            //    Stroke = new SolidColorBrush(Color.FromRgb(0, 255, 0)),
            //    StrokeThickness = 2
            //};

            //OverlayWindow.Add(_line);

            // Create an ellipse (circle)
            //_ellipse = new Ellipse
            //{
            //    Width = 15,
            //    Height = 15,
            //    Margin = new Thickness(300, 300, 0, 0),
            //    Stroke =
            //        new SolidColorBrush(Color.FromRgb(0, 255, 255))
            //};

            //OverlayWindow.Add(_ellipse);

            // Create a rectangle
            //_rectangle = new Rectangle
            //{
            //    RadiusX = 2,
            //    RadiusY = 2,
            //    Width = 50,
            //    Height = 100,
            //    Margin = new Thickness(400, 400, 0, 0),
            //    Stroke = new SolidColorBrush(Color.FromRgb(255, 0, 0)),
            //    Fill =
            //        new SolidColorBrush(Color.FromArgb(100, 255, 255,
            //            255))
            //};

            //OverlayWindow.Add(_rectangle);
            #endregion
        }
Пример #18
0
 internal void MakeClickable() => OverlayWindow.Dispatcher.Invoke(() => OverlayWindow?.MakeWindowUntransparent());
Пример #19
0
        // Random shapes.. thanks Julian ^_^
        private void SetUp()
        {
            //_polygon = new Polygon
            //{
            //    Points = new PointCollection(5) {
            //        new Point(100, 150),
            //        new Point(120, 130),
            //        new Point(140, 150),
            //        new Point(140, 200),
            //        new Point(100, 200)
            //    },
            //    Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 255)),
            //    Fill =
            //        new RadialGradientBrush(
            //            Color.FromRgb(255, 255, 0),
            //            Color.FromRgb(255, 0, 255))
            //};
            //OverlayWindow.Add(_polygon);

            OverlayWindow.Add(new body());



            //// Create a line
            //_line = new Line
            //{
            //    X1 = 100,
            //    X2 = 300,
            //    Y1 = 200,
            //    Y2 = 200,
            //    Stroke = new SolidColorBrush(Color.FromRgb(0, 255, 0)),
            //    StrokeThickness = 2
            //};

            //OverlayWindow.Add(_line);

            //// Create an ellipse (circle)
            //_ellipse = new Ellipse
            //{
            //    Width = 15,
            //    Height = 15,
            //    Margin = new Thickness(300, 300, 0, 0),
            //    Stroke =
            //        new SolidColorBrush(Color.FromRgb(0, 255, 255))
            //};

            //OverlayWindow.Add(_ellipse);

            //// Create a rectangle
            //_rectangle = new Rectangle
            //{
            //    RadiusX = 2,
            //    RadiusY = 2,
            //    Width = 50,
            //    Height = 100,
            //    Margin = new Thickness(400, 400, 0, 0),
            //    Stroke = new SolidColorBrush(Color.FromRgb(255, 0, 0)),
            //    Fill =
            //        new SolidColorBrush(Color.FromArgb(100, 255, 255,
            //            255))
            //};

            //OverlayWindow.Add(_rectangle);
        }
Пример #20
0
 internal void MakeClickthru() => OverlayWindow.Dispatcher.Invoke(() => OverlayWindow?.MakeWindowTransparent());
Пример #21
0
        public override void Update()
        {
            // Raises the events only when the given interval has
            // passed since the last event, so it is okay to call every frame
            _tickEngine.Pulse();
            if (!OverlayWindow.IsVisible)
            {
                return;
            }
            if (!MouseDown)
            {
                FollowTargetWindow();
            }
            Combatant        self  = Program.mem?.GetSelfCombatant();
            List <Combatant> clist = Program.mem?._getCombatantList();

            if (self != null && clist != null)
            {
                clist.RemoveAll(c => c.OwnerID == self.ID);
                foreach (uint ID in clist.Where(c => c.Type == ObjectType.PC).Select(x => x.ID).ToList())
                {
                    clist.RemoveAll(c => c.OwnerID == ID);
                }
                RemoveUnvantedCombatants(self, clist);

                double centerY = OverlayWindow.Height / 2;
                double centerX = OverlayWindow.Width / 2;
                foreach (Combatant c in clist)
                {                                                                        //ridiculous posx+posy as key, no idea what else to use
                    if (c.ID == 3758096384 && !miscDrawMap.ContainsKey(c.PosX + c.PosY)) //for aetherytes, npcs, and other stuff;
                    {
                        miscDrawMap.Add(c.PosX + c.PosY, new EntityOverlayControl(c));
                        OverlayWindow.Add(miscDrawMap[c.PosX + c.PosY]);
                    }
                    else if (!drawMap.ContainsKey(c.ID))
                    {
                        drawMap.Add(c.ID, new EntityOverlayControl(c, c.ID == self.ID));
                        OverlayWindow.Add(drawMap[c.ID]);
                    }

                    double Top  = (c.PosY - self.PosY);
                    double Left = (c.PosX - self.PosX);
                    Top  += centerY + (Top * OverlayWindow.Height * .003 * Properties.Settings.Default.RadarZoom);
                    Left += centerX + (Left * OverlayWindow.Width * .003 * Properties.Settings.Default.RadarZoom);
                    if (drawMap.ContainsKey(c.ID))
                    {
                        drawMap[c.ID].Update(c);
                        Top  -= (drawMap[c.ID].ActualHeight / 2);
                        Left -= (drawMap[c.ID].ActualWidth / 2);
                        if (Top < 0)
                        {
                            Canvas.SetTop(drawMap[c.ID], 0);
                        }
                        else if (Top > OverlayWindow.Height - drawMap[c.ID].ActualHeight)
                        {
                            Canvas.SetTop(drawMap[c.ID], OverlayWindow.Height - drawMap[c.ID].ActualHeight);
                        }
                        else
                        {
                            Canvas.SetTop(drawMap[c.ID], Top);
                        }

                        if (Left < 0)
                        {
                            Canvas.SetLeft(drawMap[c.ID], 0);
                        }
                        else if (Left > OverlayWindow.Width - drawMap[c.ID].ActualWidth)
                        {
                            Canvas.SetLeft(drawMap[c.ID], OverlayWindow.Width - drawMap[c.ID].ActualWidth);
                        }
                        else
                        {
                            Canvas.SetLeft(drawMap[c.ID], Left);
                        }
                    }
                    else if (miscDrawMap.ContainsKey(c.PosX + c.PosY))
                    {
                        miscDrawMap[c.PosX + c.PosY].Update(c);
                        Top  -= (miscDrawMap[c.ID].ActualHeight / 2);
                        Left -= (miscDrawMap[c.ID].ActualWidth / 2);
                        Canvas.SetTop(miscDrawMap[c.PosX + c.PosY], Top);
                        Canvas.SetLeft(miscDrawMap[c.PosX + c.PosY], Left);
                    }
                }
            }

            //cleanup
            foreach (KeyValuePair <uint, EntityOverlayControl> entry in drawMap.ToArray())
            {
                //Hide hoard/cairn, after Banded Coffer appeared... hmm Hoard will re-appear if going out of "sight" and in again
                if (entry.Value.GetName().Equals("Hoard!") && (clist?.Any(c => c.EventType == EObjType.Banded) ?? false))
                {
                    entry.Value.Visibility = Visibility.Collapsed;
                    if (!hoardsDiscovered.Contains(entry.Key))
                    {
                        hoardsDiscovered.Add(entry.Key);
                    }
                    continue;
                }

                if (clist?.Exists(c => c.ID == entry.Key) ?? false)
                {
                    continue;
                }
                else
                {
                    entry.Value.Visibility = Visibility.Collapsed;
                    drawMap.Remove(entry.Key);
                }
            }
            foreach (KeyValuePair <float, EntityOverlayControl> entry in miscDrawMap.ToArray())
            {
                if (clist?.Exists(c => c.PosX + c.PosY == entry.Key) ?? false)
                {
                    continue;
                }
                else
                {
                    entry.Value.Visibility = Visibility.Collapsed;
                    miscDrawMap.Remove(entry.Key);
                }
            }
        }
Пример #22
0
 private void OverlayWindow_Loaded(object sender, RoutedEventArgs e) => OverlayWindow.HideFromAltTab();