示例#1
0
文件: UI.cs 项目: Kxnrl/DNF-GoldCoin
 private void OnFormResized(object sender, EventArgs e)
 {
     if (WindowState == FormWindowState.Minimized)
     {
         myHandle = Process.GetCurrentProcess().MainWindowHandle;
         Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_HIDE);
         BG_Notifaction.BalloonTipTitle = "DNF金币比价器";
         BG_Notifaction.BalloonTipText  = "现在已经开始后台工作啦.~";
         BG_Notifaction.ShowBalloonTip(3000);
     }
 }
示例#2
0
文件: UI.cs 项目: Kxnrl/DNF-GoldCoin
        private void ApplicationHandler_TrayIcon(object sender, EventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            if (item == exitButton)
            {
                BG_Notifaction.Visible = false;
                BG_Notifaction.Icon    = null;
                BG_Notifaction.Dispose();
                Thread.Sleep(100);
                SaveConfigs();
                Environment.Exit(0);
            }
            else if (item == showHide)
            {
                Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_SHOW);
            }
        }
示例#3
0
 private void OnFormClosing(object sender, FormClosingEventArgs e)
 {
     if (ES_KeepAlive.Checked)
     {
         e.Cancel = true;
         myHandle = Process.GetCurrentProcess().MainWindowHandle;
         Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_HIDE);
         BG_Notifaction.BalloonTipTitle = "DNF金币比价器";
         BG_Notifaction.BalloonTipText  = "现在已经开始后台工作啦.~";
         BG_Notifaction.ShowBalloonTip(3000);
     }
     else
     {
         BG_Notifaction.Visible = false;
         BG_Notifaction.Icon    = null;
         BG_Notifaction.Dispose();
         Thread.Sleep(100);
     }
 }
示例#4
0
文件: UI.cs 项目: Kxnrl/DNF-GoldCoin
        private void OnFormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;

            if (N_Background)
            {
                myHandle = Process.GetCurrentProcess().MainWindowHandle;
                Win32Api.Window.ShowWindow(myHandle, Win32Api.Window.SW_HIDE);
                BG_Notifaction.BalloonTipTitle = "DNF金币比价器";
                BG_Notifaction.BalloonTipText  = "现在已经开始后台工作啦.~";
                BG_Notifaction.ShowBalloonTip(3000);
            }
            else if (!closing)
            {
                BG_Notifaction.Visible = false;
                BG_Notifaction.Icon    = null;
                BG_Notifaction.Dispose();

                closing = true;

                new Thread(() =>
                {
                    Thread.Sleep(1000);
                    while (beginUpdate)
                    {
                        Thread.Sleep(100);
                    }
                    Invoke(new Action(() =>
                    {
                        Close();
                        Dispose();
                        Environment.ExitCode = 10086;
                    }));
                })
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.Lowest,
                    Name         = "Cleaner thread"
                }.Start();
            }
        }
示例#5
0
文件: UI.cs 项目: Kxnrl/DNF-GoldCoin
        private void RefreshData()
        {
            if (closing)
            {
                return;
            }

            beginUpdate = true;

            var arena = Arena.跨1;

            Invoke(new Action(() =>
            {
                ES_Refresh.Enabled = false;
                Label_CD.Text      = "...";
                arena = (Arena)Enum.Parse(typeof(Arena), ES_Arena.Items[ES_Arena.SelectedIndex].ToString());
            }));

            var items = new List <ItemData>();
            var tasks = new List <Task>();

            if (ES_UU898.Checked)
            {
                tasks.Add(Task.Run(() => Spider.UU898.FetchData(arena, items)));
            }

            if (ES_DD373.Checked)
            {
                tasks.Add(Task.Run(() => Spider.DD373.FetchData(arena, items)));
            }

            if (ES_EE979.Checked)
            {
                tasks.Add(Task.Run(() => Spider.EE979.FetchData(arena, items)));
            }

            if (ES_7881.Checked)
            {
                tasks.Add(Task.Run(() => Spider.S7881.FetchData(arena, items)));
            }

            if (ES_5173.Checked)
            {
                tasks.Add(Task.Run(() => Spider.S5173.FetchData(arena, items)));
            }

            Task.WaitAll(tasks.ToArray(), 2333);

            Invoke(new Action(() =>
            {
                var count = 0;
                var ratio = 0.0f;

                SetAllControls(false);

                ItemsList.Rows.Clear();

                foreach (var item in items.OrderByDescending(p => p.Ratio).ToList())
                {
                    // 过滤之前检查到已经被购买的
                    if (BuyCheck.Contains(item.pGUID))
                    {
                        // 已被买
                        Debug.Print("Ignore [{0}]", item.pGUID);
                        continue;
                    }

                    // 过滤异常不能交易的金币?
                    // 黑商你妈死了?
                    // 哄抬你妈的金价呢?
                    if (item.Price >= 10000f || item.Ratio >= 100f)
                    {
                        continue;
                    }

                    // 交易设置过滤
                    if (item.Trade is Trade.交易 && !N_AllowTrade_T)
                    {
                        // 不允许当面交易
                        continue;
                    }
                    if (item.Trade is Trade.邮寄 && !N_AllowTrade_M)
                    {
                        // 不允许邮寄交易
                        continue;
                    }
                    if (item.Trade is Trade.拍卖 && !N_AllowTrade_S)
                    {
                        // 不允许拍卖交易
                        continue;
                    }

                    // 通知中心
                    if (N_Enabled &&
                        item.Price <= N_MaxPrice &&
                        item.Ratio >= N_MinRatio)
                    {
                        count++;

                        if (item.Ratio > ratio)
                        {
                            ratio = item.Ratio;
                        }
                    }

                    ItemDict[item.pGUID] = item;
                    ItemsList.Rows.Add(item.pGUID, item.Coins, (float)(item.Coins * (item.Trade == Trade.邮寄 ? 0.95 : 0.97)), item.Price, item.Ratio, item.Arena, Enum.GetName(typeof(Trade), item.Trade), Enum.GetName(typeof(Sites), item.Sites).Replace("Site_", ""), RandomButton(), item.bLink);
                }

                if (count > 0)
                {
                    BG_Notifaction.BalloonTipTitle = "DNF金币比价器";
                    BG_Notifaction.BalloonTipText  = "发现了 " + count + " 件商品符合要求, 最高比例为 1:" + ratio.ToString("N2");
                    BG_Notifaction.ShowBalloonTip(10000);
                }

                SetAllControls(true);

                ItemsList.Update();
                ItemsList.ClearSelection();

                Text = "DNF金币比价器" + "   " + "[" + Enum.GetName(typeof(Arena), arena) + "]";
            }));

            tickTimer = 30;
            TimerCountDown();
            beginUpdate = false;
        }
示例#6
0
        private void RefreshData()
        {
            beginUpdate = true;

            var arena = Arena.跨1;

            Invoke(new Action(() =>
            {
                ES_Refresh.Enabled = false;
                Label_CD.Text      = "...";
                arena = (Arena)Enum.Parse(typeof(Arena), ES_Arena.Items[ES_Arena.SelectedIndex].ToString());
            }));

            List <ItemData> items = new List <ItemData>();

            var resetEvent = new ManualResetEvent[4];

            resetEvent[0] = new ManualResetEvent(false);
            resetEvent[1] = new ManualResetEvent(false);
            resetEvent[2] = new ManualResetEvent(false);
            resetEvent[3] = new ManualResetEvent(false);

            if (ES_UU898.Checked)
            {
                new Thread(() =>
                {
                    Spider.UU898.FetchData(arena, items);
                    resetEvent[0].Set();
                })
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.BelowNormal,
                    Name         = "Fetch UU898"
                }.Start();
            }

            if (ES_DD373.Checked)
            {
                new Thread(() =>
                {
                    Spider.DD373.FetchData(arena, items);
                    resetEvent[1].Set();
                })
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.BelowNormal,
                    Name         = "Fetch DD373"
                }.Start();
            }

            if (ES_7881.Checked)
            {
                new Thread(() =>
                {
                    Spider.S7881.FetchData(arena, items);
                    resetEvent[2].Set();
                })
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.BelowNormal,
                    Name         = "Fetch 7881"
                }.Start();
            }

            if (ES_5173.Checked)
            {
                new Thread(() =>
                {
                    Spider.S5173.FetchData(arena, items);
                    resetEvent[3].Set();
                })
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.BelowNormal,
                    Name         = "Fetch 5173"
                }.Start();
            }

            WaitHandle.WaitAll(resetEvent);

            Invoke(new Action(() =>
            {
                var count = 0;
                var ratio = 0.0f;

                SetAllControls(false);

                ItemsList.Rows.Clear();

                foreach (var item in items.OrderByDescending(p => p.Ratio).ToList())
                {
                    if (N_Enabled &&
                        item.Price <= N_MaxPrice &&
                        item.Ratio >= N_MinRatio)
                    {
                        count++;

                        if (item.Ratio > ratio)
                        {
                            ratio = item.Ratio;
                        }
                    }

                    ItemsList.Rows.Add(item.pGUID, item.Coins, (float)(item.Coins * (item.Trade == Trade.邮寄 ? 0.95 : 0.97)), item.Price, item.Ratio, item.Arena, Enum.GetName(typeof(Trade), item.Trade), Enum.GetName(typeof(Sites), item.Sites).Replace("Site_", ""), RandomButton(), item.bLink);
                }

                if (count > 0)
                {
                    BG_Notifaction.BalloonTipTitle = "DNF金币比价器";
                    BG_Notifaction.BalloonTipText  = "发现了 " + count + " 件商品符合要求, 最高比例为 1:" + ratio.ToString("N2");
                    BG_Notifaction.ShowBalloonTip(10000);
                }

                SetAllControls(true);

                Text = "DNF金币比价器" + "   " + "[" + Enum.GetName(typeof(Arena), arena) + "]";
            }));

            tickTimer = 30;
            TimerCountDown();
            beginUpdate = false;
        }