Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            Console.Write("create Log");
            Logger.SetInitialInstance("ShapLog");

            //DailyIOController dailyIoController = new DailyIOController();

            //IDailyInputFactory dailyInputFactory =
            //  new DailyInputFactory
            //  (dailyIoController);

            UnitsIOController    unitsIoController    = new UnitsIOController();
            UnitsXmlIOController unitsXmlIoController =
                new UnitsXmlIOController(
                    unitsIoController);
            //IndividualUnitIOController individualUnitIoController =
            //  new IndividualUnitIOController();
            FirstExampleManager firstExamples =
                new FirstExampleManager();

            this.DataContext =
                new MainWindowViewModel(
                    unitsIoController,
                    unitsXmlIoController,
                    firstExamples);
        }
Example #2
0
 /// <summary>
 /// Initialises a new instance of the <see cref="IndexItemViewModel"/> class.
 /// </summary>
 /// <param name="unitsIoController">units IO controller</param>
 /// <param name="unitsXmlIoController">units XML IO controller</param>
 /// <param name="individualUnitIoController">individual Unit IO controller</param>
 /// <param name="name">item name</param>
 public IndexItemViewModel(
     UnitsIOController unitsIoController,
     UnitsXmlIOController unitsXmlIoController,
     FirstExampleManager firstExamples,
     string name)
 {
     this.unitsIoController    = unitsIoController;
     this.unitsXmlIoController = unitsXmlIoController;
     this.firstExamples        = firstExamples;
     this.indexName            = name;
     this.inConfigurationMode  = false;
     this.OpenWindowCmd        = new CommonCommand(this.ShowClassWindow);
 }
Example #3
0
        /// ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>ClassFrontPageForm</name>
        /// <date>29/12/12</date>
        /// <summary>
        ///   create a new instance of this class
        /// </summary>
        /// <param name="unitsIoController">units IO controller</param>
        /// <param name="unitsXmlIoController">Units XML IO Controller</param>
        /// <param name="individualUnitIoController">Individual Unit IO Controller</param>
        /// <param name="classId">class id</param>
        /// ---------- ---------- ---------- ---------- ---------- ----------
        public ClassFunctionalViewModel(
            UnitsIOController unitsIoController,
            UnitsXmlIOController unitsXmlIoController,
            FirstExampleManager firstExamples,
            string classId)
            : base(new ObservableCollection <string>())
        {
            this.classId       = classId;
            this.firstExamples = firstExamples;

            this.ClassIndexes = new ObservableCollection <SubClassViewModel>();

            if (!unitsXmlIoController.DoesFileExist(classId))
            {
                Logger.Instance.WriteLog($"ClassFunctionalViewModel: Aborted load: {classId} does not exist");
                this.classData = new ClassDataTypeViewModel(classId);
                return;
            }

            this.RefreshAll =
                new CommonCommand(
                    this.RefreshAllUnits,
                    () => true);

            ClassDetails classFile =
                unitsXmlIoController.Read(
                    classId);

            this.classData =
                new ClassDataTypeViewModel(
                    classFile);

            if (this.classData == null)
            {
                Logger.Instance.WriteLog($"ClassFunctionalViewModel: Aborted load: {classId} does not exist");
                return;
            }

            this.classData.InitaliseSubClassIndex();

            this.SubClasses = this.classData.SubClassNumbers;
            if (this.SubClasses.Count > 0)
            {
                this.SubClassIndex = 0;
            }

            this.PropertyChanged += UpdateProperties;

            this.LoadUnits();
        }
Example #4
0
        //private IndividualUnitIOController individualUnitIoController;

        /// <summary>
        ///   Creates a new instance of the class index form
        /// </summary>
        /// <param name="mainForm">Main form</param>
        /// <param name="unitsIoController">units IO Controller</param>
        public ClassIndexViewModel(
            UnitsIOController unitsIoController,
            UnitsXmlIOController unitsXmlIoController,
            FirstExampleManager firstExamples)
        {
            this.unitsIoController    = unitsIoController;
            this.unitsXmlIoController = unitsXmlIoController;
            //this.individualUnitIoController = individualUnitIoController;
            this.firstExamples = firstExamples;

            this.ItemsGroup          = new ObservableCollection <ClassIndexGroupViewModel>();
            this.inConfigurationMode = false;

            this.AddControls();
        }
Example #5
0
        /// <summary>
        /// Initialises a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        /// <param name="unitsIoController"><
        /// Unit input output controller
        /// /param>
        /// <param name="unitsXmlIoController">
        /// Unit (xml) input output controller
        /// </param>
        /// <param name="firstExamples">
        /// First examples manager
        /// </param>
        public MainWindowViewModel(
            UnitsIOController unitsIoController,
            UnitsXmlIOController unitsXmlIoController,
            FirstExampleManager firstExamples)
        {
            this.unitsIoController            = unitsIoController;
            this.unitsXmlIoController         = unitsXmlIoController;
            this.firstExamples                = firstExamples;
            this.groupsAndClassesIoController = new GroupsAndClassesIOController();

            AddEditJnyDetailsCommand = new CommonCommand(this.ShowAddEditJnyDetailsWindow);
            AnalysisCommand          = new CommonCommand(this.ShowAnalysisWindow);
            ConfigurationCommand     = new CommonCommand(this.ShowConfigurationWindow);
            ExitCommand           = new CommonCommand(this.ExitProgram);
            OpenLogCommand        = new CommonCommand(this.ShowLog);
            OpenLogFolderCommand  = new CommonCommand(this.ShowLogFolder);
            ShowClassIndexCommand = new CommonCommand(this.ShowClassIndexWindow);
            ShowJnyDetailsCommand = new CommonCommand(this.ShowJnyDetailsWindow);
            ShowInputDataCommand  = new CommonCommand(this.ShowInputWindow);

            this.inputWindow = null;
        }
Example #6
0
        /// <summary>
        /// Initialises a new instance of the <see cref="ClassConfigViewModel"/> class.
        /// </summary>
        /// <param name="unitsIoController">units IO controller</param>
        /// <param name="unitsXmlIoController">units XML IO controller</param>
        /// <param name=")">individual units XML IO controller</param>
        /// <param name="classId">class id</param>
        public ClassConfigViewModel(
            UnitsIOController unitsIoController,
            UnitsXmlIOController unitsXmlIoController,
            string classId)
        {
            this.unitsIoController    = unitsIoController;
            this.unitsXmlIoController = unitsXmlIoController;

            this.unsavedChanges = false;

            this.SubClassNumbers = new ObservableCollection <string>();
            this.NumbersList     = new ObservableCollection <int>();
            this.Images          = new ObservableCollection <IClassConfigImageSelectorViewModel>();

            this.classId = classId;

            // If the file doesn't exist then leave m_classData, as initialised.
            if (this.unitsXmlIoController.DoesFileExist(this.classId))
            {
                this.classFileConfiguration =
                    this.unitsXmlIoController.Read(
                        this.classId);

                this.formation       = this.classFileConfiguration.Formation;
                this.alphaIdentifier = this.classFileConfiguration.AlphaId;
                this.year            = this.classFileConfiguration.Year;

                foreach (Subclass subclass in this.classFileConfiguration.Subclasses)
                {
                    this.SubClassNumbers.Add(subclass.Type);
                }

                if (this.SubClassNumbers.Count > 0)
                {
                    this.subClassListIndex = 0;

                    foreach (Number number in this.classFileConfiguration.Subclasses[this.SubClassListIndex].Numbers)
                    {
                        this.NumbersList.Add(number.CurrentNumber);
                    }

                    for (int imageIndex = 0; imageIndex < MaxImages; ++imageIndex)
                    {
                        string imageName =
                            imageIndex < this.classFileConfiguration.Subclasses[this.SubClassListIndex].Images.Count
                            ? this.classFileConfiguration.Subclasses[this.SubClassListIndex].Images[imageIndex].Name
                            : string.Empty;

                        IClassConfigImageSelectorViewModel selector =
                            new ClassConfigImageSelectorViewModel(
                                this.unitsIoController,
                                imageName);
                        selector.SelectionMadeEvent += this.UpdateImagesInModel;
                        this.Images.Add(selector);
                    }
                }
                else
                {
                    this.subClassListIndex = -1;

                    for (int imageIndex = 0; imageIndex < MaxImages; ++imageIndex)
                    {
                        IClassConfigImageSelectorViewModel selector =
                            new ClassConfigImageSelectorViewModel(
                                this.unitsIoController,
                                string.Empty);
                        selector.SelectionMadeEvent += this.UpdateImagesInModel;
                        this.Images.Add(selector);
                    }
                }
            }
            else
            {
                this.classFileConfiguration = new ClassDetails();
            }

            this.CanSave = false;

            this.SaveCmd               = new CommonCommand(this.SaveModel, () => true);
            this.CloseCmd              = new CommonCommand(this.CloseWindow);
            this.AddNewSubClassCmd     = new CommonCommand(this.AddNewSubClass, this.CanPerformAction);
            this.AddNewNumberCmd       = new CommonCommand(this.AddNewNumber, this.CanPerformAction);
            this.AddNewNumberSeriesCmd = new CommonCommand(this.AddNewNumberSeries, this.CanPerformAction);
            this.RenumberCmd           = new CommonCommand(this.Renumber, this.CanPerformAction);
        }