示例#1
0
 public void SwitchPage(EPageID id)
 {
     if (SwitchViewEventHandler != null)
     {
         SwitchViewEventHandler(this, new PageIDEventArgs(id));
     }
 }
        private void OnSwitchView(object sender, PageIDEventArgs e)
        {
            _startupPage.OnDeactive();
            _firstsegmentationPage.OnDeactive();
            _displayPage.OnDeactive();
            _aboutPage.OnDeactive();

            btnBack.Enabled = true;
            switch (e.Value)
            {
            case EPageID.Startup:
                _startupPage.OnActive();
                _currectPageID  = EPageID.Startup;
                btnBack.Enabled = false;
                break;

            case EPageID.About:
                _aboutPage.OnActive();
                _currectPageID = EPageID.About;
                break;

            case EPageID.FirstSegmentation:
                _firstsegmentationPage.OnActive();
                _currectPageID = EPageID.FirstSegmentation;
                break;

            case EPageID.Display:
                _displayPage.OnActive();
                _currectPageID = EPageID.Display;
                break;

            default:
                break;
            }
        }
示例#3
0
文件: HLink.cs 项目: pkim/TravianBot
        public static Uri GetLink(EPageID _pageID)
        {
            switch (_pageID)
              {
            case EPageID.LOGIN:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.Login));

            case EPageID.LOGOUT:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.Logout));

            case EPageID.FARM:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.Farm));

            case EPageID.VILLAGE:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.Village));

            case EPageID.VILLAGE_OVERVIEW:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.VillagesOverview));

            case EPageID.PLAYER:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.Player));

            case EPageID.BUILDING:
              return new Uri(String.Format("{0}{1}", HInfo.PLinks.Server, HInfo.PLinks.Building));

            case EPageID.UNKNOWN:
            default:
              return null;
              }
        }
示例#4
0
文件: HPage.cs 项目: pkim/TravianBot
        protected HtmlDocument GetHtmlDocument(EPageID _pageID, IList<HTTPParameter> _get, IList<HTTPParameter> _post)
        {
            HtmlDocument htmlDocument;

              // increase the counter of access by one
              this.COAccess++;

              // if the html document is already cached
              if (this.PageDictionary.ContainsKey(_pageID))
              {
            HInfo.LogHandler.Debug(String.Format("ACCESS - {0}", HLink.GetLink(_pageID).Segments.Last()));
            htmlDocument = this.PageDictionary[_pageID];
              }

            // if the document in the cache is out of the date or not cached yet
              else
              {
            HInfo.LogHandler.Debug(String.Format("DOWNLOAD - {0}", HLink.GetLink(_pageID).Segments.Last()));

            // set options
            htmlDocument = new HtmlDocument();
            htmlDocument.OptionComputeChecksum               = false;
            //htmlDocument.OptionFixNestedTags                 = true;
            htmlDocument.OptionUseIdAttribute                = true;
            //htmlDocument.OptionOutputOptimizeAttributeValues = false;
            //htmlDocument.OptionOutputOriginalCase            = false;
            //htmlDocument.OptionOutputAsXml                   = true;
            //htmlDocument.OptionReadEncoding                  = false;

            // Download the html document of the login
            this.HTMLClient.getHTML(HLink.GetLink(_pageID),
              _get, // GET Parameter
              _post, // POST Parameter
              Encoding.Unicode,
              ref htmlDocument);

            // wait for a random time to simulate human activity
            HHumanActivity.Simulate();

            // Increase the counter of downloads by one
            this.CODownloads++;

            // Add the html document to the page dictionary
            this.PageDictionary.Add(_pageID, htmlDocument);

            if (HInfo.PConfig.CacheHTML)
            {
              if (!Directory.Exists(HInfo.PGlobal.Cache))
              {
            Directory.CreateDirectory(HInfo.PGlobal.Cache);
              }

              // save html document at the configured path
              htmlDocument.Save(String.Format("{0}{1}",
            HInfo.PGlobal.Cache, // The configured output directory
            HLink.GetLink(_pageID).Segments.Last())); // the name of the document
            }
              }

              // update the static frame page
              this.PageDictionary[EPageID.STATIC_FRAME] = this.PageDictionary[_pageID];
              return htmlDocument;
        }
示例#5
0
文件: HPage.cs 项目: pkim/TravianBot
 protected HtmlDocument GetHtmlDocument(EPageID _pageID)
 {
     return this.GetHtmlDocument(_pageID, null, null);
 }
示例#6
0
文件: HLink.cs 项目: pkim/TravianBot
        public static Uri GetLink(EPageID _pageID, Int32 _villageID, Int32 _buildingID)
        {
            String basrUrl = HLink.GetLink(_pageID, _villageID).AbsoluteUri;

              return new Uri(String.Format("{0}?{1}={2}", basrUrl, HInfo.PHTTPParameters.BuildingID, _buildingID));
        }