private void openErrorsButton_Click(object sender, EventArgs e)
        {
            var result = openErrorsFileDialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var fileName = openErrorsFileDialog.FileName;

            try
            {
                using (StreamReader file = File.OpenText(fileName))
                    using (JsonTextReader textReader = new JsonTextReader(file))
                    {
                        var serializer = new JsonSerializer();
                        maxErrors = serializer.Deserialize <List <double> >(textReader);
                    }

                BuildErrorDistribution();
            }
            catch (Exception err)
            {
                FormsUtil.ShowErrorMessage(err.ToString());
            }
        }
示例#2
0
        private void OpenRunFile(string fileName)
        {
            try
            {
                using (StreamReader file = File.OpenText(fileName))
                    using (JsonTextReader textReader = new JsonTextReader(file))
                    {
                        var serializer = JsonSerializer.Create(new JsonSerializerSettings
                        {
                            TypeNameHandling           = TypeNameHandling.All,
                            PreserveReferencesHandling = PreserveReferencesHandling.All
                        });
                        var run = (AlgorithmRun <TIn, TOut>)serializer.Deserialize(textReader, typeof(AlgorithmRun <TIn, TOut>));

                        var pathName = Path.GetFileNameWithoutExtension(fileName);
                        var runName  = pathName;

                        run.Name = runName;

                        controller.Inputs.Add(run.Input);
                        controller.Algorithms.Add(run.Algorithm);
                        controller.Runs.Add(run);

                        AddRunToTable(run);
                    }
            }
            catch (Exception err)
            {
                FormsUtil.ShowErrorMessage(err.ToString());
            }
        }
示例#3
0
        private void saveRunButton_Click(object sender, EventArgs e)
        {
            if (workloadTable.SelectedRows.Count == 1)
            {
                var result = saveRunDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string fileName = saveRunDialog.FileName;
                    try
                    {
                        var run = (AlgorithmRun <TIn, TOut>)workloadTable.SelectedRows[0].Cells["workloadTableRunColumn"].Value;

                        using (StreamWriter file = File.CreateText(fileName))
                            using (JsonTextWriter textWriter = new JsonTextWriter(file))
                            {
                                var serializer = JsonSerializer.Create(new JsonSerializerSettings
                                {
                                    TypeNameHandling           = TypeNameHandling.All,
                                    PreserveReferencesHandling = PreserveReferencesHandling.All
                                });
                                serializer.Serialize(textWriter, run, typeof(AlgorithmRun <TIn, TOut>));
                            }

                        run.Name = Path.GetFileNameWithoutExtension(fileName);
                    }
                    catch (Exception err)
                    {
                        FormsUtil.ShowErrorMessage(err.ToString());
                    }
                }
            }
        }
示例#4
0
        private void importInputButton_Click(object sender, EventArgs e)
        {
            var result = importRunDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string fileName = importRunDialog.FileName;

                try
                {
                    bool customName;
                    var  input = controller.ImportInput(fileName, out customName);

                    if (input != null)
                    {
                        if (!customName)
                        {
                            input.Name = Path.GetFileNameWithoutExtension(fileName);
                        }

                        AddAndSelectInput(input);
                        inputComboBox.SelectedItem = input;
                    }
                }
                catch (Exception err)
                {
                    FormsUtil.ShowErrorMessage(err.ToString());
                }
            }
        }
示例#5
0
        private void saveControllerButton_Click(object sender, EventArgs e)
        {
            var result = saveControllerDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string fileName = saveControllerDialog.FileName;
                try
                {
                    AlgorithmControllerConverter.SaveToFile(selectedAlgoController, fileName);
                    selectedAlgoController.Name = Path.GetFileNameWithoutExtension(fileName);
                }
                catch (Exception err)
                {
                    FormsUtil.ShowErrorMessage(err.ToString());
                }
            }
        }
示例#6
0
 private void OpenInputFile(string fileName)
 {
     try
     {
         using (StreamReader file = File.OpenText(fileName))
             using (JsonTextReader textReader = new JsonTextReader(file))
             {
                 var serializer = JsonSerializer.Create();
                 var input      = serializer.Deserialize <TIn>(textReader);
                 input.Name = Path.GetFileNameWithoutExtension(fileName);
                 AddAndSelectInput(input);
             }
     }
     catch (Exception err)
     {
         FormsUtil.ShowErrorMessage(err.ToString());
     }
 }
示例#7
0
        private void openControllerButton_Click(object sender, EventArgs e)
        {
            var result = openControllerDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                var fileName = openControllerDialog.FileName;
                try
                {
                    var controller = AlgorithmControllerConverter.LoadFromFile(fileName);

                    controller.Name = Path.GetFileNameWithoutExtension(fileName);
                    algoControllers.Add(controller);
                    controllerComboBox.SelectedItem = controller;
                }
                catch (Exception err)
                {
                    FormsUtil.ShowErrorMessage(err.ToString());
                }
            }
        }
示例#8
0
        private void saveInputButton_Click(object sender, EventArgs e)
        {
            var result = saveInputDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string fileName = saveInputDialog.FileName;
                try
                {
                    using (StreamWriter file = File.CreateText(fileName))
                        using (JsonTextWriter textWriter = new JsonTextWriter(file))
                        {
                            var serializer = JsonSerializer.Create();
                            serializer.Serialize(textWriter, CurrentInput);
                        }

                    CurrentInput.Name = Path.GetFileNameWithoutExtension(fileName);
                }
                catch (Exception err)
                {
                    FormsUtil.ShowErrorMessage(err.ToString());
                }
            }
        }