Exemplo n.º 1
0
        // Todo: add checkbox to form when checked/uncheck create method to call that does the same as Keyboard ctor
        public Keyboard()
        {
            InitializeComponent();
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            _rawinput = new CRawInput(Handle, CaptureOnlyInForeground);

            _rawinput.AddMessageFilter();   // Adding a message filter will cause keypresses to be handled
            Win32.DeviceAudit();            // Writes a file DeviceAudit.txt to the current directory

            _rawinput.KeyPressed += OnKeyPressed;
        }
Exemplo n.º 2
0
        static void Main()
        {
            Program._Administration = new Administration();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ip = "localhost:8000";

            if (!File.Exists("bind.txt"))
            {
                File.Create("bind.txt");
            }
            if (File.Exists("bind.txt"))
            {
                try
                {
                    string temp = File.ReadAllText("bind.txt");
                    if (!string.IsNullOrEmpty(temp) && !string.IsNullOrWhiteSpace(temp) && temp.Length > 2)
                    {
                        ip = temp;
                    }
                }
                catch(Exception)
                {

                }
            }

            ServerGUI gui = new ServerGUI();

            ControlWriter consoleWriter = new ControlWriter(gui.infoText);
            Console.SetOut(consoleWriter);

            // creeer een host proces voor de TrafficMessageService
            ServiceHost host = new ServiceHost(typeof(CTrafficMessage));

            // creeer een zgn. end-point voor de service
            Type contract = typeof(ITrafficMessage);
            BasicHttpBinding binding = new BasicHttpBinding();
            string baseAddress = "http://" + ip + "/MEX";
            Uri address = new Uri(baseAddress + "/MessageService");
            host.AddServiceEndpoint(contract, binding, address);

            // creeer een zgn. mex endpoint om de wsdl van de service te hosten
            host.Description.Behaviors.Add(new ServiceMetadataBehavior());
            EndpointAddress endPointAddress = new EndpointAddress(baseAddress + "/MEX");
            ServiceEndpoint mexEndpoint = new ServiceMetadataEndpoint(endPointAddress);
            host.AddServiceEndpoint(mexEndpoint);

            ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();

            // if not found - add behavior with setting turned on
            if (debug == null)
            {
                host.Description.Behaviors.Add(
                     new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
            }
            else
            {
                // make sure setting is turned ON
                if (!debug.IncludeExceptionDetailInFaults)
                {
                    debug.IncludeExceptionDetailInFaults = true;
                }
            }

            // start de service
            host.Open();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            _ITTF_SERVER_CONTROL_FORM = new ITTF_SERVER_CONTROL_FORM();
            _ITTF_SERVER_CONTROL_FORM.Show();

            _rawinput = new CRawInput(gui.Handle, CaptureOnlyInForeground);

            _rawinput.AddMessageFilter();   // Adding a message filter will cause keypresses to be handled

            _rawinput.KeyPressed += OnKeyPressed;

            new AdministrationForm().Show();
            Application.Run(gui);

            _CTrafficMessage.Bye();
        }