//event listener for saving packed state of datasheet private void ProjectSavedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { //call packState, returing packed state of plugin IDictionary<string, object> packedState = _frmDatasheet.PackState(); //add complete and visible flags to dictionary packedState.Add("Complete", boolComplete); packedState.Add("Visible", boolVisible); //add packed state to dictionary of all packed states for saving e.PackedPluginStates.Add(strPanelKey, packedState); }
//listen to other plugin's broadcasting their changes private void BroadcastStateListener(object sender, VBCommon.PluginSupport.BroadCastEventArgs e) { }
//Unpack the state of this plugin. private void ProjectOpenedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { if (e.PackedPluginStates.ContainsKey(strPanelKey)) { IDictionary<string,object> dictPlugin = e.PackedPluginStates[strPanelKey]; //Repopulate plugin Complete flag with saved project boolComplete = (bool)dictPlugin["Complete"]; //check to see if there already is a datasheet open, if so, close it before opening a saved project if (boolVisible) Hide(); //then show the opening project datasheet if ((bool)dictPlugin["Visible"]) { Show(); //enable the buttons for opening project if (boolComplete) { btnComputeAO.Enabled = true; btnGoToModeling.Enabled = true; btnManipulate.Enabled = true; btnTransform.Enabled = true; } } //unpack it _frmDatasheet.UnpackState(e.PackedPluginStates[strPanelKey]); } else { //Set this plugin to an empty state. Activate(); } }
//event handler for opening project state private void ProjectOpenedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { if (e.PackedPluginStates.ContainsKey(strPanelKey)) { IDictionary<string, object> dictPlugin = e.PackedPluginStates[strPanelKey]; //repopulate plugin complete flags from saved project boolComplete = (bool)dictPlugin["Complete"]; //check to see if there already is a prediction, if so, close it and open the saved project if (VisiblePlugin) Hide(); //make prediction active plugin if ((bool)dictPlugin["Visible"]) Show(); //Unpack the state of this plugin. _frmIPyPred.UnpackState(e.PackedPluginStates[strPanelKey]); } else { Activate(); //Set this plugin to an empty state. } }
//event handler for saving project state private void ProjectSavedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { IDictionary<string,object> packedState = _frmIPyPred.PackState(); if (packedState != null) { packedState.Add("Complete", boolComplete); packedState.Add("Visible", boolVisible); e.PackedPluginStates.Add(strPanelKey, packedState); } }
//event handler for saving project state private void ProjectSavedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { //go pack state, add complete and visible, and add to dictionary of plugins IDictionary<string, object> packedState = innerIronPythonControl.PackProjectState(); packedState.Add("Complete", boolComplete); packedState.Add("Visible", boolVisible); e.PackedPluginStates.Add(strPanelKey, packedState); }
//event listener for plugin broadcasting changes private void BroadcastStateListener(object sender, VBCommon.PluginSupport.BroadCastEventArgs e) { //listen to others broadcast..receiving something if (((IPlugin)sender).PluginType == Globals.PluginType.Modeling) { _frmIPyPred.SetModel(e.PackedPluginState); } if (boolComplete) _frmIPyPred.ClearDataGridViews(); }
//event handler for opening project state private void ProjectOpenedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { //if modeling is in the list of packed plugins, go unpack if (e.PackedPluginStates.ContainsKey(strPanelKey)) { IDictionary<string, object> dictPlugin = e.PackedPluginStates[strPanelKey]; //repopulate plugin Complete flags from saved project boolComplete = (bool)dictPlugin["Complete"]; //check to see if there already is a PLS model open, if so, close it before opening a saved project if ((VisiblePlugin) && (Complete)) Hide(); //make model being open active plugin if ((bool)dictPlugin["Visible"]) Show(); innerIronPythonControl.UnpackProjectState(e.PackedPluginStates[strPanelKey]); } else { //Set this plugin to an empty state. Activate(); } }
//event listener for plugin broadcasting changes private void BroadcastStateListener(object sender, VBCommon.PluginSupport.BroadCastEventArgs e) { //if datasheet updated itself, set data with changes, passing datasheet's plugin packed state if (((IPlugin)sender).PluginType == Globals.PluginType.Datasheet) { innerIronPythonControl.SetData(e.PackedPluginState); } //if datasheet changes were made after a model has been run, clear the model if (boolComplete && ((IPlugin)sender).PluginType == Globals.PluginType.Datasheet) { innerIronPythonControl.Clear(); MakeActive(); } }
//listen to plugin's broadcast in order to update other plugins private void BroadcastStateListener(object sender, VBCommon.PluginSupport.BroadCastEventArgs e) { string strPluginType = (((IPlugin)sender).PluginType).ToString(); //if datasheet is broadcasting any changes if (strPluginType == "Datasheet") { //find modeling plugin, needs to show itself once datasheet broadcasts itself with complete flag raised foreach (DotSpatial.Extensions.IExtension ex in App.Extensions) { IPlugin plugin = (IPlugin)ex; if (plugin.PluginType.ToString() == "Modeling") //already visible, just update not show again if (plugin.VisiblePlugin) return; //if datasheet is complete, show modeling else if (((IPlugin)sender).Complete) plugin.Show(); } //if modeling is broadcasting itself } else if (strPluginType == "Modeling") { //find prediction plugin, needs to show itself once modeling broadcasts itself with complete flag raised foreach (DotSpatial.Extensions.IExtension ex in App.Extensions) { IPlugin plugin = (IPlugin)ex; if (plugin.PluginType.ToString() == "Prediction") //already visible, just update not show again if (plugin.VisiblePlugin) return; else //modeling is complete, show prediction if (((IPlugin)sender).Complete) plugin.Show(); } } }
//raise event to pack each plugin for saving and add to PackedPluginStates dictionary private void ProjectSavedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { e.PackedPluginStates.Add(strPluginKey, PackState()); }
//raise event to unpack each plugin, sending the plugin dictionary private void ProjectOpenedListener(object sender, VBCommon.PluginSupport.SerializationEventArgs e) { if (e.PackedPluginStates.ContainsKey(strPluginKey)) { this.UnpackState(e.PackedPluginStates[strPluginKey]); } else { //Set this plugin to an empty state. } }