Beispiel #1
0
        public MainForm()
        {
            InitializeComponent();

            // set min and max size so form cannot be resized
            this.MinimumSize = new Size(900, 620);
            this.MaximumSize = new Size(900, 620);

            // initially disable buttons
            btnCopy.Enabled   = false;
            btnDelete.Enabled = false;
            btnCancel.Enabled = false;

            // Get file name
            xmlfileN = ConfigurationManager.AppSettings.Get("xmlFilePath");

            // If file exists - it may or may not have entries
            if (File.Exists(xmlfileN))
            {
                // Call top level class to load file
                // into collection class
                NewSvcEntyNames = new NewServiceEntryNames(this);

                // Check there are entries - before attempting to load
                // (belt and braces)
                if (NewSvcEntyNames.NSC != null)
                {
                    // Check there are entries to load
                    if (NewSvcEntyNames.NSC.Count > 0)
                    {
                        // ensure stop/start button enabled
                        btnStart.Enabled = true;

                        // Loop thro collection class to add Service entries to Mainform
                        foreach (NewSeviceEntry nse in NewSvcEntyNames.NSC)
                        {
                            AddEntriesToMainForm(nse);
                        }

                        // Check the Main Service status - to set as appropriate in the
                        // main form gui, Which effectiveley checks the value in the xml file
                        // (This value will always be in xml file by default)
                        if (NewSvcEntyNames.CheckServiceStatus().ToUpper() == "STOPPED")
                        //if (NewSvcEntyNames.CheckServiceStatus() == "false")
                        {
                            StopStart(Color.Red, "Stopped", false);
                        }
                        else
                        {
                            StopStart(Color.Green, "Running", true);
                        }
                    }
                    else // if the file exists but there are no entries
                    {    // set the service to stopped by default
                        StopStart(Color.Red, "Stopped", false);
                        btnStart.Enabled = false;
                    }
                }
                else
                {
                    // File exists but no entries - so stop and disable
                    StopStart(Color.Red, "Stopped", false);
                    btnStart.Enabled = false;
                }
            }
            else // File does not exist - so create and set
            {    // default service status of stopped
                // Just Load empty Windows form as no  entries
                // Create emty file if it doesnt exist
                if (CreateEmptyFile())
                {
                    StopStart(Color.Red, "Stopped", false);
                    btnStart.Enabled = false;
                }
            }

            UpdateColours(NewSvcEnty);
        }
Beispiel #2
0
 public void Populate()
 {
     //NewSvcEnty = new NewSeviceEntryCollection();
     NewSvcEntyNames = new NewServiceEntryNames(this);
 }