diff --git a/src/WPFDevelopers.Net40/Themes/Generic.xaml b/src/WPFDevelopers.Net40/Themes/Generic.xaml
index b072b455..33eab55c 100644
--- a/src/WPFDevelopers.Net40/Themes/Generic.xaml
+++ b/src/WPFDevelopers.Net40/Themes/Generic.xaml
@@ -10,6 +10,7 @@
+
diff --git a/src/WPFDevelopers.Net40/Themes/Theme.xaml b/src/WPFDevelopers.Net40/Themes/Theme.xaml
index 7df9edca..7ead93bd 100644
--- a/src/WPFDevelopers.Net40/Themes/Theme.xaml
+++ b/src/WPFDevelopers.Net40/Themes/Theme.xaml
@@ -749,6 +749,7 @@
+
@@ -1814,10 +1815,10 @@
-
+
@@ -6176,7 +6177,7 @@
-
+
@@ -6354,7 +6355,7 @@
-
+
@@ -6378,6 +6379,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml
new file mode 100644
index 00000000..3be14a28
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml.cs
new file mode 100644
index 00000000..70eb50c5
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/IPEditBoxExample.xaml.cs
@@ -0,0 +1,23 @@
+using System.Windows;
+using System.Windows.Controls;
+using WPFDevelopers.Controls;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// BarrageExample.xaml 的交互逻辑
+ ///
+ public partial class IPEditBoxExample : UserControl
+ {
+ public IPEditBoxExample()
+ {
+ InitializeComponent();
+ }
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var text = myIPEditBox.Text;
+ if (!string.IsNullOrWhiteSpace(text))
+ Message.Push(text, MessageBoxImage.Information);
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/AMapTitleLayer.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/AMapTitleLayer.cs
index d30cb641..2734543a 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/AMapTitleLayer.cs
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/AMapTitleLayer.cs
@@ -5,9 +5,11 @@ namespace WPFDevelopers.Samples.ExampleViews
{
public class AMapTitleLayer : MapTileLayer
{
+ private AMapTileSource tileSource;
public AMapTitleLayer()
{
- TileSource = new AMapTileSource();
+ tileSource = new AMapTileSource();
+ TileSource = tileSource;
}
public string UriFormat
@@ -15,13 +17,23 @@ public string UriFormat
get { return TileSource.UriFormat; }
set { TileSource.UriFormat = value; }
}
+ public void UpdateTileSourceStyle(int style)
+ {
+ tileSource.UpdateStyle(style);
+ }
}
public class AMapTileSource : TileSource
{
+ private int style = 7;
public override Uri GetUri(int x, int y, int zoomLevel)
{
- string url = string.Format("http://wprd01.is.autonavi.com/appmaptile?x={0}&y={1}&z={2}&lang=zh_cn&size=1&scl=1&style=7", x, y, zoomLevel);
+ string url = string.Format("http://wprd01.is.autonavi.com/appmaptile?x={0}&y={1}&z={2}&lang=zh_cn&size=1&scl=1&style={3}", x, y, zoomLevel, style);
return new Uri(url, UriKind.Absolute);
}
+ public void UpdateStyle(int newStyle)
+ {
+ if (newStyle == style) return;
+ style = newStyle;
+ }
}
}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml
index 3ab54fd1..87f35deb 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml
@@ -1,24 +1,35 @@
-
+
-
-
-
-
+
+
+
+
-
-
+
+
@@ -26,25 +37,38 @@
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml.cs
index e8aa5e32..8ec6b7ab 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml.cs
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/Map/BingAMapExample.xaml.cs
@@ -21,6 +21,7 @@ public partial class BingAMapExample : UserControl
private Pushpin carPushpin;
private DispatcherTimer dispatcherTimer;
private List locations;
+ private AMapTitleLayer aMapTitleLayer;
public IEnumerable PushpinArray
{
@@ -31,9 +32,27 @@ public IEnumerable PushpinArray
public static readonly DependencyProperty PushpinArrayProperty =
DependencyProperty.Register("PushpinArray", typeof(IEnumerable), typeof(BingAMapExample), new PropertyMetadata(null));
+
+
+ public Dictionary MapStyleDic
+ {
+ get { return (Dictionary)GetValue(MapStyleDicProperty); }
+ set { SetValue(MapStyleDicProperty, value); }
+ }
+
+ public static readonly DependencyProperty MapStyleDicProperty =
+ DependencyProperty.Register("MapStyleDic", typeof(Dictionary), typeof(BingAMapExample), new PropertyMetadata());
+
+
+
public BingAMapExample()
{
InitializeComponent();
+ MapStyleDic = new Dictionary();
+ MapStyleDic.Add(6, "卫星地图");
+ MapStyleDic.Add(7, "标准地图");
+ MapStyleDic.Add(8, "主道路名称");
+
var pushpins = new List();
pushpins.Add(new PushpinModel { ID = 1, Location = new Location(39.8151940395589, 116.411970893135), Title = "和义东里社区" });
pushpins.Add(new PushpinModel { ID = 2, Location = new Location(39.9094878843105, 116.33299936282), Title = "中国水科院南小区" });
@@ -106,9 +125,8 @@ private void BtnCar_Click(object sender, RoutedEventArgs e)
}
private void Map_MouseDown(object sender, MouseButtonEventArgs e)
{
- Point mousePosition = e.GetPosition(this);
- Location pinLocation = this.map.ViewportPointToLocation(mousePosition);
-
+ var mousePosition = e.GetPosition(this);
+ var pinLocation = this.map.ViewportPointToLocation(mousePosition);
//Console.WriteLine(pinLocation);
}
@@ -127,5 +145,18 @@ private void PART_Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
map.Center = model.Location;
map.ZoomLevel = 16;
}
+
+ private void StyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ var combobox = sender as ComboBox;
+ if (combobox == null) return;
+ var select = (int)combobox.SelectedValue;
+ if(aMapTitleLayer != null)
+ map.Children.Remove(aMapTitleLayer);
+ aMapTitleLayer = new AMapTitleLayer();
+ aMapTitleLayer.UpdateTileSourceStyle(select);
+ map.Children.Insert(0, aMapTitleLayer);
+ }
+
}
}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ThumbDragAndAngleExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/ThumbDragAndAngleExample.xaml.cs
deleted file mode 100644
index c067a22e..00000000
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ThumbDragAndAngleExample.xaml.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Windows.Controls;
-using System.Windows.Documents;
-using WPFDevelopers.Samples.Controls;
-
-namespace WPFDevelopers.Samples.ExampleViews
-{
- ///
- /// ThumbDragAndAngleExample.xaml 的交互逻辑
- ///
- public partial class ThumbDragAndAngleExample : UserControl
- {
- public ThumbDragAndAngleExample()
- {
- InitializeComponent();
- Loaded += delegate
- {
- var al = AdornerLayer.GetAdornerLayer(_border);
- al.Add(new ElementAdorner(_border));
- };
- }
- }
-}
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ThumbDragAndAngleExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml
similarity index 59%
rename from src/WPFDevelopers.Samples.Shared/ExampleViews/ThumbDragAndAngleExample.xaml
rename to src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml
index bfb3f19c..0b6dd36b 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ThumbDragAndAngleExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml
@@ -1,5 +1,5 @@
-
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml.cs
new file mode 100644
index 00000000..82a762eb
--- /dev/null
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/TransformThumbExample.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace WPFDevelopers.Samples.ExampleViews
+{
+ ///
+ /// TransformThumbExample.xaml 的交互逻辑
+ ///
+ public partial class TransformThumbExample : UserControl
+ {
+ public TransformThumbExample()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
index 851fa925..36e787f9 100644
--- a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
+++ b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
@@ -19,7 +19,7 @@ public enum MenuEnum
CropAvatar,
AnimationAudio,
AMap,
- ThumbAngle,
+ TransformThumb,
VerifyCode,
CircularMenu,
ChatEmoji,
@@ -77,6 +77,7 @@ public enum MenuEnum
PathIcon,
NumericBox,
ColorPicker,
+ IPEditBox,
VirtualizingWrapPanel,
AcrylicBlur,
TaskbarInfo
diff --git a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
index 09cd2d7d..f4245a49 100644
--- a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
+++ b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
@@ -126,8 +126,8 @@ void MenuItemSelection(string _menuName)
case MenuEnum.AMap:
ControlPanel = new BingAMapExample();
break;
- case MenuEnum.ThumbAngle:
- ControlPanel = new ThumbDragAndAngleExample();
+ case MenuEnum.TransformThumb:
+ ControlPanel = new TransformThumbExample();
break;
case MenuEnum.VerifyCode:
ControlPanel = new VerifyCodeExample();
@@ -309,6 +309,9 @@ void MenuItemSelection(string _menuName)
case MenuEnum.ColorPicker:
ControlPanel = new ColorPickerExample();
break;
+ case MenuEnum.IPEditBox:
+ ControlPanel = new IPEditBoxExample();
+ break;
case MenuEnum.VirtualizingWrapPanel:
ControlPanel = new VirtualizingWrapPanel();
new VirtualizingWrapPanelExample().MaskShowDialog();
diff --git a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems
index 6f64919b..48c0caa6 100644
--- a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems
+++ b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems
@@ -27,6 +27,7 @@
+
@@ -181,6 +182,9 @@
Code
EdgeLightExample.xaml
+
+ IPEditBoxExample.xaml
+
Code
LineChartExample.xaml
@@ -390,9 +394,9 @@
Code
ThermometerExample.xaml
-
+
Code
- ThumbDragAndAngleExample.xaml
+ TransformThumbExample.xaml
Code
@@ -463,6 +467,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -627,6 +635,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -856,7 +868,7 @@
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
diff --git a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
index 7734d0f6..d5907f66 100644
--- a/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
+++ b/src/WPFDevelopers.Samples40/WPFDevelopers.Samples40.csproj
@@ -32,8 +32,9 @@
-
+
+
WPFDevelopers.ico
diff --git a/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj b/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj
index bac8f4b1..ddff65be 100644
--- a/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj
+++ b/src/WPFDevelopers.Samples45x/WPFDevelopers.Samples45x.csproj
@@ -13,7 +13,7 @@
..\WPFDevelopers.Samples.Shared\WPFDevelopers.ico
-
+
diff --git a/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj b/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj
index 019b1b5b..3021e36b 100644
--- a/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj
+++ b/src/WPFDevelopers.SamplesCode/WPFDevelopers.SamplesCode.csproj
@@ -83,7 +83,6 @@
-
@@ -130,6 +129,7 @@
+
@@ -139,6 +139,8 @@
+
+
@@ -358,8 +360,8 @@
ExampleViews\ThermometerExample.xaml
-
- ExampleViews\ThumbDragAndAngleExample.xaml
+
+ ExampleViews\TransformThumbExample.xaml
ExampleViews\TimeLineExample.xaml
@@ -417,6 +419,9 @@
Controls\Others\OtherControl.xaml
+
+ Controls\ElementAdorner\TransformThumb.xaml
+
Controls\ChatEmoji\ChatEmoji.xaml
@@ -468,5 +473,8 @@
ExampleViews\ColorPickerExample.xaml
+
+ ExampleViews\IPEditBoxExample.xaml
+
diff --git a/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs b/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs
new file mode 100644
index 00000000..a3f81977
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Controls/IPEditBox/IPEditBox.cs
@@ -0,0 +1,197 @@
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace WPFDevelopers.Controls
+{
+ [TemplatePart(Name = TextBox1TemplateName, Type = typeof(TextBox))]
+ [TemplatePart(Name = TextBox2TemplateName, Type = typeof(TextBox))]
+ [TemplatePart(Name = TextBox3TemplateName, Type = typeof(TextBox))]
+ [TemplatePart(Name = TextBox4TemplateName, Type = typeof(TextBox))]
+ public class IPEditBox : Control
+ {
+ private const string TextBox1TemplateName = "PART_TextBox1";
+ private const string TextBox2TemplateName = "PART_TextBox2";
+ private const string TextBox3TemplateName = "PART_TextBox3";
+ private const string TextBox4TemplateName = "PART_TextBox4";
+ public string Text
+ {
+ get { return (string)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+
+ public static readonly DependencyProperty TextProperty =
+ DependencyProperty.Register("Text", typeof(string), typeof(IPEditBox), new PropertyMetadata(string.Empty, OnTextChanged));
+
+ private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var ctrl = d as IPEditBox;
+ if (e.NewValue is string text && !ctrl._isChangingText)
+ ctrl.PasteTextIPTextBox(text);
+ }
+
+ private TextBox _textBox1, _textBox2, _textBox3, _textBox4;
+ private bool _isChangingText = false;
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ _textBox1 = GetTemplateChild(TextBox1TemplateName) as TextBox;
+ if (_textBox1 != null)
+ {
+ _textBox1.TextChanged -= TextBox1_TextChanged;
+ _textBox1.TextChanged += TextBox1_TextChanged;
+ _textBox1.PreviewKeyDown -= TextBox_PreviewKeyDown;
+ _textBox1.PreviewKeyDown += TextBox_PreviewKeyDown;
+ _textBox1.Loaded -= TextBox_Loaded;
+ _textBox1.Loaded += TextBox_Loaded;
+ }
+ _textBox2 = GetTemplateChild(TextBox2TemplateName) as TextBox;
+ if (_textBox2 != null)
+ {
+ _textBox2.TextChanged -= TextBox2_TextChanged;
+ _textBox2.TextChanged += TextBox2_TextChanged;
+ _textBox2.PreviewKeyDown -= TextBox_PreviewKeyDown;
+ _textBox2.PreviewKeyDown += TextBox_PreviewKeyDown;
+ _textBox2.Loaded -= TextBox_Loaded; ;
+ _textBox2.Loaded += TextBox_Loaded;
+ }
+ _textBox3 = GetTemplateChild(TextBox3TemplateName) as TextBox;
+ if (_textBox3 != null)
+ {
+ _textBox3.TextChanged -= TextBox3_TextChanged;
+ _textBox3.TextChanged += TextBox3_TextChanged;
+ _textBox3.PreviewKeyDown -= TextBox_PreviewKeyDown;
+ _textBox3.PreviewKeyDown += TextBox_PreviewKeyDown;
+ _textBox3.Loaded -= TextBox_Loaded;
+ _textBox3.Loaded += TextBox_Loaded;
+ }
+ _textBox4 = GetTemplateChild(TextBox4TemplateName) as TextBox;
+ _textBox4.TextChanged -= TextBox4_TextChanged;
+ _textBox4.TextChanged += TextBox4_TextChanged;
+ _textBox4.PreviewKeyDown -= TextBox_PreviewKeyDown;
+ _textBox4.PreviewKeyDown += TextBox_PreviewKeyDown;
+ _textBox4.Loaded -= TextBox_Loaded;
+ _textBox4.Loaded += TextBox_Loaded;
+
+ }
+
+ private void TextBox1_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (_textBox1.Text.ToString().Length >= 3) _textBox2.Focus();
+ UpdateText();
+ }
+ private void TextBox2_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (_textBox2.Text.ToString().Length >= 3) _textBox3.Focus();
+ UpdateText();
+ }
+
+ private void TextBox3_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (_textBox3.Text.ToString().Length >= 3) _textBox4.Focus();
+ UpdateText();
+ }
+
+ private void TextBox4_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ UpdateText();
+ }
+ void TextBox_Loaded(object sender, RoutedEventArgs e)
+ {
+ CommandManager.AddPreviewExecutedHandler((sender as TextBox), TextBox_PreviewExecuted);
+ }
+ void TextBox_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Command == ApplicationCommands.Paste)
+ {
+ ClipboardHandle();
+ UpdateText();
+ e.Handled = true;
+ }
+ else if (e.Command == ApplicationCommands.Copy)
+ {
+ var ip = $"{_textBox1.Text}.{_textBox2.Text}.{_textBox3.Text}.{_textBox4.Text}";
+ Clipboard.SetText(ip);
+ e.Handled = true;
+ }
+ }
+
+ void ClipboardHandle()
+ {
+ var data = Clipboard.GetDataObject();
+ if (data.GetDataPresent(DataFormats.Text))
+ {
+ var text = (string)data.GetData(DataFormats.UnicodeText);
+ PasteTextIPTextBox(text);
+ }
+ }
+
+ void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.V)
+ {
+ ClipboardHandle();
+ _isChangingText = false;
+ e.Handled = true;
+ }
+ else if (e.Key == Key.Delete || e.Key == Key.Back)
+ {
+ _isChangingText = true;
+ }
+ else
+ _isChangingText = false;
+ }
+
+ void PasteTextIPTextBox(string text)
+ {
+ _textBox1.TextChanged -= TextBox1_TextChanged;
+ _textBox2.TextChanged -= TextBox2_TextChanged;
+ _textBox3.TextChanged -= TextBox3_TextChanged;
+ _textBox4.TextChanged -= TextBox4_TextChanged;
+ if (string.IsNullOrWhiteSpace(text))
+ {
+ _textBox1.Text = string.Empty;
+ _textBox2.Text = string.Empty;
+ _textBox3.Text = string.Empty;
+ _textBox4.Text = string.Empty;
+ }
+ else
+ {
+ var strs = text.Split('.');
+ var _textboxBoxes = new TextBox[] { _textBox1, _textBox2, _textBox3, _textBox4 };
+ for (short i = 0; i < _textboxBoxes.Length; i++)
+ {
+ var str = i < strs.Length ? strs[i] : string.Empty;
+ _textboxBoxes[i].Text = str;
+ }
+ }
+ _textBox1.TextChanged += TextBox1_TextChanged;
+ _textBox2.TextChanged += TextBox2_TextChanged;
+ _textBox3.TextChanged += TextBox3_TextChanged;
+ _textBox4.TextChanged += TextBox4_TextChanged;
+ }
+ void UpdateText()
+ {
+ var segments = new string[4]
+ {
+ _textBox1.Text.Trim(),
+ _textBox2.Text.Trim(),
+ _textBox3.Text.Trim(),
+ _textBox4.Text.Trim()
+ };
+ var allEmpty = segments.All(string.IsNullOrEmpty);
+ if (allEmpty)
+ {
+ SetValue(TextProperty, string.Empty);
+ return;
+ }
+ var noEmpty = segments.Where(s => !string.IsNullOrWhiteSpace(s));
+ if (noEmpty.Count() != 4) return;
+ var ip = string.Join(".", noEmpty);
+ if (ip != Text)
+ SetValue(TextProperty, ip);
+ }
+ }
+}
diff --git a/src/WPFDevelopers.Shared/Core/Helpers/TextBoxHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/TextBoxHelper.cs
index 3555636e..ba430a18 100644
--- a/src/WPFDevelopers.Shared/Core/Helpers/TextBoxHelper.cs
+++ b/src/WPFDevelopers.Shared/Core/Helpers/TextBoxHelper.cs
@@ -20,11 +20,19 @@ public static class TextBoxHelper
DependencyProperty.RegisterAttached("IsEnterUpdateEnabled", typeof(bool), typeof(TextBoxHelper),
new PropertyMetadata(false, OnIsEnterUpdateEnabledChanged));
+ public static readonly DependencyProperty MinValueProperty =
+ DependencyProperty.RegisterAttached("MinValue", typeof(int), typeof(TextBoxHelper),
+ new PropertyMetadata(int.MinValue, OnMinMaxValueChanged));
+
+ public static readonly DependencyProperty MaxValueProperty =
+ DependencyProperty.RegisterAttached("MaxValue", typeof(int), typeof(TextBoxHelper),
+ new PropertyMetadata(int.MaxValue, OnMinMaxValueChanged));
+
private static void OnSelectAllOnClickChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TextBox textBox)
{
- if ((bool) e.NewValue)
+ if ((bool)e.NewValue)
textBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown;
else
textBox.PreviewMouseLeftButtonDown -= TextBox_PreviewMouseLeftButtonDown;
@@ -35,7 +43,7 @@ private static void OnAllowOnlyNumericInputChanged(DependencyObject d, Dependenc
{
if (d is TextBox textBox)
{
- if ((bool) e.NewValue)
+ if ((bool)e.NewValue)
{
DataObject.AddPastingHandler(textBox, TextBox_Pasting);
textBox.PreviewTextInput += TextBox_PreviewTextInput;
@@ -54,7 +62,7 @@ private static void OnIsEnterUpdateEnabledChanged(DependencyObject d, Dependency
{
if (d is TextBox textBox)
{
- if ((bool) e.NewValue)
+ if ((bool)e.NewValue)
textBox.PreviewKeyDown += TextBox_PreviewKeyDown;
else
textBox.PreviewKeyDown -= TextBox_PreviewKeyDown;
@@ -63,7 +71,7 @@ private static void OnIsEnterUpdateEnabledChanged(DependencyObject d, Dependency
public static bool GetSelectAllOnClick(TextBox textBox)
{
- return (bool) textBox.GetValue(SelectAllOnClickProperty);
+ return (bool)textBox.GetValue(SelectAllOnClickProperty);
}
public static void SetSelectAllOnClick(TextBox textBox, bool value)
@@ -73,7 +81,7 @@ public static void SetSelectAllOnClick(TextBox textBox, bool value)
public static bool GetAllowOnlyNumericInput(DependencyObject obj)
{
- return (bool) obj.GetValue(AllowOnlyNumericInputProperty);
+ return (bool)obj.GetValue(AllowOnlyNumericInputProperty);
}
public static void SetAllowOnlyNumericInput(DependencyObject obj, bool value)
@@ -83,7 +91,7 @@ public static void SetAllowOnlyNumericInput(DependencyObject obj, bool value)
public static bool GetIsEnterUpdateEnabled(DependencyObject obj)
{
- return (bool) obj.GetValue(IsEnterUpdateEnabledProperty);
+ return (bool)obj.GetValue(IsEnterUpdateEnabledProperty);
}
public static void SetIsEnterUpdateEnabled(DependencyObject obj, bool value)
@@ -91,6 +99,75 @@ public static void SetIsEnterUpdateEnabled(DependencyObject obj, bool value)
obj.SetValue(IsEnterUpdateEnabledProperty, value);
}
+ public static int GetMinValue(DependencyObject obj)
+ {
+ return (int)obj.GetValue(MinValueProperty);
+ }
+
+ public static void SetMinValue(DependencyObject obj, int value)
+ {
+ obj.SetValue(MinValueProperty, value);
+ }
+
+ public static int GetMaxValue(DependencyObject obj)
+ {
+ return (int)obj.GetValue(MaxValueProperty);
+ }
+
+ public static void SetMaxValue(DependencyObject obj, int value)
+ {
+ obj.SetValue(MaxValueProperty, value);
+ }
+
+ private static void OnMinMaxValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is TextBox textBox)
+ {
+ textBox.TextChanged -= TextBox_TextChanged;
+ textBox.TextChanged += TextBox_TextChanged;
+ textBox.PreviewTextInput -= TextBoxMinMaxValue_PreviewTextInput;
+ textBox.PreviewTextInput += TextBoxMinMaxValue_PreviewTextInput;
+ }
+ }
+
+ private static void TextBoxMinMaxValue_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if (sender is TextBox textBox)
+ {
+ int minValue = GetMinValue(textBox);
+ int maxValue = GetMaxValue(textBox);
+ if (textBox.SelectionLength == textBox.Text.Length) return;
+ if (!int.TryParse(textBox.Text + e.Text, out int value))
+ {
+ e.Handled = true;
+ }
+ else
+ {
+ if (value < minValue || value > maxValue)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+ }
+ private static void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (sender is TextBox textBox)
+ {
+ var minValue = GetMinValue(textBox);
+ var maxValue = GetMaxValue(textBox);
+ if (!int.TryParse(textBox.Text, out int value))
+ textBox.Text = "";
+ else
+ {
+ if (value < minValue)
+ textBox.Text = minValue.ToString();
+ else if (value > maxValue)
+ textBox.Text = maxValue.ToString();
+ }
+ }
+ }
+
private static void TextBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is TextBox textBox && !textBox.IsKeyboardFocusWithin)
@@ -106,7 +183,7 @@ private static void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(string)))
{
- var text = (string) e.DataObject.GetData(typeof(string));
+ var text = (string)e.DataObject.GetData(typeof(string));
if (!IsNumeric(text)) e.CancelCommand();
}
@@ -139,7 +216,7 @@ private static void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter && !e.IsRepeat)
{
- var textBox = (TextBox) sender;
+ var textBox = (TextBox)sender;
var expression = textBox.GetBindingExpression(TextBox.TextProperty);
expression?.UpdateSource();
}
diff --git a/src/WPFDevelopers.Shared/Styles/Styles.ComboBox.xaml b/src/WPFDevelopers.Shared/Styles/Styles.ComboBox.xaml
index 5e851f8f..7fc0ddd6 100644
--- a/src/WPFDevelopers.Shared/Styles/Styles.ComboBox.xaml
+++ b/src/WPFDevelopers.Shared/Styles/Styles.ComboBox.xaml
@@ -132,14 +132,6 @@
CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
SnapsToDevicePixels="True">
-
+
diff --git a/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml b/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml
new file mode 100644
index 00000000..d721465e
--- /dev/null
+++ b/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Themes/NumericBox.xaml b/src/WPFDevelopers.Shared/Themes/NumericBox.xaml
index d3e825f6..be3e5677 100644
--- a/src/WPFDevelopers.Shared/Themes/NumericBox.xaml
+++ b/src/WPFDevelopers.Shared/Themes/NumericBox.xaml
@@ -86,7 +86,8 @@
Padding="0"
Command="{x:Static controls:NumericBox.DecreaseCommand}"
Delay="{TemplateBinding Delay}"
- IsTabStop="False">
+ IsTabStop="False"
+ Style="{StaticResource WD.DefaultRepeatButton}">
diff --git a/src/WPFDevelopers.Shared/Themes/Theme40.txt b/src/WPFDevelopers.Shared/Themes/Theme40.txt
index 182f11ff..c4dabf30 100644
--- a/src/WPFDevelopers.Shared/Themes/Theme40.txt
+++ b/src/WPFDevelopers.Shared/Themes/Theme40.txt
@@ -66,4 +66,5 @@ CropImage.xaml
Message.xaml
PathIcon.xaml
NumericBox.xaml
-ColorPicker.xaml
\ No newline at end of file
+ColorPicker.xaml
+IPEditBox.xaml
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/Themes/Theme45x.txt b/src/WPFDevelopers.Shared/Themes/Theme45x.txt
index 72698657..a39fa68e 100644
--- a/src/WPFDevelopers.Shared/Themes/Theme45x.txt
+++ b/src/WPFDevelopers.Shared/Themes/Theme45x.txt
@@ -67,4 +67,5 @@ CropImage.xaml
Message.xaml
PathIcon.xaml
NumericBox.xaml
-ColorPicker.xaml
\ No newline at end of file
+ColorPicker.xaml
+IPEditBox.xaml
\ No newline at end of file
diff --git a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems
index 3a2ea469..9d00e2c1 100644
--- a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems
+++ b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems
@@ -12,6 +12,7 @@
+
@@ -448,6 +449,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer