Example #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);
        }
Example #2
0
 //Global variables
 private void btnSaveAs_Click(object sender, EventArgs e)
 {
     if (PipeLineSystem.SaveAsDrawing(saveFileDialog1))
     {
         btnSaveAs.Enabled = false;
         MessageBox.Show("Your drawing is saved successfully");
     }
 }
Example #3
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     PipeLineSystem.AddNewNetwork(saveFileDialog1, btnSave, btnSaveAs);
     if (PipeLineSystem.OpenNetwork(openFileDialog1, btnLine))
     {
         PipeLineSystem.Saved   = true;
         this.btnSaveAs.Enabled = false;
         this.btnSave.Enabled   = false;
         //Draw all components methods
         MessageBox.Show("Your drawing is loaded");
         this.Refresh();
     }
 }
Example #4
0
 private void panelDrawing_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     try
     {
         PipeLineSystem.UpdateComponentSelected(e.X, e.Y, numericUpDown1, numericUpDown2);
         PipeLineSystem.Updated++;
         double pumpFlow     = Convert.ToDouble(numericUpDown2.Value);
         double upperPercent = Convert.ToDouble(this.ASpiter_UpValue.Value);
         PipeLineSystem.UpdateComponent(numericUpDown1, pumpFlow, upperPercent);
         this.Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #5
0
 /// <summary>
 /// Add new network
 /// </summary>
 /// <param name="saveFileDialog1"></param>
 /// <param name="btnSave"></param>
 /// <param name="btnSaveAs"></param>
 public static void AddNewNetwork(SaveFileDialog saveFileDialog1, Button btnSave, Button btnSaveAs)
 {
     if (PipeLineSystem.Network.GetListOfComponents().Count != 0 && PipeLineSystem.Saved == false)
     {
         DialogResult dialogResult = MessageBox.Show("The current drawing has not saved yet? Would you like to save it  ", "Save your network?", MessageBoxButtons.YesNoCancel);
         if (dialogResult == DialogResult.Yes)
         {
             if (PipeLineSystem.SavedAs == false)
             {
                 if (PipeLineSystem.SaveAsDrawing(saveFileDialog1))
                 {
                     btnSaveAs.Enabled = false;
                     MessageBox.Show("Your drawing is saved successfully");
                 }
             }
             else
             {
                 if (PipeLineSystem.SaveDrawing())
                 {
                     btnSave.Enabled   = false;
                     btnSaveAs.Enabled = false;
                     MessageBox.Show("Your drawing is saved successfully");
                 }
             }
         }
         if (dialogResult == DialogResult.No)
         {
             PipeLineSystem.Network.RemoveAll();
             btnSaveAs.Enabled      = true;
             PipeLineSystem.SavedAs = false;
             btnSave.Enabled        = false;
         }
     }
     else
     {
         PipeLineSystem.Network.RemoveAll();
         btnSaveAs.Enabled      = true;
         PipeLineSystem.SavedAs = false;
         btnSave.Enabled        = false;
     }
 }
Example #6
0
 public Network()
 {
     sys        = new PipeLineSystem();
     components = new List <Component>();
     pipelines  = new List <PipeLine>();
 }
Example #7
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     PipeLineSystem.AddNewNetwork(saveFileDialog1, btnSave, btnSaveAs);
     this.Refresh();
 }
Example #8
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.");
            }
        }