private void lbBack_Click(object sender, EventArgs e)
 {
     try
     {
         if (OldPage == null)
         {
             PageManager.Close(false, AccessManager.AccessKey);
         }
         else
         {
             if (OldPage is RouteControl_TrainList_Page)
             {
                 (OldPage as RouteControl_TrainList_Page).ListDraw();
             }
             if (OldPage is TrainList_OKAdd_Page)
             {
                 (OldPage as TrainList_OKAdd_Page).ListDraw();
             }
             PageManager.SetPage(OldPage, AccessManager.AccessKey);
         }
     }
     catch (Exception ex)
     {
         RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
     }
 }
        private void lbAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text.Trim() == string.Empty)
                {
                    return;
                }
                foreach (var it in TrainManager.Trains)
                {
                    if (it.Name == txtName.Text.Trim())
                    {
                        MessageBox.Show(TextManager.Get().Text("truetrain"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                }

                if (GameManager.Company.Money - TrainManager.TrainDatas[cbType.SelectedIndex].Price <= 0)
                {
                    MessageBox.Show(TextManager.Get().Text("nomoney"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                if (t == null)
                {
                    t = new Train(TrainManager.TrainDatas[cbType.SelectedIndex].Name);
                }
                if (t.Data != TrainManager.TrainDatas[cbType.SelectedIndex])
                {
                    t = new Train(TrainManager.TrainDatas[cbType.SelectedIndex].Name);
                }

                t.Name       = txtName.Text.Trim();
                t.Route      = null;
                t.NowStation = null;
                int i = new Random().Next(0, 2);
                if (i == 0)
                {
                    t.RunMode = true;
                }
                else if (i == 1)
                {
                    t.RunMode = false;
                }

                t.Progress = 0.0;
                t.Owner    = GameManager.Company;

                TrainManager.Trains.Add(t);

                if (OldPage == null)
                {
                    PageManager.Close(false, AccessManager.AccessKey);
                }
                else
                {
                    if (OldPage is RouteControl_TrainList_Page)
                    {
                        (OldPage as RouteControl_TrainList_Page).ListDraw();
                    }
                    else if (OldPage is TrainList_OKAdd_Page)
                    {
                        (OldPage as TrainList_OKAdd_Page).ListDraw();
                    }
                    else if (OldPage is TrainListPage)
                    {
                        (OldPage as TrainListPage).ListDraw();
                    }

                    PageManager.SetPage(OldPage, AccessManager.AccessKey, true);
                }
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
예제 #3
0
        public BankPage(MainPlayScene mps = null)
        {
            try
            {
                InitializeComponent();
                AddControl(this);

                Title   = TextManager.Get().Text("bank");
                IconImg = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "ico_bank.png", 5, 7, 1, 6));
                Scene   = mps;

                panBankBook.Visible = false;

                panSide.BackColor = ResourceManager.Get("bank.sidebar");

                lbLoan.Text = TextManager.Get().Text("loan");
                lbLoan.Font = new Font(RTCore.Environment.Font, 22);
                Size   l_size    = RTCore.Environment.CalcStringSize(lbLoan.Text, lbBankBook.Font);
                PointF l_point_f = RTCore.Environment.CalcRectangle(new Point(panSide.Width / 2, lbLoan.Location.Y + (lbLoan.Height / 2)), l_size).Location;
                lbLoan.Location    = l_point_f.ToPoint();
                lbLoan.ForeColor   = ResourceManager.Get("bank.sidebar.item.select");
                lbLoan.MouseEnter += delegate { if (loan)
                                                {
                                                    return;
                                                }
                                                lbLoan.ForeColor = ResourceManager.Get("bank.sidebar.item.sel"); };
                lbLoan.MouseLeave += delegate { if (loan)
                                                {
                                                    return;
                                                }
                                                lbLoan.ForeColor = ResourceManager.Get("bank.sidebar.item.unsel"); };
                lbLoan.Click += delegate
                {
                    if (!loan)
                    {
                        loan = true;
                        lbBankBook.ForeColor = ResourceManager.Get("bank.sidebar.item.unsel");
                        lbLoan.ForeColor     = ResourceManager.Get("bank.sidebar.item.select");
                        panBankBook.Visible  = false;
                    }
                };
                tt.SetToolTip(lbLoan, TextManager.Get().Text("loan"));

                lbBankBook.Text = TextManager.Get().Text("bankbook");
                lbBankBook.Font = new Font(RTCore.Environment.Font, 22);
                Size   b_size    = RTCore.Environment.CalcStringSize(lbBankBook.Text, lbBankBook.Font);
                PointF b_point_f = RTCore.Environment.CalcRectangle(new Point(panSide.Width / 2, lbBankBook.Location.Y + (lbBankBook.Height / 2)), b_size).Location;
                lbBankBook.Location    = b_point_f.ToPoint();
                lbBankBook.ForeColor   = ResourceManager.Get("bank.sidebar.item.unsel");
                lbBankBook.MouseEnter += delegate { if (!loan)
                                                    {
                                                        return;
                                                    }
                                                    lbBankBook.ForeColor = ResourceManager.Get("bank.sidebar.item.sel"); };
                lbBankBook.MouseLeave += delegate { if (!loan)
                                                    {
                                                        return;
                                                    }
                                                    lbBankBook.ForeColor = ResourceManager.Get("bank.sidebar.item.unsel"); };
                lbBankBook.Click += delegate
                {
                    if (loan)
                    {
                        loan = false;
                        lbBankBook.ForeColor = ResourceManager.Get("bank.sidebar.item.select");
                        lbLoan.ForeColor     = ResourceManager.Get("bank.sidebar.item.unsel");
                        panBankBook.Visible  = true;
                    }
                };
                tt.SetToolTip(lbBankBook, TextManager.Get().Text("bankbook"));

                panLoanGive.BackColor  = ResourceManager.Get("bank.rect");
                panClearLoan.BackColor = ResourceManager.Get("bank.rect");

                lbLoanTitle.Font      = new Font(RTCore.Environment.Font, 30);
                lbLoanTitle.Text      = TextManager.Get().Text("loan");
                lbLoanTitle.ForeColor = ResourceManager.Get("bank.title");

                lbLoanGive.ForeColor = ResourceManager.Get("bank.subtitle");
                lbLoanGive.Text      = TextManager.Get().Text("loangiv");
                lbLoanGive.Font      = new Font(RTCore.Environment.Font, 20);

                cbLoan.SelectedIndex = 0;
                cbLoan.Font          = new Font(RTCore.Environment.Font, 20);

                lbGoLoan.Text      = TextManager.Get().Text("loangiv");
                lbGoLoan.ForeColor = ResourceManager.Get("bank.btn.unsel");
                lbGoLoan.SelColor  = ResourceManager.Get("bank.btn.sel");
                lbGoLoan.Font      = new Font(RTCore.Environment.Font, 20);
                lbGoLoan.Location  = new Point(panLoanGive.Width - 25 - lbGoLoan.Width, 111);
                lbGoLoan.Click    += delegate
                {
                    if (GameManager.Company.Loan != 0)
                    {
                        MessageBox.Show(TextManager.Get().Text("isloan"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                    else
                    {
                        if (GameManager.isBuild)
                        {
                            MessageBox.Show(TextManager.Get().Text("builded"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            return;
                        }

                        long   l   = 0;
                        string tmp = cbLoan.Items[cbLoan.SelectedIndex].ToString();
                        tmp = tmp.Replace(",", "");
                        tmp = tmp.Replace("RTW", "");
                        l   = Convert.ToInt64(tmp);
                        GameManager.Company.Loan  += Convert.ToInt64((l) + (l * 0.05));
                        GameManager.Company.Money += l;

                        Dictionary <string, string> data = new Dictionary <string, string>();
                        data.Add("%LOAN%", string.Format("{0:n0}", l));

                        PluginManager.Loaned(l);

                        ClearLoan();

                        if (Scene == null)
                        {
                            if (GameManager.isBuild)
                            {
                                MessageBox.Show(TextManager.Get().Text("builded"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                return;
                            }
                            MessageBox.Show(TextManager.Get().Text("okloan", true, data), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            if (GameManager.Company.Money <= 0)
                            {
                                MessageBox.Show(TextManager.Get().Text("okloan", true, data), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
                            }

                            Scene.tmUpdate.Start();
                            Scene.tmDate.Start();
                            Scene.panBankruptcy.Visible = false;
                            Scene.KeyPress += Scene.MainPlayScene_KeyPress;
                            PageManager.Close(false, AccessManager.AccessKey);
                            MessageBox.Show(TextManager.Get().Text("okloan", true, data), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                };

                lbClearLoan.Font      = new Font(RTCore.Environment.Font, 20);
                lbClearLoan.Text      = TextManager.Get().Text("clearloan");
                lbClearLoan.ForeColor = ResourceManager.Get("bank.subtitle");

                ClearLoan();
                cbClearLoan.Font = new Font(RTCore.Environment.Font, 20);

                lbGoClearLoan.Text      = TextManager.Get().Text("clearloan");
                lbGoClearLoan.ForeColor = ResourceManager.Get("bank.btn.unsel");
                lbGoClearLoan.SelColor  = ResourceManager.Get("bank.btn.sel");
                lbGoClearLoan.Font      = new Font(RTCore.Environment.Font, 20);
                lbGoClearLoan.Location  = new Point(panClearLoan.Width - 25 - lbGoClearLoan.Width, 111);
                lbGoClearLoan.Click    += delegate
                {
                    if (GameManager.Company.Loan == 0)
                    {
                        MessageBox.Show(TextManager.Get().Text("noloan"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                    else
                    {
                        if (GameManager.isBuild)
                        {
                            MessageBox.Show(TextManager.Get().Text("builded"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            return;
                        }

                        long   l   = 0;
                        string tmp = cbClearLoan.Items[cbClearLoan.SelectedIndex].ToString();
                        tmp = tmp.Replace(",", "");
                        tmp = tmp.Replace("RTW", "");
                        l   = Convert.ToInt64(tmp);

                        if (GameManager.Company.Money - l <= 0)
                        {
                            MessageBox.Show(TextManager.Get().Text("nomoney"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            return;
                        }

                        GameManager.Company.Loan  -= l;
                        GameManager.Company.Money -= l;

                        Dictionary <string, string> data = new Dictionary <string, string>();
                        data.Add("%CLEAR%", string.Format("{0:n0}", l));

                        PluginManager.ClearedLoan(l);

                        ClearLoan();

                        MessageBox.Show(TextManager.Get().Text("okclearloan", true, data), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                };

                lbLoanMoney.Font = new Font(RTCore.Environment.Font, 12);

                lbBankBookTitle.Text      = TextManager.Get().Text("bankbook");
                lbBankBookTitle.ForeColor = ResourceManager.Get("bank.title");
                lbBankBookTitle.Font      = new Font(RTCore.Environment.Font, 30);

                panBankbookMoney.BackColor = ResourceManager.Get("bank.rect");

                lbBankbookMoney.ForeColor = ResourceManager.Get("bank.subtitle");
                lbBankbookMoney.Font      = new Font(RTCore.Environment.Font, 20);
                BankBookUpdate();

                panDeposit.BackColor = ResourceManager.Get("bank.rect");

                lbDeposit.Font      = new Font(RTCore.Environment.Font, 20);
                lbDeposit.Text      = TextManager.Get().Text("deposit");
                lbDeposit.ForeColor = ResourceManager.Get("bank.subtitle");

                nuDeposit.Font    = new Font(RTCore.Environment.Font, 20);
                nuDeposit.Maximum = GameManager.Company.Money * 0.8m;

                lbGoDeposit.Font     = new Font(RTCore.Environment.Font, 20);
                lbGoDeposit.Text     = TextManager.Get().Text("deposit");
                lbGoDeposit.Location = new Point(panDeposit.Width - 25 - lbGoDeposit.Width, 111);
                lbGoDeposit.Click   += delegate
                {
                    if (GameManager.isBuild)
                    {
                        MessageBox.Show(TextManager.Get().Text("builded"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }

                    if (nuDeposit.Value > 0)
                    {
                        GameManager.Company.Money        -= nuDeposit.Value;
                        GameManager.Company.Bankbooks[0] += nuDeposit.Value;
                        Dictionary <string, string> d = new Dictionary <string, string>();
                        d.Add("%MONEY%", string.Format("{0:n0}", nuDeposit.Value));
                        PluginManager.DepositedBankBook(nuDeposit.Value);
                        UpdateBankBook();
                        MessageBox.Show(TextManager.Get().Text("depositok", true, d), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                };

                panWithdraw.BackColor = ResourceManager.Get("bank.rect");

                lbWithdraw.Font      = new Font(RTCore.Environment.Font, 20);
                lbWithdraw.Text      = TextManager.Get().Text("withdraw");
                lbWithdraw.ForeColor = ResourceManager.Get("bank.subtitle");

                nuWithdraw.Font    = new Font(RTCore.Environment.Font, 20);
                nuWithdraw.Maximum = GameManager.Company.Bankbooks[0];

                lbGoWithdraw.Font     = new Font(RTCore.Environment.Font, 20);
                lbGoWithdraw.Text     = TextManager.Get().Text("withdraw");
                lbGoWithdraw.Location = new Point(panWithdraw.Width - 25 - lbGoWithdraw.Width, 111);
                lbGoWithdraw.Click   += delegate
                {
                    if (GameManager.isBuild)
                    {
                        MessageBox.Show(TextManager.Get().Text("builded"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }

                    if (nuWithdraw.Value > 0)
                    {
                        GameManager.Company.Money        += nuWithdraw.Value;
                        GameManager.Company.Bankbooks[0] -= nuWithdraw.Value;
                        Dictionary <string, string> d = new Dictionary <string, string>();
                        d.Add("%MONEY%", string.Format("{0:n0}", nuWithdraw.Value));
                        PluginManager.WithdrawedBankBook(nuWithdraw.Value);
                        UpdateBankBook();
                        MessageBox.Show(TextManager.Get().Text("withdrawok", true, d), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                };
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
예제 #4
0
        public TrainDataAdd_Image_Page(Page _oldpage = null, string _name = "", List <TrainParant> _args = null, Image img = null)
        {
            try
            {
                InitializeComponent();
                AddControl(this);

                OldPage = _oldpage;
                name    = _name;
                args    = _args;

                Title   = TextManager.Get().Text("addtrainarg");
                IconImg = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "ico_train.png", 5, 7, 1, 6));

                if (img == null)
                {
                    image = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "img_no.png", 5, 7, 1, 6));
                }
                else
                {
                    image = img;
                }

                lbBack.ForeColor = ResourceManager.Get("traindataadd.back.unsel");
                lbBack.SelColor  = ResourceManager.Get("traindataadd.back.sel");
                lbBack.Location  = new Point(25, 553);
                lbBack.Text      = TextManager.Get().Text("back");
                lbBack.Font      = new Font(RTCore.Environment.Font, 20);
                lbBack.Click    += delegate
                {
                    PageManager.SetPage(new TrainDataAdd_Args_Page(OldPage, name, args, image), AccessManager.AccessKey);
                };

                lbAdd.Font      = new Font(RTCore.Environment.Font, 20);
                lbAdd.Text      = TextManager.Get().Text("add");
                lbAdd.ForeColor = ResourceManager.Get("traindataadd.next.unsel");
                lbAdd.SelColor  = ResourceManager.Get("traindataadd.next.sel");
                lbAdd.Location  = new Point(Width - 25 - lbAdd.Width, 553);
                lbAdd.Click    += delegate
                {
                    {                     // data.xml
                        XmlDocument xml = new XmlDocument();

                        XmlNode root = xml.CreateElement("traindata");

                        XmlNode args = xml.CreateElement("args");
                        args.InnerText = "args.xml";
                        root.AppendChild(args);

                        XmlNode __name = xml.CreateElement("name");
                        __name.InnerText = name;
                        root.AppendChild(__name);

                        XmlNode images = xml.CreateElement("image");
                        images.InnerText = "img.png";
                        root.AppendChild(images);

                        xml.AppendChild(root);

                        if (!System.IO.Directory.Exists(".\\data\\trains\\datas\\" + name))
                        {
                            System.IO.Directory.CreateDirectory(".\\data\\trains\\datas\\" + name);
                        }
                        xml.Save(".\\data\\trains\\datas\\" + name + "\\data.xml");
                    }

                    {                     // args.xml
                        XmlDocument xml = new XmlDocument();

                        XmlNode root = xml.CreateElement("args");

                        foreach (var it in args)
                        {
                            XmlNode arg = xml.CreateElement("arg");

                            if (it is Locomotive)
                            {
                                XmlAttribute type = xml.CreateAttribute("type");
                                type.Value = "locomotive";

                                XmlAttribute file = xml.CreateAttribute("name");
                                file.Value = it.Name;

                                arg.Attributes.Append(type);
                                arg.Attributes.Append(file);
                            }
                            else if (it is Coach)
                            {
                                XmlAttribute type = xml.CreateAttribute("type");
                                type.Value = "coach";

                                XmlAttribute file = xml.CreateAttribute("name");
                                file.Value = it.Name;

                                arg.Attributes.Append(type);
                                arg.Attributes.Append(file);
                            }
                            else if (it is EngineCoach)
                            {
                                XmlAttribute type = xml.CreateAttribute("type");
                                type.Value = "enginecoach";

                                XmlAttribute file = xml.CreateAttribute("name");
                                file.Value = it.Name;

                                arg.Attributes.Append(type);
                                arg.Attributes.Append(file);
                            }

                            root.AppendChild(arg);
                        }

                        xml.AppendChild(root);

                        xml.Save(".\\data\\trains\\datas\\" + name + "\\args.xml");
                    }

                    image.Save(".\\data\\trains\\datas\\" + name + "\\img.png", System.Drawing.Imaging.ImageFormat.Png);
                    TrainData d = new TrainData();
                    d.Load(name);

                    TrainManager.TrainDatas.Add(d);

                    if (OldPage == null)
                    {
                        PageManager.Close(false, AccessManager.AccessKey);
                        return;
                    }

                    PageManager.SetPage(OldPage, AccessManager.AccessKey);
                };
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
예제 #5
0
        private void lbNext_Click(object sender, EventArgs e)
        {
            try
            {
                long    price = GameManager.GameRule.CalcStationPrice(s.Parent, 500000);
                decimal money = GameManager.Company.Money - price;
                if (money <= 0)
                {
                    MessageBox.Show(TextManager.Get().Text("nomoney"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                s.Rank = (Station.StationRank)cbRank.SelectedIndex;
                s.Type = (Station.StationType)cbType.SelectedIndex;
                s.Open = GameManager.Time;
                s.Parent.Childs.Add(s);

                int pluspre = 0;
                switch (s.Rank)
                {
                case Station.StationRank.RANK1: pluspre += 5; break;

                case Station.StationRank.RANK2: pluspre += 4; break;

                case Station.StationRank.RANK3: pluspre += 3; break;

                case Station.StationRank.RANK4: pluspre += 2; break;

                case Station.StationRank.RANK5: pluspre += 1; break;
                }

                switch (s.Type)
                {
                case Station.StationType.PASSENGER: pluspre += 1; break;

                case Station.StationType.FREIGHT: pluspre += 0; break;

                case Station.StationType.DOUBLE: pluspre += 2; break;
                }

                s.Parent.Preference[0] += pluspre;
                if (s.Parent.Preference[0] >= 100)
                {
                    s.Parent.Preference[0] = 100;
                }

                GameManager.Company.Money -= price;

                PluginManager.AddedStation(s);
                if (OldPage != null)
                {
                    if (OldPage is RouteAdd_Stations_List_Page)
                    {
                        (OldPage as RouteAdd_Stations_List_Page).ListDraw();
                    }

                    PageManager.SetPage(OldPage, AccessManager.AccessKey);
                }
                else
                {
                    PageManager.Close(false, AccessManager.AccessKey);
                }
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
예제 #6
0
        public TrainWayPage(Train _t, Page _oldpage)
        {
            try
            {
                InitializeComponent();
                AddControl(this);

                t = _t;
                o = _oldpage;

                Title   = TextManager.Get().Text("settrainway");
                IconImg = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "ico_train.png", 5, 7, 1, 6));

                if (o == null)
                {
                    lbBack.Visible = false;
                }

                lbBack.Text      = TextManager.Get().Text("back");
                lbBack.ForeColor = ResourceManager.Get("settrainway.back.unsel");
                lbBack.SelColor  = ResourceManager.Get("settrainway.back.sel");
                lbBack.Location  = new Point(25, 553);
                lbBack.Click    += delegate
                {
                    PageManager.SetPage(o, AccessManager.AccessKey);
                };

                lbAccept.Text      = TextManager.Get().Text("accept");
                lbAccept.ForeColor = ResourceManager.Get("settrainway.accept.unsel");
                lbAccept.SelColor  = ResourceManager.Get("settrainway.accept.sel");
                lbAccept.Location  = new Point(Width - 25 - lbAccept.Width, 553);
                lbAccept.Click    += delegate
                {
                    // TODO : Save

                    if (o != null)
                    {
                        PageManager.SetPage(o, AccessManager.AccessKey);
                    }
                    else
                    {
                        PageManager.Close();
                    }
                };

                lbTitle.Text      = t.Name;
                lbTitle.ForeColor = ResourceManager.Get("settrainway.title");
                tt.SetToolTip(lbTitle, lbTitle.Text);

                cbWay.SelectedIndexChanged += delegate
                {
                };
                cbWay.Name = "cbType";
                cbWay.Font = new Font(RTCore.Environment.Font, 20);
                cbWay.Size = new Size(455, cbWay.Height);
                ReAddItem();
                cbWay.DropDownStyle = ComboBoxStyle.DropDownList;
                cbWay.Location      = new Point((Width / 2) - 250, (Height / 2) - 75);
                Controls.Add(cbWay);

                foreach (Control it in Controls)
                {
                    it.Font = new Font(RTCore.Environment.Font, it.Font.Size, it.Font.Style);
                }
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
        private void lbEnd_Click(object sender, EventArgs e)
        {
            try
            {
                if (stas.Count < 2)
                {
                    MessageBox.Show(TextManager.Get().Text("notsta"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                if (EditMode)
                {
                    List <Station> old = r.Stations;

                    if (cbLoop.Checked)
                    {
                        stas.Add(stas.First());
                    }

                    bool reet = false;                     // true : 변경됨 / false : 변경되지 않음

                    if (old.Count == stas.Count)
                    {
                        int inx = 0;
                        foreach (var it in stas)
                        {
                            if (it != old[inx])
                            {
                                reet = true; break;
                            }
                            inx++;
                        }
                    }
                    else
                    {
                        reet = true;
                    }

                    if (reet)
                    {
                        r.Stations.Clear();
                        foreach (var it in stas)
                        {
                            r.Stations.Add(it);
                        }

                        int     pxm   = 0;
                        decimal money = 0;
                        if (r.Type == Route.RouteType.DEFAULT)
                        {
                            pxm = 500;
                        }
                        else if (r.Type == Route.RouteType.HIGH)
                        {
                            pxm = 800;
                        }
                        for (int i = 0; i < r.Stations.Count - 1; i++)
                        {
                            if (r.Stations[i].Parent.Parent == r.Stations[i + 1].Parent.Parent)
                            {
                                money += GameManager.GameRule.CalcRailBuildPriceForSameRegion(r.Stations[i].Parent.Price);
                            }
                            else
                            {
                                money += GameManager.GameRule.CalcRailBuildPrice(r.Stations[i].Parent.Parent.Location, r.Stations[i + 1].Parent.Parent.Location, pxm);
                            }
                        }
                        decimal nowm = GameManager.Company.Money;
                        if (nowm - money <= 0)
                        {
                            MessageBox.Show(TextManager.Get().Text("nomoney"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            return;
                        }

                        GameManager.Company.Money -= money;

                        List <City> citys = new List <City>();

                        foreach (var it in r.Stations)
                        {
                            if (old.Contains(it))
                            {
                                continue;
                            }

                            if (citys.Contains(it.Parent))
                            {
                                continue;
                            }
                            citys.Add(it.Parent);
                        }

                        foreach (var it in citys)
                        {
                            it.Preference[0] += 5;
                            if (it.Preference[0] >= 100)
                            {
                                it.Preference[0] = 100;
                            }
                        }
                    }

                    if (OldPage != null)
                    {
                        if (OldPage is RouteControl_Main_Page)
                        {
                            OldPage = new RouteControl_Main_Page(r);
                        }

                        PageManager.SetPage(OldPage, AccessManager.AccessKey);
                    }
                    else
                    {
                        PageManager.Close(false, AccessManager.AccessKey);
                    }
                }
                else
                {
                    foreach (var it in stas)
                    {
                        r.Stations.Add(it);
                    }

                    if (cbLoop.Checked)
                    {
                        r.Stations.Add(r.Stations.First());
                    }

                    int  pxm   = 0;
                    long money = 0;
                    if (r.Type == Route.RouteType.DEFAULT)
                    {
                        pxm = 500; r.UseMoney = 50;
                    }
                    else if (r.Type == Route.RouteType.HIGH)
                    {
                        pxm = 800; r.UseMoney = 100;
                    }
                    for (int i = 0; i < r.Stations.Count - 1; i++)
                    {
                        if (r.Stations[i].Parent.Parent == r.Stations[i + 1].Parent.Parent)
                        {
                            money += GameManager.GameRule.CalcRailBuildPriceForSameRegion(r.Stations[i].Parent.Price);
                        }
                        else
                        {
                            money += GameManager.GameRule.CalcRailBuildPrice(r.Stations[i].Parent.Parent.Location, r.Stations[i + 1].Parent.Parent.Location, pxm);
                        }
                    }
                    decimal nowm = GameManager.Company.Money;
                    if (nowm - money <= 0)
                    {
                        MessageBox.Show(TextManager.Get().Text("nomoney"), "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }

                    GameManager.Company.Money -= money;

                    r.Open = GameManager.Time;
                    List <City> citys = new List <City>();
                    foreach (var it in r.Stations)
                    {
                        if (citys.Contains(it.Parent))
                        {
                            continue;
                        }
                        citys.Add(it.Parent);
                    }

                    foreach (var it in citys)
                    {
                        it.Preference[0] += 5;
                        if (it.Preference[0] >= 100)
                        {
                            it.Preference[0] = 100;
                        }
                    }

                    GameManager.RouteMgr.Routes.Add(r);
                    PluginManager.AddedRoute(r);

                    PageManager.Close(false, AccessManager.AccessKey);
                }
            }
            catch (Exception Ex)
            {
                RTCore.Environment.ReportError(Ex, AccessManager.AccessKey);
            }
        }