/// <summary> /// This method Setups this control /// </summary> public void Setup(Project project, DTNTable table) { // store the args Project = project; Table = table; // if the value for HasServicesFolder is false if (!HasServicesFolder) { // Set the DefaultServicesFolder on the project so the Save button becomes enabled Project.ServicesFolder = Path.Combine(Project.ProjectFolder, @"DataGateway\Services"); } // Create a new instance of a 'ProjectsWriter' object. ProjectsWriter writer = new ProjectsWriter(); // Set the InitialProject text so we can compare later this.InitialProject = writer.ExportProject(this.Project); // Display the Text ServicesFolderControl.Text = Project.ServicesFolder; // Fix a bug in my control to centger the buttons this.SaveCancelControl.CancelButtonTextAlign = ContentAlignment.MiddleCenter; this.SaveCancelControl.SaveButtonTextAlign = ContentAlignment.MiddleCenter; // Change the text of the CreateBlazorServicesButton this.CreateBlazorServicesButton.Text = "Create Data Services For " + Table.TableName; // Setup the CancelButton to use Done instead of Cancel this.SaveCancelControl.SetupCancelButton("Done", 80); // Enable or disable controls UIEnable(); }
/// <summary> /// This method enables or disables control or hides or shows controls based upon the state of the app. /// </summary> public void UIEnable() { // local bool enabledSaveButton = false; // if the value for HasInitialProject is true if (HasInitialProject) { // if the Project Exists and the ServiceFolder exists and the ServiceFolders are different // Create a new instance of a 'ProjectsWriter' object. ProjectsWriter writer = new ProjectsWriter(); // Set the InitialProject text so we can compare later string currentProject = writer.ExportProject(this.Project); // set the value for enabledSaveButton enabledSaveButton = !TextHelper.IsEqual(InitialProject, currentProject); } else { // set to true enabledSaveButton = true; } // set the value SaveCancelControl.EnableSaveButton = enabledSaveButton; }
/// <summary> /// method returns the Save /// </summary> public bool OnSave(bool close) { // initial value bool saved = false; // if the project exists if (HasProject) { // Create a new instance of a 'Gateway' object. Gateway gateway = new Gateway(); // Save the project saved = gateway.SaveProject(ref project); // Show the user a message MessageBoxHelper.ShowMessage("All changes have been saved.", "Save Complete"); // create the writer ProjectsWriter writer = new ProjectsWriter(); // reset the InitialProject InitialProject = writer.ExportProject(Project); } // Enable controls UIEnable(); // return value return(saved); }