Exemple #1
0
 public ExampleResourceRequestHandler(oSite site) : base()
 {
     m_site = site;
 }
Exemple #2
0
        public static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new string[] {
                    //"https://pipeline.mediumra.re",
                    //"https://pipeline.mediumra.re/pages-app.html",
                    "https://pipeline.mediumra.re/nav-side-kanban-board.html",
                    //Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pipeline.mediumra.re")
                }
            }
            ;

            string URL = args[0];

            try
            {
                SITE = new oSite();

                Uri    uri        = new Uri(URL);
                string PATH_STORE = Utility.build_path_folder_save(uri);
                string file       = Utility.build_path_file_save(uri);
                Console.Title = URL + " -> " + file;

                SITE.NAME = uri.AbsolutePath.Split('?')[0].Replace('/', '_').Trim().ToLower();
                if (SITE.NAME[0] == '_')
                {
                    SITE.NAME = SITE.NAME.Substring(1);
                }
                if (SITE.NAME.Length == 0)
                {
                    SITE.NAME = "index.html";
                }
                SITE.URL        = uri;
                SITE.PATH_STORE = PATH_STORE;

                if (File.Exists(file))
                {
                    string f_links = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, uri.Host.Replace(':', '_') + ".txt");
                    if (File.Exists(f_links))
                    {
                        var lines = File.ReadAllLines(f_links)
                                    .Where(o => o.Trim().Length > 0)
                                    .Where(o => File.Exists(Utility.build_path_file_save(new Uri(o))) == false)
                                    .ToArray();
                        if (lines.Length > 0)
                        {
                            File.WriteAllLines(f_links, lines.Where((o, i) => i != 0));
                            return(Main(new string[] { lines[0] }));
                        }
                        else
                        {
                            MessageBox.Show("Download theme: " + uri.Host + " complete");
                            return(0);
                        }
                    }
                }

                if (browser == null)
                {
                    var settings = new CefSettings()
                    {
                        CachePath = null
                    };
                    Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
                }
                else
                {
                    browser.Stop();
                    browser.Dispose();
                }

                browser      = new ChromiumWebBrowser(URL);
                browser.Size = new System.Drawing.Size(1366, 3500);
                browser.LoadingStateChanged += BrowserLoadingStateChanged;
                browser.RequestHandler       = new CefBasicRequestHandler(SITE);

                signal.WaitOne();
                signal.Reset();

                if (string.IsNullOrEmpty(URL_NEXT))
                {
                    MessageBox.Show("Download theme: " + uri.Host + " complete");
                }
                else
                {
                    return(Main(new string[] { URL_NEXT }));
                }

                Cef.Shutdown();
            }
            catch
            {
                Cef.Shutdown();
                Process.Start(Application.ExecutablePath, URL);
                Environment.Exit(0);
            }

            return(0);
        }
Exemple #3
0
 public CefBasicRequestHandler(oSite site) : base()
 {
     m_site = site;
 }