Exemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(String.Empty);
            }

            Stop stop;

            if (value is Stop)
            {
                stop = (Stop)value;
            }
            else
            {
                stop = ((Route)value).closestStop;
            }

            AViewModel viewModel = parameter as AViewModel;

            if (stop != null && viewModel.LocationTracker.LocationKnown == true)
            {
                double distance = stop.CalculateDistanceInMiles(viewModel.LocationTracker.CurrentLocation);
                return(string.Format("distance: {0:0.00} mi", distance));
            }
            else
            {
                return("");
            }
        }
        public ActionResult WidgetContentThree()
        {
            System.Threading.Thread.Sleep(1000); // Fake waiting time to show javascript spinner
            var model = new AViewModel();

            return(PartialView("EditorTemplates/Object", model));
        }
    public void CreateNewWindow(AViewModel newWindowViewModel)
    {
        NewWindow window = new NewWindow()
        {
            DataContext = newWindowViewModel;
        };

        window.Show();
    }
    public MainWindow()
    {
        InitializeComponent();
        var view      = new AView();
        var viewModel = new AViewModel();

        view.DataContext = viewModel;
        ViewPlaceholder.Children.Clear();
        ViewPlaceholder.Children.Add(view);
    }
Exemplo n.º 5
0
 // Have to have a seperate Initialize() method because ViewModel hasn't been instanciated when
 // the constructor is called
 protected void Initialize()
 {
     if (Resources.Contains("ViewModel") == true)
     {
         aViewModel = Resources["ViewModel"] as AViewModel;
     }
     else
     {
         aViewModel = null;
     }
 }
Exemplo n.º 6
0
        public void FindViewModel()
        {
            var data = new AViewModel();

            creator.Setup(i => i.Get(typeof(AView))).Returns(new AView());

            sut.Content = data;

            Assert.Equal(data, sut.Content);

            Assert.IsType <AView>(sut.Child);
            Assert.Equal(data, (sut.Child as FrameworkElement)?.DataContext);
        }
Exemplo n.º 7
0
        public void FindViewModel()
        {
            var data = new AViewModel();
            var sut  = new ViewFrame();

            var creator = new Mock <IDIIntegration>();

            creator.Setup(i => i.Get(typeof(AView))).Returns(new AView());
            DiIntegration.SetContainer(sut, creator.Object);

            sut.Content = data;

            Assert.Equal(data, sut.Content);

            Assert.IsType <AView>(sut.Child);
            Assert.Equal(data, (sut.Child as FrameworkElement)?.DataContext);
        }
Exemplo n.º 8
0
 public MainTest()
 {
     InitializeComponent();
     _vm = new AViewModel();
     this.DataContext = _vm;
 }