Esempio n. 1
0
        /// <summary>
        /// 页面载入完成需要执行的东西
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _WB_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.ToString() == "about:blank")
            {
                return;
            }

            try
            {
                //得到资源信息
                ResRead resRead = new ResRead();
                _NowRes             = resRead.GetNowRes(_WB.Document);
                metall.LabelText    = _NowRes.Metall.ToString("#,##0");
                kristall.LabelText  = _NowRes.Kristall.ToString("#,##0");
                deuterium.LabelText = _NowRes.Deuterium.ToString("#,##0");

                energie.Text = _NowRes.Energie;
                if (_NowRes.Energie.Substring(0, 1) == "-")
                {
                    energie.ForeColor = Color.Red;
                }
                else
                {
                    energie.ForeColor = Color.Black;
                }

                if (_WebWork == EWebWork.Resources)
                {
                    //完成资源载入,那么就不要站着位置了,呵呵
                    #region 资源面板

                    _Res = resRead.GetRes(_WB.Document);
                    //金属
                    labMetall.Text        = _Res.Metall.ToString("#,##0") + "/时";
                    labMetDay.Text        = _Res.MetDay.ToString("#,##0") + "/天";
                    labMetWeek.Text       = _Res.MetWeek.ToString("#,##0") + "/周";
                    labMetEnergie.Text    = _Res.MetEnergie;
                    cmbMetProduction.Text = _Res.MetProduction;
                    labMetLevel.Text      = _Res.MetLevel;
                    labMetMemory.Text     = "存储器 " + (_Res.MetMemory.ToString("#,##0") + "K").Replace(",000K", "K");
                    //晶体
                    if (_Res.KriLevel != "0")
                    {
                        labKristall.Text      = _Res.Kristall.ToString("#,##0") + "/时";
                        labKriDay.Text        = _Res.KriDay.ToString("#,##0") + "/天";
                        labKriWeek.Text       = _Res.KriWeek.ToString("#,##0") + "/周";
                        labKriEnergie.Text    = _Res.KriEnergie;
                        cmbKriProduction.Text = _Res.KriProduction;
                        labKriLevel.Text      = _Res.KriLevel;
                        labKriMemory.Text     = "存储器 " + (_Res.KriMemory.ToString("#,##0") + "K").Replace(",000K", "K");
                    }
                    //重氢
                    if (_Res.DeuLevel != "0")
                    {
                        labDeuterium.Text     = _Res.Deuterium.ToString("#,##0") + "/时";
                        labDeuDay.Text        = _Res.DeuDay.ToString("#,##0") + "/天";
                        labDeuWeek.Text       = _Res.DeuWeek.ToString("#,##0") + "/周";
                        labDeuEnergie.Text    = _Res.DeuEnergie;
                        cmbDeuProduction.Text = _Res.DeuProduction;
                        labDeuLevel.Text      = _Res.DeuLevel;
                        labDeuMemory.Text     = "存储器 " + (_Res.DeuMemory.ToString("#,##0") + "K").Replace(",000K", "K");
                    }
                    //核电站
                    if (_Res.AtomicLevel != "0")
                    {
                        panAtomic.Visible        = true;
                        labAtomicLevel.Text      = "核电站 " + _Res.AtomicLevel;
                        labAtomicLost.Text       = _Res.AtomicLost.ToString("#,##0") + "/时";
                        labAtomicMake.Text       = _Res.AtomicMake.ToString("#,##0") + "/时";
                        cmbAtomicProduction.Text = _Res.AtomicProduction;
                    }
                    //太卫
                    if (_Res.SatelliteLevel != "0")
                    {
                        panSatellite.Visible        = true;
                        labSatelliteEnergie.Text    = _Res.Satellite.ToString("#,##0") + "/时";
                        labSatelliteLevel.Text      = "太卫 " + _Res.SatelliteLevel;
                        cmbSatelliteProduction.Text = _Res.SatelliteProduction;
                    }

                    //电站
                    labEnergie.Text       = _Res.Energie;
                    cmbEneProduction.Text = _Res.EneProduction;
                    labEneLevel.Text      = "发电站 " + _Res.EneLevel;

                    ResCalc.Text = "计算";

                    //_Galaxy.TxtLog.Text += "\r\n <Res>" + e.Url.ToString() ;
                    if (_Res.Metall != 0)
                    {
                        _OGCOntrolManage._ResRefNow = false;
                        _OGCOntrolManage._PlanetID  = "";
                        //_Galaxy.TxtLog.Text += "\r\n" + this._Planet + " --释放资源加载权利";
                    }


                    #endregion
                    if (_Res != null)
                    {//更新百分比
                        metall.Max    = Convert.ToInt64(_Res.MetMemory);
                        kristall.Max  = Convert.ToInt64(_Res.KriMemory);
                        deuterium.Max = Convert.ToInt64(_Res.DeuMemory);

                        if (_Res.MetMemory != 0)
                        {
                            metall.Value = Convert.ToInt64(_NowRes.Metall / _Res.MetMemory * 100);
                        }
                        if (_Res.KriMemory != 0)
                        {
                            kristall.Value = Convert.ToInt64(_NowRes.Kristall / _Res.KriMemory * 100);
                        }
                        if (_Res.DeuMemory != 0)
                        {
                            deuterium.Value = Convert.ToInt64(_NowRes.Deuterium / _Res.DeuMemory * 100);
                        }
                    }
                }
                else if (_WebWork == EWebWork.b_building)
                {
                    #region 建筑分类

                    /*
                     * 基础建设
                     *
                     * 金属矿
                     * 晶体矿
                     * 重氢分离器
                     * 太阳能发电站
                     * 核电站
                     *
                     * 辅助建筑
                     *
                     * 机器人工厂
                     * 纳米机器人工厂
                     * 金属仓库
                     * 晶体仓库
                     * 重氢槽
                     *
                     * 战斗&研究
                     *
                     * 造船厂
                     * 研究实验室
                     * 联盟太空站
                     * 导弹发射井
                     * 地形改造器
                     */
                    #endregion
                    #region 建筑面板

                    HtmlElement Content = _WB.Document.GetElementById("content");
                    if (Content == null)
                    {
                        ErrorSpan = ErrorSpanCount;
                        return;
                    }

                    HtmlElement ContentHE = Content.Children[0].Children[1].Children[0].Children[0].Children[0].Children[0].Children[0];
                    if (ContentHE == null)
                    {
                        return;
                    }

                    BuildHelper BuildH = new BuildHelper(this); //用来创建控件的一个类
                    BuildH.ClearBuildBtn(TabBuild);
                    BuildH.BuildRending(_BuildDT, ContentHE);   //解析文件以及创建按钮

                    #endregion
                }

                else if (_WebWork == EWebWork.Forschung)
                {
                    #region 研究分类

                    /*
                     * 空间探测技术
                     * 计算机技术
                     * 武器技术
                     * 防御盾系统
                     * 装甲技术
                     *
                     * 能量技术
                     * 超空间技术
                     * 燃烧引擎
                     * 脉冲引擎
                     * 超空间引擎
                     *
                     * 激光技术
                     * 中子技术
                     * 等离子技术
                     * 跨星系科研网络
                     * 远征科技
                     *
                     * 引力技术
                     */
                    #endregion
                    #region 建筑面板

                    HtmlElement ContentHE = _WB.Document.GetElementById("content").Children[0].Children[1].Children[0].Children[0].Children[0].Children[0].Children[0];
                    if (ContentHE == null)
                    {
                        return;
                    }

                    ForschungHelper ForschungH = new ForschungHelper(this); //用来处理研究界面的类
                    ForschungH.ClearForschungBtn(TabForschung);
                    ForschungH.ForschungRending(_BuildDT, ContentHE);       //解析文件以及创建按钮

                    #endregion
                }
                else if (_WebWork == EWebWork.Flotte)
                {
                    #region 舰队

                    /*
                     *  小型运输舰
                     *  大型运输舰
                     *  轻型战斗机
                     *  重型战斗机
                     *
                     *  巡洋舰
                     *  战列舰
                     *  轰炸机
                     *  毁灭者
                     *  战斗巡洋舰
                     *
                     *
                     *  太阳能卫星
                     *  探测器
                     *  殖民船
                     *  回收船
                     *  死星
                     */
                    #endregion
                    #region 舰队面板

                    HtmlElement Content = _WB.Document.GetElementById("content");
                    if (Content == null)
                    {
                        ErrorSpan = ErrorSpanCount;
                        return;
                    }

                    HtmlElement ContentHE = Content.Children[0].Children[1].Children[0].Children[0].Children[0].Children[0].Children[0].Children[0];
                    if (ContentHE == null)
                    {
                        return;
                    }

                    if (ContentHE.Children.Count == 1)
                    {
                        //没有造船厂
                        _WebState    = EWebState.Free;
                        this.Enabled = true;
                        return;
                    }

                    FlotteHelper FlotteH = new FlotteHelper(this); //用来处理造船厂界面的类
                    FlotteH.ClearBuildBtn(TabFlotte);
                    FlotteH.FlotteRending(_BuildDT, ContentHE);    //解析文件以及创建按钮

                    //解析建造列表
                    HtmlElement BuildList = Content.Children[0].Children[5];
                    FlotteH.FlotteBuildList(BuildList);

                    #endregion
                }
                else if (_WebWork == EWebWork.Verteidigung)
                {
                    #region 防御

                    /*
                     *  火箭发射装置
                     *  轻型激光炮
                     *  重型激光炮
                     *  高斯炮
                     *  中子炮
                     *
                     *  等离子武器
                     *  小型防护罩
                     *  大型防护罩
                     *  拦截导弹
                     *  星际导弹
                     */
                    #endregion

                    #region 防御面板

                    HtmlElement Content = _WB.Document.GetElementById("content");
                    if (Content == null)
                    {
                        ErrorSpan = ErrorSpanCount;
                        return;
                    }

                    HtmlElement ContentHE = Content.Children[0].Children[1].Children[0].Children[0].Children[0].Children[0].Children[0].Children[0];
                    if (ContentHE == null)
                    {
                        return;
                    }

                    if (ContentHE.Children.Count == 1)
                    {
                        //没有造船厂
                        _WebState    = EWebState.Free;
                        this.Enabled = true;
                        return;
                    }

                    VerteidigungHelper VerteidigungH = new VerteidigungHelper(this); //用来处理防御界面的类
                    VerteidigungH.ClearBuildBtn(TabVerteidigung);
                    VerteidigungH.VerteidigungRending(_BuildDT, ContentHE);          //解析文件以及创建按钮

                    //解析建造列表
                    HtmlElement BuildList = Content.Children[0].Children[5];
                    VerteidigungH.VerteidigungBuildList(BuildList);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            _WebState    = EWebState.Free;
            this.Enabled = true;
            // _OGCOntrolManage._LinkCount--;
        }
Esempio n. 2
0
        /// <summary>
        /// 获得资源
        /// </summary>
        /// <returns></returns>
        public CRes GetRes(HtmlDocument HtmlDoc)
        {
            CRes        Res      = new CRes();
            HtmlElement HtmlEmtF = HtmlDoc.GetElementById("content");

            if (HtmlEmtF == null)
            {
                return(Res);                 //如果不存在就返回空
            }
            HtmlElement HtmlEmt = HtmlEmtF.Children[0].Children[0].Children[2].Children[1].Children[0];

            for (int i = 0; i < HtmlEmt.Children.Count; i++)
            {
                if (HtmlEmt.Children[i] == null)
                {
                    continue;
                }
                if (HtmlEmt.Children[i].Children.Count == 0)
                {
                    continue;
                }
                if (HtmlEmt.Children[i].Children[0].InnerText == null)
                {
                    continue;
                }
                string Caption = Convert.ToString(Info.ResLocation[Info.GetCaption(HtmlEmt.Children[i].Children[0].InnerText)]);
                if (Caption == "Metall")
                {
                    //金属
                    Res.MetEnergie    = HtmlEmt.Children[i].Children[5].InnerText.Replace(".", ""); //能量
                    Res.MetProduction = GetProduction(HtmlEmt.Children[i].Children[6].InnerHtml);   //产量计算
                    Res.MetLevel      = GetLevel(HtmlEmt.Children[i].Children[0].InnerText);        //等级
                }
                else if (Caption == "Kristall")
                {
                    /// 晶体
                    Res.KriEnergie    = HtmlEmt.Children[i].Children[5].InnerText.Replace(".", "");
                    Res.KriProduction = GetProduction(HtmlEmt.Children[i].Children[6].InnerHtml);
                    Res.KriLevel      = GetLevel(HtmlEmt.Children[i].Children[0].InnerText);
                }
                else if (Caption == "Deuterium")
                {
                    /// 重氢
                    Res.DeuEnergie    = HtmlEmt.Children[i].Children[5].InnerText.Replace(".", "");
                    Res.DeuProduction = GetProduction(HtmlEmt.Children[i].Children[6].InnerHtml);
                    Res.DeuLevel      = GetLevel(HtmlEmt.Children[i].Children[0].InnerText);
                }
                else if (Caption == "Energie")
                {
                    Res.Energie      += HtmlEmt.Children[i].Children[5].InnerText;                //总电量
                    Res.EneProduction = GetProduction(HtmlEmt.Children[i].Children[6].InnerHtml); //电量计算
                    Res.EneLevel      = GetLevel(HtmlEmt.Children[i].Children[0].InnerText);      //等级
                }
                else if (Caption == "Atomic")
                {
                    Res.AtomicLost       = Convert.ToDecimal(HtmlEmt.Children[i].Children[4].InnerText.Replace(".", ""));
                    Res.AtomicMake       = Convert.ToDecimal(HtmlEmt.Children[i].Children[5].InnerText.Replace(".", ""));
                    Res.AtomicProduction = GetProduction(HtmlEmt.Children[i].Children[6].InnerHtml);
                    Res.AtomicLevel      = GetLevel(HtmlEmt.Children[i].Children[0].InnerText);//等级
                }
                else if (Caption == "Satellite")
                {
                    Res.Satellite           = Convert.ToDecimal(HtmlEmt.Children[i].Children[5].InnerText.Replace(".", ""));
                    Res.SatelliteProduction = GetProduction(HtmlEmt.Children[i].Children[6].InnerHtml);
                    Res.SatelliteLevel      = GetLevel(HtmlEmt.Children[i].Children[0].InnerText);//等级
                }
                else if (Caption == "Memory")
                {
                    Res.MetMemory = GetMemory(HtmlEmt.Children[i].Children[1].InnerText.Replace(".", "")); //金属罐头
                    Res.KriMemory = GetMemory(HtmlEmt.Children[i].Children[2].InnerText.Replace(".", "")); //晶体罐头
                    Res.DeuMemory = GetMemory(HtmlEmt.Children[i].Children[3].InnerText.Replace(".", "")); //重氢罐头
                }
                else if (Caption == "Sum")
                {
                    Res.Metall    = Convert.ToDecimal(HtmlEmt.Children[i].Children[1].InnerText.Replace(".", "")); //金属
                    Res.Kristall  = Convert.ToDecimal(HtmlEmt.Children[i].Children[2].InnerText.Replace(".", "")); /// 晶体
                    Res.Deuterium = Convert.ToDecimal(HtmlEmt.Children[i].Children[3].InnerText.Replace(".", "")); /// 重氢

                    Res.Energie = HtmlEmt.Children[i].Children[4].InnerText + "/" + Res.Energie;                   //电量
                }

                else if (Caption == "Day")
                {
                    Res.MetDay = Convert.ToDecimal(HtmlEmt.Children[i].Children[1].InnerText.Replace(".", ""));
                    Res.KriDay = Convert.ToDecimal(HtmlEmt.Children[i].Children[2].InnerText.Replace(".", ""));
                    Res.DeuDay = Convert.ToDecimal(HtmlEmt.Children[i].Children[3].InnerText.Replace(".", ""));
                }
                else if (Caption == "Week")
                {
                    Res.MetWeek = Convert.ToDecimal(HtmlEmt.Children[i].Children[1].InnerText.Replace(".", ""));
                    Res.KriWeek = Convert.ToDecimal(HtmlEmt.Children[i].Children[2].InnerText.Replace(".", ""));
                    Res.DeuWeek = Convert.ToDecimal(HtmlEmt.Children[i].Children[3].InnerText.Replace(".", ""));
                }
            }
            return(Res);
        }