private void scaleItemDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { DataGridView dataGridView = (DataGridView)sender; DataGridViewCell cell = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.ErrorText = string.Empty; if (cell.ValueType == (typeof(int))) { ScaleItem S = (ScaleItem)scaleItemBindingSource.Current; if (S.IsDefault) { dataGridView.EndEdit(); cell.ErrorText = "This is a default value. It can't be changed."; e.Cancel = true; return; } int id = (int)cell.Value; List <ScaleItem> l = interviewService.CurrentInterview.Scales.Where(x => x.Id == id).ToList(); l.Remove(S); if (l.Count > 0) { dataGridView.EndEdit(); cell.ErrorText = "The Value must be unique!"; e.Cancel = true; return; } // update all Ratings interviewService.CurrentInterview.Elements.ForEach(x => x.Scores.Where(s => s.ScaleItemId == S.Id) .ToList() .ForEach(s => s.ScaleItemId = id)); } }
private void dataRepeaterScoring_DrawItem(object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e) { try { Control[] ca = e.DataRepeaterItem.Controls.Find("buttonRating", false); if (ca != null && ca.Length == 1) { Button d = (Button)ca[0]; Score s = (Score)scoreBindingSource[e.DataRepeaterItem.ItemIndex]; ScaleItem si = this.CurrentInterviewService.CurrentInterview.Scales.Single(x => x.Id == s.ScaleItemId); d.Text = "" + si.Id; if (si.IsDefault == false) { d.Text = "NA"; } d.Tag = s; this.toolTip1.SetToolTip(d, si.Name); } } catch (Exception ex) { Debug.Print(ex.StackTrace); MessageBox.Show(ex.Message); } }
private void barEditScale_EditValueChanged(object sender, EventArgs e) { ScaleItem item = barEditScale.EditValue as ScaleItem; if (item != null) { //地图按选择比例尺显示 mainMapControl.MapScale = item.Scale; mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, mainMapControl.Extent); } }
public void SetScale(int id) { ScaleItem selectedScale = null; foreach (var t in this.AllScales) { if (t.ID == id) { selectedScale = t; break; } } GuitarModelSettings.ScaleManager.SetScale(selectedScale.Name); RefreshStringSettings(); }
private void buttonRating_Click(object sender, EventArgs e) { try { Score s = (Score)((Button)sender).Tag; DialogRateElement dlg = new DialogRateElement(); dlg.CurrentScore = s; dlg.ShowDialog(); ((Button)sender).Text = "" + s.ScaleItemId; ScaleItem si = this.CurrentInterviewService.CurrentInterview.Scales.Single(x => x.Id == s.ScaleItemId); this.toolTip1.SetToolTip((Button)sender, si.Name); } catch (Exception ex) { Debug.Print(ex.StackTrace); MessageBox.Show(ex.Message); } }
private void UpdateBarEditScaleText() { var scale = new ScaleItem(mainMapControl.MapScale); barEditScale.EditValue = scale; }
private void DrawScaleFormulaIntervals(IGenericDrawingSurface g, int offsetX, int startY, ScaleItem scale, ColorValue fontColor) { string scaleIntervals = _guitarModel.GetScaleIntervals(); g.DrawString(offsetX + 2, startY + 11, "Intervals:", BasicFontSizePt, fontColor); g.DrawString(offsetX + 40, startY + 11, scaleIntervals, BasicFontSizePt, fontColor); }
private void DrawScaleNoteList(IGenericDrawingSurface g, int offsetX, int startY, ScaleItem scale, ColorValue fontColor) { string scaleNotes = ""; int notePos = 0; try { for (int i = 0; i < scale.ScaleIntervals.Length; i++) { if (scale.ScaleIntervals[i]) { notePos++; scaleNotes += NoteManager.GetNoteName(scale.GetNoteAtSequencePosition(notePos, NoteManager.GetNoteByName(_guitarModel.SelectedKey)), true); scaleNotes += " "; } } } catch (Exception) { System.Diagnostics.Debug.WriteLine("Exception: Couldn't resolve note name at one or more scale position"); } g.DrawString(offsetX + 2, startY + 18, "Notes:", BasicFontSizePt, fontColor); g.DrawString(offsetX + 40, startY + 18, scaleNotes, BasicFontSizePt, fontColor); }
public void ImportFelixLindemann(XElement xml) { if (xml.Name == "Project") { this.CurrentProject = new Project(xml); if ((string)xml.Attribute("ShowTrim") != null) { this.ShowTrim = int.Parse(xml.Attribute("ShowTrim").Value); } if ((string)xml.Attribute("ShowCut") != null) { this.ShowCut = int.Parse(xml.Attribute("ShowCut").Value); } if ((string)xml.Attribute("ShowScale") != null) { this.ShowScale = Boolean.Parse(xml.Attribute("ShowScale").Value); } if ((string)xml.Attribute("ShowMeta") != null) { this.ShowMeta = Boolean.Parse(xml.Attribute("ShowMeta").Value); } if ((string)xml.Attribute("PrintConstructId") != null) { this.PrintConstructId = Boolean.Parse(xml.Attribute("PrintConstructId").Value); } if ((string)xml.Attribute("PrintElementId") != null) { this.PrintElementId = Boolean.Parse(xml.Attribute("PrintElementId").Value); } if ((string)xml.Attribute("AutoPrint") != null) { this.R.AutoPrint = Boolean.Parse(xml.Attribute("AutoPrint").Value); } foreach (XElement xe in xml.Elements("Interview")) { ImportFelixLindemann(xe); } this.FirePropertyChanged("CurrentProject"); this.CurrentProject.ResetHasChanges(); } else if (xml.Name == "Interview") { InterviewService iService = new InterviewService(this, new Interview(this.project)); iService.CurrentInterview.Id = Guid.Parse(xml.Attribute("Id").Value); iService.CurrentInterview.Proband = xml.Attribute("Proband").Value; iService.CurrentInterview.GridName = xml.Attribute("GridName").Value; iService.CurrentInterview.Date = DateTime.Parse(xml.Attribute("Date").Value); iService.CurrentInterview.Remark = xml.Element("Remark").Value; foreach (XElement xe in xml.Elements("ScaleItem")) { ScaleItem s = new ScaleItem(iService.CurrentInterview, xe); // is added to this.Scales in constructor } foreach (XElement xe in xml.Elements("Construct")) { Construct con = iService.AddConstruct(); con.UpdateFromXML(xe); // is added to this.Constructs in constructor } foreach (XElement xe in xml.Elements("Element")) { Element elem = iService.AddElement(); elem.UpdateFromXML(xe); // is added to this.Elements in constructor foreach (XElement xRating in xe.Elements("Rating")) { Guid cid = Guid.Parse(xRating.Attribute("ParentConstruct").Value); Predicate <Construct> pc = new Predicate <Construct>(x => x.Id.Equals(cid)); // Console.WriteLine("Suche Construct ID: {0}", cid.ToString()); if (iService.CurrentInterview.Constructs.Any(x => pc(x)) == false) { throw new KeyNotFoundException(); } Construct c = iService.CurrentInterview.Constructs.Single(x => pc(x)); int rating = int.Parse(xRating.Attribute("ScaleItemId").Value); // Console.WriteLine("Element: {0} -- Construct: {1} -- Rating: {2}", elem.Name, c.ConstructPol, rating); Score s = iService.GiveRating(elem, c, rating); } } this.AddInterview(iService.CurrentInterview); this.CurrentProject.FirePropertyChanged("Interviews"); } else { throw new Exception(String.Format("XML-Node doesn't match. Expected: 'Project' or 'Interview'. Provided. '{0}'.", xml.Name)); } }