private void Model_ElementRemoved(object sender, ElementsEventArgs e) { // Check Terrain if (this._terrain == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <TerrainDataSource> line = element as EsriLine <TerrainDataSource>; if (line == null) { return; } // Get Rule TerrainDataSource terrainDataSource = line.Parent; // DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; SchemaModel schemaModel = diagrammerEnvironment.SchemaModel; Terrain terrain = schemaModel.FindParent(terrainDataSource); if (terrain != null) { terrain.TerrainDataSources.Remove(terrainDataSource); } }
// // PRIVATE METHODS // private void Model_ElementInserted(object sender, ElementsEventArgs e) { // Check GeometricNetwork if (this._geometricNetwork == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <EdgeConnectivityRule> line = element as EsriLine <EdgeConnectivityRule>; if (line == null) { return; } // Get Rule EdgeConnectivityRule rule = line.Parent; // Add Rule this._geometricNetwork.ConnectivityRules.Add(rule); }
// // PRIVATE METHODS // private void Model_ElementInserted(object sender, ElementsEventArgs e) { // Check Topology if (this._topology == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <TopologyRule> line = element as EsriLine <TopologyRule>; if (line == null) { return; } // Get Rule TopologyRule rule = line.Parent; // Add Rule this._topology.TopologyRules.Add(rule); }
private void Model_ElementRemoved(object sender, ElementsEventArgs e) { // Check Relationship if (this._geometricNetwork == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <GeometricNetworkControllerMembership> line = element as EsriLine <GeometricNetworkControllerMembership>; if (line == null) { return; } // Get Rule GeometricNetworkControllerMembership controller = line.Parent; // DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; SchemaModel schemaModel = diagrammerEnvironment.SchemaModel; ObjectClass objectClass = schemaModel.FindParent(controller); if (objectClass != null) { objectClass.ControllerMemberships.Remove(controller); } }
private void Model_ElementRemoved(object sender, ElementsEventArgs e) { // Check Relationship if (this._relationshipClass == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <RelationshipRule> line = element as EsriLine <RelationshipRule>; if (line == null) { return; } // Get Rule RelationshipRule rule = line.Parent; // Remove rule from relationship this._relationshipClass.RelationshipRules.Remove(rule); }
private void Model_ElementRemoved(object sender, ElementsEventArgs e) { // Check GeometricNetwork if (this._geometricNetwork == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <JunctionConnectivityRule> line = element as EsriLine <JunctionConnectivityRule>; if (line == null) { return; } // Get Rule JunctionConnectivityRule rule = line.Parent; // Remove rule from relationship this._geometricNetwork.ConnectivityRules.Remove(rule); }
private void EsriModel_ElementInserted(object sender, ElementsEventArgs e) { if (e == null) { return; } if (e.Value == null) { return; } Element element = e.Value; if (element is Table) { Table table = (Table)element; foreach (TableRow row in table.Rows) { this.ResetTable(row, table); } foreach (TableGroup group in table.Groups) { this.ResetTable(group, table); } } }
//Check if shapes or line collection has changed, then rebuild search tree private void Elements_InsertElement(object sender, ElementsEventArgs e) { if (sender is Line) { Line line = (Line)e.Value; line.Start.DockChanged += new EventHandler(Origin_DockChanged); line.End.DockChanged += new EventHandler(Origin_DockChanged); Reset(); } }
/// <summary> /// 模型被删除了,要找到对应的对象,然后删除之. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void model1_ElementRemoved(object sender, ElementsEventArgs e) { if (e.Value is Table) { Table table = e.Value as Table; EntityInfo ent = table.Tag as EntityInfo; AppConf.Ins.views_enkey.Remove(ent); AppConf.Ins.views_tbkey.Remove(table); if (formConf.ContainEntity(ent)) // 包含就不用管,不包含要加入关联. { ModuleInfo mo = formConf.GetEntityModule(ent); if (mo != null) { mo.Entitys.Remove(ent); } } // 从系统内删除这些EntityInfo. //EntityInfo newent = ent.Clone(); ProTreeCtrl.Ins.ReLoadTree(); } else if (e.Value is Line) { if (formConf.lineConKeys.Keys.Contains((Line)e.Value)) { ConnInfo con = formConf.lineConKeys[(Line)e.Value]; if (AppConf.Ins.Application.Conns.Contains(con)) { AppConf.Ins.Application.Conns.Remove(con); } formConf.lineConKeys.Remove((Line)e.Value); formConf.conLineKeys.Remove(con); } } }
// // PRIVATE METHODS // private void Model_ElementInserted(object sender, ElementsEventArgs e) { }
//Handles elements being added or removed from the target diagram private void Diagram_ElementsChanged(object sender, ElementsEventArgs e) { Invalidate(); }
private void Elements_RemoveElement(object sender, ElementsEventArgs e) { Reset(); }
private void diagram1_ElementInserted(object sender, ElementsEventArgs e) { e.Value.ApplyTheme(Singleton.Instance.GetTheme(Themes.Green)); }
//Check if shapes or line collection has changed, then rebuild search tree private void Elements_InsertElement(object sender, ElementsEventArgs e) { if (sender is Line) { Line line = (Line) e.Value; line.Start.DockChanged +=new EventHandler(Origin_DockChanged); line.End.DockChanged +=new EventHandler(Origin_DockChanged); Reset(); } }
void model1_ElementInserted(object sender, ElementsEventArgs e) { //插入时候调用的方法,要判断是否已经在模型内存在,如果不存在,则加一个新的 if (e.Value is Table) { Table table = e.Value as Table; EntityInfo ent = table.Tag as EntityInfo; if (!formConf.ContainEntity(ent)) // 包含就不用管,不包含要加入关联. { MessageBox.Show("暂时不支持复制,请删除新添加的对象."); //EntityInfo newen = ent.Clone(); //table.LocationChanged += table_LocationChanged; //table.SelectedChanged += properGridCtrl.Ins.table_SelectedChanged; //AppConf.Ins.views_enkey.Add(ent, table); //AppConf.Ins.views_tbkey.Add(table, ent); //ProTreeCtrl.Ins.CheckedModule.Entitys.Add(ent); //ProTreeCtrl.Ins.ReLoadTree(); } } else if (e.Value is Line) { try { if (formConf.MouseDownTable != null) { if (formConf.MouseUpTable != null) { Console.WriteLine("MouseDown:" + formConf.MouseDownTable.ToString()); formConf.MouseUpTable = (sender as Model).CurrentMouseElements.MouseMoveElement as Table; Console.WriteLine("MouseUp:" + formConf.MouseUpTable.ToString()); ConnInfo con = new ConnInfo(); con.SrcElementID = formConf.MouseDownTable.ToString(); con.TargetElementID = formConf.MouseUpTable.ToString(); con.linetype = formConf.linetype; if (!formConf.lineConKeys.Keys.Contains((Line)e.Value)) { formConf.conLineKeys.Add(con, (Line)e.Value); formConf.lineConKeys.Add((Line)e.Value, con); AppConf.Ins.Application.Conns.Add(con); } } } } catch (Exception ex) { //MessageBox.Show(ex.Message); } } }
//Handles elements being added or removed from the target diagram private void mDiagram_ElementsChanged(object sender, ElementsEventArgs e) { GetRenderList(ControlRectangle); Invalidate(); }
private void diagram1_ElementInserted(object sender, ElementsEventArgs e) { try { e.Value.ApplyTheme(Singleton.Instance.GetTheme(Crainiate.Diagramming.Themes.LightBlue)); bool isStatement = false; if (!((string)e.Value.Key).Contains("Shape") || ignoreInsert && sender != null) { return; } if (((Shape)e.Value).StencilItem.Key == "REGRA") { isStatement = true; } // _E_ | _OU_ : Create connectors if (!isStatement) { e.Value.ApplyTheme(Singleton.Instance.GetTheme(Crainiate.Diagramming.Themes.Orange)); ((Shape)e.Value).AllowSnap = ((Shape)e.Value).AllowScale = false; ignoreInsert = true; Link connector1 = new Link(); connector1.Start.Shape = diagram1.Model.Shapes[((Shape)e.Value).Key]; connector1.End.Location = new PointF(((Shape)e.Value).Location.X + ((Shape)e.Value).Width / 2, ((Shape)e.Value).Location.Y - 10); //connector1.Avoid = true; connector1.End.Marker = new Marker(MarkerStyle.Ellipse); connector1.Start.Marker = new Marker(MarkerStyle.Ellipse); connector1.SetKey("Link - " + ((Shape)e.Value).Key); diagram1.Model.Lines.Add("Link - " + ((Shape)e.Value).Key, connector1); if (((Shape)e.Value).StencilItem.Key == "_E_") { Booleans.Add(new BoolConnector(((Shape)e.Value).Key, "AND")); ((Shape)e.Value).Label = new Crainiate.Diagramming.Label("E"); } else if (((Shape)e.Value).StencilItem.Key == "_OU_") { Booleans.Add(new BoolConnector(((Shape)e.Value).Key, "OR")); ((Shape)e.Value).Label = new Crainiate.Diagramming.Label("OU"); } } else { e.Value.ApplyTheme(Singleton.Instance.GetTheme(Crainiate.Diagramming.Themes.Green)); //((Shape)e.Value).AllowSnap = ((Shape)e.Value).AllowScale = false; ScriptDialog sDialog = new ScriptDialog(this); sDialog.StartPosition = FormStartPosition.CenterParent; sDialog.ShowDialog(); ignoreInsert = true; Link connector1 = new Link(); connector1.Start.Shape = diagram1.Model.Shapes[((Shape)e.Value).Key]; connector1.End.Location = new PointF(((Shape)e.Value).Location.X + ((Shape)e.Value).Width / 2, ((Shape)e.Value).Location.Y - 10); //connector1.Avoid = true; connector1.End.Marker = new Marker(MarkerStyle.Ellipse); connector1.Start.Marker = new Marker(MarkerStyle.Ellipse); connector1.SetKey("Link - " + ((Shape)e.Value).Key); diagram1.Model.Lines.Add("Link - " + ((Shape)e.Value).Key, connector1); if (!sDialog.ERROR) { ((Shape)e.Value).Label = new Crainiate.Diagramming.Label(sDialog.Script); ((Shape)e.Value).Width = sDialog.Script.Length * ((Shape)e.Value).Label.FontSize; Statements.Add(new Statement(((Shape)e.Value).Key, sDialog.Script)); } else { Statements.Add(new Statement(((Shape)e.Value).Key, "")); } } ignoreInsert = false; } catch (Exception) { } }