public SynchronizationView() { InitializeComponent(); OxyPlotHelper.SetAxisZoomWheelAndPan(SynchronizationPlotView); // Design time! if (DesignerProperties.GetIsInDesignMode(this)) { var appConfiguration = new CapFrameXConfiguration(); DataContext = new SynchronizationViewModel(new FrametimeStatisticProvider(appConfiguration), new EventAggregator(), appConfiguration); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); viewModel = new SynchronizationViewModel(ApplicationState.Current); viewModel.SynchronizationCompleted += delegate { #if RELEASE //in normal working we should save the state after sync to be sure that even crash of the app will not destroy the sync data ApplicationState.Current.SaveState(false); #endif Dispatcher.BeginInvoke( delegate { btnSync.Content = ApplicationStrings.SynchronizationPage_SynchronizeButton; updateGui(); lpMergeBehavior.IsEnabled = true; }); }; DataContext = viewModel; }
public void InitialState() { ApplicationState appState = new ApplicationState(); ApplicationState.Current = appState; appState.SessionData = new SessionData(); appState.SessionData.Profile = new ProfileDTO() { GlobalId = Guid.NewGuid() }; appState.MyDays = new Dictionary <CacheKey, TrainingDaysHolder>(); var holder = appState.GetTrainingDayHolder(null); DateTime time = ExtensionMethods.MonthDate(DateTime.UtcNow); holder.TrainingDays.Add(time.AddDays(1), new TrainingDayInfo(new TrainingDayDTO() { TrainingDate = time.AddDays(1) }) { IsModified = true }); holder.TrainingDays.Add(time.AddDays(2), new TrainingDayInfo(new TrainingDayDTO() { TrainingDate = time.AddDays(2) })); holder.TrainingDays.Add(time.AddDays(3), new TrainingDayInfo(new TrainingDayDTO() { TrainingDate = time.AddDays(3) }) { IsModified = true }); var tdi = new TrainingDayInfo(new TrainingDayDTO() { TrainingDate = time.AddDays(4) }) { IsModified = true }; //these points should be detected to save GPSTrackerEntryDTO gpsEntry = new GPSTrackerEntryDTO(); tdi.TrainingDay.Objects.Add(gpsEntry); gpsEntry.TrainingDay = tdi.TrainingDay; var points = new List <GPSPoint>(); points.Add(new GPSPoint(1, 2, 3, 4, 6)); tdi.GPSCoordinates.Add(new LocalObjectKey(gpsEntry.InstanceId, KeyType.InstanceId), new GPSPointsBag(points, false)); //these shouldn't be var entry1 = new GPSTrackerEntryDTO(); tdi.TrainingDay.Objects.Add(entry1); entry1.TrainingDay = tdi.TrainingDay; points = new List <GPSPoint>(); points.Add(new GPSPoint(11, 12, 13, 14, 7)); tdi.GPSCoordinates.Add(new LocalObjectKey(entry1.InstanceId, KeyType.InstanceId), new GPSPointsBag(points, true)); holder.TrainingDays.Add(time.AddDays(4), tdi); holder.TrainingDays.Add(time.AddDays(5), new TrainingDayInfo(new TrainingDayDTO() { TrainingDate = time.AddDays(5) })); holder.TrainingDays.Add(time.AddDays(6), new TrainingDayInfo(new TrainingDayDTO() { TrainingDate = time.AddDays(6) })); SynchronizationViewModel viewModel = new SynchronizationViewModel(appState); Assert.AreEqual(4, viewModel.Items.Count); Assert.AreEqual(Visibility.Collapsed, viewModel.ProgressVisibility); Assert.AreEqual(holder.TrainingDays[time.AddDays(1)], viewModel.Items[0].DayInfo); Assert.AreEqual(ItemType.TrainingDay, viewModel.Items[0].ItemType); Assert.AreEqual(holder.TrainingDays[time.AddDays(3)], viewModel.Items[1].DayInfo); Assert.AreEqual(ItemType.TrainingDay, viewModel.Items[1].ItemType); Assert.AreEqual(holder.TrainingDays[time.AddDays(4)], viewModel.Items[2].DayInfo); Assert.AreEqual(ItemType.TrainingDay, viewModel.Items[2].ItemType); Assert.AreEqual(holder.TrainingDays[time.AddDays(4)].GPSCoordinates[new LocalObjectKey(gpsEntry.InstanceId, KeyType.InstanceId)], viewModel.Items[3].GPSBag); Assert.AreEqual(ItemType.GPSCoordinates, viewModel.Items[3].ItemType); Assert.AreEqual(holder.TrainingDays[time.AddDays(4)], viewModel.Items[3].DayInfo); Assert.AreEqual(gpsEntry, viewModel.Items[3].GPSEntry); }