예제 #1
0
        public Rest(RestaurantOwnerWindow rest, string idRest)
        {
            // Constructor.
            IModel model = (DataBaseModel)Application.Current.Properties["model"];

            DataContext = new ViewModelRestaurantOwner(model);

            var VMMyRests      = "VM_RestsResults";
            var bindingMyRests = new Binding(VMMyRests)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(MyRestaurantsProperty, bindingMyRests);

            var VMRestID      = "VM_RestID";
            var bindingRestID = new Binding(VMRestID)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(RestIDProperty, bindingRestID);

            var VMIDToRemove      = "VM_IDToRemove";
            var bindingIDToRemove = new Binding(VMIDToRemove)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(IDToRemoveProperty, bindingIDToRemove);

            InitializeComponent();

            // Initialize the fileds.
            restID = idRest;
            restow = rest;
        }
        public RestaurantOwnerWindow(string username)
        {
            // Constructor.
            IModel model = (DataBaseModel)Application.Current.Properties["model"];

            DataContext = new ViewModelRestaurantOwner(model);

            var VMMyRests      = "VM_RestsResults";
            var bindingMyRests = new Binding(VMMyRests)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(MyRestaurantsProperty, bindingMyRests);

            var VMRestID      = "VM_RestID";
            var bindingRestID = new Binding(VMRestID)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(CurrentRestIDProperty, bindingRestID);

            var VMOrder      = "VM_Order";
            var bindingOrder = new Binding(VMOrder)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(OrderProperty, bindingOrder);

            var VMAsc      = "VM_Asc";
            var bindingAsc = new Binding(VMAsc)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(AscProperty, bindingAsc);

            var VMLoadMoreRests      = "VM_LoadMoreRests";
            var bindingLoadMoreRests = new Binding(VMLoadMoreRests)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(OLoadMoreRestsProperty, bindingLoadMoreRests);

            var VMEndOfRests      = "VM_EndOfRests";
            var bindingEndOfRests = new Binding(VMEndOfRests)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(OEndOfRestsProperty, bindingEndOfRests);

            // Initialize the view.
            InitializeComponent();
            noRest.Visibility = Visibility.Collapsed;
            if (OEndOfRests == true)
            {
                moreRests.IsEnabled = false;
            }
            comboSort.IsEnabled = true;

            // Fill the list of rest view accordint to DB list of rest.
            stp = (StackPanel)FindName("restList");
            FillRestStackPanel();

            // Initialize the fileds.
            ownerName             = username;
            usernameValue.Content = "Hello " + ownerName;
        }