示例#1
0
        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 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);
            }
        }