示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Page"/> class.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="host">The host.</param>
        /// <param name="page">The page.</param>
        public Page(Factory factory, IPageHost host, PagesPage page)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(factory.ToString());
            }

            if (host == null)
            {
                throw new ArgumentException(host.ToString());
            }

            if (page == null)
            {
                throw new ArgumentException(page.ToString());
            }

            this.host                   = host;
            this.pageId                 = page.Id;
            this.nextPageDelegateId     = page.NextPage.delegateId;
            this.nextPageArgument       = page.NextPage.Value;
            this.previousPageDelegateId = page.PreviousPage.delegateId;
            this.previousPageArgument   = page.PreviousPage.Value;
            this.helpGuid               = new Guid(page.HelpPage.Value);

            Type controlType = System.Reflection.Assembly.GetCallingAssembly().GetType(page.Implementation);

            this.pageUI = factory.CreatePage(this, controlType);
        }
示例#2
0
        /// <summary>
        /// Loads and initializes all UI pages.
        /// </summary>
        /// <returns>the newly created IPageHost interface object</returns>
        private static IPageHost LoadUiPages()
        {
            // Creates a page factory, a host page and set up page navigation
            Factory   factory = new WpfFactory();
            IPageHost host    = factory.CreateHost();

            PageNavigation.Instance.Host = host;

            // Add wait screen here if needed.
            XmlSerializer serializer = new XmlSerializer(typeof(Pages));

            using (MemoryStream stream = new MemoryStream())
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write(Properties.Resources.Pages);
                    writer.Flush();
                    stream.Position = 0;
                    Pages inputPages = (Pages)serializer.Deserialize(stream);

                    foreach (PagesPage page in inputPages.Page)
                    {
                        SetupLogger.LogInfo("Adding Page {0}", page.Id);
                        Page workingPage = new Page(factory, host, page);

                        // Add this page to our pages
                        PageRegistry.Instance.RegisterPage(workingPage);
                    }
                }
            }

            PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.ScreensLoaded, "1");
            return(host);
        }
示例#3
0
 public StreamTableModel(LocalDbContext db, WindowPageHost host)
 {
     _db   = db;
     _host = host;
     this.DeleteHandler = ReactiveCommand.Create(DeleteStream);
     this.ShowHandler   = ReactiveCommand.Create(ShowStream);
     Observable.Merge(WhenAdded <StreamEntity>(), WhenRemoved <StreamEntity>(), WhenUpdated <StreamEntity>())
     .ObserveOnDispatcher(DispatcherPriority.Background)
     .Subscribe(_ =>
     {
         this.Streams.Clear();
         this.Streams.AddRange(db.Streams.ToList());
     });
     this.Streams.Clear();
     this.Streams.AddRange(db.Streams.ToList());
 }
示例#4
0
        /// <summary>
        /// Enters the page.
        /// </summary>
        public virtual void EnterPage()
        {
            SetupLogger.LogInfo(String.Format("Enter {0}", this.ToString()));
            //CMP.Setup.SetupLogger.LogInfo(String.Format("Enter {0}", this.ToString()));

            // Need to get to the host page so we can access it's public functions
            IPageHost host = this.page.Host;

            // Set the previous page button to false if there is no previous button
            host.SetPreviousButtonState(true, this.page.PreviousPageArgument != null);
            // Set the next page button to "Finish" if there is no next page
            host.SetNextButtonState(true, true,
                                    this.page.NextPageArgument == null ?
                                    WPFResourceDictionary.FinishButtonText :
                                    // Set to 'Next' when there are other pages to move to.
                                    WPFResourceDictionary.NextButtonText);
            // Reset the cancel button to enabled
            host.SetCancelButtonState(true, true);
        }
示例#5
0
 public DisciplineTableModel(LocalDbContext db, WindowPageHost host)
 {
     _db   = db;
     _host = host;
     this.DeleteMenuButtonConfig = new ButtonConfig {
         Command = ReactiveCommand.Create(DeleteDiscipline)
     };
     this.ShowMenuButtonConfig = new ButtonConfig {
         Command = ReactiveCommand.Create(ShowDiscipline)
     };
     Observable.Merge(WhenAdded <DisciplineEntity>(), WhenRemoved <DisciplineEntity>(), WhenUpdated <DisciplineEntity>())
     .ObserveOnDispatcher(DispatcherPriority.Background)
     .Subscribe(_ =>
     {
         this.Disciplines.Clear();
         this.Disciplines.AddRange(db.Disciplines.ToList());
     });
     this.Disciplines.Clear();
     this.Disciplines.AddRange(db.Disciplines.ToList());
 }
示例#6
0
 public GroupTableModel(LocalDbContext db, WindowPageHost host)
 {
     _db   = db;
     _host = host;
     this.DeleteMenuButtonConfig = new ButtonConfig {
         Command = new CommandHandler(DeleteGroup)
     };
     this.ShowMenuButtonConfig = new ButtonConfig {
         Command = new CommandHandler(ShowGroup)
     };
     Observable.Merge(WhenAdded <GroupEntity>(), WhenRemoved <GroupEntity>(), WhenUpdated <GroupEntity>())
     .ObserveOnDispatcher(DispatcherPriority.Background)
     .Subscribe(_ =>
     {
         this.Groups.Clear();
         this.Groups.AddRange(db.Groups.ToList());
     });
     this.Groups.Clear();
     this.Groups.AddRange(db.Groups.ToList());
 }
示例#7
0
        static void app_Startup(object sender, StartupEventArgs e)
        {
            // Load and initializes all pages
            IPageHost host = LoadUiPages();

            // Jump off the landing page to the correct page track.
            PageNavigation.Instance.MoveToNextPage();

            // In the page track, jump to the correct first page.
            PageNavigation.Instance.MoveToNextPage();

            // Close the splash page.
            if (Program.splashPage != null)
            {
                Program.splashPage.Close();
            }

            // Launch the UI
            host.Closed += new EventHandler(Host_Closed);
            host.Show();
        }
        public StudentLessonViewModel(
            StudentEntity student,
            Dictionary <string, LessonEntity> lessonModels,
            IExportLocatorScope serviceLocator,
            IPageHost host,
            LocalDbContext context
            )
        {
            OpenStudentHandler = ReactiveCommand.Create(OpenStudent);
            OpenImageHandler   = ReactiveCommand.Create(LoadImage);
            this.Model         = student;
            ServiceLocator     = serviceLocator;
            this.FullName      = student.LastName + " " + student.FirstName;
            foreach (var keyValuePair in lessonModels)
            {
                var studentLessonModel =
                    keyValuePair.Value.StudentLessons?.FirstOrDefault(model => model._StudentId == student.Id) ??
                    new StudentLessonEntity {
                    _LessonId    = keyValuePair.Value.Id,
                    Lesson       = keyValuePair.Value,
                    Student      = student,
                    _StudentId   = student.Id,
                    IsRegistered = false,
                    Mark         = ""
                };
                if (studentLessonModel.Id == 0)
                {
                    context.StudentLessons.Add(studentLessonModel);
                    context.ThrottleSave();
                }

                this.LessonToLessonMark.Add(keyValuePair.Key,
                                            new StudentLessonMarkViewModel(studentLessonModel, context, host));
            }

            this.MissedLessons =
                this.LessonToLessonMark.Values.Aggregate(0,
                                                         (i, model) => model.StudentLesson.IsLessonMissed ? i + 1 : i);
        }
        public SchedulePageModel(WindowPageHost windowPageHost, IPageHost currentHost, LocalDbContext context)
        {
            _windowPageHost = windowPageHost;
            _currentHost    = currentHost;
            _context        = context;
            this.OpenRegistrationHandler       = ReactiveCommand.Create(OpenRegistration);
            this.DeleteMenuHandler             = ReactiveCommand.Create(DeleteSelectedLesson);
            this.EditMenuHandler               = ReactiveCommand.Create(OpenLessonEditForm);
            this.OpenStudentLessonTableHandler = ReactiveCommand.Create(OpenStudentLessonTable);
            this.OpenLessonNotesHandler        = ReactiveCommand.Create(OpenLessonNotes);
            this.ToggleLessonCheckedHandler    = ReactiveCommand.Create(ToggleLessonChecked);
            this.Show = ReactiveCommand.Create(ShowLessons);
            this.WhenAnyValue(model => model.SelectedStream)
            .Subscribe
            (
                stream =>
            {
                List <GroupEntity> groups;
                if (stream == null || stream.Id == -1)
                {
                    groups = context.Groups.ToList();
                }
                else
                {
                    groups = stream.Groups?.ToList() ?? new List <GroupEntity>();
                }

                groups.Insert(0, EmptyGroup);
                this.Groups.Clear();
                this.Groups.AddRange(groups);
                if (this.SelectedGroup == null ||
                    this.Groups.FirstOrDefault(model => this.SelectedGroup.Id == model.Id) != null)
                {
                    this.SelectedGroup = EmptyGroup;
                }
            }
            );
            this.RefreshSubject.AsObservable()
            .Subscribe
            (
                async _ =>
            {
                this.Streams.Clear();
                this.Groups.Clear();
                var streamModels = await context.Streams.ToListAsync();
                streamModels.Insert(0, EmptyStream);         // default value
                this.Streams.AddRange(streamModels);
                var schedules = await context.Schedules.ToListAsync();
                schedules.Insert(0, EmptyScheduleComboboxItem);
                schedules.ForEach(this.Schedules.Add);
                (await context.Groups.ToListAsync()).ForEach(this.Groups.Add);
                this.Groups.Insert(0, EmptyGroup);
                this.SelectedGroup      = EmptyGroup;
                this.SelectedLessonType = this.LessonTypes[0];
                this.SelectedSchedule   = EmptyScheduleComboboxItem;
                this.SelectedStream     = EmptyStream;
                ShowLessons();
            }
            );
            Observable.Merge(
                this.WhenAdded <LessonEntity>(),
                this.WhenRemoved <LessonEntity>(),
                this.WhenUpdated <LessonEntity>()
                ).ObserveOnDispatcher(DispatcherPriority.Background)
            .Subscribe(_ => ShowLessons());
        }
示例#10
0
 /// <summary>
 /// Construct a new CRUDViewModel
 /// </summary>
 public CRUDViewModel(IPageHost host) : base(host)
 {
 }
示例#11
0
 public ChipPlayerHandlerShould()
 {
     gameService = Substitute.For <IGameService>();
     pageHost    = Substitute.For <IPageHost>();
     sut         = new ChipPlayedHandler(gameService, pageHost);
 }
 public ChipPlayedHandler(IGameService gameService, IPageHost pageHost)
 {
     this.pageHost    = pageHost;
     this.gameService = gameService;
 }
 public NavigatedHandler(IPageHost pageHost)
 {
     this.pageHost = pageHost;
 }
示例#14
0
 /// <summary>
 /// Constructs a new ViewModel
 /// </summary>
 public ViewModel(IPageHost host) : base()
 {
     PageFramework = new PageFramework(host);
     Log.i("{0}.InitializeProperties()", this.GetType().Name);
     this.InitializeProperties();
 }
示例#15
0
 public void SetPageHost(IPageHost host)
 {
     PageFramework.SetPageHost(host);
 }
示例#16
0
 /// <summary>
 /// Sets the Page Host
 /// </summary>
 /// <param name="host"></param>
 public void SetPageHost(IPageHost host)
 {
     Host = host;
 }
示例#17
0
 /// <summary>
 /// Constructs a new LocalPageFramework
 /// </summary>
 public PageFramework(IPageHost host)
 {
     SetPageHost(host);
     Navigation = new NavigationCommands(this);
 }
 public LessonFormToken(string title, LessonEntity lesson, IPageHost pageHost) :
     base(title)
 {
     this.Lesson = lesson;
     PageHost    = pageHost;
 }