コード例 #1
0
ファイル: LoaderForm.cs プロジェクト: KornnerStudios/VSOExp
        private async void hwLoadLayout_Click(object sender, EventArgs e)
        {
            if (hwOpenFileLayout.ShowDialog(this) == DialogResult.OK)
            {
                hwProgress.Visible = true;

                // load in the background as these files can be enormous and the parse can take a while
                var output = await Task.Factory.StartNew(() =>
                {
                    var layoutLoader = new LayoutLoader();
                    bool success     = layoutLoader.ParseFromFile(hwOpenFileLayout.FileName);
                    return(success ? layoutLoader.Result : null);
                });

                if (output == null)
                {
                    MessageBox.Show(this, "Failed to parse: " + hwOpenFileLayout.FileName, "Parse Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                hwProgress.Visible = false;

                var loForm = new LayoutForm(output);
                loForm.Text = hwOpenFileLayout.FileName;
                loForm.Show(this);
            }
        }
コード例 #2
0
ファイル: LoaderForm.cs プロジェクト: ishani/VSOExp
    private async void hwLoadLayout_Click(object sender, EventArgs e)
    {
      if (hwOpenFileLayout.ShowDialog() == DialogResult.OK)
      {
        hwProgress.Visible = true;

        // load in the background as these files can be enormous and the parse can take a while
        LayoutLoader layoutLoader = new LayoutLoader();
        await Task.Run(() => layoutLoader.ParseFromFile(hwOpenFileLayout.FileName));

        hwProgress.Visible = false;

        LayoutLoaderOutput llOutput = layoutLoader.Result;

        LayoutForm loForm = new LayoutForm(llOutput);
        loForm.Text = hwOpenFileLayout.FileName;
        loForm.Show();
      }
    }