Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 2
0
        private void editBtn_Click(object sender, EventArgs e)
        {
            VenueState  selectedVenueState = (VenueState)list.SelectedItems[0].Tag;
            VenueEditor editor             = new VenueEditor(selectedVenueState);

            editor.Text     = Strings.EditVenue;
            editor.Closing += new CancelEventHandler(CheckForDupIP);
            editor.Closing += new CancelEventHandler(CheckForDupID);
            DialogResult dr = editor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                VenueState newVenueState = editor.GetVenueState();

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

                // 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 (newVenueState.Venue.Icon == selectedVenueState.Venue.Icon)
                {
                    imageIndex = list.SelectedItems[0].ImageIndex;
                }
                else
                {
                    imageIndex = AddVenueIcon(newVenueState.Venue.Icon);
                }

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

                // Create and add the new item
                list.Items.Add(CreateLvi(newVenueState, imageIndex));
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }
Ejemplo n.º 4
0
        private void newBtn_Click(object sender, EventArgs e)
        {
            VenueEditor editor = new VenueEditor(new VenueState());

            editor.Text     = Strings.NewVenue;
            editor.Closing += new CancelEventHandler(CheckForDupIP);
            editor.Closing += new CancelEventHandler(CheckForDupID);
            DialogResult dr = editor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                // Get the new venue
                VenueState venueState = editor.GetVenueState();

                // Store it
                StorageFile.AddVenue(venueState);

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

                // Add it to the list
                list.Items.Add(CreateLvi(venueState, imageIndex));
            }
        }
Ejemplo n.º 5
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));
            }
        }
Ejemplo n.º 6
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));
            }
        }