/// <summary>
        /// Sets the page content based on existing material.
        /// </summary>
        public void ConstructPage()
        {
            gui = new PgCollectionGuiEdit();

            #region Collection name
            //Sets the collection name.
            if (string.IsNullOrWhiteSpace((string)collection.GetData("name")))
            {
                gui.TxtblkCollectionName.Text = GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkCollectionName.Text = (string)collection.GetData("name");
            }

            //Handles changes to the database name.
            gui.TxtblkCollectionName.TextChanged += new TextChangedEventHandler((a, b) =>
            {
                if (!string.IsNullOrWhiteSpace(gui.TxtblkCollectionName.Text))
                {
                    collection.SetData("name", gui.TxtblkCollectionName.Text);
                }

                //If the textbox is empty, it will keep the last character.
                gui.TxtblkCollectionName.Text = (string)collection.GetData("name");

                DataNameChanged?.Invoke(this, null);
            });
            #endregion

            #region Template name
            gui.TxtblkTemplateName.Text = GlobalStrings.CollectionEditTemplate;
            //Sets the template name.
            if (string.IsNullOrWhiteSpace((string)project
                                          .GetCollectionTemplate(collection).GetData("name")))
            {
                gui.TxtblkTemplateName.Text += GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkTemplateName.Text += (string)project
                                               .GetCollectionTemplate(collection).GetData("name");
            }
            #endregion

            #region Description
            //Sets the description.
            gui.TxtbxDescription.Text = (string)collection.GetData("description");

            //Handles changes to the collection description.
            gui.TxtbxDescription.TextChanged += new TextChangedEventHandler((a, b) =>
            {
                collection.SetData("description", gui.TxtbxDescription.Text);
            });
            #endregion
        }
Beispiel #2
0
        public void ChainedDataItemValues()
        {
            DataItem target  = Samples.GetSimpleDataItem("foo");
            DataItem target2 = Samples.GetSimpleDataItem("foo");

            target.Data         = "one";
            target2.Data        = "two";
            target.ViewContext  = "v1";
            target2.ViewContext = "v2";

            target.ChainedDataItem = target2;

            Assert.AreEqual("two", target2.Data);
            Assert.AreEqual(target2.Data, target2.GetData(), "Empty view didn't return default value");
            Assert.AreEqual("two", target.GetData("v2"), "Chained data lookup failed for view");
            Assert.AreEqual("one", target.GetData("v1"));

            Assert.IsNull(target.GetData("invalid"));
        }
 /// <summary>
 /// Causes the header to update to match the dataitem.
 /// </summary>
 public void Refresh()
 {
     if (_data != null)
     {
         Content = (string)_data.GetData("name");
     }
     else
     {
         Content = String.Empty;
     }
 }
 /// <summary>
 /// Causes the header to update to match the dataitem.
 /// </summary>
 public void Refresh()
 {
     if (_data != null)
     {
         Header = (string)_data.GetData("name");
     }
     else
     {
         Header = String.Empty;
     }
 }
        public CmbxDataItem(DataItem item)
            : base()
        {
            this._data = item;

            if (item != null)
            {
                Content = (string)item.GetData("name");
            }
            else
            {
                Content = String.Empty;
            }
        }
        public MenuDataItem(DataItem item)
            : base()
        {
            this._data = item;

            if (item != null)
            {
                Header = (string)item.GetData("name");
            }
            else
            {
                Header = String.Empty;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new treeview item with underlying data.
        /// </summary>
        /// <param name="item">
        /// The data to provide.
        /// </param>
        public TreeViewDataItem(DataItem item)
            : base()
        {
            this._data  = item;
            _parentView = null;

            if (item != null)
            {
                Header = (string)item.GetData("name");
            }
            else
            {
                Header = String.Empty;
            }
        }
Beispiel #8
0
 /// <summary>
 /// Causes the header to update to match the dataitem.
 /// </summary>
 public void Refresh(Project project)
 {
     if (_data != null)
     {
         if (_data.type == DataItemTypes.GroupingEntryRef)
         {
             Header = (string)project.GetEntryRefEntry(_data).GetData("name");
         }
         else
         {
             Header = (string)_data.GetData("name");
         }
     }
     else
     {
         Header = String.Empty;
     }
 }
Beispiel #9
0
        public MainPage()
        {
            this.NavigationCacheMode = NavigationCacheMode.Required;
            var items = DataItem.GetData();

            if (App.IsXbox())
            {
                Hero = items.First();
                items.RemoveAt(0);
            }

            Items        = items;
            Topics       = DataItem.GetListOfTopics();
            this.Loaded += MainPage_Loaded;
            RootPage.Current.ImageCount = Items.Count;



            this.InitializeComponent();
        }
Beispiel #10
0
        public DetailsPage()
        {
            Items = DataItem.GetData().Take(6).ToList();
            this.InitializeComponent();
            Window.Current.SizeChanged += Current_SizeChanged;
            CoreWindow.GetForCurrentThread().KeyDown += DetailsPage_KeyDown;

            Loaded += DetailsPage_Loaded;

            UpdateSize(new Size(Window.Current.Bounds.Width, Window.Current.Bounds.Height));

            RootElement.ViewChanged += RootElement_ViewChanged;

            animatableSections.Add(new AnimatableSection(Section1, Section1Animate));
            animatableSections.Add(new AnimatableSection(Section2, Section2Animate));
            animatableSections.Add(new AnimatableSection(Section3, Section3Animate));
            animatableSections.Add(new AnimatableSection(Section4, Section4Animate));
            animatableSections.Add(new AnimatableSection(VideoSection, VideoSectionAnimate));
            animatableSections.Add(new AnimatableSection(RelatedSection, RelatedSectionAnimate));
        }
        /// <summary>
        /// Sets the page content based on existing material.
        /// </summary>
        public void ConstructPage()
        {
            gui = new PgCollectionGuiView();

            #region Collection name
            //Sets the collection name.
            if (string.IsNullOrWhiteSpace((string)collection.GetData("name")))
            {
                gui.TxtblkCollectionName.Text = GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkCollectionName.Text = (string)collection.GetData("name");
            }
            #endregion

            #region Collection description
            //Sets the collection description.
            if (!string.IsNullOrWhiteSpace((string)collection.GetData("description")))
            {
                gui.TxtbxDescription.Text = (string)collection.GetData("description");
            }
            #endregion

            #region Groupings
            //Creates an element to stack images in vertical columns.
            FixedColumnPanel imageStack = new FixedColumnPanel(3);
            Gui.GuiItems.Children.Add(imageStack.Gui);

            //Adds each group.
            List <DataItem> grps =
                Project.GetCollectionGroupings(collection);

            for (int i = 0; i < grps.Count; i++)
            {
                bool isGroupEntryFound = false;
                var  entryRefs         = project.GetGroupingEntryRefs(grps[i]);

                Grid groupObject = new Grid();

                //Adds the first successful entry.
                for (int j = 0; j < entryRefs.Count; j++)
                {
                    //Gets the entry's fields.
                    var fields = project.GetEntryFields(
                        project.GetEntryRefEntry(entryRefs[j]));

                    //Finds the field index with an EntryImages type.
                    int fieldId = -1;
                    for (int k = 0; k < fields.Count; k++)
                    {
                        var tempField = project.GetFieldTemplateField(fields[k]);
                        if ((TemplateFieldType)(int)tempField.GetData("dataType") ==
                            TemplateFieldType.EntryImages)
                        {
                            fieldId = k;
                            break;
                        }
                    }

                    //Attempts to load the entryimages media.
                    if (fieldId != -1)
                    {
                        string        imgUrl     = (string)fields[fieldId].GetData("data");
                        List <string> loadedData = new List <string>();
                        List <string> urls       = new List <string>();
                        bool          isAnimated = false;
                        bool          isMuted    = false;

                        //Loads existing data.
                        if (imgUrl != String.Empty)
                        {
                            loadedData = imgUrl.Split('|').ToList();
                            isAnimated = (loadedData[0] == "True");
                            isMuted    = (loadedData[1] == "True");
                            urls       = loadedData.GetRange(2, loadedData.Count - 2);
                            urls       = urls.Where(o => File.Exists(o)).ToList();
                        }

                        //Loads a visual if possible.
                        if (urls.Count > 0)
                        {
                            //Loads the first still image.
                            if (!isAnimated)
                            {
                                ImgThumbnail img = new ImgThumbnail(urls[0]);
                                img.Margin = new Thickness(4);
                                img.HorizontalAlignment = HorizontalAlignment.Center;

                                //Resizes the image.
                                img.Loaded += (a, b) =>
                                {
                                    img.IsEnabled = false;
                                    if (img.ActualWidth > 0)
                                    {
                                        img.MaxWidth  = img.GetSourceWidth();
                                        img.MaxHeight = img.GetSourceHeight();
                                    }
                                    else
                                    {
                                        img.SetSize(0);
                                    }
                                };

                                //Prevents clicking to open a larger window.
                                img.PreviewMouseUp +=
                                    new System.Windows.Input.MouseButtonEventHandler((a, b) =>
                                {
                                    b.Handled = true;
                                });

                                isGroupEntryFound = true;
                                groupObject.Children.Add(img);
                            }

                            //Loads movies and animations.
                            else
                            {
                                MediaElement media = null;
                                ImgAnimated  img   = null;

                                //Loads the first movie.
                                if (urls[0].ToLower().EndsWith(".wmv") ||
                                    urls[0].ToLower().EndsWith(".mp4"))
                                {
                                    media                     = new MediaElement();
                                    media.IsMuted             = isMuted;
                                    media.Margin              = new Thickness(4);
                                    media.HorizontalAlignment = HorizontalAlignment.Center;

                                    try
                                    {
                                        media.Volume = 0;
                                        media.Source = new Uri(urls[0]);

                                        //Resizes the image.
                                        media.MediaOpened += (a, b) =>
                                        {
                                            media.MaxWidth       = media.NaturalVideoWidth;
                                            media.MaxHeight      = media.NaturalVideoHeight;
                                            media.LoadedBehavior = MediaState.Pause;
                                            media.Volume         = 1;
                                        };

                                        //Pauses and resumes playback on hover.
                                        media.MouseEnter += (a, b) =>
                                        {
                                            media.LoadedBehavior = MediaState.Play;
                                        };

                                        media.MouseLeave += (a, b) =>
                                        {
                                            media.LoadedBehavior = MediaState.Pause;
                                        };

                                        //Loops the movie.
                                        media.MediaEnded += (a, b) =>
                                        {
                                            media.Position = new TimeSpan(0, 0, 1);
                                        };

                                        isGroupEntryFound = true;
                                        groupObject.Children.Add(media);
                                    }
                                    catch (InvalidOperationException) { } //Ignores loading errors.
                                    catch (ArgumentNullException) { }     //Ignores loading errors.
                                    catch (UriFormatException) { }        //Ignores loading errors.
                                    catch (Exception e) //Logs unknown errors.
                                    {
                                        Utils.Log("While loading media in grouping view: " + e.Message);
                                    }
                                }

                                //Loads rotating images.
                                else
                                {
                                    img = new ImgAnimated(urls, false);
                                    img.SetPlaybackDelay(1000);
                                    img.Margin = new Thickness(4);
                                    img.HorizontalAlignment = HorizontalAlignment.Center;

                                    //Resizes the image.
                                    img.Loaded += (a, b) =>
                                    {
                                        if (img.ActualWidth > 0)
                                        {
                                            img.MaxWidth  = img.GetSourceWidth();
                                            img.MaxHeight = img.GetSourceHeight();
                                        }
                                        else
                                        {
                                            img.MaxHeight = 0;
                                            img.MaxWidth  = 0;
                                        }
                                    };

                                    //Prevents clicking to open a larger window.
                                    img.PreviewMouseUp +=
                                        new System.Windows.Input.MouseButtonEventHandler((a, b) =>
                                    {
                                        b.Handled = true;
                                    });

                                    isGroupEntryFound = true;
                                    groupObject.Children.Add(img);
                                }
                            }
                        }
                    }

                    //Breaks when an entry has been added.
                    if (isGroupEntryFound)
                    {
                        break;
                    }
                }

                //Adds an overlapping caption to each group
                TextBlock blk = new TextBlock();
                blk.Background          = new SolidColorBrush(Color.FromArgb(196, 255, 255, 255));
                blk.Text                = (string)grps[i].GetData("name");
                blk.Padding             = new Thickness(4);
                blk.TextAlignment       = TextAlignment.Center;
                blk.TextWrapping        = TextWrapping.Wrap;
                blk.HorizontalAlignment = HorizontalAlignment.Stretch;
                blk.VerticalAlignment   = VerticalAlignment.Bottom;
                blk.FontSize            = 14;

                //Bold when hovered.
                blk.MouseEnter +=
                    new System.Windows.Input.MouseEventHandler((a, b) =>
                {
                    blk.FontWeight = FontWeights.Bold;
                });

                //Normal when not hovered.
                blk.MouseLeave +=
                    new System.Windows.Input.MouseEventHandler((a, b) =>
                {
                    blk.FontWeight = FontWeights.Normal;
                });

                groupObject.Children.Add(blk);

                //Navigates to the grouping when clicked.
                int pos = i; //Captured for the lambda.

                groupObject.MouseUp +=
                    new System.Windows.Input.MouseButtonEventHandler((a, b) =>
                {
                    SelectedItem = grps[pos];
                });

                //Adds the group to the image stack.
                imageStack.AddItem(groupObject);
            }
            #endregion
        }
Beispiel #12
0
        /// <summary>
        /// Sets the page content based on existing material.
        /// </summary>
        public void ConstructPage()
        {
            gui = new PgDatabaseGuiEdit();
            DataItem dat = Project.GetDatabase();

            #region Database name
            //Sets the database name.
            if (string.IsNullOrWhiteSpace((string)dat.GetData("name")))
            {
                gui.TxtblkDatabaseName.Text = GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkDatabaseName.Text = (string)dat.GetData("name");
            }

            //Handles changes to the database name.
            gui.TxtblkDatabaseName.TextChanged += new TextChangedEventHandler((a, b) =>
            {
                if (!string.IsNullOrWhiteSpace(gui.TxtblkDatabaseName.Text))
                {
                    dat.SetData("name", gui.TxtblkDatabaseName.Text);
                }

                //If the textbox is empty, it will keep the last character.
                gui.TxtblkDatabaseName.Text = (string)dat.GetData("name");

                DataNameChanged?.Invoke(this, null);
            });
            #endregion

            #region Mode combobox
            //Sets the mode combobox.
            if ((bool)dat.GetData("defUseEditMode"))
            {
                gui.CmbxDefaultEditMode.SelectedValue =
                    GlobalStrings.DatabaseEditDefEditModeEdit;
            }
            else
            {
                gui.CmbxDefaultEditMode.SelectedValue =
                    GlobalStrings.DatabaseEditDefEditModeView;
            }

            //Handles changes to mode combobox.
            gui.CmbxDefaultEditMode.SelectionChanged +=
                new SelectionChangedEventHandler((a, b) =>
            {
                dat.SetData("defUseEditMode",
                            (string)gui.CmbxDefaultEditMode.SelectedValue ==
                            GlobalStrings.DatabaseEditDefEditModeEdit);
            });
            #endregion

            #region Description
            //Sets the description.
            gui.TxtbxDescription.Text = (string)dat.GetData("description");

            //Handles changes to the description.
            gui.TxtbxDescription.TextChanged += new TextChangedEventHandler((a, b) =>
            {
                dat.SetData("description", gui.TxtbxDescription.Text);
            });
            #endregion

            #region Background image
            //Sets the background image data.
            string bgUrl = (string)dat.GetData("imageUrl");
            if (!string.IsNullOrWhiteSpace(bgUrl))
            {
                if (File.Exists(bgUrl))
                {
                    gui.ImgDeleteBgImage.IsEnabled  = true;
                    gui.ImgDeleteBgImage.Visibility = Visibility.Visible;
                    gui.ImgBgImage.IsEnabled        = true;
                    gui.ImgBgImage.Visibility       = Visibility.Visible;
                    gui.ImgBgImage.Source           =
                        new BitmapImage(new Uri(bgUrl, UriKind.Absolute));
                }
                else
                {
                    gui.ImgDeleteBgImage.IsEnabled  = false;
                    gui.ImgDeleteBgImage.Visibility = Visibility.Collapsed;
                    gui.ImgBgImage.IsEnabled        = false;
                    gui.ImgBgImage.Visibility       = Visibility.Collapsed;
                }
            }
            else
            {
                gui.ImgDeleteBgImage.IsEnabled  = false;
                gui.ImgDeleteBgImage.Visibility = Visibility.Collapsed;
                gui.ImgBgImage.Visibility       = Visibility.Collapsed;
                gui.ImgBgImage.IsEnabled        = false;
            }

            //The deletion button responds to mouse interaction.
            gui.ImgDeleteBgImage.MouseEnter +=
                new System.Windows.Input.MouseEventHandler((a, b) =>
            {
                gui.ImgDeleteBgImage.Source = new BitmapImage(
                    new Uri(Assets.BttnDeleteHover));
            });

            gui.ImgDeleteBgImage.MouseLeave +=
                new System.Windows.Input.MouseEventHandler((a, b) =>
            {
                gui.ImgDeleteBgImage.Source = new BitmapImage(
                    new Uri(Assets.BttnDelete));
            });

            gui.ImgDeleteBgImage.MouseDown +=
                new System.Windows.Input.MouseButtonEventHandler((a, b) =>
            {
                dat.SetData("imageUrl", String.Empty);
                gui.ImgDeleteBgImage.IsEnabled  = false;
                gui.ImgDeleteBgImage.Visibility = Visibility.Collapsed;
                gui.ImgBgImage.IsEnabled        = false;
                gui.ImgBgImage.Visibility       = Visibility.Collapsed;

                BgImageChanged?.Invoke(this, null);
            });

            //Shows the background image in full size if clicked.
            gui.ImgBgImage.MouseDown +=
                new System.Windows.Input.MouseButtonEventHandler((a, b) =>
            {
                DlgImgDisplay gui = new DlgImgDisplay();
                gui.Add(bgUrl);
                gui.Show();
            });

            //Allows the user to browse to an image if selected.
            gui.BttnBrowseBgImage.Click +=
                new RoutedEventHandler((a, b) =>
            {
                OpenFileDialog dlg  = new OpenFileDialog();
                dlg.CheckPathExists = true;
                dlg.Filter          = GlobalStrings.FilterPictures;
                dlg.Title           = GlobalStrings.CaptionLoadDatabase;

                dlg.FileOk +=
                    new System.ComponentModel.CancelEventHandler((c, d) =>
                {
                    try
                    {
                        bgUrl = dlg.FileName;

                        gui.ImgBgImage.Source = new BitmapImage(
                            new Uri(bgUrl, UriKind.Absolute));

                        dat.SetData("imageUrl", bgUrl);

                        gui.ImgDeleteBgImage.IsEnabled  = true;
                        gui.ImgDeleteBgImage.Visibility = Visibility.Visible;
                        gui.ImgBgImage.IsEnabled        = true;
                        gui.ImgBgImage.Visibility       = Visibility.Visible;

                        BgImageChanged?.Invoke(this, null);
                    }
                    catch (NotSupportedException e)
                    {
                        Utils.Log("Uploaded non-image: " + e);
                        MessageBox.Show(GlobalStrings.DlgUploadImageError);
                    }
                });

                dlg.ShowDialog();
            });
            #endregion

            //Sets up delay between autosaves options.
            gui.TxtbxAutosaveNumSeconds.Text         = (((int)dat.GetData("autosaveDelay")) / 1000).ToString();
            gui.TxtbxAutosaveNumSeconds.TextChanged += TxtbxAutosaveNumSeconds_TextChanged;

            //Sets up delay between autosaves options.
            gui.TxtbxAutosaveNumBackups.Text         = ((int)dat.GetData("autosaveNumberofBackups")).ToString();
            gui.TxtbxAutosaveNumBackups.TextChanged += TxtbxAutosaveNumBackups_TextChanged;
        }
        /// <summary>
        /// Sets the page content based on existing material.
        /// </summary>
        public void ConstructPage()
        {
            gui = new PgDatabaseGuiView();
            DataItem dat = Project.GetDatabase();

            #region Database name
            //Sets the database name.
            if (string.IsNullOrWhiteSpace((string)dat.GetData("name")))
            {
                gui.TxtblkDatabaseName.Text = GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkDatabaseName.Text = (string)dat.GetData("name");
            }
            #endregion

            #region Description
            //Sets the description.
            gui.TxtbxDescription.Text = (string)dat.GetData("description");
            #endregion

            #region Collections
            List <DataItem> collections =
                Project.GetItemsByType(DataItemTypes.Collection);

            //If there is nothing to display, shows a message saying so.
            if (collections.Count == 0)
            {
                //Creates the message as a textblock.
                TextBlock emptyMessage = new TextBlock();
                emptyMessage.Text = GlobalStrings.HintNoCollections;
                emptyMessage.HorizontalAlignment = HorizontalAlignment.Center;
                emptyMessage.VerticalAlignment   = VerticalAlignment.Center;
                emptyMessage.Foreground          = Brushes.LightGray;

                //Adds the message to the center of the grid.
                Grid.SetRow(emptyMessage, 1);
                gui.GuiItems.Children.Add(emptyMessage);
            }

            //Adds each collection.
            for (int i = 0; i < collections.Count; i++)
            {
                TextBlock blk = new TextBlock();
                blk.Text                = (string)collections[i].GetData("name");
                blk.Padding             = new Thickness(4);
                blk.TextAlignment       = TextAlignment.Center;
                blk.TextWrapping        = TextWrapping.Wrap;
                blk.HorizontalAlignment = HorizontalAlignment.Stretch;
                blk.FontSize            = 14;

                //Bold when hovered.
                blk.MouseEnter +=
                    new System.Windows.Input.MouseEventHandler((a, b) =>
                {
                    blk.FontWeight = FontWeights.Bold;
                });

                //Normal when not hovered.
                blk.MouseLeave +=
                    new System.Windows.Input.MouseEventHandler((a, b) =>
                {
                    blk.FontWeight = FontWeights.Normal;
                });

                //Navigates to the collection when clicked.
                int pos = i; //Captured for the lambda.

                blk.MouseDown +=
                    new System.Windows.Input.MouseButtonEventHandler((a, b) =>
                {
                    SelectedItem = collections[pos];
                });

                gui.GuiItems.Children.Add(blk);
            }
            #endregion
        }
        /// <summary>
        /// Sets the page content based on existing material.
        /// </summary>
        public void ConstructPage()
        {
            gui = new PgGroupingGuiEdit();

            #region Grouping name
            //Sets the grouping name.
            if (string.IsNullOrWhiteSpace((string)grouping.GetData("name")))
            {
                gui.TxtblkGroupingName.Text = GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkGroupingName.Text = (string)grouping.GetData("name");
            }

            //Handles changes to the grouping name.
            gui.TxtblkGroupingName.TextChanged += new TextChangedEventHandler((a, b) =>
            {
                if (!string.IsNullOrWhiteSpace(gui.TxtblkGroupingName.Text))
                {
                    grouping.SetData("name", gui.TxtblkGroupingName.Text);
                }

                //If the textbox is empty, it will keep the last character.
                gui.TxtblkGroupingName.Text = (string)grouping.GetData("name");

                DataNameChanged?.Invoke(this, null);
            });
            #endregion

            //All menu items are represented as entries for consistency.
            #region Menu Item Columns
            #region Menu item, move left/right
            var funcMenuItemMove = new Action(() =>
            {
                if (ActiveEntry == null)
                {
                    return;
                }

                //Moves the item in or out of the group (deletion/addition).
                if (gui.LstbxInGroup.Items.Contains(ActiveEntry))
                {
                    //Finds the entry reference for the current group that
                    //represents the entry, then removes the reference.
                    var refs = project.GetGroupingEntryRefs(grouping);
                    for (int i = 0; i < refs.Count; i++)
                    {
                        if ((ulong)refs[i].GetData("entryGuid") ==
                            ActiveEntry.GetItem().guid)
                        {
                            project.DeleteItemByGuid(refs[i].guid);
                        }
                    }

                    gui.LstbxInGroup.Items.Remove(ActiveEntry);
                    gui.LstbxOutGroup.Items.Add(ActiveEntry);
                }
                else
                {
                    project.AddGroupingEntryRef(
                        grouping.guid,
                        ActiveEntry.GetItem().guid);

                    gui.LstbxOutGroup.Items.Remove(ActiveEntry);
                    gui.LstbxInGroup.Items.Add(ActiveEntry);

                    EntryIncluded?.Invoke(this, null);
                }
            });
            #endregion

            #region Menuitem, selected
            var funcMenuItemSelected = new Action <LstbxDataItem>((newItem) =>
            {
                ActiveEntry = newItem;

                //Ensures only one item is selected at once.
                if (gui.LstbxInGroup.Items.Contains(ActiveEntry))
                {
                    gui.LstbxOutGroup.SelectedItem = null;
                }
                else
                {
                    gui.LstbxInGroup.SelectedItem = null;
                }
            });
            #endregion

            #region Populate menu items
            //Adds every menu item in its original order.
            var col        = project.GetGroupingCollection(grouping);
            var entries    = project.GetGroupingEntries(grouping);
            var colEntries = project.GetCollectionEntries(col);

            //Adds entries to their respective lists via group inclusiveness.
            for (int i = 0; i < colEntries.Count; i++)
            {
                var item = new LstbxDataItem(colEntries[i]);

                //Looks to see if this entry is in the group.
                var result = entries.Find(new Predicate <DataItem>((a) =>
                {
                    return(a.guid.Equals(colEntries[i].guid));
                }));

                //Adds the entry based on whether it's in the group.
                if (result != null)
                {
                    gui.LstbxInGroup.Items.Add(item);
                }
                else
                {
                    gui.LstbxOutGroup.Items.Add(item);
                }

                //Handles item selection.
                item.Selected += new RoutedEventHandler((a, b) =>
                {
                    funcMenuItemSelected(item);
                });
            }
            #endregion

            #region Keyboard event handling
            gui.LstbxInGroup.KeyDown += new KeyEventHandler((a, b) =>
            {
                //Right key pressed: Move to 2nd column
                if (b.Key == Key.Right && b.IsDown && ActiveEntry != null)
                {
                    funcMenuItemMove();
                }
            });

            gui.LstbxOutGroup.KeyDown += new KeyEventHandler((a, b) =>
            {
                //Left key pressed: Move to 1st column
                if (b.Key == Key.Left && b.IsDown &&
                    gui.LstbxOutGroup.SelectedItem != null)
                {
                    funcMenuItemMove();
                }
                #endregion
            });

            #endregion

            #region Left arrow key pressed
            gui.BttnMoveLeft.MouseDown += new MouseButtonEventHandler((a, b) =>
            {
                if (gui.LstbxOutGroup.SelectedItem != null)
                {
                    funcMenuItemMove();
                }
            });
            #endregion

            #region Right arrow key pressed
            gui.BttnMoveRight.MouseDown += new MouseButtonEventHandler((a, b) =>
            {
                if (gui.LstbxInGroup.SelectedItem != null)
                {
                    funcMenuItemMove();
                }
            });
            #endregion

            #region Grouping conditions
            gui.BttnCondAdd.Click   += BttnCondAdd_Click;
            gui.BttnCondApply.Click += BttnCondApply_Click;

            //Populates all grouping conditions.
            uint numConditions = (uint)grouping.GetData("numConditions");
            for (int i = 0; i < numConditions; i++)
            {
                var condType = (GroupingCondType)
                               grouping.GetData("conditionType" + i);

                switch (condType)
                {
                case (GroupingCondType.ByLetter):
                    string condFromLetter = (string)
                                            grouping.GetData("condAddFromLetter" + i);
                    string condToLetter = (string)
                                          grouping.GetData("condAddToLetter" + i);

                    gui.GroupConditions.Children.Add(
                        AddConditionByRange(condFromLetter, condToLetter, (uint)i));
                    break;
                }
            }
            #endregion
        }