Beispiel #1
0
        // Scopes
        private void btnScopesSave_Click(object sender, EventArgs e)
        {
            // Valiations:
            // TODO check for valid float values
            if (tbScopeManufacturer.Text.Length == 0)
            {
                errorProvider.SetError(tbScopeManufacturer, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbScopeManufacturer, "");
            }

            if (tbScopeName.Text.Length == 0)
            {
                errorProvider.SetError(tbScopeName, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbScopeName, "");
            }

            if (tbScopeAperture.Text.Length == 0)
            {
                errorProvider.SetError(tbScopeAperture, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbScopeAperture, "");
            }

            if (tbScopeFocalLength.Text.Length == 0)
            {
                errorProvider.SetError(tbScopeFocalLength, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbScopeFocalLength, "");
            }

            if (tbScopeCentralObstructionDiameter.Text.Length == 0)
            {
                errorProvider.SetError(tbScopeCentralObstructionDiameter, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbScopeCentralObstructionDiameter, "");
            }

            if (!rbScopeRoboticYes.Checked && !rbScopeRoboticNo.Checked)
            {
                errorProvider.SetError(rbScopeRoboticNo, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(rbScopeRoboticNo, "");
            }

            if (cbScopeMountType.SelectedIndex == -1)
            {
                errorProvider.SetError(cbScopeMountType, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(cbScopeMountType, "");
            }

            // Save new/changes:

            int    id           = 0;
            string manufacturer = tbScopeManufacturer.Text;
            string name         = tbScopeName.Text;
            float  aperture     = float.Parse(tbScopeAperture.Text);
            float  focalLength  = float.Parse(tbScopeFocalLength.Text);
            float  centralObstructionDiameter = float.Parse(tbScopeCentralObstructionDiameter.Text);
            bool   robotic = rbScopeRoboticYes.Checked;

            Scope.MountTypes mountType = (Scope.MountTypes)cbScopeMountType.SelectedIndex;

            if (emScopes == EditingModes.Add)
            {
                id = 0;
            }
            else
            {
                id = currentScope.Id;
            }

            Scope candidate = new Scope(id, manufacturer, name, aperture, focalLength, centralObstructionDiameter, robotic, mountType);

            if (emScopes == EditingModes.Add)
            {
                id = ScopeController.AddScope(candidate);
            }
            else
            {
                ScopeController.EditScope(id, candidate);
            }

            // Reload data:

            lblStatus.Text = "Issuing scopes saving command... ";
            currentScope   = ScopeController.GetScopes(new List <int>()
            {
                id
            })[0];
            LoadScopeData(currentScope);
            PrepareDataLists();
            lblStatus.Text += "Complete.";
        }
Beispiel #2
0
        private void ClearData()
        {
            listCameras       = CameraController.GetCameras();
            listCatalogues    = CatalogueController.GetCatalogues();
            listColorSpaces   = ColorSpaceController.GetColorSpaces();
            listFileFormats   = FileFormatController.GetFileFormats();
            listOptics        = OpticsController.GetOptics();
            listPhotographers = PhotographerController.GetPhotographers();
            listScopes        = ScopeController.GetScopes();
            listSites         = SiteController.GetSites();

            tbCollectionId.Text = "(adding)";
            tbDateTime.Text     = "";
            tbComments.Text     = "";
            tbFile.Text         = "";
            tbMetadataFile.Text = "";
            tbObjectId.Text     = "";
            tbObjectTitle.Text  = "";
            tbResolutionX.Text  = "";
            tbResolutionY.Text  = "";
            tbTotalFrames.Value = 1;

            cbCamera.Items.Clear();
            foreach (var item in listCameras)
            {
                cbCamera.Items.Add(item.LongName);
            }

            cbCatalogue.Items.Clear();
            foreach (var item in listCatalogues)
            {
                cbCatalogue.Items.Add(item.LongName);
            }

            cbColorSpace.Items.Clear();
            foreach (var item in listColorSpaces)
            {
                cbColorSpace.Items.Add(item.Name);
            }

            cbFileFormat.Items.Clear();
            foreach (var item in listFileFormats)
            {
                cbFileFormat.Items.Add(item.LongName);
            }

            cbPhotographer.Items.Clear();
            foreach (var item in listPhotographers)
            {
                cbPhotographer.Items.Add(item.GetInformalName());
            }

            cbScope.Items.Clear();
            foreach (var item in listScopes)
            {
                cbScope.Items.Add(item.GetScopeName());
            }

            clbOptics.Items.Clear();
            foreach (var item in listOptics)
            {
                clbOptics.Items.Add(item.Id + "|  " + item.GetOpticName());
            }

            cbSite.Items.Clear();
            foreach (var item in listSites)
            {
                cbSite.Items.Add(item.Name);
            }

            lblStatus.Text = "Loaded all assets.";
        }
Beispiel #3
0
        void PrepareDataLists()
        {
            // Populate all hard-coded combo-box values.

            cbOpticType.Items.Clear();
            foreach (var item in Enum.GetValues(typeof(Optic.OpticTypes)))
            {
                cbOpticType.Items.Add(item);
            }

            cbScopeMountType.Items.Clear();
            foreach (var item in Enum.GetValues(typeof(Scope.MountTypes)))
            {
                cbScopeMountType.Items.Add(item);
            }

            cbSiteLongtitudeType.Items.Clear();
            foreach (var item in Enum.GetValues(typeof(Site.LongtitudeTypes)))
            {
                cbSiteLongtitudeType.Items.Add(item);
            }

            cbSiteLatitudeType.Items.Clear();
            foreach (var item in Enum.GetValues(typeof(Site.LatitudeTypes)))
            {
                cbSiteLatitudeType.Items.Add(item);
            }

            // Query database for all values.
            listCameras       = CameraController.GetCameras();
            listCatalogues    = CatalogueController.GetCatalogues();
            listColorSpaces   = ColorSpaceController.GetColorSpaces();
            listFileFormats   = FileFormatController.GetFileFormats();
            listOptics        = OpticsController.GetOptics();
            listPhotographers = PhotographerController.GetPhotographers();
            listScopes        = ScopeController.GetScopes();
            listSites         = SiteController.GetSites();

            // Populate list boxes.
            lbCameras.Items.Clear();
            foreach (var item in listCameras)
            {
                lbCameras.Items.Add(item.Id + " " + item.LongName + " " + (item.MaxResolution.Width * item.MaxResolution.Height / 1000000).ToString() + "MP");
            }

            lbCatalogues.Items.Clear();
            foreach (var item in listCatalogues)
            {
                lbCatalogues.Items.Add(item.Id + " " + item.LongName);
            }

            lbColorSpaces.Items.Clear();
            foreach (var item in listColorSpaces)
            {
                lbColorSpaces.Items.Add(item.Id + " " + item.Name);
            }

            lbFileFormats.Items.Clear();
            foreach (var item in listFileFormats)
            {
                lbFileFormats.Items.Add(item.Id + " " + item.LongName);
            }

            lbOptics.Items.Clear();
            foreach (var item in listOptics)
            {
                lbOptics.Items.Add(item.Id + " " + item.Value + " " + item.OpticType.ToString());
            }

            lbPhotographers.Items.Clear();
            foreach (var item in listPhotographers)
            {
                lbPhotographers.Items.Add(item.Id + " " + item.LastName + ", " + item.FirstName);
            }

            lbScopes.Items.Clear();
            foreach (var item in listScopes)
            {
                lbScopes.Items.Add(item.Id + " " + item.Manufacturer + " " + item.Name);
            }

            lbSites.Items.Clear();
            foreach (var item in listSites)
            {
                lbSites.Items.Add(item.Id + " " + item.Name);
            }

            // Populate specific database fields for every tab.

            cbCamerasColorSpaces.Items.Clear();
            foreach (var item in listColorSpaces)
            {
                cbCamerasColorSpaces.Items.Add(item.Name);
            }
        }