public WeightToolStripMenuItem(IGraphWeight weight) { _weight = weight; if (_weight == null) { base.Text = LocalizedResources.GetResString("String.none", "none"); } else { base.Text = _weight.Name; } }
private void gridFcs_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || lstWeights.SelectedItems.Count != 1) { return; } IGraphWeight weight = ((WeightListViewItem)lstWeights.SelectedItems[0]).GraphWeight; int fcId = Convert.ToInt32(gridFcs.Rows[e.RowIndex].Cells[0].Value); string fieldName = (string)((DataGridViewComboBoxCell)gridFcs.Rows[e.RowIndex].Cells[2]).Value; IGraphWeightFeatureClass gwfc = weight.FeatureClasses[fcId]; if (gwfc == null) { gwfc = new GraphWeightFeatureClass(fcId, fieldName); weight.FeatureClasses[fcId] = gwfc; } if (e.ColumnIndex == 2) { if (fieldName == null || fieldName == "<none>") { ((GraphWeightFeatureClass)gwfc).FieldName = String.Empty; } else { ((GraphWeightFeatureClass)gwfc).FieldName = fieldName; } } if (e.ColumnIndex == 3) { if (gwfc.SimpleNumberCalculation != null && gwfc.SimpleNumberCalculation.Name == gridFcs.Rows[e.RowIndex].Cells[3].Value.ToString()) { } else { if (gridFcs.Rows[e.RowIndex].Cells[3].Value.ToString() == "<none>") { ((GraphWeightFeatureClass)gwfc).SimpleNumberCalculation = null; } foreach (ISimpleNumberCalculation calc in _calculators) { if (calc.Name == gridFcs.Rows[e.RowIndex].Cells[3].Value.ToString()) { PlugInManager pMan = new PlugInManager(); ((GraphWeightFeatureClass)gwfc).SimpleNumberCalculation = pMan.CreateInstance(PlugInManager.PlugInID(calc)) as ISimpleNumberCalculation; } } } } }
public static void WriteWeight(BinaryWriter writer, IGraphWeight weight, double val) { switch (weight.DataType) { case GraphWeightDataType.Integer: writer.Write(Convert.ToInt32(val)); break; case GraphWeightDataType.Double: writer.Write(val); break; } }
public static byte[] SerializeWeight(IGraphWeight weight) { if (weight != null) { XmlStream stream = new XmlStream("weight"); weight.Save(stream); MemoryStream ms = new MemoryStream(); stream.WriteStream(ms); return(ms.GetBuffer()); } return(null); }
private void gridFcs_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || lstWeights.SelectedItems.Count != 1) { return; } IGraphWeight weight = ((WeightListViewItem)lstWeights.SelectedItems[0]).GraphWeight; int fcId = Convert.ToInt32(gridFcs.Rows[e.RowIndex].Cells[0].Value); IGraphWeightFeatureClass gwfc = weight.FeatureClasses[fcId]; if (gwfc != null && gwfc.SimpleNumberCalculation != null && e.ColumnIndex == 4) { FormPropertyGrid dlg = new FormPropertyGrid(gwfc.SimpleNumberCalculation); dlg.ShowDialog(); } }
public NetworkWeighInput(IGraphWeight weight, WeightApplying weightApplying) { _weight = weight; _weightApplying = weightApplying; }
private void lstWeights_SelectedIndexChanged(object sender, EventArgs e) { btnRemoveWeight.Enabled = lstWeights.SelectedIndices.Count == 1; if (lstWeights.SelectedIndices.Count == 1) { IGraphWeight weight = ((WeightListViewItem)lstWeights.SelectedItems[0]).GraphWeight; propsWeight.SelectedObject = weight; gridFcs.Rows.Clear(); foreach (IFeatureClass fc in _selected.EdgeFeatureclasses) { int fcId = _database.GetFeatureClassID(fc.Name); DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell idCell = new DataGridViewTextBoxCell(); idCell.Value = fcId; row.Cells.Add(idCell); DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell(); nameCell.Value = fc.Name; row.Cells.Add(nameCell); DataGridViewComboBoxCell fieldCell = new DataGridViewComboBoxCell(); fieldCell.Items.Add("<none>"); foreach (IField field in fc.Fields) { switch (field.type) { case FieldType.integer: case FieldType.smallinteger: case FieldType.biginteger: case FieldType.Float: case FieldType.Double: fieldCell.Items.Add(field.name); break; } } IGraphWeightFeatureClass gwfc = weight.FeatureClasses[fcId]; if (gwfc == null) { fieldCell.Value = "<none>"; } else { fieldCell.Value = gwfc.FieldName; } row.Cells.Add(fieldCell); DataGridViewComboBoxCell calcCell = new DataGridViewComboBoxCell(); calcCell.Items.Add("<none>"); foreach (ISimpleNumberCalculation calc in _calculators) { calcCell.Items.Add(calc.Name); } if (gwfc == null || gwfc.SimpleNumberCalculation == null) { calcCell.Value = "<none>"; } else { calcCell.Value = gwfc.SimpleNumberCalculation.Name; } row.Cells.Add(calcCell); DataGridViewButtonCell calcPropCell = new DataGridViewButtonCell(); calcPropCell.Value = "..."; row.Cells.Add(calcPropCell); gridFcs.Rows.Add(row); } } }
public WeightListViewItem(IGraphWeight weight) { _weight = weight; base.Text = _weight.Name; }
public WeightToolStripMenuItem(IGraphWeight weight, bool check) : this(weight) { base.Checked = true; }