123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Diagnostics;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- namespace InABox.DynamicGrid
- {
- public class URLEditorControl : DynamicEditorControl<string>
- {
- private TextBox Editor;
- 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);
- }
- }
- }
|