Ignore:
Timestamp:
Jul 4, 2010, 3:10:48 PM (12 years ago)
Author:
kopal
Message:
  • added update icon
  • ModelPersistance added handlers to necessary events
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/WorkspaceManager/Model/ModelPersistance.cs

    r1681 r1718  
    2222using System.Xml.Serialization;
    2323using System.Runtime.Serialization.Formatters.Binary;
     24using System.Reflection;
     25using Cryptool.PluginBase;
    2426
    2527namespace WorkspaceManager.Model
     
    3537        /// <param name="filename"></param>
    3638        /// <returns></returns>
    37         public static WorkspaceModel loadModel(string filename)
     39        public static WorkspaceModel loadModel(string filename, WorkspaceManager workspaceManagerEditor)
    3840        {
    3941            FileStream fileStream = null;
     
    4244            {
    4345                fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
    44                 BinaryFormatter binaryFormatter = new BinaryFormatter();             
    45                 return (WorkspaceModel)binaryFormatter.Deserialize(fileStream);
     46                BinaryFormatter binaryFormatter = new BinaryFormatter();
     47
     48                WorkspaceModel workspacemodel =  (WorkspaceModel)binaryFormatter.Deserialize(fileStream);
     49                workspacemodel.WorkspaceManagerEditor = workspaceManagerEditor;
     50
     51                foreach (PluginModel pluginModel in workspacemodel.AllPluginModels)
     52                {
     53                    pluginModel.Plugin.OnGuiLogNotificationOccured += workspaceManagerEditor.GuiLogNotificationOccured;
     54                    pluginModel.Plugin.OnPluginProgressChanged += pluginModel.PluginProgressChanged;
     55                    pluginModel.Plugin.OnPluginStatusChanged += pluginModel.PluginStatusChanged;
     56                }
     57               
     58                foreach (ConnectorModel connectorModel in workspacemodel.AllConnectorModels)
     59                {
     60                    if(connectorModel.Outgoing == true){
     61                        connectorModel.PluginModel.Plugin.PropertyChanged += connectorModel.PropertyChangedOnPlugin;
     62                    }
     63
     64                    if (connectorModel.IsDynamic == true)
     65                    {
     66                        DynamicPropertyInfoAttribute dynamicPropertyInfoAttribute = connectorModel.PluginModel.Plugin.GetDynamicPropertyInfo();
     67                        EventInfo eventinfo = connectorModel.PluginModel.PluginType.GetEvent(dynamicPropertyInfoAttribute.UpdateDynamicPropertiesEvent);
     68                        eventinfo.AddEventHandler(connectorModel.PluginModel.Plugin, new DynamicPropertiesChanged(connectorModel.PropertyTypeChangedOnPlugin));
     69                    }
     70                }
     71
     72                return workspacemodel;
    4673            }
    4774            finally
Note: See TracChangeset for help on using the changeset viewer.