1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System.Diagnostics;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using InABox.Core;
- namespace InABox.DynamicGrid
- {
- public class URLEditorControl : DynamicEditorControl<string, URLEditor>
- {
-
- static URLEditorControl()
- {
- //DynamicEditorControlFactory.Register<URLEditorControl, URLEditor>();
- }
-
- private TextBox Editor;
- public override void Configure()
- {
- }
- protected override FrameworkElement CreateEditor()
- {
- var dock = new DockPanel
- {
- VerticalAlignment = VerticalAlignment.Stretch,
- HorizontalAlignment = HorizontalAlignment.Stretch
- };
- var button = new Button
- {
- Content = "Go",
- VerticalAlignment = VerticalAlignment.Stretch,
- VerticalContentAlignment = VerticalAlignment.Center,
- Padding = new Thickness(5, 0, 5, 0)
- };
- button.Click += (o, e) => { Process.Start(new ProcessStartInfo(Editor.Text) { UseShellExecute = true }); };
- button.SetValue(DockPanel.DockProperty, Dock.Right);
- dock.Children.Add(button);
- Editor = new TextBox
- {
- VerticalAlignment = VerticalAlignment.Stretch,
- VerticalContentAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Stretch,
- Margin = new Thickness(0, 0, 5, 0)
- };
- Editor.SetValue(DockPanel.DockProperty, Dock.Left);
- Editor.TextChanged += (o, e) => { CheckChanged(); };
- dock.Children.Add(Editor);
- return dock;
- }
- public override int DesiredHeight()
- {
- return 25;
- }
- public override int DesiredWidth()
- {
- return int.MaxValue;
- }
- protected override string RetrieveValue()
- {
- return Editor.Text;
- }
- protected override void UpdateValue(string value)
- {
- Editor.Text = value;
- }
- public override void SetFocus()
- {
- Editor.Focus();
- }
- public override void SetColor(Color color)
- {
- Editor.Background = new SolidColorBrush(color);
- }
- }
- }
|