private bool OnToggleContentViewClick() { if( ContentViewToggled != null ) { var e = new ToggleContentViewEventArgs(_editAsText); e.Cancel = false; ContentViewToggled(this, e); return !e.Cancel; } return true; }
private bool OnToggleContentViewClick() { if (ContentViewToggled != null) { var e = new ToggleContentViewEventArgs(_editAsText); e.Cancel = false; ContentViewToggled(this, e); return(!e.Cancel); } return(true); }
void titleControl_ContentViewToggled(object sender, ToggleContentViewEventArgs e) { var p = _panels.Peek() as StackPanel; PanelInfo pi = p.Tag as PanelInfo; if( e.EditAsText ) { foreach( var ctl in p.Children.OfType<UserControl>() ) ctl.Visibility = System.Windows.Visibility.Collapsed; var editor = p.Children.OfType<CommandTextEditor>().SingleOrDefault(); if( editor == null ) { editor = new CommandTextEditor(); editor.Height = 400; switch(SendCommandManager.MessageContentFormat) { case ServiceBusMQ.Manager.MessageContentFormat.Xml: editor.TextType = CommandTextType.Xml; break; case ServiceBusMQ.Manager.MessageContentFormat.Json: editor.TextType = CommandTextType.Json; break; } p.Children.Add(editor); } object inst = CreateTypeInstance(p); editor.Text = SendCommandManager.SerializeCommand(inst); editor.Visibility = System.Windows.Visibility.Visible; pi.InitialObject = inst; } else { // Hide Editor & Show Input Controls object inst = null; try { inst = CreateTypeInstance(p); } catch( FailedDeserializingCommandException ex ) { if( !ShowDiscardCommandChangesDialog(ex) ) { e.Cancel = true; return; } else inst = pi.InitialObject; } UpdateDataPanel(p, pi.DataType, inst); foreach( var ctl in p.Children.OfType<UserControl>() ) ctl.Visibility = System.Windows.Visibility.Visible; var editor = p.Children.OfType<CommandTextEditor>().SingleOrDefault(); editor.Visibility = System.Windows.Visibility.Collapsed; } pi.EditAsText = e.EditAsText; }
void titleControl_ContentViewToggled(object sender, ToggleContentViewEventArgs e) { var p = _panels.Peek() as StackPanel; PanelInfo pi = p.Tag as PanelInfo; if (e.EditAsText) { foreach (var ctl in p.Children.OfType <UserControl>()) { ctl.Visibility = System.Windows.Visibility.Collapsed; } var editor = p.Children.OfType <CommandTextEditor>().SingleOrDefault(); if (editor == null) { editor = new CommandTextEditor(); editor.Height = 400; switch (SendCommandManager.CommandContentFormat) { case "XML": editor.TextType = CommandTextType.Xml; break; case "JSON": editor.TextType = CommandTextType.Json; break; } p.Children.Add(editor); } object inst = CreateTypeInstance(p); editor.Text = SendCommandManager.SerializeCommand(inst); editor.Visibility = System.Windows.Visibility.Visible; pi.InitialObject = inst; } else // Hide Editor & Show Input Controls { object inst = null; try { inst = CreateTypeInstance(p); } catch (FailedDeserializingCommandException ex) { if (!ShowDiscardCommandChangesDialog(ex)) { e.Cancel = true; return; } else { inst = pi.InitialObject; } } UpdateDataPanel(p, pi.DataType, inst); foreach (var ctl in p.Children.OfType <UserControl>()) { ctl.Visibility = System.Windows.Visibility.Visible; } var editor = p.Children.OfType <CommandTextEditor>().SingleOrDefault(); editor.Visibility = System.Windows.Visibility.Collapsed; } pi.EditAsText = e.EditAsText; }