コード例 #1
0
ファイル: DiskForm.cs プロジェクト: ypatrin/KozaDisk
        private void SingleDiskForm_Load(object sender, EventArgs e)
        {
            //prepare tree
            this.KOTreeCatalogs.Nodes.Clear();
            List <Editor.Class.Catalog> catalogs = this.DataBase.getCatalogs();

            CatalogNode baseNode = new CatalogNode();

            baseNode.Text = "Коза Онлайн";

            foreach (Editor.Class.Catalog catalog in catalogs)
            {
                if (catalog.parentId == "0")
                {
                    CatalogNode node = new CatalogNode();
                    node.id                 = catalog.id;
                    node.name               = catalog.id;
                    node.Text               = $"[{catalog.id}] " + catalog.name;
                    node.catalogName        = catalog.name;
                    node.ImageIndex         = 1;
                    node.SelectedImageIndex = 2;

                    //get parent
                    foreach (Editor.Class.Catalog parentCatalog in catalogs)
                    {
                        if (catalog.id == parentCatalog.parentId)
                        {
                            CatalogNode parentNode = new CatalogNode();
                            parentNode.id                 = parentCatalog.id;
                            parentNode.name               = parentCatalog.id;
                            parentNode.Text               = $"[{parentCatalog.id}] " + parentCatalog.name;
                            parentNode.catalogName        = parentCatalog.name;
                            parentNode.ImageIndex         = 1;
                            parentNode.SelectedImageIndex = 2;

                            node.Nodes.Add(parentNode);
                        }
                    }

                    baseNode.Nodes.Add(node);
                }
            }

            this.KOTreeCatalogs.Nodes.Add(baseNode);

            //prepare browser
            this.FilesBrowser.ObjectForScripting = this;
            this.FilesBrowser.Navigate("about:blank");
            this.FilesBrowser.DocumentText = "0";
            this.FilesBrowser.Document.OpenNew(true);
            this.FilesBrowser.Document.Write("");
            this.FilesBrowser.Refresh();
        }
コード例 #2
0
ファイル: DiskForm.cs プロジェクト: ypatrin/KozaDisk
        private void KOTreeCatalogs_AfterSelect(object sender, TreeViewEventArgs e)
        {
            CatalogNode selectedNode = (CatalogNode)this.KOTreeCatalogs.SelectedNode;
            string      filesHtml    = Properties.Resources.Files;
            string      fileHtml     = "";

            this.FilesBrowser.Document.OpenNew(true);

            if (selectedNode != null)
            {
                List <Editor.Class.Document> documents = this.DataBase.getDocuments(selectedNode.id);

                foreach (Editor.Class.Document document in documents)
                {
                    string fileName     = document.name;
                    string fileNameFull = document.name;

                    if (fileName.Length > 45)
                    {
                        fileName = fileName.Substring(0, 45) + "...";
                    }

                    if (fileName == fileNameFull)
                    {
                        fileNameFull = String.Empty;
                    }

                    fileHtml += $"<div class=\"block\" type=\"folder\">";
                    fileHtml += $"<div class=\"head\" title=\"{fileNameFull}\">{fileName}</div>";
                    fileHtml += $"<div class=\"image\"><img src=\"{Constant.ApplcationPath}icon\\doc.png\"/></div>";
                    fileHtml += $"<div class=\"tmpl_count\"><select id=\"doc_type_{document.id}\"><option value=\"portrait\">Портретный</option><option value=\"album\">Альбомный</option></select></div>";
                    fileHtml += $"<div class=\"tmpl_count\"><a href=\"#\" onClick=\"window.external.addDocument('{document.id}', '{document.name}'); return false;\" >Добавить</a></div>";
                    fileHtml += "</div>";
                }

                filesHtml = filesHtml.Replace("%disks_blocks%", fileHtml);
                filesHtml = filesHtml.Replace("%AppPath%", Constant.ApplcationPath);
                filesHtml = filesHtml.Replace("%AppPathUrl%", Constant.ApplcationPath.Replace(@"\", @"/"));

                this.FilesBrowser.Document.Write(filesHtml);
            }
        }