/// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Remove Entity" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnEntityRemove</b> removes the first selected item in the "Entity" list view from
        /// that list view and from the <see cref="CurrentEntities"/> collection, and sets the <see
        /// cref="SectionTabItem.DataChanged"/> flag.</remarks>

        private void OnEntityRemove(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected faction, if any
            int index = EntityList.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            EntityClass entity = (EntityClass)EntityList.Items[index];

            // delete existing ID references
            var entities = CurrentEntities;

            if (!SectionTabItem.ProcessAllIdentifiers(entities, entity.Id, null))
            {
                return;
            }

            // select item in the same position
            EntityList.Items.Refresh();
            if (EntityList.Items.Count > 0)
            {
                EntityList.SelectAndShow(Math.Min(EntityList.Items.Count - 1, index));
            }

            // broadcast data changes
            EnableListButtons();
            SectionTab.DataChanged = true;
        }
Example #2
0
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Remove Image" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnImageRemove</b> removes the selected item in the <see cref="ImageListBox"/> from
        /// that list box and from the current <see cref="ImageSection"/>, and sets the <see
        /// cref="SectionTabItem.DataChanged"/> flag.</remarks>

        private void OnImageRemove(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected image, if any
            int index = ImageList.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            var item  = (ImageListBoxItem)ImageList.SelectedItem;
            var image = (EntityImage)item.Content;

            // delete existing ID references
            var images = MasterSection.Instance.Images.Collection;

            if (!SectionTabItem.ProcessAllIdentifiers(images, image.Id, null))
            {
                return;
            }

            // select item in the same position
            ImageList.Items.RemoveAt(index);
            ImageList.Items.Refresh();
            if (ImageList.Items.Count > 0)
            {
                ImageList.SelectAndShow(Math.Min(ImageList.Items.Count - 1, index));
            }

            // broadcast data changes
            EnableListButtons();
            SectionTab.DataChanged = true;
        }
Example #3
0
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Remove File" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnFileRemove</b> removes the first selected item in the "Image File" list view from
        /// that list view and from the current <see cref="ImageSection"/>, redisplays all images,
        /// and sets the <see cref="SectionTabItem.DataChanged"/> flag.</remarks>

        private void OnFileRemove(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected image file, if any
            int index = FileList.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            ImageFile file = (ImageFile)FileList.Items[index];

            // delete existing ID references
            var files = MasterSection.Instance.Images.ImageFiles;

            if (!SectionTabItem.ProcessAllIdentifiers(files, file.Id, null))
            {
                return;
            }

            file.Unload();

            // select item in the same position
            FileList.Items.Refresh();
            if (FileList.Items.Count > 0)
            {
                FileList.SelectAndShow(Math.Min(FileList.Items.Count - 1, index));
            }

            // broadcast data changes
            ImageList.Redraw();
            EnableListButtons();
            SectionTab.DataChanged = true;
        }
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Remove Faction" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnFactionRemove</b> removes the first selected item in the "Faction" list view, if
        /// any, from that list view and from the current <see cref="FactionSection"/>, and sets the
        /// <see cref="SectionTabItem.DataChanged"/> flag.</remarks>

        private void OnFactionRemove(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected faction, if any
            int index = FactionList.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            FactionClass faction = (FactionClass)FactionList.Items[index];

            // delete existing ID references
            var factions = MasterSection.Instance.Factions.Collection;

            if (!SectionTabItem.ProcessAllIdentifiers(factions, faction.Id, null))
            {
                return;
            }

            // select item in the same position
            FactionList.Items.Refresh();
            if (FactionList.Items.Count > 0)
            {
                FactionList.SelectAndShow(Math.Min(FactionList.Items.Count - 1, index));
            }

            // broadcast data changes
            EnableListButtons();
            SectionTab.DataChanged = true;
        }
Example #5
0
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Change ID" <see
        /// cref="Button"/> that is associated with the <see cref="ImageListBox"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnImageId</b> displays a <see cref="Dialog.ChangeIdentifier"/> dialog for the
        /// selected item in the <see cref="ImageListBox"/>.
        /// </para><para>
        /// If the user made any changes, <b>OnImageId</b> propagates them to the current <see
        /// cref="ImageSection"/>, redisplays all images, and sets the <see
        /// cref="SectionTabItem.DataChanged"/> flag.</para></remarks>

        private void OnImageId(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected image, if any
            int index = ImageList.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            var item  = (ImageListBoxItem)ImageList.SelectedItem;
            var image = (EntityImage)item.Content;

            // let user enter new image ID
            var images = MasterSection.Instance.Images.Collection;
            var dialog = new Dialog.ChangeIdentifier(image.Id,
                                                     Global.Strings.TitleImageIdChange, images.ContainsKey, true);

            dialog.Owner = MainWindow.Instance;
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            // retrieve new image ID
            string id = String.Intern(dialog.Identifier);

            // change existing ID references
            if (!SectionTabItem.ProcessAllIdentifiers(images, image.Id, id))
            {
                return;
            }

            // change item in Image list
            ImageList.Items.RemoveAt(index);
            item  = new ImageListBoxItem(image);
            index = ImageList.Insert(item);
            ImageList.Items.Refresh();
            ImageList.SelectAndShow(index);

            // broadcast data changes
            SectionTab.DataChanged = true;
        }
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Change ID" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnEntityId</b> displays a <see cref="Dialog.ChangeIdentifier"/> dialog for the first
        /// selected item in the "Entity" list view.
        /// </para><para>
        /// If the user made any changes, <b>OnEntityId</b> propagates them to the <see
        /// cref="CurrentEntities"/> collection and sets the <see
        /// cref="SectionTabItem.DataChanged"/> flag.</para></remarks>

        private void OnEntityId(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected entity, if any
            EntityClass entity = EntityList.SelectedItem as EntityClass;

            if (entity == null)
            {
                return;
            }

            // let user enter new entity ID
            var entities = CurrentEntities;
            var dialog   = new Dialog.ChangeIdentifier(entity.Id,
                                                       Global.Strings.TitleEntityIdChange, entities.ContainsKey, true);

            dialog.Owner = MainWindow.Instance;
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            // retrieve new faction ID
            string id = String.Intern(dialog.Identifier);

            // change existing ID references
            if (!SectionTabItem.ProcessAllIdentifiers(entities, entity.Id, id))
            {
                return;
            }

            // broadcast data changes
            EntityList.Items.Refresh();
            SectionTab.DataChanged = true;
        }
Example #7
0
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Change ID" <see
        /// cref="Button"/> that is associated with the "Image File" list view.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnFileId</b> displays a <see cref="Dialog.ChangeIdentifier"/> dialog for the first
        /// selected item in the "Image File" list view.
        /// </para><para>
        /// If the user made any changes, <b>OnFileId</b> propagates them to the current <see
        /// cref="ImageSection"/>, redisplays all images, and sets the <see
        /// cref="SectionTabItem.DataChanged"/> flag.</para></remarks>

        private void OnFileId(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected image file, if any
            ImageFile file = FileList.SelectedItem as ImageFile;

            if (file == null)
            {
                return;
            }

            // let user enter new image file ID
            var files  = MasterSection.Instance.Images.ImageFiles;
            var dialog = new Dialog.ChangeIdentifier(file.Id,
                                                     Global.Strings.TitleImageIdChange, files.ContainsKey, true);

            dialog.Owner = MainWindow.Instance;
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            // retrieve new image file ID
            string id = String.Intern(dialog.Identifier);

            // change existing ID references
            if (!SectionTabItem.ProcessAllIdentifiers(files, file.Id, id))
            {
                return;
            }

            // broadcast data changes
            FileList.Items.Refresh();
            SectionTab.DataChanged = true;
        }
        /// <summary>
        /// Handles the <see cref="ButtonBase.Click"/> event for the "Change ID" <see
        /// cref="Button"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="RoutedEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnFactionId</b> displays a <see cref="Dialog.ChangeIdentifier"/> dialog for the first
        /// selected item in the "Faction" list view.
        /// </para><para>
        /// If the user made any changes, <b>OnFactionId</b> propagates them to the current <see
        /// cref="FactionSection"/> and sets the <see cref="SectionTabItem.DataChanged"/> flag.
        /// </para></remarks>

        private void OnFactionId(object sender, RoutedEventArgs args)
        {
            args.Handled = true;

            // retrieve selected faction, if any
            FactionClass faction = FactionList.SelectedItem as FactionClass;

            if (faction == null)
            {
                return;
            }

            // let user enter new faction ID
            var factions = MasterSection.Instance.Factions.Collection;
            var dialog   = new Dialog.ChangeIdentifier(faction.Id,
                                                       Global.Strings.TitleFactionIdChange, factions.ContainsKey, true);

            dialog.Owner = MainWindow.Instance;
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            // retrieve new faction ID
            string id = String.Intern(dialog.Identifier);

            // change existing ID references
            if (!SectionTabItem.ProcessAllIdentifiers(factions, faction.Id, id))
            {
                return;
            }

            // broadcast data changes
            FactionList.Items.Refresh();
            SectionTab.DataChanged = true;
        }