예제 #1
0
 /// <summary>
 /// Reset the model.
 /// </summary>
 public void Reset()
 {
     this.observations = new RawObservations();
     this.Filename     = string.Empty;
     this.Year         = string.Empty;
     this.lockName     = false;
 }
예제 #2
0
파일: EventEntry.cs 프로젝트: abs508/asland
        /// <summary>
        /// Load a model to edit.
        /// </summary>
        /// <param name="path">path of the file to load</param>
        public void Load(string path)
        {
            this.Observations.Reset();

            try
            {
                string filename = Path.GetFileName(path);
                string year     = Path.GetFileName(Path.GetDirectoryName(path));

                RawObservations observations =
                    XmlFileIo.ReadXml <RawObservations>(
                        path);

                this.Observations.LoadObservations(
                    observations,
                    filename,
                    year);
            }
            catch (Exception ex)
            {
                string           errorDescription = $"Error loading {this.Observations.Filename}";
                AppStatusMessage message          =
                    new AppStatusMessage(
                        errorDescription);
                Messenger.Default.Send(message);

                this.logger.WriteLine(
                    $"Event Entry Save : {errorDescription}: {ex}");
            }
        }
예제 #3
0
        /// <summary>
        /// Load a new set of observations from a file.
        /// </summary>
        /// <param name="newData">new observation data</param>
        /// <param name="filename">name of the file which has been loaded</param>
        /// <param name="year">year of the file which has been loaded</param>
        public void LoadObservations(
            RawObservations newData,
            string filename,
            string year)
        {
            this.observations = newData;
            this.Filename     = filename;
            this.Year         = year;
            this.lockName     = true;

            this.Loaded?.Invoke();
        }
예제 #4
0
        /// <summary>
        /// Select a new page for the view.
        /// </summary>
        /// <param name="newPageName">
        /// Name of the page to display.
        /// </param>
        private void NewPage(string newPageName)
        {
            this.SetMonth(newPageName);

            List <string> eventPaths = this.FindEventPaths();

            this.Events.Clear();

            foreach (string eventPath in eventPaths)
            {
                try
                {
                    RawObservations observations =
                        XmlFileIo.ReadXml <RawObservations>(
                            eventPath);

                    ICalendarItem calendarItem =
                        new CalendarItem(
                            observations.Date.Substring(0, 2),
                            observations.Location,
                            observations.Intensity,
                            eventPath,
                            this.openEventCommand);

                    this.Events.Add(calendarItem);
                }
                catch (Exception ex)
                {
                    string           errorDescription = $"Error loading {eventPath}";
                    AppStatusMessage message          =
                        new AppStatusMessage(
                            errorDescription);
                    Messenger.Default.Send(message);

                    this.logger.WriteLine(
                        $"Calendar view model : {errorDescription}: {ex}");
                }
            }

            this.RaisePropertyChangedEvent(nameof(this.Events));
        }
예제 #5
0
        /// <summary>
        /// Open the event specified by the path.
        /// </summary>
        /// <param name="path">
        /// The path to the raw data for the event to be opened.
        /// </param>
        public void OpenEvent(string path)
        {
            RawObservations observations =
                XmlFileIo.ReadXml <RawObservations>(
                    path);

            if (observations == null)
            {
                return;
            }

            this.Location  = observations.Location;
            this.Date      = observations.Date;
            this.Notes     = observations.Notes;
            this.Length    = observations.Length.ToString();
            this.Intensity = observations.Intensity;
            this.TimeOfDay = observations.TimeOfDay.ToString();
            this.Weather   = observations.Weather.ToString();

            this.Habitats.Clear();

            foreach (ObservationHabitat habitat in observations.Habitats.Habitats)
            {
                this.Habitats.Add(habitat.ToString());
            }

            this.Beasties.Clear();

            foreach (string beastie in observations.Species.Kind)
            {
                Beastie modelBeastie = this.getBeastie(beastie);

                IBeastieReportIconViewModel beastieIcon =
                    new BeastieReportIconViewModel(
                        modelBeastie.DisplayName,
                        modelBeastie?.LatinName ?? string.Empty,
                        modelBeastie?.Image ?? string.Empty,
                        modelBeastie?.Presence ?? (Presence)(-1));

                this.Beasties.Add(beastieIcon);
            }

            foreach (string beastie in observations.Heard.Kind)
            {
                Beastie modelBeastie = this.getBeastie(beastie);

                IBeastieReportIconViewModel beastieIcon =
                    new BeastieReportIconViewModel(
                        modelBeastie.DisplayName,
                        modelBeastie?.LatinName ?? string.Empty,
                        modelBeastie?.Image ?? string.Empty,
                        modelBeastie?.Presence ?? (Presence)(-1));

                this.Beasties.Add(beastieIcon);
            }

            this.RaisePropertyChangedEvent(nameof(this.Location));
            this.RaisePropertyChangedEvent(nameof(this.Date));
            this.RaisePropertyChangedEvent(nameof(this.Notes));
            this.RaisePropertyChangedEvent(nameof(this.Length));
            this.RaisePropertyChangedEvent(nameof(this.Intensity));
            this.RaisePropertyChangedEvent(nameof(this.TimeOfDay));
            this.RaisePropertyChangedEvent(nameof(this.Weather));
            this.RaisePropertyChangedEvent(nameof(this.Habitats));
            this.RaisePropertyChangedEvent(nameof(this.Beasties));
        }