Exemple #1
0
        public bool UnpersistUnitSystemCatalog(string fileName)
        {
            bool ok = true;

            try {
                if (!File.Exists(fileName))
                {
                    fileName = GetBackupFileName(fileName);
                }

                if (File.Exists(fileName))
                {
                    ArrayList customUnitList = (ArrayList)UnpersistFile(fileName);

                    UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();

                    foreach (UnitSystem us in customUnitList)
                    {
                        us.SetObjectData();
                        unitSystemCatalog.Add(us);
                    }
                }
            }
            catch (Exception e) {
                ok = false;
                string message = e.ToString();
                MessageBox.Show(message, "Error Retrieving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(ok);
        }
Exemple #2
0
        public UnitSystemsControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            unitSystemCtrl = new UnitSystemControl();
            this.Controls.Add(this.unitSystemCtrl);
            this.unitSystemCtrl.Location = new Point(160, 5);

            IList       unitSystems = UnitSystemService.GetInstance().GetUnitSystemCatalog().GetList();
            IEnumerator e           = unitSystems.GetEnumerator();

            while (e.MoveNext())
            {
                this.listBoxUnitSystems.Items.Add((UnitSystem)e.Current);
            }
            this.listBoxUnitSystems.SetSelected(0, true);

            this.UpdateUnitSystemUI();
            UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();

            unitSystemCatalog.UnitSystemAdded   += new UnitSystemAddedEventHandler(unitSystemCatalog_UnitSystemAdded);
            unitSystemCatalog.UnitSystemDeleted += new UnitSystemDeletedEventHandler(unitSystemCatalog_UnitSystemDeleted);
            unitSystemCatalog.UnitSystemChanged += new UnitSystemChangedEventHandler(unitSystemCatalog_UnitSystemChanged);
        }
Exemple #3
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;
        }
Exemple #4
0
        public void InitializeCurrentUnitSystem(string name)
        {
            UnitSystemCatalog catalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();
            UnitSystem        us      = catalog.Get(name);

            if (us != null)
            {
                UnitSystemService.GetInstance().CurrentUnitSystem = us;
            }
        }
Exemple #5
0
        public bool UnpersistUnitSystemCatalog(string fileName)
        {
            bool ok = true;

            //Stream stream = null;
            try {
                if (!File.Exists(fileName))
                {
                    fileName = GetBackupFileName(fileName);
                }

                if (File.Exists(fileName))
                {
                    //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;


                    //IFormatter serializer = GetPersistenceSerializer();
                    //ArrayList customUnitList = (ArrayList)serializer.Deserialize(stream);
                    ArrayList customUnitList = (ArrayList)UnpersistFile(fileName);

                    //IEnumerator e = customUnitSystems.GetEnumerator();
                    //while (e.MoveNext()) {
                    //   UnitSystem us = (UnitSystem)e.Current;
                    //   us.SetObjectData(us.SerializationInfo, us.StreamingContext);

                    UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();

                    foreach (UnitSystem us in customUnitList)
                    {
                        us.SetObjectData();
                        unitSystemCatalog.Add(us);
                    }
                }
            }
            catch (Exception e) {
                ok = false;
                string message = e.ToString();
                MessageBox.Show(message, "Error Retrieving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            //finally {
            //   if (stream != null)
            //      stream.Close();
            //}
            return(ok);
        }
Exemple #6
0
        public void InitializeCurrentUnitSystem()
        {
            UnitSystemCatalog catalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();
            UnitSystem        us      = catalog.Get(this.currentUnitSystemName);

            if (us != null)
            {
                UnitSystemService.GetInstance().CurrentUnitSystem = us;
            }
            else
            {
                UnitSystem us2 = catalog.Get("SI-2");
                UnitSystemService.GetInstance().CurrentUnitSystem = us2;
            }
        }
Exemple #7
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();

            unitSystemCatalog.UnitSystemAdded   -= new UnitSystemAddedEventHandler(unitSystemCatalog_UnitSystemAdded);
            unitSystemCatalog.UnitSystemDeleted -= new UnitSystemDeletedEventHandler(unitSystemCatalog_UnitSystemDeleted);
            unitSystemCatalog.UnitSystemChanged -= new UnitSystemChangedEventHandler(unitSystemCatalog_UnitSystemChanged);
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Exemple #8
0
        public bool UnpersistUnitSystemCatalog(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();
                    serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
                    UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();
                    ArrayList         customUnitSystems = (ArrayList)serializer.Deserialize(stream);
                    IEnumerator       e = customUnitSystems.GetEnumerator();
                    while (e.MoveNext())
                    {
                        UnitSystem us = (UnitSystem)e.Current;
                        us.SetObjectData(us.SerializationInfo, us.StreamingContext);
                        unitSystemCatalog.Add(us);
                    }
                }
            }
            catch (Exception e)
            {
                ok = false;
                string message = e.ToString();
                MessageBox.Show(message, "Error Retrieving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
            return(ok);
        }