示例#1
0
        public static bool OpenNetwork(OpenFileDialog openFileDialog1, Button btnLine)
        {
            DialogResult dr   = openFileDialog1.ShowDialog();
            FileHandler  temp = new FileHandler(openFileDialog1.FileName);

            PipeLineSystem.FileHandler = temp;
            PipeLineSystem.Network     = PipeLineSystem.FileHandler.ReadFromFile();
            if (dr == DialogResult.OK)
            {
                if (PipeLineSystem.Network != null)
                {
                    PipeLineSystem.Saved = true;
                    PipeLineSystem.checkForEnableDrawingPipeline(btnLine);

                    return(true);
                }
            }
            else
            {
                MessageBox.Show("You choose cancel");
            }


            return(false);
        }
示例#2
0
        //
        private void panelDrawing_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                if (PipeLineSystem.DeleteClicked == 1)
                {
                    int X = e.X;
                    int Y = e.Y;
                    PipeLineSystem.CompToBeDeleted     = PipeLineSystem.Network.FindComponent(new Point(X, Y));
                    PipeLineSystem.PipeLineToBeDeleted = PipeLineSystem.Network.FindPipeLine(new Point(X, Y));
                    if (PipeLineSystem.PipeLineToBeDeleted != null)
                    {
                        PipeLineSystem.Network.RemovePipeline(PipeLineSystem.PipeLineToBeDeleted);
                    }
                    if (PipeLineSystem.CompToBeDeleted != null)
                    {
                        PipeLineSystem.Network.RemoveComponent(PipeLineSystem.CompToBeDeleted);
                    }
                    PipeLineSystem.DeleteClicked = 0;
                    panelDrawing.Refresh();
                }
                //Need to check this again
                if (PipeLineSystem.Added == false)
                {
                    double pumpFlow     = Convert.ToDouble(numericUpDown2.Value);
                    double pumpMaxFlow  = Convert.ToDouble(numericUpDown1.Value);
                    double safeLimit    = Convert.ToDouble(this.numericUpDown4.Value);
                    double upperPercent = Convert.ToDouble(this.ASpiter_UpValue.Value);
                    if (pumpFlow > pumpMaxFlow)
                    {
                        throw new Classes.CustomExceptions("Current flow cannot exceed maximum flow.");
                    }
                    PipeLineSystem.AddTempComponent(e.X, e.Y, pumpFlow, upperPercent, pumpMaxFlow);
                    PipeLineSystem.AddTempPipeline(e.X, e.Y, safeLimit);
                }
                else
                {
                    //PipeLineSystem.RemoveSelectedComponent(e.X, e.Y);
                }
                //enable the save button
                if (PipeLineSystem.Saved == false)
                {
                    btnSave.Enabled = true;
                }
                //only allow saved when save as is done
                if (PipeLineSystem.SavedAs == true)
                {
                    btnSave.Enabled = false;
                }
                PipeLineSystem.checkForEnableDrawingPipeline(btnLine);

                this.Refresh();
            }
            catch (Classes.CustomExceptions ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch
            {
                MessageBox.Show("Please select a component or pipeline to draw.");
            }
        }