public AddChuyenDi()
        {
            newTTChuyendi = new TTChuyendi()
            {
                ImgLink = "imgs/splash.jpg", Members = new List <Thanhvien>(), Place = "Nơi đến", Name = "Tên chuyến đi", Status = TTChuyendi.STATUS[0]
            };


            InitializeComponent();

            statusComboBox.ItemsSource = TTChuyendi.STATUS;

            //newTTChuyendi = new TTChuyendi() { ImgLink = "imgs/splash.jpg", Members = new List<Thanhvien>(), Place = "Nơi đến", Name = "Tên chuyến đi", Status=TTChuyendi.STATUS[0]};

            // Binding
            Binding bindingName = new Binding("Name");

            bindingName.Source = newTTChuyendi;
            bindingName.Mode   = BindingMode.TwoWay;
            bindingName.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            nameTxtBox.SetBinding(TextBox.TextProperty, bindingName);

            Binding bindingPlace = new Binding("Place");

            bindingPlace.Source = newTTChuyendi;
            bindingPlace.Mode   = BindingMode.TwoWay;
            bindingPlace.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            placeTxtBox.SetBinding(TextBox.TextProperty, bindingPlace);

            Binding bindingStatus = new Binding("Status");

            bindingStatus.Source = newTTChuyendi;
            bindingStatus.Mode   = BindingMode.TwoWay;
            bindingStatus.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            statusComboBox.SetBinding(ComboBox.SelectedValueProperty, bindingStatus);

            Binding bindingImgLink = new Binding("ImgLink");

            bindingImgLink.Source = newTTChuyendi;
            bindingImgLink.Mode   = BindingMode.TwoWay;
            bindingImgLink.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            bindingImgLink.Converter           = new DirectoryConverter();
            imgLink.SetBinding(Image.TagProperty, bindingImgLink);

            imgLink.Source            = new BitmapImage(new Uri(newTTChuyendi.ImgLink, UriKind.Relative));
            imgBackground.ImageSource = new BitmapImage(new Uri(newTTChuyendi.ImgLink, UriKind.Relative));
        }
Example #2
0
 public static void Add(TTChuyendi newTTCD)
 {
     virtualDataBase.Insert(0, newTTCD);
     SaveData(virtualDataBase);
 }
        public TTChuyendiManager(int IDChuyendi)
        {
            this.DataContext = this;
            InitializeComponent();
            IDTTChuyendi = IDChuyendi;
            TTChuyendi thisCD = ChuyendiDAO.GetAll()[IDChuyendi];

            listViewMembers.ItemsSource = ChuyendiDAO.GetAll()[IDChuyendi].Members;

            // Binding name TTChuyendi
            Binding bindingNameCD = new Binding("Name");

            bindingNameCD.Source = ChuyendiDAO.GetAll()[IDChuyendi];
            bindingNameCD.Mode   = BindingMode.TwoWay;
            bindingNameCD.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            nameCDTextBlock.SetBinding(TextBlock.TextProperty, bindingNameCD);

            // Binding place TTChuyendi
            Binding bindingPlaceCD = new Binding("Place");

            bindingPlaceCD.Source = ChuyendiDAO.GetAll()[IDChuyendi];
            bindingPlaceCD.Mode   = BindingMode.TwoWay;
            bindingPlaceCD.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            placeTextBlock.SetBinding(TextBlock.TextProperty, bindingPlaceCD);

            imageImg.Source = new BitmapImage(new Uri(AppSettings.WorkingDerectory + thisCD.ImgLink));


            // Binding total TTChuyendi
            Binding bindingTotalCD = new Binding("Total");

            bindingTotalCD.Source = ChuyendiDAO.GetAll()[IDChuyendi];
            bindingTotalCD.Mode   = BindingMode.TwoWay;
            bindingTotalCD.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            totalTextBlock.SetBinding(TextBlock.TextProperty, bindingTotalCD);

            // Binding avg TTChuyendi
            Binding bindingAvgCD = new Binding("Avg");

            bindingAvgCD.Source = ChuyendiDAO.GetAll()[IDChuyendi];
            bindingAvgCD.Mode   = BindingMode.TwoWay;
            bindingAvgCD.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            avgTextBlock.SetBinding(TextBlock.TextProperty, bindingAvgCD);

            //Binding Combobox
            statusChangeComboBox.ItemsSource = TTChuyendi.STATUS;

            Binding bindingStatus = new Binding("Status");

            bindingStatus.Source = ChuyendiDAO.GetAll()[IDChuyendi];
            bindingStatus.Mode   = BindingMode.TwoWay;
            bindingStatus.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            statusChangeComboBox.SetBinding(ComboBox.SelectedValueProperty, bindingStatus);



            Binding bindingMem = new Binding("Members");

            bindingMem.Source = ChuyendiDAO.GetAll()[IDChuyendi];
            bindingMem.Mode   = BindingMode.TwoWay;
            bindingMem.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            chartController.SetBinding(PieSeries.ItemsSourceProperty, bindingMem);
        }