Пример #1
0
        private void tbRunCore_Click(object sender, RoutedEventArgs e)
        {
            if (deviceCount == 4)
              {
            MessageBox.Show("The current implementation only supports 3 devices.");
            return;
              }

              if (cbSimCamera.IsSelected || cbComCamera.IsSelected)
              {
            foreach (ITPadApp appInstance in AppInstances)
            {
              if (appInstance.Core.UseCamera)
              {
            MessageBox.Show("You cannot use the camera in more than one device if a simulation is running.");
            return;
              }
            }
              }

              try
              {
            TPadLauncherSettings settings = new TPadLauncherSettings() { DeviceID = deviceCount++, BoardPort = null, UseCamera = false };
            if (cbSimCamera.IsSelected || cbComCamera.IsSelected)
            {
              chbUseFeatureTracking.IsChecked = true;
              chbUseFeatureTracking.IsEnabled = false;
              settings.UseCamera = true;
            }

            if (cbComSim.IsSelected || cbComCamera.IsSelected)
              settings.BoardPort = (cbComPort.SelectedItem as ComboBoxItem).Tag as String;
            settings = Launcher.GetSettings(settings);

            TPadCore core = new TPadCore();
            core.BoardCOM = settings.BoardPort;
            core.UseCamera = settings.UseCamera;
            core.Dispatcher = Dispatcher;
            core.Configure(Profile, settings.DeviceID, settings.MulticastGroup, settings.MulticastPort, settings.MulticastTTL);

            SimulatorDevice simDevice = new SimulatorDevice(this, core);
            simDevice.OnStackingControl += simDevice_OnStackingControl;
            simDevice.PropertyChanged += simDevice_PropertyChanged;
            simDevice.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            simDevice.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            BindingOperations.SetBinding(simDevice, SimulatorDevice.InitialXProperty, new Binding("StartPageX") { Source = this });
            BindingOperations.SetBinding(simDevice, SimulatorDevice.WidthProperty, new Binding("DeviceWidth") { Source = this });
            BindingOperations.SetBinding(simDevice, SimulatorDevice.HeightProperty, new Binding("DeviceHeight") { Source = this });
            BindingOperations.SetBinding(simDevice, SimulatorDevice.AppWidthProperty, new Binding("AppWidth") { Source = this });
            BindingOperations.SetBinding(simDevice, SimulatorDevice.AppHeightProperty, new Binding("AppHeight") { Source = this });
            BindingOperations.SetBinding(simDevice, SimulatorDevice.FrameWidthProperty, new Binding("FrameWidth") { Source = this });
            BindingOperations.SetBinding(simDevice, SimulatorDevice.FrameHeightProperty, new Binding("FrameHeight") { Source = this });

            //*************** TO RUN ON TPAD WINDOW *********************
            if (ckbSeparateWindow.IsChecked.Value)
            {
              simDevice.LoadTPadApp(new MockApp(Profile, simDevice, simDevice) { Core = core });
              gTop.Children.Add(simDevice);

              TPadWindow deviceWindow = new TPadWindow(Profile, Launcher, core);
              deviceWindow.Closed += deviceWindow_Closed;

              core.CoreStart(deviceWindow, simDevice);

              TPadApplicationDescriptor defaultAppDescriptor = Launcher.GetApplicationDescriptor();
              ITPadApp defatultApp = Launcher.GetAppInstance(defaultAppDescriptor, deviceWindow, simDevice, core, null);

              deviceWindow.LoadTPadApp(defatultApp);
              deviceWindow.Show();
              AppInstances.Add(defatultApp);
            }
            //*************** TO RUN ON SIMULATOR WINDOW *********************
            else
            {
              core.CoreStart(simDevice, simDevice);

              TPadApplicationDescriptor defaultAppDescriptor = Launcher.GetApplicationDescriptor();
              ITPadApp defatultApp = Launcher.GetAppInstance(defaultAppDescriptor, simDevice, simDevice, core, null);
              simDevice.LoadTPadApp(defatultApp);
              gTop.Children.Add(simDevice);
              AppInstances.Add(defatultApp);
            }
            //*************** END ********************************************
              }
              catch (Exception exception)
              {
            MessageBox.Show(exception.Message);
              }
        }
Пример #2
0
        void simDevice_OnStackingControl(object sender, StackingControlEventArgs e)
        {
            SimulatorDevice source = (SimulatorDevice)sender;
              if (e.NewState == StackingControlState.Stacking)
              {
            if (topDevice == null)
              topDevice = source;
            else
            {
              bottomDevice = source;

              topDevice.StackingControlState = StackingControlState.StackedTop;
              bottomDevice.StackingControlState = StackingControlState.StackedBotton;

              topDevice.Location = bottomDevice.Location;
              topDevice.RotationAngle = bottomDevice.RotationAngle + 180;
              topDevice.SetValue(Grid.ZIndexProperty, 1);
              bottomDevice.SetValue(Grid.ZIndexProperty, 0);
              bottomDevice.DeviceOnTopID = topDevice.Core.Device.ID;
            }
              }
              else if (e.NewState == StackingControlState.None)
              {
            if (topDevice != null)
              topDevice.StackingControlState = StackingControlState.None;

            if (bottomDevice != null)
              bottomDevice.StackingControlState = StackingControlState.None;
            if (bottomDevice != null)
              bottomDevice.DeviceOnTopID = 0;

            topDevice = null;
            bottomDevice = null;
              }
        }