public GStatement GetGStatement(GSPresentation statementPresentation) { double statementPresentationX = statementPresentation.PointPresentation.X; double statementPresentationY = statementPresentation.PointPresentation.Y; foreach (UIElement element in Workspace.Children) { if (element is GStatement) { if (Canvas.GetLeft(element) == statementPresentationX && Canvas.GetTop(element) == statementPresentationY) { return(element as GStatement); } } } return(null); }
private void HookConnections() { PanelConnections.Clear(); foreach (PanelConnection connection in graphicalConversationEditor.Connections) { GSPresentation firstStatement = GetStatementPresentation(connection.First as GStatement); if (connection.Second is GStatement) { PanelConnections.Add(new PanelConnectionPresentation(firstStatement, GetStatementPresentation(connection.Second as GStatement))); } else { PanelConnections.Add(new PanelConnectionPresentation(firstStatement, GetPropertyPresentation(connection.Second as GProperty))); } } /*foreach (UIElement element in workspace.Children) * { * * if (element is GStatement) * { * GStatement gStatement = element as GStatement; * GSPresentation statementPresentation = GetStatementPresentation(gStatement); * * foreach (PanelConnection panelConnection in gStatement.GetPanelConnections()) * { * if (panelConnection.Second is GStatement) PanelConnections.Add(new PanelConnectionPresentation(statementPresentation, GetStatementPresentation(panelConnection.Second as GStatement))); * else if (panelConnection.Second is GProperty) PanelConnections.Add(new PanelConnectionPresentation(statementPresentation, GetPropertyPresentation(panelConnection.Second as GProperty))); * } * * } * * }*/ }
// -------- Access -------- private void HookProperties() { foreach (UIElement element in Workspace.Children) { if (element is GStatement) { GStatement gStatement = element as GStatement; GSPresentation statement = new GSPresentation(gStatement); statement.PointPresentation = new PointPresentation(Canvas.GetLeft(element as GStatement), Canvas.GetTop(element as GStatement)); Statements.Add(statement); } else if (element is GProperty) { GProperty gProperty = element as GProperty; GPPresentation property = new GPPresentation(gProperty); property.PointPresentation = new PointPresentation(Canvas.GetLeft(element as GProperty), Canvas.GetTop(element as GProperty)); Properties.Add(property); } } }