private async void AppBar_NewPartButton_Click(object sender, RoutedEventArgs e) { if (_editor.Part == null) { NewFile(); return; } var partType = await ChoosePartType(true); if (!string.IsNullOrEmpty(partType)) { // Reset viewing parameters UcEditor.ResetView(false); // Create package and part var package = _editor.Part.Package; _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; _editor.Part.Dispose(); _editor.Part = null; var part = package.CreatePart(partType); _editor.Part = part; Title.Text = _packageName + " - " + part.Type; } }
private void Open_Click(object sender, RoutedEventArgs e) { string filePath = null; string fileName = null; // Show open dialog { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".iink"; // Default file extension dlg.Filter = ".iink|*.iink"; // Filter files by extension Nullable <bool> result = dlg.ShowDialog(); if (result == true) { filePath = dlg.FileName; fileName = dlg.SafeFileName; } } if (!string.IsNullOrEmpty(filePath)) { // Reset viewing parameters UcEditor.ResetView(false); // Open package and select first part _editor.Part = null; var package = _engine.OpenPackage(filePath); var part = package.GetPart(0); _editor.Part = part; _packageName = fileName; Type.Text = _packageName + " - " + part.Type; } }
private void TypeOfContentDialog_AddNewPart(string newPartType, bool newPackage) { if (newPartType != string.Empty) { ContentPackage package; if (!newPackage && (_editor.Part != null)) { package = _editor.Part.Package; } else { string packageName = MakeUntitledFilename(); package = _engine.CreatePackage(packageName); _packageName = System.IO.Path.GetFileName(packageName); } _editor.Part = null; // Reset viewing parameters UcEditor.ResetView(false); var part = package.CreatePart(newPartType); _editor.Part = part; Type.Text = _packageName + " - " + part.Type; } }
private void Next_Click(object sender, RoutedEventArgs e) { var part = _editor.Part; if (part != null) { var index = part.Package.IndexOfPart(part); if (index < part.Package.PartCount - 1) { // Reset viewing parameters UcEditor.ResetView(false); // Select new part _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; _editor.Part = null; var newPart = part.Package.GetPart(index + 1); _editor.Part = newPart; Type.Text = _packageName + " - " + newPart.Type; part.Dispose(); } } }
private void TypeOfContentDialog_AddNewPart(string newPartType, bool newPackage) { if (newPartType != string.Empty) { // Reset viewing parameters UcEditor.ResetView(false); _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; if (!newPackage && (_editor.Part != null)) { var previousPart = _editor.Part; var package = previousPart.Package; try { _editor.Part = null; var part = package.CreatePart(newPartType); _editor.Part = part; Type.Text = _packageName + " - " + part.Type; previousPart.Dispose(); } catch (Exception ex) { _editor.Part = previousPart; Type.Text = _packageName + " - " + _editor.Part.Type; MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { try { // Save and close current package SavePackage(); ClosePackage(); // Create package and part var packageName = MakeUntitledFilename(); var package = _engine.CreatePackage(packageName); var part = package.CreatePart(newPartType); _editor.Part = part; _packageName = System.IO.Path.GetFileName(packageName); Type.Text = _packageName + " - " + part.Type; } catch (Exception ex) { ClosePackage(); MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
private void Next_Click(object sender, RoutedEventArgs e) { var part = _editor.Part; if (part != null) { var package = part.Package; var count = package.PartCount; var index = package.IndexOfPart(part); if (index < count - 1) { // Reset viewing parameters UcEditor.ResetView(false); _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; _editor.Part = null; while (++index < count) { ContentPart newPart = null; try { // Select new part newPart = part.Package.GetPart(index); _editor.Part = newPart; Type.Text = _packageName + " - " + newPart.Type; part.Dispose(); break; } catch { // Can't set this part, try the next one _editor.Part = null; Type.Text = ""; newPart?.Dispose(); } } if (index >= count) { // Restore current part if none can be set _editor.Part = part; Type.Text = _packageName + " - " + part.Type; } } } }
private void Open_Click(object sender, RoutedEventArgs e) { string filePath = null; string fileName = null; // Show open dialog { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".iink"; // Default file extension dlg.Filter = ".iink|*.iink"; // Filter files by extension Nullable <bool> result = dlg.ShowDialog(); if (result == true) { filePath = dlg.FileName; fileName = dlg.SafeFileName; } } if (!string.IsNullOrEmpty(filePath)) { // Reset viewing parameters UcEditor.ResetView(false); _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; try { // Save and close current package SavePackage(); ClosePackage(); // Open package and select first part var package = _engine.OpenPackage(filePath); var part = package.GetPart(0); _editor.Part = part; _packageName = fileName; Type.Text = _packageName + " - " + part.Type; } catch (Exception ex) { ClosePackage(); MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void TypeOfContentDialog_AddNewPart(string newPartType, bool newPackage) { if (newPartType != string.Empty) { // Reset viewing parameters UcEditor.ResetView(false); _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; if (!newPackage && (_editor.Part != null)) { var package = _editor.Part.Package; _editor.Part.Dispose(); _editor.Part = null; var part = package.CreatePart(newPartType); _editor.Part = part; Type.Text = _packageName + " - " + part.Type; } else { // Close current package if (_editor.Part != null) { var part = _editor.Part; var package = part?.Package; _editor.Part = null; part?.Dispose(); package?.Dispose(); } // Create package and part { var packageName = MakeUntitledFilename(); var package = _engine.CreatePackage(packageName); var part = package.CreatePart(newPartType); _editor.Part = part; _packageName = System.IO.Path.GetFileName(packageName); Type.Text = _packageName + " - " + part.Type; } } } }
private void Previous_Click(object sender, RoutedEventArgs e) { var part = _editor.Part; if (part != null) { var index = part.Package.IndexOfPart(part); if (index > 0) { // Reset viewing parameters UcEditor.ResetView(false); // Select new part var newPart = part.Package.GetPart(index - 1); _editor.Part = newPart; Type.Text = _packageName + " - " + newPart.Type; } } }
private void AppBar_NextPartButton_Click(object sender, RoutedEventArgs e) { var part = _editor.Part; if (part != null) { var index = part.Package.IndexOfPart(part); if (index < part.Package.PartCount - 1) { // Reset viewing parameters UcEditor.ResetView(false); // Select new part var newPart = part.Package.GetPart(index + 1); _editor.Part = newPart; Title.Text = _packageName + " - " + newPart.Type; } } }
private async void AppBar_NewPartButton_Click(object sender, RoutedEventArgs e) { if (_editor.Part == null) { NewFile(); return; } var partType = await ChoosePartType(true); if (!string.IsNullOrEmpty(partType)) { // Reset viewing parameters UcEditor.ResetView(false); _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; var previousPart = _editor.Part; var package = previousPart.Package; try { _editor.Part = null; var part = package.CreatePart(partType); _editor.Part = part; Title.Text = _packageName + " - " + part.Type; previousPart.Dispose(); } catch (Exception ex) { _editor.Part = previousPart; Title.Text = _packageName + " - " + _editor.Part.Type; var msgDialog = new MessageDialog(ex.ToString()); await msgDialog.ShowAsync(); } } }
private void ResetZoom_Click(object sender, RoutedEventArgs e) { UcEditor.ResetView(true); }
private void AppBar_ResetViewButton_Click(object sender, RoutedEventArgs e) { UcEditor.ResetView(true); }
private async void AppBar_OpenPackageButton_Click(object sender, RoutedEventArgs e) { List <string> files = new List <string>(); // List iink files inside LocalFolders var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; var items = await localFolder.GetItemsAsync(); foreach (var item in items) { if (item.IsOfType(StorageItemTypes.File) && item.Path.EndsWith(".iink")) { files.Add(item.Name.ToString()); } } if (files.Count == 0) { return; } // Display file list ListBox fileList = new ListBox { ItemsSource = files, SelectedIndex = 0 }; ContentDialog fileNameDialog = new ContentDialog { Title = "Select Package Name", Content = fileList, IsSecondaryButtonEnabled = true, PrimaryButtonText = "Ok", SecondaryButtonText = "Cancel", }; if (await fileNameDialog.ShowAsync() == ContentDialogResult.Secondary) { return; } var fileName = fileList.SelectedValue.ToString(); var filePath = System.IO.Path.Combine(localFolder.Path.ToString(), fileName); // Close current package _lastSelectedBlock?.Dispose(); _lastSelectedBlock = null; if (_editor.Part != null) { var part = _editor.Part; var package = part?.Package; _editor.Part = null; part?.Dispose(); package?.Dispose(); } // Reset viewing parameters UcEditor.ResetView(false); // Open package and select first part { var package = _engine.OpenPackage(filePath); var part = package.GetPart(0); _editor.Part = part; _packageName = fileName; Title.Text = _packageName + " - " + part.Type; } }