Esempio n. 1
0
 public override Vector2 Size()
 {
     int width = m_winRect.right - m_winRect.left;
     int height = m_winRect.bottom - m_winRect.top;
     WinAPI.POINT ret = new WinAPI.POINT();
     ret.x = width;
     ret.y = height;
     return new Vector2(ret.x, ret.y);
 }
Esempio n. 2
0
        public override Vector2 Size()
        {
            int width  = m_winRect.right - m_winRect.left;
            int height = m_winRect.bottom - m_winRect.top;

            WinAPI.POINT ret = new WinAPI.POINT();
            ret.x = width;
            ret.y = height;
            return(new Vector2(ret.x, ret.y));
        }
Esempio n. 3
0
        public override Vector2 ConvertToScreen(Vector2 point)
        {
            WinAPI.POINT ret = new WinAPI.POINT();
            ret.x = point.x;
            ret.y = point.y;

            WinAPI.ClientToScreen(WindowHandle, ref ret);

            return(new Vector2(ret.x, ret.y));
        }
Esempio n. 4
0
        public override Vector2 ConvertToScreen(Vector2 point)
        {
            WinAPI.POINT ret = new WinAPI.POINT();
            ret.x = point.x;
            ret.y = point.y;

            WinAPI.ClientToScreen(WindowHandle, ref ret);

            return new Vector2(ret.x, ret.y);
        }
Esempio n. 5
0
        internal void RefleshLayeredForm()
        {
            Bitmap   formBitMap = new Bitmap(base.Width, base.Height);
            Graphics g          = Graphics.FromImage(formBitMap);

            DrawShadow(g);

            WinAPI.POINT ptSrc     = new WinAPI.POINT(0, 0);
            WinAPI.POINT ptWinPos  = new WinAPI.POINT(base.Left, base.Top);
            WinAPI.SIZE  szWinSize = new WinAPI.SIZE(Width, Height);
            byte         biAlpha   = 0xFF;

            WinAPI.BLENDFUNCTION stBlend = new WinAPI.BLENDFUNCTION(
                (byte)WinAPI.BlendOp.AC_SRC_OVER, 0, biAlpha, (byte)WinAPI.BlendOp.AC_SRC_ALPHA);

            IntPtr gdiBitMap = IntPtr.Zero;
            IntPtr memoryDC  = IntPtr.Zero;
            IntPtr preBits   = IntPtr.Zero;
            IntPtr screenDC  = IntPtr.Zero;

            try
            {
                screenDC = WinAPI.GetDC(IntPtr.Zero);
                memoryDC = WinAPI.CreateCompatibleDC(screenDC);

                gdiBitMap = formBitMap.GetHbitmap(Color.FromArgb(0));

                preBits = WinAPI.SelectObject(memoryDC, gdiBitMap);
                WinAPI.UpdateLayeredWindow(base.Handle
                                           , screenDC
                                           , ref ptWinPos
                                           , ref szWinSize
                                           , memoryDC
                                           , ref ptSrc
                                           , 0
                                           , ref stBlend
                                           , (uint)WinAPI.ULWPara.ULW_ALPHA);
            }
            finally
            {
                if (gdiBitMap != IntPtr.Zero)
                {
                    WinAPI.SelectObject(memoryDC, preBits);
                    WinAPI.DeleteObject(gdiBitMap);
                }

                WinAPI.DeleteDC(memoryDC);
                WinAPI.ReleaseDC(IntPtr.Zero, screenDC);
                g.Dispose();
                formBitMap.Dispose();
            }
        }
Esempio n. 6
0
        public override void Move(int x, int y)
        {
            Vector2 size = WindowHandle.Size();

            WinAPI.POINT p = new WinAPI.POINT();
            p.x = x;
            p.y = y;

            osu.OsuOptions.Convert(ref p, size.x, size.y);

            Vector2 converted = WindowHandle.ConvertToScreen(new Vector2(p.x, p.y));
            p.x = converted.x;
            p.y = converted.y;
            WinAPI.SetCursorPos(p.x, p.y);
        }
Esempio n. 7
0
        public override void Move(int x, int y)
        {
            Vector2 size = WindowHandle.Size();

            WinAPI.POINT p = new WinAPI.POINT();
            p.x = x;
            p.y = y;

            osu.OsuOptions.Convert(ref p, size.x, size.y);

            Vector2 converted = WindowHandle.ConvertToScreen(new Vector2(p.x, p.y));

            p.x = converted.x;
            p.y = converted.y;
            WinAPI.SetCursorPos(p.x, p.y);
        }
Esempio n. 8
0
        private void AdjustForm()
        {
            if (!Renderer.Initialized)
            {
                return;
            }


            Form.Invoke((MethodInvoker) delegate
            {
                WinAPI.BringWindowToTop(Form.Handle);
                WinAPI.RECT rect = new WinAPI.RECT();
                WinAPI.POINT pt  = new WinAPI.POINT();

                if (WinAPI.GetClientRect(Process.Process.MainWindowHandle, out rect) &&
                    WinAPI.ClientToScreen(Process.Process.MainWindowHandle, out pt))
                {
                    bool sizeChanged =
                        Form.Width != rect.Right - rect.Left ||
                        Form.Height != rect.Bottom - rect.Top;

                    bool posChanged =
                        Form.Location.X != pt.X ||
                        Form.Location.Y != pt.Y;

                    if (sizeChanged)
                    {
                        Size = new Vector2(rect.Right - rect.Left, rect.Bottom - rect.Top);
                        //BaseContainer.Bounds.Size = Size;
                    }
                    if (posChanged || sizeChanged)
                    {
                        WinAPI.SetWindowPos(Form.Handle,
                                            IntPtr.Zero,
                                            pt.X,
                                            pt.Y,
                                            rect.Right - rect.Left,
                                            rect.Bottom - rect.Top,
                                            0);
                    }
                }
            });
        }
 public MouseEventExtArgs(MouseButtons b, int clickcount, WinAPI.POINT point, int delta)
     : base(b, clickcount, point.X, point.Y, delta)
 {
 }
Esempio n. 10
0
        public void SetBits()
        {
            //绘制绘图层背景
            Bitmap    bitmap         = new Bitmap(Main.Width + 10, Main.Height + 10);
            Rectangle _BacklightLTRB = new Rectangle(20, 20, 20, 20);//窗体光泽重绘边界
            Graphics  g = Graphics.FromImage(bitmap);

            g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            ImageDrawRect.DrawRect(g, shadowimg, ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);

            // RenderHelper.DrawImageWithNineRect(g, shadowimg, ClientRectangle, new Rectangle { Size = shadowimg.Size });

            if (!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
            {
                throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");
            }

            WinAPI.POINT ptSrc     = new WinAPI.POINT(0, 0);
            WinAPI.POINT ptWinPos  = new WinAPI.POINT(base.Left, base.Top);
            WinAPI.SIZE  szWinSize = new WinAPI.SIZE(Width, Height);
            byte         biAlpha   = 0xFF;

            WinAPI.BLENDFUNCTION stBlend = new WinAPI.BLENDFUNCTION(
                (byte)WinAPI.BlendOp.AC_SRC_OVER, 0, biAlpha, (byte)WinAPI.BlendOp.AC_SRC_ALPHA);

            IntPtr gdiBitMap = IntPtr.Zero;
            IntPtr memoryDC  = IntPtr.Zero;
            IntPtr preBits   = IntPtr.Zero;
            IntPtr screenDC  = IntPtr.Zero;

            try
            {
                screenDC = WinAPI.GetDC(IntPtr.Zero);
                memoryDC = WinAPI.CreateCompatibleDC(screenDC);

                gdiBitMap = bitmap.GetHbitmap(Color.FromArgb(0));

                preBits = WinAPI.SelectObject(memoryDC, gdiBitMap);
                WinAPI.UpdateLayeredWindow(base.Handle
                                           , screenDC
                                           , ref ptWinPos
                                           , ref szWinSize
                                           , memoryDC
                                           , ref ptSrc
                                           , 0
                                           , ref stBlend
                                           , (uint)WinAPI.ULWPara.ULW_ALPHA);
            }
            finally
            {
                if (gdiBitMap != IntPtr.Zero)
                {
                    WinAPI.SelectObject(memoryDC, preBits);
                    WinAPI.DeleteObject(gdiBitMap);
                }

                WinAPI.DeleteDC(memoryDC);
                WinAPI.ReleaseDC(IntPtr.Zero, screenDC);
                g.Dispose();
                bitmap.Dispose();
            }
        }
Esempio n. 11
0
        public override bool Act(AController controller, TimeSpan totalTime, TimeSpan elapsed, bool dTime)
        {
            if (m_init)
            {
                m_init = false;
                m_curX = m_sliderData.HitData.X;
                m_curY = m_sliderData.HitData.Y;
                controller.Press((int)m_curX, (int)m_curY);
            }
            m_totalElapsed += elapsed;
            //Console.WriteLine(m_curId + " " + m_sliderData.Points.Count + m_millisecondsToComplete);
            if (m_totalElapsed.TotalMilliseconds >= m_millisecondsToComplete + 10)
            {
                if (CheckIfRepeat() == false)
                {
                    controller.Release((int)m_curX, (int)m_curY);
                    return(true);
                }
                else
                {
                    if (m_sliderData.DataDistance >= MIN_SLIDER_DISTANCE)
                    {
                        controller.Move((int)m_curX, (int)m_curY);
                    }
                }
            }
            else if (m_curId < m_sliderData.Points.Count)
            {
                WinAPI.POINT destination = new WinAPI.POINT();
                float        msPerPoint  = m_millisecondsToComplete / ((float)m_sliderData.Points.Count - 1);

                destination = m_sliderData.Points[m_curId];
                if (m_curId == 0)
                {
                    m_curX = destination.x;
                    m_curY = destination.y;
                    controller.Move((int)m_curX, (int)m_curY);
                    IncreaseId(controller);
                }
                else
                {
                    float angleX = destination.x - m_curX;
                    float angleY = destination.y - m_curY;

                    float angle = (float)Math.Atan2(angleY, angleX);
                    float addX  = (float)Math.Cos(angle);
                    float addY  = (float)Math.Sin(angle);

                    if (m_checkChange)
                    {
                        m_checkChange = false;
                        m_checkX      = true;
                        m_checkY      = true;
                        if (m_curX < destination.x)
                        {
                            m_checkX = false;
                        }
                        if (m_curY < destination.y)
                        {
                            m_checkY = false;
                        }
                    }

                    const float BRUTE_FORCE_SLOWDOWN = .94f; //Have no idea why I need to do this, but my shit goes too fast
                    if (m_sliderData.Distance >= MIN_SLIDER_DISTANCE)
                    {
                        m_curX += addX * (((float)m_sliderData.Distance / m_millisecondsToComplete) * (float)elapsed.TotalMilliseconds) * BRUTE_FORCE_SLOWDOWN;
                        m_curY += addY * (((float)m_sliderData.Distance / m_millisecondsToComplete) * (float)elapsed.TotalMilliseconds) * BRUTE_FORCE_SLOWDOWN;

                        bool[] complete = new bool[2] {
                            false, false
                        };
                        if (!m_checkX)
                        {
                            if (m_curX >= destination.x)
                            {
                                complete[0] = true;
                            }
                        }
                        else
                        {
                            if (m_curX <= destination.x)
                            {
                                complete[0] = true;
                            }
                        }
                        if (!m_checkY)
                        {
                            if (m_curY >= destination.y)
                            {
                                complete[1] = true;
                            }
                        }
                        else
                        {
                            if (m_curY <= destination.y)
                            {
                                complete[1] = true;
                            }
                        }
                        if (complete[0] && complete[1])
                        {
                            IncreaseId(controller);
                        }
                    }
                    controller.Move((int)m_curX, (int)m_curY);
                }
            }

            return(false);
        }
Esempio n. 12
0
        public override bool Act(AController controller, TimeSpan totalTime, TimeSpan elapsed, bool dTime)
        {
            if (m_init)
            {
                m_init = false;
                m_curX = m_sliderData.HitData.X;
                m_curY = m_sliderData.HitData.Y;
                controller.Press((int)m_curX, (int)m_curY);
            }
            m_totalElapsed += elapsed;
            //Console.WriteLine(m_curId + " " + m_sliderData.Points.Count + m_millisecondsToComplete);
            if (m_totalElapsed.TotalMilliseconds >= m_millisecondsToComplete + 10)
            {
                if (CheckIfRepeat() == false)
                {
                    controller.Release((int)m_curX, (int)m_curY);
                    return true;
                }
                else
                {
                    if(m_sliderData.DataDistance >= MIN_SLIDER_DISTANCE)
                        controller.Move((int)m_curX, (int)m_curY);
                }
            }
            else if(m_curId < m_sliderData.Points.Count)
            {
                WinAPI.POINT destination = new WinAPI.POINT();
                float msPerPoint = m_millisecondsToComplete / ((float)m_sliderData.Points.Count - 1);

                destination = m_sliderData.Points[m_curId];
                if (m_curId == 0)
                {
                    m_curX = destination.x;
                    m_curY = destination.y;
                    controller.Move((int)m_curX, (int)m_curY);
                    IncreaseId(controller);
                }
                else
                {

                    float angleX = destination.x - m_curX;
                    float angleY = destination.y - m_curY;

                    float angle = (float)Math.Atan2(angleY, angleX);
                    float addX = (float)Math.Cos(angle);
                    float addY = (float)Math.Sin(angle);

                    if (m_checkChange)
                    {
                        m_checkChange = false;
                        m_checkX = true;
                        m_checkY = true;
                        if (m_curX < destination.x)
                        {
                            m_checkX = false;
                        }
                        if (m_curY < destination.y)
                        {
                            m_checkY = false;
                        }
                    }

                    const float BRUTE_FORCE_SLOWDOWN = .94f; //Have no idea why I need to do this, but my shit goes too fast
                    if (m_sliderData.Distance >= MIN_SLIDER_DISTANCE)
                    {
                        m_curX += addX * (((float)m_sliderData.Distance / m_millisecondsToComplete) * (float)elapsed.TotalMilliseconds) * BRUTE_FORCE_SLOWDOWN;
                        m_curY += addY * (((float)m_sliderData.Distance / m_millisecondsToComplete) * (float)elapsed.TotalMilliseconds) * BRUTE_FORCE_SLOWDOWN;

                        bool[] complete = new bool[2] { false, false };
                        if (!m_checkX)
                        {
                            if (m_curX >= destination.x)
                            {
                                complete[0] = true;
                            }
                        }
                        else
                        {
                            if (m_curX <= destination.x)
                            {
                                complete[0] = true;
                            }
                        }
                        if (!m_checkY)
                        {
                            if (m_curY >= destination.y)
                            {
                                complete[1] = true;
                            }
                        }
                        else
                        {
                            if (m_curY <= destination.y)
                            {
                                complete[1] = true;
                            }
                        }
                        if (complete[0] && complete[1])
                        {
                            IncreaseId(controller);
                        }
                    }
                    controller.Move((int)m_curX, (int)m_curY);
                }
            }

            return false;
        }
Esempio n. 13
0
        protected override void Parse(System.IO.StreamReader reader, string line)
        {
            if (line != null)
            {
                string curveData = "";
                if (line.Contains("B|"))
                {
                    curveData = line.Substring(line.IndexOf(',', line.IndexOf("B|") - 1));
                }
                else if (line.Contains("C|"))
                {
                    curveData = line.Substring(line.IndexOf(',', line.IndexOf("C|") - 1));
                }
                else if (line.Contains("|"))
                {
                    curveData = line.Substring(line.IndexOf(',', line.IndexOf("|") - 2));
                }
                int      points = curveData.Count(f => f == ':');
                double[] data   = Parsers.NumbersFromString.Parse(curveData);

                WinAPI.POINT startPoint = new WinAPI.POINT();
                startPoint.x = HitData.X;
                startPoint.y = HitData.Y;
                m_points.Add(startPoint);

                for (int i = 0; i < points; i++)
                {
                    WinAPI.POINT point = new WinAPI.POINT();
                    point.x = (int)data[i * 2];
                    point.y = (int)data[i * 2 + 1];
                    m_points.Add(point);
                }

                m_useCount = (int)data[(points * 2)];
                m_distance = (int)data[(points * 2) + 1];


                double[] dPoints = new double[m_points.Count * 2];
                for (int i = 0; i < m_points.Count; i++)
                {
                    dPoints[i * 2]     = m_points[i].x;
                    dPoints[i * 2 + 1] = m_points[i].y;
                }

                double[]           dCurvePoints = new double[dPoints.Length];
                Curves.BezierCurve bCurve       = new Curves.BezierCurve();
                bCurve.Bezier2D(dPoints, m_points.Count, dCurvePoints);

                for (int i = 0; i < dCurvePoints.Length / 2; i++)
                {
                    WinAPI.POINT point = new WinAPI.POINT();
                    point.x = (int)dCurvePoints[i * 2];
                    point.y = (int)dCurvePoints[i * 2 + 1];
                    m_curvePoints.Add(point);
                }

                for (int i = 0; i < m_curvePoints.Count; i++)
                {
                    if (i > 0)
                    {
                        int   disX = Math.Abs(m_curvePoints[i].x) - Math.Abs(m_curvePoints[i - 1].x);
                        int   disY = Math.Abs(m_curvePoints[i].y) - Math.Abs(m_curvePoints[i - 1].y);
                        float add  = (float)Math.Sqrt((disX * disX) + (disY * disY));
                        m_totalDistance += add;
                    }
                }
            }
        }
Esempio n. 14
0
        protected override void Parse(System.IO.StreamReader reader, string line)
        {
            if (line != null)
            {
                string curveData = "";
                if (line.Contains("B|"))
                {
                    curveData = line.Substring(line.IndexOf(',', line.IndexOf("B|") - 1));
                }
                else if (line.Contains("C|"))
                {
                    curveData = line.Substring(line.IndexOf(',', line.IndexOf("C|") - 1));
                }
                else if (line.Contains("|"))
                {
                    curveData = line.Substring(line.IndexOf(',', line.IndexOf("|") - 2));
                }
                int points = curveData.Count(f => f == ':');
                double[] data = Parsers.NumbersFromString.Parse(curveData);

                WinAPI.POINT startPoint = new WinAPI.POINT();
                startPoint.x = HitData.X;
                startPoint.y = HitData.Y;
                m_points.Add(startPoint);

                for (int i = 0; i < points; i++)
                {
                    WinAPI.POINT point = new WinAPI.POINT();
                    point.x = (int)data[i * 2];
                    point.y = (int)data[i * 2 + 1];
                    m_points.Add(point);
                }

                m_useCount = (int)data[(points * 2)];
                m_distance = (int)data[(points * 2) + 1];

                double[] dPoints = new double[m_points.Count * 2];
                for (int i = 0; i < m_points.Count; i++)
                {
                    dPoints[i * 2] = m_points[i].x;
                    dPoints[i * 2 + 1] = m_points[i].y;
                }

                double[] dCurvePoints = new double[dPoints.Length];
                Curves.BezierCurve bCurve = new Curves.BezierCurve();
                bCurve.Bezier2D(dPoints, m_points.Count, dCurvePoints);

                for (int i = 0; i < dCurvePoints.Length / 2; i++)
                {
                    WinAPI.POINT point = new WinAPI.POINT();
                    point.x = (int)dCurvePoints[i * 2];
                    point.y = (int)dCurvePoints[i * 2 + 1];
                    m_curvePoints.Add(point);
                }

                for (int i = 0; i < m_curvePoints.Count; i++)
                {
                    if (i > 0)
                    {
                        int disX = Math.Abs(m_curvePoints[i].x) - Math.Abs(m_curvePoints[i - 1].x);
                        int disY = Math.Abs(m_curvePoints[i].y) - Math.Abs(m_curvePoints[i - 1].y);
                        float add = (float)Math.Sqrt((disX * disX) + (disY * disY));
                        m_totalDistance += add;
                    }
                }
            }
        }