Exemplo n.º 1
0
 private async void SettingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dialog = new AnnotationConfigurationDialog())
     {
         dialog.StartPosition = FormStartPosition.CenterParent;
         dialog.Setup(this._annotationConfig);
         var dialogResult = dialog.ShowDialog(this);
         if (dialogResult == DialogResult.OK)
         {
             await this._annotationPackageProvider.SetAnnotationConfigAsync(this._annotationConfig);
         }
     }
 }
Exemplo n.º 2
0
        public Main()
        {
            this.StartPosition = FormStartPosition.CenterScreen;

            try
            {
                this._annotationPackageProvider = new AmazonAnnotationPackageProvider();
            }
            catch (TaskCanceledException)
            {
                MessageBox.Show("The local database took too long to respond.\r\n" +
                                "Make sure your config is correctly setup. Are MinIO and your local DynamoDB running?\r\n" +
                                "Refer to the README.md for further information on how to correctly setup a local database.",
                                "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Load += (s, e) => this.Close();
                return;
            }
            catch (Exception)
            {
                MessageBox.Show("The configuration is invalid", "Configuration error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Load += (s, e) => this.Close();
                return;
            }

            this._annotationConfig = this._annotationPackageProvider.GetAnnotationConfigAsync().GetAwaiter().GetResult();
            if (this._annotationConfig == null)
            {
                this._annotationConfig = new AnnotationConfig();

                using (var configurationDialog = new AnnotationConfigurationDialog())
                {
                    configurationDialog.Setup(this._annotationConfig);
                    var dialogResult = configurationDialog.ShowDialog();

                    if (dialogResult == DialogResult.OK)
                    {
                        this._annotationPackageProvider.SetAnnotationConfigAsync(this._annotationConfig);
                    }
                    else
                    {
                        this.Load += (s, e) => this.Close();
                        return;
                    }
                }
            }

            this.InitializeComponent();

            this.Text = $"Alturos Image Annotation {Application.ProductVersion}";
            this.downloadControl.Dock = DockStyle.Fill;

            this.annotationPackageListControl.Setup(this._annotationPackageProvider);
            this.annotationImageListControl.Setup(this._annotationPackageProvider);

            this.autoplaceAnnotationsToolStripMenuItem.Checked = true;

            this.annotationDrawControl.AutoplaceAnnotations = true;
            this.annotationDrawControl.SetObjectClasses(this._annotationConfig.ObjectClasses);
            this.annotationDrawControl.SetLabelsVisible(false);

            this.tagEditControl.SetConfig(this._annotationConfig);
        }