diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml index 3abca2a889..ac7cbc8a10 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml @@ -68,7 +68,11 @@ + + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/App.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/App.xaml.cs new file mode 100644 index 0000000000..12ea48806c --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/App.xaml.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Windows; +using ICSharpCode.XamlDesigner.Configuration; +using System.Windows.Threading; +using System.Diagnostics; + +namespace ICSharpCode.XamlDesigner +{ + public partial class App + { + public static string[] Args; + + protected override void OnStartup(StartupEventArgs e) + { + DispatcherUnhandledException += App_DispatcherUnhandledException; + Args = e.Args; + System.Windows.Forms.Application.EnableVisualStyles(); + base.OnStartup(e); + } + + void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) + { + Shell.ReportException(e.Exception); + e.Handled = true; + } + + protected override void OnExit(ExitEventArgs e) + { + Settings.Default.Save(); + base.OnExit(e); + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml new file mode 100644 index 0000000000..7c1a28bd96 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml @@ -0,0 +1,32 @@ + diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml.cs new file mode 100644 index 0000000000..4200c1bc9d --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml.cs @@ -0,0 +1,45 @@ +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 ICSharpCode.XamlDesigner +{ + public partial class BitmapButton + { + public BitmapButton() + { + InitializeComponent(); + DataContext = this; + } + + public string ImageHover { + get { return "Images/" + GetType().Name + ".Hover.png"; } + } + + public string ImageNormal { + get { return "Images/" + GetType().Name + ".Normal.png"; } + } + + public string ImagePressed { + get { return "Images/" + GetType().Name + ".Pressed.png"; } + } + + public string ImageDisabled { + get { return "Images/" + GetType().Name + ".Disabled.png"; } + } + } + + class CloseButton : BitmapButton + { + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..651ee86e68 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 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("XamlDesigner")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +//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) +)] diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.Designer.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.Designer.cs new file mode 100644 index 0000000000..9a835b8cf5 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.Designer.cs @@ -0,0 +1,110 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3031 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ICSharpCode.XamlDesigner.Configuration { + + + [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()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + + + + + + + + + + + + + + + + + + + + +")] + public string AvalonDockLayout { + get { + return ((string)(this["AvalonDockLayout"])); + } + set { + this["AvalonDockLayout"] = 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; + } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.settings b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.settings new file mode 100644 index 0000000000..65e359e302 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.settings @@ -0,0 +1,46 @@ + + + + + + 0,0,0,0 + + + <DockingManager> + <ResizingPanel Orientation="Horizontal"> + <ResizingPanel ResizeWidth="200" Orientation="Vertical"> + <DockablePane ResizeHeight="441.36166666666668" Anchor="Left"> + <DockableContent Name="content1" AutoHide="false" /> + </DockablePane> + <DockablePane ResizeWidth="200" Anchor="Left"> + <DockableContent Name="content2" AutoHide="false" /> + </DockablePane> + </ResizingPanel> + <ResizingPanel Orientation="Vertical"> + <DocumentPanePlaceHolder /> + <DockablePane ResizeHeight="138" Anchor="Bottom"> + <DockableContent Name="content3" AutoHide="false" /> + </DockablePane> + </ResizingPanel> + <DockablePane ResizeWidth="271" Anchor="Right"> + <DockableContent Name="content4" AutoHide="false" /> + </DockablePane> + </ResizingPanel> + <Hidden /> + <Windows /> +</DockingManager> + + + + + + <?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/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.config b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.config new file mode 100644 index 0000000000..c49779f8d1 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.config @@ -0,0 +1,51 @@ + + + + +
+ + + + + + 0,0,0,0 + + + <DockingManager> + <ResizingPanel Orientation="Horizontal"> + <ResizingPanel ResizeWidth="200" Orientation="Vertical"> + <DockablePane ResizeHeight="441.36166666666668" Anchor="Left"> + <DockableContent Name="content1" AutoHide="false" /> + </DockablePane> + <DockablePane ResizeWidth="200" Anchor="Left"> + <DockableContent Name="content2" AutoHide="false" /> + </DockablePane> + </ResizingPanel> + <ResizingPanel Orientation="Vertical"> + <DocumentPanePlaceHolder /> + <DockablePane ResizeHeight="138" Anchor="Bottom"> + <DockableContent Name="content3" AutoHide="false" /> + </DockablePane> + </ResizingPanel> + <DockablePane ResizeWidth="271" Anchor="Right"> + <DockableContent Name="content4" AutoHide="false" /> + </DockablePane> + </ResizingPanel> + <Hidden /> + <Windows /> +</DockingManager> + + + + + %ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll + + + + + Maximized + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.manifest b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.manifest new file mode 100644 index 0000000000..e82a10f183 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.manifest @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Converters.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Converters.cs new file mode 100644 index 0000000000..3590603bf4 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Converters.cs @@ -0,0 +1,53 @@ +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 ICSharpCode.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(); + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Document.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Document.cs new file mode 100644 index 0000000000..5c1da59c5b --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Document.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.IO; +using ICSharpCode.WpfDesign.Designer; +using ICSharpCode.WpfDesign.Designer.Xaml; +using System.Xml; +using ICSharpCode.WpfDesign; +using ICSharpCode.WpfDesign.Designer.Services; +using System.Diagnostics; + +namespace ICSharpCode.XamlDesigner +{ + public class Document : INotifyPropertyChanged + { + public Document(string tempName, string text) + { + this.tempName = tempName; + Text = text; + IsDirty = false; + } + + public Document(string filePath) + { + this.filePath = filePath; + ReloadFile(); + } + + string tempName; + DesignSurface designSurface = new DesignSurface(); + + string text; + + public string Text { + get { + return text; + } + set { + if (text != value) { + text = value; + IsDirty = true; + RaisePropertyChanged("Text"); + } + } + } + + DocumentMode mode; + + void SetMode(DocumentMode newMode) + { + mode = newMode; + if (IsDesign) { + UpdateDesign(); + } + else { + UpdateXaml(); + } + RaisePropertyChanged("IsXaml"); + RaisePropertyChanged("IsDesign"); + RaisePropertyChanged("SelectionService"); + } + + public bool IsXaml { + get { return mode == DocumentMode.Xaml; } + set { if (value) SetMode(DocumentMode.Xaml); } + } + + public bool IsDesign { + get { return mode == DocumentMode.Design; } + set { if (value) SetMode(DocumentMode.Design); } + } + + string filePath; + + public string FilePath { + get { + return filePath; + } + private set { + filePath = value; + RaisePropertyChanged("FilePath"); + RaisePropertyChanged("FileName"); + RaisePropertyChanged("Title"); + RaisePropertyChanged("Name"); + } + } + + bool isDirty; + + public bool IsDirty { + get { + return isDirty; + } + private set { + isDirty = value; + RaisePropertyChanged("IsDirty"); + RaisePropertyChanged("Name"); + RaisePropertyChanged("Title"); + } + } + + public string FileName { + get { + if (FilePath == null) return null; + return Path.GetFileName(FilePath); + } + } + + public string Name { + get { + return FileName ?? tempName; + } + } + + public string Title { + get { + return IsDirty ? Name + "*" : Name; + } + } + + public DesignSurface DesignSurface { + get { return designSurface; } + } + + public DesignContext DesignContext { + get { return designSurface.DesignContext; } + } + + public UndoService UndoService { + get { return DesignContext.Services.GetService(); } + } + + public ISelectionService SelectionService { + get { + if (IsDesign && DesignContext != null) { + return DesignContext.Services.Selection; + } + return null; + } + } + + void ReloadFile() + { + Text = File.ReadAllText(FilePath); + UpdateDesign(); + IsDirty = false; + } + + public void Save() + { + if (IsDesign) { + UpdateXaml(); + } + File.WriteAllText(FilePath, Text); + IsDirty = false; + } + + public void SaveAs(string filePath) + { + FilePath = filePath; + Save(); + } + + void UpdateXaml() + { + var sb = new StringBuilder(); + using (var xmlWriter = XmlWriter.Create(sb)) { + try { + DesignSurface.SaveDesigner(xmlWriter); + Text = XamlFormatter.Format(sb.ToString()); + } + catch (Exception x) { + Shell.ReportException(x); + } + } + } + + void UpdateDesign() + { + try { + XamlLoadSettings settings = new XamlLoadSettings(); + using (var xmlReader = XmlReader.Create(new StringReader(Text))) { + DesignSurface.LoadDesigner(xmlReader, settings); + } + UndoService.UndoStackChanged += delegate { IsDirty = true; }; + } + catch (Exception x) { + Shell.ReportException(x); + } + } + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + void RaisePropertyChanged(string name) + { + if (PropertyChanged != null) { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + + #endregion + + enum DocumentMode + { + Xaml, Design + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml new file mode 100644 index 0000000000..c2fc424bea --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml.cs new file mode 100644 index 0000000000..f567d7347d --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml.cs @@ -0,0 +1,26 @@ +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 ICSharpCode.XamlDesigner +{ + public partial class DocumentView + { + public DocumentView(Document doc) + { + InitializeComponent(); + uxTextEditor.SetHighlighting("XML"); + uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged); + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DragListener.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DragListener.cs new file mode 100644 index 0000000000..e2d3cec7c9 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DragListener.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Input; + +namespace ICSharpCode.XamlDesigner +{ + class DragListener + { + public DragListener(IInputElement target) + { + this.target = target; + target.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(target_PreviewMouseLeftButtonDown); + target.PreviewMouseMove += new MouseEventHandler(target_PreviewMouseMove); + } + + public event MouseEventHandler DragStarted; + + IInputElement target; + Window window; + Point startPoint; + bool readyToRaise; + + Point GetMousePosition() + { + if (window == null) { + window = Window.GetWindow(target as DependencyObject); + } + return Mouse.GetPosition(window); + } + + bool IsMovementBigEnough() + { + Point currentPoint = GetMousePosition(); + return (Math.Abs(currentPoint.X - startPoint.X) >= SystemParameters.MinimumHorizontalDragDistance || + Math.Abs(currentPoint.Y - startPoint.Y) >= SystemParameters.MinimumVerticalDragDistance); + } + + void target_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + readyToRaise = true; + startPoint = GetMousePosition(); + } + + void target_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (readyToRaise && IsMovementBigEnough()) { + readyToRaise = false; + if (DragStarted != null) { + DragStarted(target, e); + } + } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/ExtensionMethods.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/ExtensionMethods.cs new file mode 100644 index 0000000000..4c9a1dd358 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/ExtensionMethods.cs @@ -0,0 +1,93 @@ +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 ICSharpCode.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 T FindAncestor(this DependencyObject d) where T : class + { + while (true) { + if (d == null) return null; + if (d is T) return d as T; + d = VisualTreeHelper.GetParent(d); + } + } + + 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/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Reference.png b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Reference.png new file mode 100644 index 0000000000..da47049481 Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Reference.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Tag.png b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Tag.png new file mode 100644 index 0000000000..b7686f106b Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Tag.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/AvalonDock.dll b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/AvalonDock.dll new file mode 100644 index 0000000000..15ca4dce3b Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/AvalonDock.dll differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/ICSharpCode.TextEditor.dll b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/ICSharpCode.TextEditor.dll new file mode 100644 index 0000000000..04f11701e9 Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/ICSharpCode.TextEditor.dll differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml new file mode 100644 index 0000000000..3fda7bd62e --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml.cs new file mode 100644 index 0000000000..67c68bb513 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml.cs @@ -0,0 +1,181 @@ +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 ICSharpCode.XamlDesigner.Configuration; +using System.ComponentModel; +using Microsoft.Win32; +using AvalonDock; +using System.IO; +using System.Collections.Specialized; + +namespace ICSharpCode.XamlDesigner +{ + public partial class MainWindow + { + public MainWindow() + { + RenameCommands(); + + Instance = this; + DataContext = Shell.Instance; + InitializeComponent(); + + Shell.Instance.PropertyGrid = uxPropertyGridView.PropertyGrid; + AvalonDockWorkaround(); + LoadSettings(); + ProcessPaths(App.Args); + } + + public static MainWindow Instance; + + OpenFileDialog openFileDialog; + SaveFileDialog saveFileDialog; + + 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()); + } + + protected override void OnClosing(CancelEventArgs e) + { + if (Shell.Instance.PrepareExit()) { + SaveSettings(); + } + else { + e.Cancel = true; + } + base.OnClosing(e); + } + + void RecentFiles_Click(object sender, RoutedEventArgs e) + { + var path = (string)(e.OriginalSource as MenuItem).Header; + Shell.Instance.Open(path); + } + + 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; + } + else if (path.EndsWith(".xaml", 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)) { + Toolbox.Instance.AddAssembly(path); + } + else if (path.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) { + Shell.Instance.Open(path); + } + } + } + + 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 (Settings.Default.AvalonDockLayout != null) { + uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream()); + } + } + + 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(); + + Shell.Instance.SaveSettings(); + } + + #region AvalonDockWorkaround + + void AvalonDockWorkaround() + { + uxDocumentPane.Items.KeepSyncronizedWith(Shell.Instance.Documents, d => CreateContentFor(d)); + } + + DocumentContent CreateContentFor(Document doc) + { + var content = new DocumentContent() { + DataContext = doc, + Content = new DocumentView(doc) + }; + content.SetBinding(DocumentContent.TitleProperty, "Title"); + return content; + } + + #endregion + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow_Commands.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow_Commands.cs new file mode 100644 index 0000000000..26ebe8c10b --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow_Commands.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace ICSharpCode.XamlDesigner +{ + public partial class MainWindow + { + public static SimpleCommand CloseAllCommand = new SimpleCommand("Close All"); + public static SimpleCommand SaveAllCommand = new SimpleCommand("Save All", ModifierKeys.Control | ModifierKeys.Shift, Key.S); + public static SimpleCommand ExitCommand = new SimpleCommand("Exit"); + + static void RenameCommands() + { + ApplicationCommands.Open.Text = "Open..."; + ApplicationCommands.SaveAs.Text = "Save As..."; + } + + void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.New(); + } + + void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.Open(); + } + + void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.CloseCurrentDocument(); + } + + void CloseCommand_PreviewExecuted(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.CloseCurrentDocument(); + } + + void CloseAllCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.CloseAll(); + } + + void SaveCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.SaveCurrentDocument(); + } + + void SaveAsCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.SaveCurrentDocumentAs(); + } + + void SaveAllCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.SaveAll(); + } + + void ExitCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + Shell.Instance.Exit(); + } + + void CurrentDocument_CanExecute(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = Shell.Instance.CurrentDocument != null; + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/NewFileTemplate.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/NewFileTemplate.xaml new file mode 100644 index 0000000000..1734c1d49d --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/NewFileTemplate.xaml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml new file mode 100644 index 0000000000..4f82d8f516 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml.cs new file mode 100644 index 0000000000..f7186ac275 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml.cs @@ -0,0 +1,24 @@ +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 ICSharpCode.XamlDesigner +{ + public partial class Outline + { + public Outline() + { + InitializeComponent(); + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/OutlineTree.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/OutlineTree.cs new file mode 100644 index 0000000000..806cd34aa6 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/OutlineTree.cs @@ -0,0 +1,267 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Controls; +using System.Windows; +using System.Collections.ObjectModel; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Controls.Primitives; + +namespace ICSharpCode.XamlDesigner +{ + public class OutlineTree : TreeView + { + public OutlineTree() + { + AllowDrop = true; + new DragListener(this).DragStarted += new MouseEventHandler(TreeList_DragStarted); + DragEnter += new DragEventHandler(TreeList_DragEnter); + DragOver += new DragEventHandler(TreeList_DragOver); + Drop += new DragEventHandler(TreeList_Drop); + + //Selection = new ObservableCollection(); + } + + Border insertLine; + OutlineTreeItem markedItem; + OutlineTreeItem possibleSelection; + List selectionNodes = new List(); + + public static readonly DependencyProperty SelectionProperty = + DependencyProperty.Register("Selection", typeof(ObservableCollection), typeof(OutlineTree)); + + public ObservableCollection Selection { + get { return (ObservableCollection)GetValue(SelectionProperty); } + set { SetValue(SelectionProperty, value); } + } + + protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) + { + base.OnPropertyChanged(e); + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + insertLine = (Border)Template.FindName("PART_InsertLine", this); + } + + protected override DependencyObject GetContainerForItemOverride() + { + return new OutlineTreeItem(); + } + + protected override bool IsItemItsOwnContainerOverride(object item) + { + return item is OutlineTreeItem; + } + + protected virtual DragDropEffects CanDrag(object obj) + { + return DragDropEffects.Move; + } + + protected virtual DragDropEffects CanDrop(object obj, object parent, int index) + { + return DragDropEffects.Move; + } + + void TreeList_DragOver(object sender, DragEventArgs e) + { + ProcessDrag(e); + } + + void TreeList_DragEnter(object sender, DragEventArgs e) + { + ProcessDrag(e); + } + + void TreeList_Drop(object sender, DragEventArgs e) + { + ProcessDrop(e); + } + + protected override void OnDragLeave(DragEventArgs e) + { + HideDropMarkers(); + } + + void TreeList_DragStarted(object sender, MouseEventArgs e) + { + possibleSelection = null; + object obj = (e.OriginalSource as FrameworkElement).DataContext; + if (obj != null) { + DragDropEffects effects = CanDrag(obj); + if (effects != DragDropEffects.None) { + DragDrop.DoDragDrop(this, obj, effects); + } + } + } + + void ProcessDrag(DragEventArgs e) + { + e.Effects = DragDropEffects.Move; + e.Handled = true; + + OutlineTreeItem treeItem = (e.OriginalSource as DependencyObject).FindAncestor(); + if (treeItem != null) { + HideDropMarkers(); + + ContentPresenter header = treeItem.HeaderPresenter; + Point p = e.GetPosition(header); + int part = (int)(p.Y / (header.ActualHeight / 3)); + + if (part == 1) { + markedItem = treeItem; + markedItem.Background = insertLine.Background; + } + else { + insertLine.Visibility = Visibility.Visible; + p = header.TransformToVisual(this).Transform(new Point()); + double y = part == 0 ? p.Y : p.Y + header.ActualHeight; + insertLine.Margin = new Thickness(0, y, 0, 0); + } + } + } + + void ProcessDrop(DragEventArgs e) + { + HideDropMarkers(); + } + + void HideDropMarkers() + { + insertLine.Visibility = Visibility.Collapsed; + if (markedItem != null) { + markedItem.ClearValue(OutlineTreeItem.BackgroundProperty); + } + } + + void Select(OutlineTreeItem item) + { + item.IsSelected = true; + Selection.Add(item.Element); + selectionNodes.Add(item); + } + + void SelectOnly(OutlineTreeItem item) + { + foreach (var node in selectionNodes) { + node.IsSelected = false; + } + Selection.Clear(); + Select(item); + } + + void Unselect(OutlineTreeItem item) + { + item.IsSelected = false; + Selection.Remove(item.Element); + selectionNodes.Remove(item); + } + + internal void HandleItemMouseDown(OutlineTreeItem item) + { + bool control = Keyboard.IsKeyDown(Key.LeftCtrl); + if (item.IsSelected) { + if (control) { + Unselect(item); + } + else { + possibleSelection = item; + } + } + else { + if (control) { + Select(item); + } + else { + SelectOnly(item); + } + } + } + + internal void HandleItemMouseUp(OutlineTreeItem item) + { + if (possibleSelection != null) { + SelectOnly(possibleSelection); + } + } + } + + public class OutlineTreeItem : TreeViewItem + { + public new static readonly DependencyProperty IsSelectedProperty = + Selector.IsSelectedProperty.AddOwner(typeof(OutlineTreeItem)); + + public new bool IsSelected { + get { return (bool)GetValue(IsSelectedProperty); } + set { SetValue(IsSelectedProperty, value); } + } + + public ContentPresenter HeaderPresenter { + get { return (ContentPresenter)Template.FindName("PART_Header", this); } + } + + public DocumentElement Element { + get { return DataContext as DocumentElement; } + } + + public static readonly DependencyProperty IndentProperty = + DependencyProperty.Register("Indent", typeof(Thickness), typeof(OutlineTreeItem)); + + public Thickness Indent { + get { return (Thickness)GetValue(IndentProperty); } + set { SetValue(IndentProperty, value); } + } + + protected override void OnVisualParentChanged(DependencyObject oldParent) + { + base.OnVisualParentChanged(oldParent); + OutlineTreeItem parent = ItemsControl.ItemsControlFromItemContainer(this) as OutlineTreeItem; + Indent = parent == null ? new Thickness() : new Thickness(parent.Indent.Left + 19, 0, 0, 0); + } + + protected override DependencyObject GetContainerForItemOverride() + { + return new OutlineTreeItem(); + } + + protected override bool IsItemItsOwnContainerOverride(object item) + { + return item is OutlineTreeItem; + } + + protected override void OnPreviewMouseDown(MouseButtonEventArgs e) + { + if (e.Source is ToggleButton || e.Source is ItemsPresenter) return; + + OutlineTree tree = this.FindAncestor(); + if (tree != null) { + tree.HandleItemMouseDown(this); + e.Handled = true; + } + } + + protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) + { + OutlineTree tree = this.FindAncestor(); + if (tree != null) { + tree.HandleItemMouseUp(this); + } + } + } + + public class TreeNode : ContentControl + { + public static readonly DependencyProperty ImageProperty = + DependencyProperty.Register("Image", typeof(ImageSource), typeof(TreeNode)); + + public ImageSource Image { + get { return (ImageSource)GetValue(ImageProperty); } + set { SetValue(ImageProperty, value); } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Shell.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Shell.cs new file mode 100644 index 0000000000..c3962563f1 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Shell.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.Collections.ObjectModel; +using ICSharpCode.WpfDesign.Designer.PropertyGrid; +using ICSharpCode.XamlDesigner.Configuration; +using System.Collections.Specialized; +using System.IO; +using System.Windows; +using System.Diagnostics; + +namespace ICSharpCode.XamlDesigner +{ + public class Shell : INotifyPropertyChanged + { + public Shell() + { + Documents = new ObservableCollection(); + RecentFiles = new ObservableCollection(); + LoadSettings(); + } + + public static Shell Instance = new Shell(); + public const string ApplicationTitle = "Xaml Designer"; + + //public Toolbox Toolbox { get; set; } + //public SceneTree SceneTree { get; set; } + public PropertyGrid PropertyGrid { get; internal set; } + //public ErrorList ErrorList { get; set; } + + public ObservableCollection Documents { get; private set; } + public ObservableCollection RecentFiles { get; private set; } + + Document currentDocument; + + public Document CurrentDocument { + get { + return currentDocument; + } + set { + currentDocument = value; + RaisePropertyChanged("CurrentDocument"); + RaisePropertyChanged("Title"); + } + } + + public string Title { + get { + if (CurrentDocument != null) { + return CurrentDocument.Title + " - " + ApplicationTitle; + } + return ApplicationTitle; + } + } + + void LoadSettings() + { + if (Settings.Default.RecentFiles != null) { + RecentFiles.AddRange(Settings.Default.RecentFiles.Cast()); + } + } + + public void SaveSettings() + { + if (Settings.Default.RecentFiles == null) { + Settings.Default.RecentFiles = new StringCollection(); + } + else { + Settings.Default.RecentFiles.Clear(); + } + foreach (var f in RecentFiles) { + Settings.Default.RecentFiles.Add(f); + } + } + + public static void ReportException(Exception x) + { + MessageBox.Show(x.ToString()); + } + + #region Files + + bool IsSomethingDirty { + get { + foreach (var doc in Shell.Instance.Documents) { + if (doc.IsDirty) return true; + } + return false; + } + } + + static int nonameIndex = 1; + + public void New() + { + Document doc = new Document("New" + nonameIndex++, File.ReadAllText("NewFileTemplate.xaml")); + Documents.Add(doc); + CurrentDocument = doc; + } + + public void Open() + { + var path = MainWindow.Instance.AskOpenFileName(); + if (path != null) { + Open(path); + } + } + + public void Open(string path) + { + path = Path.GetFullPath(path); + + if (RecentFiles.Contains(path)) { + RecentFiles.Remove(path); + } + RecentFiles.Insert(0, path); + + foreach (var doc in Documents) { + if (doc.FilePath == path) { + CurrentDocument = doc; + return; + } + } + + var newDoc = new Document(path); + Documents.Add(newDoc); + CurrentDocument = newDoc; + } + + public bool Save(Document doc) + { + if (doc.IsDirty) { + if (doc.FilePath == null) { + return SaveAs(doc); + } + doc.Save(); + } + return true; + } + + public bool SaveAs(Document doc) + { + var initName = doc.FileName ?? doc.Name + ".xaml"; + var path = MainWindow.Instance.AskSaveFileName(initName); + if (path != null) { + doc.SaveAs(path); + return true; + } + return false; + } + + public bool SaveAll() + { + foreach (var doc in Documents) { + if (!Save(doc)) return false; + } + return true; + } + + public bool Close(Document doc) + { + if (doc.IsDirty) { + var result = MessageBox.Show("Save \"" + doc.Name + "\" ?", Shell.ApplicationTitle, + MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); + + if (result == MessageBoxResult.Yes) { + if (!Save(doc)) return false; + } + else if (result == MessageBoxResult.Cancel) { + return false; + } + } + Documents.Remove(doc); + return true; + } + + public bool CloseAll() + { + foreach (var doc in Documents) { + if (!Close(doc)) return false; + } + return true; + } + + public bool PrepareExit() + { + if (IsSomethingDirty) { + var result = MessageBox.Show("Save All?", Shell.ApplicationTitle, + MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); + + if (result == MessageBoxResult.Yes) { + if (!SaveAll()) return false; + } + else if (result == MessageBoxResult.Cancel) { + return false; + } + } + return true; + } + + public void Exit() + { + MainWindow.Instance.Close(); + } + + public void SaveCurrentDocument() + { + Save(CurrentDocument); + } + + public void SaveCurrentDocumentAs() + { + SaveAs(CurrentDocument); + } + + public void CloseCurrentDocument() + { + Close(CurrentDocument); + } + + #endregion + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + void RaisePropertyChanged(string name) + { + if (PropertyChanged != null) { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + + #endregion + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/SimpleCommand.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/SimpleCommand.cs new file mode 100644 index 0000000000..3daea1f5f0 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/SimpleCommand.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace ICSharpCode.XamlDesigner +{ + public class SimpleCommand : RoutedUICommand + { + public SimpleCommand(string text) + { + Text = text; + } + + public SimpleCommand(string text, ModifierKeys modifiers, Key key) + { + InputGestures.Add(new KeyGesture(key, modifiers)); + Text = text; + } + + public SimpleCommand(string text, Key key) + : this(text, ModifierKeys.None, key) + { + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/TestFiles/1.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/TestFiles/1.xaml new file mode 100644 index 0000000000..cca7754177 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/TestFiles/1.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/TestFiles/2.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/TestFiles/2.xaml new file mode 100644 index 0000000000..920dc86a5d --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/TestFiles/2.xaml @@ -0,0 +1,41 @@ + + +