internal void ListDraw()
        {
            try
            {
                tt.RemoveAll();
                foreach (Control it in panList.Controls)
                {
                    it.Dispose();
                }
                panList.Controls.Clear();

                panList.Size     = new Size(730, 0);
                panList.Location = new Point(0, 0);
                int y = 0;
                foreach (var it in r.Trains)
                {
                    string type_string = "";
                    switch (it.Data.Rank)
                    {
                    case TrainData.TrainRank.HIGH: type_string = TextManager.Get().Text("hightrain"); break;

                    case TrainData.TrainRank.DEFAULT: type_string = TextManager.Get().Text("defaulttrain"); break;
                    }

                    TrainList01 sl = new TrainList01(it, true, type_string, false, r.Name);
                    sl.Location = new Point(0, y);
                    panList.Controls.Add(sl);
                    y           += sl.Height;
                    panList.Size = new Size(730, y);
                    tt.SetToolTip(sl, $"{it.Name} ({it.Data.Name}, {type_string})");
                }

                if (panList.Controls.Count <= 10)
                {
                    panListBack.AutoScroll = false;
                    panListBack.Size       = new Size(730, panListBack.Height);
                }
                else
                {
                    panListBack.AutoScroll = true;
                    panListBack.Size       = new Size(750, panListBack.Height);
                }
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
示例#2
0
        public void ListDraw(string s = "")
        {
            try
            {
                foreach (Control it in panList.Controls)
                {
                    TrainList01 tl = it as TrainList01;

                    if (tl.isSelect)
                    {
                        Selects.Add(tl.t);
                    }
                }

                tt.RemoveAll();
                foreach (Control it in panList.Controls)
                {
                    it.Dispose();
                }
                panList.Controls.Clear();

                panList.Size     = new Size(730, 0);
                panList.Location = new Point(0, 0);

                int y = 0;

                if (s == string.Empty)
                {
                    foreach (var it in TrainManager.Trains)
                    {
                        if (it.Owner != GameManager.Company)
                        {
                            continue;
                        }

                        string type = "";
                        switch (it.Data.Rank)
                        {
                        case TrainData.TrainRank.HIGH: type = TextManager.Get().Text("hightrain"); break;

                        case TrainData.TrainRank.DEFAULT: type = TextManager.Get().Text("defaulttrain"); break;
                        }

                        string route_name = "";
                        if (it.Route == null)
                        {
                            route_name = TextManager.Get().Text("uninputtrain");
                        }
                        else
                        {
                            route_name = TextManager.Get().Text("trainroute").Replace("%ROUTENAME%", it.Route.Name);
                        }

                        TrainList01 lst = new TrainList01(it, false, type, true, route_name);
                        lst.Location = new Point(0, y);
                        panList.Controls.Add(lst);
                        y           += lst.Height;
                        panList.Size = new Size(730, y);
                        tt.SetToolTip(lst, $"{it.Name} ({it.Data.Name}, {type}, {route_name})");

                        if (Selects.Contains(it))
                        {
                            lst.isSelect  = true;
                            lst.BackColor = ResourceManager.Get("list.trainlist01.background.select");
                        }
                    }

                    Selects = new List <Train>();
                }
                else
                {
                    List <string> names = new List <string>();
                    foreach (var it in TrainManager.Trains)
                    {
                        if (it.Owner == GameManager.Company)
                        {
                            names.Add(it.Name);
                        }
                    }

                    List <string> result = RTAPI.StringAPI.Search(names, s);

                    foreach (var it in TrainManager.Trains)
                    {
                        if (it.Owner != GameManager.Company)
                        {
                            continue;
                        }
                        if (!result.Contains(it.Name))
                        {
                            continue;
                        }

                        string type = "";
                        switch (it.Data.Rank)
                        {
                        case TrainData.TrainRank.HIGH: type = TextManager.Get().Text("hightrain"); break;

                        case TrainData.TrainRank.DEFAULT: type = TextManager.Get().Text("defaulttrain"); break;
                        }

                        string route_name = "";
                        if (it.Route == null)
                        {
                            route_name = TextManager.Get().Text("uninputtrain");
                        }
                        else
                        {
                            route_name = TextManager.Get().Text("trainroute").Replace("%ROUTENAME%", it.Route.Name);
                        }

                        TrainList01 lst = new TrainList01(it, false, type, true, route_name);
                        lst.Location = new Point(0, y);
                        panList.Controls.Add(lst);
                        y           += lst.Height;
                        panList.Size = new Size(730, y);
                        tt.SetToolTip(lst, $"{it.Name} ({it.Data.Name}, {type}, {route_name})");

                        if (Selects.Contains(it))
                        {
                            lst.isSelect  = true;
                            lst.BackColor = ResourceManager.Get("list.trainlist01.background.select");
                        }
                    }
                }

                if (panList.Controls.Count <= 9)
                {
                    panListBack.AutoScroll = false;
                    panListBack.Size       = new Size(730, panListBack.Height);
                }
                else
                {
                    panListBack.AutoScroll = true;
                    panListBack.Size       = new Size(750, panListBack.Height);
                }
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
        internal void ListDraw(string search = "")
        {
            List <Train> Selects = new List <Train>();

            foreach (Control it in panList.Controls)
            {
                if (it is TrainList01)
                {
                    TrainList01 lst = it as TrainList01;

                    if (lst.isSelect)
                    {
                        Selects.Add(lst.t);
                    }
                }
            }

            tt.RemoveAll();
            foreach (Control it in panList.Controls)
            {
                it.Dispose();
            }
            panList.Controls.Clear();

            panList.Size     = new Size(730, 0);
            panList.Location = new Point(0, 0);

            if (search == string.Empty)
            {
                int y = 0;
                foreach (var it in TrainManager.Trains)
                {
                    if (it.Route != null)
                    {
                        continue;
                    }
                    if (it.Owner != GameManager.Company)
                    {
                        continue;
                    }

                    string type_string = "";
                    switch (it.Data.Rank)
                    {
                    case TrainData.TrainRank.HIGH: type_string = TextManager.Get().Text("hightrain"); break;

                    case TrainData.TrainRank.DEFAULT: type_string = TextManager.Get().Text("defaulttrain"); break;
                    }

                    TrainList01 sl = new TrainList01(it, true, type_string);
                    sl.Location = new Point(0, y);
                    panList.Controls.Add(sl);
                    y           += sl.Height;
                    panList.Size = new Size(730, y);

                    tt.SetToolTip(sl, $"{it.Name} ({it.Data.Name}, {type_string})");

                    if (Selects.Contains(it))
                    {
                        sl.isSelect = true;
                        BackColor   = ResourceManager.Get("list.trainlist01.background.sel");
                    }
                }
            }
            else
            {
                List <string> all_item = new List <string>();
                foreach (var it in TrainManager.Trains)
                {
                    if (it.Route != null)
                    {
                        continue;
                    }
                    if (it.Owner != GameManager.Company)
                    {
                        continue;
                    }

                    all_item.Add(it.Name);
                }

                List <string> result = RTAPI.StringAPI.Search(all_item, search);

                int y = 0;
                foreach (var it in TrainManager.Trains)
                {
                    if (it.Route != null)
                    {
                        continue;
                    }
                    if (it.Owner != GameManager.Company)
                    {
                        continue;
                    }
                    if (!result.Contains(it.Name))
                    {
                        continue;
                    }

                    string type_string = "";
                    switch (it.Data.Rank)
                    {
                    case TrainData.TrainRank.HIGH: type_string = TextManager.Get().Text("hightrain"); break;

                    case TrainData.TrainRank.DEFAULT: type_string = TextManager.Get().Text("defaulttrain"); break;
                    }

                    TrainList01 sl = new TrainList01(it, true, type_string);
                    sl.Location = new Point(0, y);
                    panList.Controls.Add(sl);
                    y           += sl.Height;
                    panList.Size = new Size(730, y);

                    tt.SetToolTip(sl, $"{it.Name} ({it.Data.Name}, {type_string})");

                    if (Selects.Contains(it))
                    {
                        sl.isSelect = true;
                        BackColor   = ResourceManager.Get("list.trainlist01.background.sel");
                    }
                }
            }

            if (panList.Controls.Count <= 9)
            {
                panListBack.AutoScroll = false;
                panListBack.Size       = new Size(730, panListBack.Height);
            }
            else
            {
                panListBack.AutoScroll = true;
                panListBack.Size       = new Size(750, panListBack.Height);
            }
        }