private void Sample_MouseDown(object sender, MouseEventArgs e) { SampleVM vm = DataContext as SampleVM; if (vm != null) { if (e.RightButton == MouseButtonState.Pressed) { if (vm.EditingRequested != null) { vm.EditingRequested.Execute(vm); } } else if (e.LeftButton == MouseButtonState.Pressed) { if (vm.DragStarted != null) { DragStartEventArgs dsea = new DragStartEventArgs(); dsea.FrameworkElement = sender as FrameworkElement; dsea.GetEventPoint = (elem => e.GetPosition(elem)); vm.DragStarted.Execute(dsea); } } } e.Handled = true; }
public override RenderedSvg RenderColumn() { RenderedSvg result = base.RenderColumn(); SvgGroup group = new SvgGroup(); for (int i = 0; i < vm.Samples.Length; i++) { SampleVM sample = vm.Samples[i]; //sample circle sign SvgCircle circle = new SvgCircle(); circle.CenterX = Helpers.dtos(circleXoffset); circle.CenterY = Helpers.dtos(sample.Level); circle.Radius = Helpers.dtos(circleRadius); circle.Stroke = blackPaint; group.Children.Add(circle); //sample depth label SvgText depthText = new SvgText(string.Format("{0:0.##} м", sample.Depth)); depthText.Transforms.Add(new Svg.Transforms.SvgTranslate(textXoffset, (float)(sample.Level + 2.0 * circleRadius + textFontSize * 0.5))); depthText.Fill = blackPaint; depthText.FontSize = Helpers.dtos(textFontSize); group.Children.Add(depthText); //sample comment SvgText commentText = new SvgText(sample.Comment); commentText.Transforms.Add(new Svg.Transforms.SvgTranslate(textXoffset, (float)(sample.Level + 2.0 * circleRadius + textFontSize * 1.5))); commentText.Fill = blackPaint; commentText.FontSize = Helpers.dtos(textFontSize); group.Children.Add(commentText); } result.SVG = group; return(result); }
public ActionResult Index(SampleVM data) { //ModelState.Clear(); var dt = new SampleVM() { Name = "Will", Title = "CTO" }; ViewData["Name"] = "John"; //var list = new List<SelectListItem>(); //list.Add(new SelectListItem() { Text = "進階班", Value = "3" }); //list.Add(new SelectListItem() { Text = "中級班", Value = "2" }); //list.Add(new SelectListItem() { Text = "初階班", Value = "1" }); //ViewData["LevelOptions"] = new SelectList(list, "Value", "Text", 1); ViewData["LevelOptions"] = new SelectList(db.Occupation.ToList(), "OccupationId", "OccupationName", 1); return(View(dt)); }
public async Task <IActionResult> PutSample(int id, SampleVM model) { if (id != model.Id) { return(BadRequest()); } await _sampleService.SampleUpdateAsync(model); return(CreatedAtAction("GetSample", new { id }, model)); //try //{ // await _context.SaveChangesAsync(); //} //catch (DbUpdateConcurrencyException) //{ // if (!SampleExists(id)) // { // return NotFound(); // } // else // { // throw; // } //} //return NoContent(); }
public async Task <int> SampleUpdateAsync(SampleVM model) { var entity = _mapper.Map <Sample>(model); _context.Update(entity); await _context.SaveChangesAsync(); return(entity.Id); }
public ActionResult Index(SampleVM data) { if (ModelState.IsValid) { TempData["IndexSaveMsg"] = "新增" + data.Name + "成功"; return(RedirectToAction("IndexResult")); } return(View(data)); }
public ActionResult SampleByHtmlHelper(SampleFilters filters) { var model = new SampleVM() { PagedList = GetData(filters), Filters = filters }; return(View(model)); }
private string SimplifyExpression(SampleVM sampleVM) { string expression = DynamicRule.Replace("\'", "\""); expression = expression.Replace("Value1", sampleVM.Value1.ToString()); expression = expression.Replace("Value2", sampleVM.Value2.ToString()); expression = expression.Replace("ValueA", "\"" + sampleVM.ValueA.ToString() + "\""); expression = expression.Replace("ValueB", "\"" + sampleVM.ValueB.ToString() + "\""); return(expression); }
private SampleVM Clone(Sample sample) { SampleVM vm = new SampleVM(); foreach (PropertyInfo sourcePropertyInfo in sample.GetType().GetProperties()) { PropertyInfo destPropertyInfo = vm.GetType().GetProperty(sourcePropertyInfo.Name); destPropertyInfo.SetValue(vm, sourcePropertyInfo.GetValue(sample, null), null); } return(vm); }
public ActionResult Show() { var data = new SampleVM() { Title = "CTO", Name = "Will", Level = 5, Gender = GenderEnum.中性 | GenderEnum.男性 }; return(View(data)); }
public async Task <IActionResult> Simplify([FromBody] SampleVM sampleVM) { string expression = SimplifyExpression(sampleVM); var resultScript = _DynamicExpressions.CreateScript().ContinueWith(expression).RunAsync().GetResult().ReturnValue; var result = new { time = GetTime(), expression, result = resultScript }; return(Ok(result)); }
public async Task <IActionResult> GlobalsParameter([FromBody] SampleVM sampleVM) { string expression = DynamicRule.Replace("\'", "\""); var resultScript = CSharpScript.EvaluateAsync(expression, globals: sampleVM).Result; var result = new { time = GetTime(), expression, result = resultScript }; return(Ok(result)); }
private IList <SampleVM> Clone(IList <Sample> sampleList) { IList <SampleVM> sampleVMs = new List <SampleVM>(); foreach (Sample sample in sampleList) { SampleVM sampleVM = new SampleVM(); foreach (PropertyInfo sourcePropertyInfo in sample.GetType().GetProperties()) { PropertyInfo destPropertyInfo = sampleVM.GetType().GetProperty(sourcePropertyInfo.Name); destPropertyInfo.SetValue(sampleVM, sourcePropertyInfo.GetValue(sample, null), null); } sampleVMs.Add(sampleVM); } return(sampleVMs); }
private void Sample_TouchDown(object sender, TouchEventArgs e) { System.Diagnostics.Trace.WriteLine("label touched"); SampleVM vm = DataContext as SampleVM; if (vm != null) { if (vm.DragStarted != null) { DragStartEventArgs dsea = new DragStartEventArgs(); dsea.FrameworkElement = sender as FrameworkElement; dsea.GetEventPoint = (elem => e.GetTouchPoint(elem).Position); vm.DragStarted.Execute(dsea); e.Handled = true; } } }
private void Refresh() { items.Clear(); if (this.sortByName) { var byName = PerfTracer.Samples.GroupBy(s => s.Name); foreach (var sample in byName.OrderBy(s => new Uri(s.Key).AbsolutePath)) { var item = new SampleVM { Name = new Uri(sample.Key).AbsolutePath, Details = string.Format( "{0}:[{1} - {2:0.##} - {3}]ms", sample.Count(), sample.Select(s => s.ElapsedMilliseconds).Min(), sample.Select(s => s.ElapsedMilliseconds).Average(), sample.Select(s => s.ElapsedMilliseconds).Max()) }; this.items.Add(item); } } else { foreach (var sample in PerfTracer.Samples.OrderBy(s => s.Time)) { var item = new SampleVM { Name = new Uri(sample.Name).AbsolutePath, Details = string.Format("{0:H:mm:ss.fff} {1}ms", sample.Time.ToLocalTime(), sample.ElapsedMilliseconds) }; this.items.Add(item); } } }
public async Task <ActionResult <Sample> > PostSample(SampleVM model) { var id = await _sampleService.SampleSaveAsync(model); return(CreatedAtAction("GetSample", new { id }, model)); }
public async Task <BodyResponse <SampleInfo> > Login(SampleVM sampleVM) { return(await _bus.SendCommand(new SampleCommand(_mapper.Map <SampleInfo>(sampleVM)))); }
// GET: Sample/Create public ActionResult Create() { var form = new SampleVM(); return(View(form)); }
//[Route("SampleLogin")] public BodyResponse <SampleInfo> Login([FromBody] SampleVM model) { return(new BodyResponse <SampleInfo>(StatusCodeDefines.FieldError, null, null)); }
// GET: Sample/Edit/5 public ActionResult Edit(int id) { SampleVM sampleData = Clone(mockData.Where(w => w.Id == id).FirstOrDefault()); return(View(sampleData)); }
public static void Generate(string fileName, SamplesColumnVM samplesCol, Intervals.BoreIntervalVM[] intervals, Layer[] layers, string[] propNames) { using (StreamWriter textWriter = new StreamWriter(File.Open(fileName, FileMode.Create), Encoding.UTF8)) { var csv = new CsvWriter(textWriter); //writing header csv.WriteField("Глубина (м)"); csv.WriteField("Описание"); csv.WriteField("Верх интервала (м)"); csv.WriteField("Низ интервала (м)"); for (int j = 0; j < propNames.Length; j++) { csv.WriteField(propNames[j]); } csv.NextRecord(); for (int i = 0; i < samplesCol.Samples.Length; i++) { SampleVM sVM = samplesCol.Samples[i]; //searching for correspondence Intervals.BoreIntervalVM containingInterval = null; for (int j = 0; j < intervals.Length; j++) { var int1 = intervals[j]; if (sVM.Depth > int1.UpperDepth && sVM.Depth < int1.LowerDepth) { containingInterval = int1; break; } } Layer containingLayer = null; for (int j = 0; j < layers.Length; j++) { Layer l = layers[j]; if (sVM.Depth > l.TopDepth && sVM.Depth < l.BottomDepth) { containingLayer = l; break; } } //fields to write string depth = string.Format("{0:0.##}", sVM.Depth); string name = string.Format("{0}", sVM.Comment); string intTop = (containingInterval == null) ? "" : string.Format("{0:0.##}", containingInterval.UpperDepth); string intBottom = (containingInterval == null) ? "" : string.Format("{0:0.##}", containingInterval.LowerDepth); string[] props = null; if (containingLayer == null) { props = Enumerable.Repeat("", propNames.Length).ToArray(); } else { props = new string[propNames.Length]; for (int j = 0; j < containingLayer.Classifications.Length; j++) { ClassificationLayerVM clVM = containingLayer.Classifications[j]; SingleClassificationLayerVM sclVM = clVM as SingleClassificationLayerVM; if (sclVM != null) { if (sclVM.CurrentClass != null) { props[j] = ClassToString(sclVM.CurrentClass); } } MultiClassificationLayerVM mclVM = clVM as MultiClassificationLayerVM; if (mclVM != null) { if (mclVM.CurrentClasses != null) { props[j] = string.Join(", ", mclVM.CurrentClasses.Select(c => ClassToString(c)).ToArray()); } } } } //writing fields csv.WriteField(depth); csv.WriteField(name); csv.WriteField(intTop); csv.WriteField(intBottom); for (int j = 0; j < props.Length; j++) { csv.WriteField(props[j]); } csv.NextRecord(); } } }