Пример #1
0
        private void SaveAllCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            string exception, filePath;

            exception = filePath = string.Empty;
            if (!string.IsNullOrEmpty(BlockSchemePath))
            {
                if (File.Exists(BlockSchemePath))
                {
                    if ((filePath = OpenSaveClass.SaveDialog(ModelType.Scheme, string.Empty)) !=
                        string.Empty)
                    {
                        if (OpenSaveClass.SaveCommand(BlockSchemePath, filePath, out exception))
                        {
                            SaveModelFunction(filePath);
                        }
                        else
                        {
                            MessageBox.Show("Неможливо зберегти схему в файл внаслідок:\n" +
                                            exception);
                            SaveModelFunction(string.Empty);
                        }
                    }
                }
                else
                {
                    StateSwitcher(false);
                }
            }
        }
Пример #2
0
        private void SaveModelFunction(string blockSchemePath)
        {
            string filePath = string.Empty;

            if ((filePath = OpenSaveClass.SaveDialog(ModelType.Matrix, blockSchemePath)) !=
                string.Empty)
            {
                ModelItemsToSerialize modelItemsToSerialize = new ModelItemsToSerialize();
                modelItemsToSerialize.RowArray            = this.RowArray;
                modelItemsToSerialize.ModelVars           = this.ModelVars;
                modelItemsToSerialize.ErrorVars           = this.ErrorVars;
                modelItemsToSerialize.Results             = this.Results;
                modelItemsToSerialize.SubstitutionResults = this.SubstitutionResults;
                modelItemsToSerialize.SignalOut           = this.SignalOut;
                modelItemsToSerialize.SignalIn            = this.SignalIn;

                if (string.IsNullOrEmpty(blockSchemePath))
                {
                    modelItemsToSerialize.BlockSchemePath = string.Empty;
                }
                else if (File.Exists(blockSchemePath))
                {
                    modelItemsToSerialize.BlockSchemePath = blockSchemePath;
                }
                else
                {
                    modelItemsToSerialize.BlockSchemePath = string.Empty;
                    StateSwitcher(false);
                }
                string exception;
                if (!OpenSaveClass.SaveCommand(filePath, modelItemsToSerialize, out exception))
                {
                    MessageBox.Show("Неможливо зберегти модель в файл внаслідок:\n" + exception);
                }
                modelItemsToSerialize = null;
            }
        }