Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5847 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
5 changed files with 178 additions and 1 deletions
@ -0,0 +1,20 @@ |
|||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
|
||||||
|
namespace MSHelpSystem.Controls |
||||||
|
{ |
||||||
|
public class Help3TocPad : AbstractPadContent |
||||||
|
{ |
||||||
|
public Help3TocPad() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
TocPadControl toc = new TocPadControl(); |
||||||
|
|
||||||
|
public override object Control |
||||||
|
{ |
||||||
|
get { return toc; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,80 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Sebastian Ullrich" email=""/>
|
||||||
|
// <version>$Revision: 5842 $</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq; |
||||||
|
using System.Net; |
||||||
|
using System.Reflection; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Media.Animation; |
||||||
|
using System.Xml.Linq; |
||||||
|
using System.Xml.XPath; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using MSHelpSystem.Core; |
||||||
|
using MSHelpSystem.Core.Native; |
||||||
|
|
||||||
|
namespace MSHelpSystem.Controls |
||||||
|
{ |
||||||
|
class TocEntry : INotifyPropertyChanged |
||||||
|
{ |
||||||
|
const string url = "ms-xhelp://?method=children&id={3}&format=xml&product={0}&productVersion={1}&locale={2}"; |
||||||
|
string id; |
||||||
|
WebClient client = new WebClient(); |
||||||
|
|
||||||
|
public TocEntry(string id) |
||||||
|
{ |
||||||
|
this.id = id; |
||||||
|
|
||||||
|
client.DownloadStringCompleted += (_, e) => |
||||||
|
{ |
||||||
|
LoggingService.Debug(string.Format("Help 3.0: title \"{0}\"", Title)); |
||||||
|
var children = XElement.Parse(e.Result); |
||||||
|
Children = children.Elements("topic") |
||||||
|
.Select(link => new TocEntry(link.Attribute("id").Value) { Title = link.Element("title").Value }) |
||||||
|
.ToArray(); |
||||||
|
client.Dispose(); |
||||||
|
}; |
||||||
|
RaisePropertyChanged("Children"); |
||||||
|
} |
||||||
|
|
||||||
|
public string Title { get; set; } |
||||||
|
public string Id { get { return id; } } |
||||||
|
|
||||||
|
static object[] defaultChild = new object[] { null }; |
||||||
|
IEnumerable children; |
||||||
|
|
||||||
|
public IEnumerable Children |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
Help3Catalog catalog = Help3Service.ActiveCatalog; |
||||||
|
if (children == null && !client.IsBusy) |
||||||
|
client.DownloadStringAsync(new Uri(Help3Environment.GetHttpFromMsXHelp(string.Format(url, catalog.ProductCode, catalog.ProductVersion, catalog.Locale, id)))); |
||||||
|
return children ?? defaultChild; |
||||||
|
} |
||||||
|
private set |
||||||
|
{ |
||||||
|
children = value; |
||||||
|
RaisePropertyChanged("Children"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; |
||||||
|
|
||||||
|
protected void RaisePropertyChanged(string name) |
||||||
|
{ |
||||||
|
System.ComponentModel.PropertyChangedEventHandler handler = PropertyChanged; |
||||||
|
if (handler != null) handler(this, new System.ComponentModel.PropertyChangedEventArgs(name)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<UserControl |
||||||
|
x:Class="MSHelpSystem.Controls.TocPadControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||||
|
<Grid> |
||||||
|
<TreeView |
||||||
|
Name="tocTreeView" |
||||||
|
SelectedValuePath="Id" |
||||||
|
SelectedItemChanged="Help3TocItemChanged" |
||||||
|
ItemsSource="{Binding}" |
||||||
|
HorizontalAlignment="Stretch" |
||||||
|
VerticalAlignment="Stretch" |
||||||
|
Margin="0"> |
||||||
|
<TreeView.ItemTemplate> |
||||||
|
<HierarchicalDataTemplate |
||||||
|
ItemsSource="{Binding Children}"> |
||||||
|
<TextBlock |
||||||
|
Text="{Binding Title}" /> |
||||||
|
</HierarchicalDataTemplate> |
||||||
|
</TreeView.ItemTemplate> |
||||||
|
</TreeView> |
||||||
|
</Grid> |
||||||
|
</UserControl> |
@ -0,0 +1,52 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Sebastian Ullrich" email=""/>
|
||||||
|
// <version>$Revision: 5842 $</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Documents; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Media; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using MSHelpSystem.Core; |
||||||
|
|
||||||
|
namespace MSHelpSystem.Controls |
||||||
|
{ |
||||||
|
public partial class TocPadControl : UserControl |
||||||
|
{ |
||||||
|
public TocPadControl() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
LoadToc(); |
||||||
|
Help3Service.ConfigurationUpdated += new EventHandler(Help3ServiceConfigurationUpdated); |
||||||
|
} |
||||||
|
|
||||||
|
void LoadToc() |
||||||
|
{ |
||||||
|
if (!Help3Environment.IsLocalHelp) DataContext = null; |
||||||
|
// TODO: Needs a localization
|
||||||
|
else DataContext = new[] { new TocEntry("-1") { Title = "Help Library" } }; |
||||||
|
} |
||||||
|
|
||||||
|
void Help3TocItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) |
||||||
|
{ |
||||||
|
string topicId = (string)tocTreeView.SelectedValue; |
||||||
|
if (!string.IsNullOrEmpty(topicId)) { |
||||||
|
LoggingService.Debug(string.Format("Help 3.0: [TOC] Calling page with Id \"{0}\"", topicId)); |
||||||
|
DisplayHelp.Page(topicId); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void Help3ServiceConfigurationUpdated(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
LoadToc(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue