git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3737 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
<Application x:Class="SharpDevelop.Samples.XamlDesigner.App" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:sd="http://sharpdevelop.net" |
||||
xmlns:Converters="clr-namespace:SharpDevelop.Samples.XamlDesigner.Converters" |
||||
xmlns:Default="clr-namespace:SharpDevelop.Samples.XamlDesigner" |
||||
StartupUri="MainWindow.xaml" |
||||
ShutdownMode="OnMainWindowClose"> |
||||
<Application.Resources> |
||||
|
||||
<ResourceDictionary> |
||||
<ResourceDictionary.MergedDictionaries> |
||||
<ResourceDictionary Source="/Themes/ExpressionTheme.xaml" /> |
||||
<ResourceDictionary Source="/AvalonDock;component/Themes/DarkTheme.xaml" /> |
||||
<ResourceDictionary Source="/SharpDevelop.XamlDesigner;component/App.xaml" /> |
||||
</ResourceDictionary.MergedDictionaries> |
||||
|
||||
<Converters:CollapsedWhenFalse x:Key="CollapsedWhenFalse" /> |
||||
<Converters:FalseWhenZero x:Key="FalseWhenZero" /> |
||||
|
||||
<!--<Brush x:Key="RecessedBrush">#383838</Brush> |
||||
<Brush x:Key="ButtonOverBrush">#3F3F3F</Brush> |
||||
<Brush x:Key="MouseOverForegroundBrush">White</Brush>--> |
||||
|
||||
<sd:CommandView x:Key="SaveAll" |
||||
Text="Save All" |
||||
Shortcut="Control+Shift+S" /> |
||||
|
||||
<sd:CommandView x:Key="CloseAll" |
||||
Text="Close All" /> |
||||
|
||||
</ResourceDictionary> |
||||
|
||||
</Application.Resources> |
||||
</Application> |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Configuration; |
||||
using System.Data; |
||||
using System.Linq; |
||||
using System.Windows; |
||||
using SharpDevelop.Samples.XamlDesigner.Properties; |
||||
using System.Windows.Threading; |
||||
using System.Diagnostics; |
||||
|
||||
namespace SharpDevelop.Samples.XamlDesigner |
||||
{ |
||||
public partial class App : Application |
||||
{ |
||||
public static string[] Args; |
||||
|
||||
protected override void OnStartup(StartupEventArgs e) |
||||
{ |
||||
Args = e.Args; |
||||
DispatcherUnhandledException += App_DispatcherUnhandledException; |
||||
System.Windows.Forms.Application.EnableVisualStyles(); |
||||
base.OnStartup(e); |
||||
} |
||||
|
||||
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) |
||||
{ |
||||
if (!Debugger.IsAttached && Shell.Instance.CurrentDocument != null) { |
||||
Shell.Instance.CurrentDocument.Context.DesignView.Exception = e.Exception; |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
protected override void OnExit(ExitEventArgs e) |
||||
{ |
||||
Settings.Default.Save(); |
||||
base.OnExit(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Data; |
||||
using System.Globalization; |
||||
using System.Windows; |
||||
using System.Collections; |
||||
using AvalonDock; |
||||
|
||||
namespace SharpDevelop.Samples.XamlDesigner.Converters |
||||
{ |
||||
public class EnumToIntConverter : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (int)value; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
public class CollapsedWhenFalse : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (bool)value ? Visibility.Visible : Visibility.Collapsed; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class FalseWhenZero : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value == null || (int)value == 0) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class LevelConverter : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return new Thickness(5 + 19 * (int)value, 0, 5, 0); |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Media; |
||||
using System.IO; |
||||
using System.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Collections; |
||||
|
||||
namespace SharpDevelop.Samples.XamlDesigner |
||||
{ |
||||
static class ExtensionMethods |
||||
{ |
||||
public static IEnumerable<string> Paths(this IDataObject data) |
||||
{ |
||||
string[] paths = (string[])data.GetData(DataFormats.FileDrop); |
||||
if (paths != null) { |
||||
foreach (var path in paths) { |
||||
yield return path; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static T GetObject<T>(this IDataObject data) |
||||
{ |
||||
return (T)data.GetData(typeof(T).FullName); |
||||
} |
||||
|
||||
public static Stream ToStream(this string s) |
||||
{ |
||||
return new MemoryStream(Encoding.UTF8.GetBytes(s)); |
||||
} |
||||
|
||||
public static void AddRange<T>(this ObservableCollection<T> col, IEnumerable<T> items) |
||||
{ |
||||
foreach (var item in items) { |
||||
col.Add(item); |
||||
} |
||||
} |
||||
|
||||
public static void KeepSyncronizedWith<S>(this IList target, ObservableCollection<S> source, Func<S, object> convert) |
||||
{ |
||||
target.Clear(); |
||||
foreach (var item in source) { |
||||
target.Add(convert(item)); |
||||
} |
||||
|
||||
source.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) { |
||||
switch (e.Action) { |
||||
case NotifyCollectionChangedAction.Add: |
||||
target.Add(convert((S)e.NewItems[0])); |
||||
break; |
||||
|
||||
case NotifyCollectionChangedAction.Remove: |
||||
target.RemoveAt(e.OldStartingIndex); |
||||
break; |
||||
|
||||
case NotifyCollectionChangedAction.Move: |
||||
target.RemoveAt(e.OldStartingIndex); |
||||
target.Insert(e.NewStartingIndex, e.NewItems[0]); |
||||
break; |
||||
|
||||
case NotifyCollectionChangedAction.Replace: |
||||
target[e.NewStartingIndex] = convert((S)e.NewItems[0]); |
||||
break; |
||||
|
||||
case NotifyCollectionChangedAction.Reset: |
||||
target.Clear(); |
||||
break; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public static object GetDataContext(this RoutedEventArgs e) |
||||
{ |
||||
var f = e.OriginalSource as FrameworkElement; |
||||
if (f != null) return f.DataContext; |
||||
return null; |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 389 B |
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
<Window x:Class="SharpDevelop.Samples.XamlDesigner.MainWindow" |
||||
x:Name="root" |
||||
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:sd="http://sharpdevelop.net" |
||||
xmlns:AvalonDock="clr-namespace:AvalonDock;assembly=AvalonDock" |
||||
xmlns:Default="clr-namespace:SharpDevelop.Samples.XamlDesigner" |
||||
SnapsToDevicePixels="True" |
||||
Title="{Binding Title}" |
||||
FontFamily="Tahoma"> |
||||
|
||||
<DockPanel> |
||||
|
||||
<Menu DockPanel.Dock="Top"> |
||||
<MenuItem Header="File"> |
||||
<MenuItem sd:CommandHelper.Command="New" /> |
||||
<MenuItem sd:CommandHelper.Command="Open" /> |
||||
<Separator /> |
||||
<MenuItem sd:CommandHelper.Command="Close" /> |
||||
<MenuItem sd:CommandHelper.Command="CloseAll" /> |
||||
<Separator /> |
||||
<MenuItem sd:CommandHelper.Command="Save" /> |
||||
<MenuItem sd:CommandHelper.Command="SaveAs" /> |
||||
<MenuItem sd:CommandHelper.Command="SaveAll" /> |
||||
<Separator /> |
||||
<MenuItem Header="Recent Files" |
||||
ItemsSource="{Binding RecentFiles}" |
||||
IsEnabled="{Binding RecentFiles.Count, Converter={StaticResource FalseWhenZero}}" |
||||
Click="RecentFiles_Click" /> |
||||
<Separator /> |
||||
<MenuItem sd:CommandHelper.Command="Exit" /> |
||||
</MenuItem> |
||||
<MenuItem Header="Edit" |
||||
DataContext="{Binding CurrentDocument.Context.DesignCommands}"> |
||||
<MenuItem sd:CommandHelper.Command="Undo" /> |
||||
<MenuItem sd:CommandHelper.Command="Redo" /> |
||||
<Separator /> |
||||
<MenuItem sd:CommandHelper.Command="Cut" /> |
||||
<MenuItem sd:CommandHelper.Command="Copy" /> |
||||
<MenuItem sd:CommandHelper.Command="Paste" /> |
||||
<MenuItem sd:CommandHelper.Command="Delete" /> |
||||
<MenuItem sd:CommandHelper.Command="SelectAll" /> |
||||
</MenuItem> |
||||
<MenuItem Header="View"> |
||||
<MenuItem Header="Palette" |
||||
IsCheckable="True" |
||||
IsChecked="{Binding Path=(Default:MainWindow.DockableContentVisibility).IsVisible, ElementName=content1}"/> |
||||
<MenuItem Header="Outline" |
||||
IsCheckable="True" |
||||
IsChecked="{Binding Path=(Default:MainWindow.DockableContentVisibility).IsVisible, ElementName=content2}"/> |
||||
<MenuItem Header="Properties" |
||||
IsCheckable="True" |
||||
IsChecked="{Binding Path=(Default:MainWindow.DockableContentVisibility).IsVisible, ElementName=content3}"/> |
||||
</MenuItem> |
||||
</Menu> |
||||
|
||||
<AvalonDock:DockingManager x:Name="uxDockingManager"> |
||||
<AvalonDock:ResizingPanel Orientation="Horizontal"> |
||||
|
||||
<AvalonDock:DockablePane AvalonDock:ResizingPanel.ResizeWidth="200"> |
||||
<AvalonDock:DockableContent x:Name="content2" |
||||
Title="Outline" |
||||
Default:MainWindow.AttachDockableContentVisibility="True"> |
||||
<sd:OutlineView Context="{Binding CurrentDocument.Context}" /> |
||||
</AvalonDock:DockableContent> |
||||
</AvalonDock:DockablePane> |
||||
|
||||
<AvalonDock:ResizingPanel Orientation="Vertical"> |
||||
|
||||
<AvalonDock:DockablePane AvalonDock:ResizingPanel.ResizeWidth="200" |
||||
AvalonDock:ResizingPanel.ResizeHeight="160"> |
||||
<AvalonDock:DockableContent x:Name="content1" |
||||
Title="Palette" |
||||
Default:MainWindow.AttachDockableContentVisibility="True"> |
||||
<sd:PaletteView x:Name="uxPalette" |
||||
Context="{Binding CurrentDocument.Context}" /> |
||||
</AvalonDock:DockableContent> |
||||
</AvalonDock:DockablePane> |
||||
|
||||
<AvalonDock:DocumentPane x:Name="uxDocumentPane" |
||||
SelectedValue="{Binding CurrentDocument}" |
||||
SelectedValuePath="DataContext" /> |
||||
|
||||
</AvalonDock:ResizingPanel> |
||||
|
||||
<AvalonDock:DockablePane AvalonDock:ResizingPanel.ResizeWidth="257"> |
||||
<AvalonDock:DockableContent x:Name="content3" |
||||
Title="Properties" |
||||
Default:MainWindow.AttachDockableContentVisibility="True"> |
||||
<sd:PropertyGridView x:Name="uxPropertyGridView" |
||||
Context="{Binding CurrentDocument.Context}" /> |
||||
</AvalonDock:DockableContent> |
||||
</AvalonDock:DockablePane> |
||||
|
||||
</AvalonDock:ResizingPanel> |
||||
</AvalonDock:DockingManager> |
||||
</DockPanel> |
||||
</Window> |
@ -0,0 +1,258 @@
@@ -0,0 +1,258 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
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 System.Windows.Media.Imaging; |
||||
using System.Windows.Shapes; |
||||
using SharpDevelop.Samples.XamlDesigner.Properties; |
||||
using System.ComponentModel; |
||||
using Microsoft.Win32; |
||||
using AvalonDock; |
||||
using System.IO; |
||||
using System.Collections.Specialized; |
||||
using System.Globalization; |
||||
using SharpDevelop.XamlDesigner; |
||||
|
||||
namespace SharpDevelop.Samples.XamlDesigner |
||||
{ |
||||
public partial class MainWindow : Window |
||||
{ |
||||
public MainWindow() |
||||
{ |
||||
Instance = this; |
||||
DataContext = Shell.Instance; |
||||
|
||||
InitializeComponent(); |
||||
|
||||
AvalonDockWorkaround(); |
||||
LoadSettings(); |
||||
ProcessPaths(App.Args); |
||||
|
||||
Shell.Instance.Open("../../TestFiles/6.xaml"); |
||||
} |
||||
|
||||
public static MainWindow Instance; |
||||
|
||||
OpenFileDialog openFileDialog; |
||||
SaveFileDialog saveFileDialog; |
||||
|
||||
void RecentFiles_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
var path = (string)(e.OriginalSource as MenuItem).Header; |
||||
Shell.Instance.Open(path); |
||||
} |
||||
|
||||
protected override void OnClosing(CancelEventArgs e) |
||||
{ |
||||
if (Shell.Instance.PrepareExit()) { |
||||
SaveSettings(); |
||||
} |
||||
else { |
||||
e.Cancel = true; |
||||
} |
||||
base.OnClosing(e); |
||||
} |
||||
|
||||
protected override void OnDragEnter(DragEventArgs e) |
||||
{ |
||||
ProcessDrag(e); |
||||
} |
||||
|
||||
protected override void OnDragOver(DragEventArgs e) |
||||
{ |
||||
ProcessDrag(e); |
||||
} |
||||
|
||||
protected override void OnDrop(DragEventArgs e) |
||||
{ |
||||
ProcessPaths(e.Data.Paths()); |
||||
} |
||||
|
||||
void ProcessDrag(DragEventArgs e) |
||||
{ |
||||
e.Effects = DragDropEffects.None; |
||||
e.Handled = true; |
||||
|
||||
foreach (var path in e.Data.Paths()) { |
||||
if (HasXamlExtension(path)) { |
||||
e.Effects = DragDropEffects.Copy; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ProcessPaths(IEnumerable<string> paths) |
||||
{ |
||||
foreach (var path in paths) { |
||||
if (HasXamlExtension(path)) { |
||||
Shell.Instance.Open(path); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static bool HasXamlExtension(string filePath) |
||||
{ |
||||
return System.IO.Path.GetExtension(filePath).Equals(".xaml", StringComparison.InvariantCultureIgnoreCase); |
||||
} |
||||
|
||||
public string AskOpenFileName() |
||||
{ |
||||
if (openFileDialog == null) { |
||||
openFileDialog = new OpenFileDialog(); |
||||
openFileDialog.Filter = "Xaml Documents (*.xaml)|*.xaml"; |
||||
} |
||||
if ((bool)openFileDialog.ShowDialog()) { |
||||
return openFileDialog.FileName; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public string AskSaveFileName(string initName) |
||||
{ |
||||
if (saveFileDialog == null) { |
||||
saveFileDialog = new SaveFileDialog(); |
||||
saveFileDialog.Filter = "Xaml Documents (*.xaml)|*.xaml"; |
||||
} |
||||
saveFileDialog.FileName = initName; |
||||
if ((bool)saveFileDialog.ShowDialog()) { |
||||
return saveFileDialog.FileName; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
void LoadSettings() |
||||
{ |
||||
WindowState = Settings.Default.MainWindowState; |
||||
|
||||
Rect r = Settings.Default.MainWindowRect; |
||||
if (r != new Rect()) { |
||||
Left = r.Left; |
||||
Top = r.Top; |
||||
Width = r.Width; |
||||
Height = r.Height; |
||||
} |
||||
|
||||
if (!string.IsNullOrEmpty(Settings.Default.AvalonDockLayout)) { |
||||
uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream()); |
||||
} |
||||
|
||||
if (!string.IsNullOrEmpty(Settings.Default.PaletteData)) { |
||||
uxPalette.LoadData(Settings.Default.PaletteData); |
||||
} |
||||
else { |
||||
uxPalette.ResetData(); |
||||
} |
||||
} |
||||
|
||||
void SaveSettings() |
||||
{ |
||||
Settings.Default.MainWindowState = WindowState; |
||||
if (WindowState == WindowState.Normal) { |
||||
Settings.Default.MainWindowRect = new Rect(Left, Top, Width, Height); |
||||
} |
||||
|
||||
var writer = new StringWriter(); |
||||
uxDockingManager.SaveLayout(writer); |
||||
Settings.Default.AvalonDockLayout = writer.ToString(); |
||||
|
||||
Settings.Default.PaletteData = uxPalette.SaveData(); |
||||
|
||||
Shell.Instance.SaveSettings(); |
||||
} |
||||
|
||||
#region AvalonDockWorkaround
|
||||
|
||||
void AvalonDockWorkaround() |
||||
{ |
||||
uxDocumentPane.Items.KeepSyncronizedWith(Shell.Instance.Documents, d => CreateContentFor(d)); |
||||
} |
||||
|
||||
DocumentContent CreateContentFor(ShellDocument doc) |
||||
{ |
||||
var content = new DocumentContent() { |
||||
DataContext = doc, |
||||
Content = doc.View |
||||
}; |
||||
content.SetBinding(DocumentContent.TitleProperty, "Title"); |
||||
return content; |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region DockableContentVisibility
|
||||
|
||||
public static DockableContentVisibility GetDockableContentVisibility(DependencyObject obj) |
||||
{ |
||||
return (DockableContentVisibility)obj.GetValue(DockableContentVisibilityProperty); |
||||
} |
||||
|
||||
public static void SetDockableContentVisibility(DependencyObject obj, DockableContentVisibility value) |
||||
{ |
||||
obj.SetValue(DockableContentVisibilityProperty, value); |
||||
} |
||||
|
||||
public static readonly DependencyProperty DockableContentVisibilityProperty = |
||||
DependencyProperty.RegisterAttached("DockableContentVisibility", typeof(DockableContentVisibility), typeof(MainWindow)); |
||||
|
||||
public static bool GetAttachDockableContentVisibility(DependencyObject obj) |
||||
{ |
||||
return (bool)obj.GetValue(AttachDockableContentVisibilityProperty); |
||||
} |
||||
|
||||
public static void SetAttachDockableContentVisibility(DependencyObject obj, bool value) |
||||
{ |
||||
obj.SetValue(AttachDockableContentVisibilityProperty, value); |
||||
} |
||||
|
||||
public static readonly DependencyProperty AttachDockableContentVisibilityProperty = |
||||
DependencyProperty.RegisterAttached("AttachDockableContentVisibility", typeof(bool), typeof(MainWindow), |
||||
new PropertyMetadata(AttachDockableContentVisibilityChanged)); |
||||
|
||||
static void AttachDockableContentVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
var v = new DockableContentVisibility(d as DockableContent, MainWindow.Instance.uxDockingManager); |
||||
SetDockableContentVisibility(d, v); |
||||
} |
||||
|
||||
public class DockableContentVisibility : ViewModel |
||||
{ |
||||
public DockableContentVisibility(DockableContent content, DockingManager manager) |
||||
{ |
||||
this.content = content; |
||||
this.manager = manager; |
||||
|
||||
var dpd = DependencyPropertyDescriptor.FromProperty(DockableContent.StatePropertyKey.DependencyProperty, typeof(DockableContent)); |
||||
dpd.AddValueChanged(content, (s, e) => { RaisePropertyChanged("IsVisible"); }); |
||||
} |
||||
|
||||
DockableContent content; |
||||
DockingManager manager; |
||||
|
||||
public bool IsVisible |
||||
{ |
||||
get |
||||
{ |
||||
return content.State != DockableContentState.Hidden; |
||||
} |
||||
set |
||||
{ |
||||
if (value) { |
||||
manager.Show(content); |
||||
} |
||||
else { |
||||
manager.Hide(content); |
||||
} |
||||
RaisePropertyChanged("IsVisible"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<Canvas /> |
||||
</Window> |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
using System.Windows; |
||||
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] |
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.3053
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SharpDevelop.Samples.XamlDesigner.Properties { |
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] |
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
||||
|
||||
public static Settings Default { |
||||
get { |
||||
return defaultInstance; |
||||
} |
||||
} |
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()] |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
[global::System.Configuration.DefaultSettingValueAttribute("0,0,0,0")] |
||||
public global::System.Windows.Rect MainWindowRect { |
||||
get { |
||||
return ((global::System.Windows.Rect)(this["MainWindowRect"])); |
||||
} |
||||
set { |
||||
this["MainWindowRect"] = value; |
||||
} |
||||
} |
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()] |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public global::System.Collections.Specialized.StringCollection RecentFiles { |
||||
get { |
||||
return ((global::System.Collections.Specialized.StringCollection)(this["RecentFiles"])); |
||||
} |
||||
set { |
||||
this["RecentFiles"] = value; |
||||
} |
||||
} |
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()] |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
[global::System.Configuration.DefaultSettingValueAttribute(@"<?xml version=""1.0"" encoding=""utf-16""?>
|
||||
<ArrayOfString xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
|
||||
<string>%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll</string> |
||||
</ArrayOfString>")]
|
||||
public global::System.Collections.Specialized.StringCollection AssemblyList { |
||||
get { |
||||
return ((global::System.Collections.Specialized.StringCollection)(this["AssemblyList"])); |
||||
} |
||||
set { |
||||
this["AssemblyList"] = value; |
||||
} |
||||
} |
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()] |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
[global::System.Configuration.DefaultSettingValueAttribute("Maximized")] |
||||
public global::System.Windows.WindowState MainWindowState { |
||||
get { |
||||
return ((global::System.Windows.WindowState)(this["MainWindowState"])); |
||||
} |
||||
set { |
||||
this["MainWindowState"] = value; |
||||
} |
||||
} |
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()] |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
[global::System.Configuration.DefaultSettingValueAttribute("")] |
||||
public string AvalonDockLayout { |
||||
get { |
||||
return ((string)(this["AvalonDockLayout"])); |
||||
} |
||||
set { |
||||
this["AvalonDockLayout"] = value; |
||||
} |
||||
} |
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()] |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
[global::System.Configuration.DefaultSettingValueAttribute("")] |
||||
public string PaletteData { |
||||
get { |
||||
return ((string)(this["PaletteData"])); |
||||
} |
||||
set { |
||||
this["PaletteData"] = value; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
<?xml version='1.0' encoding='utf-8'?> |
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SharpDevelop.Samples.XamlDesigner.Properties" GeneratedClassName="Settings"> |
||||
<Profiles /> |
||||
<Settings> |
||||
<Setting Name="MainWindowRect" Type="System.Windows.Rect" Scope="User"> |
||||
<Value Profile="(Default)">0,0,0,0</Value> |
||||
</Setting> |
||||
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User"> |
||||
<Value Profile="(Default)" /> |
||||
</Setting> |
||||
<Setting Name="AssemblyList" Type="System.Collections.Specialized.StringCollection" Scope="User"> |
||||
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?> |
||||
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
||||
<string>%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll</string> |
||||
</ArrayOfString></Value> |
||||
</Setting> |
||||
<Setting Name="MainWindowState" Type="System.Windows.WindowState" Scope="User"> |
||||
<Value Profile="(Default)">Maximized</Value> |
||||
</Setting> |
||||
<Setting Name="AvalonDockLayout" Type="System.String" Scope="User"> |
||||
<Value Profile="(Default)" /> |
||||
</Setting> |
||||
<Setting Name="PaletteData" Type="System.String" Scope="User"> |
||||
<Value Profile="(Default)" /> |
||||
</Setting> |
||||
</Settings> |
||||
</SettingsFile> |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> |
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> |
||||
<security> |
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> |
||||
<!-- UAC Manifest Options |
||||
If you want to change the Windows User Account Control level replace the |
||||
requestedExecutionLevel node with one of the following. |
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> |
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> |
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> |
||||
|
||||
If you want to utilize File and Registry Virtualization for backward |
||||
compatibility then delete the requestedExecutionLevel node. |
||||
--> |
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> |
||||
</requestedPrivileges> |
||||
</security> |
||||
</trustInfo> |
||||
|
||||
<dependency> |
||||
<dependentAssembly> |
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity> |
||||
</dependentAssembly> |
||||
</dependency> |
||||
|
||||
</asmv1:assembly> |
@ -0,0 +1,147 @@
@@ -0,0 +1,147 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Documents; |
||||
using SharpDevelop.XamlDesigner.Controls; |
||||
using SharpDevelop.XamlDesigner.Placement; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Media; |
||||
using SharpDevelop.XamlDesigner.Dom; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
public class AdornerManager |
||||
{ |
||||
public AdornerManager(DesignContext context) |
||||
{ |
||||
this.context = context; |
||||
context.Selection.Changed += new DesignSelectionChangedHandler(Selection_Changed); |
||||
} |
||||
|
||||
DesignContext context; |
||||
GeneralAdorner insertAdorner; |
||||
|
||||
AdornerLayer AdornerLayer |
||||
{ |
||||
get { return context.DesignView.AdornerLayer; } |
||||
} |
||||
|
||||
void Selection_Changed(object sender, DesignSelectionChangedEventArgs e) |
||||
{ |
||||
foreach (var item in e.OldItems) { |
||||
if (item.View != null) { |
||||
OnUnselect(item); |
||||
} |
||||
} |
||||
foreach (var item in e.NewItems) { |
||||
if (item.View != null) { |
||||
OnSelect(item); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void AddGeneralAdorner(DesignItem item, FrameworkElement adorner) |
||||
{ |
||||
var generalAdorner = new GeneralAdorner(item.View); |
||||
generalAdorner.Child = adorner; |
||||
AdornerLayer.Add(generalAdorner); |
||||
} |
||||
|
||||
void ClearAdorners(DesignItem item) |
||||
{ |
||||
if (item.View != null) { |
||||
var adorners = AdornerLayer.GetAdorners(item.View); |
||||
if (adorners != null) { |
||||
foreach (var adorner in adorners) { |
||||
AdornerLayer.Remove(adorner); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void OnSelect(DesignItem item) |
||||
{ |
||||
AddGeneralAdorner(item, new ResizeAdorner()); |
||||
} |
||||
|
||||
public void OnUnselect(DesignItem item) |
||||
{ |
||||
ClearAdorners(item); |
||||
} |
||||
|
||||
public void OnBeginMove(IEnumerable<DesignItem> items) |
||||
{ |
||||
foreach (var item in context.Selection) { |
||||
ClearAdorners(item); |
||||
} |
||||
foreach (var item in items) { |
||||
AddGeneralAdorner(item, new MoveAdorner()); |
||||
} |
||||
} |
||||
|
||||
public void OnEndMove(IEnumerable<DesignItem> items) |
||||
{ |
||||
foreach (var item in items) { |
||||
ClearAdorners(item); |
||||
} |
||||
foreach (var item in context.Selection) { |
||||
OnSelect(item); |
||||
} |
||||
} |
||||
|
||||
public void ShowInsertAdorner(FrameworkElement target, Rect area, Dock side) |
||||
{ |
||||
if (insertAdorner == null) { |
||||
insertAdorner = new GeneralAdorner(target); |
||||
AdornerLayer.Add(insertAdorner); |
||||
} |
||||
|
||||
Point location; |
||||
double length; |
||||
Orientation orientation; |
||||
|
||||
switch (side) { |
||||
case Dock.Left: |
||||
location = area.TopLeft; |
||||
length = area.Height; |
||||
orientation = Orientation.Vertical; |
||||
break; |
||||
case Dock.Right: |
||||
location = area.TopRight; |
||||
length = area.Height; |
||||
orientation = Orientation.Vertical; |
||||
break; |
||||
case Dock.Top: |
||||
location = area.TopLeft; |
||||
length = area.Width; |
||||
orientation = Orientation.Horizontal; |
||||
break; |
||||
default: |
||||
location = area.BottomLeft; |
||||
length = area.Width; |
||||
orientation = Orientation.Horizontal; |
||||
break; |
||||
} |
||||
|
||||
var insertLine = new InsertLine(); |
||||
insertAdorner.Child = insertLine; |
||||
insertAdorner.ChildSize = new Size(length, double.NaN); |
||||
insertAdorner.ChildLocation = location; |
||||
|
||||
if (orientation == Orientation.Vertical) { |
||||
insertLine.LayoutTransform = new RotateTransform(90); |
||||
} |
||||
} |
||||
|
||||
public void HideInsertAdorner() |
||||
{ |
||||
if (insertAdorner != null) { |
||||
AdornerLayer.Remove(insertAdorner); |
||||
insertAdorner = null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
class ContainerAdorner : Control |
||||
{ |
||||
static ContainerAdorner() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ContainerAdorner), |
||||
new FrameworkPropertyMetadata(typeof(ContainerAdorner))); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
class GrabAdorner |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
class InsertLine : Control |
||||
{ |
||||
static InsertLine() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(InsertLine), |
||||
new FrameworkPropertyMetadata(typeof(InsertLine))); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
class MoveAdorner : Control |
||||
{ |
||||
static MoveAdorner() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MoveAdorner), |
||||
new FrameworkPropertyMetadata(typeof(MoveAdorner))); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
class PanelAdorner : Control |
||||
{ |
||||
static PanelAdorner() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PanelAdorner), |
||||
new FrameworkPropertyMetadata(typeof(PanelAdorner))); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
class ResizeAdorner : Control |
||||
{ |
||||
static ResizeAdorner() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeAdorner), |
||||
new FrameworkPropertyMetadata(typeof(ResizeAdorner))); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:Default="clr-namespace:SharpDevelop.XamlDesigner" |
||||
xmlns:Controls="clr-namespace:SharpDevelop.XamlDesigner.Controls" |
||||
xmlns:Converters="clr-namespace:SharpDevelop.XamlDesigner.Converters" |
||||
xmlns:PropertyGrid="clr-namespace:SharpDevelop.XamlDesigner.PropertyGrid" |
||||
xmlns:Editors="clr-namespace:SharpDevelop.XamlDesigner.PropertyGrid.Editors" |
||||
xmlns:Commanding="clr-namespace:SharpDevelop.XamlDesigner.Commanding"> |
||||
|
||||
<Brush x:Key="OutlineInsertBackground">#516675</Brush> |
||||
<Brush x:Key="OutlineInsertLine">#99BFDB</Brush> |
||||
|
||||
<Style TargetType="{x:Type Controls:OutlineInsertLine}"> |
||||
<Setter Property="IsHitTestVisible" |
||||
Value="False" /> |
||||
<Setter Property="HorizontalAlignment" |
||||
Value="Left" /> |
||||
<Setter Property="VerticalAlignment" |
||||
Value="Top" /> |
||||
<Setter Property="Template"> |
||||
<Setter.Value> |
||||
<ControlTemplate TargetType="{x:Type Controls:OutlineInsertLine}"> |
||||
<Border Height="1" |
||||
Background="{DynamicResource OutlineInsertLine}" /> |
||||
</ControlTemplate> |
||||
</Setter.Value> |
||||
</Setter> |
||||
</Style> |
||||
|
||||
</ResourceDictionary> |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public abstract class CommandBase |
||||
{ |
||||
public string CommandName { get; internal set; } |
||||
|
||||
public virtual bool CanExecute(object parameter) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public virtual void Execute(object parameter) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,203 @@
@@ -0,0 +1,203 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using System.Windows.Controls; |
||||
using System.Reflection; |
||||
using System.Windows.Media; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public static class CommandHelper |
||||
{ |
||||
static CommandHelper() |
||||
{ |
||||
CommandManager.RequerySuggested += RequerySuggestedDelegate; |
||||
} |
||||
|
||||
static EventHandler RequerySuggestedDelegate = RequerySuggested; |
||||
static DefaultContainerStyles DefaultContainerStyles = new DefaultContainerStyles(); |
||||
static List<WeakReference> TrackingElements = new List<WeakReference>(); |
||||
|
||||
static MethodInfo CommandConverter_GetKnownCommand = typeof(CommandConverter) |
||||
.GetMethod("GetKnownCommand", BindingFlags.NonPublic | BindingFlags.Static); |
||||
|
||||
public static string GetCommand(DependencyObject obj) |
||||
{ |
||||
return (string)obj.GetValue(CommandProperty); |
||||
} |
||||
|
||||
public static void SetCommand(DependencyObject obj, object value) |
||||
{ |
||||
obj.SetValue(CommandProperty, value); |
||||
} |
||||
|
||||
public static readonly DependencyProperty CommandProperty = |
||||
DependencyProperty.RegisterAttached("Command", typeof(string), typeof(CommandHelper), |
||||
new FrameworkPropertyMetadata(CommandPropertyChanged)); |
||||
|
||||
//public static object GetCommandTarget(DependencyObject obj)
|
||||
//{
|
||||
// return (object)obj.GetValue(CommandTargetProperty);
|
||||
//}
|
||||
|
||||
//public static void SetCommandTarget(DependencyObject obj, object value)
|
||||
//{
|
||||
// obj.SetValue(CommandTargetProperty, value);
|
||||
//}
|
||||
|
||||
//public static readonly DependencyProperty CommandTargetProperty =
|
||||
// DependencyProperty.RegisterAttached("CommandTarget", typeof(object), typeof(CommandHelper),
|
||||
// new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
|
||||
|
||||
public static CommandView GetCommandView(DependencyObject obj) |
||||
{ |
||||
return (CommandView)obj.GetValue(CommandViewProperty); |
||||
} |
||||
|
||||
public static void SetCommandView(DependencyObject obj, CommandView value) |
||||
{ |
||||
obj.SetValue(CommandViewProperty, value); |
||||
} |
||||
|
||||
public static readonly DependencyProperty CommandViewProperty = |
||||
DependencyProperty.RegisterAttached("CommandView", typeof(CommandView), typeof(CommandHelper)); |
||||
|
||||
static void CommandPropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
var commandName = (string)e.NewValue; |
||||
var element = target as FrameworkElement; |
||||
var view = element.TryFindResource(commandName) as CommandView; |
||||
|
||||
if (view == null) { |
||||
view = new CommandView(); |
||||
view.Text = commandName; |
||||
} |
||||
|
||||
view.CommandName = commandName; |
||||
|
||||
SetCommandView(element, view); |
||||
|
||||
TrackingElements.Add(new WeakReference(element)); |
||||
|
||||
var routedCommand = CommandConverter_GetKnownCommand.Invoke(null, new[] { commandName, null }) as RoutedCommand; |
||||
if (routedCommand != null) { |
||||
view.InitializeFromRoutedCommand(routedCommand); |
||||
} |
||||
|
||||
var key = new ContainerStyleKey(element.GetType()); |
||||
var style = element.TryFindResource(key) as Style; |
||||
if (style == null) { |
||||
style = DefaultContainerStyles[key] as Style; |
||||
} |
||||
|
||||
style.BasedOn = element.FindResource(element.GetType()) as Style; |
||||
element.Style = style; |
||||
|
||||
if (view.Shortcut != null) { |
||||
Application.Current.MainWindow.InputBindings.Add( |
||||
new InputBinding(new ShortcutCommand() { Sender = element }, view.Shortcut)); |
||||
} |
||||
} |
||||
|
||||
public static void RequerySuggested(object sender, EventArgs e) |
||||
{ |
||||
foreach (var weak in TrackingElements) { |
||||
if (weak.IsAlive) { |
||||
var element = weak.Target as FrameworkElement; |
||||
if (element.IsLoaded) { |
||||
var handler = FindCommandHandler(element); |
||||
var view = GetCommandView(element); |
||||
if (handler != null) { |
||||
view.IsEnabled = handler.CanExecute(null); |
||||
} |
||||
else { |
||||
view.IsEnabled = false; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void TryExecuteCommand(object sender) |
||||
{ |
||||
var handler = FindCommandHandler(sender); |
||||
if (handler != null) { |
||||
handler.Execute(null); |
||||
} |
||||
} |
||||
|
||||
public static CommandBase FindCommandHandler(object sender) |
||||
{ |
||||
CommandBase handler = null; |
||||
var d = sender as DependencyObject; |
||||
if (d != null) { |
||||
var commandView = GetCommandView(d); |
||||
if (commandView != null) { |
||||
//var target = GetCommandTarget(d);
|
||||
//if (target != null) {
|
||||
// handler = FindCommandHandler(target, commandView.CommandName);
|
||||
//}
|
||||
if (handler == null) { |
||||
handler = FindCommandHandler(sender, commandView.CommandName); |
||||
} |
||||
} |
||||
} |
||||
return handler; |
||||
} |
||||
|
||||
static CommandBase FindCommandHandler(object start, string commandName) |
||||
{ |
||||
foreach (var step in GetCommandChain(start)) { |
||||
var hasCommands = step as IHasCommands; |
||||
if (hasCommands != null) { |
||||
foreach (var commandHandler in hasCommands.Commands) { |
||||
if (commandHandler.CommandName == commandName) { |
||||
return commandHandler; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
static IEnumerable<object> GetCommandChain(object start) |
||||
{ |
||||
yield return start; |
||||
var d = start as DependencyObject; |
||||
if (d != null) { |
||||
if (d != start) { |
||||
yield return d; |
||||
} |
||||
var element = d as FrameworkElement; |
||||
if (element != null) { |
||||
yield return element.DataContext; |
||||
} |
||||
d = VisualTreeHelper.GetParent(d); |
||||
} |
||||
} |
||||
|
||||
class ShortcutCommand : ICommand |
||||
{ |
||||
public FrameworkElement Sender; |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
var handler = FindCommandHandler(Sender); |
||||
if (handler != null) { |
||||
return handler.CanExecute(parameter); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public event EventHandler CanExecuteChanged; |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
CommandHelper.TryExecuteCommand(Sender); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
using System.Diagnostics; |
||||
using System.Windows.Input; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public class CommandView : DependencyObject |
||||
{ |
||||
public string CommandName { get; internal set; } |
||||
|
||||
public static readonly DependencyProperty TextProperty = |
||||
DependencyProperty.Register("Text", typeof(string), typeof(CommandView)); |
||||
|
||||
public string Text |
||||
{ |
||||
get { return (string)GetValue(TextProperty); } |
||||
set { SetValue(TextProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty ShortcutProperty = |
||||
DependencyProperty.Register("Shortcut", typeof(SimpleKeyGesture), typeof(CommandView)); |
||||
|
||||
public SimpleKeyGesture Shortcut |
||||
{ |
||||
get { return (SimpleKeyGesture)GetValue(ShortcutProperty); } |
||||
set { SetValue(ShortcutProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty IconProperty = |
||||
DependencyProperty.Register("Icon", typeof(object), typeof(CommandView)); |
||||
|
||||
public object Icon |
||||
{ |
||||
get { return (object)GetValue(IconProperty); } |
||||
set { SetValue(IconProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty IsEnabledProperty = |
||||
DependencyProperty.Register("IsEnabled", typeof(bool), typeof(CommandView)); |
||||
|
||||
public bool IsEnabled |
||||
{ |
||||
get { return (bool)GetValue(IsEnabledProperty); } |
||||
set { SetValue(IsEnabledProperty, value); } |
||||
} |
||||
|
||||
public void InitializeFromRoutedCommand(RoutedCommand command) |
||||
{ |
||||
var keyGesture = command.InputGestures.OfType<KeyGesture>().FirstOrDefault(); |
||||
if (keyGesture != null) { |
||||
Shortcut = new SimpleKeyGesture() { |
||||
Key = keyGesture.Key, |
||||
Modifiers = keyGesture.Modifiers |
||||
}; |
||||
} |
||||
var uiCommand = command as RoutedUICommand; |
||||
if (uiCommand != null) { |
||||
Text = uiCommand.Text; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
using System.Reflection; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public class ContainerStyleKey : ResourceKey |
||||
{ |
||||
public ContainerStyleKey(Type containerType) |
||||
{ |
||||
ContainerType = containerType; |
||||
} |
||||
|
||||
public Type ContainerType { get; set; } |
||||
|
||||
public override Assembly Assembly |
||||
{ |
||||
get { return ContainerType.Assembly; } |
||||
} |
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider) |
||||
{ |
||||
return this; |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
var key = obj as ContainerStyleKey; |
||||
if (key != null) { |
||||
return key.ContainerType == ContainerType; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return ContainerType.GetHashCode(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
<ResourceDictionary x:Class="SharpDevelop.XamlDesigner.Commanding.DefaultContainerStyles" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:Commanding="clr-namespace:SharpDevelop.XamlDesigner.Commanding"> |
||||
|
||||
<Style x:Key="{Commanding:ContainerStyleKey Button}" |
||||
x:Shared="False" |
||||
TargetType="Button"> |
||||
<Setter Property="IsEnabled" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).IsEnabled, RelativeSource={RelativeSource Self}}" /> |
||||
<Setter Property="Content" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).Text, RelativeSource={RelativeSource Self}}" /> |
||||
<Setter Property="ToolTip" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).Shortcut, RelativeSource={RelativeSource Self}}" /> |
||||
<EventSetter Event="Click" |
||||
Handler="ButtonClick" /> |
||||
</Style> |
||||
|
||||
<Style x:Key="{Commanding:ContainerStyleKey MenuItem}" |
||||
x:Shared="False" |
||||
TargetType="MenuItem"> |
||||
<Setter Property="IsEnabled" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).IsEnabled, RelativeSource={RelativeSource Self}}" /> |
||||
<Setter Property="Header" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).Text, RelativeSource={RelativeSource Self}}" /> |
||||
<Setter Property="Icon" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).Icon, RelativeSource={RelativeSource Self}}" /> |
||||
<Setter Property="InputGestureText" |
||||
Value="{Binding Path=(Commanding:CommandHelper.CommandView).Shortcut, RelativeSource={RelativeSource Self}}" /> |
||||
<EventSetter Event="Click" |
||||
Handler="MenuItemClick" /> |
||||
</Style> |
||||
|
||||
</ResourceDictionary> |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
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 System.Windows.Media.Imaging; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Shapes; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public partial class DefaultContainerStyles : ResourceDictionary |
||||
{ |
||||
public DefaultContainerStyles() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
void ButtonClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
CommandHelper.TryExecuteCommand(sender); |
||||
} |
||||
|
||||
void MenuItemClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
CommandHelper.TryExecuteCommand(sender); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public interface IHasCommands |
||||
{ |
||||
List<CommandBase> Commands { get; } |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
public class MethodCommand : CommandBase |
||||
{ |
||||
public MethodCommand(string commandName, Action execute) |
||||
: this(commandName, execute, null) |
||||
{ |
||||
} |
||||
|
||||
public MethodCommand(string commandName, Action execute, Func<bool> canExecute) |
||||
{ |
||||
CommandName = commandName; |
||||
ExecuteDelegate = execute; |
||||
CanExecuteDelegate = canExecute; |
||||
} |
||||
|
||||
public Action ExecuteDelegate { get; set; } |
||||
public Func<bool> CanExecuteDelegate { get; set; } |
||||
|
||||
public override bool CanExecute(object parameter) |
||||
{ |
||||
if (CanExecuteDelegate != null) { |
||||
return CanExecuteDelegate(); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public override void Execute(object parameter) |
||||
{ |
||||
ExecuteDelegate(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using System.ComponentModel; |
||||
using System.Globalization; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Commanding |
||||
{ |
||||
[TypeConverter(typeof(SimpleKeyGestureConverter))] |
||||
public class SimpleKeyGesture : InputGesture |
||||
{ |
||||
public Key Key; |
||||
public ModifierKeys Modifiers; |
||||
|
||||
static KeyConverter KeyConverter = new KeyConverter(); |
||||
static ModifierKeysConverter ModifierKeysConverter = new ModifierKeysConverter(); |
||||
|
||||
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) |
||||
{ |
||||
KeyEventArgs e = inputEventArgs as KeyEventArgs; |
||||
return e != null && e.Key == Key && Keyboard.Modifiers == Modifiers; |
||||
} |
||||
|
||||
public static SimpleKeyGesture FromString(string s) |
||||
{ |
||||
var result = new SimpleKeyGesture(); |
||||
var index = s.LastIndexOf('+'); |
||||
|
||||
if (index >= 0) { |
||||
result.Modifiers = (ModifierKeys)ModifierKeysConverter.ConvertFromString(s.Substring(0, index)); |
||||
result.Key = (Key)KeyConverter.ConvertFromString(s.Substring(index + 1)); |
||||
} |
||||
else { |
||||
result.Key = (Key)KeyConverter.ConvertFromString(s); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
if (Modifiers == ModifierKeys.None) return KeyConverter.ConvertToString(Key); |
||||
return ModifierKeysConverter.ConvertToString(Modifiers) + "+" + KeyConverter.ConvertToString(Key); |
||||
} |
||||
} |
||||
|
||||
class SimpleKeyGestureConverter : TypeConverter |
||||
{ |
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
||||
{ |
||||
return sourceType == typeof(string); |
||||
} |
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
||||
{ |
||||
return SimpleKeyGesture.FromString((string)value); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class AdvancedDragEventArgs |
||||
{ |
||||
internal AdvancedDragEventArgs(AdvancedThumb thumb) |
||||
{ |
||||
this.thumb = thumb; |
||||
} |
||||
|
||||
AdvancedThumb thumb; |
||||
|
||||
public Point StartPoint |
||||
{ |
||||
get { return thumb.StartPoint; } |
||||
} |
||||
|
||||
public Vector Delta |
||||
{ |
||||
get { return thumb.Delta; } |
||||
} |
||||
|
||||
public bool IsCancel |
||||
{ |
||||
get { return thumb.IsCancel; } |
||||
} |
||||
} |
||||
|
||||
public delegate void AdvancedDragEventHandler(object sender, AdvancedDragEventArgs e); |
||||
} |
@ -0,0 +1,156 @@
@@ -0,0 +1,156 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using SharpDevelop.XamlDesigner.Dom.UndoSystem; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class AdvancedThumb : Control |
||||
{ |
||||
static AdvancedThumb() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(AdvancedThumb), |
||||
new FrameworkPropertyMetadata(typeof(AdvancedThumb))); |
||||
} |
||||
|
||||
public AdvancedThumb() |
||||
{ |
||||
UseDelay = true; |
||||
args = new AdvancedDragEventArgs(this); |
||||
} |
||||
|
||||
public IInputElement RelativeTo { get; set; } |
||||
public bool UseDelay { get; set; } |
||||
|
||||
Point startPoint; |
||||
Vector delta; |
||||
bool isMouseDown; |
||||
bool isDragging; |
||||
bool isCancel; |
||||
AdvancedDragEventArgs args; |
||||
|
||||
public Point StartPoint |
||||
{ |
||||
get { return startPoint; } |
||||
} |
||||
|
||||
public Vector Delta |
||||
{ |
||||
get { return delta; } |
||||
} |
||||
|
||||
public bool IsCancel |
||||
{ |
||||
get { return isCancel; } |
||||
} |
||||
|
||||
public event AdvancedDragEventHandler DragStarted; |
||||
public event AdvancedDragEventHandler DragDelta; |
||||
public event AdvancedDragEventHandler DragCompleted; |
||||
public event AdvancedDragEventHandler Click; |
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) |
||||
{ |
||||
Focus(); |
||||
startPoint = Mouse.GetPosition(RelativeTo); |
||||
isMouseDown = true; |
||||
isDragging = false; |
||||
CaptureMouse(); |
||||
e.Handled = true; |
||||
} |
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e) |
||||
{ |
||||
if (isMouseDown) { |
||||
delta = Mouse.GetPosition(RelativeTo) - startPoint; |
||||
if (isDragging) { |
||||
OnDragDelta(); |
||||
} |
||||
else { |
||||
if (!UseDelay || |
||||
Math.Abs(delta.X) > SystemParameters.MinimumHorizontalDragDistance || |
||||
Math.Abs(delta.Y) > SystemParameters.MinimumHorizontalDragDistance) { |
||||
isDragging = true; |
||||
OnDragStarted(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) |
||||
{ |
||||
if (isMouseDown) { |
||||
ReleaseMouseCapture(); |
||||
if (!isDragging) { |
||||
OnClick(); |
||||
} |
||||
Complete(false); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnDragStarted() |
||||
{ |
||||
UndoManager.OnDragStarted(this); |
||||
if (DragStarted != null) { |
||||
DragStarted(this, args); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnDragDelta() |
||||
{ |
||||
if (DragDelta != null) { |
||||
DragDelta(this, args); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnDragCompleted() |
||||
{ |
||||
if (isCancel) { |
||||
UndoManager.OnDragCanceled(this); |
||||
} |
||||
else { |
||||
UndoManager.OnDragCompleted(this); |
||||
} |
||||
if (DragCompleted != null) { |
||||
DragCompleted(this, args); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnClick() |
||||
{ |
||||
if (Click != null) { |
||||
Click(this, args); |
||||
} |
||||
} |
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Escape) { |
||||
CancelDrag(); |
||||
} |
||||
} |
||||
|
||||
public void CancelDrag() |
||||
{ |
||||
Complete(true); |
||||
} |
||||
|
||||
void Complete(bool cancel) |
||||
{ |
||||
if (isMouseDown) { |
||||
isMouseDown = false; |
||||
ReleaseMouseCapture(); |
||||
if (isDragging) { |
||||
isDragging = false; |
||||
isCancel = cancel; |
||||
OnDragCompleted(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Collections.Specialized; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class CollectionListener : ItemsControl |
||||
{ |
||||
public CollectionListener(object source, string bindingPath) |
||||
{ |
||||
SetBinding(ItemsSourceProperty, new Binding(bindingPath) { Source = source }); |
||||
} |
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged; |
||||
|
||||
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) |
||||
{ |
||||
base.OnItemsChanged(e); |
||||
if (CollectionChanged != null) { |
||||
CollectionChanged(this, e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
class DashedLine : FrameworkElement |
||||
{ |
||||
public static readonly DependencyProperty Point1Property = |
||||
DependencyProperty.Register("Point1", typeof(Point), typeof(DashedLine)); |
||||
|
||||
public Point Point1 |
||||
{ |
||||
get { return (Point)GetValue(Point1Property); } |
||||
set { SetValue(Point1Property, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty Point2Property = |
||||
DependencyProperty.Register("Point2", typeof(Point), typeof(DashedLine)); |
||||
|
||||
public Point Point2 |
||||
{ |
||||
get { return (Point)GetValue(Point2Property); } |
||||
set { SetValue(Point2Property, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty BackgroundPenProperty = |
||||
DependencyProperty.Register("BackgroundPen", typeof(Pen), typeof(DashedLine)); |
||||
|
||||
public Pen BackgroundPen |
||||
{ |
||||
get { return (Pen)GetValue(BackgroundPenProperty); } |
||||
set { SetValue(BackgroundPenProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty ForegroundPenProperty = |
||||
DependencyProperty.Register("ForegroundPen", typeof(Pen), typeof(DashedLine)); |
||||
|
||||
public Pen ForegroundPen |
||||
{ |
||||
get { return (Pen)GetValue(ForegroundPenProperty); } |
||||
set { SetValue(ForegroundPenProperty, value); } |
||||
} |
||||
|
||||
protected override void OnRender(DrawingContext drawingContext) |
||||
{ |
||||
if (BackgroundPen != null) { |
||||
drawingContext.DrawLine(BackgroundPen, Point1, Point2); |
||||
} |
||||
if (ForegroundPen != null) { |
||||
//var dashStyle = ForegroundPen.DashStyle.Clone();
|
||||
//dashStyle.Offset = Point1.X + Point1.Y;
|
||||
//ForegroundPen.DashStyle = dashStyle;
|
||||
drawingContext.DrawLine(ForegroundPen, Point1, Point2); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,297 @@
@@ -0,0 +1,297 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
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 System.Windows.Media.Imaging; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Shapes; |
||||
using System.Globalization; |
||||
using SharpDevelop.XamlDesigner.Converters; |
||||
using System.Reflection; |
||||
using System.Windows.Threading; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class EditSlider : Control |
||||
{ |
||||
static EditSlider() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(EditSlider), |
||||
new FrameworkPropertyMetadata(typeof(EditSlider))); |
||||
} |
||||
|
||||
public EditSlider() |
||||
{ |
||||
SizeChanged += new SizeChangedEventHandler(EditSlider_SizeChanged); |
||||
} |
||||
|
||||
AdvancedThumb thumb; |
||||
FrameworkElement bar; |
||||
TextBox textBox; |
||||
Vector startDelta; |
||||
double startValue; |
||||
|
||||
BindingExpression currentValueExpression; |
||||
|
||||
static PropertyInfo sourceValueProperty = |
||||
typeof(BindingExpression).GetProperty("SourceValue", BindingFlags.NonPublic | BindingFlags.Instance); |
||||
|
||||
public AdvancedThumb Thumb |
||||
{ |
||||
get { return thumb; } |
||||
} |
||||
|
||||
public static readonly DependencyProperty ValueProperty = |
||||
DependencyProperty.Register("Value", typeof(double), typeof(EditSlider), |
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); |
||||
|
||||
public double Value |
||||
{ |
||||
get { return (double)GetValue(ValueProperty); } |
||||
set { SetValue(ValueProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty MinimumProperty = |
||||
DependencyProperty.Register("Minimum", typeof(double), typeof(EditSlider), |
||||
new FrameworkPropertyMetadata(double.NegativeInfinity)); |
||||
|
||||
public double Minimum |
||||
{ |
||||
get { return (double)GetValue(MinimumProperty); } |
||||
set { SetValue(MinimumProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty MaximumProperty = |
||||
DependencyProperty.Register("Maximum", typeof(double), typeof(EditSlider), |
||||
new FrameworkPropertyMetadata(double.PositiveInfinity)); |
||||
|
||||
public double Maximum |
||||
{ |
||||
get { return (double)GetValue(MaximumProperty); } |
||||
set { SetValue(MaximumProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty StepProperty = |
||||
DependencyProperty.Register("Step", typeof(double), typeof(EditSlider), |
||||
new FrameworkPropertyMetadata(0.25)); |
||||
|
||||
public double Step |
||||
{ |
||||
get { return (double)GetValue(StepProperty); } |
||||
set { SetValue(StepProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty DecimalsProperty = |
||||
DependencyProperty.Register("Decimals", typeof(int), typeof(EditSlider), |
||||
new FrameworkPropertyMetadata(0)); |
||||
|
||||
public int Decimals |
||||
{ |
||||
get { return (int)GetValue(DecimalsProperty); } |
||||
set { SetValue(DecimalsProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty InPercentsProperty = |
||||
DependencyProperty.Register("InPercents", typeof(bool), typeof(EditSlider)); |
||||
|
||||
public bool InPercents |
||||
{ |
||||
get { return (bool)GetValue(InPercentsProperty); } |
||||
set { SetValue(InPercentsProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty InvisibleValueProperty = |
||||
DependencyProperty.Register("InvisibleValue", typeof(bool), typeof(EditSlider)); |
||||
|
||||
public bool InvisibleValue |
||||
{ |
||||
get { return (bool)GetValue(InvisibleValueProperty); } |
||||
set { SetValue(InvisibleValueProperty, value); } |
||||
} |
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
base.OnPropertyChanged(e); |
||||
|
||||
if (e.Property == MinimumProperty || |
||||
e.Property == MaximumProperty) { |
||||
SetNewValue(Value); |
||||
UpdateBar(); |
||||
} |
||||
else if (e.Property == InPercentsProperty) { |
||||
PrintCurrentValue(); |
||||
} |
||||
else if (e.Property == ValueProperty) { |
||||
UpdateCurrentValueExpression(); |
||||
UpdateBar(); |
||||
} |
||||
} |
||||
|
||||
public override void OnApplyTemplate() |
||||
{ |
||||
base.OnApplyTemplate(); |
||||
|
||||
bar = Template.FindName("PART_Bar", this) as FrameworkElement; |
||||
|
||||
textBox = Template.FindName("PART_TextBox", this) as TextBox; |
||||
textBox.KeyDown += new KeyEventHandler(textBox_KeyDown); |
||||
textBox.GotKeyboardFocus += new KeyboardFocusChangedEventHandler(textBox_GotKeyboardFocus); |
||||
textBox.SetBinding(TextBox.TextProperty, new Binding("Value") { |
||||
Source = this, |
||||
Converter = new TextConverter() { EditSlider = this } |
||||
}); |
||||
|
||||
thumb = Template.FindName("PART_Thumb", this) as AdvancedThumb; |
||||
thumb.Click += new AdvancedDragEventHandler(thumb_Click); |
||||
thumb.DragStarted += new AdvancedDragEventHandler(thumb_DragStarted); |
||||
thumb.DragDelta += new AdvancedDragEventHandler(thumb_DragDelta); |
||||
thumb.DragCompleted += new AdvancedDragEventHandler(thumb_DragCompleted); |
||||
|
||||
UpdateBar(); |
||||
} |
||||
|
||||
void textBox_KeyDown(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Enter) { |
||||
Focusable = true; |
||||
Focus(); |
||||
ClearValue(FocusableProperty); |
||||
} |
||||
} |
||||
|
||||
void textBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) |
||||
{ |
||||
textBox.SelectAll(); |
||||
} |
||||
|
||||
void thumb_Click(object sender, AdvancedDragEventArgs e) |
||||
{ |
||||
textBox.Focus(); |
||||
} |
||||
|
||||
void thumb_DragStarted(object sender, AdvancedDragEventArgs e) |
||||
{ |
||||
startDelta = e.Delta; |
||||
startValue = Value; |
||||
} |
||||
|
||||
void thumb_DragDelta(object sender, AdvancedDragEventArgs e) |
||||
{ |
||||
var finalDelta = e.Delta - startDelta; |
||||
var newValue = startValue + (finalDelta.X - finalDelta.Y) * Step; |
||||
SetNewValue(Math.Round(newValue, Decimals + (InPercents ? 2 : 0))); |
||||
} |
||||
|
||||
void thumb_DragCompleted(object sender, AdvancedDragEventArgs e) |
||||
{ |
||||
if (e.IsCancel) { |
||||
SetNewValue(startValue); |
||||
} |
||||
} |
||||
|
||||
void EditSlider_SizeChanged(object sender, SizeChangedEventArgs e) |
||||
{ |
||||
UpdateBar(); |
||||
} |
||||
|
||||
void PrintCurrentValue() |
||||
{ |
||||
if (textBox != null) { |
||||
var expr = BindingOperations.GetBindingExpression(textBox, TextBox.TextProperty); |
||||
expr.UpdateTarget(); |
||||
} |
||||
} |
||||
|
||||
void UpdateBar() |
||||
{ |
||||
if (bar != null) { |
||||
var range = Maximum - Minimum; |
||||
if (range > 0 && range < double.MaxValue) { |
||||
var parentWidth = (bar.Parent as FrameworkElement).ActualWidth; |
||||
bar.Width = parentWidth * (Value - Minimum) / range; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UpdateCurrentValueExpression() |
||||
{ |
||||
var newExpression = GetBindingExpression(ValueProperty); |
||||
|
||||
if (currentValueExpression != newExpression) { |
||||
currentValueExpression = newExpression; |
||||
if (currentValueExpression != null) { |
||||
// HACK
|
||||
var sourceValue = sourceValueProperty.GetValue(currentValueExpression, null); |
||||
var sourceType = sourceValue != null ? sourceValue.GetType() : null; |
||||
|
||||
AutoRange(sourceType); |
||||
} |
||||
} |
||||
|
||||
// if there was exception...
|
||||
if (currentValueExpression != null) { |
||||
currentValueExpression.UpdateTarget(); |
||||
} |
||||
} |
||||
|
||||
void AutoRange(Type type) |
||||
{ |
||||
if (type == typeof(Byte)) { |
||||
Minimum = Byte.MinValue; |
||||
Maximum = Byte.MaxValue; |
||||
} |
||||
else if (type == typeof(SByte)) { |
||||
Minimum = SByte.MinValue; |
||||
Maximum = SByte.MaxValue; |
||||
} |
||||
} |
||||
|
||||
void SetNewValue(double newValue) |
||||
{ |
||||
newValue = Math.Max(Minimum, Math.Min(Maximum, newValue)); |
||||
// NaN also
|
||||
if (!object.Equals(Value, newValue)) { |
||||
Value = newValue; |
||||
} |
||||
} |
||||
|
||||
class TextConverter : IValueConverter |
||||
{ |
||||
public EditSlider EditSlider; |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (EditSlider.InvisibleValue) return null; |
||||
|
||||
var d = (double)value; |
||||
if (EditSlider.InPercents) { |
||||
d = d * 100; |
||||
return Utils.DoubleToInvariantString(d) + "%"; |
||||
} |
||||
return Utils.DoubleToInvariantString(d); |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
EditSlider.PrintCurrentValue(); |
||||
|
||||
var s = (string)value; |
||||
if (EditSlider.InPercents) { |
||||
s = s.Replace("%", ""); |
||||
} |
||||
double result; |
||||
if (Utils.TryParseDouble(s, out result)) { |
||||
return EditSlider.InPercents ? result / 100 : result; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Data; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class EnterTextBox : TextBox |
||||
{ |
||||
public EnterTextBox() |
||||
{ |
||||
SetResourceReference(StyleProperty, typeof(TextBox)); |
||||
} |
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Enter) { |
||||
var expr = BindingOperations.GetBindingExpressionBase(this, TextProperty); |
||||
if (expr != null) { |
||||
expr.UpdateSource(); |
||||
if (expr.Status == BindingStatus.UpdateSourceError) { |
||||
expr.UpdateTarget(); |
||||
} |
||||
} |
||||
SelectAll(); |
||||
} |
||||
else { |
||||
if (e.Key == Key.Escape) { |
||||
var expr = BindingOperations.GetBindingExpressionBase(this, TextProperty); |
||||
if (expr != null) { |
||||
expr.UpdateTarget(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Windows.Data; |
||||
using SharpDevelop.XamlDesigner.Converters; |
||||
using System.Globalization; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class EnumListBox : ListBox |
||||
{ |
||||
static EnumListBox() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(EnumListBox), |
||||
new FrameworkPropertyMetadata(typeof(EnumListBox))); |
||||
} |
||||
|
||||
public static readonly DependencyProperty EnumValueProperty = |
||||
DependencyProperty.Register("EnumValue", typeof(object), typeof(EnumListBox), |
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); |
||||
|
||||
public object EnumValue |
||||
{ |
||||
get { return (object)GetValue(EnumValueProperty); } |
||||
set { SetValue(EnumValueProperty, value); } |
||||
} |
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
base.OnPropertyChanged(e); |
||||
|
||||
if (e.Property == EnumValueProperty) { |
||||
if (EnumValue != null) { |
||||
//TODO: flags
|
||||
SelectedIndex = Enum.GetValues(EnumValue.GetType()).Cast<object>().ToList().IndexOf(EnumValue); |
||||
} |
||||
else { |
||||
UnselectAll(); |
||||
} |
||||
} |
||||
else if (e.Property == SelectedIndexProperty) { |
||||
if (EnumValue != null) { |
||||
EnumValue = Enum.ToObject(EnumValue.GetType(), SelectedIndex); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,102 @@
@@ -0,0 +1,102 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Threading; |
||||
using System.Windows.Controls.Primitives; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class FilterDecorator : ContentControl |
||||
{ |
||||
static FilterDecorator() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(FilterDecorator), |
||||
new FrameworkPropertyMetadata(typeof(FilterDecorator))); |
||||
} |
||||
|
||||
public FilterDecorator() |
||||
{ |
||||
timer = new DispatcherTimer(); |
||||
timer.Interval = TimeSpan.FromMilliseconds(1000); |
||||
timer.Tick += new EventHandler(timer_Tick); |
||||
} |
||||
|
||||
DispatcherTimer timer; |
||||
bool waitingForInput; |
||||
|
||||
public static readonly DependencyProperty FilterProperty = |
||||
DependencyProperty.Register("Filter", typeof(string), typeof(FilterDecorator), |
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); |
||||
|
||||
public string Filter |
||||
{ |
||||
get { return (string)GetValue(FilterProperty); } |
||||
set { SetValue(FilterProperty, value); } |
||||
} |
||||
|
||||
static readonly DependencyPropertyKey IsFilteringPropertyKey = |
||||
DependencyProperty.RegisterReadOnly("IsFiltering", typeof(bool), typeof(FilterDecorator), null); |
||||
|
||||
public static DependencyProperty IsFilteringProperty = IsFilteringPropertyKey.DependencyProperty; |
||||
|
||||
public bool IsFiltering |
||||
{ |
||||
get { return (bool)GetValue(IsFilteringProperty); } |
||||
private set { SetValue(IsFilteringPropertyKey, value); } |
||||
} |
||||
|
||||
protected override void OnMouseEnter(MouseEventArgs e) |
||||
{ |
||||
if (Keyboard.FocusedElement is TextBoxBase) return; |
||||
Focus(); |
||||
} |
||||
|
||||
void timer_Tick(object sender, EventArgs e) |
||||
{ |
||||
waitingForInput = false; |
||||
timer.Stop(); |
||||
} |
||||
|
||||
protected override void OnPreviewTextInput(TextCompositionEventArgs e) |
||||
{ |
||||
if (e.OriginalSource is TextBoxBase) return; |
||||
|
||||
if (e.Text != null && |
||||
e.Text.Length > 0 && |
||||
char.IsLetterOrDigit(e.Text[0])) { |
||||
|
||||
if (waitingForInput) { |
||||
Filter = Filter + e.Text; |
||||
} |
||||
else { |
||||
Filter = e.Text; |
||||
waitingForInput = true; |
||||
} |
||||
IsFiltering = true; |
||||
timer.Stop(); |
||||
timer.Start(); |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Escape && IsFiltering) { |
||||
StopFiltering(); |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
void StopFiltering() |
||||
{ |
||||
timer.Stop(); |
||||
Filter = null; |
||||
IsFiltering = false; |
||||
waitingForInput = false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class Form : ItemsControl |
||||
{ |
||||
public Form() |
||||
{ |
||||
SetResourceReference(ItemContainerStyleProperty, FormItem.DefaultStyleKey); |
||||
Grid.SetIsSharedSizeScope(this, true); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class FormItem : HeaderedContentControl |
||||
{ |
||||
static FormItem() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(FormItem), |
||||
new FrameworkPropertyMetadata(typeof(FormItem))); |
||||
|
||||
DefaultStyleKey = new ComponentResourceKey(typeof(FormItem), "DefaultStyle"); |
||||
VerticalStyleKey = new ComponentResourceKey(typeof(FormItem), "VerticalStyle"); |
||||
} |
||||
|
||||
public static ResourceKey DefaultStyleKey { get; private set; } |
||||
public static ResourceKey VerticalStyleKey { get; private set; } |
||||
} |
||||
} |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Documents; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
using System.Windows.Input; |
||||
using System.Diagnostics; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class GeneralAdorner : Adorner |
||||
{ |
||||
public GeneralAdorner(UIElement target) |
||||
: base(target) |
||||
{ |
||||
ChildSize = new Size(double.NaN, double.NaN); |
||||
} |
||||
|
||||
FrameworkElement child; |
||||
Point scale = new Point(); |
||||
MatrixTransform desiredTransform; |
||||
|
||||
public Point ChildLocation { get; set; } |
||||
public Size ChildSize { get; set; } |
||||
|
||||
public FrameworkElement Child |
||||
{ |
||||
get |
||||
{ |
||||
return child; |
||||
} |
||||
set |
||||
{ |
||||
if (child != value) { |
||||
RemoveVisualChild(child); |
||||
RemoveLogicalChild(child); |
||||
child = value; |
||||
AddLogicalChild(value); |
||||
AddVisualChild(value); |
||||
InvalidateMeasure(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected override int VisualChildrenCount |
||||
{ |
||||
get { return child == null ? 0 : 1; } |
||||
} |
||||
|
||||
protected override Visual GetVisualChild(int index) |
||||
{ |
||||
return child; |
||||
} |
||||
|
||||
protected override Size MeasureOverride(Size constraint) |
||||
{ |
||||
var elementMatrix = ((Transform)AdornedElement.TransformToVisual(Parent as Visual)).Value; |
||||
scale.X = elementMatrix.Transform(new Vector(1, 0)).Length; |
||||
scale.Y = elementMatrix.Transform(new Vector(0, 1)).Length; |
||||
|
||||
elementMatrix.ScalePrepend(1 / scale.X, 1 / scale.Y); |
||||
desiredTransform = new MatrixTransform(elementMatrix); |
||||
|
||||
var result = AdornedElement.RenderSize; |
||||
result.Width *= scale.X; |
||||
result.Height *= scale.Y; |
||||
|
||||
if (child != null) { |
||||
if (!double.IsNaN(ChildSize.Width)) { |
||||
child.Width = ChildSize.Width * scale.X; |
||||
} |
||||
if (!double.IsNaN(ChildSize.Height)) { |
||||
child.Height = ChildSize.Height * scale.Y; |
||||
} |
||||
child.Measure(result); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
protected override Size ArrangeOverride(Size finalSize) |
||||
{ |
||||
if (child != null) { |
||||
var p = new Point(ChildLocation.X * scale.X, ChildLocation.Y * scale.Y); |
||||
child.Arrange(new Rect(p, finalSize)); |
||||
} |
||||
return finalSize; |
||||
} |
||||
|
||||
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) |
||||
{ |
||||
return desiredTransform; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class IconItem : Control |
||||
{ |
||||
static IconItem() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(IconItem), |
||||
new FrameworkPropertyMetadata(typeof(IconItem))); |
||||
} |
||||
|
||||
public static readonly DependencyProperty IconProperty = |
||||
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(IconItem)); |
||||
|
||||
public ImageSource Icon { |
||||
get { return (ImageSource)GetValue(IconProperty); } |
||||
set { SetValue(IconProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty TextProperty = |
||||
DependencyProperty.Register("Text", typeof(string), typeof(IconItem)); |
||||
|
||||
public string Text { |
||||
get { return (string)GetValue(TextProperty); } |
||||
set { SetValue(TextProperty, value); } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class LayersPanel : Grid |
||||
{ |
||||
public static readonly DependencyProperty SelectedIndexProperty = |
||||
DependencyProperty.Register("SelectedIndex", typeof(int), typeof(LayersPanel)); |
||||
|
||||
public int SelectedIndex |
||||
{ |
||||
get { return (int)GetValue(SelectedIndexProperty); } |
||||
set { SetValue(SelectedIndexProperty, value); } |
||||
} |
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
base.OnPropertyChanged(e); |
||||
if (e.Property == SelectedIndexProperty) { |
||||
UpdateVisibility(); |
||||
} |
||||
} |
||||
|
||||
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) |
||||
{ |
||||
base.OnVisualChildrenChanged(visualAdded, visualRemoved); |
||||
UpdateVisibility(); |
||||
} |
||||
|
||||
void UpdateVisibility() |
||||
{ |
||||
for (int i = 0; i < Children.Count; i++) { |
||||
if (i == SelectedIndex) { |
||||
Children[i].Visibility = Visibility.Visible; |
||||
} |
||||
else { |
||||
Children[i].Visibility = Visibility.Hidden; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
class OutlineInsertLine : Control |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public static class PixelSnapper |
||||
{ |
||||
static PixelSnapper() |
||||
{ |
||||
Application.Current.MainWindow.LayoutUpdated += new EventHandler(SnapHelper_LayoutUpdated); |
||||
} |
||||
|
||||
static HashSet<WeakReference> elements = new HashSet<WeakReference>(); |
||||
|
||||
public static void SetSnap(UIElement target, bool value) |
||||
{ |
||||
elements.Add(new WeakReference(target)); |
||||
} |
||||
|
||||
static void SnapHelper_LayoutUpdated(object sender, EventArgs e) |
||||
{ |
||||
foreach (var reference in elements) { |
||||
if (reference.IsAlive) { |
||||
Snap(reference.Target as UIElement); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void Snap(UIElement target) |
||||
{ |
||||
var ps = PresentationSource.FromVisual(target); |
||||
if (ps == null) return; |
||||
|
||||
var matrix = (target.TransformToVisual(ps.RootVisual) as MatrixTransform).Matrix; |
||||
Point p = new Point(matrix.OffsetX, matrix.OffsetY); |
||||
|
||||
double deltaX = Math.Round(p.X) - p.X; |
||||
double deltaY = Math.Round(p.Y) - p.Y; |
||||
|
||||
if (deltaX != 0 || deltaY != 0) { |
||||
var tr = target.RenderTransform as TranslateTransform; |
||||
if (tr == null) { |
||||
tr = new TranslateTransform(); |
||||
target.RenderTransform = tr; |
||||
} |
||||
tr.X = (tr.X + deltaX) - Math.Truncate(tr.X + deltaX); |
||||
tr.Y = (tr.Y + deltaY) - Math.Truncate(tr.Y + deltaY); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows.Input; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class SelectionFrame : Control |
||||
{ |
||||
static SelectionFrame() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(SelectionFrame), |
||||
new FrameworkPropertyMetadata(typeof(SelectionFrame))); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,309 @@
@@ -0,0 +1,309 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
using System.Windows.Data; |
||||
using System.Diagnostics; |
||||
using System.Windows.Input; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Media; |
||||
using SharpDevelop.XamlDesigner.Converters; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class TreeBox : ListBox |
||||
{ |
||||
static TreeBox() |
||||
{ |
||||
SelectionModeProperty.OverrideMetadata(typeof(TreeBox), |
||||
new FrameworkPropertyMetadata(SelectionMode.Extended)); |
||||
|
||||
HorizontalContentAlignmentProperty.OverrideMetadata(typeof(TreeBox), |
||||
new FrameworkPropertyMetadata(HorizontalAlignment.Stretch)); |
||||
} |
||||
|
||||
public TreeBox() |
||||
{ |
||||
SetResourceReference(StyleProperty, typeof(ListBox)); |
||||
listener = new CollectionListener(this, "TreeSource"); |
||||
listener.CollectionChanged += new NotifyCollectionChangedEventHandler(listener_CollectionChanged); |
||||
} |
||||
|
||||
CollectionListener listener; |
||||
|
||||
void listener_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
||||
{ |
||||
GenerateRootItems(); |
||||
} |
||||
|
||||
public static readonly DependencyProperty CoreStyleProperty = |
||||
DependencyProperty.Register("CoreStyle", typeof(Style), typeof(TreeBox)); |
||||
|
||||
public Style CoreStyle |
||||
{ |
||||
get { return (Style)GetValue(CoreStyleProperty); } |
||||
set { SetValue(CoreStyleProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty TreeSourceProperty = |
||||
DependencyProperty.Register("TreeSource", typeof(IEnumerable), typeof(TreeBox)); |
||||
|
||||
public IEnumerable TreeSource |
||||
{ |
||||
get { return (IEnumerable)GetValue(TreeSourceProperty); } |
||||
set { SetValue(TreeSourceProperty, value); } |
||||
} |
||||
|
||||
public static readonly DependencyProperty AllowDragProperty = |
||||
DependencyProperty.Register("AllowDrag", typeof(bool), typeof(TreeBox)); |
||||
|
||||
public bool AllowDrag |
||||
{ |
||||
get { return (bool)GetValue(AllowDragProperty); } |
||||
set { SetValue(AllowDragProperty, value); } |
||||
} |
||||
|
||||
internal void OnItemsChanged(TreeBoxItemCore core, NotifyCollectionChangedEventArgs e) |
||||
{ |
||||
if (core.IsExpanded) { |
||||
int index = Items.IndexOf(core); |
||||
switch (e.Action) { |
||||
case NotifyCollectionChangedAction.Add: |
||||
var newCore = CreateCore(e.NewItems[0], core); |
||||
Items.Insert(index + e.NewStartingIndex + 1, newCore); |
||||
break; |
||||
case NotifyCollectionChangedAction.Remove: |
||||
Items.RemoveAt(index + e.OldStartingIndex + 1); |
||||
break; |
||||
default: |
||||
Collapse(core); |
||||
Expand(core); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void GenerateRootItems() |
||||
{ |
||||
Items.Clear(); |
||||
|
||||
if (TreeSource != null) { |
||||
foreach (var item in TreeSource) { |
||||
var core = CreateCore(item, null); |
||||
Items.Add(core); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void Expand(TreeBoxItemCore core) |
||||
{ |
||||
int index = Items.IndexOf(core); |
||||
foreach (var item in core.Items) { |
||||
var newCore = CreateCore(item, core); |
||||
Items.Insert(++index, newCore); |
||||
} |
||||
} |
||||
|
||||
public void Collapse(TreeBoxItemCore core) |
||||
{ |
||||
int index = Items.IndexOf(core) + 1; |
||||
while (index < Items.Count && (Items[index] as TreeBoxItemCore).Level > core.Level) { |
||||
Items.RemoveAt(index); |
||||
} |
||||
} |
||||
|
||||
protected override DependencyObject GetContainerForItemOverride() |
||||
{ |
||||
var listBoxItem = new TreeBoxItem(); |
||||
listBoxItem.SetBinding(ListBoxItem.IsSelectedProperty, "IsSelected"); |
||||
return listBoxItem; |
||||
} |
||||
|
||||
protected override void PrepareContainerForItemOverride(DependencyObject element, object item) |
||||
{ |
||||
base.PrepareContainerForItemOverride(element, item); |
||||
|
||||
var core = item as TreeBoxItemCore; |
||||
base.PrepareContainerForItemOverride(core, core.Item); |
||||
} |
||||
|
||||
TreeBoxItemCore CreateCore(object item, TreeBoxItemCore parent) |
||||
{ |
||||
var core = new TreeBoxItemCore(); |
||||
core.Item = item; |
||||
core.ParentTree = this; |
||||
if (parent != null) { |
||||
core.Level = parent.Level + 1; |
||||
} |
||||
core.DataContext = item; |
||||
core.SetBinding(FrameworkElement.StyleProperty, |
||||
new Binding("CoreStyle") { Source = this }); |
||||
|
||||
return core; |
||||
} |
||||
|
||||
#region Drag & Drop
|
||||
|
||||
InsertInfo insert; |
||||
|
||||
internal void TryStartDrag() |
||||
{ |
||||
if (AllowDrag) { |
||||
insert = new InsertInfo(); |
||||
insert.Items = SelectedItems.Cast<object>().ToArray(); |
||||
insert.Adorner = new GeneralAdorner(this) { |
||||
Child = new OutlineInsertLine() |
||||
}; |
||||
DragDrop.DoDragDrop(this, this, DragDropEffects.All); |
||||
} |
||||
} |
||||
|
||||
protected override void OnDragEnter(DragEventArgs e) |
||||
{ |
||||
ProcessDrag(e); |
||||
} |
||||
|
||||
protected override void OnDragOver(DragEventArgs e) |
||||
{ |
||||
ProcessDrag(e); |
||||
} |
||||
|
||||
void ProcessDrag(DragEventArgs e) |
||||
{ |
||||
e.Effects = DragDropEffects.None; |
||||
e.Handled = true; |
||||
|
||||
if (insert != null) { |
||||
|
||||
HidePreview(); |
||||
|
||||
insert.Copy = Keyboard.IsKeyDown(Key.LeftCtrl); |
||||
|
||||
var container = (e.OriginalSource as DependencyObject).FindAncestor<TreeBoxItem>(); |
||||
if (container != null) { |
||||
|
||||
insert.Hover = container; |
||||
|
||||
var y = e.GetPosition(container).Y; |
||||
var h = container.ActualHeight; |
||||
|
||||
if (y < h / 5) { |
||||
insert.Part = Part.Before; |
||||
} |
||||
else if (y > h - h / 5) { |
||||
insert.Part = Part.After; |
||||
} |
||||
else { |
||||
insert.Part = Part.Inside; |
||||
} |
||||
|
||||
if (CanDrop()) { |
||||
e.Effects = DragDropEffects.Move; |
||||
ShowPreview(); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
bool CanDrop() |
||||
{ |
||||
if (insert.Part == Part.Inside) { |
||||
insert.TargetParent = insert.Hover.Core.Item; |
||||
insert.TargetIndex = insert.Hover.Core.Items.Count; |
||||
} |
||||
else if (insert.Part == Part.Before) { |
||||
SetTarget(insert.Hover.Core, 0); |
||||
} |
||||
else { |
||||
SetTarget(insert.Hover.Core, 1); |
||||
} |
||||
return CanInsert(insert.TargetParent, insert.Items, insert.TargetIndex, insert.Copy); |
||||
} |
||||
|
||||
void SetTarget(TreeBoxItemCore core, int shift) |
||||
{ |
||||
var index = Items.IndexOf(core); |
||||
for (int i = index - 1; i >= 0; i--) { |
||||
var item = Items[i] as TreeBoxItemCore; |
||||
if (item.Level < core.Level) { |
||||
insert.TargetParent = item.Item; |
||||
insert.TargetIndex = item.Items.IndexOf(core) + shift; |
||||
return; |
||||
} |
||||
} |
||||
|
||||
insert.TargetParent = TreeSource; |
||||
insert.TargetIndex = Items.IndexOf(core) + shift; |
||||
} |
||||
|
||||
void ShowPreview() |
||||
{ |
||||
insert.Hover.Background = FindResource("OutlineInsertBackground") as Brush; |
||||
|
||||
if (insert.Part == Part.Before || insert.Part == Part.After) { |
||||
var p = insert.Part == Part.Before ? new Point() : new Point(0, insert.Hover.ActualHeight); |
||||
var y = insert.Hover.TransformToAncestor(this).Transform(p).Y; |
||||
var element = insert.Adorner.Child as FrameworkElement; |
||||
|
||||
element.Width = insert.Hover.ActualWidth; |
||||
element.Margin = new Thickness(0, y, 0, 0); |
||||
|
||||
AdornerLayer.GetAdornerLayer(this).Add(insert.Adorner); |
||||
} |
||||
} |
||||
|
||||
void HidePreview() |
||||
{ |
||||
if (insert.Hover != null) { |
||||
insert.Hover.ClearValue(TreeBoxItem.BackgroundProperty); |
||||
AdornerLayer.GetAdornerLayer(this).Remove(insert.Adorner); |
||||
} |
||||
} |
||||
|
||||
protected override void OnDrop(DragEventArgs e) |
||||
{ |
||||
HidePreview(); |
||||
} |
||||
|
||||
protected virtual bool CanInsert(object parent, IEnumerable<object> items, int index, bool copy) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
protected virtual void Insert(object parent, IEnumerable<object> items, int index, bool copy) |
||||
{ |
||||
} |
||||
|
||||
protected virtual bool CanDelete(IEnumerable<object> items) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
protected virtual void Delete(IEnumerable<object> items) |
||||
{ |
||||
} |
||||
|
||||
class InsertInfo |
||||
{ |
||||
public object[] Items; |
||||
public bool Copy; |
||||
public TreeBoxItem Hover; |
||||
public Part Part; |
||||
public object TargetParent; |
||||
public int TargetIndex; |
||||
public GeneralAdorner Adorner; |
||||
} |
||||
|
||||
enum Part |
||||
{ |
||||
Before, Inside, After |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
class TreeBoxItem : ListBoxItem |
||||
{ |
||||
public TreeBoxItem() |
||||
{ |
||||
SetResourceReference(StyleProperty, typeof(ListBoxItem)); |
||||
} |
||||
|
||||
Point startPoint; |
||||
//bool click;
|
||||
|
||||
public TreeBoxItemCore Core |
||||
{ |
||||
get { return Content as TreeBoxItemCore; } |
||||
} |
||||
|
||||
//protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
//{
|
||||
// base.OnMouseLeftButtonDown(e);
|
||||
// if (IsSelected) {
|
||||
// //click = true;
|
||||
// startPoint = e.GetPosition(null);
|
||||
// CaptureMouse();
|
||||
// e.Handled = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) |
||||
{ |
||||
base.OnMouseLeftButtonDown(e); |
||||
startPoint = e.GetPosition(null); |
||||
CaptureMouse(); |
||||
} |
||||
|
||||
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) |
||||
{ |
||||
ReleaseMouseCapture(); |
||||
//if (click) {
|
||||
// OnMouseLeftButtonDown(e);
|
||||
//}
|
||||
} |
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e) |
||||
{ |
||||
if (IsMouseCaptured) { |
||||
var currentPoint = e.GetPosition(null); |
||||
if (Math.Abs(currentPoint.X - startPoint.X) >= SystemParameters.MinimumHorizontalDragDistance || |
||||
Math.Abs(currentPoint.Y - startPoint.Y) >= SystemParameters.MinimumVerticalDragDistance) { |
||||
|
||||
//click = true;
|
||||
this.FindAncestor<TreeBox>().TryStartDrag(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Controls |
||||
{ |
||||
public class TreeBoxItemCore : TreeViewItem |
||||
{ |
||||
static TreeBoxItemCore() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeBoxItemCore), |
||||
new FrameworkPropertyMetadata(typeof(TreeBoxItemCore))); |
||||
} |
||||
|
||||
public TreeBoxItemCore() |
||||
{ |
||||
Loaded += new RoutedEventHandler(TreeBoxItemCore_Loaded); |
||||
} |
||||
|
||||
void TreeBoxItemCore_Loaded(object sender, RoutedEventArgs e) |
||||
{ |
||||
if (updateWnenLoaded) { |
||||
UpdateItems(); |
||||
} |
||||
} |
||||
|
||||
public TreeBox ParentTree { get; internal set; } |
||||
public object Item { get; internal set; } |
||||
bool updateWnenLoaded; |
||||
|
||||
public static readonly DependencyProperty LevelProperty = |
||||
DependencyProperty.Register("Level", typeof(int), typeof(TreeBoxItemCore)); |
||||
|
||||
public int Level |
||||
{ |
||||
get { return (int)GetValue(LevelProperty); } |
||||
set { SetValue(LevelProperty, value); } |
||||
} |
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
base.OnPropertyChanged(e); |
||||
|
||||
if (e.Property == IsExpandedProperty) { |
||||
var newValue = (bool)e.NewValue; |
||||
|
||||
if (IsLoaded) { |
||||
UpdateItems(); |
||||
} |
||||
else { |
||||
updateWnenLoaded = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) |
||||
{ |
||||
base.OnItemsChanged(e); |
||||
if (IsLoaded) { |
||||
ParentTree.OnItemsChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
void UpdateItems() |
||||
{ |
||||
if (IsExpanded) { |
||||
ParentTree.Expand(this); |
||||
} |
||||
else { |
||||
ParentTree.Collapse(this); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,220 @@
@@ -0,0 +1,220 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Data; |
||||
using System.Globalization; |
||||
using System.Windows; |
||||
using System.Collections; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Converters |
||||
{ |
||||
public class IntFromEnumConverter : IValueConverter |
||||
{ |
||||
public static IntFromEnumConverter Instance = new IntFromEnumConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (int)value; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return Enum.ToObject(targetType, (int)value); |
||||
} |
||||
} |
||||
|
||||
public class HiddenWhenFalse : IValueConverter |
||||
{ |
||||
public static HiddenWhenFalse Instance = new HiddenWhenFalse(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (bool)value ? Visibility.Visible : Visibility.Hidden; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class CollapsedWhenFalse : IValueConverter |
||||
{ |
||||
public static CollapsedWhenFalse Instance = new CollapsedWhenFalse(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (bool)value ? Visibility.Visible : Visibility.Collapsed; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class LevelConverter : IValueConverter |
||||
{ |
||||
public static LevelConverter Instance = new LevelConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return new Thickness(2 + 14 * (int)value, 0, 0, 0); |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class CollapsedWhenZero : IValueConverter |
||||
{ |
||||
public static CollapsedWhenZero Instance = new CollapsedWhenZero(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value == null || (int)value == 0) { |
||||
return Visibility.Collapsed; |
||||
} |
||||
return Visibility.Visible; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class FalseWhenNull : IValueConverter |
||||
{ |
||||
public static FalseWhenNull Instance = new FalseWhenNull(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return value != null; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class BoldWhenTrue : IValueConverter |
||||
{ |
||||
public static BoldWhenTrue Instance = new BoldWhenTrue(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (bool)value ? FontWeights.Bold : FontWeights.Normal; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
// Boxed int throw exception without converter (wpf bug?)
|
||||
public class SafeDoubleConverter : IValueConverter |
||||
{ |
||||
public static SafeDoubleConverter Instance = new SafeDoubleConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return value ?? 0.0; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return value; |
||||
} |
||||
} |
||||
public class HiddenWhenTrue : IValueConverter |
||||
{ |
||||
public static HiddenWhenTrue Instance = new HiddenWhenTrue(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return (bool)value ? Visibility.Hidden : Visibility.Visible; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class FullTypeNameConverter : IValueConverter |
||||
{ |
||||
public static FullTypeNameConverter Instance = new FullTypeNameConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
var c = value as Type; |
||||
if (c == null) return value; |
||||
return c.Name + " (" + c.Namespace + ")"; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class TypeNameConverter : IValueConverter |
||||
{ |
||||
public static TypeNameConverter Instance = new TypeNameConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value == null) return null; |
||||
var type = value.GetType(); |
||||
var typeName = Utils.IsCollection(type) ? "Collection" : type.Name; |
||||
return "(" + type.Name + ")"; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class EnsureCollectionConverter : IValueConverter |
||||
{ |
||||
public static EnsureCollectionConverter Instance = new EnsureCollectionConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value == null) { |
||||
return null; |
||||
} |
||||
if (value is IEnumerable) { |
||||
return value; |
||||
} |
||||
return new[] { value }; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public class MinConverter : IValueConverter |
||||
{ |
||||
public static MinConverter Instance = new MinConverter(); |
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
return Math.Min((int)value, int.Parse(parameter.ToString())); |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Resources; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
public static class DesignResources |
||||
{ |
||||
static FrameworkElement dummy = new FrameworkElement(); |
||||
|
||||
static ResourceManager resourceManager = new ResourceManager( |
||||
typeof(DesignResources).Assembly.GetName().Name + ".g", typeof(DesignResources).Assembly); |
||||
|
||||
public static Stream GetStream(string path) |
||||
{ |
||||
return resourceManager.GetStream(path.ToLower()); |
||||
} |
||||
|
||||
public static string GetString(string path) |
||||
{ |
||||
var stream = GetStream(path); |
||||
if (stream != null) { |
||||
return new StreamReader(stream).ReadToEnd(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
static ResourceKey CreateKey(object id) |
||||
{ |
||||
return new ComponentResourceKey(typeof(DesignResources), id); |
||||
} |
||||
|
||||
static object FindResource(ResourceKey key) |
||||
{ |
||||
return dummy.FindResource(key); |
||||
} |
||||
|
||||
static DesignResources() |
||||
{ |
||||
SnaplineStyleKey = CreateKey("SnaplineStyleKey"); |
||||
} |
||||
|
||||
public static ResourceKey SnaplineStyleKey { get; private set; } |
||||
public static Style SnaplineStyle { get { return FindResource(SnaplineStyleKey) as Style; } } |
||||
} |
||||
} |
@ -0,0 +1,117 @@
@@ -0,0 +1,117 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using SharpDevelop.XamlDesigner.Commanding; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignCommands : ViewModel |
||||
{ |
||||
internal DesignCommands(DesignContext context) |
||||
{ |
||||
this.context = context; |
||||
|
||||
AddCommand("Undo", Undo, CanUndo); |
||||
AddCommand("Redo", Redo, CanRedo); |
||||
AddCommand("Copy", Copy, CanCopy); |
||||
AddCommand("Cut", Cut, CanCut); |
||||
AddCommand("Paste", Paste, CanPaste); |
||||
AddCommand("Delete", Delete, CanDelete); |
||||
AddCommand("SelectAll", SelectAll, CanSelectAll); |
||||
AddCommand("BringToFront", BringToFront, CanBringToFront); |
||||
AddCommand("SendToBack", SendToBack, CanSendToBack); |
||||
} |
||||
|
||||
DesignContext context; |
||||
|
||||
public bool CanUndo() |
||||
{ |
||||
return context.UndoManager.CanUndo; |
||||
} |
||||
|
||||
public void Undo() |
||||
{ |
||||
context.UndoManager.Undo(); |
||||
} |
||||
|
||||
public bool CanRedo() |
||||
{ |
||||
return context.UndoManager.CanRedo; |
||||
} |
||||
|
||||
public void Redo() |
||||
{ |
||||
context.UndoManager.Redo(); |
||||
} |
||||
|
||||
public bool CanCopy() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public void Copy() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool CanPaste() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public void Paste() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool CanCut() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public void Cut() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool CanSelectAll() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public void SelectAll() |
||||
{ |
||||
context.Selection.Set(context.Root.Descendants().Skip(1)); |
||||
} |
||||
|
||||
public bool CanDelete() |
||||
{ |
||||
return context.Selection.Count > 0 && !context.Selection.Contains(context.Root); |
||||
} |
||||
|
||||
public void Delete() |
||||
{ |
||||
context.Selection.Delete(); |
||||
} |
||||
|
||||
public bool CanBringToFront() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public void BringToFront() |
||||
{ |
||||
} |
||||
|
||||
public bool CanSendToBack() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public void SendToBack() |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,146 @@
@@ -0,0 +1,146 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Collections.ObjectModel; |
||||
using System.Xaml; |
||||
using System.IO; |
||||
using System.Xaml.Schema; |
||||
using System.Windows; |
||||
using SharpDevelop.XamlDesigner.Controls; |
||||
using System.Windows.Controls; |
||||
using SharpDevelop.XamlDesigner.Extensibility; |
||||
using SharpDevelop.XamlDesigner.Extensibility.Attributes; |
||||
using SharpDevelop.XamlDesigner.Palette; |
||||
using SharpDevelop.XamlDesigner.Commanding; |
||||
using SharpDevelop.XamlDesigner.Dom.UndoSystem; |
||||
using System.Windows.Threading; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignContext : ViewModel |
||||
{ |
||||
internal DesignContext(DesignProject project, ITextHolder textHolder) |
||||
{ |
||||
Project = project; |
||||
TextHolder = textHolder; |
||||
|
||||
DesignView = new DesignView(this); |
||||
ToolPanel = new ToolPanel(this); |
||||
Selection = new SelectionCollection(); |
||||
UndoManager = new UndoManager(); |
||||
DesignCommands = new DesignCommands(this); |
||||
AdornerManager = new AdornerManager(this); |
||||
|
||||
CreateTimer(); |
||||
} |
||||
|
||||
public DesignView DesignView { get; private set; } |
||||
public ToolPanel ToolPanel { get; private set; } |
||||
public AdornerManager AdornerManager { get; private set; } |
||||
public SelectionCollection Selection { get; private set; } |
||||
public UndoManager UndoManager { get; private set; } |
||||
public DesignCommands DesignCommands { get; private set; } |
||||
public DesignProject Project { get; private set; } |
||||
|
||||
public bool NeedParse; |
||||
//public List<string> References = new List<string>();
|
||||
public ITextHolder TextHolder { get; private set; } |
||||
|
||||
DispatcherTimer timer; |
||||
|
||||
DesignItem root; |
||||
|
||||
public DesignItem Root |
||||
{ |
||||
get |
||||
{ |
||||
return root; |
||||
} |
||||
set |
||||
{ |
||||
root = value; |
||||
RaisePropertyChanged("Root"); |
||||
} |
||||
} |
||||
|
||||
DocumentMode mode = DocumentMode.Design; |
||||
|
||||
public DocumentMode Mode |
||||
{ |
||||
get |
||||
{ |
||||
return mode; |
||||
} |
||||
set |
||||
{ |
||||
mode = value; |
||||
RaisePropertyChanged("Mode"); |
||||
} |
||||
} |
||||
|
||||
bool isDirty; |
||||
|
||||
public bool IsDirty |
||||
{ |
||||
get |
||||
{ |
||||
return isDirty; |
||||
} |
||||
set |
||||
{ |
||||
isDirty = value; |
||||
RaisePropertyChanged("IsDirty"); |
||||
} |
||||
} |
||||
|
||||
public void Load(string text) |
||||
{ |
||||
TextHolder.Text = text; |
||||
Parse(); |
||||
} |
||||
|
||||
public void Parse() |
||||
{ |
||||
timer.Stop(); |
||||
Root = XamlOperations.Parse(this); |
||||
//DesignView.Root = Root.View;
|
||||
} |
||||
|
||||
public void SavePoint() |
||||
{ |
||||
IsDirty = false; |
||||
} |
||||
|
||||
void CreateTimer() |
||||
{ |
||||
timer = new DispatcherTimer(); |
||||
timer.Interval = TimeSpan.FromMilliseconds(DesignEnvironment.Instance.ParseDelay); |
||||
timer.Tick += new EventHandler(timer_Tick); |
||||
} |
||||
|
||||
void timer_Tick(object sender, EventArgs e) |
||||
{ |
||||
if (NeedParse) { |
||||
Parse(); |
||||
} |
||||
} |
||||
|
||||
public void ResetTimer() |
||||
{ |
||||
timer.Stop(); |
||||
timer.Start(); |
||||
} |
||||
|
||||
public DesignItem CreateItem(Type type) |
||||
{ |
||||
return CreateItem(Activator.CreateInstance(type)); |
||||
} |
||||
|
||||
public DesignItem CreateItem(object instance) |
||||
{ |
||||
return new DesignItem(this, instance); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows.Media; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public static class DesignExtensionMethods |
||||
{ |
||||
public static IEnumerable<DesignItem> AncestorsAndSelf(this DesignItem item) |
||||
{ |
||||
yield return item; |
||||
foreach (var item2 in Ancestors(item)) { |
||||
yield return item2; |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<DesignItem> Ancestors(this DesignItem item) |
||||
{ |
||||
while (item.ParentItem != null) { |
||||
yield return item.ParentItem; |
||||
item = item.ParentItem; |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<DesignItem> DescendantsAndSelf(this DesignItem item) |
||||
{ |
||||
yield return item; |
||||
foreach (var child in Descendants(item)) { |
||||
yield return child; |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<DesignItem> Descendants(this DesignItem item) |
||||
{ |
||||
foreach (var child in Children(item)) { |
||||
foreach (var child2 in DescendantsAndSelf(child)) { |
||||
yield return child2; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<DesignItem> Children(this DesignItem item) |
||||
{ |
||||
var content = item.Content; |
||||
if (content != null) { |
||||
if (content.Collection != null) { |
||||
foreach (var child in content.Collection) { |
||||
yield return child; |
||||
} |
||||
} |
||||
else if (content.Value != null) { |
||||
yield return content.Value; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Filters an element list, dropping all elements that are not part of the xaml document
|
||||
// (e.g. because they were deleted).
|
||||
//public static IEnumerable<DesignItem> GetLiveElements(IEnumerable<DesignItem> items)
|
||||
//{
|
||||
// foreach (DesignItem item in items) {
|
||||
// if (IsInDocument(item) && CanSelectComponent(item)) {
|
||||
// yield return item;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public static bool CanAdd(this DesignItem container, IEnumerable<DesignItem> items, bool copy) |
||||
{ |
||||
return container.View is Panel; |
||||
} |
||||
|
||||
public static void Add(this DesignItem container, IEnumerable<DesignItem> items, bool copy) |
||||
{ |
||||
foreach (var item in items) { |
||||
(container.View as Panel).Children.Add(item.View); |
||||
} |
||||
} |
||||
|
||||
public static bool CanInsert(this DesignItem container, IEnumerable<DesignItem> items, DesignItem after, bool copy) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public static void Insert(this DesignItem container, IEnumerable<DesignItem> items, DesignItem after, bool copy) |
||||
{ |
||||
|
||||
} |
||||
|
||||
public static void Delete(this DesignItem item) |
||||
{ |
||||
var panel = item.View.Parent as Panel; |
||||
if (panel != null) { |
||||
panel.Children.Remove(item.View); |
||||
} |
||||
} |
||||
|
||||
public static void Delete(this IEnumerable<DesignItem> items) |
||||
{ |
||||
foreach (var item in items) { |
||||
Delete(item); |
||||
} |
||||
} |
||||
|
||||
public static DesignItem Clone(this DesignItem item) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static Rect GetLayoutSlot(this DesignItem item) |
||||
{ |
||||
return LayoutInformation.GetLayoutSlot(item.View); |
||||
} |
||||
|
||||
public static Rect GetBounds(this DesignItem item) |
||||
{ |
||||
Point zero = new Point(); |
||||
if (item.View.Parent != null) { |
||||
zero = item.View.TransformToAncestor(item.View.Parent as Visual).Transform(zero); |
||||
} |
||||
return new Rect(zero, item.View.RenderSize); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,194 @@
@@ -0,0 +1,194 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using SharpDevelop.XamlDesigner.Extensibility; |
||||
using SharpDevelop.XamlDesigner.Extensibility.Attributes; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Xml.Linq; |
||||
using System.Windows.Markup; |
||||
using System.ComponentModel; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignItem : DependencyObject, INotifyPropertyChanged, IHasContext |
||||
{ |
||||
internal DesignItem(DesignContext context, Type type) |
||||
{ |
||||
Construct(context, type, null); |
||||
} |
||||
|
||||
internal DesignItem(DesignContext context, object instance) |
||||
{ |
||||
Construct(context, instance.GetType(), instance); |
||||
InitializeNew(); |
||||
} |
||||
|
||||
public Type Type { get; private set; } |
||||
public object Instance { get; private set; } |
||||
public DesignProperty ParentProperty { get; private set; } |
||||
public DesignItem ParentItem { get; private set; } |
||||
public DesignContext Context { get; private set; } |
||||
public DesignProperty Content { get; private set; } |
||||
//public DesignProperty Name { get; private set; }
|
||||
public XElement XmlElement; |
||||
|
||||
Dictionary<MemberId, DesignProperty> properties = new Dictionary<MemberId, DesignProperty>(); |
||||
|
||||
public FrameworkElement View |
||||
{ |
||||
get { return Instance as FrameworkElement; } |
||||
} |
||||
|
||||
public static readonly DependencyProperty IsSelectedProperty = |
||||
Selector.IsSelectedProperty.AddOwner(typeof(DesignItem)); |
||||
|
||||
public bool IsSelected |
||||
{ |
||||
get { return (bool)GetValue(IsSelectedProperty); } |
||||
set { SetValue(IsSelectedProperty, value); } |
||||
} |
||||
|
||||
string name; |
||||
|
||||
public string Name |
||||
{ |
||||
get { return name; } |
||||
set |
||||
{ |
||||
name = value; |
||||
RaisePropertyChanged("Name"); |
||||
RaisePropertyChanged("DisplayName"); |
||||
} |
||||
} |
||||
|
||||
public string DisplayName |
||||
{ |
||||
get |
||||
{ |
||||
if (Name != null) { |
||||
return Type.Name + " (" + Name + ")"; |
||||
} |
||||
return Type.Name; |
||||
} |
||||
} |
||||
|
||||
public bool InstanceMatchType |
||||
{ |
||||
get |
||||
{ |
||||
return Instance == null || Instance.GetType() == Type; |
||||
} |
||||
} |
||||
|
||||
public static DesignItem GetAttachedItem(DependencyObject obj) |
||||
{ |
||||
return (DesignItem)obj.GetValue(AttachedItemProperty); |
||||
} |
||||
|
||||
public static void SetAttachedItem(DependencyObject obj, DesignItem value) |
||||
{ |
||||
obj.SetValue(AttachedItemProperty, value); |
||||
} |
||||
|
||||
public static readonly DependencyProperty AttachedItemProperty = |
||||
DependencyProperty.RegisterAttached("AttachedItem", typeof(DesignItem), typeof(DesignItem), |
||||
new PropertyMetadata(AttachedItemChanged)); |
||||
|
||||
static void AttachedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
var item = e.NewValue as DesignItem; |
||||
item.Instance = d; |
||||
item.Initialize(); |
||||
} |
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
base.OnPropertyChanged(e); |
||||
|
||||
if (e.Property == IsSelectedProperty) { |
||||
if ((bool)e.NewValue) { |
||||
Context.Selection.AddWhenPropertyChanged(this); |
||||
} |
||||
else { |
||||
Context.Selection.RemoveWhenPropertyChanged(this); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void Construct(DesignContext context, Type type, object instance) |
||||
{ |
||||
Context = context; |
||||
Type = type; |
||||
Instance = instance; |
||||
|
||||
foreach (ContentPropertyAttribute a in type.GetCustomAttributes(typeof(ContentPropertyAttribute), true)) { |
||||
if (a.Name != null) { |
||||
Content = Property(a.Name); |
||||
} |
||||
break; |
||||
} |
||||
|
||||
//foreach (RuntimeNamePropertyAttribute a in type.GetCustomAttributes(typeof(RuntimeNamePropertyAttribute), true)) {
|
||||
// if (a.Name != null) {
|
||||
// Name = Property(a.Name);
|
||||
// }
|
||||
// break;
|
||||
//}
|
||||
} |
||||
|
||||
public void Initialize() |
||||
{ |
||||
foreach (var a in MetadataStore.GetAttributes<ItemInitializerAttribute>(Type)) { |
||||
a.ItemInitializer(this); |
||||
} |
||||
} |
||||
|
||||
public void InitializeNew() |
||||
{ |
||||
Initialize(); |
||||
foreach (var a in MetadataStore.GetAttributes<NewItemInitializerAttribute>(Type)) { |
||||
a.NewItemInitializer(this); |
||||
} |
||||
var b = MetadataStore.GetAttributes<DefaultSizeAttribute>(Type).FirstOrDefault(); |
||||
if (b != null) { |
||||
View.Width = b.DefaultSize.Width; |
||||
View.Height = b.DefaultSize.Height; |
||||
} |
||||
} |
||||
|
||||
public DesignProperty Property(string name) |
||||
{ |
||||
return Property(Type, name); |
||||
} |
||||
|
||||
public DesignProperty Property(Type type, string name) |
||||
{ |
||||
return Property(MemberId.GetMember(type, name)); |
||||
} |
||||
|
||||
public DesignProperty Property(MemberId member) |
||||
{ |
||||
DesignProperty result; |
||||
if (!properties.TryGetValue(member, out result)) { |
||||
result = new DesignProperty(this, member); |
||||
properties[member] = result; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void RaisePropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,101 @@
@@ -0,0 +1,101 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Collections.Specialized; |
||||
using System.Collections; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignItemCollection : DesignItem, IList<DesignItem>, INotifyCollectionChanged |
||||
{ |
||||
internal DesignItemCollection(DesignContext context, Type type) : base(context, type) |
||||
{ |
||||
} |
||||
|
||||
List<DesignItem> list = new List<DesignItem>(); |
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged; |
||||
|
||||
internal void ParserAdd(DesignItem item) |
||||
{ |
||||
list.Add(item); |
||||
} |
||||
|
||||
#region IList<DesignItem> Members
|
||||
|
||||
public int IndexOf(DesignItem item) |
||||
{ |
||||
return list.IndexOf(item); |
||||
} |
||||
|
||||
public void Insert(int index, DesignItem item) |
||||
{ |
||||
list.Insert(index, item); |
||||
} |
||||
|
||||
public void RemoveAt(int index) |
||||
{ |
||||
list.RemoveAt(index); |
||||
} |
||||
|
||||
public DesignItem this[int index] |
||||
{ |
||||
get |
||||
{ |
||||
return list[index]; |
||||
} |
||||
set |
||||
{ |
||||
list[index] = value; |
||||
} |
||||
} |
||||
|
||||
public void Add(DesignItem item) |
||||
{ |
||||
list.Add(item); |
||||
} |
||||
|
||||
public void Clear() |
||||
{ |
||||
list.Clear(); |
||||
} |
||||
|
||||
public bool Contains(DesignItem item) |
||||
{ |
||||
return list.Contains(item); |
||||
} |
||||
|
||||
public void CopyTo(DesignItem[] array, int arrayIndex) |
||||
{ |
||||
list.CopyTo(array, arrayIndex); |
||||
} |
||||
|
||||
public int Count |
||||
{ |
||||
get { return list.Count; } |
||||
} |
||||
|
||||
public bool IsReadOnly |
||||
{ |
||||
get { return false; } |
||||
} |
||||
|
||||
public bool Remove(DesignItem item) |
||||
{ |
||||
return list.Remove(item); |
||||
} |
||||
|
||||
public IEnumerator<DesignItem> GetEnumerator() |
||||
{ |
||||
return list.GetEnumerator(); |
||||
} |
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() |
||||
{ |
||||
return list.GetEnumerator(); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Reflection; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignProject |
||||
{ |
||||
public DesignContext CreateContext(ITextHolder textHolder) |
||||
{ |
||||
return new DesignContext(this, textHolder); |
||||
} |
||||
|
||||
public List<Assembly> Assemblies = new List<Assembly>(); |
||||
|
||||
static Assembly MscorlibAssembly = typeof(object).Assembly; |
||||
static Assembly WindowsBaseAssembly = typeof(DependencyObject).Assembly; |
||||
static Assembly PresentationCoreAssembly = typeof(UIElement).Assembly; |
||||
static Assembly PresentationFrameworkAssembly = typeof(FrameworkElement).Assembly; |
||||
|
||||
static Assembly[] DefaultAssemblies = new Assembly[] { |
||||
MscorlibAssembly, |
||||
WindowsBaseAssembly, |
||||
PresentationCoreAssembly, |
||||
PresentationFrameworkAssembly |
||||
}; |
||||
|
||||
public IEnumerable<Type> GetAvailableTypes() |
||||
{ |
||||
foreach (var assembly in Assemblies.Concat(DefaultAssemblies).Distinct()) { |
||||
foreach (var type in assembly.GetExportedTypes()) { |
||||
if (type.IsAbstract) continue; |
||||
if (type.GetConstructor(Type.EmptyTypes) != null) { |
||||
yield return type; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using SharpDevelop.XamlDesigner.Dom.UndoSystem; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignProperty : ViewModel, IHasContext |
||||
{ |
||||
internal DesignProperty(DesignItem item, MemberId member) |
||||
{ |
||||
ParentItem = item; |
||||
MemberId = member; |
||||
|
||||
if (Utils.IsCollection(member.ValueType)) { |
||||
value = new DesignItemCollection(item.Context, member.ValueType); |
||||
} |
||||
} |
||||
|
||||
public MemberId MemberId { get; private set; } |
||||
public DesignItem ParentItem { get; private set; } |
||||
|
||||
public DesignContext Context |
||||
{ |
||||
get { return ParentItem.Context; } |
||||
} |
||||
|
||||
DesignItem value; |
||||
|
||||
public DesignItem Value |
||||
{ |
||||
get { return value; } |
||||
set { SetValue(value); } |
||||
} |
||||
|
||||
public object ValueObject |
||||
{ |
||||
get |
||||
{ |
||||
if (Value != null) { |
||||
return Value.Instance; |
||||
} |
||||
var propertyId = MemberId as PropertyId; |
||||
if (propertyId != null && ParentItem.InstanceMatchType) { |
||||
return propertyId.Descriptor.GetValue(ParentItem.Instance); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public bool IsSet |
||||
{ |
||||
get { return Value != null; } |
||||
} |
||||
|
||||
public DesignItemCollection Collection |
||||
{ |
||||
get { return Value as DesignItemCollection; } |
||||
} |
||||
|
||||
public void Reset() |
||||
{ |
||||
SetValue(DependencyProperty.UnsetValue); |
||||
} |
||||
|
||||
public void SetValue(object value) |
||||
{ |
||||
var valueItem = value as DesignItem; |
||||
|
||||
if (valueItem == null) { |
||||
//var text = value as string;
|
||||
//if (text != null &&
|
||||
// !MemberId.ValueType.IsAssignableFrom(typeof(string)) &&
|
||||
// MemberId.ValueSerializer != null &&
|
||||
// MemberId.ValueSerializer.CanConvertFromString(text, null)) {
|
||||
|
||||
// value = MemberId.ValueSerializer.ConvertFromString(text, null);
|
||||
//}
|
||||
if (value != DependencyProperty.UnsetValue) { |
||||
valueItem = Context.CreateItem(value); |
||||
} |
||||
} |
||||
|
||||
Context.UndoManager.Execute(new PropertyAction(this, valueItem)); |
||||
} |
||||
|
||||
internal void SetValueCore(DesignItem value) |
||||
{ |
||||
this.value = value; |
||||
|
||||
XamlOperations.SetValue(this); |
||||
|
||||
RaisePropertyChanged("Value"); |
||||
RaisePropertyChanged("ValueObject"); |
||||
RaisePropertyChanged("Collection"); |
||||
RaisePropertyChanged("IsSet"); |
||||
} |
||||
|
||||
internal void ParserSetValue(DesignItem value) |
||||
{ |
||||
this.value = value; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class EventId : MemberId |
||||
{ |
||||
internal EventId(EventDescriptor d) |
||||
{ |
||||
Descriptor = d; |
||||
} |
||||
|
||||
public EventDescriptor Descriptor { get; private set; } |
||||
|
||||
public override string Name |
||||
{ |
||||
get { return Descriptor.Name; } |
||||
} |
||||
|
||||
public override Type OwnerType |
||||
{ |
||||
get { return Descriptor.ComponentType; } |
||||
} |
||||
|
||||
public override Type ValueType |
||||
{ |
||||
get { return typeof(string); } |
||||
} |
||||
|
||||
public override bool IsReadOnly |
||||
{ |
||||
get { return false; } |
||||
} |
||||
|
||||
public override ValueSerializer ValueSerializer |
||||
{ |
||||
get { return ValueSerializer.GetSerializerFor(typeof(string)); } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
interface IHasContext |
||||
{ |
||||
DesignContext Context { get; } |
||||
} |
||||
} |
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Xaml.Schema; |
||||
using System.Windows.Controls; |
||||
using System.Xaml; |
||||
using System.Windows.Input; |
||||
using SharpDevelop.XamlDesigner.Extensibility; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public abstract class MemberId |
||||
{ |
||||
public abstract string Name { get; } |
||||
public abstract Type OwnerType { get; } |
||||
public abstract Type ValueType { get; } |
||||
public abstract bool IsReadOnly { get; } |
||||
public abstract ValueSerializer ValueSerializer { get; } |
||||
public bool IsAttachable { get; internal set; } |
||||
|
||||
public string DisplayName |
||||
{ |
||||
get { return IsAttachable ? OwnerType.Name + "." + Name : Name; } |
||||
} |
||||
|
||||
public string Documentation |
||||
{ |
||||
get { return DesignEnvironment.Instance.GetDocumentation(this); } |
||||
} |
||||
|
||||
public bool IsBrowsable |
||||
{ |
||||
get |
||||
{ |
||||
var a = MetadataStore.GetAttributes<BrowsableAttribute>(this).FirstOrDefault(); |
||||
return a != null ? a.Browsable : true; |
||||
} |
||||
} |
||||
|
||||
static Dictionary<Type, Dictionary<string, MemberId>> map = |
||||
new Dictionary<Type, Dictionary<string, MemberId>>(); |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return OwnerType.Name + "." + Name; |
||||
} |
||||
|
||||
public static MemberId GetMember(Type type, string name) |
||||
{ |
||||
EnsureType(type); |
||||
|
||||
foreach (var currentType in type.GetChain()) { |
||||
MemberId result; |
||||
if (map[currentType].TryGetValue(name, out result)) { |
||||
return result; |
||||
} |
||||
} |
||||
|
||||
throw new Exception(); |
||||
} |
||||
|
||||
public static IEnumerable<MemberId> GetMembers(Type type) |
||||
{ |
||||
EnsureType(type); |
||||
|
||||
foreach (var currentType in type.GetChain()) { |
||||
foreach (var member in map[currentType].Values) { |
||||
yield return member; |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void EnsureType(Type type) |
||||
{ |
||||
Dictionary<string, MemberId> result; |
||||
if (!map.TryGetValue(type, out result)) { |
||||
result = new Dictionary<string, MemberId>(); |
||||
|
||||
foreach (PropertyDescriptor d in TypeDescriptor.GetProperties(type)) { |
||||
if (d.ComponentType == type) { |
||||
result[d.Name] = new PropertyId(d); |
||||
} |
||||
} |
||||
foreach (EventDescriptor d in TypeDescriptor.GetEvents(type)) { |
||||
if (d.ComponentType == type) { |
||||
result[d.Name] = new EventId(d); |
||||
} |
||||
} |
||||
foreach (PropertyDescriptor d in GetAttachableProperties(type)) { |
||||
result[d.Name] = new PropertyId(d) { IsAttachable = true }; |
||||
} |
||||
|
||||
map[type] = result; |
||||
} |
||||
if (type.BaseType != null) { |
||||
EnsureType(type.BaseType); |
||||
} |
||||
} |
||||
|
||||
static IEnumerable<PropertyDescriptor> GetAttachableProperties(Type type) |
||||
{ |
||||
var schemaType = XamlSchemaTypeResolver.Default.Resolve( |
||||
XamlSchemaTypeResolver.Default.GetTypeReference(type)); |
||||
|
||||
foreach (var group in schemaType.AttachableMembers) { |
||||
foreach (var property in group.Members.OfType<SchemaProperty>()) { |
||||
var d = XamlClrProperties.GetPropertyDescriptor(property); |
||||
if (d != null) { |
||||
yield return d; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.ComponentModel; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class PropertyId : MemberId |
||||
{ |
||||
internal PropertyId(PropertyDescriptor d) |
||||
{ |
||||
Descriptor = d; |
||||
} |
||||
|
||||
public PropertyDescriptor Descriptor { get; private set; } |
||||
|
||||
public override string Name |
||||
{ |
||||
get { return Descriptor.Name; } |
||||
} |
||||
|
||||
public override Type OwnerType |
||||
{ |
||||
get { return Descriptor.ComponentType; } |
||||
} |
||||
|
||||
public override Type ValueType |
||||
{ |
||||
get { return Descriptor.PropertyType; } |
||||
} |
||||
|
||||
public override bool IsReadOnly |
||||
{ |
||||
get { return Descriptor.IsReadOnly; } |
||||
} |
||||
|
||||
public override ValueSerializer ValueSerializer |
||||
{ |
||||
get { return ValueSerializer.GetSerializerFor(Descriptor); } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignSelectionChangedEventArgs |
||||
{ |
||||
public DesignItem[] OldItems; |
||||
public DesignItem[] NewItems; |
||||
} |
||||
|
||||
public delegate void DesignSelectionChangedHandler(object sender, DesignSelectionChangedEventArgs e); |
||||
} |
@ -0,0 +1,185 @@
@@ -0,0 +1,185 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
using System.Windows.Input; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class SelectionCollection : ICollection<DesignItem>, INotifyCollectionChanged |
||||
{ |
||||
HashSet<DesignItem> selection = new HashSet<DesignItem>(); |
||||
DesignItem[] oldSelection; |
||||
|
||||
public event DesignSelectionChangedHandler Changed; |
||||
public event NotifyCollectionChangedEventHandler CollectionChanged; |
||||
|
||||
public void Add(DesignItem item) |
||||
{ |
||||
BeginChange(); |
||||
AddCore(item); |
||||
EndChange(); |
||||
} |
||||
|
||||
public bool Remove(DesignItem item) |
||||
{ |
||||
BeginChange(); |
||||
var result = RemoveCore(item); |
||||
EndChange(); |
||||
return result; |
||||
} |
||||
|
||||
public void Clear() |
||||
{ |
||||
BeginChangeAndClear(); |
||||
EndChange(); |
||||
} |
||||
|
||||
public void Auto(DesignItem item) |
||||
{ |
||||
Auto(item.AsArrayOrDefault()); |
||||
} |
||||
|
||||
public void Auto(IEnumerable<DesignItem> items) |
||||
{ |
||||
if (items == null) { |
||||
Clear(); |
||||
} |
||||
else { |
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl)) { |
||||
BeginChange(); |
||||
foreach (var item in items) { |
||||
ToggleCore(item); |
||||
} |
||||
} |
||||
else { |
||||
BeginChangeAndClear(); |
||||
foreach (var item in items) { |
||||
AddCore(item); |
||||
} |
||||
} |
||||
EndChange(); |
||||
} |
||||
} |
||||
|
||||
public void Set(DesignItem item) |
||||
{ |
||||
Set(item.AsArrayOrDefault()); |
||||
} |
||||
|
||||
public void Set(IEnumerable<DesignItem> items) |
||||
{ |
||||
BeginChangeAndClear(); |
||||
if (items != null) { |
||||
foreach (var item in items) { |
||||
AddCore(item); |
||||
} |
||||
} |
||||
EndChange(); |
||||
} |
||||
|
||||
internal void AddWhenPropertyChanged(DesignItem item) |
||||
{ |
||||
if (oldSelection == null) { |
||||
Add(item); |
||||
} |
||||
} |
||||
|
||||
internal void RemoveWhenPropertyChanged(DesignItem item) |
||||
{ |
||||
if (oldSelection == null) { |
||||
Remove(item); |
||||
} |
||||
} |
||||
|
||||
public bool Contains(DesignItem item) |
||||
{ |
||||
return selection.Contains(item); |
||||
} |
||||
|
||||
public void CopyTo(DesignItem[] array, int arrayIndex) |
||||
{ |
||||
selection.CopyTo(array, arrayIndex); |
||||
} |
||||
|
||||
public int Count |
||||
{ |
||||
get { return selection.Count; } |
||||
} |
||||
|
||||
public bool IsReadOnly |
||||
{ |
||||
get { return false; } |
||||
} |
||||
|
||||
IEnumerator<DesignItem> IEnumerable<DesignItem>.GetEnumerator() |
||||
{ |
||||
return selection.GetEnumerator(); |
||||
} |
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() |
||||
{ |
||||
return selection.GetEnumerator(); |
||||
} |
||||
|
||||
void AddCore(DesignItem item) |
||||
{ |
||||
if (item != null) { |
||||
selection.Add(item); |
||||
item.IsSelected = true; |
||||
} |
||||
} |
||||
|
||||
bool RemoveCore(DesignItem item) |
||||
{ |
||||
if (item != null) { |
||||
item.IsSelected = false; |
||||
return selection.Remove(item); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void ToggleCore(DesignItem item) |
||||
{ |
||||
if (item != null) { |
||||
if (item.IsSelected) { |
||||
RemoveCore(item); |
||||
} |
||||
else { |
||||
AddCore(item); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void BeginChange() |
||||
{ |
||||
oldSelection = selection.ToArray(); |
||||
} |
||||
|
||||
void BeginChangeAndClear() |
||||
{ |
||||
BeginChange(); |
||||
foreach (var item in oldSelection) { |
||||
RemoveCore(item); |
||||
} |
||||
} |
||||
|
||||
void EndChange() |
||||
{ |
||||
var e = new DesignSelectionChangedEventArgs() { |
||||
OldItems = oldSelection, |
||||
NewItems = selection.ToArray() |
||||
}; |
||||
oldSelection = null; |
||||
if (Changed != null && !selection.SequenceEqual(e.OldItems)) { |
||||
Changed(this, e); |
||||
} |
||||
if (CollectionChanged != null) { |
||||
CollectionChanged(this, new NotifyCollectionChangedEventArgs( |
||||
NotifyCollectionChangedAction.Reset)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows; |
||||
using System.ComponentModel; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.TypeReplacement |
||||
{ |
||||
//[Simulate(typeof(Application))]
|
||||
//[TypeDescriptionProvider(typeof(SimulateTypeDescriptionProvider))]
|
||||
class DesignTimeApplication |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.ComponentModel; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.TypeReplacement |
||||
{ |
||||
class DesignTimeWindow : ContentControl |
||||
{ |
||||
static DesignTimeWindow() |
||||
{ |
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(DesignTimeWindow), |
||||
new FrameworkPropertyMetadata(typeof(DesignTimeWindow))); |
||||
} |
||||
|
||||
public static readonly DependencyProperty TitleProperty = |
||||
Window.TitleProperty.AddOwner(typeof(DesignTimeWindow)); |
||||
|
||||
public string Title |
||||
{ |
||||
get { return (string)GetValue(TitleProperty); } |
||||
set { SetValue(TitleProperty, value); } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.UndoSystem |
||||
{ |
||||
class InsertAction : UndoAction |
||||
{ |
||||
public InsertAction(DesignItemCollection collection, DesignItem item, int index) |
||||
{ |
||||
this.collection = collection; |
||||
this.item = item; |
||||
this.index = index; |
||||
} |
||||
|
||||
DesignItemCollection collection; |
||||
DesignItem item; |
||||
int index; |
||||
|
||||
public override void Undo() |
||||
{ |
||||
collection.RemoveAt(index); |
||||
} |
||||
|
||||
public override void Redo() |
||||
{ |
||||
collection.Insert(index, item); |
||||
} |
||||
|
||||
public override IEnumerable<DesignItem> GetAffectedItems() |
||||
{ |
||||
yield return item; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.UndoSystem |
||||
{ |
||||
class PropertyAction : UndoAction |
||||
{ |
||||
public PropertyAction(DesignProperty property, DesignItem newValue) |
||||
{ |
||||
this.property = property; |
||||
this.oldValue = property.Value; |
||||
this.newValue = newValue; |
||||
} |
||||
|
||||
DesignProperty property; |
||||
DesignItem oldValue; |
||||
DesignItem newValue; |
||||
|
||||
public override void Undo() |
||||
{ |
||||
property.SetValueCore(oldValue); |
||||
} |
||||
|
||||
public override void Redo() |
||||
{ |
||||
property.SetValueCore(newValue); |
||||
} |
||||
|
||||
public override IEnumerable<DesignItem> GetAffectedItems() |
||||
{ |
||||
yield return property.ParentItem; |
||||
} |
||||
|
||||
public bool TryMergeWith(PropertyAction other) |
||||
{ |
||||
if (property == other.property) { |
||||
newValue = other.newValue; |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.UndoSystem |
||||
{ |
||||
class RemoveAction : UndoAction |
||||
{ |
||||
public RemoveAction(DesignItemCollection collection, DesignItem item) |
||||
{ |
||||
this.collection = collection; |
||||
this.item = item; |
||||
this.index = collection.IndexOf(item); |
||||
} |
||||
|
||||
DesignItemCollection collection; |
||||
DesignItem item; |
||||
int index; |
||||
|
||||
public override void Undo() |
||||
{ |
||||
collection.Insert(index, item); |
||||
} |
||||
|
||||
public override void Redo() |
||||
{ |
||||
collection.RemoveAt(index); |
||||
} |
||||
|
||||
public override IEnumerable<DesignItem> GetAffectedItems() |
||||
{ |
||||
yield return item; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.UndoSystem |
||||
{ |
||||
public abstract class UndoAction |
||||
{ |
||||
public abstract void Undo(); |
||||
public abstract void Redo(); |
||||
|
||||
public virtual IEnumerable<DesignItem> GetAffectedItems() |
||||
{ |
||||
yield break; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,139 @@
@@ -0,0 +1,139 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.UndoSystem |
||||
{ |
||||
public class UndoManager |
||||
{ |
||||
Stack<UndoAction> undoStack = new Stack<UndoAction>(); |
||||
Stack<UndoAction> redoStack = new Stack<UndoAction>(); |
||||
UndoTransaction trans; |
||||
|
||||
public EventHandler Changed; |
||||
|
||||
public bool CanUndo |
||||
{ |
||||
get { return undoStack.Count > 0; } |
||||
} |
||||
|
||||
public bool CanRedo |
||||
{ |
||||
get { return redoStack.Count > 0; } |
||||
} |
||||
|
||||
public void Undo() |
||||
{ |
||||
if (CanUndo) { |
||||
var action = undoStack.Pop(); |
||||
action.Undo(); |
||||
redoStack.Push(action); |
||||
} |
||||
else { |
||||
throw new Exception(); |
||||
} |
||||
} |
||||
|
||||
public void Redo() |
||||
{ |
||||
if (CanRedo) { |
||||
var action = redoStack.Pop(); |
||||
action.Redo(); |
||||
undoStack.Push(action); |
||||
} |
||||
else { |
||||
throw new Exception(); |
||||
} |
||||
} |
||||
|
||||
public void Execute(UndoAction action) |
||||
{ |
||||
action.Redo(); |
||||
Done(action); |
||||
} |
||||
|
||||
public void Done(UndoAction action) |
||||
{ |
||||
if (trans != null) { |
||||
var propertyAction = action as PropertyAction; |
||||
if (propertyAction != null) { |
||||
foreach (var a in trans.Actions.OfType<PropertyAction>()) { |
||||
if (a.TryMergeWith(propertyAction)) { |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
trans.Actions.Add(action); |
||||
} |
||||
else { |
||||
undoStack.Push(action); |
||||
redoStack.Clear(); |
||||
} |
||||
} |
||||
|
||||
public bool OpenTransaction() |
||||
{ |
||||
if (trans == null) { |
||||
trans = new UndoTransaction(); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public void CommitTransaction() |
||||
{ |
||||
var commited = trans; |
||||
trans = null; |
||||
if (commited.Actions.Count > 0) { |
||||
Done(commited); |
||||
} |
||||
} |
||||
|
||||
public void AbortTransaction() |
||||
{ |
||||
trans.Undo(); |
||||
trans = null; |
||||
} |
||||
|
||||
static bool opened; |
||||
|
||||
static UndoManager FindUndoManager(FrameworkElement element) |
||||
{ |
||||
var contextHolder = element.AncestorsAndSelf().OfType<IHasContext>().FirstOrDefault(); |
||||
if (contextHolder != null) { |
||||
return contextHolder.Context.UndoManager; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static void OnDragStarted(FrameworkElement element) |
||||
{ |
||||
var manager = FindUndoManager(element); |
||||
if (manager != null) { |
||||
opened = manager.OpenTransaction(); |
||||
} |
||||
} |
||||
|
||||
public static void OnDragCompleted(FrameworkElement element) |
||||
{ |
||||
if (opened) { |
||||
var manager = FindUndoManager(element); |
||||
if (manager != null) { |
||||
manager.CommitTransaction(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void OnDragCanceled(FrameworkElement element) |
||||
{ |
||||
if (opened) { |
||||
var manager = FindUndoManager(element); |
||||
if (manager != null) { |
||||
manager.AbortTransaction(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom.UndoSystem |
||||
{ |
||||
class UndoTransaction : UndoAction |
||||
{ |
||||
public List<UndoAction> Actions = new List<UndoAction>(); |
||||
|
||||
public override IEnumerable<DesignItem> GetAffectedItems() |
||||
{ |
||||
foreach (var action in Actions) { |
||||
foreach (var item in action.GetAffectedItems()) { |
||||
yield return item; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override void Undo() |
||||
{ |
||||
foreach (var action in Enumerable.Reverse(Actions)) { |
||||
action.Undo(); |
||||
} |
||||
} |
||||
|
||||
public override void Redo() |
||||
{ |
||||
foreach (var action in Actions) { |
||||
action.Redo(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Xaml; |
||||
using System.IO; |
||||
using System.Windows; |
||||
using System.Xaml.Schema; |
||||
using SharpDevelop.XamlDesigner.Dom.TypeReplacement; |
||||
using System.ComponentModel; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
class XamlOperations |
||||
{ |
||||
//static XamlOperations()
|
||||
//{
|
||||
// var parent = TypeDescriptor.GetProvider(typeof(Window));
|
||||
// TypeDescriptor.AddProvider(new SimulateTypeDescriptionProvider(parent), typeof(Window));
|
||||
//}
|
||||
|
||||
public static DesignItem Parse(DesignContext context) |
||||
{ |
||||
var text = context.TextHolder.Text; |
||||
var nodes = new XamlValidatingReader(new XamlXmlReader(new StringReader(text))).ReadToEnd(); |
||||
Dictionary<XamlNode, DesignItem> map = new Dictionary<XamlNode, DesignItem>(); |
||||
var stack = new Stack<object>(); |
||||
DesignItem currentItem = null; |
||||
DesignItem root = null; |
||||
|
||||
foreach (var node in nodes) { |
||||
switch (node.NodeType) { |
||||
case XamlNodeType.Record: |
||||
var type = (node as XamlTypedStartRecordNode).RecordType; |
||||
var clrType = type.GetClrType(); |
||||
var item = new DesignItem(context, clrType); |
||||
if (stack.Count == 0) { |
||||
root = item; |
||||
} |
||||
else { |
||||
var parentProperty = stack.Peek() as DesignProperty; |
||||
if (parentProperty.Collection != null) { |
||||
parentProperty.Collection.ParserAdd(item); |
||||
} |
||||
else { |
||||
parentProperty.ParserSetValue(item); |
||||
} |
||||
} |
||||
map[node] = item; |
||||
stack.Push(item); |
||||
currentItem = item; |
||||
break; |
||||
case XamlNodeType.EndRecord: |
||||
var type2 = (node as XamlTypedEndRecordNode).RecordType; |
||||
var clrType2 = type2.GetClrType(); |
||||
if (typeof(Window).IsAssignableFrom(clrType2)) { |
||||
XamlClrProperties.SetClrType(type2, typeof(DesignTimeWindow)); |
||||
} |
||||
currentItem = stack.Pop() as DesignItem; |
||||
break; |
||||
case XamlNodeType.Member: |
||||
var memberIdentifier = (node as XamlTypedStartMemberNode).MemberIdentifier; |
||||
var schemaType = XamlSchemaTypeResolver.Default.Resolve( |
||||
new TypeReference(memberIdentifier.TypeName, null)); |
||||
DesignProperty property = null; |
||||
if (schemaType != null) { |
||||
property = currentItem.Property(schemaType.GetClrType(), memberIdentifier.MemberName); |
||||
} |
||||
else { |
||||
property = currentItem.Property(memberIdentifier.MemberName); |
||||
} |
||||
stack.Push(property); |
||||
break; |
||||
case XamlNodeType.EndMember: |
||||
stack.Pop(); |
||||
break; |
||||
case XamlNodeType.Atom: |
||||
var atomItem = context.CreateItem((node as XamlAtomNode).Value); |
||||
(stack.Peek() as DesignProperty).ParserSetValue(atomItem); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
var list = new List<XamlNode>(); |
||||
var attachedItemId = MemberIdentifier.Get(typeof(DesignItem), "AttachedItem"); |
||||
|
||||
foreach (var node in nodes) { |
||||
list.Add(node); |
||||
if (node.NodeType == XamlNodeType.Record) { |
||||
list.Add(new XamlStartMemberNode() { MemberIdentifier = attachedItemId }); |
||||
list.Add(new XamlAtomNode() { Value = map[node] }); |
||||
list.Add(new XamlEndMemberNode() { MemberIdentifier = attachedItemId }); |
||||
} |
||||
} |
||||
|
||||
var reader = new XamlValidatingReader(new XamlReader(list)); |
||||
XamlServices.Load(reader); |
||||
return root; |
||||
} |
||||
|
||||
public static void SetValue(DesignProperty property) |
||||
{ |
||||
var propertyId = property.MemberId as PropertyId; |
||||
if (propertyId != null) { |
||||
if (property.IsSet) { |
||||
propertyId.Descriptor.SetValue(property.ParentItem.Instance, property.Value.Instance); |
||||
} |
||||
else { |
||||
propertyId.Descriptor.ResetValue(property.ParentItem.Instance); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void Insert(DesignItemCollection collection, int index, DesignItem item) |
||||
{ |
||||
} |
||||
|
||||
public static void Remove(DesignItemCollection collection, DesignItem item) |
||||
{ |
||||
} |
||||
|
||||
public static DesignItem Clone(DesignItem item) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
//class Resolver : XamlSchemaTypeResolver
|
||||
//{
|
||||
// public override SchemaType Resolve(TypeReference typeReference)
|
||||
// {
|
||||
// var result = base.Resolve(typeReference);
|
||||
// var type = result.GetClrType();
|
||||
// if (typeof(Window).IsAssignableFrom(type)) {
|
||||
// //result = GenerateSchemaType(typeof(DesignTimeWindow));
|
||||
// XamlClrProperties.SetClrType(result, typeof(DesignTimeWindow));
|
||||
// }
|
||||
// else if (type == typeof(Application)) {
|
||||
// result = GenerateSchemaType(typeof(DesignTimeApplication));
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
} |
||||
} |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using SharpDevelop.XamlDesigner.Dom; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Extensibility.Attributes |
||||
{ |
||||
public class PropertyEditorAttribute : Attribute |
||||
{ |
||||
public DataTemplate EditorTemplate; |
||||
} |
||||
|
||||
public class TypeReplacerAttribute : Attribute |
||||
{ |
||||
public Type TypeReplacer; |
||||
} |
||||
|
||||
public class DefaultSizeAttribute : Attribute |
||||
{ |
||||
public Size DefaultSize; |
||||
} |
||||
|
||||
public class ValueRangeAttribute : Attribute |
||||
{ |
||||
public ValueRange ValueRange; |
||||
} |
||||
|
||||
public class PopularAttribute : Attribute |
||||
{ |
||||
} |
||||
|
||||
public class ContainerTypeAttribute : Attribute |
||||
{ |
||||
public Type ContainerType; |
||||
} |
||||
|
||||
public class ItemInitializerAttribute : Attribute |
||||
{ |
||||
public Action<DesignItem> ItemInitializer; |
||||
} |
||||
|
||||
public class NewItemInitializerAttribute : Attribute |
||||
{ |
||||
public Action<DesignItem> NewItemInitializer; |
||||
} |
||||
|
||||
public class StandardValuesAttribute : Attribute |
||||
{ |
||||
public Type Type; |
||||
public StandardValue[] StandardValues; |
||||
} |
||||
|
||||
public class StandardValue |
||||
{ |
||||
public object Instance { get; set; } |
||||
public string Text { get; set; } |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return Text; |
||||
} |
||||
} |
||||
|
||||
public class ValueRange |
||||
{ |
||||
public double Min; |
||||
public double Max; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Media; |
||||
using SharpDevelop.XamlDesigner.Controls; |
||||
using System.Windows.Shapes; |
||||
using SharpDevelop.XamlDesigner.Placement; |
||||
using System.Windows; |
||||
using SharpDevelop.XamlDesigner.Dom; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Extensibility |
||||
{ |
||||
class DefaultInitializers |
||||
{ |
||||
public static void NewContentControl(DesignItem item) |
||||
{ |
||||
(item.Instance as ContentControl).Content = item.Type.Name.ToString(); |
||||
} |
||||
|
||||
public static void Panel(DesignItem item) |
||||
{ |
||||
var panel = item.View as Panel; |
||||
if (panel.Background == null) { |
||||
panel.Background = Brushes.Transparent; |
||||
} |
||||
var panelAdorner = new GeneralAdorner(panel); |
||||
panelAdorner.Child = new PanelAdorner(); |
||||
item.Context.DesignView.AdornerLayer.Add(panelAdorner); |
||||
} |
||||
|
||||
public static void Border(DesignItem item) |
||||
{ |
||||
var border = item.View as Border; |
||||
border.Background = Brushes.Transparent; |
||||
} |
||||
|
||||
public static void Shape(DesignItem item) |
||||
{ |
||||
var shape = item.View as Shape; |
||||
shape.Fill = Brushes.Transparent; |
||||
} |
||||
|
||||
public static void Label(DesignItem item) |
||||
{ |
||||
var label = item.View as Label; |
||||
label.Padding = new Thickness(0, 0, 5, 5); |
||||
} |
||||
|
||||
public static void GroupBox(DesignItem item) |
||||
{ |
||||
var groupBox = item.View as GroupBox; |
||||
groupBox.Padding = new Thickness(4, 6, 4, 6); |
||||
} |
||||
|
||||
//public static void FrameworkElement(DesignItem item)
|
||||
//{
|
||||
// var container = Activator.CreateInstance(MetadataStore.GetContainer(item)) as PlacementContainer;
|
||||
// PlacementContainer.SetContainer(item, container);
|
||||
//}
|
||||
} |
||||
} |
@ -0,0 +1,272 @@
@@ -0,0 +1,272 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Shapes; |
||||
using SharpDevelop.XamlDesigner.Extensibility.Attributes; |
||||
using SharpDevelop.XamlDesigner.PropertyGrid.Editors; |
||||
using System.Windows; |
||||
using System.Collections; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Controls.Primitives; |
||||
using System.Windows.Media.Media3D; |
||||
using System.Windows.Documents; |
||||
using System.ComponentModel; |
||||
using System.Windows.Media; |
||||
using System.Windows.Input; |
||||
using System.Reflection; |
||||
using SharpDevelop.XamlDesigner.Dom; |
||||
using SharpDevelop.XamlDesigner.Placement; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Extensibility |
||||
{ |
||||
static class DefaultMetadata |
||||
{ |
||||
static Type[] numericTypes = new Type[] |
||||
{ |
||||
typeof(Byte), |
||||
typeof(SByte), |
||||
typeof(Int16), |
||||
typeof(UInt16), |
||||
typeof(Int32), |
||||
typeof(UInt32), |
||||
typeof(Int64), |
||||
typeof(UInt64), |
||||
typeof(Single), |
||||
typeof(Double), |
||||
typeof(Decimal) |
||||
}; |
||||
|
||||
internal static void Register() |
||||
{ |
||||
AddItemInitializer(typeof(Panel), DefaultInitializers.Panel); |
||||
AddItemInitializer(typeof(Border), DefaultInitializers.Border); |
||||
AddItemInitializer(typeof(Shape), DefaultInitializers.Shape); |
||||
AddItemInitializer(typeof(Label), DefaultInitializers.Label); |
||||
|
||||
AddNewItemInitializer(typeof(ContentControl), DefaultInitializers.NewContentControl); |
||||
|
||||
AddEditor(typeof(bool), EditorTemplates.BoolEditor); |
||||
AddEditor(typeof(bool?), EditorTemplates.NuallableBoolEditor); |
||||
AddEditor(typeof(Thickness), EditorTemplates.ThicknessEditor); |
||||
AddEditor(typeof(HorizontalAlignment), EditorTemplates.HorizontalAlignmentEditor); |
||||
AddEditor(typeof(VerticalAlignment), EditorTemplates.VerticalAlignmentEditor); |
||||
AddEditor(typeof(IList), EditorTemplates.CollectionEditor); |
||||
AddEditor(typeof(Brush), EditorTemplates.BrushEditor); |
||||
AddEditor(typeof(MulticastDelegate), EditorTemplates.EventEditor); |
||||
|
||||
AddEditor(FrameworkElement.DataContextProperty, EditorTemplates.ObjectEditor); |
||||
|
||||
foreach (var type in numericTypes) { |
||||
AddEditor(type, EditorTemplates.NumberEditor); |
||||
} |
||||
|
||||
MetadataStore.AddAttribute(UIElement.OpacityProperty, new ValueRangeAttribute() { |
||||
ValueRange = new ValueRange() { Min = 0, Max = 1 } |
||||
}); |
||||
|
||||
AddStandardValues(typeof(Brush), typeof(Brushes)); |
||||
AddStandardValues(typeof(Color), typeof(Colors)); |
||||
AddStandardValues(typeof(FontStretch), typeof(FontStretches)); |
||||
AddStandardValues(typeof(FontWeight), typeof(FontWeights)); |
||||
AddStandardValues(typeof(FontStyle), typeof(FontStyles)); |
||||
AddStandardValues(typeof(Cursor), typeof(Cursors)); |
||||
AddStandardValues(typeof(PixelFormat), typeof(PixelFormats)); |
||||
AddStandardValues(typeof(TextDecorationCollection), typeof(TextDecorations)); |
||||
|
||||
AddStandardValues(typeof(ICommand), typeof(ApplicationCommands)); |
||||
AddStandardValues(typeof(ICommand), typeof(EditingCommands)); |
||||
AddStandardValues(typeof(ICommand), typeof(NavigationCommands)); |
||||
AddStandardValues(typeof(ICommand), typeof(ComponentCommands)); |
||||
AddStandardValues(typeof(ICommand), typeof(MediaCommands)); |
||||
|
||||
AddStandardValues(typeof(FontFamily), Fonts.SystemFontFamilies |
||||
.Select(f => new StandardValue() { Instance = f, Text = f.Source })); |
||||
|
||||
AddPopularProperty(Line.Y2Property); |
||||
AddPopularProperty(NavigationWindow.ShowsNavigationUIProperty); |
||||
AddPopularProperty(FlowDocumentScrollViewer.DocumentProperty); |
||||
AddPopularProperty(GridViewRowPresenterBase.ColumnsProperty); |
||||
AddPopularProperty(ListView.ViewProperty); |
||||
AddPopularProperty(DocumentPageView.PageNumberProperty); |
||||
AddPopularProperty(Popup.PlacementProperty); |
||||
AddPopularProperty(Popup.PopupAnimationProperty); |
||||
AddPopularProperty(ScrollBar.ViewportSizeProperty); |
||||
AddPopularProperty(UniformGrid.RowsProperty); |
||||
AddPopularProperty(TabControl.TabStripPlacementProperty); |
||||
AddPopularProperty(Line.X1Property); |
||||
AddPopularProperty(Line.Y1Property); |
||||
AddPopularProperty(Line.X2Property); |
||||
AddPopularProperty(Polygon.PointsProperty); |
||||
AddPopularProperty(Polyline.PointsProperty); |
||||
AddPopularProperty(Path.DataProperty); |
||||
AddPopularProperty(HeaderedContentControl.HeaderProperty); |
||||
AddPopularProperty(MediaElement.UnloadedBehaviorProperty); |
||||
AddPopularProperty(Shape.FillProperty); |
||||
AddPopularProperty(Page.TitleProperty); |
||||
AddPopularProperty(ItemsControl.ItemsSourceProperty); |
||||
AddPopularProperty(Image.SourceProperty); |
||||
AddPopularProperty(TextBlock.TextProperty); |
||||
AddPopularProperty(DockPanel.LastChildFillProperty); |
||||
AddPopularProperty(Expander.IsExpandedProperty); |
||||
AddPopularProperty(Shape.StrokeProperty); |
||||
AddPopularProperty(RangeBase.ValueProperty); |
||||
AddPopularProperty(ItemsControl.ItemContainerStyleProperty); |
||||
AddPopularProperty(ToggleButton.IsCheckedProperty); |
||||
AddPopularProperty(Window.TitleProperty); |
||||
AddPopularProperty(Viewport3DVisual.CameraProperty); |
||||
AddPopularProperty(Frame.SourceProperty); |
||||
AddPopularProperty(Rectangle.RadiusXProperty); |
||||
AddPopularProperty(Rectangle.RadiusYProperty); |
||||
AddPopularProperty(FrameworkElement.HeightProperty); |
||||
AddPopularProperty(FrameworkElement.WidthProperty); |
||||
AddPopularProperty(UniformGrid.ColumnsProperty); |
||||
AddPopularProperty(RangeBase.MinimumProperty); |
||||
AddPopularProperty(RangeBase.MaximumProperty); |
||||
AddPopularProperty(ScrollBar.OrientationProperty); |
||||
AddPopularProperty(ContentControl.ContentProperty); |
||||
AddPopularProperty(Popup.IsOpenProperty); |
||||
AddPopularProperty(TextElement.FontSizeProperty); |
||||
AddPopularProperty(FrameworkElement.NameProperty); |
||||
AddPopularProperty(Popup.HorizontalOffsetProperty); |
||||
AddPopularProperty(Popup.VerticalOffsetProperty); |
||||
AddPopularProperty(Window.WindowStyleProperty); |
||||
AddPopularProperty(Shape.StrokeThicknessProperty); |
||||
AddPopularProperty(TextElement.ForegroundProperty); |
||||
AddPopularProperty(FrameworkElement.VerticalAlignmentProperty); |
||||
AddPopularProperty(Button.IsDefaultProperty); |
||||
AddPopularProperty(UIElement.RenderTransformOriginProperty); |
||||
AddPopularProperty(TextElement.FontFamilyProperty); |
||||
AddPopularProperty(FrameworkElement.HorizontalAlignmentProperty); |
||||
AddPopularProperty(ToolBar.BandProperty); |
||||
AddPopularProperty(ToolBar.BandIndexProperty); |
||||
AddPopularProperty(ItemsControl.ItemTemplateProperty); |
||||
AddPopularProperty(TextBlock.TextWrappingProperty); |
||||
AddPopularProperty(FrameworkElement.MarginProperty); |
||||
AddPopularProperty(RangeBase.LargeChangeProperty); |
||||
AddPopularProperty(RangeBase.SmallChangeProperty); |
||||
AddPopularProperty(Panel.BackgroundProperty); |
||||
AddPopularProperty(Shape.StrokeMiterLimitProperty); |
||||
AddPopularProperty(TextElement.FontWeightProperty); |
||||
AddPopularProperty(StackPanel.OrientationProperty); |
||||
AddPopularProperty(ListBox.SelectionModeProperty); |
||||
AddPopularProperty(FrameworkElement.StyleProperty); |
||||
AddPopularProperty(TextBox.TextProperty); |
||||
AddPopularProperty(Window.SizeToContentProperty); |
||||
AddPopularProperty(Window.ResizeModeProperty); |
||||
AddPopularProperty(TextBlock.TextTrimmingProperty); |
||||
AddPopularProperty(Window.ShowInTaskbarProperty); |
||||
AddPopularProperty(Window.IconProperty); |
||||
AddPopularProperty(UIElement.RenderTransformProperty); |
||||
AddPopularProperty(Button.IsCancelProperty); |
||||
AddPopularProperty(Border.BorderBrushProperty); |
||||
AddPopularProperty(Block.TextAlignmentProperty); |
||||
AddPopularProperty(Border.CornerRadiusProperty); |
||||
AddPopularProperty(Border.BorderThicknessProperty); |
||||
AddPopularProperty(TreeViewItem.IsSelectedProperty); |
||||
AddPopularProperty(Border.PaddingProperty); |
||||
AddPopularProperty(Shape.StretchProperty); |
||||
|
||||
HideProperty(FrameworkElement.NameProperty); |
||||
HideProperty(typeof(UIElement), "RenderSize"); |
||||
HideProperty(typeof(FrameworkElement), "Resources"); |
||||
HideProperty(typeof(Window), "Owner"); |
||||
|
||||
AddContainerType(typeof(Grid), typeof(GridContainer)); |
||||
AddContainerType(typeof(Canvas), typeof(CanvasContainer)); |
||||
AddContainerType(typeof(StackPanel), typeof(StackPanelContainer)); |
||||
AddContainerType(typeof(DockPanel), typeof(DockPanelContainer)); |
||||
AddContainerType(typeof(WrapPanel), typeof(WrapPanelContainer)); |
||||
AddContainerType(typeof(UniformGrid), typeof(PreviewContainer)); |
||||
|
||||
AddDefaultSize(typeof(UIElement), new Size(120, 100)); |
||||
AddDefaultSize(typeof(ContentControl), new Size(double.NaN, double.NaN)); |
||||
AddDefaultSize(typeof(Button), new Size(75, 23)); |
||||
|
||||
var s1 = new Size(120, double.NaN); |
||||
AddDefaultSize(typeof(Slider), s1); |
||||
AddDefaultSize(typeof(TextBox), s1); |
||||
AddDefaultSize(typeof(PasswordBox), s1); |
||||
AddDefaultSize(typeof(ComboBox), s1); |
||||
AddDefaultSize(typeof(ProgressBar), s1); |
||||
|
||||
var s2 = new Size(120, 20); |
||||
AddDefaultSize(typeof(ToolBar), s2); |
||||
AddDefaultSize(typeof(Menu), s2); |
||||
} |
||||
|
||||
static void AddEditor(Type type, DataTemplate editorTemplate) |
||||
{ |
||||
MetadataStore.AddAttribute(type, new PropertyEditorAttribute() { |
||||
EditorTemplate = editorTemplate |
||||
}); |
||||
} |
||||
|
||||
static void AddEditor(DependencyProperty dp, DataTemplate editorTemplate) |
||||
{ |
||||
MetadataStore.AddAttribute(dp, new PropertyEditorAttribute() { |
||||
EditorTemplate = editorTemplate |
||||
}); |
||||
} |
||||
|
||||
static void AddPopularProperty(DependencyProperty dp) |
||||
{ |
||||
MetadataStore.AddAttribute(dp, new PopularAttribute()); |
||||
} |
||||
|
||||
static void HideProperty(DependencyProperty dp) |
||||
{ |
||||
MetadataStore.AddAttribute(dp, new BrowsableAttribute(false)); |
||||
} |
||||
|
||||
static void HideProperty(Type type, string memberName) |
||||
{ |
||||
MetadataStore.AddAttribute(type, memberName, new BrowsableAttribute(false)); |
||||
} |
||||
|
||||
static void AddStandardValues(Type type, Type valuesContainer) |
||||
{ |
||||
AddStandardValues(type, valuesContainer |
||||
.GetProperties(BindingFlags.Public | BindingFlags.Static) |
||||
.Select(p => new StandardValue() { |
||||
Instance = p.GetValue(null, null), |
||||
Text = p.Name |
||||
})); |
||||
} |
||||
|
||||
static void AddStandardValues(Type type, IEnumerable<StandardValue> values) |
||||
{ |
||||
MetadataStore.AddAttribute(type, new StandardValuesAttribute() { |
||||
Type = type, |
||||
StandardValues = values.ToArray() |
||||
}); |
||||
} |
||||
|
||||
public static void AddContainerType(Type type, Type containerType) |
||||
{ |
||||
MetadataStore.AddAttribute(type, new ContainerTypeAttribute() { |
||||
ContainerType = containerType |
||||
}); |
||||
} |
||||
|
||||
public static void AddDefaultSize(Type type, Size defaultSize) |
||||
{ |
||||
MetadataStore.AddAttribute(type, new DefaultSizeAttribute() { DefaultSize = defaultSize }); |
||||
} |
||||
|
||||
public static void AddItemInitializer(Type type, Action<DesignItem> initializer) |
||||
{ |
||||
MetadataStore.AddAttribute(type, new ItemInitializerAttribute() { |
||||
ItemInitializer = initializer |
||||
}); |
||||
} |
||||
|
||||
public static void AddNewItemInitializer(Type type, Action<DesignItem> initializer) |
||||
{ |
||||
MetadataStore.AddAttribute(type, new NewItemInitializerAttribute() { |
||||
NewItemInitializer = initializer |
||||
}); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
using SharpDevelop.XamlDesigner.Dom; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Extensibility |
||||
{ |
||||
//NOTE: Works like Inherited = true, AllowMultiple = true
|
||||
public static class MetadataStore |
||||
{ |
||||
static MetadataStore() |
||||
{ |
||||
DefaultMetadata.Register(); |
||||
} |
||||
|
||||
static Dictionary<Type, TypeMetadata> store = new Dictionary<Type, TypeMetadata>(); |
||||
|
||||
public static void AddAttribute(Type type, Attribute attribute) |
||||
{ |
||||
EnsureTypeMetadata(type).Attributes.Add(attribute); |
||||
} |
||||
|
||||
public static void AddAttribute(Type type, string memberName, Attribute attribute) |
||||
{ |
||||
EnsureMemberMetadata(type, memberName).Attributes.Add(attribute); |
||||
} |
||||
|
||||
public static void AddAttribute(DependencyProperty dp, Attribute attribute) |
||||
{ |
||||
AddAttribute(dp.OwnerType, dp.Name, attribute); |
||||
} |
||||
|
||||
public static IEnumerable<T> GetAttributes<T>(Type type) where T : Attribute |
||||
{ |
||||
foreach (var current in GetTypeChain(type)) { |
||||
TypeMetadata typeMetadata; |
||||
if (store.TryGetValue(current, out typeMetadata)) { |
||||
foreach (var attribute in typeMetadata.GetMergedAttributes().OfType<T>()) { |
||||
yield return attribute; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
static IEnumerable<Type> GetTypeChain(Type type) |
||||
{ |
||||
var current = type; |
||||
while (current != null) { |
||||
yield return current; |
||||
current = current.BaseType; |
||||
} |
||||
foreach (var item in type.GetInterfaces()) { |
||||
yield return item; |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<T> GetAttributes<T>(Type type, string memberName) where T : Attribute |
||||
{ |
||||
TypeMetadata typeMetadata; |
||||
if (store.TryGetValue(type, out typeMetadata)) { |
||||
if (typeMetadata.Members != null) { |
||||
MemberMetadata memberMetadata; |
||||
if (typeMetadata.Members.TryGetValue(memberName, out memberMetadata)) { |
||||
foreach (var attribute in memberMetadata.GetMergedAttributes().OfType<T>()) { |
||||
yield return attribute; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<T> GetAttributes<T>(DependencyProperty dp) where T : Attribute |
||||
{ |
||||
return GetAttributes<T>(dp.OwnerType, dp.Name); |
||||
} |
||||
|
||||
public static IEnumerable<T> GetAttributes<T>(DesignProperty property) where T : Attribute |
||||
{ |
||||
return GetAttributes<T>(property.MemberId); |
||||
} |
||||
|
||||
public static IEnumerable<T> GetAttributes<T>(MemberId member) where T : Attribute |
||||
{ |
||||
return GetAttributes<T>(member.OwnerType, member.Name); |
||||
} |
||||
|
||||
public static IEnumerable<T> GetAttributes<T>(MemberDescriptor descriptor) where T : Attribute |
||||
{ |
||||
return GetAttributes<T>(descriptor.GetComponentType(), descriptor.Name); |
||||
} |
||||
|
||||
static TypeMetadata EnsureTypeMetadata(Type type) |
||||
{ |
||||
TypeMetadata result; |
||||
if (!store.TryGetValue(type, out result)) { |
||||
result = new TypeMetadata(); |
||||
result.Type = type; |
||||
store[type] = result; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
static MemberMetadata EnsureMemberMetadata(Type type, string memberName) |
||||
{ |
||||
var typeMetadata = EnsureTypeMetadata(type); |
||||
if (typeMetadata.Members == null) { |
||||
typeMetadata.Members = new Dictionary<string, MemberMetadata>(); |
||||
} |
||||
MemberMetadata result; |
||||
if (!typeMetadata.Members.TryGetValue(memberName, out result)) { |
||||
result = new MemberMetadata(); |
||||
result.MemberInfo = type.GetMember(memberName)[0]; |
||||
typeMetadata.Members[memberName] = result; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
class TypeMetadata |
||||
{ |
||||
public Type Type; |
||||
public List<Attribute> Attributes = new List<Attribute>(); |
||||
public Dictionary<string, MemberMetadata> Members; |
||||
|
||||
public IEnumerable<Attribute> GetMergedAttributes() |
||||
{ |
||||
return Attribute.GetCustomAttributes(Type).Concat(Attributes); |
||||
} |
||||
} |
||||
|
||||
class MemberMetadata |
||||
{ |
||||
public MemberInfo MemberInfo; |
||||
public List<Attribute> Attributes = new List<Attribute>(); |
||||
|
||||
public IEnumerable<Attribute> GetMergedAttributes() |
||||
{ |
||||
return Attribute.GetCustomAttributes(MemberInfo).Concat(Attributes); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Media; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using System.Globalization; |
||||
using System.ComponentModel; |
||||
|
||||
namespace SharpDevelop.XamlDesigner |
||||
{ |
||||
public static class ExtensionMethods |
||||
{ |
||||
public static T FindAncestor<T>(this DependencyObject d) where T : class |
||||
{ |
||||
return AncestorsAndSelf(d).OfType<T>().FirstOrDefault(); |
||||
} |
||||
|
||||
public static IEnumerable<DependencyObject> AncestorsAndSelf(this DependencyObject d) |
||||
{ |
||||
while (d != null) { |
||||
yield return d; |
||||
d = VisualTreeHelper.GetParent(d); |
||||
} |
||||
} |
||||
|
||||
public static T FindChild<T>(this DependencyObject d) where T : class |
||||
{ |
||||
if (d is T) return d as T; |
||||
int n = VisualTreeHelper.GetChildrenCount(d); |
||||
for (int i = 0; i < n; i++) { |
||||
var child = VisualTreeHelper.GetChild(d, i); |
||||
var result = FindChild<T>(child); |
||||
if (result != null) return result; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static double Coerce(this double d, double min, double max) |
||||
{ |
||||
return Math.Max(Math.Min(d, max), min); |
||||
} |
||||
|
||||
public static void AddCommandHandler(this UIElement element, ICommand command, Action execute) |
||||
{ |
||||
AddCommandHandler(element, command, execute, null); |
||||
} |
||||
|
||||
public static void AddCommandHandler(this UIElement element, ICommand command, Action execute, Func<bool> canExecute) |
||||
{ |
||||
var cb = new CommandBinding(command); |
||||
if (canExecute != null) { |
||||
cb.CanExecute += delegate(object sender, CanExecuteRoutedEventArgs e) { |
||||
e.CanExecute = canExecute(); |
||||
e.Handled = true; |
||||
}; |
||||
} |
||||
cb.Executed += delegate(object sender, ExecutedRoutedEventArgs e) { |
||||
execute(); |
||||
}; |
||||
element.CommandBindings.Add(cb); |
||||
} |
||||
|
||||
public static void AddRange<T>(this ICollection<T> col, IEnumerable<T> items) |
||||
{ |
||||
foreach (var item in items) { |
||||
col.Add(item); |
||||
} |
||||
} |
||||
|
||||
public static string ToInvariantString(this double d) |
||||
{ |
||||
return d.ToString(CultureInfo.InvariantCulture.NumberFormat); |
||||
} |
||||
|
||||
public static T[] AsArray<T>(this T obj) |
||||
{ |
||||
return new[] { obj }; |
||||
} |
||||
|
||||
public static T[] AsArrayOrDefault<T>(this T obj) |
||||
{ |
||||
if (obj == null) { |
||||
return null; |
||||
} |
||||
return new[] { obj }; |
||||
} |
||||
|
||||
public static object GetDataContext(this RoutedEventArgs e) |
||||
{ |
||||
var f = e.OriginalSource as FrameworkElement; |
||||
if (f != null) { |
||||
return f.DataContext; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static IEnumerable<string> Paths(this IDataObject data) |
||||
{ |
||||
string[] paths = (string[])data.GetData(DataFormats.FileDrop); |
||||
if (paths != null) { |
||||
foreach (var path in paths) { |
||||
yield return path; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static Type GetComponentType(this MemberDescriptor descriptor) |
||||
{ |
||||
if (descriptor is PropertyDescriptor) { |
||||
return (descriptor as PropertyDescriptor).ComponentType; |
||||
} |
||||
return (descriptor as EventDescriptor).ComponentType; |
||||
} |
||||
|
||||
public static IEnumerable<Type> GetChain(this Type type) |
||||
{ |
||||
while (type != null) { |
||||
yield return type; |
||||
type = type.BaseType; |
||||
} |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public class DesignEnvironment |
||||
{ |
||||
public static DesignEnvironment Instance = new DesignEnvironment(); |
||||
|
||||
public int ParseDelay = 3000; |
||||
|
||||
public virtual string GetDocumentation(MemberId member) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public virtual void CreateEventHandler(DesignProperty property) |
||||
{ |
||||
} |
||||
|
||||
public virtual IFileWatcher CreateWatcher() |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public enum DocumentMode |
||||
{ |
||||
Xaml, |
||||
Design |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public interface IFileWatcher |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
public interface ITextHolder |
||||
{ |
||||
string Text { get; set; } |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Dom |
||||
{ |
||||
class SystemFileWatcher |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using SharpDevelop.XamlDesigner.Controls; |
||||
using System.Collections; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Outline |
||||
{ |
||||
class OutlineTreeBox : TreeBox |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
<UserControl x:Class="SharpDevelop.XamlDesigner.Outline.OutlineView" |
||||
x:Name="root" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:Default="clr-namespace:SharpDevelop.XamlDesigner" |
||||
xmlns:Dom="clr-namespace:SharpDevelop.XamlDesigner.Dom" |
||||
xmlns:Controls="clr-namespace:SharpDevelop.XamlDesigner.Controls" |
||||
xmlns:Converters="clr-namespace:SharpDevelop.XamlDesigner.Converters" |
||||
xmlns:Outline="clr-namespace:SharpDevelop.XamlDesigner.Outline" |
||||
SnapsToDevicePixels="True"> |
||||
|
||||
<UserControl.Resources> |
||||
|
||||
<HierarchicalDataTemplate DataType="{x:Type Dom:DesignItem}" |
||||
ItemsSource="{Binding Content.Value, Converter={x:Static Converters:EnsureCollectionConverter.Instance}}"> |
||||
<TextBlock Text="{Binding DisplayName}" /> |
||||
</HierarchicalDataTemplate> |
||||
|
||||
</UserControl.Resources> |
||||
|
||||
<Controls:FilterDecorator> |
||||
<Outline:OutlineTreeBox TreeSource="{Binding Context.Root, ElementName=root, Converter={x:Static Converters:EnsureCollectionConverter.Instance}}" |
||||
SelectionMode="Extended" |
||||
AllowDrag="True" |
||||
AllowDrop="True" |
||||
BorderThickness="0"> |
||||
<Outline:OutlineTreeBox.CoreStyle> |
||||
<Style TargetType="{x:Type Controls:TreeBoxItemCore}"> |
||||
<Setter Property="IsSelected" |
||||
Value="{Binding IsSelected}" /> |
||||
<Setter Property="IsExpanded" |
||||
Value="{Binding Path=(Outline:OutlineView.IsExpanded), Mode=TwoWay}" /> |
||||
</Style> |
||||
</Outline:OutlineTreeBox.CoreStyle> |
||||
</Outline:OutlineTreeBox> |
||||
</Controls:FilterDecorator> |
||||
|
||||
</UserControl> |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
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 System.Windows.Media.Imaging; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Shapes; |
||||
using System.Collections.Specialized; |
||||
using SharpDevelop.XamlDesigner.Controls; |
||||
using System.Globalization; |
||||
using SharpDevelop.XamlDesigner.Dom; |
||||
|
||||
namespace SharpDevelop.XamlDesigner.Outline |
||||
{ |
||||
public partial class OutlineView : UserControl, IHasContext |
||||
{ |
||||
public OutlineView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
public static readonly DependencyProperty ContextProperty = |
||||
DependencyProperty.Register("Context", typeof(DesignContext), typeof(OutlineView)); |
||||
|
||||
public DesignContext Context |
||||
{ |
||||
get { return (DesignContext)GetValue(ContextProperty); } |
||||
set { SetValue(ContextProperty, value); } |
||||
} |
||||
|
||||
public static bool GetIsExpanded(DependencyObject obj) |
||||
{ |
||||
return (bool)obj.GetValue(IsExpandedProperty); |
||||
} |
||||
|
||||
public static void SetIsExpanded(DependencyObject obj, bool value) |
||||
{ |
||||
obj.SetValue(IsExpandedProperty, value); |
||||
} |
||||
|
||||
public static readonly DependencyProperty IsExpandedProperty = |
||||
DependencyProperty.RegisterAttached("IsExpanded", typeof(bool), typeof(OutlineView), |
||||
new PropertyMetadata(true)); |
||||
|
||||
//protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
//{
|
||||
// base.OnPropertyChanged(e);
|
||||
// if (e.Property == DocumentProperty) {
|
||||
// if (e.NewValue != null) {
|
||||
// AttachDocument(e.NewValue as DesignContext);
|
||||
// }
|
||||
// if (e.OldValue != null) {
|
||||
// DetachDocument(e.OldValue as DesignContext);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//void AttachDocument(DesignContext doc)
|
||||
//{
|
||||
// UpdateRoot();
|
||||
// doc.Changed += Document_Changed;
|
||||
//}
|
||||
|
||||
//void DetachDocument(DesignContext doc)
|
||||
//{
|
||||
// UpdateRoot();
|
||||
// doc.Changed -= Document_Changed;
|
||||
//}
|
||||
|
||||
//void Document_Changed(object sender, DocumentChangedEventArgs e)
|
||||
//{
|
||||
// //if (e.Property == e.Property.ParentItem.Content) {
|
||||
// // uxTree.UpdateChildren(e.Property.ParentItem);
|
||||
// //}
|
||||
// //else
|
||||
// if (e.Property == null) {
|
||||
// UpdateRoot();
|
||||
// }
|
||||
//}
|
||||
|
||||
//void UpdateRoot()
|
||||
//{
|
||||
// if (Document != null && Document.Root != null) {
|
||||
// uxTree.TreeSource = new[] { Document.Root };
|
||||
// }
|
||||
// else {
|
||||
// uxTree.TreeSource = null;
|
||||
// }
|
||||
//}
|
||||
} |
||||
} |
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
<PaletteData xmlns="http://sharpdevelop.net"> |
||||
|
||||
<PaletteAssembly Name="PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> |
||||
<PaletteItem TypeName="System.Windows.Controls.Button" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.CheckBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.ComboBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Label" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.TextBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.RadioButton" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Canvas" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Grid" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Border" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.DockPanel" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Expander" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.GroupBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Image" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.InkCanvas" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.ListBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Menu" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.PasswordBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.ProgressBar" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.RichTextBox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.ScrollViewer" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Slider" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.StackPanel" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.TabControl" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.ToolBar" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.TreeView" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Viewbox" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.Viewport3D" /> |
||||
<PaletteItem TypeName="System.Windows.Controls.WrapPanel" /> |
||||
</PaletteAssembly> |
||||
|
||||
<PaletteAssembly Path="../../Libraries/WPFToolkit.dll"> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.DataGrid" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Calendar" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.DatePicker" /> |
||||
</PaletteAssembly> |
||||
|
||||
<PaletteAssembly Path="../../Libraries/RibbonControlsLibrary.dll"> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.HorizontalScrollViewer" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.Ribbon" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenu" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenuItem" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonApplicationSplitMenuItem" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonButton" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonCheckBox" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonComboBox" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonComboBoxItem" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonContextualTabGroup" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonControlGroup" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonDialogLauncher" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonDropDownButton" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonGroup" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonGroupPanel" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonHighlightingList" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonHighlightingListItem" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonMenuItem" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonLabel" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonQuickAccessToolBar" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonToolBarStackPanel" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonSeparator" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.SplitButton" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonSplitButton" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonSystemButton" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonTab" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonTabPanel" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonTextBox" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonTitlePanel" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonToggleButton" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonToolTip" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.RibbonWindow" /> |
||||
<PaletteItem TypeName="Microsoft.Windows.Controls.Ribbon.TwoLineLabel" /> |
||||
</PaletteAssembly> |
||||
|
||||
</PaletteData> |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.1 KiB |