Пример #1
0
        /// <summary>
        /// Load inking preference from file. A new one will be created none is loaded.
        /// This method will also create drawing attributes to be used by ink canvas.
        /// </summary>
        /// <returns></returns>
        public static async Task <InkingPreference> LoadDrawingPreference()
        {
            // Check drawing preference file
            AppEventSource.Log.Debug("ViewerPage: Checking previously saved drawing preference...");
            StorageFile file = await SuspensionManager.GetSavedFileAsync(INKING_PREFERENCE_FILENAME);

            InkingPreference inkingPreference = await
                                                SuspensionManager.DeserializeFromFileAsync(typeof(InkingPreference), file) as InkingPreference;

            // Discard the inking preference if it is not the current version
            if (inkingPreference != null && inkingPreference.version != InkingPreference.CURRENT_INKING_PREF_VERSION)
            {
                inkingPreference = null;
            }
            // Create drawing preference file if one was not loaded.
            if (inkingPreference == null)
            {
                AppEventSource.Log.Debug("ViewerPage: No saved drawing preference loaded. Creating a new one...");
                inkingPreference = new InkingPreference();
                await inkingPreference.SaveAsync();
            }
            return(inkingPreference);
        }
        public InkingPrefContentDialog(InkingPreference inkingPref)
        {
            this.InitializeComponent();
            this.MaxWidth = Window.Current.Bounds.Width;
            this._inkingPreference = inkingPref;

            // Assign values from inkingPref
            //this.penSizeLabel.Text = "Pen size: " + this.InkingPreference.penSize.ToString();
            this.penSizeSlider.Value = this.InkingPreference.penSize;
            this.penSizeEllipse.Fill = new SolidColorBrush(this.InkingPreference.penColor);
            this.penSizeEllipse.Height = this.InkingPreference.penSize;
            this.penSizeEllipse.Width = this.InkingPreference.penSize;

            this.highlighterSizeSlider.Value = this.InkingPreference.highlighterSize;
            this.highlighterSizeRectangle.Fill = new SolidColorBrush(this.InkingPreference.highlighterColor);
            this.highlighterSizeRectangle.Height = this.InkingPreference.highlighterSize;
            this.highlighterSizeRectangle.Width = this.InkingPreference.highlighterSize;

            // Binding colors to ListBox
            this.highlighterColors = this.penColors;
            this.penColorListBox.DataContext = this.penColors;
            this.highlighterColorListBox.DataContext = this.highlighterColors;
        }
Пример #3
0
        /// <summary>
        /// Load inking preference from file. A new one will be created none is loaded.
        /// This method will also create drawing attributes to be used by ink canvas.
        /// </summary>
        /// <returns></returns>
        private async Task LoadDrawingPreference()
        {
            // Check drawing preference file
            AppEventSource.Log.Debug("ViewerPage: Checking previously saved drawing preference...");
            StorageFile file = await SuspensionManager.GetSavedFileAsync(INKING_PREFERENCE_FILENAME);
            this.inkingPreference = await
                SuspensionManager.DeserializeFromFileAsync(typeof(InkingPreference), file) as InkingPreference;
            // Discard the inking preference if it is not the current version
            if (this.inkingPreference != null && this.inkingPreference.version != InkingPreference.CURRENT_INKING_PREF_VERSION)
                this.inkingPreference = null;
            // Create drawing preference file if one was not loaded.
            if (this.inkingPreference == null)
            {
                AppEventSource.Log.Debug("ViewerPage: No saved drawing preference loaded. Creating a new one...");
                this.inkingPreference = new InkingPreference();
                await SaveDrawingPreference();
            }
            // Drawing preference
            this.drawingAttributes = new InkDrawingAttributes();
            this.drawingAttributes.FitToCurve = true;

            Pencil_Click(null, null);
        }
Пример #4
0
 /// <summary>
 /// Event handler for the "Inking Setting" button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void InkingSetting_Click(object sender, RoutedEventArgs e)
 {
     InkingPrefContentDialog dialog = new InkingPrefContentDialog(this.inkingPreference);
     if (await dialog.ShowAsync() == ContentDialogResult.Primary)
     {
         // Update drawing attributes
         this.inkingPreference = dialog.InkingPreference;
         if (this.Pencil.IsChecked == true) Pencil_Click(null, null);
         else if (this.Highlighter.IsChecked == true) Highlighter_Click(null, null);
         // Save inking preference
         await SaveDrawingPreference();
     }
 }