private void generate_Execute(object obj) { IsEditorVisible = true; Message = String.Empty; var distribution = Owner.SelectedDistribution; var generate = distribution.Instance as ISampleableDistribution <double>; try { double[] values = generate.Generate(samples: NumberOfSamplesToBeGenerated); Values.Clear(); foreach (var d in values) { Values.Add(new SampleViewModel() { Value = d }); } } catch { Message = "Sample generation failed. Please check the chosen distribution parameters."; return; } EstimateCommand.Execute(null); if (Message != String.Empty) { Message = "Samples have been generated, but the distribution's measures could not be updated: " + Message; } }
private void data_ListChanged(object sender, ListChangedEventArgs e) { IsModified = true; if (IsUpdatedOnEdit && EstimateCommand.CanExecute(this)) { EstimateCommand.Execute(this); } }
public static void Main(string[] args) { //DateTime now = DateTime.Now; args = @"simulate -b 5 -n 1 -t rel -i ..\..\..\etc\$$year$$-runs.txt -j ..\..\..\etc\$$year$$-judgments.txt -e mout -p meta=..\..\..\etc\metadata.txt".Replace("$$year$$", args[0]).Split(); if (args.Length > 0) { // Check CLI command name string commandName = args[0].ToLower(); AbstractCommand command = null; switch (commandName) { case "-h": Allcea.PrintMainUsage(null); Environment.Exit(0); break; case "estimate": command = new EstimateCommand(); break; case "evaluate": command = new EvaluateCommand(); break; case "next": command = new NextCommand(); break; case "simulate": command = new SimulateCommand(); break; case "features": command = new FeaturesCommand(); break; default: Console.Error.WriteLine("'" + commandName + "' is not a valid Allcea command. See '" + Allcea.CLI_NAME_AND_VERSION + " -h'."); Environment.Exit(1); break; } // Parse CLI options Options options = command.Options; // help? Cannot wait to parse CLI options because it will throw exception before if (options.HasOption("h") && args.Contains("-h")) { Allcea.PrintUsage(null, commandName, options, command.OptionsFooter); } else { try { Parser parser = new BasicParser(); CommandLine cmd = parser.Parse(options, args.Skip(1).ToArray()); // If we have extra CLI options the Parse method doesn't throw exception. Handle here if (cmd.Args == null || cmd.Args.Length != 0) { throw new ParseException("Unused option(s): " + string.Join(",", cmd.Args)); } // Run command command.CheckOptions(cmd); command.Run(); } catch (ParseException pe) { Console.Error.WriteLine((pe.Message.EndsWith(".") ? pe.Message : pe.Message + ".") + " See '" + Allcea.CLI_NAME_AND_VERSION + " " + commandName + " -h'."); Environment.Exit(1); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); Environment.Exit(1); } } } else { // No CLI options Allcea.PrintMainUsage(null); Environment.Exit(1); } //Console.Error.WriteLine(DateTime.Now.Subtract(now).TotalMilliseconds); }