public void Print(string htmlFilename)
        {
            documentLoaded  = false;
            documentPrinted = false;

            InternetExplorer ie = new InternetExplorerClass();

            ie.DocumentComplete      += new DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete);
            ie.PrintTemplateTeardown += new DWebBrowserEvents2_PrintTemplateTeardownEventHandler(ie_PrintTemplateTeardown);

            object missing = Missing.Value;

            ie.Navigate(htmlFilename, ref missing, ref missing, ref missing, ref missing);
            while (!documentLoaded && ie.QueryStatusWB(OLECMDID.OLECMDID_PRINT) != OLECMDF.OLECMDF_ENABLED)
            {
                Thread.Sleep(100);
            }

            ie.ExecWB(OLECMDID.OLECMDID_PRINT, OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref missing, ref missing);
            while (!documentPrinted)
            {
                Thread.Sleep(100);
            }

            ie.DocumentComplete      -= ie_DocumentComplete;
            ie.PrintTemplateTeardown -= ie_PrintTemplateTeardown;
            ie.Quit();
        }
Ejemplo n.º 2
0
        private static void OpenReportInIE()
        {
            object           o  = new object();
            InternetExplorer ie = new InternetExplorerClass();
            IWebBrowserApp   wb = (IWebBrowserApp)ie;

            wb.Visible = true;

            wb.Navigate(ConfigurationManager.AppSettings["logTextFileName"].ToString(), ref o, ref o, ref o, ref o);
        }
Ejemplo n.º 3
0
        public void AddNewFriend()
        {
            object           o  = null;
            InternetExplorer ie = new InternetExplorerClass();

            IWebBrowserApp wb = ie;

            wb.Visible = true;
            wb.ToolBar = 0;
            wb.Width   = 600;
            wb.Height  = 600;
            wb.Navigate("http://www.facebook.com/addfriend.php?id=" + uidToAddTextBox.Text, ref o, ref o, ref o, ref o);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates an instance of the InternetExplorer.
 /// </summary>
 /// <returns> An instance of Internet Explorer. </returns>
 private static SHDocVw.InternetExplorer CreateInternetExplorerClass()
 {
     try
     {
         var explorer = new InternetExplorerClass();
         explorer.Visible = true;
         return(explorer);
     }
     catch (Exception)
     {
         return(CreateInternetExplorerClass());
     }
 }
Ejemplo n.º 5
0
        // TODO: Pull this for Mono
        private void StartNewRecording()
        {
            if (this.recordButton.Text == "Start")
            {
                recordButton.Icon      = GetIcon(IconType.Stop);
                this.recordButton.Text = "Stop";

                if (documentContainer1.Documents.Length == 0)
                {
                    documentContainer1.AddDocument(dockControl1);
                    Application.DoEvents();
                }

                this.textScript.Clear();
                AppendText(starterProject, false);
                if (ie != null)
                {
                    ie.Quit();
                    ie = null;
                }
                ie         = new InternetExplorerClass();
                ie.Visible = true;
                object url     = "about:blank";
                object nullObj = String.Empty;
                ie.Navigate2(ref url, ref nullObj, ref nullObj, ref nullObj, ref nullObj);
                ie.DocumentComplete  += new DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete);
                ie.NavigateComplete2 += new DWebBrowserEvents2_NavigateComplete2EventHandler(ie_NavigateComplete2);
                ie.BeforeNavigate2   += new DWebBrowserEvents2_BeforeNavigate2EventHandler(ie_BeforeNavigate2);
            }
            else
            {
                recordButton.Icon      = GetIcon(IconType.Start);
                this.recordButton.Text = "Start";
                AppendText(endProject, false);
                if (ie != null)
                {
                    try
                    {
                        ie.Quit();
                    }
                    catch (COMException)
                    {
                    }
                    finally
                    {
                        ie = null;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void OnQuit()
        {
            // IE was manually shut down
            // No need to unhook events, IE is already gone...
            ie = null;

            if (IsSender)
            {
                base.StopSending();
            }
            else
            {
                base.StopPlaying();
            }
        }
Ejemplo n.º 7
0
        public override void Dispose()
        {
            if (!IsSender)
            {
                ObjectReceived -= new CapabilityObjectReceivedEventHandler(OnObjectReceived);
            }

            if (ie != null)
            {
                // Unhook before we cause it to fire
                ie.OnQuit -= new DWebBrowserEvents2_OnQuitEventHandler(OnQuit);
                ie.Quit();
                ie = null;
            }

            base.Dispose();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            // create an instance of Internet Explorer
            InternetExplorer ie = new InternetExplorerClass();
            // set up event handlers
            ie.OnVisible +=
                new DWebBrowserEvents2_OnVisibleEventHandler(ieVisible);
            ie.TitleChange +=
                new DWebBrowserEvents2_TitleChangeEventHandler(ieTitleChange);

            // display Internet Explorer
            // and navigate to user's selected home page
            ie.Visible = true;
            object noValue = System.Reflection.Missing.Value;   // don't want to supply values for some parameters of Navigate method
            ie.Navigate(@"http://www.microsoft.com", ref noValue, ref noValue, ref noValue, ref noValue);
            Console.ReadLine();
        }
Ejemplo n.º 9
0
        public override void Dispose()
        {
            if(!IsSender)
            {
                ObjectReceived -= new CapabilityObjectReceivedEventHandler(OnObjectReceived);
            }

            if(ie != null)
            {
                // Unhook before we cause it to fire
                ie.OnQuit -= new DWebBrowserEvents2_OnQuitEventHandler(OnQuit);
                ie.Quit();
                ie = null;
            }

            base.Dispose();
        }
Ejemplo n.º 10
0
        public static SUIIE CreateIEWithURL(string URL)
        {
            InternetExplorer ie = new InternetExplorerClass();

            ie.Visible = true;
            SUIWindow ieWin    = new SUIWindow(new IntPtr(ie.HWND));
            SUIIE     instance = new SUIIE(ie);

            instance.ieWin = ieWin;
            Object obj = new Object();

            ie.Navigate(URL, ref obj, ref obj, ref obj, ref obj);
            if (instance.WaitingForLoadComplete())
            {
                instance.IEWin.Maximized = true;
                return(instance);
            }
            return(null);
        }
Ejemplo n.º 11
0
        private void Initialize()
        {
            if (ie == null)
            {
                ie         = new InternetExplorerClass();
                ie.OnQuit += new DWebBrowserEvents2_OnQuitEventHandler(OnQuit);

                if (IsSender)
                {
                    // On the sending side, hook as many events as desired (see HookAllEvents for others)
                    // Don't hook events in constructor, because we don't have an RtpSender yet
                    ie.BeforeNavigate += new DWebBrowserEvents_BeforeNavigateEventHandler(OnBeforeNavigate);
                }
                else
                {
                    // Hook ObjectReceived event on capability
                    ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);
                }
            }

            ie.Visible = true;
        }
        private void Initialize()
        {
            if(ie == null)
            {
                ie = new InternetExplorerClass(); 
                ie.OnQuit += new DWebBrowserEvents2_OnQuitEventHandler(OnQuit);

                if(IsSender)
                {
                    // On the sending side, hook as many events as desired (see HookAllEvents for others)
                    // Don't hook events in constructor, because we don't have an RtpSender yet
                    ie.BeforeNavigate += new DWebBrowserEvents_BeforeNavigateEventHandler(OnBeforeNavigate);
                }
                else
                {
                    // Hook ObjectReceived event on capability
                    ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);
                }
            }

            ie.Visible = true;
        }
		/**
		 * New window, add to list's and attach events.
		 **/
		void webBrowser_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl)
		{
			//Debug.WriteLine("New Window");

			//Assertion mode enabled, do not open window
			if (HTMLEvents.AssertElement) Cancel = true;

			ppDisp = new InternetExplorerClass();
			new WebBrowserEvents("PopUp", (InternetExplorerClass)ppDisp, ref _writer);

		}
Ejemplo n.º 14
0
 public static SUIIE CreateIEWithURL(string URL)
 {
     InternetExplorer ie = new InternetExplorerClass();
     ie.Visible = true;
     SUIWindow ieWin = new SUIWindow(new IntPtr(ie.HWND));
     SUIIE instance = new SUIIE(ie);
     instance.ieWin = ieWin;
     Object obj = new Object();
     ie.Navigate(URL, ref obj, ref obj, ref obj, ref obj);
     if (instance.WaitingForLoadComplete())
     {
         instance.IEWin.Maximized = true;
         return instance;
     }
     return null;
 }
        private void OnQuit()
        {
            // IE was manually shut down
            // No need to unhook events, IE is already gone...
            ie = null;

            if(IsSender)
            {
                base.StopSending();
            }
            else
            {
                base.StopPlaying();
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates an instance of the InternetExplorer.
 /// </summary>
 /// <returns> An instance of Internet Explorer. </returns>
 private static SHDocVw.InternetExplorer CreateInternetExplorerClass()
 {
     try
     {
         var explorer = new InternetExplorerClass { Visible = true };
         return explorer;
     }
     catch (Exception)
     {
         return CreateInternetExplorerClass();
     }
 }
Ejemplo n.º 17
0
        private static void OpenReportInIE()
        {
            object o = new object();
            InternetExplorer ie = new InternetExplorerClass();
            IWebBrowserApp wb = (IWebBrowserApp)ie;
            wb.Visible = true;

            wb.Navigate(ConfigurationManager.AppSettings["logTextFileName"].ToString(), ref o, ref o, ref o, ref o);
        }
Ejemplo n.º 18
0
        protected void BuildSSO()
        {
            try
            {
                xmlPublicKey  = GetPublicKey();
                xmlPrivateKey = GetPrivateKey();

                if (xmlPublicKey == null)
                {
                    LogError("Unable to retrieve Public Key");
                    return;
                }

                if (xmlPrivateKey == null)
                {
                    LogError("Unable to retrieve Private Key");
                    return;
                }

                CspParameters            Sendercp  = new CspParameters();
                RSACryptoServiceProvider SenderRSA = null;

                try
                {
                    Sendercp.Flags = CspProviderFlags.UseMachineKeyStore;
                    SenderRSA      = new RSACryptoServiceProvider(Sendercp);
                    SenderRSA.FromXmlString(xmlPrivateKey.OuterXml);
                }
                catch (Exception ex)
                {
                    SenderRSA.Clear();
                    LogError("Error while constructing the PrivateKey: " + ex.Message);
                    return;
                }

                CspParameters            Receivercp  = new CspParameters();
                RSACryptoServiceProvider ReceiverRSA = null;

                try
                {
                    Receivercp.Flags = CspProviderFlags.UseMachineKeyStore;
                    ReceiverRSA      = new RSACryptoServiceProvider(Receivercp);
                    ReceiverRSA.FromXmlString(xmlPublicKey.OuterXml);
                }
                catch (Exception ex)
                {
                    ReceiverRSA.Clear();
                    LogError("Error while constructing the PublicKey: " + ex.Message);
                    return;
                }

                string tpayload = AssemblePayload();

                byte[] TripleDESKey  = null;
                byte[] encryptedData = SSOEncryption.TripleDESEncrypt(Encoding.ASCII.GetBytes(tpayload), out TripleDESKey);

                string base64enc = Convert.ToBase64String(encryptedData);

                string plainsig = base64enc + _clientID + _serverID;

                MD5    md     = null;
                byte[] buffer = null;
                byte[] hash   = null;

                try
                {
                    md = MD5CryptoServiceProvider.Create();

                    //Convert the string into an array of bytes.
                    buffer = Encoding.ASCII.GetBytes(plainsig);

                    //Create the hash value from the array of bytes.
                    hash = md.ComputeHash(buffer);
                }
                catch (Exception ex)
                {
                    ReceiverRSA.Clear();
                    SenderRSA.Clear();
                    LogError("Error Computing Hash: " + ex.Message);
                    return;
                }

                byte[] signed;
                byte[] cipher;

                try
                {
                    signed = SenderRSA.SignHash(hash, CryptoConfig.MapNameToOID("MD5"));
                }
                catch (Exception ex)
                {
                    ReceiverRSA.Clear();
                    SenderRSA.Clear();
                    LogError("Error Signing Hash: " + ex.Message);
                    return;
                }

                try
                {
                    cipher = ReceiverRSA.Encrypt(TripleDESKey, false);
                }
                catch (Exception ex)
                {
                    ReceiverRSA.Clear();
                    SenderRSA.Clear();
                    LogError("Error Encrypting Symmetric Key: " + ex.Message);
                    return;
                }

                string base64sign   = Convert.ToBase64String(signed);
                string base64cipher = Convert.ToBase64String(cipher);


                _payload   = webcode(base64enc);
                _signature = webcode(base64sign);

                //byte[] EncBinarySig = Convert.FromBase64String(webDecode(_signature));

                _cipher = webcode(base64cipher);

                WebClient           wc   = new WebClient();
                NameValueCollection vars = new NameValueCollection();
                vars.Add("Payload", webcode(base64enc));
                vars.Add("Signature", webcode(base64sign));
                vars.Add("Cipher", webcode(base64cipher));
                vars.Add("ClientID", _clientID);
                vars.Add("ServerID", _serverID);
                vars.Add("SenderKeyVersion", _senderKeyVersion);
                vars.Add("ReceiverKeyVersion", _receiverKeyVersion);

                ShellWindows shWin = new ShellWindows();

                object o = null;
                object v = (object)vars;
                SHDocVw.InternetExplorer IE = new InternetExplorerClass();
                //IWebBrowserApp wb = (IWebBrowserApp)IE;
                ////wb.FullName = "AnswerKey";
                //wb.Visible = true;
                //wb.Navigate("http://www.c-sharpcorner.com/", ref o, ref o, ref o, ref o);
                //IE.Name
                bool b = false;

                foreach (InternetExplorer ies in shWin)
                {
                    if (ies.HWND == IE.HWND)
                    {
                        IE.Visible = true;
                        IE.Navigate("http://www.c-sharpcorner.com/", ref o, ref o, ref o, ref o);
                    }
                    else
                    {
                        IE         = new InternetExplorerClass();
                        IE.Visible = true;
                        IE.Navigate("http://www.codeproject.com/", ref o, ref o, ref o, ref o);
                    }
                }



                //IE.Visible = true;
                //IE.Navigate("https://sso.ehr.com/Destination.aspx", ref o, ref o, ref v, ref o);
                ////MessageBox.Show(IE.Name.ToString());

                //int hndl = IE.HWND;



                //byte[] retBytes = wc.UploadValues("https://sso.ehr.com/Destination.aspx", vars);

                //string retASCII = Encoding.ASCII.GetString(retBytes);

                ReceiverRSA.Clear();
                SenderRSA.Clear();
            }
            catch (Exception ex)
            {
                throw new Exception("Error while Building the SSO Package: \n" + ex.Message);
            }
        }