private void buttonFavouritesRename_Click(object sender, RoutedEventArgs e)
        {
            FavouriteBase item = treeView.SelectedItem as FavouriteBase;

            if (item != null)
            {
                Dialogs.FavouriteName dialog = new FavouriteName();

                dialog.ItemName = item.Name;

                DialogPanel.ShowDialog(Properties.Resources.ResourceManager, "PROPERTIES", dialog, "textFavouriteName", DialogButtons.Ok | DialogButtons.Cancel,
                                       delegate(DialogResult dialogResult)
                {
                    if (dialogResult == DialogResult.Ok)
                    {
                        item.Name = dialog.ItemName;
                    }
                }
                                       );
            }
        }
        private void buttonFavouritesNewFolder_Click(object sender, RoutedEventArgs e)
        {
            FavouriteFolder newFolder = new FavouriteFolder();

            newFolder.Name = CultureHelper.GetString(Properties.Resources.ResourceManager, "FAVOURITESNEWFOLDER");

            Dialogs.FavouriteName dialog = new FavouriteName();

            dialog.ItemName = newFolder.Name;

            DialogPanel.ShowDialog(Properties.Resources.ResourceManager, "PROPERTIES", dialog, "textFavouriteName", DialogButtons.Ok | DialogButtons.Cancel,
                                   delegate(DialogResult dialogResult)
            {
                if (dialogResult == DialogResult.Ok)
                {
                    newFolder.Name = dialog.ItemName;

                    if (string.IsNullOrEmpty(newFolder.Name))
                    {
                        newFolder.Name = CultureHelper.GetString(Properties.Resources.ResourceManager, "FAVOURITESNEWFOLDER");
                    }

                    FavouriteFolder parent = treeView.SelectedItem as FavouriteFolder;

                    if (parent == null)
                    {
                        parent = FindParent(_rootFolder, treeView.SelectedItem as FavouriteBase);
                    }

                    if (parent == null)
                    {
                        parent = _rootFolder;
                    }

                    if (parent != null)
                    {
                        int foundIdx = -1;

                        for (int i = 0; i < parent.Children.Count && foundIdx == -1; i++)
                        {
                            if (parent.Children[i] is Favourite)
                            {
                                foundIdx = i;
                            }
                        }

                        if (foundIdx == -1)
                        {
                            foundIdx = parent.Children.Count;
                        }

                        parent.Children.Insert(foundIdx, newFolder);


                        TreeViewItem tviParent = treeView.GetContainerFromItem(parent) as TreeViewItem;

                        if (tviParent != null)
                        {
                            tviParent.IsExpanded = true;
                        }

                        TreeViewItem tvi = treeView.GetContainerFromItem(newFolder) as TreeViewItem;

                        if (tvi != null)
                        {
                            tvi.IsSelected = true;
                        }
                    }
                }
            }
                                   );
        }