Beispiel #1
0
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            var userPrefs = new UserPreferences();

            userPrefs.WindowHeight = this.Height;
            userPrefs.WindowWidth  = this.Width;
            userPrefs.WindowTop    = this.Top;
            userPrefs.WindowLeft   = this.Left;
            userPrefs.WindowState  = this.WindowState;
            userPrefs.Save();

            _ViewModel.Save();
            _Model.Save();
        }
Beispiel #2
0
        //
        public Image Save(Graphics graphics, int width, int height)
        {
            Image bitmap = new Bitmap(width, height);

            _model.Save(new WindowsFormsGraphicsAdaptor(Graphics.FromImage(bitmap)));
            return(bitmap);
        }
Beispiel #3
0
 private void modifierLutilisateurToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count > 0)
     {
         if (dataGridView1.CurrentRow.Cells[1].ReadOnly == true)
         {
             Utilitaire.activerCellules_All(dataGridView1, dataGridView1.CurrentRow.Index);
         }
         else
         {
             Validate();
             mdl.Save();
             this.Refresh();
         }
     }
 }
Beispiel #4
0
        public void HandleEventNewMember(View.Console view, Model.MemberRegister register)
        {
            view.ShowInputInfo(View.Console.MenuEvent.AddNewMember, null);

            Model.Member m = new Model.Member(register.GetNextMemberId());

            try
            {
                m.Name = view.InputMemberName();
            }
            catch (ArgumentException)
            {
                view.ShowErrorMessage(View.Console.Error.InvalidMemberName, null);
                view.Wait();
                return;
            }
            try { m.PersonalNumber = view.InputMemberPersonalNumber(); }
            catch (ArgumentException)
            {
                view.ShowErrorMessage(View.Console.Error.InvalidPersonalNumber, null);
                view.Wait();
                return;
            }

            register.AddMember(m);
            register.Save();
        }
Beispiel #5
0
        public void ShutDownAsync(object param)
        {
            model.Save();
            model.DownloadQueue.Save();
            connectionController.Exit();
            watchdogController.Stop();
            //Kill local overlord if running
            overlordManagerService.Stop();
            if (null != client)
            {
                client.Stop();
            }

            //Kill UI
            SafeObservableStatic.Dispatcher.Invoke(DispatcherPriority.Normal,
                                                   new Action(
                                                       delegate
            {
                if (null != mainWindowModel)
                {
                    popupController.Close();
                    mainWindowModel.Close();
                    trayIcon.Dispose();

                    model.GetShutdownLock();
                    singleInstanceService.Dispose();
                    System.Windows.Application.Current.Shutdown(0);
                }
            }
                                                       ));
        }
Beispiel #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (statut == 0)
     {
         string numPatient = RandomString(4);
         Tools.executeLMD_Query("INSERT INTO patient(numeroPatient,prenom,nom,age,sexe,adresse,dateNaissance,lieuNaissance,poids,groupeSanguin,tension,profession,taille) VALUES ('" +
                                textBoxnom.Text + numPatient + "','" +
                                textBoxpre.Text + "','" +
                                textBoxnom.Text + "','" +
                                textBoxage.Text + "','" +
                                comboBoxsex.Text + "','" +
                                textBoxadr.Text + "','" +
                                dateTimePickerdn.Value.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
                                textBoxln.Text + "','" +
                                textBoxpoi.Text + "','" +
                                textBoxgs.Text + "','" +
                                textBoxten.Text + "','" +
                                textBoxpro.Text + "','" +
                                textBoxtai.Text + "')");
     }
     else
     {
         Validate();
         model.Save();
     }
     formPatient.Refresh();
     this.Close();
 }
Beispiel #7
0
 protected override void Update(object destObject = null)
 {
     base.Update(Model);
     EventRightsEditViewmodel?.Save();
     TemplatedEditViewmodel?.Save();
     Model.Save();
 }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (appel == 0)
            {
                if (dateTimePicker1.Text != string.Empty && comboBox_medecin.Text != string.Empty && textBox_fait.Text != string.Empty && textBox_traitement.Text != string.Empty)
                {
                    Tools.executeLMD_Query("INSERT INTO prescription(idHospitalisation,idPersonne,fait,traitement,date) VALUES ('" +
                                           idHospitalisation + "','" +
                                           comboBox_medecin.SelectedValue + "','" +
                                           textBox_fait.Text + "','" +
                                           textBox_traitement.Text + "','" +
                                           dateTimePicker1.Value.Date.ToString("yyyy-MM-dd ") + "')");


                    frm.Refresh();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Veillez renseigner tous les champs obligatoire !");
                }
            }

            if (appel == 2)
            {
                Validate();
                mdl.Save();
                frm.Refresh();
                this.Close();
            }
        }
        public void Replace()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.FileName = Model.FileName;
            if (openFileDialog.ShowDialog().Value)
            {
                Model.FileName = Path.GetFileName(openFileDialog.FileName);
                string extension = Path.GetExtension(openFileDialog.FileName).ToLower();

                if (extension == ".png")
                {
                    Model.FileType = FileBlob.FILE_TYPE_PNG;
                }
                else if (extension == ".jpg" || extension == ".jpeg")
                {
                    Model.FileType = FileBlob.FILE_TYPE_JPEG;
                }
                else if (extension == ".dotx")
                {
                    Model.FileType = FileBlob.FILE_TYPE_TEMPLATE;
                }
                else
                {
                    Model.FileType = FileBlob.FILE_TYPE_OTHER;
                }

                Model.Save();
                Model.LoadFile(openFileDialog.FileName);
            }
        }
Beispiel #10
0
 public PersonalityTraitChoice(SubModel model, List <TableEntry> choices, bool other) : base(model, null, 1, null, false, true)
 {
     Other      = other;
     Name       = other ? "2nd Personality Trait" : "Personality Trait";
     Choices    = choices;
     Navigation = model.Navigation;
     OnSelect   = new Command((par) =>
     {
         if (par is string s)
         {
             Model.MakeHistory();
             Trait = s;
             Model.Save();
             Model.FirePlayerChanged();
         }
         if (par is ChoiceOption co)
         {
             Model.MakeHistory();
             if (co.Selected)
             {
                 Trait = null;
             }
             else
             {
                 Trait = co.NameWithSource;
             }
             Model.Save();
             Model.FirePlayerChanged();
         }
     });
     UpdateOptions();
 }
 /// <summary>
 /// Saves the document. If the controller has a model, the default implementation will save the model.
 /// </summary>
 protected virtual async Task OnSave()
 {
     if (Model != null)
     {
         await Model.Save();
     }
 }
Beispiel #12
0
        public void RadonDeg()
        {
            var rn = ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon);
            var cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);

            DateTime Start = new DateTime(2005, 1, 1);
            Lake     L     = new Lake("test", 10);

            L.SetState("Initial", Start, new WaterPacket(0));
            SinkSourceBoundary sb = new SinkSourceBoundary(10.0 / 86400);

            ((WaterPacket)sb.WaterSample).AddChemical(rn, 2.3);
            ((WaterPacket)sb.WaterSample).AddChemical(cl, 2.3);
            L.Sources.Add(sb);
            L.Output.LogAllChemicals = true;
            L.Output.LogComposition  = true;

            Model M = new Model();

            M._waterBodies.Add(L);
            M.Save("temp.xml");

            L.Update(Start.AddDays(1));

            Assert.AreEqual(2.3, L.Output.ChemicalsToLog[cl].GetSiValue(L.CurrentTime), 1e-5);
            Assert.AreNotEqual(2.3, L.Output.ChemicalsToLog[rn].GetSiValue(L.CurrentTime), 1e-5);

            var  M2 = ModelFactory.GetModel("temp.xml");
            Lake L2 = M2._waterBodies.First() as Lake;

            L2.Update(Start.AddDays(1));

            Assert.AreEqual(2.3, L2.Output.ChemicalsToLog[cl].GetSiValue(L2.CurrentTime), 1e-5);
            Assert.AreNotEqual(2.3, L2.Output.ChemicalsToLog[rn].GetSiValue(L2.CurrentTime), 1e-5);
        }
Beispiel #13
0
        public void RunModel()
        {
            Model model = CreateHydroNetModel();

            model.MoveInTime(new DateTime(2005, 6, 1), new TimeSpan(3, 0, 0, 0));
            model.Save(filename + ".xml");
        }
        public void Save()
        {
            settings.UseMemoryLayout            = useMemoryLayout;
            settings.DiscardUnusedSections      = discardUnusedSections;
            settings.NotUseStandardStartupFiles = notUseStandardStartup;
            settings.LinkedLibraries            = linkedLibraries.ToList();
            settings.LinkerScripts       = LinkerScripts.ToList();
            settings.SystemLibraries     = SystemLibraries.ToList();
            settings.InRom1Start         = Convert.ToUInt32(inRom1Start, 16);
            settings.InRom1Size          = Convert.ToUInt32(inRom1Size, 16);
            settings.InRom2Start         = Convert.ToUInt32(inRom2Start, 16);
            settings.InRom2Size          = Convert.ToUInt32(inRom2Size, 16);
            settings.InRam1Start         = Convert.ToUInt32(inRam1Start, 16);
            settings.InRam1Size          = Convert.ToUInt32(inRam1Size, 16);
            settings.InRam2Start         = Convert.ToUInt32(inRam2Start, 16);
            settings.InRam2Size          = Convert.ToUInt32(inRam2Size, 16);
            settings.ScatterFile         = scatterFile;
            settings.MiscLinkerArguments = miscOptions;
            settings.Library             = (LibraryType)librarySelectedIndex;

            var currentSettings = Model.GetToolchainSettings <GccToolchainSettings>();

            currentSettings.LinkSettings = settings;

            Model.SetToolchainSettings(currentSettings);

            Model.Save();
        }
        public void Save()
        {
            settings.Defines             = defines.ToList();
            settings.CustomFlags         = miscOptions;
            settings.CppLanguageStandard = (CppLanguageStandard)cppLanguageStandardSelectedIndex;
            settings.CLanguageStandard   = (CLanguageStandard)clanguageStandardSelectedIndex;
            //base.Model.CompilerSettings.Defines = defines.ToList();
            //var config = project.SelectedConfiguration;

            //config.CppSupport = cppSupport;
            //config.MiscCompilerArguments = miscOptions;
            //config.Defines = defines.ToList();
            settings.Includes         = includePaths.ToList();
            settings.Optimization     = (OptimizationLevel)optimizationLevelSelectedIndex;
            settings.Fpu              = (FPUSupport)fpuSelectedIndex;
            settings.DebugInformation = debugSymbols;
            settings.Exceptions       = exceptions;
            settings.Rtti             = rtti;

            var currentSettings = Model.GetToolchainSettings <GccToolchainSettings>();

            currentSettings.CompileSettings = settings;

            Model.SetToolchainSettings(currentSettings);

            Model.Save();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (appel == 0)
            {
                if (textBox_numCons.Text != string.Empty && textBox_observation.Text != string.Empty && date.Text != string.Empty && comboBox_pathologie.Text != string.Empty && comboBox_patient.Text != string.Empty && comboBox_medecin.Text != string.Empty)
                {
                    // string matricule = GenererMatricule();
                    Tools.executeLMD_Query("INSERT INTO consultation(idPathologie,idPersonne,idPatient,numeroConsultation,date,observationsPrescriptions) VALUES ('" +
                                           comboBox_pathologie.SelectedValue + "','" +
                                           comboBox_medecin.SelectedValue + "','" +
                                           comboBox_patient.SelectedValue + "','" +
                                           textBox_numCons.Text + "','" +
                                           date.Value.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
                                           textBox_observation.Text + "')");



                    frm.Refresh();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Veillez renseigner tous les champs obligatoire !");
                }
            }
            if (appel == 2)
            {
                Validate();
                mdl.Save();
                frm.Refresh();
                this.Close();
            }
        }
        private void Save()
        {
            if (hasLoaded)
            {
                settings.Interface = (JlinkInterfaceType)interfaceSelectedIndex;

                if (selectedDevice != null)
                {
                    settings.DeviceKey    = selectedDevice?.Device;
                    settings.TargetDevice = selectedDevice?.Device.Split(' ')[0].Trim();
                }

                settings.PostDownloadReset = _postDownloadReset;
                settings.Download          = _download;
                settings.Reset             = _reset;
                settings.UseRemote         = _useRemote;
                settings.RemoteIPAddress   = _ipAddress;
                settings.Run = _run;

                if (!string.IsNullOrEmpty(speed))
                {
                    settings.SpeedkHz = Convert.ToInt32(speed);
                }
                else
                {
                    settings.SpeedkHz = 12000;
                }

                Model.SetDebuggerSettings(settings);
                Model.Save();
            }
        }
Beispiel #18
0
 /* ----------------------------------------------------------------- */
 ///
 /// SetCommands
 ///
 /// <summary>
 /// Sets commands of the MainWindow.
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 private void SetCommands()
 {
     Open                        = IsDrop();
     InsertOrMove                = IsDragMove();
     Recent.Open                 = IsLink();
     Ribbon.Open.Command         = Any(() => PostOpen(e => Model.Open(e)));
     Ribbon.Close.Command        = Close();
     Ribbon.Save.Command         = IsOpen(() => Post(() => Model.Overwrite()));
     Ribbon.SaveAs.Command       = IsOpen(() => PostSave(e => Model.Save(e)));
     Ribbon.Preview.Command      = IsItem(() => PostPreview());
     Ribbon.Select.Command       = IsOpen(() => Send(() => Model.Select()));
     Ribbon.SelectAll.Command    = IsOpen(() => Send(() => Model.Select(true)));
     Ribbon.SelectFlip.Command   = IsOpen(() => Send(() => Model.Flip()));
     Ribbon.SelectClear.Command  = IsOpen(() => Send(() => Model.Select(false)));
     Ribbon.Insert.Command       = IsItem(() => PostInsert(e => Model.Insert(e)));
     Ribbon.InsertFront.Command  = IsOpen(() => PostInsert(e => Model.Insert(0, e)));
     Ribbon.InsertBack.Command   = IsOpen(() => PostInsert(e => Model.Insert(int.MaxValue, e)));
     Ribbon.InsertOthers.Command = IsOpen(() => PostInsert());
     Ribbon.Extract.Command      = IsItem(() => PostSave(e => Model.Extract(e)));
     Ribbon.Remove.Command       = IsItem(() => Send(() => Model.Remove()));
     Ribbon.RemoveOthers.Command = IsOpen(() => PostRemove());
     Ribbon.MovePrevious.Command = IsItem(() => Send(() => Model.Move(-1)));
     Ribbon.MoveNext.Command     = IsItem(() => Send(() => Model.Move(1)));
     Ribbon.RotateLeft.Command   = IsItem(() => Send(() => Model.Rotate(-90)));
     Ribbon.RotateRight.Command  = IsItem(() => Send(() => Model.Rotate(90)));
     Ribbon.Metadata.Command     = IsOpen(() => PostMetadata());
     Ribbon.Encryption.Command   = IsOpen(() => PostEncryption());
     Ribbon.Refresh.Command      = IsOpen(() => Send(() => Model.Refresh()));
     Ribbon.Undo.Command         = IsUndo();
     Ribbon.Redo.Command         = IsRedo();
     Ribbon.ZoomIn.Command       = Any(() => Send(() => Model.Zoom(1)));
     Ribbon.ZoomOut.Command      = Any(() => Send(() => Model.Zoom(-1)));
     Ribbon.Settings.Command     = Any(() => PostSettings());
     Ribbon.Exit.Command         = Any(() => Send <CloseMessage>());
 }
Beispiel #19
0
 public IdealChoice(SubModel model, List <TableEntry> choices) : base(model, null, 1, null, false, true)
 {
     Name       = "Ideal";
     Choices    = choices;
     Navigation = model.Navigation;
     OnSelect   = new Command((par) =>
     {
         if (par is string s)
         {
             Model.MakeHistory();
             Model.Context.Player.Ideal = s;
             Model.Save();
             Model.FirePlayerChanged();
         }
         if (par is ChoiceOption co)
         {
             Model.MakeHistory();
             if (co.Selected)
             {
                 Model.Context.Player.Ideal = null;
             }
             else
             {
                 Model.Context.Player.Ideal = co.NameWithSource;
             }
             Model.Save();
             Model.FirePlayerChanged();
         }
     });
     UpdateOptions();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (appel == 0)
            {
                if (textBox_motif.Text != string.Empty && datedebut.Text != string.Empty && comboBox_consultation.Text != string.Empty)
                {
                    // string matricule = GenererMatricule();
                    Tools.executeLMD_Query("INSERT INTO hospitalisation(idConsultation,motif,dateDebut,dateFin,modeSortie) VALUES ('" +
                                           comboBox_consultation.SelectedValue + "','" +
                                           textBox_motif.Text + "','" +
                                           datedebut.Value.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
                                           dateFin.Value.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
                                           textBox_mode.Text + "')");

                    frm.Refresh();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Veillez renseigner tous les champs obligatoire !");
                }
            }
            if (appel == 2)
            {
                Validate();
                mdl.Save();
                frm.Refresh();
                this.Close();
            }
        }
Beispiel #21
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (appel == 0)
            {
                if (comboBox_typesalle.Text != string.Empty && comboBox_service.Text != string.Empty && textBox_capacite.Text != string.Empty && textBox_dispo.Text != string.Empty && textBox_numSalle.Text != string.Empty && textBox_prix.Text != string.Empty)
                {
                    ConnexionDPI.Tools.executeLMD_Query("INSERT INTO salle(idTypeDeSalle,idService,numeroSalle,capacite,disponibilite, prixParJour ) VALUES ('" +
                                                        comboBox_typesalle.SelectedValue + "','" +
                                                        comboBox_service.SelectedValue + "','" +
                                                        textBox_numSalle.Text + "','" +
                                                        textBox_capacite.Text + "','" +
                                                        textBox_dispo.Text + "','" +
                                                        textBox_prix.Text + "')");

                    frm.Refresh();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Veillez renseigner tous les champs obligatoire !");
                }
            }
            if (appel == 2)
            {
                Validate();
                mdl.Save();
                frm.Refresh();
                this.Close();
            }
        }
Beispiel #22
0
 protected override void Update(object destObject = null)
 {
     Model.RecordingInfo = RecordingInfoViewmodel?.GetRecordingInfo();
     base.Update(Model);
     EventRightsEditViewmodel?.Save();
     TemplatedEditViewmodel?.Save();
     Model.Save();
 }
        private void Save()
        {
            settings.InterfaceConfigFile = interfaceConfigFile?.ToAvalonPath();
            settings.TargetConfigFile    = targetConfigFile?.ToAvalonPath();

            OpenOCDDebugAdaptor.SetSettings(Model, settings);
            Model.Save();
        }
Beispiel #24
0
 // Code to execute when the application is closing (eg, user hit Back)
 // This code will not execute when the application is deactivated
 private void Application_Closing(object sender, ClosingEventArgs e)
 {
     if (Model == null)
     {
         Model = new MainModel();
     }
     Model.Save();
 }
Beispiel #25
0
 // Code to execute when the application is deactivated (sent to background)
 // This code will not execute when the application is closing
 private void Application_Deactivated(object sender, DeactivatedEventArgs e)
 {
     if (Model == null)
     {
         Model = new MainModel();
     }
     Model.Save();
 }
Beispiel #26
0
 public void Save()
 {
     if (selectedDebugger != null)
     {
         Model.Debugger2Reference = selectedDebugger.GetType().ToString();
         Model.Save();
     }
 }
Beispiel #27
0
 public void Save()
 {
     foreach (var s in sources)
     {
         s.Save(Root[0]);
     }
     Model.Save();
 }
        private void Save()
        {
            _settings.Toolchain = SelectedPackage?.Title;
            _settings.Version   = SelectedVersion;

            Model.SetToolchainSettings(_settings);
            Model.Save();
        }
        private void Save()
        {
            settings.InterfaceConfigFile = interfaceConfigFile?.ToAvalonPath();
            settings.TargetConfigFile    = targetConfigFile?.ToAvalonPath();

            Model.SetDebuggerSettings(settings);
            Model.Save();
        }
Beispiel #30
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            //Save the model to the database
            //It has already been updated in Page_Load
            Model.Save();

            Response.Redirect("~/Default.aspx");
        }
 public override void Update(object destObject = null)
 {
     foreach (PlayoutServerViewmodel s in PlayoutServers)
     {
         s.Update();
     }
     Model.Save();
     base.Update(destObject);
 }
        public void SynchronizeModel(Model model)
        {
            if (_model == null)
            {
                _model = model;
                _model.Save(_modelPath);
                return;
            }

            var newModelHash = model.GetHashCode();
            var oldModelHash = _model.GetHashCode();

            if (newModelHash == oldModelHash) return;

            model.CopyFrom(_model);
            _model = model;
            _model.Save(_modelPath);
        }
        public OperationResult Register(People person, Model.BusinessEntities.Certificate cert)
        {
            try
            {
                using (Model.EDEntities db = new Model.EDEntities())
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        person.Save(db);
                        cert.Save(db);
                        scope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                return OperationResult.Fail(-1, ex.Message);
            }

            return OperationResult.Success(1, "Person has successfully been registered");
        }
Beispiel #34
0
    public void GroundWaterTest()
    {
      WaterPacket GroundWater = new WaterPacket(1);
//      GroundWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 0.01);
      GroundWater.IDForComposition = 4;

      Lake Vedsted= LakeFactory.GetLake("Vedsted Sø");
      Vedsted.Depth = 5;
      Vedsted.WaterLevel = 45.7;

      //Create and add a discharge boundary
      TimestampSeries Discharge = new TimestampSeries();
      Discharge.AddSiValue(new DateTime(2007, 3, 12), 6986 / TimeSpan.FromDays(365).TotalSeconds);
      Discharge.AddSiValue(new DateTime(2007, 4, 3), 5894 / TimeSpan.FromDays(365).TotalSeconds);
      Discharge.AddSiValue(new DateTime(2007, 4, 25), 1205 / TimeSpan.FromDays(365).TotalSeconds);
      Discharge.RelaxationFactor = 1;
      Discharge.AllowExtrapolation = true;
      Assert.AreEqual(Discharge.GetValue(new DateTime(2007, 4, 25)), Discharge.GetValue(new DateTime(2007, 6, 25)), 0.0000001);
      SinkSourceBoundary Kilde = new SinkSourceBoundary(Discharge);
      Kilde.Name = "Small spring";
      Kilde.ID = 3;
      Kilde.WaterSample.IDForComposition = 3;
      Vedsted.Sources.Add(Kilde);


      Vedsted.Output.LogAllChemicals = true;
      Vedsted.Output.LogComposition = true;

      //Add to an engine
      Model Engine = new Model();
      Engine.Name = "Vedsted-opsætning";
      Engine._waterBodies.Add(Vedsted);

      //Set initial state
      WaterPacket InitialStateWater = new WaterPacket(1);
      InitialStateWater.IDForComposition = 1;
      DateTime Start = new DateTime(2007, 1, 1);
      DateTime End = new DateTime(2007, 12, 31);
      Engine.SetState("Initial", Start, InitialStateWater);
      Engine.SimulationEndTime = End;
      Engine.TimeStep = TimeSpan.FromDays(30);

      Engine.MoveInTime(End, TimeSpan.FromDays(30));
      Vedsted.Name = "Vedsted step 1";
      Engine.Save(testDataPath + Vedsted.Name + ".xml");
      Engine.RestoreState("Initial");

      //Create and add precipitation boundary
      TimespanSeries Precipitation = new TimespanSeries();
      Precipitation.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;
      Precipitation.AllowExtrapolation = true;
      double[] values = new double[] { 108, 83, 73, 52, 61, 86, 99, 101, 75, 108, 85, 101 };
      AddMonthlyValues(Precipitation, 2007, values);
      SinkSourceBoundary Precip = new SinkSourceBoundary(Precipitation);
      Precip.ContactGeometry = Vedsted.SurfaceArea;
      Precip.Name = "Precipitation";
      Precip.ID = 2;
      Precip.WaterSample.IDForComposition = 2;
      Vedsted.Precipitation.Add(Precip);

      //Create and add evaporation boundary
      TimespanSeries Evaporation = new TimespanSeries();
      Evaporation.AllowExtrapolation = true;
      Evaporation.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;
      double[] values2 = new double[] {4,11,34,66,110,118,122,103,61,26,7,1 };
      AddMonthlyValues(Evaporation, 2007, values2);
      EvaporationRateBoundary eva = new EvaporationRateBoundary(Evaporation);
      eva.ContactGeometry = Vedsted.SurfaceArea;
      eva.Name = "Evapo";
      
      Vedsted.EvaporationBoundaries.Add(eva);

      Engine.MoveInTime(End, TimeSpan.FromDays(30));
      Vedsted.Name = "Vedsted step 2";
      Engine.Save(testDataPath + Vedsted.Name + ".xml");
      Engine.RestoreState("Initial");


      //To be used by other tests
      Engine.Save(testDataPath + "VedstedNoGroundwater.xml");

      XYPolygon ContactArea = XYPolygon.GetSquare(Vedsted.Area/10);

      #region Groundwater boundaries
      //Add groundwater boundaries
      GroundWaterBoundary B1 = new GroundWaterBoundary(Vedsted, 1.3e-4, 1, 45.47, ContactArea);
      B1.Name = "B1";
      B1.ID = 4;
      B1.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B1);

      GroundWaterBoundary B2 = new GroundWaterBoundary(Vedsted, 1e-6, 1, 44.96, ContactArea);
      B2.Name = "B2";
      B2.ID = 5;
      B2.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B2);

      GroundWaterBoundary B3 = new GroundWaterBoundary(Vedsted, 2e-6, 1, 44.63, ContactArea);
      B3.Name = "B3";
      B3.ID = 6;
      B3.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B3);

      GroundWaterBoundary B4 = new GroundWaterBoundary(Vedsted, 4.9e-7, 1, 44.75, ContactArea);
      B4.Name = "B4";
      B4.ID = 7;
      B4.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B4);

      GroundWaterBoundary B5 = new GroundWaterBoundary(Vedsted, 1.5e-8, 1, 44.27, ContactArea);
      B5.Name = "B5";
      B5.ID = 8;
      B5.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B5);

      GroundWaterBoundary B6 = new GroundWaterBoundary(Vedsted, 1.5e-8, 1, 44.16, ContactArea);
      B6.Name = "B6";
      B6.ID = 9;
      B6.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B6);

      GroundWaterBoundary B7 = new GroundWaterBoundary(Vedsted, 1.1e-6, 1, 45.15, ContactArea);
      B7.Name = "B7";
      B7.ID = 10;
      B7.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B7);

      GroundWaterBoundary B8 = new GroundWaterBoundary(Vedsted, 1.1e-6, 1, 44.54, ContactArea);
      B8.Name = "B8";
      B8.ID = 11;
      B8.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B8);

      GroundWaterBoundary B9 = new GroundWaterBoundary(Vedsted, 2.1e-8, 1, 45.4, ContactArea);
      B9.Name = "B9";
      B9.ID = 12;
      B9.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B9);

      GroundWaterBoundary B10 = new GroundWaterBoundary(Vedsted, 3.5e-6, 1, 45.16, ContactArea);
      B10.Name = "B10";
      B10.ID = 13;
      B10.WaterSample = GroundWater;
      Vedsted.GroundwaterBoundaries.Add(B10);

      #endregion

      Engine.MoveInTime(End, TimeSpan.FromDays(30));
      Vedsted.Name = "Vedsted step 3";
      Engine.Save(testDataPath + Vedsted.Name + ".xml");
      Engine.RestoreState("Initial");

      Vedsted.GroundwaterBoundaries.Clear();

      var cl =ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction);

      GroundWaterBoundary Inflow = new GroundWaterBoundary(Vedsted, 1e-7,1,46.7,XYPolygon.GetSquare(Vedsted.Area/2));
      Inflow.Name = "Inflow";
      GroundWater.AddChemical(cl, 3);
      Inflow.WaterSample = GroundWater;

      Vedsted.RealData.AddChemicalTimeSeries(cl);
      Vedsted.RealData.ChemicalConcentrations[cl].AddSiValue(new DateTime(2007, 8, 7), 2.5);

      ((WaterPacket)InitialStateWater).AddChemical(cl, 2.5 * InitialStateWater.Volume);
      Engine.SetState("Initial", Start, InitialStateWater);

      GroundWaterBoundary Outflow = new GroundWaterBoundary(Vedsted, 1e-7,1,44.7,XYPolygon.GetSquare(Vedsted.Area/2));
      Outflow.Name = "Outflow";

      Vedsted.GroundwaterBoundaries.Add(Inflow);
      Vedsted.GroundwaterBoundaries.Add(Outflow);

      Engine.MoveInTime(End, TimeSpan.FromDays(30));
      Vedsted.Name = "Vedsted step 4";
      Engine.Save(testDataPath + Vedsted.Name + ".xml");
      Engine.RestoreState("Initial");



      #region ////Add seepage meter boundaries
      //GroundWaterBoundary S1 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46);
      //Vedsted.SinkSources.Add(S1);
      //GroundWaterBoundary S2 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46);
      //Vedsted.SinkSources.Add(S2);
      //GroundWaterBoundary S3 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46);
      //Vedsted.SinkSources.Add(S3);
      //GroundWaterBoundary I1 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46);
      //Vedsted.SinkSources.Add(I1);
      //GroundWaterBoundary I2 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46);
      //Vedsted.SinkSources.Add(I2);
      //GroundWaterBoundary I3 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46);
      //Vedsted.SinkSources.Add(I3);

#endregion


      Assert.AreEqual(Evaporation.EndTime, Engine.MaximumEndTime);
      Engine.Save(testDataPath + "Vedsted.xml");

      Engine.MoveInTime(End, TimeSpan.FromDays(30));

      double outflow2 = Vedsted.Output.Outflow.GetValue(Start, End.Subtract(TimeSpan.FromDays(5)));
      double evapo2 = Vedsted.Output.Evaporation.GetValue(Start, End.Subtract(TimeSpan.FromDays(5)));

      Engine.Save(testDataPath + "Vedsted2.xml");

    }
Beispiel #35
0
 public void HandleEventShowMemberInfoMenu(Model.Member member, View.Console view, Model.MemberRegister register)
 {
     while (true)
     {
         view.ShowMenu(View.Console.MenuEvent.MemberInfoMenu, member);
         switch (view.GetMenuSelection())
         {
             case View.Console.MenuEvent.EditMemberName:
                 view.ShowInputInfo(View.Console.MenuEvent.EditMemberName, member);
                 try
                 {
                     member.Name = view.InputMemberName();
                     register.Save();
                 }
                 catch (ArgumentException)
                 {
                     view.ShowErrorMessage(View.Console.Error.InvalidMemberName, null);
                     view.Wait();
                 }
                 break;
             case View.Console.MenuEvent.EditMemberPersonalNumber:
                 view.ShowInputInfo(View.Console.MenuEvent.EditMemberPersonalNumber, member);
                 try
                 {
                     member.PersonalNumber = view.InputMemberPersonalNumber();
                     register.Save();
                 }
                 catch (ArgumentException)
                 {
                     view.ShowErrorMessage(View.Console.Error.InvalidPersonalNumber, null);
                     view.Wait();
                 }
                 break;
             case View.Console.MenuEvent.ManageBoatsMenu:
                 HandleEventShowManageBoatsMenu(member, view, register);
                 register.Save();
                 break;
             case View.Console.MenuEvent.Back:
                 // exit menu.
                 return;
         }
     }
 }
Beispiel #36
0
        private void HandleEventAddNewBoat(Model.Member member, View.Console view, Model.MemberRegister register)
        {
            view.ShowInputInfo(View.Console.MenuEvent.AddBoat, member);
            Model.Boat boat = new Model.Boat();
            boat.ID = register.GetNextBoatIdFor(member);

            try
            {
                boat.Model = (Model.Boat.BoatModel)view.InputBoatModel();
            }
            catch(ArgumentException)
            {
                view.ShowErrorMessage(View.Console.Error.InvalidBoatModel, null);
                view.Wait();
                return;
            }

            try
            {
                boat.Length = view.InputBoatLenght();
            }
            catch (ArgumentException)
            {
                view.ShowErrorMessage(View.Console.Error.InvalidBoatLenght, null);
                view.Wait();
                return;
            }

            member.AddBoat(boat);
            register.Save();
        }
Beispiel #37
0
 private void HandleEventShowEditBoatMenu(Model.Member member, Model.Boat boat,
     View.Console view, Model.MemberRegister register)
 {
     while (true)
     {
         view.ShowMenu(View.Console.MenuEvent.EditBoatMenu, member);
         switch (view.GetMenuSelection())
         {
             case View.Console.MenuEvent.EditBoatModel:
                 view.ShowInputInfo(View.Console.MenuEvent.EditBoatModel, member);
                 try
                 {
                     boat.Model = (Model.Boat.BoatModel)view.InputBoatModel();
                     register.Save();
                 }
                 catch (ArgumentException)
                 {
                     view.ShowErrorMessage(View.Console.Error.InvalidBoatModel, null);
                     view.Wait();
                     return;
                 }
                 break;
             case View.Console.MenuEvent.EditBoatLength:
                 view.ShowInputInfo(View.Console.MenuEvent.EditBoatLength, member);
                 try
                 {
                     boat.Length = view.InputBoatLenght();
                     register.Save();
                     break;
                 }
                 catch (ArgumentException)
                 {
                     view.ShowErrorMessage(View.Console.Error.InvalidBoatLenght, null);
                     view.Wait();
                     break;
                 }
             case View.Console.MenuEvent.Back:
                 // exit menu
                 return;
         }
     }
 }
Beispiel #38
0
 private void writeSave(Model model, string fileName)
 {
     while (true)
     {
         try
         {
             model.Save(fileName);
             return;
         }
         catch (Exception e)
         {
             if (MessageBox.Show("Unable to save to '"+fileName+"':\n"+e.Message, "Error saving file",
                                 MessageBoxButtons.RetryCancel, MessageBoxIcon.Stop)
                                 != System.Windows.Forms.DialogResult.Retry)
             {
                 return;
             }
         }
     }
 }
Beispiel #39
0
    public void TestMethod1()
    {
      Model M = new Model();
      M.Name = "Cook";

      WaterPacket HyporhericWater = new WaterPacket(1);
      HyporhericWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 0.6 / HyporhericWater.Volume);

      for (int i = 0; i < 10; i++)
      {
        Lake s1 = new Lake("s" + i, XYPolygon.GetSquare(50 * 2));
        s1.Depth = 0.3;
        StagnantExchangeBoundary seb = new StagnantExchangeBoundary(s1.Volume / 20000);
        seb.WaterSample = HyporhericWater.DeepClone(s1.Area * 0.2 * 0.4);
        seb.Output.LogAllChemicals = true;
        s1.Output.LogAllChemicals = true;
        s1.Sinks.Add(seb);
        s1.Sources.Add(seb);
        if (i > 0)
          M._waterBodies[i - 1].AddDownStreamWaterBody(s1);

        M._waterBodies.Add(s1);
      }

      //Bromide injection
      TimespanSeries ts = new TimespanSeries();
      ts.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 18, 12, 0, 0), 0);
      ts.AddSiValue(new DateTime(2005, 10, 18, 12, 0, 0), new DateTime(2005, 10, 18, 12, 40, 0), 0.001 * 60);
      ts.AddSiValue(new DateTime(2005, 10, 18, 12, 40, 0), DateTime.MaxValue, 0);
      SinkSourceBoundary Bromide = new SinkSourceBoundary(ts);
      WaterPacket P = new WaterPacket(1);
      P.AddChemical(new Chemical("Bromide", 1), 1.13);
      Bromide.WaterSample = P;

      //SF6 injection
      TimespanSeries ts2 = new TimespanSeries();
      ts2.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 15, 12, 0, 0), 0);
      ts2.AddSiValue(new DateTime(2005, 10, 15, 12, 0, 0), new DateTime(2005, 10, 19, 12, 0, 0), 1e-6);
      ts2.AddSiValue(new DateTime(2005, 10, 19, 12, 0, 0), DateTime.MaxValue, 0);
      SinkSourceBoundary SF6 = new SinkSourceBoundary(ts2);
      WaterPacket SF6w = new WaterPacket(1);
      SF6w.AddChemical(new Chemical("SF6", 1), 1.13);
      SF6.WaterSample = SF6w;

      M._waterBodies.First().Sources.Add(Bromide);
      M._waterBodies.First().Sources.Add(SF6);
      M._waterBodies.First().Sources.Add(new SinkSourceBoundary(0.2));

      DateTime Start = new DateTime(2005, 10, 13);
      DateTime End = new DateTime(2005, 10, 19);

      M.SetState("Initial", Start, new WaterPacket(1));

      M.MoveInTime(new DateTime(2005, 10, 18, 12, 0, 0), TimeSpan.FromHours(2));
      M.MoveInTime(new DateTime(2005, 10, 18, 13, 0, 0), TimeSpan.FromHours(0.02));
      M.MoveInTime(End, TimeSpan.FromHours(2));
      M.Save(@"..\..\..\TestData\CookEtAl.xml");

      M.RestoreState("Initial");
      TimespanSeries ts3 = new TimespanSeries();
      ts3.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 16, 12, 0, 0), 0);
      ts3.AddSiValue(new DateTime(2005, 10, 16, 12, 0, 0), new DateTime(2005, 10, 17, 0, 0, 0), 0.4);
      ts3.AddSiValue(new DateTime(2005, 10, 17, 0, 0, 0), DateTime.MaxValue, 0);
      M._waterBodies.First().Sources.Add(new SinkSourceBoundary(ts3));
      M.MoveInTime(new DateTime(2005, 10, 18, 12, 0, 0), TimeSpan.FromHours(2));
      M.MoveInTime(new DateTime(2005, 10, 18, 13, 0, 0), TimeSpan.FromHours(0.02));
      M.MoveInTime(End, TimeSpan.FromHours(2));
      M.Save(@"..\..\..\TestData\CookEtAl2.xml");
    }
Beispiel #40
0
        private void ShowMainMenu(View.Console view, Model.MemberRegister register)
        {
            while (true)
            {
                view.ShowMenu(View.Console.MenuEvent.MainMenu, null);
                switch (view.GetMenuSelection())
                {
                    case View.Console.MenuEvent.AddNewMember:
                        HandleEventNewMember(view, register);
                        break;
                    case View.Console.MenuEvent.MemberListMenu:
                        HandleEventShowMemberListMenu(view, register);
                        break;
                    case View.Console.MenuEvent.MemberInfoMenu:
                        view.ShowInputInfo(View.Console.MenuEvent.MemberInfoMenu, null);
                        int id = view.InputMemberID();
                        if (id == 0)
                            break;

                        try
                        {
                            Model.Member m = register.GetMember(id);
                            HandleEventShowMemberInfoMenu(m, view, register);
                        }
                        catch (ArgumentException)
                        {
                            view.ShowErrorMessage(View.Console.Error.NoMemberWithId, id.ToString());
                            view.Wait();
                        }
                        break;
                    case View.Console.MenuEvent.DeleteMember:
                        view.ShowInputInfo(View.Console.MenuEvent.DeleteMember, null);
                        id = view.InputMemberID();
                        if (id == 0)
                            break;

                        try
                        {
                            register.DeleteMember(register.GetMember(id));
                            register.Save();
                        }
                        catch (ArgumentException)
                        {
                            view.ShowErrorMessage(View.Console.Error.NoMemberWithId, id.ToString());
                            view.Wait();
                        }
                        break;
                    case View.Console.MenuEvent.Exit:
                        return;
                }
            }
        }
    public void TestMethod1()
    {
      Lake L = new Lake("Deep lake", XYPolygon.GetSquare(10000));
      L.Depth = 4;
      L.Output.LogAllChemicals = true;

      Lake L2 = new Lake("Shallow lake", XYPolygon.GetSquare(40000));
      L2.Depth = 1;
      L2.Output.LogAllChemicals = true;

      SinkSourceBoundary flow = new SinkSourceBoundary(L.Volume / (15.0 * 86400.0));

      L.Sources.Add(flow);
      L2.Sources.Add(flow);

      Chemical rn = ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon);
      Chemical cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);
      WaterPacket groundwater = new WaterPacket(1);
      groundwater.SetConcentration(rn, 200);
      groundwater.SetConcentration(cl, 200);
      SinkSourceBoundary gwflow = new SinkSourceBoundary(L.Volume / (15.0 * 86400.0));
      gwflow.WaterSample = groundwater;

      L.Sources.Add(gwflow);
      L2.Sources.Add(gwflow);

      Model M = new Model();
      M.WaterBodies.Add(L);
      M.WaterBodies.Add(L2);

      DateTime start = new DateTime(2010,1,1);

      M.SetState("Initial", start, new WaterPacket(1));
      M.MoveInTime(new DateTime(2010, 12, 31), TimeSpan.FromDays(5));
      M.Save(@"..\..\..\TestData\Radon.xml");

    }