Ejemplo n.º 1
0
 public static void UpdateStatus(IEnumerable menuItems)
 {
     if (menuItems == null)
     {
         return;
     }
     foreach (object o in menuItems)
     {
         IStatusUpdate cmi = o as IStatusUpdate;
         if (cmi != null)
         {
             cmi.UpdateStatus();
         }
     }
 }
Ejemplo n.º 2
0
        void WebBrowserNavigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            // do not use e.Url (frames!)
            string url = webBrowser.Url.ToString();

            if (dummyUrl != null && url == "about:blank")
            {
                urlBox.Text = dummyUrl;
            }
            else
            {
                urlBox.Text = url;
            }
            // Update toolbar:
            foreach (object o in toolStrip.Items)
            {
                IStatusUpdate up = o as IStatusUpdate;
                if (up != null)
                {
                    up.UpdateStatus();
                }
            }
        }
Ejemplo n.º 3
0
        public HtmlViewPane(bool showNavigation)
        {
            Dock = DockStyle.Fill;
            Size = new Size(500, 500);

            webBrowser      = new ExtendedWebBrowser();
            webBrowser.Dock = DockStyle.Fill;
            webBrowser.NewWindowExtended += delegate(object sender, NewWindowExtendedEventArgs e)
            {
                e.Cancel = true;
                WorkbenchSingleton.Workbench.ShowView(new BrowserPane(e.Url));
            };
            webBrowser.Navigated += delegate
            {
                // do not use e.Url (frames!)
                urlBox.Text = webBrowser.Url.ToString();

                // Update toolbar:
                foreach (object o in toolStrip.Items)
                {
                    IStatusUpdate up = o as IStatusUpdate;
                    if (up != null)
                    {
                        up.UpdateStatus();
                    }
                }
            };
            Controls.Add(webBrowser);

            if (showNavigation)
            {
                toolStrip           = ToolbarService.CreateToolStrip(this, sButtonsPath);
                toolStrip.GripStyle = ToolStripGripStyle.Hidden;
                Controls.Add(toolStrip);
            }
        }
Ejemplo n.º 4
0
        private void StartFilter()
        {
            m_Device = null;

            while (!m_bStop)
            {
                try
                {
                    LivePcapDeviceList devices = null;
                    devices = LivePcapDeviceList.Instance;

                    int i = 0;
                    /* Scan the list printing every entry */
                    foreach (LivePcapDevice dev in devices)
                    {
                        if (dev.Description.ToString() == m_strNIC)
                        {
                            m_Device = devices[i];
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }

                    if (m_Device == null)
                    {
                        m_IStatusUpdate.UpdateStatus("Failed to get handle to NIC");
                    }
                    else
                    {
                        //Open the device for capturing
                        int readTimeoutMilliseconds = 1000;
                        m_Device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);

                        //Register our handler function to the 'packet arrival' event
                        m_Device.OnPacketArrival += new PacketArrivalEventHandler(device_OnPacketArrival);

                        // udpdump filter to capture only UDP/IP packets
                        string filter = "udp";
                        m_Device.SetFilter(filter);

                        if (m_dtBound != DateTime.MaxValue)
                        {
                            m_IStatusUpdate.UpdateStatus("Next update at " + (m_dtBound + m_spanLease).ToString());
                        }
                        else
                        {
                            m_IStatusUpdate.UpdateStatus("Started DHCP Client...");
                        }
                        // Start capture packets
                        m_Device.Capture();
                        // NO stop request...
                        if (!m_bStop)
                        {
                            if (m_Device != null)
                            {
                                m_Device.Close();
                                m_Device = null;
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    m_IStatusUpdate.UpdateStatus("Exception: " + exc.Message);
                    try
                    {
                        m_Device.Close();
                    }
                    catch (Exception)
                    { }
                    m_Device = null;
                }
                Thread.Sleep(1000);
            }
        }