示例#1
0
 private void SelectALine(Graphics gr, Point mouseClick)
 {
     using (var path = new GraphicsPath())
     {
         foreach (var p in myNetwork.Pipelines)
         {
             Point[] pts = new Point[p.InBetweenPoints.Count + 2];
             pts[0] = p.StartPoint;
             for (int i = 0; i < p.InBetweenPoints.Count; i++)
             {
                 pts[i + 1] = p.InBetweenPoints[i];
             }
             pts[p.InBetweenPoints.Count + 1] = p.EndPoint;
             path.AddLines(pts);
             if (path.IsOutlineVisible(mouseClick, new Pen(Color.Orange, 8), gr))
             {
                 selectedPipeline = p;
                 break;
             }
         }
     }
 }
示例#2
0
        private void panel1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            selectedComponent = myNetwork.GetComponent(e.Location);

            Pump p = selectedComponent as Pump;
            if (p != null)
            {
                this.tbCurrentFlow.Text = p.Flow.ToString();
                this.tbCapacity.Text = p.Capacity.ToString();
            }

            Components.Splitter splitterComp = selectedComponent as Components.Splitter;
            if (splitterComp != null && splitterComp.IsAdjustable)
            {
                splitterTrackBar.Visible = true;
                AdjSplitLb.Visible = true;
                AdjSplitLb1.Visible = true;
            }
            else
            {
                splitterTrackBar.Visible = false;
                AdjSplitLb.Visible = false;
                AdjSplitLb1.Visible = false;
            }
            if (selectedComponent != null)
            {
                selectedPipeline = null;
                selectedPipelineLoc = new Point(0, 0);
            }
            else
            {
                selectedPipelineLoc = e.Location;
            }
            panel1.Invalidate();
        }
示例#3
0
 private void btnUpdateFlow_Click(object sender, EventArgs e)
 {
     if (selectedComponent != null)
     {
         if (selectedComponent is Pump)
         {
             Pump p = (Pump)selectedComponent;
             double capacity;
             double flow;
             if (double.TryParse(tbCapacity.Text, out capacity) &&
                 double.TryParse(tbCurrentFlow.Text, out flow))
             {
                 p.SetFlow(capacity, flow);
             }
             else
             {
                 MessageBox.Show("Invalid values!");
             }
         }
         selectedComponent = null;
         this.tbCurrentFlow.Text = "";
         this.tbCapacity.Text = "";
         panel1.Invalidate();
     }
     else if (selectedPipeline != null)
     {
         double maxFlow;
         if (double.TryParse(tbCapacity.Text, out maxFlow))
         {
             selectedPipeline.ChangeMaxFlow(maxFlow);
         }
         else
         {
             MessageBox.Show("Invalid max value!");
         }
         selectedPipeline = null;
         this.tbCurrentFlow.Text = "";
         this.tbCapacity.Text = "";
         panel1.Invalidate();
     }
 }
示例#4
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (selectedComponent != null)
     {
         myNetwork.RemoveComponent(selectedComponent);
         myNetwork.RemovePipeline(selectedComponent);
         selectedComponent = null;
         type = ComponentType.NONE;
         if (splitterTrackBar.Visible)
         {
             splitterTrackBar.Visible = false;
             AdjSplitLb1.Visible = false;
             AdjSplitLb.Visible = false;
         }
     }
     if (selectedPipeline != null)
     {
         myNetwork.RemovePipeline(selectedPipeline);
         selectedPipeline = null;
         selectedPipelineLoc = new Point(0, 0);
         type = ComponentType.NONE;
     }
     this.tbCapacity.Text = "";
     this.tbCurrentFlow.Text = "";
     panel1.Invalidate();
 }
示例#5
0
 /// <summary>
 /// Removes a pipeline from the list and clears its starting and ending point.
 /// </summary>
 /// <param name="p">The pipeline that will be removed.</param>
 public void RemovePipeline(Pipeline p)
 {
     p.ClearComponents();
     this.Pipelines.Remove(p);
 }
示例#6
0
 /// <summary>
 /// Adds a pipeline to the pipeline list.
 /// </summary>
 /// <param name="p">The pipeline that will be added.</param>
 public void AddPipeline(Pipeline p)
 {
     this.Pipelines.Add(p);
 }