コード例 #1
0
        private void ButtonLoad_Click(object sender, EventArgs e)
        {
            VoronoiFile file;

            openFileDialog.ShowDialog();

            if (string.IsNullOrWhiteSpace(openFileDialog.FileName))
            {
                return;
            }

            using (var fileStream = openFileDialog.OpenFile())
            {
                using (var streamReader = new StreamReader(fileStream))
                {
                    var data = streamReader.ReadToEnd();
                    file = JsonConvert.DeserializeObject <VoronoiFile>(data);
                }
                fileStream.Close();
            }

            _height  = file.Height;
            _width   = file.Width;
            _session = new Session {
                Sites = file.Sites
            };

            textBoxHeight.Text = _height.ToString();
            textBoxWidth.Text  = _width.ToString();
            dataTableBindingSource.DataSource = Sites.Create(file.Sites);
            optionValues.Checked = true;
            optionRandom.Checked = false;
        }