Пример #1
0
        public void Dispose()
        {
            Exit();

            if (_deviceService != null)
            {
                _deviceService.Dispose();
                _deviceService = null;
            }
        }
Пример #2
0
        public void Run()
        {
            if (Running)
            {
                return;
            }

            _deviceService = new DevicesService();
            Globals.Instance.NewDeviceEvent    += new EventHandler <DeviceChangeEventArgs>(_deviceService_NewDeviceEvent);
            Globals.Instance.RemoveDeviceEvent += new EventHandler <DeviceChangeEventArgs>(_deviceService_RemoveDeviceEvent);

            // utworzenie menu podstawowego
            _menu        = new ContextMenu();
            _menu.Popup += new EventHandler(_menu_Popup);

            _informationMenuItem = new MenuItem(Properties.Resources.Info, delegate(object sender, EventArgs e)
            {
                // pokazanie okna z informacjami o programie
                ShowInformationDialog();
            });

            _optionsMenuItem = new MenuItem(Properties.Resources.Options, delegate(object sender, EventArgs e)
            {
                // pokazanie okna z opcjami
            });

            _exitMenuItem = new MenuItem(Properties.Resources.CloseApplication, delegate(object sender, EventArgs e)
            {
                Exit();
                Application.Exit();
            });

            _testModeMenuItem = new MenuItem("TEST mode", delegate(object sender, EventArgs e)
            {
                Globals.Instance.ChangePlane(simPROJECT.Planes.PlaneType.Test);
            });
            _testModeMenuItem.RadioCheck = true;

            _devicesLabelMenuItem         = new MenuItem(" *** Devices ***");
            _devicesLabelMenuItem.Enabled = false;

            _planesLabelMenuItem         = new MenuItem(" *** Planes ***");
            _planesLabelMenuItem.Enabled = false;

            _tray         = new AppTrayIcon(_container, _menu);
            _tray.Visible = true;

            // wystartowanie obsługi urządzeń

            _deviceService.Start();

            Running = true;
        }