private AdjustableSplitter SelectAdjustableSplitter() { //Codrin AdjustableSplitter selectedAdjustableSplitter = (AdjustableSplitter)fl.Components.First(component => component.GetId() == selectedComponent.GetId()); return(selectedAdjustableSplitter); }
public AdjustableSplitterEditPopup(AdjustableSplitter splitter) : base(splitter) { InitializeComponent(); nudDown.ValueChanged += (x, y) => { if (isSetting) return; isSetting = true; Splitter.DownFlowPercent = (int)nudDown.Value; nudUp.Value = Splitter.UpFlowPercent; OnFlowAltered(); isSetting = false; }; nudUp.ValueChanged += (x, y) => { if (isSetting) return; isSetting = true; Splitter.UpFlowPercent = (int)nudUp.Value; nudDown.Value = Splitter.DownFlowPercent; OnFlowAltered(); isSetting = false; }; }
public void changeSplitterPercentage(AdjustableSplitter adjustableSplitter, int newPercentage) { adjustableSplitter.changeSplitterPercentage(newPercentage); }
private void pbCanvas_MouseUp(object sender, MouseEventArgs e) { //Andi String selected = ""; string[] str; Point position = e.Location; position.X -= halfSize; position.Y -= halfSize; switch (tool) { case ToolType.select: selected = CheckMousePosition(position); if (selected != null) { str = selected.Split(new[] { ',' }); if (str[0] == "Component") { SelectComponent(Convert.ToInt32(str[1])); if (selectedFirstPipeComponent != null && selectedFirstPipeComponent.GetId() != Convert.ToInt32(str[1])) { selectedSecondPipeComponent = selectedComponent; Pipeline p = fl.GetPipelineByTwoComponents(selectedFirstPipeComponent, selectedSecondPipeComponent); if (p != null) { SelectPipeline(p.CurrentId); networkProperties.Visible = false; componentProperties.Visible = false; gbPipeline.Visible = true; tbPipeline.Visible = true; tbPipeline.Text = selectedPipeline.SafetyLimit.ToString(); } } } if (str[0] == "Pipeline") { SelectPipeline(Convert.ToInt32(str[1])); } } if (selected == null) { unselectedComponent = selectedComponent; selectedComponent = null; selectedPipeline = null; } break; case ToolType.move: if (moveComponent == false) { selected = CheckMousePosition(position); if (selected != null) { str = selected.Split(new[] { ',' }); if (str[0] == "Component") { SelectComponent(Convert.ToInt32(str[1])); moveComponent = true; } } if (selected == null) { unselectedComponent = selectedComponent; selectedComponent = null; } } else { //if(CheckComponentOverlay(position)) moveComponent = false; } break; case ToolType.delete: selected = CheckMousePosition(position); if (selected != null) { str = selected.Split(new[] { ',' }); if (str[0] == "Component") { DeleteComponent(Convert.ToInt32(str[1])); } } else { } break; case ToolType.addSink: if (CheckComponentOverlay(position)) { fl.AddComponent(position, ComponentType.Sink); } break; case ToolType.addPump: if (CheckComponentOverlay(position)) { fl.AddComponent(position, ComponentType.Pump); } break; case ToolType.addMerger: if (CheckComponentOverlay(position)) { fl.AddComponent(position, ComponentType.Merger); } break; case ToolType.addAdjSplitter: if (CheckComponentOverlay(position)) { fl.AddComponent(position, ComponentType.AdjustableSplitter); } break; case ToolType.addSplitter: if (CheckComponentOverlay(position)) { fl.AddComponent(position, ComponentType.Splitter); } break; case ToolType.addPipeline: selected = CheckMousePosition(position); if (selected != null) { str = selected.Split(new[] { ',' }); if (str[0] == "Component") { SelectComponent(Convert.ToInt32(str[1])); if (input == null) { input = selectedComponent; if (input is Components.Splitter || input is AdjustableSplitter) { int part = CheckPartOfComponent(position, input); if (part == 1) { inputPos = "up"; } if (part == 4) { inputPos = "down"; } if (part == 2 || part == 3) { input = null; } } } else if (output == null && input != null) { output = selectedComponent; if ((input is Pump && output is Pump) || (input is Sink && output is Sink)) { output = null; } if (output is Merger) { int part = CheckPartOfComponent(position, output); if (part == 2) { outputPos = "up"; } if (part == 3) { outputPos = "down"; } if (part == 1 || part == 4) { output = null; } } if (output != null) { fl.Connect(output, input, outputPos, inputPos); input = null; output = null; inputPos = ""; outputPos = ""; } } } } break; default: break; } // Checks if a Pump is selected if (selectedComponent != null && selectedComponent.ComponentType == ComponentType.Pump) { componentProperties.Visible = true; Pump selectedPump = SelectPump(); tbCapacity.Text = Convert.ToString(selectedPump.Capacity); tbFlow.Text = Convert.ToString(selectedPump.Output); } else { componentProperties.Visible = false; } if (selectedPipeline != null) { gbPipeline.Visible = true; gbPipeline.Enabled = true; tbPipeline.Text = Convert.ToString(selectedPipeline.SafetyLimit); } else { gbPipeline.Enabled = false; gbPipeline.Visible = false; } //Checks if an adjustable splitter is selected if (selectedComponent != null && selectedComponent.ComponentType == ComponentType.AdjustableSplitter) { gbSetRate.Visible = true; AdjustableSplitter selectedAdjustableSplitter = SelectAdjustableSplitter(); tbSetRate.Text = Convert.ToString(selectedAdjustableSplitter.DivisionRate); } else { gbSetRate.Visible = false; } if (selectedComponent == null && selectedPipeline == null) { networkProperties.Visible = true; tbGeneralSafetyLimit.Text = Convert.ToString(fl.GeneralSafetyLimit); } else { networkProperties.Visible = false; } pbCanvas.Invalidate(); }