public void FireEditEntity(WorkingModel c) { if (ReadOnly) { return; } WorkingModel entity = c; if (entity == null) { entity = FocusedEntity; } if (entity != null) { FormLunchModel countryform = new FormLunchModel(entity); countryform.Text = GetLocalized("editLunch"); countryform.isNew = false; if (FocusedEntity != null && gridViewLunch.RowCount > 1) { countryform.setReadOnlyTypeLunch(FocusedEntity.IsDurationTime); } if (countryform.ShowDialog() == DialogResult.OK) { _listEntities.ResetItemById(entity.ID); } } }
public void BuildsSchemaType() { var server = new WorkingModel().CreateServer(); var rawResult = server.Execute <JObject>(@"{ __type(name:""Query"") { name kind fields { name } } }"); var expectedType = new ObjectType { Kind = ObjectKinds.Object, Name = "Query", Fields = new [] { new ObjectField { Name = "child" } } }; var queryType = rawResult["__type"].ToObject <ObjectType>(); queryType.Should().BeEquivalentTo(expectedType); }
public DurationATimeLunchBrake(WorkingModel wm) : base(wm) { if (!wm.AddCharges) { throw new InvalidCastException("Duration a time"); } }
public void FireNewEntity() { if (ReadOnly) { return; } if (Country == null) { return; } WorkingModel entity = new WorkingModel(); entity.CountryID = Country.ID; entity.WorkingModelType = WorkingModelType.LunchModel; FormLunchModel countryform = new FormLunchModel(entity); countryform.Text = GetLocalized("NewLunch"); countryform.isNew = true; if (FocusedEntity != null) { countryform.setReadOnlyTypeLunch(FocusedEntity.IsDurationTime); } if (countryform.ShowDialog() == DialogResult.OK) { _listEntities.Add((WorkingModel)countryform.Entity); UpdateBarButtonEnable(); } }
private void btnSaveNew_Click(object sender, EventArgs e) { if (saveData()) { WorkingModel = new WorkingModel(); loadData(); txtName.Focus(); } }
private WorkingModel GetEntityByRowHandle(int rowHandle) { WorkingModel entity = null; if (gridViewLunch.IsDataRow(rowHandle)) { entity = (WorkingModel)gridViewLunch.GetRow(rowHandle); } return(entity); }
public override bool Commit() { Debug.Assert(WModel != null); if (IsValid()) { if (IsModified()) { WModel.ConditionType = (int)wnlist.State; WModel.Data = wnlist.ValuesToString(); WModel.Name = WorkingModelName; WModel.Message = WorkingModelMessage; WModel.AddValue = FixedAmount; WModel.MultiplyValue = MultiplyFactor; WModel.AddCharges = IsAdditionalCharge; WModel.BeginTime = BeginDate; WModel.EndTime = EndDate; WModel.LanguageID = Baumax.Contract.SharedConsts.NeutralLangId; WModel.UseInRecording = chk_UseInRecording.Checked; try { if (WModel.IsNew) { WorkingModel wm = ClientEnvironment.WorkingModelService.Save(WModel); WModel.ID = wm.ID; } else { ClientEnvironment.WorkingModelService.SaveOrUpdate(WModel); } Modified = true; } catch (ValidationException) { ErrorMessage(GetLocalized("CantSaveWorkingModel")); return(false); } catch (EntityException ex) { ProcessEntityException(ex); return(false); } } return(base.Commit()); } else { return(false); } }
public override bool Commit() { Debug.Assert(LunchModelEntity != null); if (IsValid()) { if (IsModified()) { LunchModelEntity.Name = lunchModelName; LunchModelEntity.ConditionTime = conditionTime; LunchModelEntity.HoursLunch = Hours; LunchModelEntity.IsDurationTime = IsDurationTime; LunchModelEntity.BeginTime = BeginDate; LunchModelEntity.EndTime = EndDate; LunchModelEntity.LanguageID = SharedConsts.NeutralLangId; try { if (LunchModelEntity.IsNew) { WorkingModel wm = ClientEnvironment.WorkingModelService.Save(LunchModelEntity); LunchModelEntity.ID = wm.ID; } else { ClientEnvironment.WorkingModelService.SaveOrUpdate(LunchModelEntity); } Modified = true; } catch (ValidationException) { ErrorMessage(GetLocalized("CantSaveLunchModel")); return(false); } catch (EntityException ex) { ProcessEntityException(ex); return(false); } } return(base.Commit()); } else { return(false); } }
public LunchBrakeModel(WorkingModel wm) { if (wm == null) { throw new ArgumentNullException("WorkingModel"); } if (wm.WorkingModelType != WorkingModelType.LunchModel) { throw new ArgumentException("LunchModel"); } BeginDate = wm.BeginTime; EndDate = wm.EndTime; ConditionTime = (int)(wm.AddValue * 60); ApplyValue = (int)(wm.MultiplyValue * 60); }
private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e) { if (!isUserWriteRight) { return; } GridHitInfo info = gridViewLunch.CalcHitInfo(e.X, e.Y); if (info.InRowCell && gridViewLunch.IsDataRow(info.RowHandle)) { WorkingModel entity = GetEntityByRowHandle(info.RowHandle); if (entity != null) { FireEditEntity(entity); } } }
public void AvoidsNPlusOne() { var model = new WorkingModel(); var server = model.CreateServer(); var rawResult = server.Execute <JObject>(@"{ children { id child { value1 value2 value3 } } }"); model.GrandchildResolves.Should().Be(1); }
public void ReturnsData() { var server = new WorkingModel().CreateServer(); var rawResult = server.Execute <JObject>(@"{ children { id child { value1 } } }"); var actual = rawResult["children"] .ToObject <ChildObject[]>(); actual .Should() .BeEquivalentTo(ChildrenResolver.Data); }
private void btnEdit_Click(object sender, EventArgs e) { try { int id = TextUtils.ToInt(grvDetail.GetFocusedRowCellValue(colWorkingID)); if (id == 0) { return; } WorkingModel model = (WorkingModel)WorkingBO.Instance.GetObjectByID(id); frmWorkingDetailH frm = new frmWorkingDetailH(); frm.WorkingModel = model; if (frm.ShowDialog() == DialogResult.OK) { loadWorking(); } } catch (Exception) { } }
private void gridViewLunch_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) { if (e.Column == gc_typeLunchModel) { if (e.IsGetData) { int idx = e.ListSourceRowIndex; if (idx >= 0 && idx < _listEntities.Count) { WorkingModel wm = _listEntities[e.ListSourceRowIndex]; if (wm.IsDurationTime) { e.Value = GetLocalized("DurationTime"); } else { e.Value = GetLocalized("DurationWorkingDay"); } } } } }
public void ReturnsObjectValues() { var expectedData = JObject.Parse(@"{ child: { value1: ""hello"", value2: ""world"", value3: 654, } }"); var server = new WorkingModel().CreateServer(); var result = server.Execute <JObject>(@"{ child { value1 value2 value3 } }"); result.Should().BeEquivalentTo(expectedData); }
public void GeneratesSchema() { var server = new WorkingModel().CreateServer(); var rawResult = server.Execute <JObject>(@"{ __type(name:""ChildObject"") { name kind fields { name type { name kind ofType { name kind } } } } }"); var expectedField = new ObjectField { Name = "child", Type = new ObjectType { Name = "GrandchildObject", Kind = ObjectKinds.Object } }; var queryType = rawResult["__type"].ToObject <ObjectType>(); queryType.Fields .SingleOrDefault(x => x.Name == "child") .Should() .BeEquivalentTo(expectedField); }
public override XmlElement SaveConfigItem(XmlDocument Owner) { //base XmlElement base_xml = base.SaveConfigItem(Owner); //LinkWrokFlow XmlElement linkwf = Owner.CreateElement("LinkWorkflow"); linkwf.SetAttribute("name", LinkWorkFLow); linkwf.SetAttribute("model", WorkingModel.ToString("G")); foreach (paramtransfer_item pi in ParamTransfer) { XmlElement pi_xml = Owner.CreateElement("ParamTransfer"); pi_xml.SetAttribute("source", pi.parent); pi_xml.SetAttribute("dest", pi.child); pi_xml.SetAttribute("direction", pi.direction.ToString()); linkwf.AppendChild(pi_xml); } base_xml.AppendChild(linkwf); return(base_xml); }
public void FireDeleteEntity(WorkingModel c) { if (ReadOnly) { return; } WorkingModel entity = c; if (entity == null) { entity = FocusedEntity; } if (entity != null) { //if (IsUsedWorkingModel(entity.ID)) return; if (QuestionMessageYes(GetLocalized("QuestionDeleteLunchModel"))) { try { ClientEnvironment.CountryService.WorkingModelService.DeleteByID(entity.ID); _listEntities.Remove(entity); UpdateBarButtonEnable(); } catch (ValidationException) { ErrorMessage(GetLocalized("CantDeleteLunchModel")); } catch (EntityException ex) { ProcessEntityException(ex); } } } }
public void ReturnsData() { var server = new WorkingModel().CreateServer(); var rawResult = server.Execute <JObject>(@"{ children { id child { value1 value2 value3 } } }"); var actual = rawResult["children"] .Select(x => x["child"]) .Select(x => x.ToObject <GrandchildObject>()) .ToArray(); actual .Should() .BeEquivalentTo(GrandchildResolver.Data.Select(x => x.Value)); }
public JsonResult Save(WorkingModel model) { // All model properties are null here???? return(Json("Success")); }
// Function that transforms stuff and does interpolation for vertices that were created in the middles of faces // TODO: replace with a generic user-vertex-info function public static BasicModelVert WorkingVertexToBMV(Vec3 position, VInfoReference[] vinfos, BasicModelData input_model, Mat4 input_xform, WorkingModel working_model) { Vec3 normal = Vec3.Zero; Vec2 uv = Vec2.Zero; foreach (VInfoReference vinfo in vinfos) { int index = vinfo.index; if (index != -1) { int tri = index / 3; int vert = index % 3; double weight = vinfo.weight; int normal_index = (int)(vert == 0 ? input_model.a_norm[tri] : vert == 1 ? input_model.b_norm[tri] : input_model.c_norm[tri]); normal += weight * input_xform.TransformVec3(new Vec3 { x = input_model.nx[normal_index], y = input_model.ny[normal_index], z = input_model.nz[normal_index] }, 0.0); int uv_index = (int)(vert == 0 ? input_model.a_uv[tri] : vert == 1 ? input_model.b_uv[tri] : input_model.c_uv[tri]); uv += weight * new Vec2 { x = input_model.u[uv_index], y = input_model.v[uv_index] }; } } return(new BasicModelVert { position = position, normal = Vec3.Normalize(normal), uv = uv }); }
public GrandchildResolver(WorkingModel model) { _model = model; }
protected WorkingFacade(WorkingModel model) : base(model) { }
// Once all of the triangle pairs that need intersection testing have been determined, we can do the actual intersection testing // Get out the scissors !!! protected virtual void Snip(ModelInput in_a, ModelInput in_b, List <TrianglePair> pairs) { List <int> first_tris = new List <int>(); List <int> second_tris = new List <int>(); foreach (TrianglePair pair in pairs) { if (!first_tris.Contains(pair.a)) { first_tris.Add(pair.a); } if (!second_tris.Contains(pair.b)) { second_tris.Add(pair.b); } } WorkingModel a = in_a.ToWorkingModel(0, first_tris); WorkingModel b = in_b.ToWorkingModel(1, second_tris); WorkingModel.Intersect(a, b, pairs); List <BasicModelVert> first_notsafe_bmv = a.GetBMVList(first_in, first_xform); List <BasicModelVert> first_safe_bmv = new List <BasicModelVert>(); for (int i = 0; i < first_in.a_vert.Length; i++) { if (!first_tris.Contains(i)) { for (int j = 0; j < 3; j++) { int xyz = (int)((j == 0 ? first_in.a_vert : j == 1 ? first_in.b_vert : first_in.c_vert)[i]); int uv = (int)((j == 0 ? first_in.a_uv : j == 1 ? first_in.b_uv : first_in.c_uv)[i]); int norm = (int)((j == 0 ? first_in.a_norm : j == 1 ? first_in.b_norm : first_in.c_norm)[i]); first_safe_bmv.Add(new BasicModelVert { position = first_xform.TransformVec3(new Vec3 { x = first_in.x[xyz], y = first_in.y[xyz], z = first_in.z[xyz] }, 1.0), uv = new Vec2 { x = first_in.u[uv], y = first_in.v[uv] }, normal = Vec3.Normalize(first_xform.TransformVec3(new Vec3 { x = first_in.nx[norm], y = first_in.ny[norm], z = first_in.nz[norm] }, 0.0)) }); } } } List <BasicModelVert> second_notsafe_bmv = b.GetBMVList(second_in, second_xform); List <BasicModelVert> second_safe_bmv = new List <BasicModelVert>(); for (int i = 0; i < second_in.a_vert.Length; i++) { if (!second_tris.Contains(i)) { for (int j = 0; j < 3; j++) { int xyz = (int)((j == 0 ? second_in.a_vert : j == 1 ? second_in.b_vert : second_in.c_vert)[i]); int uv = (int)((j == 0 ? second_in.a_uv : j == 1 ? second_in.b_uv : second_in.c_uv)[i]); int norm = (int)((j == 0 ? second_in.a_norm : j == 1 ? second_in.b_norm : second_in.c_norm)[i]); second_safe_bmv.Add(new BasicModelVert { position = second_xform.TransformVec3(new Vec3 { x = second_in.x[xyz], y = second_in.y[xyz], z = second_in.z[xyz] }, 1.0), uv = new Vec2 { x = second_in.u[uv], y = second_in.v[uv] }, normal = Vec3.Normalize(second_xform.TransformVec3(new Vec3 { x = second_in.nx[norm], y = second_in.ny[norm], z = second_in.nz[norm] }, 0.0)) }); } } } cutEdges = new List <Vec3[]>(); cutEdges.AddRange(a.GetCutEdgesList()); cutEdges.AddRange(b.GetCutEdgesList()); cutPoints = new List <Vec3>(); foreach (Vec3[] edge in b.GetCutEdgesList()) { foreach (Vec3 vert in edge) { if (!cutPoints.Exists((v) => (v - vert).ComputeMagnitudeSquared() < 0.0000000000000000000001)) { cutPoints.Add(vert); } } } List <BasicModelVert> first_bmv_trimmed = ScrapTrimmedStuff(first_safe_bmv, first_notsafe_bmv, cutEdges, first_keep); List <BasicModelVert> second_bmv_trimmed = ScrapTrimmedStuff(second_safe_bmv, second_notsafe_bmv, cutEdges, second_keep); first_out = BMVListToModel(first_bmv_trimmed); second_out = BMVListToModel(second_bmv_trimmed); }
public WorkingModel ToWorkingModel(int id, List <int> keptTriangles) { WorkingModel model = new WorkingModel(); model.objID = id; List <int> vertexIndices = new List <int>(); List <int> useVerts = new List <int>(); // get all the triangles and their vertices foreach (int triangleIndex in keptTriangles) { WorkingTriangle triangle = new WorkingTriangle(); triangle.objID = id; triangle.triID = triangleIndex; for (int i = 0; i < 3; i++) { int vi = t_v[triangleIndex, i]; int useIndex = vertexIndices.IndexOf(vi); VertexPosition vpos; if (useIndex == -1) { useVerts.Add(vertexIndices.Count); vertexIndices.Add(vi); Vec3 pos = verts[vi]; vpos = new VertexPosition { xyz = new Vec3 { x = pos.x, y = pos.y, z = pos.z } }; model.vertexPositions.Add(vpos); } else { useVerts.Add(useIndex); Vec3 pos = verts[vi]; vpos = model.vertexPositions[useIndex]; } WorkingVertex wvert = new WorkingVertex(); wvert.position = vpos; wvert.vinfo[0] = new VInfoReference { objID = id, index = triangleIndex * 3 + i, weight = 1.0 }; wvert.vinfo[1] = new VInfoReference { objID = id, index = -1, weight = 0.0 }; wvert.vinfo[2] = new VInfoReference { objID = id, index = -1, weight = 0.0 }; triangle.verts[i] = wvert; } model.triangles.Add(triangle); model.originalTriangleIndices.Add(triangleIndex); } // now get all the edges between them foreach (WorkingTriangle tri in model.triangles) { for (int i = 0; i < 3; i++) { // if a triangle hasn't got an edge, give it one, and find the matching triangle if (tri.edges[i] == null) { WorkingEdge edge = tri.edges[i] = new WorkingEdge(); edge.verts[0] = tri.verts[i]; edge.verts[1] = tri.verts[(i + 1) % 3]; edge.triangles[0] = tri; foreach (WorkingTriangle other in model.triangles) { if (other != tri) { for (int j = 0; j < 3; j++) { // if another triangle has an edge, it's got a matching triangle, and our triangle can't be their match if (other.edges[j] != null) { continue; } if ((other.verts[j] == edge.verts[0] && other.verts[(j + 1) % 3] == edge.verts[1]) || (other.verts[j] == edge.verts[1] && other.verts[(j + 1) % 3] == edge.verts[0])) { edge.triangles[1] = other; other.edges[j] = edge; break; } } } } } } } return(model); }
public WorkingModelWrapper(WorkingModel model) { _workingmodel = model; BuildConditions(); }