예제 #1
0
        private void PopulateDryingMaterialList()
        {
            this.listViewMaterials.Items.Clear();
            string typeFilterStr    = this.comboBoxTypes.SelectedItem.ToString();
            string userDefFilterStr = this.comboBoxUserDef.SelectedItem.ToString();

            if (typeFilterStr.Equals(UI.STR_ALL) && userDefFilterStr.Equals(UI.STR_ALL))
            {
                this.PopulateIt(DryingMaterialCatalog.GetInstance().GetDryingMaterialList());
            }
            else if (typeFilterStr.Equals(UI.STR_ALL) && !userDefFilterStr.Equals(UI.STR_ALL))
            {
                bool userDef = UI.GetUserDefinedAsBool(userDefFilterStr);
                this.PopulateIt(DryingMaterialCatalog.GetInstance().GetDryingMaterialList(userDef));
            }
            else if (!typeFilterStr.Equals(UI.STR_ALL) && userDefFilterStr.Equals(UI.STR_ALL))
            {
                MaterialType type = DryingMaterialsControl.GetDryingMaterialTypeAsEnum(typeFilterStr);
                this.PopulateIt(DryingMaterialCatalog.GetInstance().GetDryingMaterialList(type));
            }
            else
            {
                bool         userDef = UI.GetUserDefinedAsBool(userDefFilterStr);
                MaterialType type    = DryingMaterialsControl.GetDryingMaterialTypeAsEnum(typeFilterStr);
                this.PopulateIt(DryingMaterialCatalog.GetInstance().GetDryingMaterialList(userDef, type));
            }
        }
예제 #2
0
        public DryingMaterialsControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.inConstruction = true;

            this.comboBoxUserDef.Items.Add(UI.STR_ALL);
            this.comboBoxUserDef.Items.Add(UI.STR_USER_DEF_USER_DEF);
            this.comboBoxUserDef.Items.Add(UI.STR_USER_DEF_NOT_USER_DEF);
            this.comboBoxUserDef.SelectedIndex = 0;

            this.comboBoxTypes.Items.Add(UI.STR_ALL);
            this.comboBoxTypes.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_GENERIC_FOOD);
            this.comboBoxTypes.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_GENERIC_MATERIAL);
//         this.comboBoxTypes.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_SPECIAL_FOOD);
            this.comboBoxTypes.SelectedIndex = 0;

            this.PopulateDryingMaterialList();

            DryingMaterialCatalog.GetInstance().DryingMaterialAdded   += new DryingMaterialAddedEventHandler(DryingMaterialsControl_DryingMaterialAdded);
            DryingMaterialCatalog.GetInstance().DryingMaterialChanged += new DryingMaterialChangedEventHandler(DryingMaterialsControl_DryingMaterialChanged);
            DryingMaterialCatalog.GetInstance().DryingMaterialDeleted += new DryingMaterialDeletedEventHandler(DryingMaterialsControl_DryingMaterialDeleted);

            this.inConstruction = false;
        }
예제 #3
0
        public Flowsheet(NewProcessSettings newProcessSettings, FlowsheetPreferences flowsheetPrefs, ApplicationPreferences appPrefs)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.flowsheetPrefs = flowsheetPrefs;
            this.appPrefs       = appPrefs;

            DryingGas dg = DryingGasCatalog.GetInstance().GetDryingGas(newProcessSettings.DryingGasName);

            if (dg == null)
            {
                //string message = "You need to set a drying gas in Materials / New Process Settings first!";
                //MessageBox.Show(message, "New Flowsheet Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dg = DryingGasCatalog.GetInstance().GetDryingGas("Air");
            }

            DryingMaterial dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial(newProcessSettings.DryingMaterialName);

            if (dm == null)
            {
                string message = "You need to choose a drying material for the new flowsheet to be created first! (go to Materials / New Flowsheet Settings)";
                MessageBox.Show(message, "New Flowsheet Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.evapAndDryingSystem = new EvaporationAndDryingSystem(UI.NEW_SYSTEM, dm, dg);

            this.connectionManager = new ConnectionManager(this);
            this.customEditor      = new ProsimoUI.CustomEditor.CustomEditor(this);

            Init();
        }
예제 #4
0
        public void PersistMaterialCatalog(string fileName, string bakFileName)
        {
            FileStream fs = null;

            try {
                if (File.Exists(fileName))
                {
                    File.Copy(fileName, bakFileName, true);
                    File.Delete(fileName);
                }
                fs = new FileStream(fileName, FileMode.Create);

                IList customMaterials = DryingMaterialCatalog.GetInstance().GetDryingMaterialList(true);

                SoapFormatter serializer = new SoapFormatter();
                //            BinaryFormatter serializer = new BinaryFormatter();
                serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
                serializer.Serialize(fs, customMaterials);
            }
            catch (Exception e) {
                string message = e.ToString();
                MessageBox.Show(message, "Error Saving Material Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally {
                if (fs != null)
                {
                    fs.Flush();
                    fs.Close();
                }
            }
        }
예제 #5
0
        public Flowsheet(NewSystemPreferences newSystemPrefs, EvaporationAndDryingSystem system)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.newSystemPrefs = newSystemPrefs;
            UnitSystemCatalog catalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();
            UnitSystem        us      = catalog.Get("SI-2");

            UnitSystemService.GetInstance().CurrentUnitSystem = us;
            this.currentUnitSystemName = us.Name;

            this.MultipleSelection = false;
            this.Activity          = FlowsheetActivity.Default;

            if (system == null)
            {
                DryingGas dg = DryingGasCatalog.GetInstance().GetDryingGas(newSystemPrefs.DryingGasName);
                if (dg == null)
                {
                    dg = DryingGasCatalog.GetInstance().GetDryingGas("Air");
                }

                DryingMaterial dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial(newSystemPrefs.DryingMaterialName);
                if (dm == null)
                {
                    dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial("Generic Material");
                }

                this.evapAndDryingSystem = new EvaporationAndDryingSystem("New System", dm, dg);
            }
            else
            {
                this.evapAndDryingSystem = system;
            }

            this.evapAndDryingSystem.SystemChanged      += new SystemChangedEventHandler(evapAndDryingSystem_SystemChanged);
            this.evapAndDryingSystem.CalculationStarted += new CalculationStartedEventHandler(evapAndDryingSystem_CalculationStarted);
            this.evapAndDryingSystem.CalculationEnded   += new CalculationEndedEventHandler(evapAndDryingSystem_CalculationEnded);

            this.connectionManager = new ConnectionManager(this);
            this.customEditor      = new ProsimoUI.CustomEditor.CustomEditor(this);
            this.streamManager     = new StreamManager(this);
            this.unitOpManager     = new UnitOpManager(this);
            UI ui = new UI();

            this.BackColor     = ui.FLOWSHEET_COLOR;
            this.NumericFormat = NumericFormat.FixedPoint;
            this.DecimalPlaces = "3";
            this.Version       = new FlowsheetVersion();

            this.KeyDown += new KeyEventHandler(Flowsheet_KeyDown);
            this.KeyUp   += new KeyEventHandler(Flowsheet_KeyUp);
            UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(Flowsheet_CurrentUnitSystemChanged);
            this.IsDirty = false;
        }
예제 #6
0
 private void Duplicate()
 {
     if (this.dryingMaterialsControl.ListViewMaterials.SelectedItems.Count == 1)
     {
         DryingMaterial dryingMaterial = this.dryingMaterialsControl.GetSelectedDryingMaterial();
         DryingMaterial dm             = (DryingMaterial)dryingMaterial.Clone();
         dm.IsUserDefined = true;
         dm.Name          = "Copy of " + dryingMaterial.Name;
         DryingMaterialCatalog.GetInstance().AddDryingMaterial(dm);
     }
 }
예제 #7
0
        public DryingMaterial GetSelectedDryingMaterial()
        {
            DryingMaterial dm = null;

            if (this.listViewMaterials.SelectedItems.Count == 1)
            {
                ListViewItem lvi = (ListViewItem)this.listViewMaterials.SelectedItems[0];
                ListViewItem.ListViewSubItem lvsi = (ListViewItem.ListViewSubItem)lvi.SubItems[0];
                dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial(lvsi.Text);
            }
            return(dm);
        }
예제 #8
0
               fs.Close();
            }
         }
      }

      public void UnpersistAppPreferences(MainForm mainForm)
      {
         string fileName = mainForm.ExePathName + MainForm.APP_PREFS;
         Stream stream = null;
         try
         {
            stream = new FileStream(fileName, FileMode.Open);
            SoapFormatter serializer = new SoapFormatter();
            serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
            ArrayList items = (ArrayList)serializer.Deserialize(stream);

            IEnumerator e = items.GetEnumerator();
            while (e.MoveNext())
            {
               object obj = e.Current;
            
               if (obj is UIPreferences)
               {
                  UIPreferences uiPrefs = (UIPreferences)obj;
                  uiPrefs.SetObjectData(uiPrefs.SerializationInfo, uiPrefs.StreamingContext);
                  mainForm.Location = uiPrefs.MainFormLocation;
                  mainForm.Size = uiPrefs.MainFormSize;
                  mainForm.WindowState = uiPrefs.MainFormWindowState;
                  mainForm.ToolboxVisible = uiPrefs.ToolboxVisible;
                  mainForm.ToolboxLocation = uiPrefs.ToolboxLocation;
               }
               else if (obj is NewSystemPreferences)
               {
                  NewSystemPreferences newSysPrefs = (NewSystemPreferences)obj;
                  newSysPrefs.SetObjectData(newSysPrefs.SerializationInfo, newSysPrefs.StreamingContext);
                  if (!DryingGasCatalog.GetInstance().IsInCatalog(newSysPrefs.DryingGasName))
                  {
                     newSysPrefs.DryingGasName = DryingGasCatalog.GetInstance().GetDefaultDryingGas().Name;
                  }
                  if (!DryingMaterialCatalog.GetInstance().IsInCatalog(newSysPrefs.DryingMaterialName))
                  {
                     newSysPrefs.DryingMaterialName = DryingMaterialCatalog.GetInstance().GetDefaultDryingMaterial().Name;
                  }
                  mainForm.NewSystemPrefs = newSysPrefs;
               }
            }
         }
         catch (Exception)
         {
            NewSystemPreferences newSysPrefs = new NewSystemPreferences();
            mainForm.NewSystemPrefs = newSysPrefs;
         }
         finally 
예제 #9
0
        public Flowsheet(NewProcessSettings newProcessSettings, ApplicationPreferences appPrefs, EvaporationAndDryingSystem system)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.newProcessSettings = newProcessSettings;
            this.appPrefs           = appPrefs;

            this.MultipleSelection = false;
            SetFlowsheetActivity(FlowsheetActivity.Default);

            if (system == null)
            {
                DryingGas dg = DryingGasCatalog.GetInstance().GetDryingGas(newProcessSettings.DryingGasName);
                if (dg == null)
                {
                    //               string message = "You need to set a drying gas in Materials / New Process Settings first!";
                    //               MessageBox.Show(message, "New Flowsheet Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dg = DryingGasCatalog.GetInstance().GetDryingGas("Air");
                }

                DryingMaterial dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial(newProcessSettings.DryingMaterialName);
                if (dm == null)
                {
                    string message = "You need to choose a drying material for the new flowsheet to be created first! (go to Materials / New Flowsheet Settings)";
                    MessageBox.Show(message, "New Flowsheet Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                this.evapAndDryingSystem = new EvaporationAndDryingSystem(UI.NEW_SYSTEM, dm, dg);
            }
            else
            {
                this.evapAndDryingSystem = system;
            }

            this.evapAndDryingSystem.SystemChanged      += new SystemChangedEventHandler(evapAndDryingSystem_SystemChanged);
            this.evapAndDryingSystem.CalculationStarted += new CalculationStartedEventHandler(evapAndDryingSystem_CalculationStarted);
            this.evapAndDryingSystem.CalculationEnded   += new CalculationEndedEventHandler(evapAndDryingSystem_CalculationEnded);
            this.evapAndDryingSystem.NameChanged        += new NameChangedEventHandler(evapAndDryingSystem_NameChanged);

            this.connectionManager = new ConnectionManager(this);
            this.customEditor      = new ProsimoUI.CustomEditor.CustomEditor(this);
            this.streamManager     = new StreamManager(this);
            this.unitOpManager     = new UnitOpManager(this);
            this.BackColor         = Color.White;
            this.Version           = new FlowsheetVersion();

            this.IsDirty = false;
        }
예제 #10
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     DryingMaterialCatalog.GetInstance().DryingMaterialAdded   -= new DryingMaterialAddedEventHandler(DryingMaterialsControl_DryingMaterialAdded);
     DryingMaterialCatalog.GetInstance().DryingMaterialChanged -= new DryingMaterialChangedEventHandler(DryingMaterialsControl_DryingMaterialChanged);
     DryingMaterialCatalog.GetInstance().DryingMaterialDeleted -= new DryingMaterialDeletedEventHandler(DryingMaterialsControl_DryingMaterialDeleted);
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
     }
     base.Dispose(disposing);
 }
예제 #11
0
        public bool UnpersistMaterialCatalog(string fileName, string bakFileName)
        {
            bool   ok     = true;
            Stream stream = null;

            try
            {
                if (File.Exists(fileName) || File.Exists(bakFileName))
                {
                    if (File.Exists(fileName))
                    {
                        stream = new FileStream(fileName, FileMode.Open);
                    }
                    else if (File.Exists(bakFileName))
                    {
                        stream = new FileStream(bakFileName, FileMode.Open);
                    }
                    SoapFormatter serializer = new SoapFormatter();
//               BinaryFormatter serializer = new BinaryFormatter();
//               serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
                    ArrayList   customMaterials = (ArrayList)serializer.Deserialize(stream);
                    IEnumerator e = customMaterials.GetEnumerator();
                    while (e.MoveNext())
                    {
                        DryingMaterial dm = (DryingMaterial)e.Current;
                        dm.SetObjectData();
                        DryingMaterialCatalog.GetInstance().AddDryingMaterial(dm);
                    }
                }
            }
            catch (Exception e)
            {
                ok = false;
                string message = e.ToString();
                MessageBox.Show(message, "Error Retrieving Material Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
            return(ok);
        }
예제 #12
0
        public void PersistMaterialCatalog(string fileName, string bakFileName)
        {
            FileStream fs = null;

            try
            {
                if (File.Exists(fileName))
                {
                    File.Copy(fileName, bakFileName, true);
                    File.Delete(fileName);
                }
                fs = new FileStream(fileName, FileMode.Create);

                ArrayList   customMaterials = new ArrayList();
                IEnumerator e = DryingMaterialCatalog.GetInstance().GetDryingMaterialList().GetEnumerator();
                while (e.MoveNext())
                {
                    DryingMaterial dm = (DryingMaterial)e.Current;
                    if (dm.IsUserDefined)
                    {
                        customMaterials.Add(dm);
                    }
                }

                SoapFormatter serializer = new SoapFormatter();
//            BinaryFormatter serializer = new BinaryFormatter();
//            serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
                serializer.Serialize(fs, customMaterials);
            }
            catch (Exception e)
            {
                string message = e.ToString();
                MessageBox.Show(message, "Error Saving Material Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Flush();
                    fs.Close();
                }
            }
        }
예제 #13
0
        public void DeleteSelectedElements()
        {
            ArrayList toDeleteList = new ArrayList();

            IEnumerator en = this.listViewMaterials.SelectedItems.GetEnumerator();

            while (en.MoveNext())
            {
                ListViewItem lvi = (ListViewItem)en.Current;
                ListViewItem.ListViewSubItem lvsi = (ListViewItem.ListViewSubItem)lvi.SubItems[0];
                toDeleteList.Add(lvsi.Text);
            }

            IEnumerator en2 = toDeleteList.GetEnumerator();

            while (en2.MoveNext())
            {
                string name = (string)en2.Current;
                DryingMaterialCatalog.GetInstance().RemoveDryingMaterial(name);
            }
        }
예제 #14
0
        public AddOrEditDryingMaterialForm(DryingMaterial dryingMaterial, INumericFormat numericFormat)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.inConstruction = true;
            this.iNumericFormat = numericFormat;

            // populate the moisture substance combobox
            IEnumerator en = SubstanceCatalog.GetInstance().GetMoistureSubstanceList().GetEnumerator();

            while (en.MoveNext())
            {
                Substance substance = (Substance)en.Current;
                this.comboBoxMoistureSubstance.Items.Add(substance);
            }
            this.comboBoxMoistureSubstance.SelectedIndex = 0;

            if (dryingMaterial == null)
            {
                // new
                this.isNew = true;
                this.Text  = "New Drying Material";

                this.dryingMaterialCache = new DryingMaterialCache(DryingMaterialCatalog.GetInstance());
                this.textBoxName.Text    = "New Drying Material";

                // populate the material type combobox
                this.comboBoxType.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_GENERIC_MATERIAL);
                this.comboBoxType.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_GENERIC_FOOD);
//            this.comboBoxType.Items.Add(DryingMaterialsControl.STR_MAT_TYPE_SPECIAL_FOOD);
                this.comboBoxType.SelectedIndex = 0;

                string       matTypeStr  = this.comboBoxType.SelectedItem as string;
                MaterialType matTypeEnum = DryingMaterialsControl.GetDryingMaterialTypeAsEnum(matTypeStr);
                this.dryingMaterialCache.SetMaterialType(matTypeEnum);

                Substance subst = this.comboBoxMoistureSubstance.SelectedItem as Substance;
                this.dryingMaterialCache.MoistureSubstance = subst;
            }
            else
            {
                // edit
                this.isNew = false;
                this.Text  = "Edit Drying Material";

                this.dryingMaterialCache = new DryingMaterialCache(dryingMaterial, DryingMaterialCatalog.GetInstance());
                this.textBoxName.Text    = this.dryingMaterialCache.Name;

                // populate the material type combobox
                this.comboBoxType.Items.Add(DryingMaterialsControl.GetDryingMaterialTypeAsString(this.dryingMaterialCache.MaterialType));
                this.comboBoxType.SelectedIndex             = 0;
                this.comboBoxMoistureSubstance.SelectedItem = this.dryingMaterialCache.MoistureSubstance;
            }

            this.labelSpecificHeat.InitializeVariable(this.dryingMaterialCache.SpecificHeatOfAbsoluteDryMaterial);
            this.textBoxSpecificHeat.InitializeVariable(numericFormat, this.dryingMaterialCache.SpecificHeatOfAbsoluteDryMaterial);

            this.substancesControl.SubstancesToShow = SubstancesToShow.Material;
            this.dmComponentsControl.SetMaterialComponents(this.dryingMaterialCache, numericFormat);
            this.UpdateTheUI(this.dryingMaterialCache.MaterialType);

            this.dryingMaterialCache.MaterialTypeChanged      += new MaterialTypeChangedEventHandler(dryingMaterialCache_MaterialTypeChanged);
            this.dryingMaterialCache.MoistureSubstanceChanged += new MoistureSubstanceChangedEventHandler(dryingMaterialCache_MoistureSubstanceChanged);
            this.substancesControl.ListViewSubstances.SelectedIndexChanged += new EventHandler(ListViewSubstances_SelectedIndexChanged);

            this.inConstruction = false;
        }