private void Load()
        {
            var storageKey = GetStorageKey();
            var n          = 0;

            while (n < MaxItems)
            {
                var uri = AppHost.Settings.Get(storageKey, "itemuri" + n, null) as string;
                if (string.IsNullOrEmpty(uri))
                {
                    break;
                }

                ItemUri itemUri;
                if (!ItemUri.TryParse(uri, out itemUri))
                {
                    n++;
                    continue;
                }

                var name         = AppHost.Settings.Get(storageKey, "name" + n, string.Empty) as string ?? string.Empty;
                var icon         = new Icon(itemUri.Site, AppHost.Settings.Get(storageKey, "icon" + n, string.Empty) as string ?? string.Empty);
                var templateId   = new ItemId(new Guid(AppHost.Settings.Get(storageKey, "templateid" + n, string.Empty) as string ?? string.Empty));
                var templateName = AppHost.Settings.Get(storageKey, "templatename" + n, string.Empty) as string ?? string.Empty;

                var item = GetTreeViewItem(itemUri, name, icon, templateId, templateName);

                recentItems.Insert(0, item);

                n++;
            }
        }
Exemplo n.º 2
0
        public IEnumerable <IItem> GetItems(DatabaseUri databaseUri)
        {
            Assert.ArgumentNotNull(databaseUri, nameof(databaseUri));

            journal = new StringJournal("SelectItem", databaseUri.ToString())
            {
                Max = 8,
                RemoveDuplicates = true
            };

            foreach (var entry in journal.GetHistory())
            {
                var parts = entry.Split('^');
                if (parts.Length != 2)
                {
                    continue;
                }

                ItemUri itemUri;
                if (!ItemUri.TryParse(parts[1], out itemUri))
                {
                    continue;
                }

                var name = parts[0];

                yield return(new HistoryEntry(itemUri, name));
            }
        }
        public void Initialize([NotNull] Site site, [NotNull] string templateName)
        {
            Assert.ArgumentNotNull(site, nameof(site));
            Assert.ArgumentNotNull(templateName, nameof(templateName));

            Site         = site;
            TemplateName = templateName;

            var siteTreeViewItem = new SiteTreeViewItem(site);

            TreeView.Items.Add(siteTreeViewItem);

            var key          = GetStorageKey(site, templateName);
            var lastSelected = Storage.ReadString(NewItemWizardRegistryKey, key, string.Empty);

            if (!string.IsNullOrEmpty(lastSelected))
            {
                ItemUri itemUri;
                if (ItemUri.TryParse(lastSelected, out itemUri))
                {
                    if (TreeView.ExpandTo(itemUri) != null)
                    {
                        return;
                    }
                }
            }

            siteTreeViewItem.IsExpanded = true;
        }
Exemplo n.º 4
0
        protected virtual void Load()
        {
            bulkUpdating++;
            try
            {
                items.Clear();

                var contents = AppHost.Files.ReadAllText(FileName);

                var root = contents.ToXElement();
                if (root == null)
                {
                    return;
                }

                var folderName = root.GetAttributeValue("name");
                if (!string.IsNullOrEmpty(folderName))
                {
                    Name = folderName;
                }

                foreach (var element in root.Elements())
                {
                    ItemUri itemUri;
                    if (!ItemUri.TryParse(element.GetAttributeValue("itemuri"), out itemUri))
                    {
                        continue;
                    }

                    var name = element.GetAttributeValue("name");
                    var icon = new Icon(element.GetAttributeValue("icon"));

                    var i = new LibraryItemDescriptor(items, itemUri, name, icon);

                    items.Add(i);
                }
            }
            finally
            {
                bulkUpdating--;
            }
        }
Exemplo n.º 5
0
        public virtual void Load([NotNull] XElement element)
        {
            Assert.ArgumentNotNull(element, nameof(element));

            TemplateSections.Clear();

            ItemUri templateUri;

            ItemUri.TryParse(element.GetAttributeValue("templateuri"), out templateUri);

            TemplateUri = templateUri;
            Name        = element.GetAttributeValue("templatename");
            ClassName   = element.GetAttributeValue("classname");

            foreach (var sectionElement in element.Elements())
            {
                var section = ShapeCreator.CreateTemplateSection(ShapeCreator);

                section.Load(sectionElement);

                TemplateSections.Add(section);
            }
        }
Exemplo n.º 6
0
        public IEnumerable <RecentItem> Load([NotNull] string storageKey)
        {
            Assert.ArgumentNotNull(storageKey, nameof(storageKey));

            var n = 0;

            var recentItems = new List <RecentItem>();

            while (n < 99)
            {
                var uri = AppHost.Settings.Get(storageKey, "itemuri" + n, null) as string;
                if (string.IsNullOrEmpty(uri))
                {
                    break;
                }

                ItemUri itemUri;
                if (!ItemUri.TryParse(uri, out itemUri))
                {
                    n++;
                    continue;
                }

                var name         = AppHost.Settings.Get(storageKey, "name" + n, string.Empty) as string ?? string.Empty;
                var icon         = new Icon(itemUri.Site, AppHost.Settings.Get(storageKey, "icon" + n, string.Empty) as string ?? string.Empty);
                var templateId   = new ItemId(new Guid(AppHost.Settings.Get(storageKey, "templateid" + n, string.Empty) as string ?? string.Empty));
                var templateName = AppHost.Settings.Get(storageKey, "templatename" + n, string.Empty) as string ?? string.Empty;

                var item = new RecentItem(itemUri, name, icon, templateId, templateName);

                recentItems.Insert(0, item);

                n++;
            }

            return(recentItems);
        }
Exemplo n.º 7
0
        private void InitializeTreeView([NotNull] Site site)
        {
            Debug.ArgumentNotNull(site, nameof(site));

            var siteTreeViewItem = new SiteTreeViewItem(site);

            TreeView.Items.Add(siteTreeViewItem);

            var lastSelected = Storage.ReadString(CreateItemsDialogRegistryKey, "LastSelected", string.Empty);

            if (!string.IsNullOrEmpty(lastSelected))
            {
                ItemUri itemUri;
                if (ItemUri.TryParse(lastSelected, out itemUri))
                {
                    if (TreeView.ExpandTo(itemUri) != null)
                    {
                        return;
                    }
                }
            }

            siteTreeViewItem.IsExpanded = true;
        }