1111using Windows . UI . Popups ;
1212using Windows . UI . Xaml ;
1313using Windows . UI . Xaml . Controls ;
14+ using Windows . UI . Xaml . Controls . Primitives ;
15+ using Windows . UI . Xaml . Data ;
1416
1517// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
1618
@@ -22,19 +24,29 @@ namespace SharpFM.App
2224 public sealed partial class MainPage : Page
2325 {
2426 public ObservableCollection < FileMakerClip > Keys { get ; }
25- public ObservableCollection < FileMakerClip > Layouts
26- {
27- get
28- {
29- return new ObservableCollection < FileMakerClip > ( Keys . Where ( k => FileMakerClip . ClipTypes [ k . ClipboardFormat ] == "Layout" ) ) ;
30- }
31- }
27+
28+ public ObservableCollection < FileMakerClip > Layouts { get ; }
29+
30+ public FileMakerClip SelectedLayout { get ; set ; }
31+ public FileMakerClip SelectedClip { get ; set ; }
32+
33+ public string SelectedClipAsCsharp { get ; set ; }
3234
3335 public MainPage ( )
3436 {
3537 InitializeComponent ( ) ;
3638
3739 Keys = new ObservableCollection < FileMakerClip > ( ) ;
40+ Layouts = new ObservableCollection < FileMakerClip > ( ) ;
41+
42+ Keys . CollectionChanged += ( sender , e ) =>
43+ {
44+ Layouts . Clear ( ) ;
45+ foreach ( var layout in Keys . Where ( k => FileMakerClip . ClipTypes [ k . ClipboardFormat ] == "Layout" ) )
46+ {
47+ Layouts . Add ( layout ) ;
48+ }
49+ } ;
3850
3951 Clipboard . ContentChanged += Clipboard_ContentChanged ;
4052 }
@@ -120,12 +132,11 @@ private void masterNewScript_Click(object sender, RoutedEventArgs e)
120132 private async void asModelAppBarButton_Click ( object sender , RoutedEventArgs e )
121133 {
122134 // TODO: improve the UX of this whole thing. This works as a hack for proving the concept, but it could be so much better.
123-
124135 var data = mdv . SelectedItem as FileMakerClip ;
125136
126137 var md = new MessageDialog ( "Do you want to use a layout to limit the number of fields in the generated model?" , "Use Layout Projection?" ) ;
127138 // setup the command that will show the Layout picker and generate content that way
128- md . Commands . Add ( new UICommand ( "Pick a Layout" , new UICommandInvokedHandler ( async uic =>
139+ md . Commands . Add ( new UICommand ( "Use Layout" , new UICommandInvokedHandler ( async uic =>
129140 {
130141 var picker = new LayoutClipPicker
131142 {
@@ -135,7 +146,7 @@ private async void asModelAppBarButton_Click(object sender, RoutedEventArgs e)
135146 if ( pickerResult == ContentDialogResult . Primary )
136147 {
137148 // regenerate using the layout picker
138- var classString = data . CreateClass ( picker . DialogResult ) ;
149+ var classString = data . CreateClass ( SelectedLayout ) ;
139150 var dp = new DataPackage ( ) ;
140151 dp . SetText ( classString ) ;
141152 Clipboard . SetContent ( dp ) ;
@@ -155,5 +166,10 @@ private async void asModelAppBarButton_Click(object sender, RoutedEventArgs e)
155166
156167 var result = await md . ShowAsync ( ) ;
157168 }
169+
170+ //private void LayoutPickerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
171+ //{
172+ // SelectedLayout = ((ComboBox)sender).SelectedItem as FileMakerClip;
173+ //}
158174 }
159175}
0 commit comments