Esempio n. 1
0
        private void TopNav_Load(object sender, EventArgs _)
        {
            btnLogin.PopupOpen += btnImport_PopupShowing;
            btnLogin_New.Click += (s, e) =>
            {
                new Login().ShowDialog();
            };
            btnOpt.Click += (s, e) => new ConfigCenter().ShowDialog();
            btnQueryWithoutLogin.Click += (s, e) => MainForm.Instance.OpenQueryPageWithoutLogin();
            btnLearn.Click             += (s, e) => Shell.StartUrl("https://blog.iccfish.com/docs/%E8%AE%A2%E7%A5%A8%E5%8A%A9%E6%89%8B-net/");
            btnLoginUsingQr.Click      += (s, e) =>
            {
                new QrLogin().Show(this.FindForm());
            };

            InitLinks();

            var endDate = ParamData.GetMaxTicketDate(false);

            de.Date         = endDate;
            de.DateChanged += (s, e) =>
            {
                de.Date = endDate;
            };
        }
 /// <summary>
 /// 创建 <see cref="QueryParam" />  的新实例(QueryParam)
 /// </summary>
 public QueryParam()
 {
     Name                = "新建查询";
     IsLoaded            = true;
     EnableAutoPreSubmit = false;
     DepartureTimeTo     = 23;
     ArriveTimeTo        = 23;
     AutoPreSubmitConfig.EnableOClockRefresh = true;
     AutoPreSubmitConfig.AutoWaitToSell      = true;
     EnableAutoVC        = false;
     DepartureDate       = ParamData.GetMaxTicketDate(false);
     _enableTrainSuggest = QueryConfiguration.Current.EnableAutoSuggest;
 }
Esempio n. 3
0
 void RefreshSellStatus()
 {
     MaxDate = ParamData.GetMaxTicketDate(StudentTicket);
     foreach (var date in Items.Cast <DateWrap>())
     {
         if (date <= MaxDate)
         {
             date.BeginSellDate = null;
         }
         else
         {
             date.BeginSellDate = ParamData.GetBeginSellTime(date.Date, StudentTicket);
         }
     }
     Invalidate();
 }
        /// <summary>
        /// 刷新起售站预售时间提醒
        /// </summary>
        void LoadStartStationTip(TOBA.Query.Entity.QueryResult result)
        {
            if (!IsControlVisible)
            {
                return;
            }

            var cacheKey = $"{result.Date.DayOfYear}{QueryParam.FromStationCode}{QueryParam.ToStationCode}{DateTime.Now.Minute / 30}";

            if (!Configuration.QueryConfiguration.Current.EnableStartStationTip)
            {
                pSellTipContainer.Visible = false;
                btnEnableSellTip.Visible  = false;
                return;
            }

            if (cacheKey == _tipCacheKey)
            {
                return;
            }

            var list = new List <ListViewItem>();

            if (result.Date >= ParamData.GetMaxTicketDate(QueryParam.QueryStudentTicket))
            {
                foreach (var train in result.Where(s => s.StartStationSellInfo != null).GroupBy(s => s.StartStation.StationName))
                {
                    var item = new ListViewItem()
                    {
                        ImageIndex = 0
                    };
                    var trains = train.ToArray();
                    item.Tag = trains;

                    var info = trains[0].StartStationSellInfo;
                    item.Text = $"车次【{trains.Select(s => s.Code).JoinAsString("/")}】的始发站【{train.Key}】的起售时间为【{info.SellTime.ToShortTimeString()}】,{(info.IsInSell ? "已经起售" : info.IsEarly ? "时间早一些,可以提前关注" : "可以稍后关注")}";
                    if (info.IsInSell)
                    {
                        item.ForeColor = Color.Red;
                    }
                    else if (info.IsEarly)
                    {
                        item.ForeColor = Color.RoyalBlue;
                    }
                    else
                    {
                        item.ForeColor = Color.Green;
                    }

                    list.Add(item);
                }
            }
            //是否车次过少?
            if (result.Count <= 3)
            {
                list.Add(new ListViewItem("车次较少,建议更改查询条件。如果两站之间没有更多的车次,可试试中转查询。")
                {
                    ImageIndex = 0, ForeColor = Color.BlueViolet
                });
            }
            var feCount = result.Count(s => s.FromStation.IsFirst && s.ToStation.IsEnd);

            if (feCount < 3 && feCount < result.Count / 3)
            {
                list.Add(new ListViewItem("大多数车次为过路车。如果站不大容易导致车票难买,可考虑跨站购票。")
                {
                    ImageIndex = 0, ForeColor = Color.BlueViolet
                });
            }
            var notSellList = result.Where(s => s.BeginSellTime != null && !s.FromStation.IsFirst).ToArray();

            if (notSellList.Length > 0)
            {
                list.Add(new ListViewItem($"车次【{notSellList.Select(s => s.Code).JoinAsString("/")}】尚未起售,但不是始发站。建议留意对应车次之前几站以及始发站的起售时间,可以碰碰运气是否能拿到票。")
                {
                    ImageIndex = 0, ForeColor = Color.BlueViolet
                });
            }

            lvSellTip.Items.Clear();
            lvSellTip.Items.AddRange(list.ToArray());

            var hasTip = lvSellTip.Items.Count > 0;

            if (QueryParam.UiSetting.EnableSellTip)
            {
                pSellTipContainer.Visible = hasTip;
            }
            else
            {
                btnEnableSellTip.Visible = hasTip;
            }

            _tipCacheKey = cacheKey;
        }