public LogWindow(AppFitbitUltraSecurity window, View.VLogger logger, string friendlyName, params string[] args)
        {
            InitializeComponent();
            Title = string.Format("Log Window: {0}\n", friendlyName);

            console.Text = consoleMessages.AddMessage("initialized application");
        }
        public ClientSideQuerying()
        {
            InitializeComponent();

            // Define and bind a live view of expensive non-discontinued products ordered by price.
            _viewProducts =
                (from p in _scope.GetItems<Product>()
                 where !p.Discontinued && p.UnitPrice >= 30
                 orderby p.UnitPrice
                 select new
                 {
                     ProductID = p.ProductID,
                     ProductName = p.ProductName,
                     CategoryID = p.CategoryID,
                     CategoryName = p.Category.CategoryName,
                     SupplierID = p.SupplierID,
                     Supplier = p.Supplier.CompanyName,
                     UnitPrice = p.UnitPrice,
                     QuantityPerUnit = p.QuantityPerUnit,
                     UnitsInStock = p.UnitsInStock,
                     UnitsOnOrder = p.UnitsOnOrder
                 }).AsDynamic(); // AsDynamic() is required for data binding because an anonymous class is used (select new...)

            dataGrid1.ItemsSource = _viewProducts;

            // Define a view of seafood products. Filtering is performed on the server.
            _seafoodProductsView = _scope.GetItems<Product>().AsFiltered(p => p.CategoryID == 8);

            // Bind the label text to the number of products in the view
            textBlockCount.SetBinding(TextBlock.TextProperty, new Binding("Value") { Source = _viewProducts.LiveCount() });
        }
        public DummyWindow(AppFitbitUltraStats dummyApp, View.VLogger logger, string friendlyName, params string[] args)
        {
            InitializeComponent();
            Title = string.Format("Dummy HomeOS application: {0}\n", friendlyName);

            console.Text = consoleMessages.AddMessage("initialized application");
        }
 /// <summary>
 /// Requests a change of view.
 /// </summary>
 /// <param name="view">
 /// The requested view.
 /// </param>
 /// <param name="data">
 /// Optional data for the requested view.
 /// </param>
 protected void RequestViewChange(View view, object data = null)
 {
     if (ViewChangeRequest != null)
     {
         var args = new ViewChangeRequestArgs(view, data);
         ViewChangeRequest(this, args);
     }
 }
        public GradesController(Model model, View view)
        {
            this.model = (GradesModel) model;
            this.view = (GradesView) view;

            coursesModel = (CoursesModel) ModelFactory.NewModelInstance(ModelType.Courses);
            courseRubricsModel = (CourseRubricsModel) ModelFactory.NewModelInstance(ModelType.CourseRubrics);

            coursesList = new List<CourseObject>();
            rubricsList = new List<CourseRubricObject>();
            gradesListDictionary = new Dictionary<string, List<GradeObject>>();

            this.view.comboBoxCourse.SelectionChanged += ActionComboChange;

            FetchAllData();
        }
 public bCheckV2.Helpers.Definitions.TaskItem FormatTaskItem(TaskItem task, View typeOfView)
 {
     bCheckV2.Helpers.Definitions.TaskItem t = new bCheckV2.Helpers.Definitions.TaskItem();
     t.ChecklistID = task.ChecklistID;
     t.ChecklistTaskID = task.ChecklistTaskID;
     t.OpsChecklistTaskID = task.OpsChecklistTaskID;
     t.AlertTime = task.AlertTime.ToString();
     t.Description = task.TaskDescription;
     t.StatusID = ViewModel.Current.StaticData["AssigneeStatus"].ToList().Where(status => status.Value == task.Status).First().Key;
     t.ManagementSignOffStatusID = ViewModel.Current.StaticData["ManagementStatus"].ToList().Where(status => status.Value == task.ManagementSignOff).First().Key;
     t.TaskName = task.TaskName == null ? "DummyTask" : task.TaskName;
     t.DueTime = task.DueTime.ToString();
     t.LocationID = ViewModel.Current.locations.Where(loc => task.Locations == loc.Location).First().Id;
     t.Comments = task.Comments;
     t.LinkToProcess = task.LinkToProcess;
     t.UniqueID = Guid.Parse(task.ID1);
     //t.AssignedTo = typeOfView == View.vwAssignedTasks ? GetFormattedUsers(task.Assignees) : GetFormattedUsers(task.Managers);
     t.CreatedDateLocal = new DateTime(task.CreatedLocal.Ticks,DateTimeKind.Utc);
     return t;
 }
			public WrapperControl(View view)
			{
				_view = view;
				_view.MeasureInvalidated += (sender, args) => InvalidateMeasure();

				IVisualElementRenderer visualElementRenderer = Platform.CreateRenderer(view);
				Platform.SetRenderer(view, visualElementRenderer);
				Content = visualElementRenderer.ContainerElement;

				// make sure we re-measure once the template is applied
				var frameworkElement = visualElementRenderer.ContainerElement as FrameworkElement;
				if (frameworkElement != null)
				{
					frameworkElement.Loaded += (sender, args) =>
					{
						((IVisualElementController)_view).InvalidateMeasure(InvalidationTrigger.MeasureChanged);
						InvalidateMeasure();
					};
				}
			}
        public ClassesController(Model model, View view)
        {
            this.model = (ClassesInSchoolsModel) model;
            this.view = (ClassesView) view;

            classesModel = (ClassesModel) ModelFactory.NewModelInstance(ModelType.Classes);
            usersModel = (UsersModel) ModelFactory.NewModelInstance(ModelType.Users);

            classesList = new List<ClassObject>();
            schoolClassesList = new List<ClassInSchoolObject>();
            teachersList = new List<UserObject>();

            this.view.CurrentListView.SelectionMode = System.Windows.Controls.SelectionMode.Single;
            this.view.buttonAdd.Click += ActionShowDialog;
            this.view.buttonDelete.Click += ActionDelete;
            this.view.buttonDelete.IsEnabled = false;

            LoadClassNames();
            LoadData();
        }
        public UsersController(Model model, View view)
        {
            this.model = (UsersModel) model;
            this.view = (UsersView) view;

            classesList = new List<ClassObject>();
            schoolClassesList = new List<ClassInSchoolObject>();
            usersList = new List<object>();

            classesModel = (ClassesModel) ModelFactory.NewModelInstance(ModelType.Classes);
            schoolClassesModel = (ClassesInSchoolsModel) ModelFactory.NewModelInstance(ModelType.ClassesInSchools);

            this.view.buttonDelete.Click += ActionDelete;
            this.view.buttonAdd.Click += ActionShowDialog;

            schoolClassesModel = (ClassesInSchoolsModel) ModelFactory.NewModelInstance(ModelType.ClassesInSchools);

            LoadClasses();
            GetData();
        }
        public StudentGradingController(Model model, View view)
        {
            this.model = (GradesModel) model;
            this.view = (StudentGradingView) view;

            coursesModel = (CoursesModel) ModelFactory.NewModelInstance(ModelType.Courses);
            courseRubricsModel = (CourseRubricsModel) ModelFactory.NewModelInstance(ModelType.CourseRubrics);
            usersModel = (UsersModel) ModelFactory.NewModelInstance(ModelType.Users);

            coursesList = new List<CourseObject>();
            rubricsList = new List<CourseRubricObject>();
            studentsList = new List<UserObject>();

            gradesListDictionary = new Dictionary<string, List<GradeObject>>();

            this.view.comboBoxCourse.SelectionChanged += ActionComboChange;
            this.view.comboBoxStudent.SelectionChanged += ActionComboChange;
            this.view.buttonAddGrade.Click += ActionShowDialog;

            FetchAllData();
        }
 protected override void UnloadModel(View model)
 {
     ((Entry)model).TextChanged -= EntryModel_TextChanged;
     base.UnloadModel(model);
 }
 private string ConstructUrlParams(IIsAction action, View? view, int numRows)
 {
     string msg = "";
     const string toolname = "BCHECK";
     string baseUrl = ViewModel.ListAsmxUrl;
     switch (action)
     {
         case IIsAction.ALERTS:
             {
                 msg = string.Format("{0}?TOOLNAME={1}&ACTION={2}", baseUrl, toolname, action.ToString());
             }
             break;
         case IIsAction.QUERY:
             {
                 if (view == null) throw new ArgumentException("The parameter view cannot be NULL when action=QUERY", "view");
                 msg = string.Format("{0}?TOOLNAME={1}&ACTION={2}&VIEW={3}", baseUrl, toolname, action.ToString(), view.ToString());
             }
             break;
     }
     return msg;
 }
 private void SetView(View view)
 {
     switch (view)
     {
         case View.MapView:
             _model.SetRibbonTabSelectedState(RibbonTabState.Map);
             CurrentUserControl = _mapView;
             break;
         case View.ArcGisPortalWebMapItemsView:
             _model.SetRibbonTabSelectedState(RibbonTabState.Config);
             CurrentUserControl = _arcGisPortalWebMapItemsView;
             break;
         case View.CreateOfflineMapView:
             _model.SetRibbonTabSelectedState(RibbonTabState.Config);
             CurrentUserControl = _createOfflineMapView;
             break;
         case View.LogInDialogView:
             CurrentUserControl = _logInDialogView;
             break;
         case View.OfflineMapItemsView:
             _model.SetRibbonTabSelectedState(RibbonTabState.Config);
             CurrentUserControl = _offlineMapItemsView;
             break;
         case View.StartScreenView:
             _model.SetRibbonTabSelectedState(RibbonTabState.Config);
             CurrentUserControl = _startScreenView;
             break;
     }
 }
        private void InitializeModelEvents()
        {
            _model.OAuth2TokenTokenReceived += p =>
            {
                if (p == null)
                {
                    IsUserLoggedIn = false;
                    IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
                    IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
                    return;
                }
                IsUserLoggedIn = true;
                IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
                IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
                UpdateIdentityManager(p);
                _model.DoResetArcGisPortalItemsView();
                _model.SetUserNameInfo(p.UserName);
                _model.SetMessageInfo(UserNameInfo + DEFAULT_LOGGED_IN_INFO);
            };

            _model.ChangeMessageInfo += p =>
            {
                if (p != string.Empty)
                {
                    Messages.Insert(0, p);
                }

                MessageInfo = p;
            };

            _model.ChangeUserNameInfo += p => { UserNameInfo = p; };

            _model.ChangeMapNameInfo += p => { LoadedMapNameInfo = p; };

            _model.ChangeMapTypeInfo += p =>
            {
                _loadedMapType = p;

                switch (p)
                {
                    case LoadedMapType.Online:
                        LoadedMapTypeInfo = "[online map]";
                        break;
                    case LoadedMapType.Offline:
                        LoadedMapTypeInfo = "[offline map]";
                        break;
                    case LoadedMapType.None:
                        LoadedMapTypeInfo = string.Empty;
                        break;
                }
            };

            _model.ChangeView += (newView, sourceView, changeBackToSource) =>
            {
                if (_changeBackToPredecessorView)
                {
                    SetView(_predecessorView);
                    _predecessorView = View.MainView;
                    _changeBackToPredecessorView = false;
                    return;
                }

                _predecessorView = sourceView;
                _changeBackToPredecessorView = changeBackToSource;
                SetView(newView);
            };

            _model.ChangeRibbonTabSelectedState += p =>
            {
                switch (p)
                {
                    case RibbonTabState.Config:
                        RibbonTabSelectedIndex = 0;
                        break;
                    case RibbonTabState.Map:
                        RibbonTabSelectedIndex = 1;
                        break;
                }
            };

            _model.NetworkStatusAvailabilityChanged += p =>
            {
                IsNetworkAvailable = p;
                IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
                IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
            };

            _model.SyncStateChanged += () => { IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible; };
        }
        /// <summary>
        /// Shows list of songs after user press grid tile
        /// </summary>
        /// <param name="index">The selected tile</param>
        private void ShowSongList(int index)
        {
            // remove tiles
            tileGridStack.Children.Clear();

            // set up datagrid
            songList = new DataGrid();

            songList.Style = FindResource("songListStyle") as Style;
            songList.RowStyle = (Style)Resources["songListRow"];

            songList.ContextMenu = CreateContextMenu();
            // must be a cleaner way of doing this
            DataGridTextColumn songName = new DataGridTextColumn();
            songName.Header = "Title";
            songName.Binding = new Binding("SongName");
            songName.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
            songList.Columns.Add(songName);

            DataGridTextColumn artistName = new DataGridTextColumn();
            artistName.Header = "Artist";
            artistName.Binding = new Binding("Artist");
            artistName.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
            songList.Columns.Add(artistName);

            DataGridTextColumn albumName = new DataGridTextColumn();
            albumName.Header = "Album";
            albumName.Binding = new Binding("Album.AlbumName");
            albumName.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
            songList.Columns.Add(albumName);

            DataGridTextColumn songGenre = new DataGridTextColumn();
            songGenre.Header = "Genre";
            songGenre.Binding = new Binding("Genre");
            songGenre.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
            songList.Columns.Add(songGenre);

            if (currentSelectedButton == albumButton)
            {
                Album a = musicLibrary.GetSortedAlbumTitles()[index];
                songList.ItemsSource = a.Songs;
            }
            else
            {
                // get list of all songs by artist
                List<Song> artistSongs = new List<Song>();
                string selectedArtist = musicLibrary.GetSortedArtistTitles()[index];

                foreach(Album a in musicLibrary.AlbumList)
                {
                    if (a.Artist == selectedArtist)
                    {
                        foreach (Song s in a.Songs)
                            artistSongs.Add(s);
                    }
                }
                // sorts it by album name and track number
                var sortedList = artistSongs.OrderBy(i => i.Album.AlbumName).ThenBy(i => i.TrackNum);
                songList.ItemsSource = sortedList;

            }

            tileGridStack.Children.Add(songList);

            songList.Margin = new Thickness(0, 0, 30, 0);

            // show back button
            backButton.Visibility = Visibility.Visible;

            currentView = View.SongList;
        }
        /// <summary>
        /// Show the grid - ugly as shit code
        /// </summary>
        private void ShowGrid()
        {
            tileGridStack.Children.Clear();

            backButton.Visibility = Visibility.Hidden;
            // set up grid
            List<Tile> tileList = new List<Tile>();
            List<Album> sortedAlbumTitles = null;
            List<string> sortedArtistTitles = null;

            if (currentSelectedButton == albumButton)
            {
                for (int i = 0; i < musicLibrary.GetSortedAlbumTitles().Count; i++)
                {
                    tileList.Add(new Tile());
                }

                // sort list of albums alphabetically
                sortedAlbumTitles = musicLibrary.GetSortedAlbumTitles();
            }
            else
            {
                for (int i = 0; i < musicLibrary.ArtistList.Count; i++)
                {
                    tileList.Add(new Tile());
                }
                sortedArtistTitles = musicLibrary.GetSortedArtistTitles();
            }

            for (int i = 0; i < tileList.Count; i++)
            {
                Tile t = tileList[i];
                t.Name = "t" + i;
                t.Click += gridTile_click;
                t.Style = FindResource("gridTileStyle") as Style;

                tileGridStack.Children.Add(t);

                if (currentSelectedButton == albumButton)
                {
                    if(sortedAlbumTitles[i].GetAlbumArt() != null)
                    {
                        // place album art on tile
                        Image image = new Image();
                        image.Source = sortedAlbumTitles[i].GetAlbumArt();

                        t.Content = image;
                    }
                    else
                    {
                        // if album doesn't have art use the album name as tile content
                        t.Content = new TextBlock()
                        {
                            Text = sortedAlbumTitles[i].AlbumName,
                            Width = t.Width,
                            TextAlignment = TextAlignment.Center,
                            TextWrapping = TextWrapping.Wrap
                        };
                    }
                }
                else
                {
                    // for artist list
                    t.Content = new TextBlock()
                    {
                        Text = sortedArtistTitles[i],
                        Width = t.Width,
                        TextAlignment = TextAlignment.Center,
                        TextWrapping = TextWrapping.Wrap
                    };
                }

            }

            currentView = View.Grid;
        }