コード例 #1
0
        public void OpenItem(ISiteItem selectedItem)
        {
            var webDocumentItem = selectedItem as WebDocumentItem;

            if (webDocumentItem != null)
            {
                eventAggregator.Publish(new OpenFromWebEvent(webDocumentItem.Id, webDocumentItem.Name, Blog));
            }
        }
コード例 #2
0
ファイル: WebDocument.cs プロジェクト: zhouhua/DownmarkerWPF
        public override bool IsSameItem(ISiteItem siteItem)
        {
            var webDocumentItem = siteItem as WebDocumentItem;

            if (webDocumentItem != null)
            {
                return(webDocumentItem.Id == Id);
            }

            return(false);
        }
コード例 #3
0
        public override bool IsSameItem(ISiteItem siteItem)
        {
            var fileItem = siteItem as FileSystemSiteItem;

            if (fileItem == null)
            {
                return(false);
            }

            return(fileItem.Path == FileName);
        }
コード例 #4
0
        private void btn_add_provider_Click(object sender, EventArgs e)
        {
            ISiteItem     siteItem     = Youtube2MP.SiteItemProvider[cmb_providers.SelectedItem.ToString()];
            ListViewItem  listViewItem = new ListViewItem(siteItem.Name);
            SiteItemEntry entry        = new SiteItemEntry()
            {
                Provider = siteItem.Name, Title = siteItem.Name
            };

            if (siteItem.Name == "Folder")
            {
                listViewItem.BackColor = Color.Cyan;
            }
            listViewItem.Tag      = entry;
            listViewItem.Selected = true;
            list_startpage.Items.Add(listViewItem);
        }
コード例 #5
0
 void webMatrixHost_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
 {
     try
     {
         ISiteItem siteItem = e.Items.FirstOrDefault <ISiteItem>();
         if (siteItem != null)
         {
             ISiteFolder siteFolder = siteItem as ISiteFolder;
             if (siteFolder != null) // folders must end with '\'
             {
                 e.AddMenuItem(new ContextMenuItem("Compile TypeScript files in folder", _typescriptCompileImageSmall,
                                                   new DelegateCommand(CanExecute, (parameter) =>
                 {
                     if (!_executer.Start())
                     {
                         return;
                     }
                     var tsfiles = Directory.GetFiles(siteFolder.Path, "*.ts", SearchOption.AllDirectories);
                     CompileTypeScriptFilesAsync(tsfiles).ContinueWith((antecedent) => _executer.End());
                 }), null));
             }
             else
             {
                 var siteFile = siteItem as ISiteFile;
                 if (siteFile != null && Path.GetExtension(siteFile.Path) == ".ts")
                 {
                     e.AddMenuItem(new ContextMenuItem("Compile TypeScript file", _typescriptCompileImageSmall,
                                                       new DelegateCommand(CanExecute, (parameter) =>
                     {
                         if (!_executer.Start())
                         {
                             return;
                         }
                         var tsfiles = new string[] { siteFile.Path };
                         CompileTypeScriptFilesAsync(tsfiles).ContinueWith((antecedent) => _executer.End());
                     }), null));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _webMatrixHost.ShowExceptionMessage("Compile TypeScript (context menu)", "The following error occured. Please report at https://github.com/MacawNL/TypeScript4WebMatrix/issues.", ex);
     }
 }
コード例 #6
0
        public FileSystemSiteItem(string filePath)
        {
            Path = filePath;
            Name = System.IO.Path.GetFileName(filePath);

            if (File.Exists(filePath))
                Children = new ISiteItem[0];
            else
            {
                Children = Directory.GetDirectories(filePath)
                    .Select(ToFileSystemItem)
                    .OrderBy(i => i.Name)
                    .Concat(Directory.GetFiles(filePath) //TODO Restrict to markdown files only?
                                .Select(ToFileSystemItem)
                                .OrderBy(i => i.Name))
                    .ToArray();
            }
        }
コード例 #7
0
        public FileSystemSiteItem(string filePath)
        {
            Path = filePath;
            Name = System.IO.Path.GetFileName(filePath);

            if (File.Exists(filePath))
            {
                Children = new ISiteItem[0];
            }
            else
            {
                Children = Directory.GetDirectories(filePath)
                           .Select(ToFileSystemItem)
                           .OrderBy(i => i.Name)
                           .Concat(Directory.GetFiles(filePath) //TODO Restrict to markdown files only?
                                   .Select(ToFileSystemItem)
                                   .OrderBy(i => i.Name))
                           .ToArray();
            }
        }
コード例 #8
0
        public void OpenItem(ISiteItem selectedItem)
        {
            var fileItem = selectedItem as FileSystemSiteItem;
            if (fileItem == null || !File.Exists(fileItem.Path)) return;

            if (Constants.DefaultExtensions.Contains(Path.GetExtension(fileItem.Path).ToLower()))
            {
                eventAggregator.Publish(new FileOpenEvent(fileItem.Path));
            }
            else
            {
                try
                {
                    Process.Start(fileItem.Path);
                }
                catch (Exception ex)
                {
                    dialogService.ShowError("Failed to open file", "Cannot open {0}", ex.Message);
                }
            }
        }
コード例 #9
0
        private void list_startpage_SelectedIndexChanged(object sender, EventArgs e)
        {
            panel1.Controls.Clear();
            if (selectedSiteitem != null)
            {
                selectedSiteitem.ParentFolder = (string)cmb_folder.SelectedItem;
                selectedSiteitem.ConfigString = selectedSiteitem.GetConfigString();
            }

            cmb_folder.Items.Clear();
            cmb_folder.Items.Add("");

            foreach (ListViewItem item in list_startpage.Items)
            {
                SiteItemEntry siteItemEntry = item.Tag as SiteItemEntry;
                if (siteItemEntry != null && Youtube2MP.SiteItemProvider[siteItemEntry.Provider].GetType() == typeof(Folder))
                {
                    cmb_folder.Items.Add(siteItemEntry.Title);
                }
            }
            if (list_startpage.SelectedItems.Count > 0 && !loading)
            {
                SiteItemEntry entry = list_startpage.SelectedItems[0].Tag as SiteItemEntry;
                selectedSiteitem        = entry;
                cmb_folder.SelectedItem = selectedSiteitem.ParentFolder;
                ISiteItem siteItem = Youtube2MP.SiteItemProvider[entry.Provider];
                siteItem.Configure(entry);
                if (siteItem.ConfigControl != null)
                {
                    panel1.Controls.Add(siteItem.ConfigControl);
                }
            }
            foreach (ListViewItem listViewItemitem in list_startpage.Items)
            {
                listViewItemitem.Text = ((SiteItemEntry)listViewItemitem.Tag).Title;
            }
            BuildTree();
        }
コード例 #10
0
 public override bool IsSameItem(ISiteItem siteItem)
 {
     return(false);
 }
コード例 #11
0
 public abstract bool IsSameItem(ISiteItem siteItem);
コード例 #12
0
 public override bool IsSameItem(ISiteItem siteItem)
 {
     return false;
 }
コード例 #13
0
 public static void AddSiteItem(ISiteItem siteItem)
 {
     SiteItemProvider.Add(siteItem.Name, siteItem);
 }
コード例 #14
0
 public void OpenItem(ISiteItem selectedItem)
 {
 }
コード例 #15
0
ファイル: WebDocument.cs プロジェクト: rudimk/DownmarkerWPF
        public override bool IsSameItem(ISiteItem siteItem)
        {
            var webDocumentItem = siteItem as WebDocumentItem;
            if (webDocumentItem != null)
                return webDocumentItem.Id == Id;

            return false;
        }
コード例 #16
0
 public void OpenItem(ISiteItem selectedItem)
 {
 }
コード例 #17
0
 public void OpenItem(ISiteItem selectedItem)
 {
     var webDocumentItem = selectedItem as WebDocumentItem;
     if (webDocumentItem != null)
         eventAggregator.Publish(new OpenFromWebEvent(webDocumentItem.Id, webDocumentItem.Name, Blog));
 }
コード例 #18
0
 static public void AddSiteItem(ISiteItem siteItem)
 {
     SiteItemProvider.Add(siteItem.Name, siteItem);
 }