From 2c39a1ef8c13bd8d0321f79b0ce2850d0a590b45 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 27 Jun 2012 22:49:23 +0000 Subject: Done Save, Load and Delete dialogs. --- .../SaveDialog.xaml.cs | 70 +++++++++++++++++----- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs') diff --git a/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs b/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs index 8df7b73..8d8e515 100644 --- a/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs +++ b/Noddybox.WindowsPhone.Silverlight/SaveDialog.xaml.cs @@ -62,16 +62,46 @@ namespace Noddybox.WindowsPhone.Silverlight #region Properties + private static void OnDummyDependency(DependencyObject d, DependencyPropertyChangedEventArgs e) {} + public static readonly DependencyProperty StartPathProperty = - DependencyProperty.Register("StartPath", typeof(string), typeof(SaveDialog), null); - // new PropertyMetadata("StartPath", new PropertyChangedCallback(SaveDialog.OnStartPathChanged))); + DependencyProperty.Register("StartPath", typeof(string), typeof(SaveDialog), + new PropertyMetadata("StartPath", new PropertyChangedCallback(SaveDialog.OnDummyDependency))); public static readonly DependencyProperty OkButtonTextProperty = - DependencyProperty.Register("OkButtonText", typeof(string), typeof(SaveDialog), null); - // new PropertyMetadata("StartPath", new PropertyChangedCallback(SaveDialog.OnStartPathChanged))); + DependencyProperty.Register("OkButtonText", typeof(string), typeof(SaveDialog), + new PropertyMetadata("OkButtonText", new PropertyChangedCallback(SaveDialog.OnDummyDependency))); + + public static readonly DependencyProperty TitleTextProperty = + DependencyProperty.Register("TitleText", typeof(string), typeof(SaveDialog), + new PropertyMetadata("TitleText", new PropertyChangedCallback(SaveDialog.OnDummyDependency))); + + public static readonly DependencyProperty FileMaskProperty = + DependencyProperty.Register("FileMask", typeof(string), typeof(SaveDialog), + new PropertyMetadata("FileMask", new PropertyChangedCallback(SaveDialog.OnDummyDependency))); + + public delegate void FileDialogEventHandler(object sender, FileDialogEvent e); + + /// + /// Event for users to subscribe to the pressing of the OK button. + /// + public event FileDialogEventHandler OkPressed; - private static void OnStartPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + /// + /// Set the file mask. + /// + public string FileMask { + get {return (string)GetValue(FileMaskProperty);} + set + { + SetValue(FileMaskProperty, value); + + if (!DesignerProperties.IsInDesignTool) + { + model.Mask = value; + } + } } /// @@ -79,8 +109,11 @@ namespace Noddybox.WindowsPhone.Silverlight /// public string StartPath { - set + get {return (string)GetValue(StartPathProperty);} + set { + SetValue(StartPathProperty, value); + if (!DesignerProperties.IsInDesignTool) { model.Path = value; @@ -93,17 +126,25 @@ namespace Noddybox.WindowsPhone.Silverlight /// public string OkButtonText { - set + get {return (string)GetValue(OkButtonTextProperty);} + set { + SetValue(OkButtonTextProperty, value); + okButton.Content = value; } } /// - /// Set the contents of the Cancel button. + /// Set the contents of the Title bar. /// - public string CancelButtonText + public string TitleText { - set {cancelButton.Content = value;} + get {return (string)GetValue(TitleTextProperty);} + set + { + SetValue(TitleTextProperty, value); + titleText.Text = value; + } } #endregion @@ -112,15 +153,16 @@ namespace Noddybox.WindowsPhone.Silverlight private void OnFilenameKeyUp(object sender, KeyEventArgs e) { + fileList.SelectedItem = null; model.Filename = fileName.Text; } private void OnOKButton(object sender, RoutedEventArgs e) { - } - - private void OnCancelButton(object sender, RoutedEventArgs e) - { + if (OkPressed != null) + { + OkPressed(this, new FileDialogEvent() {Path = model.SelectedFile}); + } } private void OnFileListSelection(object sender, SelectionChangedEventArgs e) -- cgit v1.2.3