private void OnClick_ButtonTTSVoices(object sender, RoutedEventArgs e) { //ViewModel.m_ShellView.ExecuteShellProcess(AudioPaneViewModel.TTS_VOICE_MAPPING_DIRECTORY); string text; Dictionary <string, string> ttsVoiceMap = ViewModel.readTTSVoicesMapping(out text); var editBox = new TextBoxReadOnlyCaretVisible { Text = text, AcceptsReturn = true, TextWrapping = TextWrapping.WrapWithOverflow }; var windowPopup = new PopupModalWindow(ViewModel.m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_AudioPane_Lang.TTSVoiceMapping), new ScrollViewer { Content = editBox }, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 500, 600, null, 40, null); windowPopup.EnableEnterKeyDefault = false; editBox.Loaded += new RoutedEventHandler((send, ev) => { //editBox.SelectAll(); FocusHelper.FocusBeginInvoke(editBox); }); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { string str = editBox.Text; if (string.IsNullOrEmpty(str)) { str = " "; } StreamWriter streamWriter = new StreamWriter(AudioPaneViewModel.TTS_VOICE_MAPPING_FILE, false, Encoding.UTF8); try { streamWriter.Write(str); } finally { streamWriter.Close(); } string newText; ttsVoiceMap = ViewModel.readTTSVoicesMapping(out newText); //DebugFix.assert(newText.Equals(editBox.Text, StringComparison.Ordinal)); } }
private bool askUser(string message, string info) { m_Logger.Log("ShellView.askUser", Category.Debug, Priority.Medium); var label = new TextBlock { Text = message, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider( m_ShellView.LoadTangoIcon("help-browser"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var details = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], BorderThickness = new Thickness(1), Padding = new Thickness(6), TextReadOnly = info }; var windowPopup = new PopupModalWindow(m_ShellView, message, panel, PopupModalWindow.DialogButtonsSet.YesNo, PopupModalWindow.DialogButton.No, true, 360, 200, details, 40, null); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { return(true); } return(false); }
private string showTextEditorPopupDialog(string editedText, String dialogTitle) { m_Logger.Log("showTextEditorPopupDialog", Category.Debug, Priority.Medium); var editBox = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], Text = editedText, TextWrapping = TextWrapping.WrapWithOverflow, AcceptsReturn = true }; var windowPopup = new PopupModalWindow(m_ShellView, dialogTitle, new ScrollViewer { Content = editBox, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, VerticalScrollBarVisibility = ScrollBarVisibility.Auto }, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 350, 200, null, 40, m_DescriptionPopupModalWindow); windowPopup.EnableEnterKeyDefault = true; editBox.Loaded += new RoutedEventHandler((sender, ev) => { editBox.SelectAll(); FocusHelper.FocusBeginInvoke(editBox); }); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { string str = editBox.Text == null ? "" : editBox.Text.Trim(); //if (string.IsNullOrEmpty(str)) //{ // return ""; //} return(str); } return(null); }
private bool askUserAlt(string title, string message) { m_Logger.Log("ShellView.askUser", Category.Debug, Priority.Medium); var label = new TextBlock { Text = message, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider( m_ShellView.LoadTangoIcon("dialog-warning"), //help-browser m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var windowPopup = new PopupModalWindow(m_ShellView, title, panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Cancel, true, 400, 200, null, 40, null); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { return(true); } return(false); }
public string messageBoxFilePick(string title, string exeOrBat) { m_Logger.Log(@"UrakawaSession_Save.messageBoxFilePick", Category.Debug, Priority.Medium); string ext = Path.GetExtension(exeOrBat); PopupModalWindow windowPopup = null; //var textArea = new TextBoxReadOnlyCaretVisible() //{ // FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], // TextReadOnly = info, // BorderThickness = new Thickness(1), // Padding = new Thickness(6), // HorizontalAlignment = HorizontalAlignment.Stretch, // VerticalAlignment = VerticalAlignment.Stretch, // Focusable = true, // TextWrapping = TextWrapping.Wrap //}; //var scroll = new ScrollViewer //{ // Content = textArea, // Margin = new Thickness(6), // VerticalScrollBarVisibility = ScrollBarVisibility.Visible, // HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled //}; var fileText = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], BorderThickness = new Thickness(1), BorderBrush = SystemColors.ControlDarkDarkBrush, //Padding = new Thickness(6), TextReadOnly = " ", //IsReadOnly = true, Width = 300, Margin = new Thickness(0, 8, 0, 0), Padding = new Thickness(4), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Focusable = true, TextWrapping = TextWrapping.Wrap }; //fileText.SetValue(KeyboardNavigation.TabIndexProperty, 12); KeyboardNavigation.SetTabIndex(fileText, 12); var label = new TextBlock { Text = "Please locate [" + exeOrBat + "]", Margin = new Thickness(0, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, }; //label.SetValue(KeyboardNavigation.TabIndexProperty, 10); KeyboardNavigation.SetTabIndex(label, 10); var fileButton = new Button() { Content = "Browse...", Margin = new Thickness(0, 0, 0, 0), Padding = new Thickness(8, 0, 8, 0), }; //fileButton.SetValue(KeyboardNavigation.TabIndexProperty, 11); KeyboardNavigation.SetTabIndex(fileButton, 11); fileButton.Click += (sender, e) => { var dlg_ = new Microsoft.Win32.OpenFileDialog { FileName = exeOrBat, DefaultExt = ext, Filter = @"Executable (*" + ext + ")|*" + ext + "", CheckFileExists = false, CheckPathExists = false, AddExtension = true, DereferenceLinks = true, Title = @"Tobi: " + "Pipeline2 (" + exeOrBat + ")" }; bool?result_ = false; m_ShellView.DimBackgroundWhile( () => { result_ = dlg_.ShowDialog(); } , windowPopup ); if (result_ == true) { fileText.TextReadOnly = dlg_.FileName; } }; var filePanel = new DockPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, LastChildFill = true }; //fileButton.SetValue(DockPanel.DockProperty, Dock.Right); DockPanel.SetDock(fileButton, Dock.Right); filePanel.Children.Add(fileButton); filePanel.Children.Add(label); var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(filePanel); panel.Children.Add(fileText); //panel.Margin = new Thickness(8, 8, 8, 0); windowPopup = new PopupModalWindow(m_ShellView, title, panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 380, 200, null, //scroll, 300, null); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { return(fileText.TextReadOnly); } return(null); }
private bool askUserAppUpdate(string thisVersion, string latestVersion) { m_Logger.Log("ShellView.askUserAppUpdate", Category.Debug, Priority.Medium); var label = new TextBlock { Text = Tobi_Lang.TobiUpdate_Message, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var label2 = new TextBlock { Text = "[" + thisVersion + " --> " + latestVersion + "]", Margin = new Thickness(8, 0, 8, 8), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(LoadTangoIcon("help-browser"), MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(iconProvider.IconLarge); var panel2 = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(panel2); panel2.Children.Add(label); panel2.Children.Add(label2); //panel.Margin = new Thickness(8, 8, 8, 0); //var details = new TextBoxReadOnlyCaretVisible // { // TextReadOnly = Tobi_Lang.ExitConfirm //}; var windowPopup = new PopupModalWindow(this, UserInterfaceStrings.EscapeMnemonic(Tobi_Lang.TobiUpdate_Title), panel, PopupModalWindow.DialogButtonsSet.YesNo, PopupModalWindow.DialogButton.No, true, 400, 200, null, 40, null); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { if (m_UrakawaSession != null && m_UrakawaSession.DocumentProject != null && m_UrakawaSession.IsDirty) { PopupModalWindow.DialogButton button = m_UrakawaSession.CheckSaveDirtyAndClose(PopupModalWindow.DialogButtonsSet.YesNoCancel, "exit"); if (PopupModalWindow.IsButtonEscCancel(button)) { return(false); } } return(true); } return(false); }
private string askUserId(IShellView shellView, string title, string message, string info) { m_Logger.Log("Bootstrapper.askUserId", Category.Debug, Priority.Medium); var label = new TextBlock // TextBoxReadOnlyCaretVisible { //FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], //BorderThickness = new Thickness(1), //Padding = new Thickness(6), //TextReadOnly = message, Text = message, FontWeight = FontWeights.Bold, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var input = new TextBox() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Text = "" }; //var iconProvider = new ScalableGreyableImageProvider( // m_ShellView.LoadTangoIcon("help-browser"), // m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; //panel.Margin = new Thickness(8, 8, 8, 0); //panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); panel.Children.Add(input); var checkBox = new CheckBox { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], IsThreeState = false, IsChecked = Settings.Default.UserId_DoNotAskAgain, VerticalAlignment = VerticalAlignment.Center, Content = Tobi_Common_Lang.DoNotShowMessageAgain, Margin = new Thickness(0, 16, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, }; panel.Children.Add(checkBox); var details = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], BorderThickness = new Thickness(1), Padding = new Thickness(6), TextReadOnly = info }; var windowPopup = new PopupModalWindow(shellView, // m_ShellView title, panel, PopupModalWindow.DialogButtonsSet.OkCancel, // PopupModalWindow.DialogButtonsSet.YesNo PopupModalWindow.DialogButton.Ok, //PopupModalWindow.DialogButton.Yes true, 425, 190, details, 70, null); windowPopup.ShowModal(); Settings.Default.UserId_DoNotAskAgain = checkBox.IsChecked.Value; if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { return(input.Text); } return(null); }
private bool showMetadataAttributeEditorPopupDialog(string label1, string label2, MetadataAttribute metadataAttr, out string newName, out string newValue, bool isAltContentMetadata, bool isOptionalAttributes, bool invalidSyntax) { m_Logger.Log("Descriptions.MetadataAttributeEditor", Category.Debug, Priority.Medium); var label_Name = new TextBlock { Text = label1 + ": ", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var label_Value = new TextBlock { Text = label2 + ": ", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; //var editBox_Name = new TextBox //{ // Text = metadataAttr.Name, // TextWrapping = TextWrapping.WrapWithOverflow //}; var editBoxCombo_Name = new ComboBox //WithAutomationPeer { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], Text = metadataAttr.Name, IsEditable = true, IsTextSearchEnabled = true, #if NET40 IsTextSearchCaseSensitive = false #endif //NET40 }; //var binding = new Binding //{ // Mode = BindingMode.OneWay, // Source = new RelativeSource(RelativeSourceMode.Self), // Path = new PropertyPath("SelectedItem") //}; ////var expr = editBoxCombo_Name.SetBinding(AutomationProperties.NameProperty, binding); //editBoxCombo_Name.SetValue(AutomationProperties.NameProperty, "daniel"); //editBoxCombo_Name.SelectionChanged += new SelectionChangedEventHandler( // (object sender, SelectionChangedEventArgs e) => // { // //var expr = editBoxCombo_Name.GetBindingExpression(AutomationProperties.NameProperty); // //expr.UpdateTarget(); // //editBoxCombo_Name.NotifyScreenReaderAutomationIfKeyboardFocused(); // //var txt = editBoxCombo_Name.Text; // //editBoxCombo_Name.Text = "mike"; // //editBoxCombo_Name.Text = txt; // editBoxCombo_Name.NotifyScreenReaderAutomation(); // m_Logger.Log("UP TRAGET", Category.Debug, Priority.High); // } // ); var list = new List <String>(); if (isAltContentMetadata) { list.AddRange(DiagramContentModelHelper.DIAGRAM_ElementAttributes); #if true || SUPPORT_ANNOTATION_ELEMENT list.Add(DiagramContentModelHelper.Ref); list.Add(DiagramContentModelHelper.Role); list.Add(DiagramContentModelHelper.By); #endif //SUPPORT_ANNOTATION_ELEMENT } else { if (isOptionalAttributes) { list.AddRange(DiagramContentModelHelper.DIAGRAM_MetadataAdditionalAttributeNames); } else { list.AddRange(DiagramContentModelHelper.DIAGRAM_MetadataProperties); list.Add(DiagramContentModelHelper.NA); } } editBoxCombo_Name.ItemsSource = list; // col = new ObservableCollection<string> { "Eric", "Phillip" }; //combo.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = col }); var editBox_Value = new TextBoxReadOnlyCaretVisible { //Watermark = TEXTFIELD_WATERMARK, Text = metadataAttr.Value, TextWrapping = TextWrapping.WrapWithOverflow }; var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; var panelName = new DockPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, LastChildFill = true }; panelName.Margin = new Thickness(0, 0, 0, 8); label_Name.SetValue(DockPanel.DockProperty, Dock.Left); panelName.Children.Add(label_Name); panelName.Children.Add(editBoxCombo_Name); var panelValue = new DockPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; label_Value.SetValue(DockPanel.DockProperty, Dock.Left); panelValue.Children.Add(label_Value); panelValue.Children.Add(editBox_Value); panel.Children.Add(panelName); panel.Children.Add(panelValue); if (invalidSyntax) { var msg = new TextBlock(new Run("(invalid syntax)")) { Margin = new Thickness(0, 6, 0, 0), Focusable = true, FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], }; panel.Children.Add(msg); } //var details = new TextBoxReadOnlyCaretVisible // { // TextReadOnly = Tobi_Lang.ExitConfirm //}; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic("Edit attribute"), panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 310, 200, null, 40, m_DescriptionPopupModalWindow); windowPopup.EnableEnterKeyDefault = true; editBoxCombo_Name.Loaded += new RoutedEventHandler((sender, ev) => { var textBox = ComboBoxWithAutomationPeer.GetTextBox(editBoxCombo_Name); if (textBox != null) { textBox.FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"]; textBox.SelectAll(); } FocusHelper.FocusBeginInvoke(editBoxCombo_Name); }); editBox_Value.Loaded += new RoutedEventHandler((sender, ev) => { editBox_Value.SelectAll(); //FocusHelper.FocusBeginInvoke(editBox_Name); }); WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, true); WatermarkComboBoxBehavior.SetLabel(editBoxCombo_Name, TEXTFIELD_WATERMARK); Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"]; WatermarkComboBoxBehavior.SetLabelStyle(editBoxCombo_Name, style); WatermarkTextBoxBehavior.SetEnableWatermark(editBox_Value, true); WatermarkTextBoxBehavior.SetLabel(editBox_Value, TEXTFIELD_WATERMARK); //Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"]; WatermarkTextBoxBehavior.SetLabelStyle(editBox_Value, style); windowPopup.ShowModal(); WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, false); WatermarkTextBoxBehavior.SetEnableWatermark(editBox_Value, false); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { newName = editBoxCombo_Name.Text.Trim(); newValue = editBox_Value.Text.Trim(); return(true); } newName = null; newValue = null; return(false); }
private bool doImport() { m_Logger.Log(String.Format(@"UrakawaSession.doImport() [{0}]", DocumentFilePath), Category.Debug, Priority.Medium); string ext = Path.GetExtension(DocumentFilePath); if (".opf".Equals(ext, StringComparison.OrdinalIgnoreCase)) { int levelsUp = 0; string parentDir = Path.GetDirectoryName(DocumentFilePath); DirectoryInfo parentDirInfo = new DirectoryInfo(parentDir); tryAgain: levelsUp++; #if NET40 IEnumerable <DirectoryInfo> metaInfDirs = parentDirInfo.EnumerateDirectories("META-INF", SearchOption.TopDirectoryOnly); #else DirectoryInfo[] metaInfDirs = parentDirInfo.GetDirectories("META-INF", SearchOption.TopDirectoryOnly); #endif bool found = false; foreach (DirectoryInfo dirInfo in metaInfDirs) { string containerXml = Path.Combine(dirInfo.FullName, "container.xml"); if (File.Exists(containerXml)) { DocumentFilePath = containerXml; ext = Path.GetExtension(DocumentFilePath); found = true; break; } } if (!found && levelsUp <= 2 && parentDirInfo.Parent != null) { parentDirInfo = parentDirInfo.Parent; goto tryAgain; } } if (DataProviderFactory.EPUB_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase)) { checkEpub(DocumentFilePath, null); } else if (DataProviderFactory.XML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase) && FileDataProvider.NormaliseFullFilePath(DocumentFilePath).IndexOf( @"META-INF" //+ Path.DirectorySeparatorChar + '/' + @"container.xml" , StringComparison.OrdinalIgnoreCase) >= 0 //DocumentFilePath.IndexOf("container.xml", StringComparison.OrdinalIgnoreCase) >= 0 ) { string parentDir = Path.GetDirectoryName(DocumentFilePath); DirectoryInfo dirInfo = new DirectoryInfo(parentDir); if (dirInfo.Parent != null) { string checkEpubPath = dirInfo.Parent.FullName; checkEpub(checkEpubPath, "exp"); } } else if (".opf".Equals(ext, StringComparison.OrdinalIgnoreCase)) { if (!checkDAISY(DocumentFilePath)) { //checkEpub(DocumentFilePath, "opf"); assume container.xml was found (see above) } } else if (DataProviderFactory.HTML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase) || DataProviderFactory.XHTML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase)) { //MessageBox.Show messageBoxAlert("WARNING: single HTML import is an experimental and incomplete EPUB feature!", null); checkEpub(DocumentFilePath, "xhtml"); } else if (DataProviderFactory.XML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase)) { //checkDAISY(DocumentFilePath); if (false && // TODO: Pipeline 2 with better support for DTBOOK validation (currently skips metadata values) askUser("DAISY Check?", DocumentFilePath)) { string pipeline_ExePath = obtainPipelineExe(); if (!string.IsNullOrEmpty(pipeline_ExePath)) { string outDir = Path.GetDirectoryName(DocumentFilePath); outDir = Path.Combine(outDir, Path.GetFileName(DocumentFilePath) + "_PIPEVAL"); bool success = false; Func <String, String> checkErrorsOrWarning = (string report) => { if (report.IndexOf("[DP2] DONE", StringComparison.Ordinal) < 0) { return("Pipeline job doesn't appear to have completed?"); } string reportFile = Path.Combine(outDir, "report.xhtml"); if (File.Exists(reportFile)) { string reportXmlSource = File.ReadAllText(reportFile); if (!string.IsNullOrEmpty(reportXmlSource)) { string xmlInfo = ""; XmlDocument xmlDoc = XmlReaderWriterHelper.ParseXmlDocumentFromString(reportXmlSource, false, false); IEnumerable <XmlNode> lis = XmlDocumentHelper.GetChildrenElementsOrSelfWithName( xmlDoc.DocumentElement, true, "li", null, false); foreach (XmlNode li in lis) { if (li.Attributes == null) { continue; } XmlNode classAttr = li.Attributes.GetNamedItem("class"); if (classAttr == null || classAttr.Value != "error") { continue; } xmlInfo += li.InnerText; xmlInfo += Environment.NewLine; } if (string.IsNullOrEmpty(xmlInfo)) { success = true; return(null); } return(xmlInfo); } } success = true; return(null); }; try { string workingDir = Path.GetDirectoryName(pipeline_ExePath); //Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); executeProcess( workingDir, "DAISY Pipeline (validation)", //"\"" + pipeline_ExePath //+ "\"" , "dtbook-validator " + "--i-source \"" + DocumentFilePath + "\" " + "--x-output-dir \"" + outDir + "\" ", checkErrorsOrWarning); } catch (Exception ex) { messageBoxText("Oops :(", "Problem running DAISY Pipeline (validation)!", ex.Message + Environment.NewLine + ex.StackTrace); } if (Directory.Exists(outDir)) { //m_ShellView.ExecuteShellProcess(outDir); FileDataProvider.TryDeleteDirectory(outDir, false); } } } } string outputDirectory = Path.Combine( Path.GetDirectoryName(DocumentFilePath), Daisy3_Import.GetXukDirectory(DocumentFilePath)); //string xukPath = Daisy3_Import.GetXukFilePath(outputDirectory, DocumentFilePath); //if (File.Exists(xukPath)) if (Directory.Exists(outputDirectory)) { if (!askUserConfirmOverwriteFileFolder(outputDirectory, true, null)) { return(false); } FileDataProvider.TryDeleteDirectory(outputDirectory, true); } var combo = new ComboBox { Margin = new Thickness(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; ComboBoxItem item1 = new ComboBoxItem(); item1.Content = AudioLib.SampleRate.Hz11025.ToString(); combo.Items.Add(item1); ComboBoxItem item2 = new ComboBoxItem(); item2.Content = AudioLib.SampleRate.Hz22050.ToString(); combo.Items.Add(item2); ComboBoxItem item3 = new ComboBoxItem(); item3.Content = AudioLib.SampleRate.Hz44100.ToString(); combo.Items.Add(item3); switch (Settings.Default.AudioProjectSampleRate) { case AudioLib.SampleRate.Hz11025: { combo.SelectedItem = item1; combo.Text = item1.Content.ToString(); break; } case AudioLib.SampleRate.Hz22050: { combo.SelectedItem = item2; combo.Text = item2.Content.ToString(); break; } case AudioLib.SampleRate.Hz44100: { combo.SelectedItem = item3; combo.Text = item3.Content.ToString(); break; } } var label_ = new TextBlock { Text = Tobi_Plugin_Urakawa_Lang.Stereo, Margin = new Thickness(0, 0, 8, 0), HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var checkBox = new CheckBox { IsThreeState = false, IsChecked = Settings.Default.AudioProjectStereo, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; var panel__ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 8, 0, 22), }; panel__.Children.Add(label_); panel__.Children.Add(checkBox); var label = new TextBlock { Text = Tobi_Plugin_Urakawa_Lang.UseSourceAudioFormat, Margin = new Thickness(0, 0, 8, 0), HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var checkAuto = new CheckBox { IsThreeState = false, IsChecked = false, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; var panel_ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 12), }; panel_.Children.Add(label); panel_.Children.Add(checkAuto); var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(combo); panel.Children.Add(panel__); panel.Children.Add(panel_); //var line = new Separator() //{ // Margin = new Thickness(0, 8, 0, 8), //}; //line.HorizontalAlignment = HorizontalAlignment.Stretch; //line.VerticalAlignment = VerticalAlignment.Center; //panel.Children.Add(line); var details = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], BorderThickness = new Thickness(1), Padding = new Thickness(6), TextReadOnly = Tobi_Plugin_Urakawa_Lang.UseSourceAudioFormatTip }; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.ProjectAudioFormat), panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, false, 320, 200, details, 40, null); windowPopup.EnableEnterKeyDefault = true; windowPopup.ShowModal(); if (!PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { return(false); } Settings.Default.AudioProjectStereo = checkBox.IsChecked.Value; if (combo.SelectedItem == item1) { Settings.Default.AudioProjectSampleRate = SampleRate.Hz11025; } else if (combo.SelectedItem == item2) { Settings.Default.AudioProjectSampleRate = SampleRate.Hz22050; } else if (combo.SelectedItem == item3) { Settings.Default.AudioProjectSampleRate = SampleRate.Hz44100; } var converter = new Daisy3_Import(DocumentFilePath, outputDirectory, IsAcmCodecsDisabled, Settings.Default.AudioProjectSampleRate, Settings.Default.AudioProjectStereo, checkAuto.IsChecked.Value, Settings.Default.XUK_PrettyFormat ); //Directory.GetParent(bookfile).FullName //converter.VerifyHtml5OutliningAlgorithmUsingPipelineTestSuite(); bool cancelled = false; bool error = m_ShellView.RunModalCancellableProgressTask(true, Tobi_Plugin_Urakawa_Lang.Importing, converter, () => { cancelled = true; DocumentFilePath = null; DocumentProject = null; }, () => { cancelled = false; if (string.IsNullOrEmpty(converter.XukPath)) { return; } //DocumentFilePath = converter.XukPath; //DocumentProject = converter.Project; //AddRecentFile(new Uri(DocumentFilePath, UriKind.Absolute)); }); if (!cancelled) { //DebugFix.Assert(!report); string xukPath = converter.XukPath; if (string.IsNullOrEmpty(xukPath)) { return(false); } string projectDir = Path.GetDirectoryName(xukPath); DebugFix.Assert(outputDirectory == projectDir); string title = converter.GetTitle(); if (!string.IsNullOrEmpty(title)) { string fileName = Daisy3_Import.GetXukFilePath(projectDir, DocumentFilePath, title, false); fileName = Path.GetFileNameWithoutExtension(fileName); string parent = Path.GetDirectoryName(projectDir); //string fileName = Path.GetFileNameWithoutExtension(xukPath); ////while (fileName.StartsWith("_")) ////{ //// fileName = fileName.Substring(1, fileName.Length - 1); ////} //char[] chars = new char[] { '_' }; //fileName = fileName.TrimStart(chars); string newProjectDir = Path.Combine(parent, fileName); // + Daisy3_Import.XUK_DIR if (newProjectDir != projectDir) { bool okay = true; if (Directory.Exists(newProjectDir)) { if (askUserConfirmOverwriteFileFolder(newProjectDir, true, null)) { try { FileDataProvider.TryDeleteDirectory(newProjectDir, false); } catch (Exception ex) { #if DEBUG Debugger.Break(); #endif // DEBUG Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); okay = false; } } else { okay = false; } } if (okay) { Directory.Move(projectDir, newProjectDir); xukPath = Path.Combine(newProjectDir, Path.GetFileName(xukPath)); } } } DocumentFilePath = null; DocumentProject = null; try { OpenFile(xukPath); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); return(false); } } return(!cancelled); }
private string showLineEditorPopupDialog(string editedText, string dialogTitle, List <string> predefinedCandidates, bool invalidSyntax) { m_Logger.Log("showTextEditorPopupDialog", Category.Debug, Priority.Medium); if (predefinedCandidates == null) { var editBox = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], //Watermark = TEXTFIELD_WATERMARK, Text = editedText, TextWrapping = TextWrapping.NoWrap, AcceptsReturn = false }; var panel = new StackPanel(); panel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical); panel.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center); editBox.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center); panel.Children.Add(editBox); if (invalidSyntax) { var msg = new TextBlock(new Run("(invalid syntax)")) { Margin = new Thickness(0, 6, 0, 0), Focusable = true, FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], }; panel.Children.Add(msg); } var windowPopup = new PopupModalWindow(m_ShellView, dialogTitle, panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 300, 160, null, 40, m_DescriptionPopupModalWindow); windowPopup.EnableEnterKeyDefault = true; editBox.SetValue(AutomationProperties.NameProperty, dialogTitle); editBox.Loaded += new RoutedEventHandler((sender, ev) => { editBox.SelectAll(); FocusHelper.FocusBeginInvoke(editBox); }); WatermarkTextBoxBehavior.SetEnableWatermark(editBox, true); WatermarkTextBoxBehavior.SetLabel(editBox, TEXTFIELD_WATERMARK); Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"]; WatermarkTextBoxBehavior.SetLabelStyle(editBox, style); windowPopup.ShowModal(); WatermarkTextBoxBehavior.SetEnableWatermark(editBox, false); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { string str = editBox.Text == null ? "" : editBox.Text.Trim(); //if (string.IsNullOrEmpty(str)) //{ // return ""; //} return(str); } return(null); } else { var editBoxCombo_Name = new ComboBox //WithAutomationPeer { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], Text = editedText, IsEditable = true, IsTextSearchEnabled = true, #if NET40 IsTextSearchCaseSensitive = false #endif //NET40 }; editBoxCombo_Name.ItemsSource = predefinedCandidates; var panel = new StackPanel(); panel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical); panel.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center); editBoxCombo_Name.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center); panel.Children.Add(editBoxCombo_Name); if (invalidSyntax) { var msg = new TextBlock(new Run("(invalid syntax)")) { Margin = new Thickness(0, 6, 0, 0), Focusable = true, FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], }; panel.Children.Add(msg); } var windowPopup = new PopupModalWindow(m_ShellView, dialogTitle, panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 300, 160, null, 40, m_DescriptionPopupModalWindow); windowPopup.EnableEnterKeyDefault = true; editBoxCombo_Name.Loaded += new RoutedEventHandler((sender, ev) => { var textBox = ComboBoxWithAutomationPeer.GetTextBox(editBoxCombo_Name); if (textBox != null) { textBox.FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"]; textBox.SelectAll(); } FocusHelper.FocusBeginInvoke(editBoxCombo_Name); }); WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, true); WatermarkComboBoxBehavior.SetLabel(editBoxCombo_Name, TEXTFIELD_WATERMARK); Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"]; WatermarkComboBoxBehavior.SetLabelStyle(editBoxCombo_Name, style); windowPopup.ShowModal(); WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, false); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { string str = editBoxCombo_Name.Text == null ? "" : editBoxCombo_Name.Text.Trim(); //if (string.IsNullOrEmpty(str)) //{ // return ""; //} return(str); } return(null); } }
private void OnClick_ButtonExport(object sender, RoutedEventArgs e) { m_Logger.Log("DescriptionView.OnClick_ButtonExport", Category.Debug, Priority.Medium); Tuple <TreeNode, TreeNode> selection = m_Session.GetTreeNodeSelection(); TreeNode node = selection.Item2 ?? selection.Item1; if (node == null || node.GetAlternateContentProperty() == null || node.GetImageMedia() == null || !(node.GetImageMedia() is ManagedImageMedia)) { return; } SampleRate sampleRate = SampleRate.Hz22050; sampleRate = Urakawa.Settings.Default.AudioExportSampleRate; bool encodeToMp3 = true; encodeToMp3 = Urakawa.Settings.Default.AudioExportEncodeToMp3; var combo = new ComboBox { Margin = new Thickness(0, 0, 0, 12) }; ComboBoxItem item1 = new ComboBoxItem(); item1.Content = AudioLib.SampleRate.Hz11025.ToString(); combo.Items.Add(item1); ComboBoxItem item2 = new ComboBoxItem(); item2.Content = AudioLib.SampleRate.Hz22050.ToString(); combo.Items.Add(item2); ComboBoxItem item3 = new ComboBoxItem(); item3.Content = AudioLib.SampleRate.Hz44100.ToString(); combo.Items.Add(item3); switch (sampleRate) { case AudioLib.SampleRate.Hz11025: { combo.SelectedItem = item1; combo.Text = item1.Content.ToString(); break; } case AudioLib.SampleRate.Hz22050: { combo.SelectedItem = item2; combo.Text = item2.Content.ToString(); break; } case AudioLib.SampleRate.Hz44100: { combo.SelectedItem = item3; combo.Text = item3.Content.ToString(); break; } } var checkBox = new CheckBox { IsThreeState = false, IsChecked = encodeToMp3, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; var label_ = new TextBlock { Text = Tobi_Plugin_Urakawa_Lang.ExportEncodeMp3, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var panel__ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; panel__.Children.Add(label_); panel__.Children.Add(checkBox); var panel_ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Vertical, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; panel_.Children.Add(combo); panel_.Children.Add(panel__); var windowPopup_ = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.ExportSettings), panel_, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, false, 300, 180, null, 40, m_DescriptionPopupModalWindow); windowPopup_.EnableEnterKeyDefault = true; windowPopup_.ShowModal(); if (!PopupModalWindow.IsButtonOkYesApply(windowPopup_.ClickedDialogButton)) { return; } encodeToMp3 = checkBox.IsChecked.Value; Urakawa.Settings.Default.AudioExportEncodeToMp3 = checkBox.IsChecked.Value; if (combo.SelectedItem == item1) { sampleRate = SampleRate.Hz11025; Urakawa.Settings.Default.AudioExportSampleRate = sampleRate; } else if (combo.SelectedItem == item2) { sampleRate = SampleRate.Hz22050; Urakawa.Settings.Default.AudioExportSampleRate = sampleRate; } else if (combo.SelectedItem == item3) { sampleRate = SampleRate.Hz44100; Urakawa.Settings.Default.AudioExportSampleRate = sampleRate; } string rootFolder = Path.GetDirectoryName(m_Session.DocumentFilePath); var dlg = new FolderBrowserDialog { RootFolder = Environment.SpecialFolder.MyComputer, SelectedPath = rootFolder, ShowNewFolderButton = true, Description = @"Tobi: " + UserInterfaceStrings.EscapeMnemonic("Export DIAGRAM XML") }; DialogResult result = DialogResult.Abort; m_ShellView.DimBackgroundWhile(() => { result = dlg.ShowDialog(); }); if (result != DialogResult.OK && result != DialogResult.Yes) { return; } if (!Directory.Exists(dlg.SelectedPath)) { return; } ManagedImageMedia managedImage = (ManagedImageMedia)node.GetImageMedia(); string exportImageName = //Path.GetFileName FileDataProvider.EliminateForbiddenFileNameCharacters (managedImage.ImageMediaData.OriginalRelativePath) ; string imageDescriptionDirectoryPath = Daisy3_Export.GetAndCreateImageDescriptionDirectoryPath(false, exportImageName, dlg.SelectedPath); if (Directory.Exists(imageDescriptionDirectoryPath)) { if (!m_Session.askUserConfirmOverwriteFileFolder(imageDescriptionDirectoryPath, true, m_DescriptionPopupModalWindow)) { return; } FileDataProvider.TryDeleteDirectory(imageDescriptionDirectoryPath, true); } FileDataProvider.CreateDirectory(imageDescriptionDirectoryPath); PCMFormatInfo audioFormat = node.Presentation.MediaDataManager.DefaultPCMFormat; AudioLibPCMFormat pcmFormat = audioFormat.Data; if ((ushort)sampleRate != pcmFormat.SampleRate) { pcmFormat.SampleRate = (ushort)sampleRate; } Application.Current.MainWindow.Cursor = Cursors.Wait; this.Cursor = Cursors.Wait; //m_ShellView try { string descriptionFile = Daisy3_Export.CreateImageDescription( Urakawa.Settings.Default.AudioCodecDisableACM, pcmFormat, encodeToMp3, 0, imageDescriptionDirectoryPath, exportImageName, node.GetAlternateContentProperty(), null, null, null); } finally { Application.Current.MainWindow.Cursor = Cursors.Arrow; this.Cursor = Cursors.Arrow; //m_ShellView } m_ShellView.ExecuteShellProcess(imageDescriptionDirectoryPath); }
public void ImportMetadata() { //m_ShellView.ExecuteShellProcess(MetadataPaneViewModel.METADATA_IMPORT_DIRECTORY); string text; List <Tuple <string, string> > metadatas = readMetadataImport(out text); var editBox = new TextBoxReadOnlyCaretVisible { Text = text, AcceptsReturn = true, TextWrapping = TextWrapping.WrapWithOverflow }; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_MetadataPane_Lang.Import), new ScrollViewer { Content = editBox }, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 500, 600, null, 40, null); windowPopup.EnableEnterKeyDefault = false; editBox.Loaded += new RoutedEventHandler((sender, ev) => { //editBox.SelectAll(); FocusHelper.FocusBeginInvoke(editBox); }); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { if (!string.IsNullOrEmpty(editBox.Text)) { StreamWriter streamWriter = new StreamWriter(METADATA_IMPORT_FILE, false, Encoding.UTF8); try { streamWriter.Write(editBox.Text); } finally { streamWriter.Close(); } string newText; metadatas = readMetadataImport(out newText); //DebugFix.assert(newText.Equals(editBox.Text, StringComparison.Ordinal)); Presentation presentation = m_UrakawaSession.DocumentProject.Presentations.Get(0); foreach (Tuple <string, string> md in metadatas) { List <NotifyingMetadataItem> toRemove = new List <NotifyingMetadataItem>(); foreach (NotifyingMetadataItem m in this.MetadataCollection.Metadatas) { if (m.Name.Equals(md.Item1, StringComparison.Ordinal)) { if (!m.Definition.IsRepeatable) { if (!toRemove.Contains(m)) { toRemove.Add(m); } } } } foreach (var m in toRemove) { RemoveMetadata(m); } Metadata metadata = presentation.MetadataFactory.CreateMetadata(); metadata.NameContentAttribute = new MetadataAttribute { Name = md.Item1, NamespaceUri = "", Value = md.Item2 }; MetadataAddCommand cmd = presentation.CommandFactory.CreateMetadataAddCommand (metadata); presentation.UndoRedoManager.Execute(cmd); } } } }