Esempio n. 1
0
        public ViewModel()
        {
            urlStart    = "http";
            myUrl       = "";
            urlSize     = "Please Wait";
            myStopwatch = new Stopwatch();

            StartCommand = new DelegateCommand(() =>
            {
                CheckUrl(MyUrl);
            },
                                               () =>
            {
                return(MyUrl.StartsWith(urlStart));
            });

            Task.Run(() =>
            {
                while (true)
                {
                    StartCommand.RaiseCanExecuteChanged();
                    Thread.Sleep(500);
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    StopWatchValue = MyStopwatch.ElapsedMilliseconds.ToString();
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Load web page from txt_address box and update history.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Load_WebPage_Click(object sender, EventArgs e)
        {
            string MyUrl;

            MyUrl = txt_Address.Text;

            if (MyUrl != "")
            {
                // Make sure url starts with HTTP protocol
                if (MyUrl.StartsWith("http://") == false & MyUrl.StartsWith("https://") == false)
                {
                    MyUrl = "http://" + MyUrl;
                }

                try
                {
                    webBrowser1.Navigate(new Uri(MyUrl, UriKind.RelativeOrAbsolute));
                    Add_Url_to_History(MyUrl);
                }

                catch (SystemException sec) {
                    Console.WriteLine(sec.Message);
                }
                catch (Exception x) {
                    Console.WriteLine(x.Message);
                }
            } // End if
        }