/// <summary> Default constructor. </summary> public ModelExtractor(BlamVersion gameVersion) { InitializeComponent(); // Force controls added to the control panel to dock to the top mControlPanel.ControlAdded += (sender, e) => { e.Control.Dock = DockStyle.Top; }; // Create the controller mController = new ModelExtractorController(gameVersion); // Attach to controller state changes mController.StateChanged += ControllerStateChanged; SetState(ModelExtractorStateEnum.ExtractorClosed); // Attach child controls to controller mTagsPathControl.BindPath("TagsFolder", mController.GetExtractorSettings()); mDataPathControl.BindPath("DataFolder", mController.GetExtractorSettings()); mMessageList.Attach(mController); mJobListControl.Attach(mController); // Populate the model type list foreach (var type in mController.GetExtractorFactory().GetFileTypes()) { mModelTypeComboBox.Items.Add(String.Format("{0} (*.{1})", type.TypeName, type.TypeExtension)); mExtensions.Add(type.TypeExtension); } // Set the initial extractor type mModelTypeComboBox.SelectedIndex = 0; mModelTypeComboBox.SelectedIndexChanged += SelectedExtensionChanged; SetExtractor(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Attaches the ui to the given controller. </summary> /// /// <param name="controller"> The controller. </param> public void Attach(IModelExtractorController controller) { mController = controller; // Attach to controller state changes mController.StateChanged += ControllerStateChanged; SetState(ModelExtractorStateEnum.ExtractorClosed); // Attach to extraction manager events var extractionManager = mController.GetExtractionManager(); extractionManager.JobAdded += (sender, args) => { if (InvokeRequired) { BeginInvoke(new Action( () => { AddJob(args.JobID, args.JobName); SetJobState(args.JobID, args.JobState, ""); }) ); } else { AddJob(args.JobID, args.JobName); SetJobState(args.JobID, args.JobState, ""); } }; extractionManager.JobRemoved += (sender, args) => { if (InvokeRequired) { BeginInvoke(new Action( () => { RemoveJob(args.JobID); }) ); } else { RemoveJob(args.JobID); } }; extractionManager.JobStateChanged += (sender, args) => { if (InvokeRequired) { BeginInvoke(new Action( () => { SetJobState(args.JobID, args.JobState, args.ResultString); }) ); } else { SetJobState(args.JobID, args.JobState, args.ResultString); } }; }