Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            this.Topmost = true;

            t    = new TimeManager();
            c.dl = t;
            Binding binding = new Binding();

            binding.Source = t;
            binding.Path   = new PropertyPath("TimeFormatted");
            BindingOperations.SetBinding(this.timeLabel, Label.ContentProperty, binding);

            binding        = new Binding();
            binding.Source = c;
            binding.Path   = new PropertyPath("PositionFormat");
            BindingOperations.SetBinding(this.positionLabel, Label.ContentProperty, binding);

            var defaultX = SettingDAO.getValueByKey("DEFAULTX");
            var defaultY = SettingDAO.getValueByKey("DEFAULTY");

            if (defaultX == "-1" || defaultY == "-1")
            {
                defaultX = SettingDAO.getValueByKey("19201080X");
                defaultY = SettingDAO.getValueByKey("19201080Y");
            }
            c.Position = new System.Drawing.Point(Convert.ToInt32(defaultX), Convert.ToInt32(defaultY));

            lstMessage.Items.Add("00:13 huoquan");
            lstMessage.Items.Add("00:16 huoquan");

            t.timelines.Add("00:13 huoquan");
            t.timelines.Add("00:16 huoquan");
        }
Пример #2
0
        private void captureTimer_Tick(object sender, EventArgs e)
        {
            var width  = 1;
            var height = 1;
            var image  = new System.Drawing.Bitmap(width, height);

            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image))
            {
                g.CopyFromScreen(position.X, position.Y, 0, 0, new System.Drawing.Size(width, height));
                int sum = 0;
                for (int x = 0; x < image.Width; x++)
                {
                    for (int y = 0; y < image.Height; y++)
                    {
                        var pixelColor = image.GetPixel(x, y);
                        sum += pixelColor.R + pixelColor.G + pixelColor.B;
                    }
                }
                avgRGB = sum / 3;
                if (!didSetCursor)
                {
                    Position = System.Windows.Forms.Control.MousePosition;
                }
                Console.WriteLine(avgRGB);
                if (avgRGB >= 210)
                {
                    if (!didSetCursor)
                    {
                        didSetCursor = true;
                        SettingDAO.updateValueByKey("DEFAULTX", Position.X.ToString());
                        SettingDAO.updateValueByKey("DEFAULTY", Position.Y.ToString());
                        captureTimer.Stop();
                        System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show("进战图标位置重设完成,若是不小心移动到其他白色区域而触发此对话框,可以再" +
                                                                                                "点击刚才的按钮继续重新设定,请确保最终位置是在进入战斗图标(两柄交叉小剑)的交叉处或者刀刃处(最白的地方)",
                                                                                                "重设确认",
                                                                                                System.Windows.MessageBoxButton.OK);
                    }
                    else
                    {
                        Console.WriteLine("Battel Start");
                        dl.BattelDidStart();
                        isBattelStarted = true;
                        captureTimer.Stop();
                    }
                }
            }
        }