diff --git a/samples/XamlDesigner/XamlDesigner.csproj b/samples/XamlDesigner/XamlDesigner.csproj index aaec0d7d01..bb9af8668d 100644 --- a/samples/XamlDesigner/XamlDesigner.csproj +++ b/samples/XamlDesigner/XamlDesigner.csproj @@ -58,6 +58,9 @@ 3.5 + + 4.0 + 3.5 diff --git a/samples/XamlDesigner2/App.xaml b/samples/XamlDesigner2/App.xaml deleted file mode 100644 index 12438427b8..0000000000 --- a/samples/XamlDesigner2/App.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/XamlDesigner2/App.xaml.cs b/samples/XamlDesigner2/App.xaml.cs deleted file mode 100644 index e91af9e345..0000000000 --- a/samples/XamlDesigner2/App.xaml.cs +++ /dev/null @@ -1,39 +0,0 @@ -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); - } - } -} diff --git a/samples/XamlDesigner2/Converters.cs b/samples/XamlDesigner2/Converters.cs deleted file mode 100644 index fc24c41a1d..0000000000 --- a/samples/XamlDesigner2/Converters.cs +++ /dev/null @@ -1,67 +0,0 @@ -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(); - } - } -} diff --git a/samples/XamlDesigner2/ExtensionMethods.cs b/samples/XamlDesigner2/ExtensionMethods.cs deleted file mode 100644 index cd11839c95..0000000000 --- a/samples/XamlDesigner2/ExtensionMethods.cs +++ /dev/null @@ -1,84 +0,0 @@ -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 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(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(this ObservableCollection col, IEnumerable items) - { - foreach (var item in items) { - col.Add(item); - } - } - - public static void KeepSyncronizedWith(this IList target, ObservableCollection source, Func 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; - } - } -} diff --git a/samples/XamlDesigner2/Images/Error.png b/samples/XamlDesigner2/Images/Error.png deleted file mode 100644 index c37bd062e6..0000000000 Binary files a/samples/XamlDesigner2/Images/Error.png and /dev/null differ diff --git a/samples/XamlDesigner2/Images/Reference.png b/samples/XamlDesigner2/Images/Reference.png deleted file mode 100644 index da47049481..0000000000 Binary files a/samples/XamlDesigner2/Images/Reference.png and /dev/null differ diff --git a/samples/XamlDesigner2/Images/Tag.png b/samples/XamlDesigner2/Images/Tag.png deleted file mode 100644 index b7686f106b..0000000000 Binary files a/samples/XamlDesigner2/Images/Tag.png and /dev/null differ diff --git a/samples/XamlDesigner2/MainWindow.xaml b/samples/XamlDesigner2/MainWindow.xaml deleted file mode 100644 index 1872b10067..0000000000 --- a/samples/XamlDesigner2/MainWindow.xaml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/XamlDesigner2/MainWindow.xaml.cs b/samples/XamlDesigner2/MainWindow.xaml.cs deleted file mode 100644 index 177fa59959..0000000000 --- a/samples/XamlDesigner2/MainWindow.xaml.cs +++ /dev/null @@ -1,258 +0,0 @@ -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 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 - } -} diff --git a/samples/XamlDesigner2/NewFileTemplate.xaml b/samples/XamlDesigner2/NewFileTemplate.xaml deleted file mode 100644 index a2b830f012..0000000000 --- a/samples/XamlDesigner2/NewFileTemplate.xaml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/samples/XamlDesigner2/Properties/AssemblyInfo.cs b/samples/XamlDesigner2/Properties/AssemblyInfo.cs deleted file mode 100644 index c0ea722fa8..0000000000 --- a/samples/XamlDesigner2/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] \ No newline at end of file diff --git a/samples/XamlDesigner2/Properties/Settings.Designer.cs b/samples/XamlDesigner2/Properties/Settings.Designer.cs deleted file mode 100644 index 9b2157575e..0000000000 --- a/samples/XamlDesigner2/Properties/Settings.Designer.cs +++ /dev/null @@ -1,100 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -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(@" - - %ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll -")] - 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; - } - } - } -} diff --git a/samples/XamlDesigner2/Properties/Settings.settings b/samples/XamlDesigner2/Properties/Settings.settings deleted file mode 100644 index 7930f5f0d3..0000000000 --- a/samples/XamlDesigner2/Properties/Settings.settings +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - 0,0,0,0 - - - - - - <?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> - - - Maximized - - - - - - - - - \ No newline at end of file diff --git a/samples/XamlDesigner2/Properties/app.manifest b/samples/XamlDesigner2/Properties/app.manifest deleted file mode 100644 index e82a10f183..0000000000 --- a/samples/XamlDesigner2/Properties/app.manifest +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/AdornerManager.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/AdornerManager.cs deleted file mode 100644 index 49f88d71d3..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/AdornerManager.cs +++ /dev/null @@ -1,147 +0,0 @@ -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 items) - { - foreach (var item in context.Selection) { - ClearAdorners(item); - } - foreach (var item in items) { - AddGeneralAdorner(item, new MoveAdorner()); - } - } - - public void OnEndMove(IEnumerable 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; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/ContainerAdorner.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/ContainerAdorner.cs deleted file mode 100644 index 159a05d995..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/ContainerAdorner.cs +++ /dev/null @@ -1,18 +0,0 @@ -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))); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/GrabAdorner.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/GrabAdorner.cs deleted file mode 100644 index fe8a0709fc..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/GrabAdorner.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner -{ - class GrabAdorner - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/InsertLine.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/InsertLine.cs deleted file mode 100644 index d18c24ed69..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/InsertLine.cs +++ /dev/null @@ -1,18 +0,0 @@ -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))); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/MoveAdorner.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/MoveAdorner.cs deleted file mode 100644 index 3db75a87bb..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/MoveAdorner.cs +++ /dev/null @@ -1,18 +0,0 @@ -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))); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/PanelAdorner.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/PanelAdorner.cs deleted file mode 100644 index c241e986c0..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/PanelAdorner.cs +++ /dev/null @@ -1,18 +0,0 @@ -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))); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/ResizeAdorner.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/ResizeAdorner.cs deleted file mode 100644 index 3da6f2abd8..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Adorners/ResizeAdorner.cs +++ /dev/null @@ -1,19 +0,0 @@ -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))); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/App.xaml b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/App.xaml deleted file mode 100644 index 6cf985f8a8..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/App.xaml +++ /dev/null @@ -1,30 +0,0 @@ - - - #516675 - #99BFDB - - - - \ No newline at end of file diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandBase.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandBase.cs deleted file mode 100644 index 341d8ebfb1..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandBase.cs +++ /dev/null @@ -1,22 +0,0 @@ -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) - { - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandHelper.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandHelper.cs deleted file mode 100644 index 45c1c640cf..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandHelper.cs +++ /dev/null @@ -1,203 +0,0 @@ -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 TrackingElements = new List(); - - 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 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); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandView.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandView.cs deleted file mode 100644 index 6897f5fae4..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/CommandView.cs +++ /dev/null @@ -1,67 +0,0 @@ -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().FirstOrDefault(); - if (keyGesture != null) { - Shortcut = new SimpleKeyGesture() { - Key = keyGesture.Key, - Modifiers = keyGesture.Modifiers - }; - } - var uiCommand = command as RoutedUICommand; - if (uiCommand != null) { - Text = uiCommand.Text; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/ContainerStyleKey.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/ContainerStyleKey.cs deleted file mode 100644 index 46ac7c9315..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/ContainerStyleKey.cs +++ /dev/null @@ -1,44 +0,0 @@ -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(); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/DefaultContainerStyles.xaml b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/DefaultContainerStyles.xaml deleted file mode 100644 index 58c173b0e2..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/DefaultContainerStyles.xaml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/DefaultContainerStyles.xaml.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/DefaultContainerStyles.xaml.cs deleted file mode 100644 index 48af3ce200..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/DefaultContainerStyles.xaml.cs +++ /dev/null @@ -1,34 +0,0 @@ -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); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/IHasCommands.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/IHasCommands.cs deleted file mode 100644 index 26aa73fe1f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/IHasCommands.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Commanding -{ - public interface IHasCommands - { - List Commands { get; } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/MethodCommand.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/MethodCommand.cs deleted file mode 100644 index 33084da6b8..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/MethodCommand.cs +++ /dev/null @@ -1,38 +0,0 @@ -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 canExecute) - { - CommandName = commandName; - ExecuteDelegate = execute; - CanExecuteDelegate = canExecute; - } - - public Action ExecuteDelegate { get; set; } - public Func CanExecuteDelegate { get; set; } - - public override bool CanExecute(object parameter) - { - if (CanExecuteDelegate != null) { - return CanExecuteDelegate(); - } - return true; - } - - public override void Execute(object parameter) - { - ExecuteDelegate(); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/SimpleKeyGesture.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/SimpleKeyGesture.cs deleted file mode 100644 index c8b2debeff..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Commanding/SimpleKeyGesture.cs +++ /dev/null @@ -1,61 +0,0 @@ -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); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/AdvancedDragEventArgs.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/AdvancedDragEventArgs.cs deleted file mode 100644 index 3280056769..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/AdvancedDragEventArgs.cs +++ /dev/null @@ -1,35 +0,0 @@ -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); -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/AdvancedThumb.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/AdvancedThumb.cs deleted file mode 100644 index 6afd7ead72..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/AdvancedThumb.cs +++ /dev/null @@ -1,156 +0,0 @@ -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(); - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/CollectionListener.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/CollectionListener.cs deleted file mode 100644 index af1de81d59..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/CollectionListener.cs +++ /dev/null @@ -1,28 +0,0 @@ -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); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/DashedLine.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/DashedLine.cs deleted file mode 100644 index 2197cc9da0..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/DashedLine.cs +++ /dev/null @@ -1,61 +0,0 @@ -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); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EditSlider.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EditSlider.cs deleted file mode 100644 index 18272fff4a..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EditSlider.cs +++ /dev/null @@ -1,297 +0,0 @@ -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; - } - } - } -} \ No newline at end of file diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EnterTextBox.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EnterTextBox.cs deleted file mode 100644 index 7aa396bede..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EnterTextBox.cs +++ /dev/null @@ -1,41 +0,0 @@ -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(); - } - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EnumListBox.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EnumListBox.cs deleted file mode 100644 index d55de95ca0..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/EnumListBox.cs +++ /dev/null @@ -1,51 +0,0 @@ -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().ToList().IndexOf(EnumValue); - } - else { - UnselectAll(); - } - } - else if (e.Property == SelectedIndexProperty) { - if (EnumValue != null) { - EnumValue = Enum.ToObject(EnumValue.GetType(), SelectedIndex); - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/FilterDecorator.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/FilterDecorator.cs deleted file mode 100644 index a360d385df..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/FilterDecorator.cs +++ /dev/null @@ -1,102 +0,0 @@ -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; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/Form.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/Form.cs deleted file mode 100644 index 8adb103456..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/Form.cs +++ /dev/null @@ -1,17 +0,0 @@ -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); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/FormItem.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/FormItem.cs deleted file mode 100644 index ef3f19025e..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/FormItem.cs +++ /dev/null @@ -1,24 +0,0 @@ -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; } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/GeneralAdorner.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/GeneralAdorner.cs deleted file mode 100644 index 6855496f8d..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/GeneralAdorner.cs +++ /dev/null @@ -1,97 +0,0 @@ -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; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/IconItem.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/IconItem.cs deleted file mode 100644 index 795dcb9e43..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/IconItem.cs +++ /dev/null @@ -1,35 +0,0 @@ -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); } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/LayersPanel.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/LayersPanel.cs deleted file mode 100644 index f5f75d8841..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/LayersPanel.cs +++ /dev/null @@ -1,47 +0,0 @@ -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; - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/OutlineInsertLine.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/OutlineInsertLine.cs deleted file mode 100644 index 335554d0fc..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/OutlineInsertLine.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Controls; - -namespace SharpDevelop.XamlDesigner.Controls -{ - class OutlineInsertLine : Control - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/PixelSnapper.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/PixelSnapper.cs deleted file mode 100644 index 761f267027..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/PixelSnapper.cs +++ /dev/null @@ -1,55 +0,0 @@ -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 elements = new HashSet(); - - 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); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/SelectionFrame.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/SelectionFrame.cs deleted file mode 100644 index 3feaf42dea..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/SelectionFrame.cs +++ /dev/null @@ -1,21 +0,0 @@ -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))); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBox.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBox.cs deleted file mode 100644 index bd449a6a7f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBox.cs +++ /dev/null @@ -1,309 +0,0 @@ -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().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(); - 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 items, int index, bool copy) - { - return true; - } - - protected virtual void Insert(object parent, IEnumerable items, int index, bool copy) - { - } - - protected virtual bool CanDelete(IEnumerable items) - { - return true; - } - - protected virtual void Delete(IEnumerable 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 - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBoxItem.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBoxItem.cs deleted file mode 100644 index fd18e30e62..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBoxItem.cs +++ /dev/null @@ -1,65 +0,0 @@ -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().TryStartDrag(); - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBoxItemCore.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBoxItemCore.cs deleted file mode 100644 index 7f45ddcf49..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Controls/TreeBoxItemCore.cs +++ /dev/null @@ -1,80 +0,0 @@ -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); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Converters/Converters.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Converters/Converters.cs deleted file mode 100644 index 30f7a29aa6..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Converters/Converters.cs +++ /dev/null @@ -1,220 +0,0 @@ -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(); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/DesignResources.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/DesignResources.cs deleted file mode 100644 index 5423d91a9f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/DesignResources.cs +++ /dev/null @@ -1,52 +0,0 @@ -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; } } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignCommands.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignCommands.cs deleted file mode 100644 index d1c5f01669..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignCommands.cs +++ /dev/null @@ -1,117 +0,0 @@ -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() - { - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignContext.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignContext.cs deleted file mode 100644 index 90226c3b17..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignContext.cs +++ /dev/null @@ -1,146 +0,0 @@ -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 References = new List(); - 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); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignExtensionMethods.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignExtensionMethods.cs deleted file mode 100644 index 56effbe4f3..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignExtensionMethods.cs +++ /dev/null @@ -1,129 +0,0 @@ -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 AncestorsAndSelf(this DesignItem item) - { - yield return item; - foreach (var item2 in Ancestors(item)) { - yield return item2; - } - } - - public static IEnumerable Ancestors(this DesignItem item) - { - while (item.ParentItem != null) { - yield return item.ParentItem; - item = item.ParentItem; - } - } - - public static IEnumerable DescendantsAndSelf(this DesignItem item) - { - yield return item; - foreach (var child in Descendants(item)) { - yield return child; - } - } - - public static IEnumerable Descendants(this DesignItem item) - { - foreach (var child in Children(item)) { - foreach (var child2 in DescendantsAndSelf(child)) { - yield return child2; - } - } - } - - public static IEnumerable 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 GetLiveElements(IEnumerable items) - //{ - // foreach (DesignItem item in items) { - // if (IsInDocument(item) && CanSelectComponent(item)) { - // yield return item; - // } - // } - //} - - public static bool CanAdd(this DesignItem container, IEnumerable items, bool copy) - { - return container.View is Panel; - } - - public static void Add(this DesignItem container, IEnumerable items, bool copy) - { - foreach (var item in items) { - (container.View as Panel).Children.Add(item.View); - } - } - - public static bool CanInsert(this DesignItem container, IEnumerable items, DesignItem after, bool copy) - { - return true; - } - - public static void Insert(this DesignItem container, IEnumerable 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 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); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignItem.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignItem.cs deleted file mode 100644 index 7f2e9c6e1a..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignItem.cs +++ /dev/null @@ -1,194 +0,0 @@ -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 properties = new Dictionary(); - - 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(Type)) { - a.ItemInitializer(this); - } - } - - public void InitializeNew() - { - Initialize(); - foreach (var a in MetadataStore.GetAttributes(Type)) { - a.NewItemInitializer(this); - } - var b = MetadataStore.GetAttributes(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 - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignItemCollection.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignItemCollection.cs deleted file mode 100644 index f15be21a86..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignItemCollection.cs +++ /dev/null @@ -1,101 +0,0 @@ -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, INotifyCollectionChanged - { - internal DesignItemCollection(DesignContext context, Type type) : base(context, type) - { - } - - List list = new List(); - - public event NotifyCollectionChangedEventHandler CollectionChanged; - - internal void ParserAdd(DesignItem item) - { - list.Add(item); - } - - #region IList 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 GetEnumerator() - { - return list.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return list.GetEnumerator(); - } - - #endregion - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignProject.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignProject.cs deleted file mode 100644 index 7d2f8a6a5f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignProject.cs +++ /dev/null @@ -1,43 +0,0 @@ -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 Assemblies = new List(); - - 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 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; - } - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignProperty.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignProperty.cs deleted file mode 100644 index 42754e35c5..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/DesignProperty.cs +++ /dev/null @@ -1,106 +0,0 @@ -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; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/EventId.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/EventId.cs deleted file mode 100644 index 7942b3bd48..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/EventId.cs +++ /dev/null @@ -1,44 +0,0 @@ -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)); } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/IHasContext.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/IHasContext.cs deleted file mode 100644 index 2fbe1101ba..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/IHasContext.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Dom -{ - interface IHasContext - { - DesignContext Context { get; } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/MemberId.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/MemberId.cs deleted file mode 100644 index 096b7a0d8a..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/MemberId.cs +++ /dev/null @@ -1,119 +0,0 @@ -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(this).FirstOrDefault(); - return a != null ? a.Browsable : true; - } - } - - static Dictionary> map = - new Dictionary>(); - - 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 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 result; - if (!map.TryGetValue(type, out result)) { - result = new Dictionary(); - - 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 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()) { - var d = XamlClrProperties.GetPropertyDescriptor(property); - if (d != null) { - yield return d; - } - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/PropertyId.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/PropertyId.cs deleted file mode 100644 index 7a52b157a2..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/PropertyId.cs +++ /dev/null @@ -1,44 +0,0 @@ -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); } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/SelectionChangedEventArgs.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/SelectionChangedEventArgs.cs deleted file mode 100644 index 0cc1370df8..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/SelectionChangedEventArgs.cs +++ /dev/null @@ -1,15 +0,0 @@ -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); -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/SelectionCollection.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/SelectionCollection.cs deleted file mode 100644 index 91742132dd..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/SelectionCollection.cs +++ /dev/null @@ -1,185 +0,0 @@ -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, INotifyCollectionChanged - { - HashSet selection = new HashSet(); - 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 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 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 IEnumerable.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)); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/TypeReplacement/DesignTimeApplication.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/TypeReplacement/DesignTimeApplication.cs deleted file mode 100644 index f7c4597ad2..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/TypeReplacement/DesignTimeApplication.cs +++ /dev/null @@ -1,16 +0,0 @@ -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 - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/TypeReplacement/DesignTimeWindow.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/TypeReplacement/DesignTimeWindow.cs deleted file mode 100644 index 28bd412afe..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/TypeReplacement/DesignTimeWindow.cs +++ /dev/null @@ -1,28 +0,0 @@ -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); } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/InsertAction.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/InsertAction.cs deleted file mode 100644 index 36ee574f4e..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/InsertAction.cs +++ /dev/null @@ -1,36 +0,0 @@ -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 GetAffectedItems() - { - yield return item; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/PropertyAction.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/PropertyAction.cs deleted file mode 100644 index bfa4e0d4b0..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/PropertyAction.cs +++ /dev/null @@ -1,45 +0,0 @@ -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 GetAffectedItems() - { - yield return property.ParentItem; - } - - public bool TryMergeWith(PropertyAction other) - { - if (property == other.property) { - newValue = other.newValue; - return true; - } - return false; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/RemoveAction.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/RemoveAction.cs deleted file mode 100644 index 38e04078b3..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/RemoveAction.cs +++ /dev/null @@ -1,36 +0,0 @@ -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 GetAffectedItems() - { - yield return item; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoAction.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoAction.cs deleted file mode 100644 index 52d318abb4..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoAction.cs +++ /dev/null @@ -1,18 +0,0 @@ -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 GetAffectedItems() - { - yield break; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoManager.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoManager.cs deleted file mode 100644 index f41c54ce34..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoManager.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; - -namespace SharpDevelop.XamlDesigner.Dom.UndoSystem -{ - public class UndoManager - { - Stack undoStack = new Stack(); - Stack redoStack = new Stack(); - 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()) { - 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().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(); - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoTransaction.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoTransaction.cs deleted file mode 100644 index 1cfffccad3..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/UndoSystem/UndoTransaction.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Dom.UndoSystem -{ - class UndoTransaction : UndoAction - { - public List Actions = new List(); - - public override IEnumerable 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(); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/XamlOperations.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/XamlOperations.cs deleted file mode 100644 index 00bc45e3a8..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Dom/XamlOperations.cs +++ /dev/null @@ -1,144 +0,0 @@ -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 map = new Dictionary(); - var stack = new Stack(); - 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(); - 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; - // } - //} - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/Attributes/Attributes.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/Attributes/Attributes.cs deleted file mode 100644 index cc3f8278cc..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/Attributes/Attributes.cs +++ /dev/null @@ -1,71 +0,0 @@ -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 ItemInitializer; - } - - public class NewItemInitializerAttribute : Attribute - { - public Action 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; - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/DefaultInitializers.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/DefaultInitializers.cs deleted file mode 100644 index a6b699e117..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/DefaultInitializers.cs +++ /dev/null @@ -1,63 +0,0 @@ -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); - //} - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/DefaultMetadata.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/DefaultMetadata.cs deleted file mode 100644 index 9b61e74180..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/DefaultMetadata.cs +++ /dev/null @@ -1,272 +0,0 @@ -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 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 initializer) - { - MetadataStore.AddAttribute(type, new ItemInitializerAttribute() { - ItemInitializer = initializer - }); - } - - public static void AddNewItemInitializer(Type type, Action initializer) - { - MetadataStore.AddAttribute(type, new NewItemInitializerAttribute() { - NewItemInitializer = initializer - }); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/MetadataStore.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/MetadataStore.cs deleted file mode 100644 index a38012f83c..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Extensibility/MetadataStore.cs +++ /dev/null @@ -1,145 +0,0 @@ -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 store = new Dictionary(); - - 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 GetAttributes(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()) { - yield return attribute; - } - } - } - } - - static IEnumerable 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 GetAttributes(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()) { - yield return attribute; - } - } - } - } - } - - public static IEnumerable GetAttributes(DependencyProperty dp) where T : Attribute - { - return GetAttributes(dp.OwnerType, dp.Name); - } - - public static IEnumerable GetAttributes(DesignProperty property) where T : Attribute - { - return GetAttributes(property.MemberId); - } - - public static IEnumerable GetAttributes(MemberId member) where T : Attribute - { - return GetAttributes(member.OwnerType, member.Name); - } - - public static IEnumerable GetAttributes(MemberDescriptor descriptor) where T : Attribute - { - return GetAttributes(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(); - } - 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 Attributes = new List(); - public Dictionary Members; - - public IEnumerable GetMergedAttributes() - { - return Attribute.GetCustomAttributes(Type).Concat(Attributes); - } - } - - class MemberMetadata - { - public MemberInfo MemberInfo; - public List Attributes = new List(); - - public IEnumerable GetMergedAttributes() - { - return Attribute.GetCustomAttributes(MemberInfo).Concat(Attributes); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/ExtensionMethods.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/ExtensionMethods.cs deleted file mode 100644 index e634fac7ed..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/ExtensionMethods.cs +++ /dev/null @@ -1,125 +0,0 @@ -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(this DependencyObject d) where T : class - { - return AncestorsAndSelf(d).OfType().FirstOrDefault(); - } - - public static IEnumerable AncestorsAndSelf(this DependencyObject d) - { - while (d != null) { - yield return d; - d = VisualTreeHelper.GetParent(d); - } - } - - public static T FindChild(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(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 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(this ICollection col, IEnumerable 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(this T obj) - { - return new[] { obj }; - } - - public static T[] AsArrayOrDefault(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 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 GetChain(this Type type) - { - while (type != null) { - yield return type; - type = type.BaseType; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Images/Class.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Images/Class.png deleted file mode 100644 index d0f11003eb..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Images/Class.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/DesignEnvironment.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/DesignEnvironment.cs deleted file mode 100644 index e89212697d..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/DesignEnvironment.cs +++ /dev/null @@ -1,28 +0,0 @@ -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; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/DocumentMode.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/DocumentMode.cs deleted file mode 100644 index 6a1a0fda9f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/DocumentMode.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Dom -{ - public enum DocumentMode - { - Xaml, - Design - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/IFileWatcher.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/IFileWatcher.cs deleted file mode 100644 index 23eeae84c9..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/IFileWatcher.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Dom -{ - public interface IFileWatcher - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/ITextHolder.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/ITextHolder.cs deleted file mode 100644 index f70f22905b..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/ITextHolder.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Dom -{ - public interface ITextHolder - { - string Text { get; set; } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/SystemFileWatcher.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/SystemFileWatcher.cs deleted file mode 100644 index b020afd77c..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Integration/SystemFileWatcher.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Dom -{ - class SystemFileWatcher - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineTreeBox.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineTreeBox.cs deleted file mode 100644 index 85101f42be..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineTreeBox.cs +++ /dev/null @@ -1,13 +0,0 @@ -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 - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineView.xaml b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineView.xaml deleted file mode 100644 index f2995acf84..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineView.xaml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineView.xaml.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineView.xaml.cs deleted file mode 100644 index f935cf6ea3..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Outline/OutlineView.xaml.cs +++ /dev/null @@ -1,97 +0,0 @@ -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; - // } - //} - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/DefaultPaletteData.xaml b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/DefaultPaletteData.xaml deleted file mode 100644 index efdd43e5e6..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/DefaultPaletteData.xaml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Border.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Border.png deleted file mode 100644 index 7c3b9e2bd5..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Border.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Button.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Button.png deleted file mode 100644 index 302fbdd26c..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Button.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Calendar.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Calendar.png deleted file mode 100644 index af2fd92024..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Calendar.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Canvas.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Canvas.png deleted file mode 100644 index e025e4e860..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Canvas.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/CanvasInk.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/CanvasInk.png deleted file mode 100644 index 1c59b35f34..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/CanvasInk.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/CheckBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/CheckBox.png deleted file mode 100644 index 7bd53735fe..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/CheckBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ColumnDefinitions.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ColumnDefinitions.png deleted file mode 100644 index 3ffa7a44cd..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ColumnDefinitions.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ComboBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ComboBox.png deleted file mode 100644 index 33cacc7b8a..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ComboBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ComboBoxItem.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ComboBoxItem.png deleted file mode 100644 index be3bff4f76..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ComboBoxItem.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ContentControl.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ContentControl.png deleted file mode 100644 index 95b89fa66b..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ContentControl.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DataGrid.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DataGrid.png deleted file mode 100644 index fc43023a05..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DataGrid.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DatePicker.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DatePicker.png deleted file mode 100644 index ef343cfe24..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DatePicker.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DatePickerTextBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DatePickerTextBox.png deleted file mode 100644 index ccb5d56b68..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DatePickerTextBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DockPanel.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DockPanel.png deleted file mode 100644 index 81b493f080..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DockPanel.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DocumentViewer.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DocumentViewer.png deleted file mode 100644 index 7e9217a8a4..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/DocumentViewer.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Element.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Element.png deleted file mode 100644 index c49c703253..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Element.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ElementGray.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ElementGray.png deleted file mode 100644 index 577ecfa090..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ElementGray.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Ellipse.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Ellipse.png deleted file mode 100644 index c9c7f170d3..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Ellipse.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Expander.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Expander.png deleted file mode 100644 index 55bfb0044f..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Expander.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Folder.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Folder.png deleted file mode 100644 index 12bd18f058..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Folder.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderContainer.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderContainer.png deleted file mode 100644 index 73e4b0ae0c..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderContainer.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderControls.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderControls.png deleted file mode 100644 index 9db0c972d8..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderControls.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderControls1.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderControls1.png deleted file mode 100644 index f74c2cd6e0..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderControls1.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderShape.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderShape.png deleted file mode 100644 index be03ada46d..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderShape.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderToolKit.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderToolKit.png deleted file mode 100644 index a114aac4e3..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/FolderToolKit.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Frame.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Frame.png deleted file mode 100644 index ed9fbdadda..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Frame.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Grid.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Grid.png deleted file mode 100644 index 34e0478098..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Grid.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/GridSplitter.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/GridSplitter.png deleted file mode 100644 index 68681b6e40..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/GridSplitter.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/GroupBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/GroupBox.png deleted file mode 100644 index ac6ae0ce41..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/GroupBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/HyperlinkButton.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/HyperlinkButton.png deleted file mode 100644 index aca968cac0..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/HyperlinkButton.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Image.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Image.png deleted file mode 100644 index a7a4fc0075..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Image.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Label.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Label.png deleted file mode 100644 index 19c012fb39..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Label.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Line.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Line.png deleted file mode 100644 index c9303b72b9..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Line.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListBox.png deleted file mode 100644 index 78c03fcb69..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListBoxItem.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListBoxItem.png deleted file mode 100644 index 557a19a2f7..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListBoxItem.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListView.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListView.png deleted file mode 100644 index 77935d7aee..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ListView.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/MediaElement.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/MediaElement.png deleted file mode 100644 index f930e00cdf..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/MediaElement.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Menu.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Menu.png deleted file mode 100644 index 8caf26e775..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Menu.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/MultiScaleImage.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/MultiScaleImage.png deleted file mode 100644 index ee48f48366..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/MultiScaleImage.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/PasswordBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/PasswordBox.png deleted file mode 100644 index f8f5efe933..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/PasswordBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/PasswordBox1.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/PasswordBox1.png deleted file mode 100644 index 6e95124919..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/PasswordBox1.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Path.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Path.png deleted file mode 100644 index 27c78ff482..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Path.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Polygon.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Polygon.png deleted file mode 100644 index 18675e2861..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Polygon.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Polyline.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Polyline.png deleted file mode 100644 index e43437270f..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Polyline.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ProgressBar.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ProgressBar.png deleted file mode 100644 index 9bc1a02623..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ProgressBar.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RadioButton.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RadioButton.png deleted file mode 100644 index 5456a198d0..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RadioButton.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Rectangle.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Rectangle.png deleted file mode 100644 index c4a09ef825..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Rectangle.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RepeatButton.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RepeatButton.png deleted file mode 100644 index dbfc90f046..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RepeatButton.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RichTextBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RichTextBox.png deleted file mode 100644 index d8d81bd392..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RichTextBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RowDefinitions.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RowDefinitions.png deleted file mode 100644 index c5956465c6..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/RowDefinitions.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ScrollBar.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ScrollBar.png deleted file mode 100644 index e5ffa3a2cc..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ScrollBar.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ScrollViewer.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ScrollViewer.png deleted file mode 100644 index 60b35a2cc3..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ScrollViewer.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Separator.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Separator.png deleted file mode 100644 index 908d1b4e38..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Separator.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Slider.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Slider.png deleted file mode 100644 index 3db8d64a14..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Slider.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/StackPanel.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/StackPanel.png deleted file mode 100644 index ab36993d3c..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/StackPanel.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/StatusBar.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/StatusBar.png deleted file mode 100644 index d521b0d715..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/StatusBar.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabControl.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabControl.png deleted file mode 100644 index 275226109d..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabControl.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabItem.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabItem.png deleted file mode 100644 index 3389cabddc..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabItem.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabPanel.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabPanel.png deleted file mode 100644 index 0370a6107a..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TabPanel.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TextBlock.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TextBlock.png deleted file mode 100644 index a79242b54b..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TextBlock.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TextBox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TextBox.png deleted file mode 100644 index 10da710bcb..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TextBox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Thumb.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Thumb.png deleted file mode 100644 index 6646b379d7..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Thumb.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToggleButton.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToggleButton.png deleted file mode 100644 index 595c7fd9e1..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToggleButton.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBar.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBar.png deleted file mode 100644 index dae60be371..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBar.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBarPanel.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBarPanel.png deleted file mode 100644 index d588c3ae7f..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBarPanel.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBarTray.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBarTray.png deleted file mode 100644 index 476d2770e8..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolBarTray.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolKit.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolKit.png deleted file mode 100644 index 9d4b518831..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/ToolKit.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TreeView.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TreeView.png deleted file mode 100644 index 87734b1dd4..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/TreeView.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/UniformGrid.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/UniformGrid.png deleted file mode 100644 index 8f49b193c1..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/UniformGrid.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Viewbox.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Viewbox.png deleted file mode 100644 index f3c67c6c37..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/Viewbox.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/WindowsFomrsHost.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/WindowsFomrsHost.png deleted file mode 100644 index 4651069ec1..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/WindowsFomrsHost.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/WrapPanel.png b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/WrapPanel.png deleted file mode 100644 index bc57aae1dd..0000000000 Binary files a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/Icons/WrapPanel.png and /dev/null differ diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteAssembly.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteAssembly.cs deleted file mode 100644 index 3279e13c96..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteAssembly.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Collections.ObjectModel; -using System.Reflection; -using System.Windows.Markup; -using System.ComponentModel; -using System.Windows.Data; -using System.Diagnostics; -using System.Windows; - -namespace SharpDevelop.XamlDesigner.Palette -{ - [ContentProperty("Items")] - public class PaletteAssembly : PaletteNode - { - public PaletteAssembly() - { - Items = new PaletteItemCollection(this); - ItemsView = CollectionViewSource.GetDefaultView(Items); - ItemsView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); - } - - public Assembly Assembly { get; private set; } - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public PaletteItemCollection Items { get; private set; } - - public ICollectionView ItemsView { get; private set; } - public PaletteData ParentData { get; private set; } - - public string ShortName - { - get - { - if (Assembly != null) { - return Assembly.GetName().Name; - } - return null; - } - } - - string name; - - [DefaultValue(null)] - public string Name - { - get { return name; } - set - { - name = value; - try { - Assembly = Assembly.Load(name); - } - catch { - //TODO - } - } - } - - string path; - - [DefaultValue(null)] - public string Path - { - get { return path; } - set - { - path = value; - try { - var fullPath = System.IO.Path.GetFullPath(path); - Assembly = Assembly.LoadFile(fullPath); - } - catch { - //TODO - } - } - } - - public string ToolTip - { - get { return Path ?? Name; } - } - - internal void SetParent(PaletteData parent) - { - ParentData = parent; - } - - public void LoadItems(bool includeNewItems) - { - HashSet existingTypes = new HashSet(Items.Select(t => t.Type)); - foreach (var type in Assembly.GetExportedTypes()) { - if (typeof(FrameworkElement).IsAssignableFrom(type) && !type.IsAbstract) { - if (!existingTypes.Contains(type)) { - Items.Add(new PaletteItem() { - TypeName = type.FullName, - IsIncluded = includeNewItems - }); - } - } - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteAssemblyCollection.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteAssemblyCollection.cs deleted file mode 100644 index eb6ae5e0f8..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteAssemblyCollection.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Collections.ObjectModel; - -namespace SharpDevelop.XamlDesigner.Palette -{ - public class PaletteAssemblyCollection : ObservableCollection - { - public PaletteAssemblyCollection(PaletteData parent) - { - this.parent = parent; - } - - PaletteData parent; - - protected override void InsertItem(int index, PaletteAssembly item) - { - item.SetParent(parent); - base.InsertItem(index, item); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteData.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteData.cs deleted file mode 100644 index eb0f80f458..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteData.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Collections.ObjectModel; -using System.Windows.Markup; -using System.Windows; -using System.Windows.Data; -using System.ComponentModel; - -namespace SharpDevelop.XamlDesigner.Palette -{ - [ContentProperty("Assemblies")] - public class PaletteData : ViewModel - { - public PaletteData() - { - Assemblies = new PaletteAssemblyCollection(this); - } - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public PaletteAssemblyCollection Assemblies { get; private set; } - - bool showAll; - - [DefaultValue(false)] - public bool ShowAll - { - get - { - return showAll; - } - set - { - if (showAll != value) { - showAll = value; - if (showAll) { - ShowAllNodes(); - } - else { - ShowIncludedNodes(); - } - RaisePropertyChanged("ShowAll"); - } - } - } - - void ShowAllNodes() - { - foreach (var assembly in Assemblies) { - assembly.LoadItems(false); - } - } - - void ShowIncludedNodes() - { - foreach (var assembly in Assemblies) { - foreach (var item in assembly.Items.ToArray()) { - if (!item.IsIncluded) { - assembly.Items.Remove(item); - } - } - } - } - - public void Include(IEnumerable nodes) - { - foreach (var item in nodes.OfType().ToArray()) { - item.IsIncluded = true; - } - } - - public void Exclude(IEnumerable nodes) - { - foreach (var item in nodes.OfType().ToArray()) { - item.IsIncluded = false; - if (!ShowAll) { - item.ParentAssembly.Items.Remove(item); - } - } - } - - public void Remove(IEnumerable assemblies) - { - foreach (PaletteAssembly assembly in assemblies.ToArray()) { - Assemblies.Remove(assembly); - } - } - - public void AddAssembly(string path) - { - var newAssembly = new PaletteAssembly() { Path = path }; - Assemblies.Add(newAssembly); - newAssembly.LoadItems(true); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteItem.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteItem.cs deleted file mode 100644 index 057de42999..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteItem.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Reflection; -using System.Windows.Media.Imaging; -using System.Windows.Media; -using System.ComponentModel; - -namespace SharpDevelop.XamlDesigner.Palette -{ - public class PaletteItem : PaletteNode - { - public Type Type { get; internal set; } - public string TypeName { get; set; } - public PaletteAssembly ParentAssembly { get; private set; } - - public string Name - { - get { return Type != null ? Type.Name : null; } - } - - public object Icon - { - get - { - if (Type != null) { - var stream = DesignResources.GetStream("Palette/Icons/" + Type.Name + ".png"); - if (stream != null) { - return BitmapFrame.Create(stream); - } - return "Icons/ElementGray.png"; - } - return null; - } - } - - bool isIncluded = true; - - [DefaultValue(true)] - public bool IsIncluded - { - get - { - return isIncluded; - } - set - { - if (isIncluded != value) { - isIncluded = value; - RaisePropertyChanged("IsIncluded"); - } - } - } - - CreateTool createTool; - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public CreateTool CreateTool - { - get - { - if (createTool == null) { - createTool = new CreateTool(Type); - } - return createTool; - } - } - - internal void SetParent(PaletteAssembly parent) - { - ParentAssembly = parent; - if (Type == null && ParentAssembly.Assembly != null) { - Type = ParentAssembly.Assembly.GetType(TypeName); - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteItemCollection.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteItemCollection.cs deleted file mode 100644 index 8d40fb2672..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteItemCollection.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Collections.ObjectModel; - -namespace SharpDevelop.XamlDesigner.Palette -{ - public class PaletteItemCollection : ObservableCollection - { - public PaletteItemCollection(PaletteAssembly parent) - { - this.parent = parent; - } - - PaletteAssembly parent; - - protected override void InsertItem(int index, PaletteItem item) - { - item.SetParent(parent); - base.InsertItem(index, item); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteNode.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteNode.cs deleted file mode 100644 index 47b24ed68d..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteNode.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner.Palette -{ - public abstract class PaletteNode : ViewModel - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteView.xaml b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteView.xaml deleted file mode 100644 index 514a248a62..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteView.xaml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteView.xaml.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteView.xaml.cs deleted file mode 100644 index 1085de1721..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Palette/PaletteView.xaml.cs +++ /dev/null @@ -1,187 +0,0 @@ -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.Windows.Markup; -using SharpDevelop.XamlDesigner.Controls; -using System.Collections; -using Microsoft.Win32; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Palette -{ - public partial class PaletteView : UserControl, IHasContext - { - public PaletteView() - { - InitializeComponent(); - InitializeContextMenu(); - AllowDrop = true; - } - - PaletteData paletteData; - OpenFileDialog openFileDialog; - - public static readonly DependencyProperty ContextProperty = - DependencyProperty.Register("Context", typeof(DesignContext), typeof(PaletteView)); - - public DesignContext Context - { - get { return (DesignContext)GetValue(ContextProperty); } - set { SetValue(ContextProperty, value); } - } - - //protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) - //{ - // base.OnPropertyChanged(e); - - // if (e.Property == ContextProperty) { - // if (e.NewValue != null) { - // (e.NewValue as DesignContext).AttachedPaletteData = paletteData; - // } - // } - //} - - public void LoadData(string xaml) - { - paletteData = XamlReader.Parse(xaml) as PaletteData; - uxDataContextHolder.DataContext = paletteData; - (Resources["PaletteData"] as ObjectDataProvider).ObjectInstance = DataContext; - } - - public void ResetData() - { - LoadData(DesignResources.GetString("Palette/DefaultPaletteData.xaml")); - } - - public string SaveData() - { - if (paletteData == null) { - throw new Exception(); - } - return XamlWriter.Save(paletteData); - } - - 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 (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) || - path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) { - e.Effects = DragDropEffects.Copy; - break; - } - } - } - - void ProcessPaths(IEnumerable paths) - { - foreach (var path in paths) { - if (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) || - path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) { - paletteData.AddAssembly(path); - } - } - } - - void InitializeContextMenu() - { - ContextMenuOpening += new ContextMenuEventHandler(PaletteView_ContextMenuOpening); - uxInclude.Click += new RoutedEventHandler(uxInclude_Click); - uxExclude.Click += new RoutedEventHandler(uxExclude_Click); - uxAddAssembly.Click += new RoutedEventHandler(uxAddAssembly_Click); - uxRemoveAssembly.Click += new RoutedEventHandler(uxRemoveAssembly_Click); - uxResetPalette.Click += new RoutedEventHandler(uxResetPalette_Click); - } - - IEnumerable GetSelectedNodes() - { - foreach (var item in uxTree.SelectedItems) { - yield return (item as TreeBoxItemCore).Item as PaletteNode; - } - } - - void uxAddAssembly_Click(object sender, RoutedEventArgs e) - { - if (openFileDialog == null) { - openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "Assemblies (*.dll; *.exe)|*.dll;*.exe"; - } - if (openFileDialog.ShowDialog().Value) { - paletteData.AddAssembly(openFileDialog.FileName); - } - } - - void uxResetPalette_Click(object sender, RoutedEventArgs e) - { - ResetData(); - } - - void uxInclude_Click(object sender, RoutedEventArgs e) - { - paletteData.Include(GetSelectedNodes()); - } - - void uxExclude_Click(object sender, RoutedEventArgs e) - { - paletteData.Exclude(GetSelectedNodes()); - } - - void uxRemoveAssembly_Click(object sender, RoutedEventArgs e) - { - paletteData.Remove(GetSelectedNodes()); - } - - void PaletteView_ContextMenuOpening(object sender, ContextMenuEventArgs e) - { - uxInclude.Visibility = Visibility.Collapsed; - uxExclude.Visibility = Visibility.Collapsed; - uxRemoveAssembly.Visibility = Visibility.Collapsed; - - bool onlyAssemblies = true; - - foreach (var node in GetSelectedNodes()) { - var paletteItem = node as PaletteItem; - if (paletteItem != null) { - if (paletteItem.IsIncluded) { - uxExclude.Visibility = Visibility.Visible; - } - else { - uxInclude.Visibility = Visibility.Visible; - } - onlyAssemblies = false; - } - } - - if (onlyAssemblies) { - uxRemoveAssembly.Visibility = Visibility.Visible; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/CanvasContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/CanvasContainer.cs deleted file mode 100644 index 327139d42a..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/CanvasContainer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class CanvasContainer : PositionalContainer - { - public override void SetPosition(DesignItem item, Rect bounds) - { - Canvas.SetLeft(item.View, bounds.X); - Canvas.SetTop(item.View, bounds.Y); - item.View.ClearValue(FrameworkElement.MarginProperty); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/DockPanelContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/DockPanelContainer.cs deleted file mode 100644 index 736e08dd5b..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/DockPanelContainer.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class DockPanelContainer : PreviewContainer - { - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/GridContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/GridContainer.cs deleted file mode 100644 index 7c35cb42cc..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/GridContainer.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class GridContainer : PositionalContainer - { - public override void SetPosition(DesignItem item, Rect bounds) - { - item.View.Width = bounds.Width; - item.View.Height = bounds.Height; - item.View.Margin = new Thickness(bounds.X, bounds.Y, 0, 0); - item.View.HorizontalAlignment = HorizontalAlignment.Left; - item.View.VerticalAlignment = VerticalAlignment.Top; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/MoveOperation.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/MoveOperation.cs deleted file mode 100644 index a37b1ed484..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/MoveOperation.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Input; -using SharpDevelop.XamlDesigner.Extensibility; -using SharpDevelop.XamlDesigner.Extensibility.Attributes; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class MoveOperation - { - public PlacementContainer PrimaryContainer; - public PreviewContainer SecondaryContainer; - public PlacementInfo[] PlacementInfos; - public bool Copy; - public Point StartPoint; - public Point EndPoint; - public DesignView DesignView; - - public MoveOperation(DesignItem newItem, Point startPoint) - { - DesignView = newItem.Context.DesignView; - StartPoint = DesignView.TransformScrolledToZoomed.Transform(startPoint); - - newItem.View.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); - var size = newItem.View.DesiredSize; - var p = new Point(StartPoint.X - size.Width / 2, StartPoint.Y - size.Height / 2); - - this.PlacementInfos = new PlacementInfo() { - Item = newItem, - OriginalBounds = new Rect(p, size) - }.AsArray(); - - PrimaryContainer = DesignView.SeparatedContainer; - PrimaryContainer.Enter(this); - - Begin(); - } - - public MoveOperation(IEnumerable items, Point startPoint) - { - this.PlacementInfos = items.Select(t => new PlacementInfo() { - Item = t, - OriginalBounds = t.GetLayoutSlot() - }).ToArray(); - - this.StartPoint = startPoint; - this.DesignView = items.First().Context.DesignView; - - Begin(); - } - - public IEnumerable Items - { - get { return PlacementInfos.Select(f => f.Item); } - } - - public void MoveTo(Point endPoint) - { - this.EndPoint = DesignView.TransformScrolledToZoomed.Transform(endPoint); - - DesignItem newParent = null; - DesignItem currentParent = PrimaryContainer == null ? null : PrimaryContainer.ContainerItem; - - foreach (var hit in DesignView.HitTest(endPoint).Except(Items)) { - if (hit == currentParent || hit.CanAdd(Items, Copy)) { - newParent = hit; - break; - } - } - - PlacementContainer newContainer = null; - if (newParent == null) { - newContainer = DesignView.SeparatedContainer; - } - else { - newContainer = PlacementContainer.GetContainer(newParent); - if (newContainer == null) { - var containerType = MetadataStore.GetAttributes(newParent.Type).First().ContainerType; - newContainer = Activator.CreateInstance(containerType) as PlacementContainer; - PlacementContainer.SetContainer(newParent, newContainer); - } - } - - var newPositionalContainer = newContainer as PositionalContainer; - - if (newPositionalContainer != null) { - if (newPositionalContainer != PrimaryContainer) { - newPositionalContainer.BeforeLeavePreviousContainer(this); - PrimaryContainer.Leave(this); - PrimaryContainer = newPositionalContainer; - PrimaryContainer.Enter(this); - } - } - - if (newContainer != SecondaryContainer) { - if (SecondaryContainer != null) { - SecondaryContainer.Leave(this); - } - SecondaryContainer = newContainer as PreviewContainer; - if (SecondaryContainer != null) { - SecondaryContainer.Enter(this); - } - } - - var delta = EndPoint - StartPoint; - var transformToContainer = PrimaryContainer.TransformToContainer(); - - foreach (var info in PlacementInfos) { - var newBounds = info.OriginalBounds; - newBounds.Offset(delta); - info.NewBoundsInContainer = transformToContainer.TransformBounds(newBounds); - } - - PrimaryContainer.OnMove(this); - - if (SecondaryContainer != null) { - SecondaryContainer.OnMove(this); - } - } - - public void Abort() - { - End(); - } - - public void Commit() - { - End(); - } - - void Begin() - { - this.DesignView.Context.AdornerManager.OnBeginMove(Items); - this.Copy = Keyboard.IsKeyDown(Key.LeftCtrl); - } - - void End() - { - PrimaryContainer.Leave(this); - if (SecondaryContainer != null) { - SecondaryContainer.Leave(this); - } - DesignView.Context.AdornerManager.OnEndMove(Items); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PlacementContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PlacementContainer.cs deleted file mode 100644 index 894e2c856d..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PlacementContainer.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Media; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class PlacementContainer - { - public DesignItem ContainerItem; - - public static PlacementContainer GetContainer(DependencyObject obj) - { - return (PlacementContainer)obj.GetValue(ContainerProperty); - } - - public static void SetContainer(DependencyObject obj, PlacementContainer value) - { - obj.SetValue(ContainerProperty, value); - } - - public static readonly DependencyProperty ContainerProperty = - DependencyProperty.RegisterAttached("Container", typeof(PlacementContainer), typeof(PlacementContainer), - new PropertyMetadata(ContainerChanged)); - - static void ContainerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - (e.NewValue as PlacementContainer).ContainerItem = d as DesignItem; - } - - public virtual GeneralTransform TransformToContainer() - { - return ContainerItem.Context.DesignView.ZoomedLayer.TransformToDescendant(ContainerItem.View); - } - - public virtual void Enter(MoveOperation op) - { - } - - public virtual void Leave(MoveOperation op) - { - } - - public virtual void OnResize(ResizeOperation op) - { - } - - public virtual void OnMove(MoveOperation op) - { - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PlacementInfo.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PlacementInfo.cs deleted file mode 100644 index ff4700548f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PlacementInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - public class PlacementInfo - { - public DesignItem Item; - public Rect OriginalBounds; - public Rect NewBoundsInContainer; - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PositionalContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PositionalContainer.cs deleted file mode 100644 index bbe6c535a1..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PositionalContainer.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Media; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - abstract class PositionalContainer : PlacementContainer - { - SnapEngine snapEngine; - - public abstract void SetPosition(DesignItem item, Rect bounds); - - public override void OnMove(MoveOperation op) - { - if (snapEngine != null) { - snapEngine.SnapMove(op); - } - foreach (var info in op.PlacementInfos) { - SetPosition(info.Item, info.NewBoundsInContainer); - } - } - - public override void Enter(MoveOperation op) - { - ContainerItem.Add(op.Items, op.Copy); - snapEngine = new SnapEngine(ContainerItem); - snapEngine.BuildMap(op); - } - - public override void Leave(MoveOperation op) - { - op.Items.Delete(); - snapEngine.HideSnaplines(); - snapEngine = null; - } - - public void BeforeLeavePreviousContainer(MoveOperation op) - { - SnapEngine.UpdateBaseline(op.Items.First()); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PreviewContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PreviewContainer.cs deleted file mode 100644 index befee1844f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/PreviewContainer.cs +++ /dev/null @@ -1,83 +0,0 @@ -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.Diagnostics; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class PreviewContainer : PlacementContainer - { - public override void OnMove(MoveOperation op) - { - var panel = ContainerItem.View as Panel; - var orient = GetOrientation(panel); - int? afterIndex = null; - var p = TransformToContainer().Transform(op.EndPoint); - - FrameworkElement element = null; - Dock side = Dock.Left; - - if (panel.Children.Count == 0) { - side = orient == Orientation.Horizontal ? Dock.Left : Dock.Top; - } - else { - for (int i = 0; i < panel.Children.Count; i++) { - var child = panel.Children[i] as FrameworkElement; - var bounds = LayoutInformation.GetLayoutSlot(child); - if (bounds.Contains(p)) { - if (orient == Orientation.Horizontal) { - if (p.X > bounds.X + bounds.Width / 2) { - afterIndex = i; - break; - } - } - else { - if (p.Y > bounds.Y + bounds.Height / 2) { - afterIndex = i; - break; - } - } - afterIndex = i - 1; - break; - } - } - - if (!afterIndex.HasValue && panel.Children.Count > 0) { - afterIndex = panel.Children.Count - 1; - //info.IsDefault = true; - } - - if (afterIndex.HasValue) { - if (afterIndex.Value >= 0) { - element = panel.Children[afterIndex.Value] as FrameworkElement; - side = orient == Orientation.Horizontal ? Dock.Right : Dock.Bottom; - //info.InsertAfter = DesignContext.GetAttachedItem(info.MarkElement); - } - else { - element = panel.Children[0] as FrameworkElement; - side = orient == Orientation.Horizontal ? Dock.Left : Dock.Top; - } - } - - var area = element == null ? new Rect(ContainerItem.View.RenderSize) : - LayoutInformation.GetLayoutSlot(element); - - ContainerItem.Context.AdornerManager.ShowInsertAdorner(ContainerItem.View, area, side); - } - } - - public override void Leave(MoveOperation op) - { - ContainerItem.Context.AdornerManager.HideInsertAdorner(); - } - - public virtual Orientation GetOrientation(FrameworkElement parentView) - { - return Orientation.Horizontal; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeDirection.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeDirection.cs deleted file mode 100644 index b9f3f446ea..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeDirection.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharpDevelop.XamlDesigner -{ - enum ResizeDirection - { - Left, Right, Up, Down, LeftUp, RightUp, LeftDown, RightDown - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeInfo.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeInfo.cs deleted file mode 100644 index 159cc98ac5..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -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.Input; - -namespace SharpDevelop.XamlDesigner -{ - class ResizeInfo : Control - { - public ResizeInfo(Canvas parent) - { - this.parent = parent; - parent.Children.Add(this); - } - - Canvas parent; - - static ResizeInfo() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeInfo), - new FrameworkPropertyMetadata(typeof(ResizeInfo))); - } - - public static readonly DependencyProperty TextProperty = - DependencyProperty.Register("Text", typeof(string), typeof(ResizeInfo)); - - public string Text - { - get { return (string)GetValue(TextProperty); } - set { SetValue(TextProperty, value); } - } - - public void Update(Size size) - { - Text = size.Width.ToInvariantString() + " x " + size.Height.ToInvariantString(); - var p = Mouse.GetPosition(parent); - Canvas.SetLeft(this, p.X); - Canvas.SetTop(this, p.Y); - } - - public void Remove() - { - parent.Children.Remove(this); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeOperation.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeOperation.cs deleted file mode 100644 index 138c29b11e..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeOperation.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class ResizeOperation - { - public ResizeOperation(DesignItem item, ResizeDirection dir) - { - this.dir = dir; - - PlacementInfo = new PlacementInfo(); - PlacementInfo.Item = item; - PlacementInfo.OriginalBounds = item.GetBounds(); - } - - public PlacementInfo PlacementInfo; - ResizeDirection dir; - - public void Resize(Vector delta) - { - double dx = 0; - double dy = 0; - - var ha = ResizeThumb.GetHorizontalAlignment(dir); - var va = ResizeThumb.GetVerticalAlignmentt(dir); - - if (ha == HorizontalAlignment.Left) dx = -delta.X; - if (ha == HorizontalAlignment.Right) dx = delta.X; - if (va == VerticalAlignment.Top) dy = -delta.Y; - if (va == VerticalAlignment.Bottom) dy = delta.Y; - - var newWidth = Math.Round(Math.Max(0, PlacementInfo.OriginalBounds.Width + dx)); - var newHeight = Math.Round(Math.Max(0, PlacementInfo.OriginalBounds.Height + dy)); - - //item.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(newWidth); - //item.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(newHeight); - - PlacementInfo.Item.View.Width = newWidth; - PlacementInfo.Item.View.Height = newHeight; - PlacementInfo.NewBoundsInContainer = PlacementInfo.Item.GetBounds(); - } - - public void Abort() - { - } - - public void Commit() - { - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeThumb.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeThumb.cs deleted file mode 100644 index 1268a2fef4..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/ResizeThumb.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Controls; -using System.Windows; -using System.Windows.Input; -using SharpDevelop.XamlDesigner.Controls; -using System.Windows.Documents; -using System.Diagnostics; -using System.Windows.Controls.Primitives; -using SharpDevelop.XamlDesigner.Placement; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner -{ - class ResizeThumb : AdvancedThumb - { - static ResizeThumb() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeThumb), - new FrameworkPropertyMetadata(typeof(ResizeThumb))); - } - - public ResizeThumb() - { - UseDelay = false; - } - - ResizeDirection dir; - ResizeOperation op; - ResizeInfo info; - DesignView designView; - - public ResizeDirection ResizeDirection - { - get { return dir; } - set - { - dir = value; - Cursor = GetCursor(dir); - HorizontalAlignment = GetHorizontalAlignment(dir); - VerticalAlignment = GetVerticalAlignmentt(dir); - } - } - - protected override void OnDragStarted() - { - var item = DesignItem.GetAttachedItem(this.FindAncestor().AdornedElement); - op = new ResizeOperation(item, dir); - - designView = item.Context.DesignView; - info = new ResizeInfo(designView.FeedbackLayer); - info.Update(op.PlacementInfo.OriginalBounds.Size); - } - - protected override void OnDragDelta() - { - op.Resize(Delta); - info.Update(op.PlacementInfo.NewBoundsInContainer.Size); - BringIntoView(); - } - - protected override void OnDragCompleted() - { - op.Commit(); - info.Remove(); - } - - static Cursor GetCursor(ResizeDirection dir) - { - switch (dir) { - case ResizeDirection.Down: return Cursors.SizeNS; - case ResizeDirection.Left: return Cursors.SizeWE; - case ResizeDirection.LeftDown: return Cursors.SizeNESW; - case ResizeDirection.LeftUp: return Cursors.SizeNWSE; - case ResizeDirection.Right: return Cursors.SizeWE; - case ResizeDirection.RightDown: return Cursors.SizeNWSE; - case ResizeDirection.RightUp: return Cursors.SizeNESW; - default: return Cursors.SizeNS; - } - } - - public static HorizontalAlignment GetHorizontalAlignment(ResizeDirection dir) - { - switch (dir) { - case ResizeDirection.Down: return HorizontalAlignment.Center; - case ResizeDirection.Left: return HorizontalAlignment.Left; - case ResizeDirection.LeftDown: return HorizontalAlignment.Left; - case ResizeDirection.LeftUp: return HorizontalAlignment.Left; - case ResizeDirection.Right: return HorizontalAlignment.Right; - case ResizeDirection.RightDown: return HorizontalAlignment.Right; - case ResizeDirection.RightUp: return HorizontalAlignment.Right; - default: return HorizontalAlignment.Center; - } - } - - public static VerticalAlignment GetVerticalAlignmentt(ResizeDirection dir) - { - switch (dir) { - case ResizeDirection.Down: return VerticalAlignment.Bottom; - case ResizeDirection.Left: return VerticalAlignment.Center; - case ResizeDirection.LeftDown: return VerticalAlignment.Bottom; - case ResizeDirection.LeftUp: return VerticalAlignment.Top; - case ResizeDirection.Right: return VerticalAlignment.Center; - case ResizeDirection.RightDown: return VerticalAlignment.Bottom; - case ResizeDirection.RightUp: return VerticalAlignment.Top; - default: return VerticalAlignment.Top; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/SeparatedContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/SeparatedContainer.cs deleted file mode 100644 index 451be9c881..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/SeparatedContainer.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Controls; -using System.Windows.Media; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class SeparatedContainer : CanvasContainer - { - public SeparatedContainer(DesignView DesignView, Canvas canvas) - { - this.DesignView = DesignView; - this.canvas = canvas; - } - - DesignView DesignView; - Canvas canvas; - - public override void Enter(MoveOperation op) - { - foreach (var item in op.Items) { - canvas.Children.Add(item.View); - } - } - - public override void Leave(MoveOperation op) - { - canvas.Children.Clear(); - } - - public override GeneralTransform TransformToContainer() - { - return DesignView.ZoomedLayer.TransformToDescendant(canvas); - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/SnapEngine.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/SnapEngine.cs deleted file mode 100644 index c8b054e357..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/SnapEngine.cs +++ /dev/null @@ -1,337 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using SharpDevelop.XamlDesigner.Controls; -using System.Diagnostics; -using SharpDevelop.XamlDesigner.Dom; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class SnapEngine - { - public SnapEngine(DesignItem containerItem) - { - this.containerItem = containerItem; - } - - DesignItem containerItem; - List map = new List(); - - public const double Accuracy = 7; - public const double GlobalMargin = 11; - public const double ControlMargin = 7; - - public static double? GetBaseline(DependencyObject obj) - { - return (double?)obj.GetValue(BaselineProperty); - } - - public static void SetBaseline(DependencyObject obj, double? value) - { - obj.SetValue(BaselineProperty, value); - } - - public static void UpdateBaseline(DesignItem item) - { - SetBaseline(item.View, CalculateBaseline(item.View)); - } - - public static readonly DependencyProperty BaselineProperty = - DependencyProperty.RegisterAttached("Baseline", typeof(double?), typeof(SnapEngine)); - - public Canvas FeedbackLayer - { - get { return containerItem.Context.DesignView.FeedbackLayer; } - } - - public void BuildMap(MoveOperation op) - { - var containerRect = new Rect(containerItem.View.RenderSize); - AddLinesToMap(containerRect, 0, SnaplineKind.Bounds, false); - AddLinesToMap(containerRect, -GlobalMargin, SnaplineKind.Bounds, false); - - var list = new List(); - - foreach (var item in containerItem.Children().Except(op.Items)) { - if (item.View.RenderTransform == Transform.Identity && - item.View.LayoutTransform == Transform.Identity) { - list.Add(item); - } - } - - foreach (var item in list) { - var bounds = item.GetBounds(); - AddLinesToMap(bounds, 0, SnaplineKind.Bounds, false); - AddLinesToMap(bounds, ControlMargin, SnaplineKind.Margin, true); - TryAddBaseline(map, bounds, CalculateBaseline(item.View)); - } - } - - public void SnapResize(ResizeOperation op) - { - } - - public void SnapMove(MoveOperation op) - { - HideSnaplines(); - - var input = BuildInput(op); - - Vector delta; - if (TrySnap(input, out delta)) { - foreach (var info in op.PlacementInfos) { - var snappedBounds = info.NewBoundsInContainer; - snappedBounds.Offset(delta); - info.NewBoundsInContainer = snappedBounds; - } - - var snappedInput = BuildInput(op); - ShowSnaplines(snappedInput, Orientation.Horizontal); - ShowSnaplines(snappedInput, Orientation.Vertical); - } - } - - List BuildInput(MoveOperation op) - { - var result = new List(); - var info = op.PlacementInfos[0]; - - AddLinesToInput(result, op.PlacementInfos[0].NewBoundsInContainer); - TryAddBaseline(result, info.NewBoundsInContainer, CalculateBaseline(info.Item.View)); - - return result; - } - - public void HideSnaplines() - { - FeedbackLayer.Children.Clear(); - } - - void ShowSnaplines(IEnumerable snappedInput, Orientation orient) - { - var offsetDict = new Dictionary(); - - foreach (var inputLine in snappedInput) { - if (inputLine.Orientation == orient) { - foreach (var mapLine in map) { - if (mapLine.Orientation == orient && - mapLine.Offset == inputLine.Offset) { - - var offset = mapLine.Offset; - Snapline drawLine; - - if (!offsetDict.TryGetValue(offset, out drawLine)) { - drawLine = new Snapline(); - drawLine.Orientation = mapLine.Orientation; - drawLine.Offset = offset; - drawLine.Start = double.MaxValue; - drawLine.End = double.MinValue; - offsetDict[offset] = drawLine; - } - drawLine.Start = Math.Min(drawLine.Start, Math.Min(inputLine.Start, mapLine.Start)); - drawLine.End = Math.Max(drawLine.End, Math.Max(inputLine.End, mapLine.End)); - } - } - } - } - - var tr = containerItem.View.TransformToVisual(FeedbackLayer); - var viewStyle = DesignResources.SnaplineStyle; - var drawLines = offsetDict.Values.ToList(); - - foreach (var line in drawLines) { - var view = new DashedLine(); - if (line.Orientation == Orientation.Horizontal) { - view.Point1 = new Point(line.Start, line.Offset); - view.Point2 = new Point(line.End, line.Offset); - } - else { - view.Point1 = new Point(line.Offset, line.Start); - view.Point2 = new Point(line.Offset, line.End); - } - view.Point1 = tr.Transform(view.Point1); - view.Point2 = tr.Transform(view.Point2); - view.Style = viewStyle; - - FeedbackLayer.Children.Add(view); - } - } - - void AddLinesToMap(Rect r, double inflate, SnaplineKind kind, bool opposite) - { - var r2 = r; - r2.Inflate(0, inflate); - AddLine(map, r2, ResizeDirection.Up, kind, opposite ? SnaplineSide.Bottom : SnaplineSide.Top); - AddLine(map, r2, ResizeDirection.Down, kind, opposite ? SnaplineSide.Top : SnaplineSide.Bottom); - - r2 = r; - r2.Inflate(inflate, 0); - AddLine(map, r2, ResizeDirection.Left, kind, opposite ? SnaplineSide.Right : SnaplineSide.Left); - AddLine(map, r2, ResizeDirection.Right, kind, opposite ? SnaplineSide.Left : SnaplineSide.Right); - } - - void AddLinesToInput(List list, Rect r) - { - AddLine(list, r, ResizeDirection.Up, SnaplineKind.Bounds, null); - AddLine(list, r, ResizeDirection.Down, SnaplineKind.Bounds, null); - AddLine(list, r, ResizeDirection.Left, SnaplineKind.Bounds, null); - AddLine(list, r, ResizeDirection.Right, SnaplineKind.Bounds, null); - } - - static void AddLine(List list, Rect r, ResizeDirection dir, - SnaplineKind kind, SnaplineSide? side) - { - switch (dir) { - case ResizeDirection.Up: - list.Add(new Snapline() { - Kind = kind, - Side = side ?? SnaplineSide.Top, - Orientation = Orientation.Horizontal, - Start = r.Left, - End = r.Right, - Offset = r.Top - }); - break; - case ResizeDirection.Down: - list.Add(new Snapline() { - Kind = kind, - Side = side ?? SnaplineSide.Bottom, - Orientation = Orientation.Horizontal, - Start = r.Left, - End = r.Right, - Offset = r.Bottom - }); - break; - case ResizeDirection.Left: - list.Add(new Snapline() { - Kind = kind, - Side = side ?? SnaplineSide.Left, - Orientation = Orientation.Vertical, - Start = r.Top, - End = r.Bottom, - Offset = r.Left - }); - break; - case ResizeDirection.Right: - list.Add(new Snapline() { - Kind = kind, - Side = side ?? SnaplineSide.Right, - Orientation = Orientation.Vertical, - Start = r.Top, - End = r.Bottom, - Offset = r.Right - }); - break; - } - } - - void TryAddBaseline(List list, Rect bounds, double? baseline) - { - if (baseline.HasValue) { - list.Add(new Snapline() { - Kind = SnaplineKind.Baseline, - Side = SnaplineSide.Any, - Orientation = Orientation.Horizontal, - Start = bounds.Left, - End = bounds.Right, - Offset = bounds.Top + baseline.Value - }); - } - } - - bool TrySnap(List input, out Vector delta) - { - double deltaX = 0; - double deltaY = 0; - var result = false; - delta = new Vector(); - - if (TrySnap(input, Orientation.Horizontal, out deltaY)) { - delta.Y = deltaY; - result = true; - } - if (TrySnap(input, Orientation.Vertical, out deltaX)) { - delta.X = deltaX; - result = true; - } - - return result; - } - - bool TrySnap(IEnumerable input, Orientation orient, out double delta) - { - delta = double.MaxValue; - - foreach (var inputLine in input) { - if (inputLine.Orientation == orient) { - foreach (var mapLine in map) { - if (mapLine.Orientation == orient && - (mapLine.Kind == inputLine.Kind || - mapLine.Kind == SnaplineKind.Margin && inputLine.Kind == SnaplineKind.Bounds) && - (mapLine.Side == SnaplineSide.Any || mapLine.Side == inputLine.Side)) { - - if (Math.Abs(mapLine.Offset - inputLine.Offset) <= Accuracy && - - (mapLine.Kind != SnaplineKind.Margin || - Math.Max(mapLine.Start, inputLine.Start) < Math.Min(mapLine.End, inputLine.End))) { - - var newDelta = mapLine.Offset - inputLine.Offset; - if (Math.Abs(newDelta) < Math.Abs(delta)) { - delta = newDelta; - } - } - } - } - } - } - - return delta != double.MaxValue; - } - - //TODO: GlyphRun must be used - static double? CalculateBaseline(FrameworkElement element) - { - var textBox = element.FindChild(); - if (textBox != null) { - var r = textBox.GetRectFromCharacterIndex(0).Bottom; - return textBox.TranslatePoint(new Point(0, r), element).Y; - } - var textBlock = element.FindChild(); - if (textBlock != null) - return textBlock.TranslatePoint(new Point(0, textBlock.BaselineOffset), element).Y; - - return null; - } - - class Snapline - { - public double Start; - public double End; - public double Offset; - public SnaplineKind Kind; - public SnaplineSide Side; - public Orientation Orientation; - } - - enum SnaplineKind - { - Bounds, - Margin, - Baseline - } - - enum SnaplineSide - { - Left, - Right, - Top, - Bottom, - Any - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/StackPanelContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/StackPanelContainer.cs deleted file mode 100644 index dead0f1855..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/StackPanelContainer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Diagnostics; -using System.Windows.Controls.Primitives; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class StackPanelContainer : PreviewContainer - { - public override Orientation GetOrientation(FrameworkElement parentView) - { - return (parentView as StackPanel).Orientation; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/WrapPanelContainer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/WrapPanelContainer.cs deleted file mode 100644 index abe08ae894..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Placement/WrapPanelContainer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; - -namespace SharpDevelop.XamlDesigner.Placement -{ - class WrapPanelContainer : PreviewContainer - { - public override Orientation GetOrientation(FrameworkElement parentView) - { - return (parentView as WrapPanel).Orientation; - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/AssemblyInfo.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/AssemblyInfo.cs deleted file mode 100644 index 35fc1aafdf..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Markup; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SharpDevelop.XamlDesigner")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Organization1")] -[assembly: AssemblyProduct("SharpDevelop.XamlDesigner")] -[assembly: AssemblyCopyright("Copyright © Organization1 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: XmlnsPrefix("http://sharpdevelop.net", "sd")] - -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.Commanding")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.Controls")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.Converters")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.Palette")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.Outline")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.PropertyGrid")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.PropertyGrid.Editors")] -[assembly: XmlnsDefinition("http://sharpdevelop.net", "SharpDevelop.XamlDesigner.PropertyGrid.Editors.BrushEditor")] diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Resources.Designer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Resources.Designer.cs deleted file mode 100644 index e5a47a251a..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Resources.Designer.cs +++ /dev/null @@ -1,70 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -namespace SharpDevelop.XamlDesigner.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDevelop.XamlDesigner.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Resources.resx b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Resources.resx deleted file mode 100644 index af7dbebbac..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Settings.Designer.cs b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Settings.Designer.cs deleted file mode 100644 index 926d1a4650..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -namespace SharpDevelop.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; - } - } - } -} diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Settings.settings b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9e..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/PropertyGrid/BindingDialog.xaml b/samples/XamlDesigner2/SharpDevelop.XamlDesigner/PropertyGrid/BindingDialog.xaml deleted file mode 100644 index f02a137b0f..0000000000 --- a/samples/XamlDesigner2/SharpDevelop.XamlDesigner/PropertyGrid/BindingDialog.xaml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - -