Exemplo n.º 1
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                _service       = new FarmaService();
                _ticketService = new TicketService();

                _listener = new LowLevelKeyboardListener();
                _window   = new LowLevelWindowsListener();

                _infoBrowser         = new BrowserWindow();
                _customBrowser       = new BrowserWindow();
                _presentationBrowser = new BrowserWindow();

                // Leemos los archivos de configuración
                _service.LeerFicherosConfiguracion();
                _ticketService.InitializeConfiguration();

                // Setamos el comportamiento de la aplicación al presionar una tecla
                _listener.OnKeyPressed += _listener_OnKeyPressed;

                // Activamos el listener de teclado
                _listener.HookKeyboard();

                _iconNotification = new System.Windows.Forms.NotifyIcon();
                _iconNotification.BalloonTipText  = "La Aplicación SisFarma se encuentra ejecutando";
                _iconNotification.BalloonTipTitle = "SisFarma Notificación";
                _iconNotification.Text            = "Presione Click para Mostrar";
                _iconNotification.Icon            = Lector.Sharp.Wpf.Properties.Resources.Logo;
                _iconNotification.BalloonTipIcon  = System.Windows.Forms.ToolTipIcon.Info;

                System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();
                System.Windows.Forms.MenuItem    notificactionInfoMenu = new System.Windows.Forms.MenuItem("Info");
                notificactionInfoMenu.Click += notificactionInfoMenu_Click;
                System.Windows.Forms.MenuItem notificationQuitMenu = new System.Windows.Forms.MenuItem("Salir");
                notificationQuitMenu.Click += notificationQuitMenu_Click;

                menu.MenuItems.Add(notificactionInfoMenu);
                menu.MenuItems.Add(notificationQuitMenu);
                _iconNotification.ContextMenu = menu;
                _iconNotification.Visible     = true;

                InitializeTicketTimer();
                InitializeShutdownTimer();

                OpenWindowPresentation(_presentationBrowser, _service.Presentation);
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
        }
        public MainWindow()
        {
            var updateTimer = new System.Timers.Timer(5000);

            updateTimer.Elapsed += (s, e) =>
            {
                if (Updater.CheckUpdateSyncWithInfo())
                {
                    Updater.UpdateHot();
                    Dispatcher.Invoke(() => Application.Current.BeginReStart());
                }
            };
            updateTimer.Start();

            try
            {
                RegisterStartup();
                SupportHtml5();
                InitializeComponent();
                _service        = new FarmaService();
                _listener       = new LowLevelKeyboardListener();
                _infoBrowser    = new BrowserWindow();
                _customBrowser  = new BrowserWindow();
                _customBrowserR = new BrowserWindow();
                _window         = new LowLevelWindowsListener();

                // Leemos los archivos de configuración
                _service.LeerFicherosConfiguracion();

                // Setamos el comportamiento de la aplicación al presionar una tecla
                _listener.OnKeyPressed += _listener_OnKeyPressed;

                // Activamos el listener de teclado
                _listener.HookKeyboard();

                // Deshabilitamos HotKey, porque usamos LowLevelKeyboardProc
                //this.RegisterHotKeys();

                _iconNotification = new System.Windows.Forms.NotifyIcon();
                _iconNotification.BalloonTipText  = "La Aplicación SisFarma se encuentra ejecutando";
                _iconNotification.BalloonTipTitle = "SisFarma Notificación";
                _iconNotification.Text            = "Presione Click para Mostrar";
                _iconNotification.Icon            = Lector.Sharp.Wpf.Properties.Resources.Logo;
                _iconNotification.BalloonTipIcon  = System.Windows.Forms.ToolTipIcon.Info;

                System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();
                System.Windows.Forms.MenuItem    notificactionInfoMenu = new System.Windows.Forms.MenuItem("Info");
                notificactionInfoMenu.Click += notificactionInfoMenu_Click;
                System.Windows.Forms.MenuItem notificationQuitMenu = new System.Windows.Forms.MenuItem("Salir");
                notificationQuitMenu.Click += notificationQuitMenu_Click;

                menu.MenuItems.Add(notificactionInfoMenu);
                menu.MenuItems.Add(notificationQuitMenu);
                _iconNotification.ContextMenu = menu;
                _iconNotification.Visible     = true;
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message);
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                _service       = new FarmaService();
                _ticketService = new TicketService();

                _listener = new LowLevelKeyboardListener();
                _window   = new LowLevelWindowsListener();

                _infoBrowser         = new BrowserWindow();
                _customBrowser       = new BrowserWindow();
                _presentationBrowser = new BrowserWindow();

                // Leemos los archivos de configuración
                _service.LeerFicherosConfiguracion();
                _ticketService.InitializeConfiguration();

                // Setamos el comportamiento de la aplicación al presionar una tecla
                _listener.OnKeyPressed += _listener_OnKeyPressed;

                // Activamos el listener de teclado
                _listener.HookKeyboard();

                _iconNotification = new System.Windows.Forms.NotifyIcon();
                _iconNotification.BalloonTipText  = "La Aplicación SisFarma se encuentra ejecutando";
                _iconNotification.BalloonTipTitle = "SisFarma Notificación";
                _iconNotification.Text            = "Presione Click para Mostrar";
                _iconNotification.Icon            = Lector.Sharp.Wpf.Properties.Resources.Logo;
                _iconNotification.BalloonTipIcon  = System.Windows.Forms.ToolTipIcon.Info;

                System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();
                System.Windows.Forms.MenuItem    notificactionInfoMenu = new System.Windows.Forms.MenuItem("Info");
                notificactionInfoMenu.Click += notificactionInfoMenu_Click;
                System.Windows.Forms.MenuItem notificationQuitMenu = new System.Windows.Forms.MenuItem("Salir");
                notificationQuitMenu.Click += notificationQuitMenu_Click;

                menu.MenuItems.Add(notificactionInfoMenu);
                menu.MenuItems.Add(notificationQuitMenu);
                _iconNotification.ContextMenu = menu;
                _iconNotification.Visible     = true;

                InitializeTicketTimer();
                InitializeShutdownTimer();

                OpenWindowPresentation(_presentationBrowser, _service.Presentation);

                //_processChrome = new Process();
                //_processChrome.StartInfo.FileName = @"chrome.exe";
                //_processChrome.StartInfo.Arguments = $@"--kiosk --fullscreen --app={_service.Presentation}";
                //_processChrome.Start();
                //_processChrome.WaitForInputIdle(1000);
                //_processChrome.Refresh();
                //SetParent(_processChrome.MainWindowHandle, new WindowInteropHelper(this).Handle);
                //SetWindowPos(_processChrome.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
                //SetForegroundWindow(_processChrome.Handle);
                //_processChrome.Refresh();
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
        }