示例#1
0
        public TPadWindow(TPadProfile profile, ITPadAppLauncher launcher, TPadCore core)
        {
            SizeMultiplier = 0.75; // This makes the window smaller when using a single monitor set-up -- for development
              Launcher = launcher;
              Profile = profile;
              Core = core;

              InitializeComponent();
        }
示例#2
0
        public SimulatorDevice(Simulator simulator, TPadCore core)
        {
            sWindow = simulator;
              Profile = core.Profile;
              Core = core;
              DeviceOnTopID = 0;
              CalculatorGlyph = false;
              TPadAppBounds = Rect.Empty;

              Core.Device.StackingChanged += new StackingChangedEventHandler(Device_StackingChanged);

              InitializeComponent();
        }
示例#3
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);
              }
        }