Beispiel #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);
                }
            }
        }
Beispiel #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;
            }
        }
Beispiel #3
0
        private void OpenModelCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            string exception;
            ModelItemsToSerialize modelItemsToSerialize =
                (ModelItemsToSerialize)OpenSaveClass.OpenDialog(ModelType.Matrix, out exception);

            if (modelItemsToSerialize == null)
            {
                if (!string.IsNullOrEmpty(exception))
                {
                    MessageBox.Show("Неможливо відкрити файл моделі внаслідок:\n" + exception);
                }
                return;
            }

            this.RowArray            = modelItemsToSerialize.RowArray;
            this.ModelVars           = modelItemsToSerialize.ModelVars;
            this.ErrorVars           = modelItemsToSerialize.ErrorVars;
            this.Results             = modelItemsToSerialize.Results;
            this.SubstitutionResults = modelItemsToSerialize.SubstitutionResults;
            this.BlockSchemePath     = modelItemsToSerialize.BlockSchemePath;
            this.SignalOut           = modelItemsToSerialize.SignalOut;
            this.SignalIn            = modelItemsToSerialize.SignalIn;

            modelItemsToSerialize.Clear();
            modelItemsToSerialize = null;

            int arraySize = RowArray.Length, count = dataTable.Columns.Count;

            if (arraySize > count)
            {
                for (int i = count; i < arraySize; i++)
                {
                    column         = new DataGridTextColumn();
                    column.Header  = Convert.ToString(i + 1);
                    column.Binding = new Binding("Row[" + i + "]");
                    dataTable.Columns.Add(column);
                }
            }
            else if (arraySize < count)
            {
                for (int i = count - 1; i >= arraySize; i--)
                {
                    dataTable.Columns.RemoveAt(i);
                }
            }

            dataTable.ItemsSource     = null;
            dataTableXB.ItemsSource   = null;
            ModelVarSubst.ItemsSource = null;
            ErrorVarSubst.ItemsSource = null;
            dataTable.ItemsSource     = RowArray;
            dataTableXB.ItemsSource   = RowArray;
            ModelVarSubst.ItemsSource = ModelVars;
            ErrorVarSubst.ItemsSource = ErrorVars;

            if ((!string.IsNullOrEmpty(this.BlockSchemePath)) && (File.Exists(BlockSchemePath)))
            {
                StateSwitcher(true);
            }
            else
            {
                StateSwitcher(false);
            }

            if (blockSchemeWindow != null)
            {
                blockSchemeWindow.WindowDisposal();
                blockSchemeWindow = null;
            }

            determinantTextBox.Clear();
            substitutionTextBox.Clear();

            determinantTextBox.Text  = ResultFormation();
            substitutionTextBox.Text = SubstResFormation();

            ButtonsReset();
        }