Exemple #1
0
        /// <summary>
        /// When the edit form is closing, check to make sure the IP is unique.
        /// </summary>
        private void CheckForDupID(object sender, CancelEventArgs e)
        {
            VenueEditor editor = (VenueEditor)sender;

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

            Venue  ven = editor.GetVenue();
            string id  = ven.Identifier.ToLower(CultureInfo.InvariantCulture).Trim();

            // First check to see if the ID changed from the selected venue
            //  If it changed, we have to check against all of the venue IDs
            Venue original = editor.OriginalVenue;

            if (original.Identifier == null || original.Identifier.ToLower(CultureInfo.InvariantCulture).Trim() != id)
            {
                Venue dupIDVenue = null;

                // The IP has changed, so check to make sure it's not a dup
                foreach (ListViewItem item in list.Items)
                {
                    VenueState currentVenueState = (VenueState)item.Tag;
                    Venue      currentVen        = currentVenueState.Venue;

                    if (currentVen.Identifier.ToLower(CultureInfo.InvariantCulture).Trim() == id)
                    {
                        dupIDVenue = currentVen;
                        break;
                    }
                }

                // If the ID is a duplicate, show an error and prevent the dialog from closing
                if (dupIDVenue != null)
                {
                    RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture,
                                                                Strings.DuplicateOwnerText, dupIDVenue.Name), Strings.DuplicateOwnerTitle,
                                            MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                            (MessageBoxOptions)0);
                    e.Cancel = true;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// When the edit form is closing, check to make sure the IP is unique.
        /// </summary>
        private void CheckForDupIP(object sender, CancelEventArgs e)
        {
            VenueEditor editor = (VenueEditor)sender;

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

            Venue     ven = editor.GetVenue();
            IPAddress ip  = IPAddress.Parse(ven.IPAddress.Trim());

            // First check to see if the IP changed from the selected venue
            //  If it changed, we have to check against all of the venue IPs
            Venue original = editor.OriginalVenue;

            if (original.IPAddress == null || !IPAddress.Parse(original.IPAddress.Trim()).Equals(ip))
            {
                Venue dupIPVenue = null;

                // The IP has changed, so check to make sure it's not a dup
                foreach (ListViewItem item in list.Items)
                {
                    VenueState currentVenueState = (VenueState)item.Tag;
                    Venue      currentVen        = currentVenueState.Venue;
                    if (IPAddress.Parse(currentVen.IPAddress.Trim()).Equals(ip))
                    {
                        dupIPVenue = currentVen;
                        break;
                    }
                }

                // If the IP is a duplicate, show an error and prevent the dialog from closing
                if (dupIPVenue != null)
                {
                    RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture,
                                                                Strings.DuplicateIPAddressText, dupIPVenue.Name), Strings.DuplicateIpAddressTitle,
                                            MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                            (MessageBoxOptions)0);
                    e.Cancel = true;
                }
            }
        }
Exemple #3
0
        private void newBtn_Click(object sender, EventArgs e)
        {
            VenueEditor editor = new VenueEditor(new Venue());
            editor.Text = "New Venue";
            editor.Closing += new CancelEventHandler(CheckForDupIP);
            editor.Closing += new CancelEventHandler(CheckForDupID);
            DialogResult dr = editor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                // Get the new venue
                Venue venue = editor.GetVenue();

                // Store it
                StorageFile.AddVenue(venue);

                // Create the new LVI
                int imageIndex = AddVenueIcon(venue.Icon);

                // Add it to the list
                list.Items.Add (CreateLvi(venue, imageIndex));
            }
        }
Exemple #4
0
        private void editBtn_Click(object sender, EventArgs e)
        {
            Venue selectedVenue = (Venue)list.SelectedItems[0].Tag;
            VenueEditor editor = new VenueEditor(selectedVenue);
            editor.Text = "Edit Venue";
            editor.Closing += new CancelEventHandler(CheckForDupIP);
            editor.Closing += new CancelEventHandler(CheckForDupID);
            DialogResult dr = editor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                Venue editedVenue = editor.GetVenue();

                if (editedVenue.Identifier != selectedVenue.Identifier)
                {
                    // The venue identifier was edited, so we need to completely delete & re-add this venue
                    StorageFile.DeleteVenue(selectedVenue.Identifier);
                    StorageFile.AddVenue(editedVenue);
                }
                else
                {
                    StorageFile.UpdateVenue(editedVenue);
                }

                // Don't remove the image; it will screw up the images for all of the other venues
                // But we will check to see if the image has changed (if not, just use the old imageIndex)
                int imageIndex;
                if (editedVenue.Icon == selectedVenue.Icon)
                    imageIndex = list.SelectedItems[0].ImageIndex;
                else
                    imageIndex = AddVenueIcon(editedVenue.Icon);

                // Remove the old item
                list.Items.RemoveAt(list.SelectedIndices[0]);

                // Create and add the new item
                list.Items.Add (CreateLvi(editedVenue, imageIndex));
            }
        }