public void main()
    {
        var vm1 = new ViewModel1();
        var vm2 = new ViewModel2();

        vm1.ChangeValueAction = new Action(() => { vm2.SomeProperty = String.Empty; });
    }
        public static IViewModel GetViewModel <TViewModel>(INavigation navigationService) where TViewModel : BaseViewModel
        {
            IViewModel vm = null;

            if (typeof(TViewModel) == typeof(MainViewModel))
            {
                vm = new MainViewModel();
            }

            if (typeof(TViewModel) == typeof(ViewModel1))
            {
                vm = new ViewModel1();
            }

            if (typeof(TViewModel) == typeof(ViewModel2))
            {
                vm = new ViewModel2();
            }

            if (vm != null)
            {
                vm.NavigationService = navigationService;
            }

            return(vm);
        }
    public ApplicationViewModel()
    {
        ViewModel1 = new ViewModel1(someParameters);
        ViewModel2 = new ViewModel2(otherParameters);

        ViewModel1.PropertyChanged += VM1_PropertyChanged;
    }
        public ActionResult PastOperations(ViewModel3 viewModel)
        {
            var testTable = from ap in db.Appointment
                            join dapp in db.DAppDate on ap.DId equals dapp.Id
                            join d in db.Doctor on dapp.Doctor_id equals d.Id
                            join dep in db.Department on d.DId equals dep.Id
                            join hosp in db.Hospital on dep.HId equals hosp.Id
                            select new ViewModel
            {
                appointment = ap,
                dApp        = dapp,
                doctor      = d,
                department  = dep,
                hospital    = hosp,
            };

            ViewData["TestTable"] = testTable;
            var findIllnessId = db.Illness.OrderByDescending(x => x.Id).FirstOrDefault(x => x.Name == viewModel.IllnessName);
            List <Appointment> appointmentList = db.Appointment.Where(x => x.PatientId == PatientHelper.id).ToList();
            List <Patient>     patientList     = db.Patient.Where(x => x.Id == PatientHelper.id).ToList();

            ViewModel2 viewModel2 = new ViewModel2();

            viewModel2.appointments = appointmentList;
            viewModel2.patientss    = patientList;
            viewModel2.PID          = PatientHelper.id;


            return(View(viewModel2));
        }
Exemplo n.º 5
0
 private void Add_OnClick(object sender, RoutedEventArgs e)
 {
     Button btn = (Button)sender;
     var nmb = int.Parse(Regex.Replace(btn.Name, "[^0-9.]", ""));
     object ob = null;
     switch (nmb)
     {
         case 1:
             ob = new ViewModel1(App.EventAgrigator);
             break;
         case 2:
             ob = new ViewModel2(App.EventAgrigator);
             break;
         case 3:
             ob = new ViewModel3(App.EventAgrigator);
             break;
         case 4:
             ob = new ViewModel4(App.EventAgrigator);
             break;
         case 5:
             ob = new ViewModel5(App.EventAgrigator);
             break;
     }
     if (ob != null)
         _objectList.Add(ob);
 }
Exemplo n.º 6
0
        public void PropertyOwnersMarkedForGC_BindingReleased()
        {
            WeakReference <ViewModel1> wr1 = null;
            WeakReference <ViewModel2> wr2 = null;

            new Action(() =>
            {
                var vm1 = new ViewModel1();
                var vm2 = new ViewModel2();

                wr1 = new WeakReference <ViewModel1>(vm1);
                wr2 = new WeakReference <ViewModel2>(vm2);

                PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.TwoWay);
            })();

            EnforceGC();

            {
                ViewModel1 vm1;
                Assert.That(wr1.TryGetTarget(out vm1), Is.False);

                ViewModel2 vm2;
                Assert.That(wr2.TryGetTarget(out vm2), Is.False);
            }
        }
Exemplo n.º 7
0
 private void TweetsList_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     item = this.listView.SelectedItem as Models.TweetInfo;
     //var item = this.listView.SelectedItem as TweetClass.TweetInfo;
     //ViewModel.TweetIdSet(item.Id);
     ViewModel2.TweetIdSet(item.Id);
     itemStock();
     FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
 }
Exemplo n.º 8
0
        public void OneWayToSourceBinding_ChangesOnTargetNotSyncedtoSource()
        {
            var vm1 = new ViewModel1();
            var vm2 = new ViewModel2();

            PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.OneWayToSource);

            vm1.PrimaryValue = 42;
            Assert.That(vm2.SecondaryValue, Is.Not.EqualTo(42));
        }
        public IActionResult Index(int Id)
        {
            ViewModel2 viewModel2 = new ViewModel2();

            viewModel2.subCategories = subcategoryRepository.AllSubCategories().Where(x => x.CategoryId == Id).ToList();
            foreach (var item in viewModel2.subCategories)
            {
                viewModel2.products = productRepository.Products(item).ToList();
            }
            return(View(viewModel2));
        }
Exemplo n.º 10
0
        public void TwoWayBinding_ChangesOnEitherEndSyncedToTheOtherOne()
        {
            var vm1 = new ViewModel1();
            var vm2 = new ViewModel2();

            PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.TwoWay);

            vm1.PrimaryValue = 42;
            Assert.That(vm2.SecondaryValue, Is.EqualTo(42));

            vm2.SecondaryValue = 24;
            Assert.That(vm1.PrimaryValue, Is.EqualTo(24));
        }
Exemplo n.º 11
0
        public Home()
        {
            this.InitializeComponent();

            tokens = data.getToken();
            //tweetLoad();
            ViewModel2.GetTimelineInfos();

            var settings = ApplicationData.Current.RoamingSettings;

            tweet = new ObservableCollection <Models.TweetInfo>();
            //tweetInfo = new ObservableCollection<TweetClass.TweetInfo>();
        }
Exemplo n.º 12
0
     public MainWindowViewModel()
     {
     ViewModel1 = new ViewModel1();
     ViewModel2 = new ViewModel2();
     ViewModel3 = new ViewModel3();
     ViewModel1.PropertyChanged += (s,e) => 
     {
         if(e.PropertyName == "IsBusy") 
         { 
           // set the MainWindowViewModel.IsBusy property here
         }
     }
     //IsBusy = true; - its working
 }
Exemplo n.º 13
0
 private void TweetsList_Tapped(object sender, TappedRoutedEventArgs e)
 {
     try
     {
         item = this.listView.SelectedItem as Models.TweetInfo;
         ViewModel.TweetIdSet(item.Id);
         ViewModel2.TweetIdSet(item.Id);
         //itemStock();
     }
     catch (Exception ex)
     {
     }
     FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
 }
Exemplo n.º 14
0
        public void Unbind_RemovesBindingAgain()
        {
            var vm1 = new ViewModel1();
            var vm2 = new ViewModel2();

            var id = PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue);

            vm2.SecondaryValue = 42;
            Assert.That(vm1.PrimaryValue, Is.EqualTo(42));

            PropertyBinding.Unbind(id);

            vm2.SecondaryValue = 2525;
            Assert.That(vm1.PrimaryValue, Is.EqualTo(42));
        }
Exemplo n.º 15
0
        public void PropertyOwnersStillAlive_BindingsSurvivesGC()
        {
            var vm1 = new ViewModel1();
            var vm2 = new ViewModel2();

            PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.TwoWay);

            EnforceGC();

            {
                // lets see whether binding still works
                vm1.PrimaryValue = 42;
                Assert.That(vm2.SecondaryValue, Is.EqualTo(42));
            }
        }
Exemplo n.º 16
0
 public MainViewModel()
 {
     Add1Command = new Command(() => AddItems(ViewModel1.Items));
     Add2Command = new Command(() => AddItems(ViewModel2.Items));
     Add3Command = new Command(() => AddItems(ViewModel3.Items));
     Add4Command = new Command(() =>
     {
         ViewModel1.ReloadData();
         ViewModel2.ReloadData();
         ViewModel3.ReloadData();
     });
     Add5Command = new Command(() =>
     {
         ViewModel1.ChangeListViewVisability();
         ViewModel2.ChangeListViewVisability();
         ViewModel3.ReloadData();
     });
 }
Exemplo n.º 17
0
        public ActionResult AppointmentIndex(int id)
        {
            int findLastIllness = PatientHelper.id;
            var model           = new ViewModel2();

            model.doctors     = db.Doctor.ToList();
            model.hospitals   = db.Hospital.ToList();
            model.departments = db.Department.ToList();
            model.dAppDates   = db.DAppDate.ToList();
            model.patients    = db.Patient.FirstOrDefault(x => x.Id == id);
            model.illness     = db.Illness.OrderByDescending(x => x.Id).FirstOrDefault(x => x.PId == findLastIllness);



            List <Hospital> hospital = db.Hospital.ToList();

            ViewBag.HospitalNames = new SelectList(hospital, "Id", "Name");

            return(View(model));
        }
Exemplo n.º 18
0
 public ViewModel1(ViewModel2 vm2, Log log)
 {
     VM2 = vm2;
     Log = log;
 }
Exemplo n.º 19
0
  // this will be handled by IoC container
  public MainViewModel(ViewModel1 viewModel1, ViewModel2 viewModel2, ViewModel3 viewModel3)
 {
     ViewModel1 = viewModel1;
     ViewModel2 = viewModel2;
     ViewModel3 = viewModel3;
 }
Exemplo n.º 20
0
 public MainViewModel()
 {
     ViewModel1  = new ViewModel1();
     ViewModel2  = new ViewModel2();
     Vertauschen = new Vertauschen(this);
 }
 public ViewModel1(ViewModel2 vm2)
 {
     _vm2 = vm2;
 }
Exemplo n.º 22
0
        public async Task <ActionResult> Index()
        {
            List <platserModell> StatInfo = new List <platserModell>();
            List <filmModell>    FilmInfo = new List <filmModell>();

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync("BiljettService/Bokadeplatser");

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var StatResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    StatInfo = JsonConvert.DeserializeObject <List <platserModell> >(StatResponse);
                }
            }
            //returning the employee list to view

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res2 = await client.GetAsync("BiljettService/VisningsSchema");

                //Checking the response is successful or not which is sent using HttpClient
                if (Res2.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var FilmResponse = Res2.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    FilmInfo = JsonConvert.DeserializeObject <List <filmModell> >(FilmResponse);
                }
            }

            //returning the employee list to view


            ViewModel2 model2 = new ViewModel2();

            model2.platser = StatInfo;
            model2.film    = FilmInfo;
            return(View(model2));
        }
 public ApplicationViewModel()
 {
     _myScatterSeries = new Collection <Series>();
     ViewModel1       = new ViewModel1(someParameters, _myScatterSeries);
     ViewModel2       = new ViewModel2(otherParameters, _myScatterSeries);
 }