private void RunBTN_Click(object sender, EventArgs e) { bool hasErrors = false; foreach (var c in ComponentsGraph) { if (!c.ComponentReady()) { hasErrors = true; } } if (hasErrors) { CanvasPBX.Invalidate(); MessageBox.Show("Kindly enter the attributes and/or inputs for the marked components."); return; } foreach (var c in ComponentsGraph) { if (c.GetType().Equals(typeof(FileInputSignal))) { c.StartJob(); } } }
private void ComponentBTNClicked(object sender, EventArgs e) { var buttonSender = (Button)sender; Component c = (DSPUI.Components.Component)Activator.CreateInstance((Type)buttonSender.Tag); c.Location = new Point(CanvasPBX.Width / 2 - DSPUI.Components.Component.WIDTH / 2, CanvasPBX.Height / 2 - DSPUI.Components.Component.HEIGHT / 2); //Image i = c.GetDrawing(); //g.DrawImage(i, c.Location.X, c.Location.Y, DSPUI.Components.Component.WIDTH, DSPUI.Components.Component.HEIGHT); ComponentsGraph.Add(c); CanvasPBX.Invalidate(); }
private void CanvasPBX_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { var ind = GetComponentContainingPoint(e.Location); if (ind != -1) { DeleteComponentFromGraph(ind); } List <Component> comFrom; List <Component> comTo; GetLinesContainingPoint(e.Location, out comFrom, out comTo); for (int i = 0; i < comFrom.Count; i++) { comTo[i].RemoveInputComponent(comFrom[i]); } } else if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (newConnection != null) { int ind = GetComponentContainingPoint(e.Location); if (ind != -1) { if (ComponentsGraph[ind] != newConnection.c) { if (ComponentsGraph[ind].PointOnOutputConnection(e.Location) && newConnection.isInputToOutput) { if (!ComponentsGraph[ind].OutputComponents.Contains(newConnection.c) && newConnection.c.IsValidInputComponent(ComponentsGraph[ind])) { newConnection.c.AddInputComponent(ComponentsGraph[ind]); } } else if (ComponentsGraph[ind].PointOnInputConnection(e.Location) && newConnection.isOutputToInput) { if (!newConnection.c.OutputComponents.Contains(ComponentsGraph[ind]) && ComponentsGraph[ind].IsValidInputComponent(newConnection.c)) { ComponentsGraph[ind].AddInputComponent(newConnection.c); } } } } } } CanvasPBX.Invalidate(); newConnection = null; }
private void CanvasPBX_MouseClick(object sender, MouseEventArgs e) { Point p = CanvasPBX.PointToClient(Cursor.Position); var ind = GetComponentContainingPoint(p); if (ind != -1) { if (ComponentsGraph[ind].PointOnWarningIcon(p)) { t.Show(ComponentsGraph[ind].ErrorMessage, CanvasPBX, p.X, p.Y, 2000); } } }
private void CanvasPBX_MouseMove(object sender, MouseEventArgs e) { if (newConnection != null) { if (newConnection.isComponentToMove) { int dispX = e.Location.X - newConnection.lastMouseLocation.X; int dispY = e.Location.Y - newConnection.lastMouseLocation.Y; newConnection.c.Location = new Point(newConnection.c.Location.X + dispX, newConnection.c.Location.Y + dispY); newConnection.lastMouseLocation = e.Location; } newConnection.currentMouseLocation = e.Location; CanvasPBX.Invalidate(); } }