Beispiel #1
0
        public EpicsRatingFormA(bool alternate = false)
        {
            List <IPageInterface> pageInterfaces;

            _isAlternate = alternate;
            if (!alternate)
            {
                var p1 = new Page1();
                var p2 = new Page2();
                var p3 = new Page3();
                var p4 = new Page4();
                var p5 = new Page5();
                var p6 = new Page6();
                var p7 = new Page7();

                Pages = new List <Page>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
                pageInterfaces = new List <IPageInterface>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
            }
            else
            {
                var p1 = new Page1();
                var p2 = new Page2();
                var p3 = new Page3Alternate();
                var p4 = new Page4();
                var p5 = new Page5();
                var p6 = new Page6Alternate();
                var p7 = new Page7();

                Pages = new List <Page>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
                pageInterfaces = new List <IPageInterface>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
            }

            logic = EpicsRatingFormLogic.Create(pageInterfaces, this);
            InitializeComponent();
            CurrentPage = 0;
        }
Beispiel #2
0
        private void LoadMenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog loadDialog = new OpenFileDialog();

            loadDialog.Title  = "Load EPIC form";
            loadDialog.Filter = "EPIC forms (*.ef)|*.ef|All Files (*.*)|*.*";

            if (loadDialog.ShowDialog() != true)
            {
                return;
            }

            try
            {
                using (FileStream stream = File.OpenRead(loadDialog.FileName))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    // get the type
                    bool wasAlternate = _isAlternate;
                    _isAlternate = (bool)formatter.Deserialize(stream);

                    ((Page1)Pages[0]).SetViewModel(Page1ViewModel.Load(stream, formatter));
                    ((Page2)Pages[1]).SetViewModel(Page2ViewModel.Load(stream, formatter));
                    if (_isAlternate)      // alternate page
                    {
                        if (!wasAlternate) // change page 3 to alternate
                        {
                            Pages[2] = new Page3Alternate();
                        }

                        ((Page3Alternate)Pages[2]).SetViewModel(Page3ViewModelAlternate.Load(stream, formatter));
                    }
                    else // Normal page now
                    {
                        if (wasAlternate) // change page 3 to the normal page
                        {
                            Pages[2] = new Page3();
                        }

                        ((Page3)Pages[2]).SetViewModel(Page3ViewModel.Load(stream, formatter));
                    }

                    ((Page4)Pages[3]).SetViewModel(Page4ViewModel.Load(stream, formatter));
                    ((Page5)Pages[4]).SetViewModel(Page5ViewModel.Load(stream, formatter));

                    if (_isAlternate)      // alternate page
                    {
                        if (!wasAlternate) // change page 6 to alternate
                        {
                            Pages[5] = new Page6Alternate();
                        }

                        ((Page6Alternate)Pages[5]).SetViewModel(Page6ViewModelAlternate.Load(stream, formatter));
                    }
                    else // Normal page now
                    {
                        if (wasAlternate) // change page 6 to the normal page
                        {
                            Pages[5] = new Page6();
                        }

                        ((Page6)Pages[5]).SetViewModel(Page6ViewModel.Load(stream, formatter));
                    }


                    ((Page7)Pages[6]).SetViewModel(Page7ViewModel.Load(stream, formatter));

                    logic.Pages[0] = ((IPageInterface)Pages[0]).ViewModel;
                    logic.Pages[1] = ((IPageInterface)Pages[1]).ViewModel;
                    logic.Pages[2] = ((IPageInterface)Pages[2]).ViewModel;
                    logic.Pages[3] = ((IPageInterface)Pages[3]).ViewModel;
                    logic.Pages[4] = ((IPageInterface)Pages[4]).ViewModel;
                    logic.Pages[5] = ((IPageInterface)Pages[5]).ViewModel;
                    logic.Pages[6] = ((IPageInterface)Pages[6]).ViewModel;
                }
                CurrentPage = _currentPage;

                MessageBox.Show("Loading complete.");
            }
            catch (Exception exception)
            {
                MessageBox.Show("There was an issue opening the file: " + exception.Message, "ERROR");
            }
        }
Beispiel #3
0
        private void LoadPages(bool regular)
        {
            // check before loading.
            if (MessageBox.Show("Discard any changes?", "", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            _isAlternate = !regular;

            List <IPageInterface> pageInterfaces;

            if (regular)
            {
                var p1 = new Page1();
                var p2 = new Page2();
                var p3 = new Page3();
                var p4 = new Page4();
                var p5 = new Page5();
                var p6 = new Page6();
                var p7 = new Page7();


                Pages = new List <Page>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
                pageInterfaces = new List <IPageInterface>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
            }
            else
            {
                var p1 = new Page1();
                var p2 = new Page2();
                var p3 = new Page3Alternate();
                var p4 = new Page4();
                var p5 = new Page5();
                var p6 = new Page6Alternate();
                var p7 = new Page7();

                Pages = new List <Page>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
                pageInterfaces = new List <IPageInterface>()
                {
                    p1, p2, p3, p4, p5, p6, p7
                };
            }

            if (logic == null)
            {
                logic = EpicsRatingFormLogic.Create(pageInterfaces, this);
            }
            else
            {
                logic.Pages.Clear();
                foreach (var pageInterface in pageInterfaces)
                {
                    logic.Pages.Add(pageInterface.ViewModel);
                }
            }
            CurrentPage = 0;
        }