private void AddSample(string sampleName, double start, double length) { var sample = new Sample { Description = sampleName }; if (LibraryTrack != null) { TrackSampleLibrary.UpdateSampleFromTrack(sample, LibraryTrack); } Samples.Add(sample); CurrentSample = sample; trackWave.CurrentSample = sample; trackWave.Samples = Samples; sample.Start = start; sample.Length = length; sample.Bpm = BpmHelper.GetBpmFromLoopLength(sample.Length); RefreshTrackWavePositions(); BindData(); }
private void updateSample(int sampleKey, string text, SampleMaster?newSampleMaster) { var sampleText = "Sample" + sampleKey + text; Sample sample = DC.Data.SampleX[sampleKey]; sample.Update( text: sampleText, flag: sample.Flag, number: sample.Number, amount: sample.Amount, amount4: sampleKey == 0 ? 0 : sampleKey * 0.0001m, amount5: sampleKey == 0 ? (decimal?)null : sampleKey * 0.00001m, preciseDecimal: sample.PreciseDecimal, sampleState: sample.SampleState, dateOnly: sample.DateOnly, timeOnly: sample.TimeOnly, dateTimeTicks: sample.DateTimeTicks, dateTimeMinute: sample.DateTimeMinute, dateTimeSecond: sample.DateTimeSecond, oneMaster: newSampleMaster, otherMaster: newSampleMaster, optional: sample.Optional); expectedData !.Samples.Remove(sampleKey); expectedData !.Samples.Add(sampleKey, sample.ToString()); assertData(); }
public async Task ReadAsync() { using (var reader = new StreamReader(SourcePath)) { while (!reader.EndOfStream) { var line = await reader.ReadLineAsync(); var values = line.Split(Separator); if (values[ColumnToRead] != null) { double sample; if (double.TryParse(values[ColumnToRead], out sample)) { Samples.Add(sample); } } } } if (Samples != null) { if (Samples.Count > 0) { OnDataReceived(Samples); } } }
protected override void OnInitialize() { base.OnInitialize(); Samples.Add(new SampleViewModel { Title = "Setup", Subtitle = "Setting up a WinRT application.", ViewModelType = typeof(SetupViewModel) }); Samples.Add(new SampleViewModel { Title = "Binding Conventions", Subtitle = "Binding view model properties to your view.", ViewModelType = typeof(BindingsViewModel) }); Samples.Add(new SampleViewModel { Title = "Action Conventions", Subtitle = "Wiring view events to view model methods.", ViewModelType = typeof(ActionsViewModel) }); Samples.Add(new SampleViewModel { Title = "Coroutines", Subtitle = "Mix IResult and Async / Await", ViewModelType = typeof(CoroutineViewModel) }); Samples.Add(new SampleViewModel { Title = "Execute", Subtitle = "Using Execute to execute code on the UI thread.", ViewModelType = typeof(ExecuteViewModel) }); Samples.Add(new SampleViewModel { Title = "Navigating", Subtitle = "Navigating between pages and passing parameters.", ViewModelType = typeof(NavigationViewModel) }); Samples.Add(new SampleViewModel { Title = "Search", Subtitle = "How to integrate the Share charm in your app.", ViewModelType = typeof(SearchViewModel) }); Samples.Add(new SampleViewModel { Title = "Settings", Subtitle = "How to use your view models in the settings charm.", ViewModelType = typeof(SettingsViewModel) }); Samples.Add(new SampleViewModel { Title = "Share Source", Subtitle = "How to use the share charm from your view model.", ViewModelType = typeof(ShareSourceViewModel) }); }
/// <summary> /// Adds a sample to the <see cref="AverageStatistics{T}.Samples"/> list. /// </summary> /// <typeparam name="TSample">Type of the sample value to be inserted</typeparam> /// <param name="sample"></param> public override void AddSample <TSample>(TSample sample) { if (sample is ulong) { Samples.Add((ulong)(object)sample); NewSamepleAdded = true; } else if (sample is long) { Samples.Add((ulong)(long)(object)sample); NewSamepleAdded = true; } else if (sample is int) { Samples.Add((ulong)(int)(object)sample); NewSamepleAdded = true; } else if (sample is uint) { Samples.Add((ulong)(object)sample); NewSamepleAdded = true; } else if (sample is ByteCountStatistics) { Samples.Add(((ByteCountStatistics)(object)sample).Value); NewSamepleAdded = true; } else { base.AddSample(sample); } }
public override void AddManualSamples() { Samples.Add(new MinimumSwaps2Sample() { arr = new Int32[] { 4, 3, 1, 2 } }); Answers.Add(new MinimumSwaps2Answer() { result = 3 }); Samples.Add(new MinimumSwaps2Sample() { arr = new Int32[] { 2, 3, 4, 1, 5 } }); Answers.Add(new MinimumSwaps2Answer() { result = 3 }); Samples.Add(new MinimumSwaps2Sample() { arr = new Int32[] { 1, 3, 5, 2, 4, 6, 7 } }); Answers.Add(new MinimumSwaps2Answer() { result = 3 }); }
/// <summary> /// The main measurment routine. Calling this will cause code:OnMeasure event to be /// raised. /// </summary> /// <param name="name">name of the benchmark</param> /// <param name="scale">The number of times the benchmark is cloned in 'action' (typically 1)</param> /// <param name="action">The actual code to measure.</param> /// <param name="reset">Code that will be called before 'action' to reset the state of the benchmark.</param> /// <returns>A Stats object representing the measurements (in usec)</returns> public Samples Measure(string name, float scale, Action action, Action reset) { if (reset != null && IterationCount != 1) { throw new ApplicationException("Reset can only be used on timers with an iteration count of 1"); } var statsUSec = new Samples(); if (Prime) { if (reset != null) { reset(); } action(); } for (int i = 0; i < SampleCount; i++) { if (reset != null) { reset(); } statsUSec.Add(timer.Measure(name, scale, action)); } if (OnMeasure != null) { OnMeasure(name, IterationCount, scale, statsUSec); } return(statsUSec); }
private void TryGetVisualTestsFromInstallPath(string frameworkPath, string file) { Assembly assembly = Assembly.LoadFrom(file); foreach (var type in assembly.GetTypes()) { if (type.IsDefined(typeof(CompilerGeneratedAttribute), false) || !IsVisualTestClass(type)) { continue; } foreach (var method in type.GetMethods().Where(IsVisualTestMethod)) { string solutionFilePath = ""; string projectFilePath = ""; if (!type.Namespace.Contains("DeltaEngine")) { solutionFilePath = Path.Combine(frameworkPath, "DeltaEngine.Samples.sln"); projectFilePath = GetSampleTestsProjectFilePaths(frameworkPath, assembly.GetName().Name); } Samples.Add(new Sample(assembly.GetName().Name + ": " + method.Name, SampleCategory.Test, solutionFilePath, projectFilePath, file) { EntryClass = type.Name, EntryMethod = method.Name }); } } }
private void buttonBrowseInput_Click(object sender, EventArgs e) { var dlg = new OpenFileDialog(); dlg.Filter = "In Files (*.in) | *.in"; if (dlg.ShowDialog() == DialogResult.OK) { textBoxInputFile.Text = dlg.FileName; String line; using (StreamReader sr = new StreamReader(dlg.FileName)) { while ((line = sr.ReadLine()) != null) { var splittedLine = line.Split(' '); if (splittedLine.Length < 15) { continue; } for (int i = 0; i < 12; i++) { int toIns; if (Int32.TryParse(splittedLine[i], out toIns)) { Samples.Add(toIns); } else { Samples.Add(0); } } } } } }
public WidgetCfgAssistant_ActionButton_OptionsBase(WidgetCfgSample <WidgetCfg_ActionButton> baseSample) { Title = localize.title_EditWidget; BaseSample = baseSample; ShowPreviewImage = false; ShowFirstPreviewImage = true; Samples.Add(new WidgetCfgSample <WidgetCfg_ActionButton>(localize.action_SaveAndQuit, BaseSample.GetConfigClone())); var cfg = BaseSample.GetConfigClone(); var cfgPrev = BaseSample.GetConfigClone(); Samples.Add(new WidgetCfgSample <WidgetCfg_ActionButton>(localize.ActionButtonStyle, null, cfg, typeof(WidgetCfgAssistant_ActionButton_Icon), cfgPrev)); cfg = BaseSample.GetConfigClone(); cfgPrev = BaseSample.GetConfigClone(); cfgPrev.ColorTitleText = xColor.Pink; Samples.Add(new WidgetCfgSample <WidgetCfg_ActionButton>(localize.WidgetTitle, null, cfg, typeof(WidgetCfgAssistant_ActionButton_Title), cfgPrev)); cfg = BaseSample.GetConfigClone(); cfgPrev = BaseSample.GetConfigClone(); Samples.Add(new WidgetCfgSample <WidgetCfg_ActionButton>(localize.ClickAction, null, cfg, typeof(WidgetCfgAssistant_Universal_ClickAction <WidgetCfg_ActionButton>), cfgPrev)); cfg = BaseSample.GetConfigClone(); cfgPrev = BaseSample.GetConfigClone(); Samples.Add(new WidgetCfgSample <WidgetCfg_ActionButton>(localize.Theme, null, cfg, typeof(WidgetCfgAssistant_ActionButton_Theme), cfgPrev)); NextStepAssistantType = null; }
public static int g_batch_id = 0; //实验批次号 protected override void OnViewLoaded() { foreach (var sample in Samples) { sample.TestItem1 = false; sample.TestItem2 = false; sample.TestItem3 = false; sample.TestItem4 = false; sample.TestItem5 = false; sample.TestItem6 = false; sample.TestItem7 = false; sample.TestItem8 = false; sample.TestItem9 = false; } op.CanComm.SetListenFun(op.OP.SampleRackCoils[0].Addr, CanFunCodeEnum.UPLOAD_REGISTER, RackChange); var scaner_info = ResManager.getInstance().GetScaner("0"); if (scaner_info == null) { ErrorSystem.WriteActError("扫码器无法识别!", false); } if (scaner_info != null) { scaner = IoC.Get <AbstractScaner>(scaner_info.ScanerType); scaner_port = scaner_info.Port; } visible = true; for (int i = 0; i < 24; i++) { template_code_list.Add(new ScanSampleIndexData(i, string.Format("{0:D2}", i + 1), "*", string.Format("{0:D2}", i + 2))); } if (Samples.Count == 0) { for (int i = 0; i < 24; i++) { for (int j = 0; j < 6; j++) { var sample_code = ""; var resinfo = ResManager.getInstance().SearchGelCard("T_BJ_SampleRack", "", "", i, j); resinfo.SetCode(sample_code); resinfo.Values[resinfo.CountX, resinfo.CountY] = resinfo; resinfo.sampleinfo = new SampleInfo(sample_code, (byte)i, (byte)j); Samples.Add(resinfo.sampleinfo); } } } var samples_sort = Samples.ToList(); samples_sort.Sort((a, b) => { return((a.RackIndex * 100 + a.Index) - (b.RackIndex * 100 + b.Index)); }); Samples.Clear(); foreach (var item in samples_sort) { Samples.Add(item); } base.OnViewLoaded(); }
public override void AddManualSamples() { Samples.Add(new RKSumSample() { N = 1, K = 3, seq = new Int64[] { 3 } }); Answers.Add(new RKSumAnswer() { a = new Int64[] { 1 } }); Samples.Add(new RKSumSample() { N = 2, K = 2, seq = new Int64[] { 12, 34, 56 } }); Answers.Add(new RKSumAnswer() { a = new Int64[] { 6, 28 } }); Samples.Add(new RKSumSample() { N = 3, K = 2, seq = new Int64[] { 2, 3, 4, 4, 5, 6 } }); Answers.Add(new RKSumAnswer() { a = new Int64[] { 1, 2, 3 } }); }
public WidgetCfgAssistant_CalendarCircleWave_DayColors(WidgetCfgSample <WidgetCfg_CalendarCircleWave> baseSample) { Title = localize.DayColors; AllowCustom = true; ShowColors = true; BaseSample = baseSample; var cfgTemplate = baseSample.GetConfigClone(); int iClrs = cfgTemplate.DayBackgroundGradient.GradientS[0].CustomColors.Length; int i1 = Math.Max(4 - iClrs, 0); int i2 = Math.Min(4, i1 + iClrs - 1); float nLum1 = 0; float nLum2 = 0; if (iClrs == 1 && cfgTemplate.DayBackgroundGradient.GradientS[0].CustomColors.Length == 2) { if (cfgTemplate.DayBackgroundGradient.GradientS[0].CustomColors[0].Luminosity > cfgTemplate.DayBackgroundGradient.GradientS[0].CustomColors[1].Luminosity) { nLum1 = .1F; nLum2 = -.1F; } else { nLum1 = -.1F; nLum2 = .1F; } } int i = 0; foreach (var clrs in DynamicColors.SampleColorSetS) { i++; var cfg = (WidgetCfg_CalendarCircleWave)cfgTemplate.Clone(); List <xColor> xclrs = new List <xColor>(); for (int iClr = i1; iClr <= i2; iClr++) { xclrs.Add(xColor.FromHex(clrs[iClr])); } if (iClrs == 1 && nLum1 != 0) { var clr1 = xclrs[0].AddLuminosity(nLum1); var clr2 = xclrs[0].AddLuminosity(nLum2); xclrs.Clear(); xclrs.Add(clr1); xclrs.Add(clr2); } cfg.DayBackgroundGradient = new DateGradient() { GradientS = { new DynamicGradient(cfg.TimeUnit, xclrs.ToArray()) } }; Samples.Add(new WidgetCfgSample <WidgetCfg_CalendarCircleWave>(localize.text_Sample + " " + i, xclrs.ToArray(), cfg)); } NextStepAssistantType = typeof(WidgetCfgAssistant_CalendarCircleWave_OptionsBase); }
void OpenDumpFile_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { DumpFileHandler handler = new DumpFileHandler(OpenDumpFile.FileName); xrfSample sample = handler.GetSampleData(); Samples.Add(new SampleWorkspaceViewModel(OpenDumpFile.SafeFileName, ref sample)); SelectedSample = Samples[Samples.Count - 1] as SampleWorkspaceViewModel; }
private void SetupCurrentSampleJobs() { Samples.Clear(); foreach (var item in _currentGroup.Children) { Samples.Add((ClientSample)item.Job); } }
/// <summary> /// Adds sample to sample list and calculates value of integral. /// </summary> /// <param name="sample"></param> public void AddSample(Sample sample) { Samples.Add(sample); if (Samples.Count > 1) { Value += (Samples[Samples.Count - 2].Value + sample.Value) * (sample.Time - Samples[Samples.Count - 2].Time) * 0.5; } }
/// <summary> /// Adds a sample to the <see cref="Samples"/> list. /// </summary> /// <typeparam name="TSample"></typeparam> /// <param name="sample"></param> public virtual void AddSample <TSample>(TSample sample) { if (sample is T) { Samples.Add((T)(object)sample); NewSamepleAdded = true; } }
public override void AddManualSamples() { Samples.Add(new CountTripletsSample() { arr = new List <long> { 1, 2, 4, 6, 3, 8, 6, 12, 24, 24 }, r = 2 }); Answers.Add(new CountTripletsAnswer() { res = 7 }); Samples.Add(new CountTripletsSample() { arr = new List <long> { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, r = 1 }); Answers.Add(new CountTripletsAnswer() { res = 161700 }); Samples.Add(new CountTripletsSample() { arr = new List <long> { 1, 2, 2, 4 }, r = 2 }); Answers.Add(new CountTripletsAnswer() { res = 2 }); Samples.Add(new CountTripletsSample() { arr = new List <long> { 1, 3, 9, 9, 27, 81 }, r = 3 }); Answers.Add(new CountTripletsAnswer() { res = 6 }); Samples.Add(new CountTripletsSample() { arr = new List <long> { 1, 5, 5, 25, 125 }, r = 5 }); Answers.Add(new CountTripletsAnswer() { res = 4 }); }
private void AddSamples() { //CPUPerformance.CPUView cpuView = new CPUPerformance.CPUView(); //Sparrow.Chart.Demos.Demos.PerformanceDemo.PerformanceDemo performanceView = new Demos.PerformanceDemo.PerformanceDemo(); CategoryModel category = new CategoryModel(); XmlReader reader = null; try { reader = XmlReader.Create("Demos.xml"); while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Category": category = new CategoryModel(reader["Name"]); this.Categories.Add(category); break; case "Sample": category.Samples.Add(new SampleModel(reader["Name"], "", reader["Class"], reader["Image"])); break; } } } } catch (Exception) { } finally { if (reader != null) { reader.Close(); } } foreach (var cat in Categories) { foreach (var sample in cat.Samples) { sample.IsHeader = false; Samples.Add(sample); } } //SampleModel performanceDemo = new SampleModel("Performance Demo", "", "Sparrow.Chart.Demos.Demos.PerformanceDemo.PerformanceDemo"); //performanceDemo.IsHeader = false; //SampleModel liveDataDemo = new SampleModel("Live Datas Demo", "", "Sparrow.Chart.Demos.Demos.LiveDatasDemo.LiveDatasDemo"); //liveDataDemo.IsHeader = false; //Samples.Add(liveDataDemo); //Samples.Add(performanceDemo); }
public override void GetVariate(int size, double lamda) { for (int i = 0; i < size; i++) { double uniform = random.NextDouble(); double variate = -Math.Log(1 - uniform) / lamda; Samples.Add(variate); } }
public override void CreateSamples(System.IO.StreamReader reader) { ReverseShuffleMergeSample sample = new ReverseShuffleMergeSample() { s = reader.ReadLine() }; Samples.Add(sample); }
public override void CreateSamples(StreamReader reader) { CommonChildSample sample = new CommonChildSample() { s1 = reader.ReadLine(), s2 = reader.ReadLine() }; Samples.Add(sample); }
private void AddTutorial(string projectDirectory, string projectName, string projectFile) { string solutionFilePath = Path.Combine(projectDirectory, "..", GetTutorialSolutionFileName(projectName)); string executableFile = Path.Combine(projectDirectory, "bin", GetConfigurationName(), projectName + ".exe"); Samples.Add(new Sample(projectName, SampleCategory.Tutorial, solutionFilePath, projectFile, executableFile)); }
public BaseRpHitableObject() { Samples.Add( new SampleInfo { Bank = "whistle", Name = "soft" } ); }
public override void CreateSamples(System.IO.StreamReader reader) { reader.ReadLine(); SpecialStringAgainSample sample = new SpecialStringAgainSample() { s = reader.ReadLine() }; Samples.Add(sample); }
public override void GenSamples() { Int32 n = rnd.Next(); Samples.Add(new List <Int32>() { n }); Answers.Add(n); }
public override void AddManualSamples() { Samples.Add(new ReverseShuffleMergeSample() { s = "caaabaddbc" }); Answers.Add(new ReverseShuffleMergeAnswer() { result = "bdaac" }); }
public override void CreateSamples(StreamReader reader) { int n = Convert.ToInt32(reader.ReadLine()); int[] arr = Array.ConvertAll(reader.ReadLine().Split(' '), arrTemp => Convert.ToInt32(arrTemp)); Samples.Add(new AlmostSortedSample() { arr = arr }); }
public void AddSampleToSamples(string fileName) { ClientSample sample = new ClientSample() { RawFile = Path.GetFileNameWithoutExtension(fileName), RawFilePath = Path.GetFullPath(fileName), Name = Path.GetFileNameWithoutExtension(fileName) }; Samples.Add(sample); }
/** * Add a new sample to the dataset. The gesture name * and subject must have already been added. */ public void AddSample(Sample sample, int subject_id, int gesture_id) { Samples.Add(sample); if (gesture_id >= SamplesByGesture.Count) { throw new Exception("gesture_id >= SamplesByGesture.Count"); } SamplesByGesture[gesture_id].Add(sample); }