private void HandleLoaded(object sender, RoutedEventArgs e)
        {
            if (bridge == null)
            {
                WPFSpinnakerConfiguration.Init();

                // Using log4net with Spinnaker is optional.
                log4net.Config.XmlConfigurator.Configure();
                SpinnakerLog4netAdapter.Init();

                bridge = SpinnakerConfiguration.CurrentConfig.CreateBrowserBridge(webBrowser);
                SplashViewModel splashViewModel = new SampleApplication.Core.SampleApplication().Init();
                bridge.ShowView("SplashView.html", splashViewModel);
                splashViewModel.PropertyChanged += (propSender,propChangeEvent) =>
                {
                    if (propChangeEvent.PropertyName == "CurrentPage")
                        bridge.ExecuteScriptFunction("setHeroBackground");
                };

                System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick += new EventHandler((o, tickArgs) =>
                {
                    splashViewModel.RealtimeViewModel.HandleGUITimerTick();
                });
                dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 50);
                dispatcherTimer.Start();
            }
        }
 public void Setup()
 {
     TestSpinnakerConfiguration.Init();
     webBrowser = new UnitTestWebBrowser();
     bridge = SpinnakerConfiguration.CurrentConfig.CreateBrowserBridge(webBrowser);
     Assert.IsNotNull(bridge, "Should have created a browser bridge");
 }
        internal ViewModelInstance(INotifyPropertyChanged viewModel, ViewModelDefinition viewModelDefinition, BrowserBridge browser)
        {
            this.viewModel = viewModel;
            this.browser = browser;
            this.viewModelDefinition = viewModelDefinition;
            scriptId = id.ToString().Replace("{", "").Replace("}", "").Replace("-", "");

            browser.ExecuteScriptFunction("createInstance", new string[] { viewModelDefinition.BindableName, scriptId });
        }
 public void BindViewModel(INotifyPropertyChanged viewModel, BrowserBridge browser)
 {
     ViewModelDefinition definition = GetViewModelDefinition(viewModel.GetType());
     if (definition == null)
     {
         definition = new ViewModelDefinition(viewModel.GetType(), viewModel.GetType().Name);
         StringBuilder sb = new StringBuilder();
         List<ViewModelDefinition> allDefs = new List<ViewModelDefinition>();
         definition.CollectViewModelDefinitions(allDefs);
         foreach (ViewModelDefinition child in allDefs)
             child.DefineInBrowser(sb);
         InjectFramework(sb);
         browser.InsertScript(sb.ToString());
     }
 }
 public void ActivateRootViewModel(INotifyPropertyChanged viewModel, BrowserBridge browser)
 {
     ViewModelInstance rootViewModel = InstantiateInBrowser(viewModel, browser);
     browser.ExecuteScriptFunction("bindRoot", rootViewModel.ScriptId);
 }
 internal ViewModelInstance InstantiateInBrowser(INotifyPropertyChanged instance, BrowserBridge browser)
 {
     ViewModelInstance result = null;
     viewModelInstancesByViewModel.TryGetValue(instance, out result);
     if (result == null)
     {
         result = new ViewModelInstance(instance, GetViewModelDefinition(instance.GetType()), browser);
         result.RefCount = 1;
         viewModelInstancesById[result.Id] = result;
         viewModelInstancesByViewModel[instance] = result;
         result.InitializeProperties();
         browser.ExecuteScriptFunction("handleViewModelCreated", instance.GetType().Name, result.Id.ToString("N"));
     }
     else
         result.RefCount++;
     return result;
 }