diff --git a/SharpFM.App/LayoutClipPicker.xaml b/SharpFM.App/LayoutClipPicker.xaml index 91efa4a..87f8e5f 100644 --- a/SharpFM.App/LayoutClipPicker.xaml +++ b/SharpFM.App/LayoutClipPicker.xaml @@ -13,6 +13,6 @@ SecondaryButtonClick="ContentDialog_SecondaryButtonClick"> - + diff --git a/SharpFM.App/MainPage.xaml b/SharpFM.App/MainPage.xaml index 9af5254..c3fe2f3 100644 --- a/SharpFM.App/MainPage.xaml +++ b/SharpFM.App/MainPage.xaml @@ -12,12 +12,22 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - + + + + + - + @@ -37,9 +47,12 @@ - + + + + @@ -88,5 +101,25 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpFM.App/MainPage.xaml.cs b/SharpFM.App/MainPage.xaml.cs index fb278b8..f408554 100644 --- a/SharpFM.App/MainPage.xaml.cs +++ b/SharpFM.App/MainPage.xaml.cs @@ -11,6 +11,8 @@ using Windows.UI.Popups; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 @@ -22,19 +24,29 @@ namespace SharpFM.App public sealed partial class MainPage : Page { public ObservableCollection Keys { get; } - public ObservableCollection Layouts - { - get - { - return new ObservableCollection(Keys.Where(k => FileMakerClip.ClipTypes[k.ClipboardFormat] == "Layout")); - } - } + + public ObservableCollection Layouts { get; } + + public FileMakerClip SelectedLayout { get; set; } + public FileMakerClip SelectedClip { get; set; } + + public string SelectedClipAsCsharp { get; set; } public MainPage() { InitializeComponent(); Keys = new ObservableCollection(); + Layouts = new ObservableCollection(); + + Keys.CollectionChanged += (sender, e) => + { + Layouts.Clear(); + foreach (var layout in Keys.Where(k => FileMakerClip.ClipTypes[k.ClipboardFormat] == "Layout")) + { + Layouts.Add(layout); + } + }; Clipboard.ContentChanged += Clipboard_ContentChanged; } @@ -120,12 +132,11 @@ private void masterNewScript_Click(object sender, RoutedEventArgs e) private async void asModelAppBarButton_Click(object sender, RoutedEventArgs e) { // TODO: improve the UX of this whole thing. This works as a hack for proving the concept, but it could be so much better. - var data = mdv.SelectedItem as FileMakerClip; var md = new MessageDialog("Do you want to use a layout to limit the number of fields in the generated model?", "Use Layout Projection?"); // setup the command that will show the Layout picker and generate content that way - md.Commands.Add(new UICommand("Pick a Layout", new UICommandInvokedHandler(async uic => + md.Commands.Add(new UICommand("Use Layout", new UICommandInvokedHandler(async uic => { var picker = new LayoutClipPicker { @@ -135,7 +146,7 @@ private async void asModelAppBarButton_Click(object sender, RoutedEventArgs e) if (pickerResult == ContentDialogResult.Primary) { // regenerate using the layout picker - var classString = data.CreateClass(picker.DialogResult); + var classString = data.CreateClass(SelectedLayout); var dp = new DataPackage(); dp.SetText(classString); Clipboard.SetContent(dp); @@ -155,5 +166,10 @@ private async void asModelAppBarButton_Click(object sender, RoutedEventArgs e) var result = await md.ShowAsync(); } + + //private void LayoutPickerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + //{ + // SelectedLayout = ((ComboBox)sender).SelectedItem as FileMakerClip; + //} } } \ No newline at end of file diff --git a/SharpFM.Core/FileMakerClip.cs b/SharpFM.Core/FileMakerClip.cs index ff98f21..b74d46c 100644 --- a/SharpFM.Core/FileMakerClip.cs +++ b/SharpFM.Core/FileMakerClip.cs @@ -77,8 +77,6 @@ public byte[] RawData /// public string XmlData { get; set; } - - /// /// The fields exposed through this FileMaker Clip (if its a table or a layout). /// diff --git a/SharpFM.Core/FileMakerClipExtensions.cs b/SharpFM.Core/FileMakerClipExtensions.cs index a517c64..4cd15a9 100644 --- a/SharpFM.Core/FileMakerClipExtensions.cs +++ b/SharpFM.Core/FileMakerClipExtensions.cs @@ -14,6 +14,8 @@ public static class FileMakerClipExtensions /// public static string CreateClass(this FileMakerClip _clip, FileMakerClip fieldProjectionLayout = null) { + if(_clip == null) { return string.Empty; } + var fieldProjectionList = new List(); if (fieldProjectionLayout != null && FileMakerClip.ClipTypes[fieldProjectionLayout.ClipboardFormat] == "Layout") {