public void DrawPartGroup(PartGroup partGroup) { gameObject.SetActive(true); for (int i = 0; i < contentTransform.childCount; i++) { Destroy(contentTransform.GetChild(i).gameObject); } if (Part.PartList.ContainsKey(partGroup)) { List <Part> parts = Part.PartList[partGroup]; foreach (Part part in parts) { GameObject obj = Instantiate(buttonTemplate, contentTransform); var text = obj.GetComponentInChildren <Text>(); text.text = part.PartName; obj.GetComponentInChildren <Component_Button>().SetPart(part); obj.GetComponentInChildren <Info_Button>().SetDataSheet(part.ClassName); } } else { gameObject.SetActive(false); } }
public void AddPartGroupTest() { PartGroupBLL target = new PartGroupBLL(); PartGroup group = new PartGroup { GroupName = "test group2" }; group.Part.Add(new Part { PartID = new System.Guid("BAF2361E-CB23-4515-96A3-000BFA2D7D56") }); group.Part.Add(new Part { PartID = new System.Guid("6D95D410-994C-4DB2-803D-0012CBB90BD9") }); group.Part.Add(new Part { PartID = new System.Guid("564D2794-0E93-47C1-9682-0018CAA85F2F") }); group.Part.Add(new Part { PartID = new System.Guid("7B1BE85D-9B95-4BC1-8BC5-0020AE58D2EE") }); group.Part.Add(new Part { PartID = new System.Guid("44997C30-0C2C-46C4-A172-00251018EC85") }); group.Part.Add(new Part { PartID = new System.Guid("6E29BACB-858B-46C5-8596-003786F21FBB") }); target.AddPartGroup(group); Assert.AreNotEqual(0, group.GroupID); }
public static bool IsUpdatedModelFunctional(Model m, PartGroup pg1, PartGroup pg2) { List <Node> nodes = new List <Node>(m._GRAPH._NODES); foreach (Node node in pg1._NODES) { nodes.Remove(node); } nodes.AddRange(pg2._NODES); Category cat = m._CAT; List <Functions> funcs = getFunctionalityFromCategory(cat); List <Functions> updated = getNodesFunctionalities(nodes); var sub = funcs.Except(updated); if (sub.ToList().Count > 0) { return(false); } var add = updated.Except(funcs); if (add.Count() == 0) { return(false); // no supplementary } return(true); }// IsUpdatedModelFunctional
public static string PartGroupToString(PartGroup partGroup) { switch (partGroup) { case PartGroup.Breadboard: return("Bread Boards"); case PartGroup.BasicCircuit: return("Basic Chips"); case PartGroup.SpecialCircuit: return("Special Chips"); case PartGroup.Memory: return("Memory Chips"); case PartGroup.Inputs: return("Inputs"); case PartGroup.Outputs: return("Outputs"); case PartGroup.Wires: return("Wires"); default: return("Unknown group"); } }
public IQueryable <ViewPart> QueryPartsByGroup(PartGroup group) { var groupedPartQry = Context.GroupPartRelation.Where(gp => gp.PartGroup.GroupID == group.GroupID).Select(gp => gp.Part); var partQry = from gp in groupedPartQry join p in Context.ViewPart on gp.PartID equals p.PartID select p; return(partQry); }
public void GetPartGroupByKeyTest() { PartGroupBLL target = new PartGroupBLL(); PartGroup tmpGroup = target.GetPartGroupByKey(new PartGroup { GroupID = 1 }); Assert.IsNotNull(tmpGroup); }
private void partGroupkryptonComboBox1_SelectedIndexChanged(object sender, EventArgs e) { partGroupkryptonTextBox.Text = ""; if (partGroupkryptonComboBox1.SelectedItem != null) { PartGroup p = (PartGroup)partGroupkryptonComboBox1.SelectedItem; partGroupkryptonTextBox.Text = p.NAME; } }
private void bindGridViewPartResult(PartGroup model) { if (model != null) { List <ViewPart> parts = this.Service.QueryPartsByGroup(model); this.GridViewPartResult.DataSource = parts; this.GridViewPartResult.DataBind(); GroupParts = parts; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { PartGroup info = new PartGroup(); List <PartGroup> pgs = Service.QueryPartGroups(info); BindDataControl(gvGroup, pgs); BindData(PartInfo); } }
public void DeletePartGroup() { PartGroupBLL target = new PartGroupBLL(); PartGroup group = new PartGroup { GroupID = 30 }; target.DeletePartGroup(group); group = target.GetPartGroupByKey(group); Assert.AreEqual(null, group); }
protected void btnSave_Click(object sender, EventArgs e) { if (this.txtGroupName.Text.Trim().Length > 0) { PartGroup group = new PartGroup(); group.GroupName = this.txtGroupName.Text.Trim(); group.Description = this.txtDescription.Text.Trim(); group.GroupID = int.Parse(hidGroupID.Value); List <Part> parts = new List <Part>(); if (GroupParts.Count > 0) { List <ViewPart> vps = GroupParts; foreach (ViewPart vp in vps) { group.GroupParts.Add(new GroupPartRelation { Part = new Part { PartID = vp.PartID } }); parts.Add(new Part { PartID = vp.PartID }); } } if (group.GroupID > 0) { Service.UpdatePartGroup(group); } else { PartGroup temp = new PartGroup(); temp.GroupName = group.GroupName; List <PartGroup> list = Service.QueryPartGroups(temp); if (list != null && list.Count > 0) { RegisterStartupScript("Message", "<script>alert('该分组名称已存在');</script>"); return; } else { group = Service.AddPartGroup(group); hidGroupID.Value = group.GroupID.ToString(); } } } else { this.txtGroupName.Focus(); Response.Write("<script>alert('分组名称不能为空。');</script>"); } }
private void updateRecord() { foreach (DataGridViewRow item in gridData.Rows) { PartGroup dep = (PartGroup)item.Tag; if (dep.ID == m_prtgroup.ID) { gridData[0, item.Index].Value = m_prtgroup.CODE; gridData[1, item.Index].Value = m_prtgroup.NAME; break; } } }
private void removeRecord(int id) { foreach (DataGridViewRow item in gridData.Rows) { PartGroup dep = (PartGroup)item.Tag; if (dep.ID == id) { gridData.Rows.Remove(item); break; } } gridData.ClearSelection(); }
public void SelectPartGroup(PartGroup partGroup) { if (selectedPartGroup == partGroup) { selectedPartGroup = PartGroup.None; workspaceEditor.SetDesiredAction(WorkspaceAction.None); } else { selectedPartGroup = partGroup; } partGroupController.DrawPartGroup(selectedPartGroup); }
public Part(string partName, string className, PartGroup partGroup) { PartName = partName; ClassName = className; PartGroup = partGroup; IsMultiPoint = false; if (!PartList.ContainsKey(partGroup)) { PartList.Add(partGroup, new List <Part>()); } PartList[partGroup].Add(this); }
public void ClearForm() { try { textBoxCode.Text = ""; textBoxName.Text = ""; m_prtgroup = new PartGroup(); errorProvider1.Clear(); } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void bindGridView() { GridView1.DataKeyNames = new string[] { "GroupID", "GroupName" }; GridView1.PageSize = 10; PartGroup info = new PartGroup(); if (!string.IsNullOrEmpty(this.txtGroupName.Text.Trim())) { info.GroupName = this.txtGroupName.Text.Trim(); } List <PartGroup> pgs = Service.QueryPartGroups(info); GridView1.DataSource = pgs; GridView1.DataBind();//将控件及其所有子控件绑定到指定的数据源 }
}// ContainsSecondaryFunction public static double[] GetPartGroupCompatibility(Model m1, Model m2, PartGroup pg1, PartGroup pg2) { // 0: not replaceable // res[0]: if pg1 can be replaced by pg2 with the compatibility val // res[1]: if pg2 can be replaced by pg1 with the compatibility val double[] res = new double[2]; // part groups should not come from the same source model if (pg1._ParentModelIndex == pg2._ParentModelIndex || (pg1._NODES.Count == 0 && pg2._NODES.Count == 0)) { return(res); } // 1. if compatible functions exist List <Functions> funcs1 = getNodesFunctionalities(pg1._NODES); List <Functions> funcs2 = getNodesFunctionalities(pg2._NODES); //int comp = IsFunctionCompatible(funcs1, funcs2); //if (comp == -1) //{ // return res; //} //// 2. if #1. stands, check if the functionality of the model is preserved //if (comp == 0 || comp == 2) //{ // if (IsUpdatedModelFunctional(m1, pg1, pg2)) // { // res[0] = 1; // } //} //if (comp == 1 || comp == 2) //{ // if (IsUpdatedModelFunctional(m2, pg2, pg1)) // { // res[1] = 1; // } //} // same funcs if (hasCompatibleFunctions(funcs1, funcs2)) { res[0] = 1; } if (hasCompatibleFunctions(funcs2, funcs1)) { res[1] = 1; } return(res); }// IsTwoPartGroupCompatible
private void gridData_SelectionChanged(object sender, EventArgs e) { if (gridData.SelectedRows.Count == 0) { return; } ClearForm(); m_prtgroup = (PartGroup)gridData.SelectedRows[0].Tag; if (m_prtgroup == null) { return; } loadData(); setEnableForm(false); setEditMode(EditMode.View); }
public void UpdatePartGroup() { PartGroupBLL target = new PartGroupBLL(); PartGroup group = new PartGroup { GroupID = 48, GroupName = "test group048", Description = "desc" }; //group.Part.Add(new Part { PartID = new System.Guid("BAF2361E-CB23-4515-96A3-000BFA2D7D56") }); group.Part.Add(new Part { PartID = new System.Guid("6D95D410-994C-4DB2-803D-0012CBB90BD9") }); group.Part.Add(new Part { PartID = new System.Guid("564D2794-0E93-47C1-9682-0018CAA85F2F") }); //group.Part.Add(new Part { PartID = new System.Guid("7B1BE85D-9B95-4BC1-8BC5-0020AE58D2EE") }); //group.Part.Add(new Part { PartID = new System.Guid("44997C30-0C2C-46C4-A172-00251018EC85") }); //group.Part.Add(new Part { PartID = new System.Guid("6E29BACB-858B-46C5-8596-003786F21FBB") }); group.Part.Add(new Part { PartID = new System.Guid("D232CEC7-7133-4905-9E5C-004128F6AC40") }); target.UpdatePartGroup(group); PartGroupBLL target1 = new PartGroupBLL(); PartGroup group1 = new PartGroup { GroupID = 48, GroupName = "test group 0048", Description = "desc" }; group.Part.Add(new Part { PartID = new System.Guid("BAF2361E-CB23-4515-96A3-000BFA2D7D56") }); //group.Part.Add(new Part { PartID = new System.Guid("6D95D410-994C-4DB2-803D-0012CBB90BD9") }); group.Part.Add(new Part { PartID = new System.Guid("564D2794-0E93-47C1-9682-0018CAA85F2F") }); //group.Part.Add(new Part { PartID = new System.Guid("7B1BE85D-9B95-4BC1-8BC5-0020AE58D2EE") }); //group.Part.Add(new Part { PartID = new System.Guid("44997C30-0C2C-46C4-A172-00251018EC85") }); //group.Part.Add(new Part { PartID = new System.Guid("6E29BACB-858B-46C5-8596-003786F21FBB") }); group1.Part.Add(new Part { PartID = new System.Guid("D232CEC7-7133-4905-9E5C-004128F6AC40") }); target1.UpdatePartGroup(group1); group = target.GetPartGroupByKey(group); Assert.AreEqual("test group 048", group.GroupName); }
protected void Page_Load(object sender, EventArgs e) { this.Title = "零件组编辑"; if (!IsPostBack) { GroupParts = null; if (Request.QueryString["groupid"] != null) { PartGroup model = Service.GetPartGroupByKey(int.Parse(Request.QueryString["groupid"])); this.txtGroupName.Text = model.GroupName; this.txtDescription.Text = model.Description; hidGroupID.Value = model.GroupID.ToString(); PartGroup group = new PartGroup(); group.GroupID = int.Parse(hidGroupID.Value); bindGridViewPartResult(group); } } bindGridViewTempPartResult(); }
/// <summary> /// Saves the current Score as a MusicXML file. /// </summary> public void save() { // Create a save dialog to get the output file path Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); if (fileName == "" || !File.Exists(fileName)) { dialog.DefaultExt = "mml"; dialog.CheckPathExists = true; dialog.ValidateNames = true; dialog.Filter = "Music XML|*.mml"; Nullable <bool> result = dialog.ShowDialog(); if (result == false) { throw new FileNotFoundException(); } fileName = dialog.FileName; } try { // Put the staff in a part to meet MusicXML schema requirements Part p1 = new Part(data.FirstStaff); p1.Name = "FirstPart"; p1.PartId = "01"; PartGroup pg1 = new PartGroup(); p1.Group = pg1; data.PartGroups.Add(pg1); data.Parts.Add(p1); // Convert to MusicXML and save var parser = new MusicXmlParser(); var outputXml = parser.ParseBack(data); outputXml.Save(fileName); } catch (Exception ex) { MessageBox.Show("Could not save to " + fileName + ".\n" + ex.Message); fileName = ""; save(); } }
protected void ExportPartGroup() { string errorMessage; PartGroup group = new PartGroup(); if (!string.IsNullOrEmpty(txtGroupName.Text.Trim())) { group.GroupName = txtGroupName.Text.ToString(); } byte[] buffer = Service.ExportPartGroup(group, out errorMessage); if (string.IsNullOrEmpty(errorMessage) && buffer.Length > 0) { Response.Clear(); Response.Buffer = true; Response.ContentType = "text/csv"; Response.AddHeader("Content-Disposition", "attachment; filename=partgroups.csv"); Response.ContentEncoding = Encoding.GetEncoding("utf-8"); Response.OutputStream.Write(buffer, 0, buffer.Length); Response.Flush(); Response.End(); } }
public void Save(object sender, EventArgs e) { try { if (Valid()) { this.Cursor = Cursors.WaitCursor; UpdateEntity(); if (m_prtgroup.ID == 0) { RepositoryFactory.GetInstance().GetRepository(RepositoryFactory.PART_GROUP_REPOSITORY).Save(m_prtgroup); PartGroup bank = (PartGroup)RepositoryFactory.GetInstance().GetRepository(RepositoryFactory.PART_GROUP_REPOSITORY).GetByCode(m_prtgroup); int r = gridData.Rows.Add(bank.CODE, bank.NAME); gridData.Rows[r].Tag = bank; } else { RepositoryFactory.GetInstance().GetRepository(RepositoryFactory.PART_GROUP_REPOSITORY).Update(m_prtgroup); updateRecord(); } KryptonMessageBox.Show("Record has been saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); gridData.ClearSelection(); ClearForm(); textBoxCode.Focus(); this.Cursor = Cursors.Default; } } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// add one partGroup to database /// </summary> /// <param name="partGroup">an instance of class PartGroup</param> public void Add(PartGroup partGroup) { context.PartGroup.InsertOnSubmit(partGroup); }
/// <summary> /// get one partGroup by its's id /// </summary> /// <param name="partGroupNR">the id of the partGroup</param> /// <returns>the </returns> public PartGroup GetById(string partGroupNR) { PartGroup partGroup = context.PartGroup.Single(a => a.PartGroupNR.Equals(partGroupNR)); return(partGroup); }
private void kryptonComboBox1_SelectedIndexChanged(object sender, EventArgs e) { PartGroup p = (PartGroup)partGroupkryptonComboBox1.SelectedItem; partGroupkryptonTextBox.Text = p == null ? "" : p.NAME; }
public override Score Parse(XDocument xmlDocument) //TODO: Exception handling! { Score score = new Score(); var firstSystem = new StaffSystem(score); score.Pages.Last().Systems.Add(firstSystem); MusicXmlParserState state = new MusicXmlParserState(); foreach (XElement defaultSettingsNode in xmlDocument.Descendants().Where(d => d.Name == "defaults" || d.Name == "identification")) { foreach (XElement settingNode in defaultSettingsNode.Elements()) { var dummyStaff = new Staff { Score = score }; //Nasty workaround MusicXmlParsingStrategy parsingStrategy = MusicXmlParsingStrategy.GetProperStrategy(settingNode); if (parsingStrategy != null) { parsingStrategy.ParseElement(state, dummyStaff, settingNode); } } } foreach (XElement partNode in xmlDocument.Descendants(XName.Get("part"))) { state.CurrentSystemNo = 1; var partId = partNode.ParseAttribute("id"); state.FirstLoop = true; Staff staff = new Staff() { MeasureAddingRule = Staff.MeasureAddingRuleEnum.AddMeasuresManually }; score.Staves.Add(staff); var part = score.Parts.FirstOrDefault(p => p.PartId == partId) ?? new Part(staff) { PartId = partId }; staff.Part = part; score.Parts.Add(part); foreach (XElement node in partNode.Elements()) { MusicXmlParsingStrategy parsingStrategy = MusicXmlParsingStrategy.GetProperStrategy(node); if (parsingStrategy != null) { parsingStrategy.ParseElement(state, staff, node); } } } var partListNode = xmlDocument.Descendants(XName.Get("part-list")); PartGroup currentPartGroup = null; foreach (var partListElementNode in partListNode.Elements()) { if (partListElementNode.Name == "part-group") { partListElementNode.IfAttribute("type").HasValue("start").Then(() => { currentPartGroup = new PartGroup() { Number = score.PartGroups.Count + 1 }; score.PartGroups.Add(currentPartGroup); }); partListElementNode.IfAttribute("type").HasValue("stop").Then(() => currentPartGroup = null); if (currentPartGroup != null) { partListElementNode.IfElement("group-barline").HasValue <GroupBarlineType>(d => { d.Add("Yes", GroupBarlineType.Enabled); d.Add("No", GroupBarlineType.Disabled); d.Add("Mensurstrich", GroupBarlineType.Mensurstrich); return(d); }).Then(r => currentPartGroup.GroupBarline = r); } } if (partListElementNode.Name == "score-part" && currentPartGroup != null) { var scorePartId = partListElementNode.IfAttribute("id").HasAnyValue().ThenReturnResult(); var matchingScorePart = score.Parts.FirstOrDefault(p => p.PartId == scorePartId); if (matchingScorePart != null) { matchingScorePart.Group = currentPartGroup; } } } //Sibelius hack: if (score.Encoding?.Software?.Any(s => s.Contains("Sibelius")) ?? false) { new DefaultScoreFormatter().Format(score); } foreach (var staff in score.Staves) { staff.MeasureAddingRule = Staff.MeasureAddingRuleEnum.AddMeasureOnInsertingBarline; } return(score); }
public void AddPartGroup(PartGroup partGroup) { _context.Add(partGroup); }
public static PartGroup SaveGroup(int partID, string name, int groupID = 0) { CurtDevDataContext db = new CurtDevDataContext(); PartGroup pg = new PartGroup(); if (groupID == 0) { pg = new PartGroup { name = name }; db.PartGroups.InsertOnSubmit(pg); db.SubmitChanges(); PartGroupPart pgp = new PartGroupPart { partGroupID = pg.id, partID = partID, sort = 1 }; db.PartGroupParts.InsertOnSubmit(pgp); } else { pg = db.PartGroups.Where(x => x.id.Equals(groupID)).First(); pg.name = name; } db.SubmitChanges(); UpdatePart(partID); return GetGroup(pg.id); }
public static string IntToGroupString(int i) { PartGroup partGroups = (PartGroup)i; return(PartGroupToString(partGroups)); }