public void OpenItem(ISiteItem selectedItem) { var webDocumentItem = selectedItem as WebDocumentItem; if (webDocumentItem != null) { eventAggregator.Publish(new OpenFromWebEvent(webDocumentItem.Id, webDocumentItem.Name, Blog)); } }
public override bool IsSameItem(ISiteItem siteItem) { var webDocumentItem = siteItem as WebDocumentItem; if (webDocumentItem != null) { return(webDocumentItem.Id == Id); } return(false); }
public override bool IsSameItem(ISiteItem siteItem) { var fileItem = siteItem as FileSystemSiteItem; if (fileItem == null) { return(false); } return(fileItem.Path == FileName); }
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); }
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); } }
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(); } }
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(); } }
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); } } }
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(); }
public override bool IsSameItem(ISiteItem siteItem) { return(false); }
public abstract bool IsSameItem(ISiteItem siteItem);
public override bool IsSameItem(ISiteItem siteItem) { return false; }
public static void AddSiteItem(ISiteItem siteItem) { SiteItemProvider.Add(siteItem.Name, siteItem); }
public void OpenItem(ISiteItem selectedItem) { }
public override bool IsSameItem(ISiteItem siteItem) { var webDocumentItem = siteItem as WebDocumentItem; if (webDocumentItem != null) return webDocumentItem.Id == Id; return false; }
public void OpenItem(ISiteItem selectedItem) { var webDocumentItem = selectedItem as WebDocumentItem; if (webDocumentItem != null) eventAggregator.Publish(new OpenFromWebEvent(webDocumentItem.Id, webDocumentItem.Name, Blog)); }
static public void AddSiteItem(ISiteItem siteItem) { SiteItemProvider.Add(siteItem.Name, siteItem); }