Example #1
0
        public void SetActive()
        {
            var databaseUri = SelectItemDialog.DatabaseUri;

            if (databaseUri == DatabaseUri.Empty)
            {
                return;
            }

            if (!loaded)
            {
                loaded = true;

                BaseTreeViewItem treeViewItem;
                if (SelectItemDialog.ShowAllDatabases)
                {
                    treeViewItem = new SiteTreeViewItem(databaseUri.Site)
                    {
                        Text = databaseUri.Site.Name
                    };
                }
                else
                {
                    treeViewItem = new DatabaseTreeViewItem(databaseUri)
                    {
                        Text = databaseUri.DatabaseName.ToString()
                    };
                }

                treeViewItem.MakeExpandable();

                ContentTreeView.TreeView.Items.Add(treeViewItem);

                treeViewItem.ExpandAndWait();
            }

            if (SelectItemDialog.SelectedItemUri != ItemUri.Empty)
            {
                ContentTreeView.ExpandTo(SelectItemDialog.SelectedItemUri);
            }
            else if (!string.IsNullOrEmpty(SelectItemDialog.InitialItemPath))
            {
                ContentTreeView.ExpandTo(databaseUri, SelectItemDialog.InitialItemPath);
            }
            else if (!string.IsNullOrEmpty(SelectItemDialog.SettingsKey))
            {
                var id = AppHost.Settings.GetString("SelectItemDialog\\" + SelectItemDialog.SettingsKey, databaseUri.ToString(), string.Empty);
                if (id.IsGuid())
                {
                    Guid guid;
                    if (Guid.TryParse(id, out guid))
                    {
                        var itemUri = new ItemUri(databaseUri, new ItemId(guid));
                        ContentTreeView.ExpandTo(itemUri);
                    }
                }
            }

            ContentTreeView.SetFocus();
        }
Example #2
0
        private void ExpandToShortcut([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var hyperlink = sender as Hyperlink;

            if (hyperlink == null)
            {
                return;
            }

            var item = hyperlink.Tag as IItem;

            if (item == null)
            {
                return;
            }

            var baseSiteTreeViewItem = ContentTreeView.ExpandTo(item.ItemUri);

            if (baseSiteTreeViewItem == null)
            {
                return;
            }

            baseSiteTreeViewItem.BringIntoView();
            baseSiteTreeViewItem.Focus();
            Keyboard.Focus(baseSiteTreeViewItem);
        }