Esempio n. 1
0
 public Dashboard()
 {
     InitializeComponent();
     vm = (ViewModelClass)this.DataContext;
     //DataContext = Status;
     //DataContext = new VM_Dashboard(new MySimApp(new MytelnetClient()));
 }
Esempio n. 2
0
        public void ApplicationStartup(object sender, StartupEventArgs args)
        {
            MainWindow mainWindow = new MainWindow();                           // Instantiate the main window

            mainWindow.ViewModel = ViewModelClass.GetInstance(mainWindow);      // Get an instance of the ViewModel and set the View's ViewModel pointer
            mainWindow.Show();                                                  // Now display the view
        }
Esempio n. 3
0
        public async Task TestAddingClass_Defaults()
        {
            DataItemClass c = new DataItemClass()
            {
                Identifier      = Guid.NewGuid(),
                UpperIdentifier = base.CurrentSemesterId,
                Credits         = 3,
                Name            = "Math",
                Details         = "",
                RawColor        = ColorTools.GetArray(Colors.Red, 3)
            };

            DataChanges changes = new DataChanges();

            changes.Add(c);

            await base.DataStore.ProcessLocalChanges(changes);

            var viewModel = await ViewModelClass.LoadAsync(base.LocalAccountId, c.Identifier, DateTime.Today);

            var viewClass = viewModel.Class;

            Assert.AreEqual("Math", viewClass.Name);
            Assert.AreEqual(3, viewClass.Credits);
            Assert.AreEqual("", viewClass.Details);
            Assert.AreEqual(Colors.Red, viewClass.Color);
        }
Esempio n. 4
0
 public MainWindow()
 {
     WindowState      = WindowState.Maximized;
     vm               = new ViewModelClass(new MySimApp(new MytelnetClient()));
     this.DataContext = vm;
     InitializeComponent();
 }
Esempio n. 5
0
        public void BindingAcrossObjectBoundaries()
        {
            var binder = new Binder();

            /* ViewModelClass, ViewClass, and ControlClass all implement interface
             * INotifyPropertyChanged.
             */
            var view = new ViewClass()
            {
                MyControl = new ControlClass {
                    Label = "aaa"
                }
            };
            var viewModel = new ViewModelClass {
                MyControlLabel = "bbb"
            };

            this._bindings = binder.Bind(viewModel, view);

            //  viewModel.MyControlLabel is now bound to view.MyControl.Label.
            //  both will have the value "bbb".
            Assert.AreEqual("bbb", ((ControlClass)view.MyControl).Label);

            ((ControlClass)view.MyControl).Label = "ccc";      // propagates "ccc" to viewModel.MyControlLabel

            Assert.AreEqual("ccc", viewModel.MyControlLabel);

            viewModel.MyControlLabel = "ddd";  // propagates "ddd" to view.MyControl.Label

            Assert.AreEqual("ddd", ((ControlClass)view.MyControl).Label);
        }
Esempio n. 6
0
        public void NameBasedBinding()
        {
            var binder = new Binder();

            /* ViewModelClass and ViewClass both have a string property MyProperty,
             * and they both implement INotifyPropertyChanged
             */
            var view = new ViewClass {
                MyProperty = "aaa"
            };
            var viewModel = new ViewModelClass {
                MyProperty = "bbb"
            };

            this._bindings = binder.Bind(viewModel, view);

            //  viewModel.MyProperty is now bound to view.MyProperty.
            //  view.MyProperty will have the value "bbb".

            Assert.AreEqual("bbb", view.MyProperty);

            view.MyProperty = "ccc";      // propagates "ccc" to viewModel.MyProperty

            Assert.AreEqual("ccc", viewModel.MyProperty);

            viewModel.MyProperty = "ddd"; // propagates "ddd" to view.MyProperty

            Assert.AreEqual("ddd", view.MyProperty);
        }
Esempio n. 7
0
        public async System.Threading.Tasks.Task TestDeletingClassSchedule()
        {
            DataChanges changes = new DataChanges();

            changes.Add(new DataItemSchedule()
            {
                Identifier      = Guid.NewGuid(),
                UpperIdentifier = base.CurrentClassId,
                StartTime       = new DateTime(2015, 1, 1, 8, 00, 00, DateTimeKind.Utc),
                EndTime         = new DateTime(2015, 1, 1, 8, 50, 00, DateTimeKind.Utc),
                Room            = "Modern Languages 201",
                ScheduleWeek    = Schedule.Week.BothWeeks,
                ScheduleType    = Schedule.Type.Normal,
                DayOfWeek       = DayOfWeek.Monday
            });

            await DataStore.ProcessLocalChanges(changes);

            var viewModel = await ViewModelClass.LoadAsync(base.LocalAccountId, base.CurrentClassId, new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc));

            Assert.AreEqual(1, viewModel.Class.Schedules.Count);

            var schedule = viewModel.Class.Schedules[0];


            changes = new DataChanges();

            changes.DeleteItem(schedule.Identifier);

            await DataStore.ProcessLocalChanges(changes);

            viewModel = await ViewModelClass.LoadAsync(base.LocalAccountId, base.CurrentClassId, new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc));

            Assert.AreEqual(0, viewModel.Class.Schedules.Count);
        }
        public MainWindow()
        {
            vm = new ViewModelClass(new MySimApp(new MytelnetClient()));
            this.DataContext = vm;
            InitializeComponent();

            //this.JoystickVM = new VM_Joystick(new MySimApp(new MytelnetClient()));
        }
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            ViewModelClass _vm = (ViewModelClass)DataContext;

            _vm.AddWindow    = new Lazy <IWindow>(() => new AddWindow());
            _vm.UpdateWindow = new Lazy <IWindow>(() => new UpdateWindow());
        }
Esempio n. 10
0
        public ActionResult Kesfet()
        {
            DatabaseContext db             = new DatabaseContext();
            ViewModelClass  viewModelClass = new ViewModelClass();

            viewModelClass.HomeSubCategories = db.Sub_Categories.ToList();
            viewModelClass.HomeCategory      = db.Categories.ToList();
            viewModelClass.HomeExpert        = db.Experts.ToList();
            return(View(viewModelClass));
        }
 public Joystick()
 {
     InitializeComponent();
     sb = Knob.FindResource("CenterKnob") as Storyboard;
     sb.Begin();
     sb.Stop();
     //_vm = ((MainWindow)Application.Current.MainWindow).getVM();
     _vm = (ViewModelClass)this.DataContext;
     //DataContext = _vm;
 }
Esempio n. 12
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            viewModel = (ViewModelClass)DataContext;

            //=====================================================
            //viewModel.ResetValue();
            //=====================================================
            //warSry = (Sky)DataContext;
            mainPlayer.Open(new Uri("C:/Users/Admin/Desktop/FULL/Invasion of Gooks/Resources/Sound/menuSingle.wav", UriKind.Absolute));
            mainPlayer.Play();
        }
Esempio n. 13
0
        private async void button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            NoSearchText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            NoResults.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;

            var searchText = textBox.Text.Replace(' ', '+');

            if (searchText == "")
            {
                NoSearchText.Visibility = Windows.UI.Xaml.Visibility.Visible;
                textBlock1.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
                return;
            }

            WebRequest webRequestHelper = WebRequest.CreateHttp(string.Format("https://www.googleapis.com/youtube/v3/search?part=snippet&q={0}&type=video&key=AIzaSyA8M6liIdtVZCOibC6LC2sW8dmoJwiKEvA", searchText));
            var        results          = await webRequestHelper.GetResponseAsync();

            Stream       dataStream         = results.GetResponseStream();
            StreamReader reader             = new StreamReader(dataStream);
            string       responseFromServer = reader.ReadToEnd();
            JToken       result             = JObject.Parse(responseFromServer);
            var          values             = result["items"];

            if (values != null)
            {
                foreach (var item in values)
                {
                    JObject id         = item["id"] as JObject;
                    var     vId        = id["videoId"].ToString();
                    JObject itemResult = item["snippet"] as JObject;
                    if (itemResult != null)
                    {
                        var vm = new ViewModelClass();
                        vm.Title       = itemResult["title"].ToString();
                        vm.Description = itemResult["description"].ToString();
                        vm.VideoId     = vId;
                        JObject thumbNails = itemResult["thumbnails"] as JObject;
                        JObject image      = thumbNails["medium"] as JObject;
                        vm.Image = image["url"].ToString();
                        ViewModelClassObject.Add(vm);
                    }
                }
            }
            else
            {
                NoResults.Visibility  = Windows.UI.Xaml.Visibility.Visible;
                textBlock1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                return;
            }

            listview.ItemsSource = ViewModelClassObject;
        }
        private void Knob_MouseUp(object sender, MouseButtonEventArgs e)
        {
            sb.Begin();

            knobPosition.X = 0;
            knobPosition.Y = 0;
            Window parentWin = Window.GetWindow(this);

            _vm = ((MainWindow)Application.Current.MainWindow).getVM();
            _vm.FlyPlane(0, 0);
            UIElement element = (UIElement)Knob;

            element.ReleaseMouseCapture();
        }
Esempio n. 15
0
        //int animationIndex = 0;

        //int currenRow = 1;
        //ширина и высота одного кадра
        //double frameW = 299;
        //double frameH = 310;

        public BattleWind()
        {
            InitializeComponent();
            //на паре
            gamePlayer.Open(new Uri("C:/Users/Admin/Desktop/FULL/Invasion of Gooks/Resources/Sound/rideOfTheValkyries.wav", UriKind.Absolute));

            //дома
            //gamePlayer.Open(new Uri("C:/Users/Admin/Desktop/Invasion of Gooks_фреймы/Invasion of Gooks/Resources/Sound/rideOfTheValkyries.wav", UriKind.Absolute));
            gamePlayer.Volume = 0.4;
            gamePlayer.Play();

            //на паре
            gamePlayerPropellers.Open(new Uri("C:/Users/Admin/Desktop/FULL/Invasion of Gooks/Resources/Sound/propeller1.wav", UriKind.Absolute));

            //дома
            //gamePlayerPropellers.Open(new Uri("C:/User/Admin/Desktop/Invasion of Gooks_фреймы/Invasion of Gooks/Resources/Sound/propeller1.wav", UriKind.Absolute));
            gamePlayerPropellers.Volume = 0.3;
            gamePlayerPropellers.Play();

            viewModel = (ViewModelClass)DataContext;
            Resources["ViewModel"] = viewModel;
            //================================================!!!=================
            viewModel.own = this;

            viewModel.warSky.ExplosionEvent += WarSky_ExplosionEvent;

            //полyчение изображения из ресyрсов окна
            ExplosionImage = (BitmapImage)Resources["Explosion.Image"];
            ////подключаем прослyшкy к событию взрыва
            //viewModel.warSky.ExplosionEvent += WarSky_ExplosionEvent;
            //timerExplosions.Interval = TimeSpan.FromMilliseconds((double)Resources["Explosion.Interval"]);
            //timerExplosions.Tick += TimerExplosions_Tick;
            //список кадров, полyчаемый из ресyрсов
            rects = (Rect[])Resources["Explosion.Frames"];
            //создаём массив для отдельных кадров
            //ImageFrames = new ImageSource[rects.Length];
            //for (int i = 0; i < rects.Length; i++)
            //{
            //    ImageFrames[i] = ExplosionImage.Clone()
            //}

            //ExplosionCanvas.Children.Add(image = new Image() { Source = ExplosionImage, Clip = new RectangleGeometry(rects[0]) });
            timerAnimation.Tick    += AnimationTimer_Tick /* new EventHandler()*/;
            timerAnimation.Interval = TimeSpan.FromMilliseconds((double)Resources["Explosion.Interval"]);/* new TimeSpan(0, 0, 0, 0, 800);*/

            timerAnimation.Start();
            //timerExplosions.Start();
            viewModel.KeyUser(KeyControl.Continue);
        }
Esempio n. 16
0
        public void AddViewModel()
        {
            ObservableCollection <ModelClass> model = new ObservableCollection <ModelClass>();
            ViewModelObservableCollection <ViewModelClass, ModelClass> viewModel = new ViewModelObservableCollection <ViewModelClass, ModelClass>(model);

            Assert.AreEqual(model.Count, 0);
            Assert.AreEqual(viewModel.Count, 0);

            var newViewItem = new ViewModelClass(new ModelClass()
            {
                Data = "Set"
            });

            viewModel.Add(newViewItem);


            Assert.AreEqual(model.Count, 1);
            Assert.AreEqual(viewModel.Count, 1);
        }
Esempio n. 17
0
        //public delegate void ProcessRecordHandler(SqlDataReader record);


        /*
         * "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=Music;" +
         * "Integrated Security=True;Connect Timeout=30;Encrypt=False;" +
         * "TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
         */
        /*
         * void DoWork()
         * {
         * }
         */
        public void ProcessRecord(ViewModelClass model)
        {
            string SQLConnectionString =
                "Server = tcp:kiwizen-dsed.database.windows.net,1433;Initial Catalog = DSED; " +
                "Persist Security Info=False;User ID = kiwizen-dsed; Password=Monday99; " +
                "MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout = 30";

            //DataSet dataset = new DataSet();
            using (SqlConnection sqlConnection = new SqlConnection(SQLConnectionString))
            {
                try
                {
                    string SelectAllQuery = "select OwnerID, FirstName, LastName from Owner";

                    sqlConnection.Open();
                    using (SqlCommand command = new SqlCommand(SelectAllQuery, sqlConnection))
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            model.Clear();
                            while (reader.Read())
                            {
                                model.Add(new
                                {
                                    LastName  = reader[DBString.LastNameKey].ToString(),
                                    FirstName = reader[DBString.FirstNameKey].ToString()
                                });
                            }
                        }
                    sqlConnection.Close();
                }
                catch
                {
                    throw new Exception("SQL Database Error Exception.");
                }
                finally
                {
                    if (sqlConnection != null)
                    {
                        sqlConnection.Close();
                    }
                }
            }
        }
Esempio n. 18
0
        public void Tldr()
        {
            var viewModel = new ViewModelClass();
            var view      = new ViewClass();

            /* Create binder */
            var binder = new Binder();

            /* Establish bindings.
             * Store the bindings in this._bindings to make sure it is not garbage collected.
             * This is typically done when the view appears (*not* when it is created!)
             */
            this._bindings = binder.Bind(viewModel, view);

            /* Destroy bindings.
             * Typically when the view disappears.
             */
            this._bindings.Dispose();
            this._bindings = null;
        }
        // GET: Category
        public ActionResult Category(int id)
        {
            ViewModelClass modelClass = new ViewModelClass();
            var            experts    = db.Experts.Where(ex => ex.Sub_Category.topCategoryID == id || ex.abilityID == id).Select(s => new Expert()
            {
                abilityID = s.abilityID, name = s.name
            }).ToList();

            modelClass.HomeExpert = experts;
            var sub_Category = db.Sub_Categories.Where(x => x.topCategoryID == id).Select(s => new Sub_Category()
            {
                topCategoryID = s.topCategoryID, name = s.name
            }).ToList();

            modelClass.HomeSubCategories = sub_Category;
            //ViewData["kategoriler"] = sub_Category;
            //ViewData["expertler"] = experts;

            return(View(modelClass));
        }
Esempio n. 20
0
        private async void GetButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MusicDBServiceClient client = new MusicDBServiceClient();
                ViewModelClass       model  = new ViewModelClass();
                model.AddMethod   = Add;
                model.ClearMethod = Clear;

                await client.ProcessRecordAsync(model);

                //IList<Owner> articleList = await client.QueryOwnerAsync();

                //set the result to UI
                //lvDataTemplates.ItemsSource = articleList;
            }
            catch //(Exception ex)
            {
                //NotifyUser(ex.Message);
            }
        }
Esempio n. 21
0
        public void DynamicRebinding()
        {
            var binder = new Binder();

            /* ViewModelClass, ViewClass, ControlModelClass, ControlClass and TextControlClass all
             * implement interface INotifyPropertyChanged.
             */
            var view = new ViewClass()
            {
                MyControl = new ControlClass {
                    Label = "aaa"
                }
            };
            var viewModel = new ViewModelClass()
            {
                MyControl = new ControlModelClass {
                    Label = "bbb", Text = "ccc"
                }
            };

            this._bindings = binder.Bind(viewModel, view);

            //  viewModel.MyControl.Label is now bound to view.MyControl.Label.
            //  Both will have the value "bbb".
            //  viewModel.MyControl.Text is not bound to anything and will have its original value ("ccc")

            Assert.AreEqual("bbb", ((ControlClass)view.MyControl).Label);
            Assert.AreEqual("ccc", viewModel.MyControl.Text);

            view.MyControl = new TextControlClass {
                Text = "ddd"
            };

            // viewModel.MyControl.Text gets *rebound* to view.MyControl.Text.
            // Both will now have value "ddd".
            // viewModel.MyControl.Label will still have value "bbb".

            Assert.AreEqual("bbb", viewModel.MyControl.Label);
            Assert.AreEqual("ddd", viewModel.MyControl.Text);
        }
        private void Knob_MouseMove(object sender, MouseEventArgs e)
        {
            double slope, absX, absY;

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                double x = e.GetPosition(this).X - knobLocation.X;
                double y = e.GetPosition(this).Y - knobLocation.Y;
                //knobPosition.X = x;
                //knobPosition.Y = y;
                if (Math.Sqrt(x * x + y * y) <= Base.Width / 2)
                {
                    knobPosition.X = x;
                    knobPosition.Y = y;
                }
                else
                {
                    //linear equation to calculate point at radious on same line.
                    slope = y / x;
                    absX  = Math.Sqrt(Math.Pow(Base.Width / 2, 2) / (Math.Pow(slope, 2) + 1));
                    absY  = absX * slope;
                    if (x > 0)
                    {
                        knobPosition.X = absX;
                    }
                    else if (x < 0)
                    {
                        knobPosition.X = -absX;
                    }
                    else
                    {
                        knobPosition.X = 0;
                    }
                    if (y > 0)
                    {
                        if (x > 0)
                        {
                            knobPosition.Y = absY;
                        }
                        else
                        {
                            knobPosition.Y = -absY;
                        }
                    }
                    else if (y < 0)
                    {
                        if (x < 0)
                        {
                            knobPosition.Y = -absY;
                        }
                        else
                        {
                            knobPosition.Y = absY;
                        }
                    }
                    else
                    {
                        knobPosition.Y = 0;
                    }
                }

                Window parentWin = Window.GetWindow(this);
                _vm = ((MainWindow)Application.Current.MainWindow).getVM();
                /// the values to send to simulator, the joystick range is between -1 to 1 when the horizontal to the right take value 1 and most vertical up takes vlaue 1
                _vm.FlyPlane(knobPosition.X / (Base.Width / 2), knobPosition.Y / (Base.Height / -2));
            }
        }
        /// <summary>
        /// Initializes a new instance of the GameComplete window.
        /// </summary>
        /// <param name="message">Message to display in this form.</param>
        public GameComplete(ViewModelClass vm)
        {
            InitializeComponent();

            this.DataContext = vm;          // Set the data context for this window
        }
Esempio n. 24
0
 protected override void OnAppearing()
 {
     BindingContext = new ViewModelClass();
 }
Esempio n. 25
0
 public View()
 {
     InitializeComponent();
     DataContext = new ViewModelClass();
 }
        public static List <ViewModelClass> ReadViewModels(SwaggerObject swaggerObject, string apiNameSpace, string clientNameSpace)
        {
            List <ViewModelClass> viewModelList = new List <ViewModelClass>();

            foreach (var definition in swaggerObject.definitions)
            {
                ViewModelClass viewModelClass = new ViewModelClass();

                viewModelClass.NameOfClass = TranslateNameSpace(definition.Key, apiNameSpace, clientNameSpace);

                foreach (var property in definition.Value.properties)
                {
                    if (!string.IsNullOrEmpty(property.Value.type) &&
                        property.Value.type.Equals("object"))
                    {
                        // INNER VIEW MODEL CLASS DETECTED
                        ViewModelClass innerViewModelClass = new ViewModelClass();

                        string nameOfClassAdjusted = definition.Key + char.ToUpper(property.Key[0]) + property.Key.Substring(1);

                        innerViewModelClass.NameOfClass = TranslateNameSpace(nameOfClassAdjusted, apiNameSpace, clientNameSpace);

                        foreach (var innerProperty in property.Value.properties)
                        {
                            string CSharpType = TranslateCSharpType(innerProperty.Value.type,
                                                                    innerProperty.Value.format,
                                                                    innerProperty.Value._ref,
                                                                    innerProperty.Value.items,
                                                                    apiNameSpace,
                                                                    clientNameSpace);

                            innerViewModelClass.Properties.Add(new ViewModelProperty
                            {
                                Name = innerProperty.Key,
                                Type = CSharpType
                            });
                        }

                        viewModelList.Add(innerViewModelClass);

                        viewModelClass.Properties.Add(new ViewModelProperty
                        {
                            Name = property.Key,
                            Type = innerViewModelClass.NameOfClass
                        });
                    }
                    else
                    {
                        string CSharpType = TranslateCSharpType(property.Value.type,
                                                                property.Value.format,
                                                                property.Value._ref,
                                                                property.Value.items,
                                                                apiNameSpace,
                                                                clientNameSpace);

                        viewModelClass.Properties.Add(new ViewModelProperty
                        {
                            Name = property.Key,
                            Type = CSharpType
                        });
                    }
                }

                viewModelList.Add(viewModelClass);
            }

            return(viewModelList);
        }
 public MainWindow(ViewModelClass viewmodel)
 {
     this.Viewmodel = viewmodel;
     InitializeComponent();
 }
 public Dashboard()
 {
     InitializeComponent();
     vm = (ViewModelClass)this.DataContext;
 }