diff --git a/CLinerStyle/CLinerStylec 001.7z b/CLinerStyle/CLinerStylec 001.7z
new file mode 100644
index 0000000..d20b6f6
Binary files /dev/null and b/CLinerStyle/CLinerStylec 001.7z differ
diff --git a/CLinerStyle/src/CLinerStyle.sln b/CLinerStyle/src/CLinerStyle.sln
new file mode 100644
index 0000000..7f629fa
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CLinerStyle", "CLinerStyle\CLinerStyle.csproj", "{2CFD8A97-FFB8-47D2-9EB2-450B98FED28E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2CFD8A97-FFB8-47D2-9EB2-450B98FED28E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2CFD8A97-FFB8-47D2-9EB2-450B98FED28E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2CFD8A97-FFB8-47D2-9EB2-450B98FED28E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2CFD8A97-FFB8-47D2-9EB2-450B98FED28E}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/CLinerStyle/src/CLinerStyle.v12.suo b/CLinerStyle/src/CLinerStyle.v12.suo
new file mode 100644
index 0000000..985861b
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle.v12.suo differ
diff --git a/CLinerStyle/src/CLinerStyle/CLinerStyle.csproj b/CLinerStyle/src/CLinerStyle/CLinerStyle.csproj
new file mode 100644
index 0000000..342c7a8
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/CLinerStyle.csproj
@@ -0,0 +1,127 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {2CFD8A97-FFB8-47D2-9EB2-450B98FED28E}
+ Library
+ Properties
+ CLinerStyle
+ CLinerStyle
+ v4.5
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\..\..\Control\LibControl\Controls\bin\Debug\Lib.Controls.MyControls.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cs_Slider.xaml
+
+
+ Cs_Spinner.xaml
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Properties/AssemblyInfo.cs b/CLinerStyle/src/CLinerStyle/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..c5a10eb
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CLinerStyle")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CLinerStyle")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8d6deeaa-a283-4c47-ad25-8d4bfade470b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/CLinerStyle/src/CLinerStyle/Themes/Border.xaml b/CLinerStyle/src/CLinerStyle/Themes/Border.xaml
new file mode 100644
index 0000000..b9c1905
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/Border.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/Button.xaml b/CLinerStyle/src/CLinerStyle/Themes/Button.xaml
new file mode 100644
index 0000000..9498b78
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/Button.xaml
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/CheckBox.xaml b/CLinerStyle/src/CLinerStyle/Themes/CheckBox.xaml
new file mode 100644
index 0000000..acf4863
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/CheckBox.xaml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/CircleLabelStyle.xaml b/CLinerStyle/src/CLinerStyle/Themes/CircleLabelStyle.xaml
new file mode 100644
index 0000000..29f19c4
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/CircleLabelStyle.xaml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/ComboBox.xaml b/CLinerStyle/src/CLinerStyle/Themes/ComboBox.xaml
new file mode 100644
index 0000000..2746389
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/ComboBox.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/CsColor.xaml b/CLinerStyle/src/CLinerStyle/Themes/CsColor.xaml
new file mode 100644
index 0000000..0636663
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/CsColor.xaml
@@ -0,0 +1,7 @@
+
+ #ff808080
+ #ff454545
+ #ff676767
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/Cs_Slider.xaml b/CLinerStyle/src/CLinerStyle/Themes/Cs_Slider.xaml
new file mode 100644
index 0000000..40093cc
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/Cs_Slider.xaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CLinerStyle/src/CLinerStyle/Themes/Cs_Slider.xaml.cs b/CLinerStyle/src/CLinerStyle/Themes/Cs_Slider.xaml.cs
new file mode 100644
index 0000000..3263823
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/Cs_Slider.xaml.cs
@@ -0,0 +1,170 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace CLinerStyle
+{
+ ///
+ /// Cs_Slider.xaml 的互動邏輯
+ ///
+ public partial class Cs_Slider : UserControl
+ {
+ public double thumbHeight = 36;
+ public double thumbWidth = 20;
+ public static int DefaultMaximun = 100;
+ public static int DefaultMinimun = 0;
+ public static int DefaultValueNum = 0;
+ public static double Cs_SliderHeight;
+ public Cs_Slider()
+ {
+ InitializeComponent();
+ thumb.Height = thumbHeight;
+ thumb.Width = thumbWidth;
+ }
+ public int Maximun
+ {
+ get
+ {
+ return (int)this.GetValue(Cs_Slider.MaximunProperty);
+ }
+ set
+ {
+ this.SetValue(Cs_Slider.MaximunProperty, (object)value);
+ }
+ }
+ public static readonly DependencyProperty MaximunProperty =
+ DependencyProperty.Register("Maximun", typeof(int), typeof(Cs_Slider), new PropertyMetadata(DefaultMaximun, null));
+
+ public int Minimun
+ {
+ get
+ {
+ return (int)this.GetValue(Cs_Slider.MinimunProperty);
+ }
+ set
+ {
+ this.SetValue(Cs_Slider.MinimunProperty, (object)value);
+ }
+ }
+ public static readonly DependencyProperty MinimunProperty =
+ DependencyProperty.Register("Minimun", typeof(int), typeof(Cs_Slider), new PropertyMetadata(DefaultMinimun, null));
+
+
+
+ public static readonly DependencyProperty thumbProperty = DependencyProperty.Register("imagethumb", typeof(ImageSource), typeof(Cs_Slider), (PropertyMetadata)new FrameworkPropertyMetadata((object)null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(Cs_Slider.onThumbChange)));
+
+ public ImageSource imagethumb
+ {
+ get
+ {
+ return (ImageSource)this.GetValue(Cs_Slider.thumbProperty);
+ }
+ set
+ {
+ this.SetValue(Cs_Slider.thumbProperty, (object)value);
+ }
+ }
+ private static void onThumbChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ Cs_Slider Cs_Slider = obj as Cs_Slider;
+ if (Cs_Slider == null)
+ return;
+
+ //Cs_Slider.recaculateThumb();
+ //Cs_Slider.recaculate();
+ Cs_Slider.InvalidateVisual();
+ }
+
+ public delegate void Cs_SliderValueChanged(Object sender, int value);
+ public event Cs_SliderValueChanged OnKaCs_SliderValueChanged;
+ public int ValueNum
+ {
+ get
+ {
+ return (int)this.GetValue(ValueChangedPropertyProperty);
+ }
+ set
+ {
+ this.SetValue(ValueChangedPropertyProperty, (object)value);
+ }
+ }
+ //private static readonly DependencyProperty ValueChangedPropertyProperty = DependencyProperty.Register("ValueNum", typeof(int), typeof(Cs_Slider), (PropertyMetadata)new FrameworkPropertyMetadata((object)0, FrameworkPropertyMetadataOptions.None, new PropertyChangedCallback(OnValueChanged)));
+ public static readonly DependencyProperty ValueChangedPropertyProperty =
+ DependencyProperty.Register("ValueNum", typeof(int), typeof(Cs_Slider), new PropertyMetadata(DefaultValueNum, OnValueChanged));
+
+ private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+
+ //int newValue = (int)e.NewValue;
+ Cs_Slider ks = d as Cs_Slider;
+ //ks.thumb.Margin = new Thickness(0, (ks.ValueNum - ks.Minimun) * Cs_SliderHeight / (ks.Maximun - ks.Minimun), 0, 0);
+ ks.InvalidateVisual();
+ }
+ SolidColorBrush BRUSHES = new SolidColorBrush(Color.FromArgb(0xFF, 0x6B, 0x6B, 0x6B));
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double actualWidth = this.ActualWidth;
+ double actualHeight = this.ActualHeight;
+ //Pen pen2 = new Pen(Brushes.Black, 2);
+ //pen2.Freeze();
+ //dc.DrawRoundedRectangle(null, pen2, new Rect(this.ActualWidth / 2 - 4, 19, 8, this.ActualHeight - 38), 3, 3);
+
+ //Pen pen3 = new Pen(Brushes.Black, 2);
+ //pen3.Freeze();
+ //dc.DrawRoundedRectangle(null, pen3, new Rect(this.ActualWidth / 2 - 6, 17, 12, this.ActualHeight - 34), 3, 3);
+
+ LinearGradientBrush lgb = new LinearGradientBrush();
+ lgb.EndPoint = new Point(1, 0.5);
+ lgb.StartPoint = new Point(0, 0.5);
+ GradientStop gs = new GradientStop();
+ gs.Color = Color.FromArgb(0xff, 0x78, 0x78, 0x78);
+ gs.Offset = 0;
+ //GradientStop gs3 = new GradientStop();
+ //gs3.Color = Color.FromArgb(0xff, 0x3E, 0x3E, 0x3E);
+ //gs3.Offset = 1;
+ GradientStop gs2 = new GradientStop();
+ gs2.Color = Color.FromArgb(0xff, 0x29, 0x29, 0x29);
+ gs2.Offset = 0.6;
+ lgb.GradientStops.Add(gs);
+ lgb.GradientStops.Add(gs2);
+ //lgb.GradientStops.Add(gs3);
+ Pen pen = new Pen(BRUSHES, 2);
+ pen.Freeze();
+ dc.DrawRoundedRectangle(lgb, null, new Rect(this.ActualWidth / 2 - 5, 18, 10, this.ActualHeight - 36), 3, 3);
+ //动态更改长度后重新计算长度
+ Cs_SliderHeight = this.ActualHeight - 36;
+ this.thumb.Margin = new Thickness(0, (this.ValueNum - this.Minimun) * Cs_SliderHeight / (this.Maximun - this.Minimun), 0, 0);
+
+ }
+
+ private void thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
+ {
+
+ double top = thumb.Margin.Top + e.VerticalChange;
+ if (top < 0) top = 0;
+ else if (top > Cs_SliderHeight) top = Cs_SliderHeight;
+ ValueNum = (int)((top / Cs_SliderHeight) * (Maximun - Minimun) + Minimun);
+ if (OnKaCs_SliderValueChanged != null) //no by pass
+ {
+ OnKaCs_SliderValueChanged(this, ValueNum);
+ }
+
+ }
+
+ }
+}
+
+
diff --git a/CLinerStyle/src/CLinerStyle/Themes/Cs_Spinner.xaml b/CLinerStyle/src/CLinerStyle/Themes/Cs_Spinner.xaml
new file mode 100644
index 0000000..b314d6d
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/Cs_Spinner.xaml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CLinerStyle/src/CLinerStyle/Themes/Cs_Spinner.xaml.cs b/CLinerStyle/src/CLinerStyle/Themes/Cs_Spinner.xaml.cs
new file mode 100644
index 0000000..a12dfaf
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/Cs_Spinner.xaml.cs
@@ -0,0 +1,284 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Timers;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace CLinerStyle
+{
+ ///
+ /// Cs_Cs_Spinner.xaml 的互動邏輯
+ ///
+ public partial class Cs_Spinner : UserControl
+ {
+ public static int DefaultMaximun = 100;
+ public static int DefaultMinimun = 0;
+ public static int DefaultValueNum = 0;
+ public static RoutedCommand IncreaseCommand { get; set; }
+ public static RoutedCommand DecreaseCommand { get; set; }
+ Timer timer;
+ Timer time = new Timer(500);
+ public Cs_Spinner()
+ {
+ InitializeComponent();
+ Cs_Spinner.IncreaseCommand = new RoutedCommand("IncreaseCommand", typeof(Cs_Spinner));
+ Cs_Spinner.DecreaseCommand = new RoutedCommand("DecreaseCommand", typeof(Cs_Spinner));
+ CommandManager.RegisterClassCommandBinding(typeof(Cs_Spinner), new CommandBinding((ICommand)Cs_Spinner.IncreaseCommand, new ExecutedRoutedEventHandler(Cs_Spinner.OnIncreaseCommand)));
+ CommandManager.RegisterClassCommandBinding(typeof(Cs_Spinner), new CommandBinding((ICommand)Cs_Spinner.DecreaseCommand, new ExecutedRoutedEventHandler(Cs_Spinner.OnDecreaseCommand)));
+ CommandManager.RegisterClassInputBinding(typeof(Cs_Spinner), new InputBinding((ICommand)Cs_Spinner.IncreaseCommand, (InputGesture)new KeyGesture(Key.Up)));
+ CommandManager.RegisterClassInputBinding(typeof(Cs_Spinner), new InputBinding((ICommand)Cs_Spinner.IncreaseCommand, (InputGesture)new KeyGesture(Key.Right)));
+ CommandManager.RegisterClassInputBinding(typeof(Cs_Spinner), new InputBinding((ICommand)Cs_Spinner.DecreaseCommand, (InputGesture)new KeyGesture(Key.Down)));
+ CommandManager.RegisterClassInputBinding(typeof(Cs_Spinner), new InputBinding((ICommand)Cs_Spinner.DecreaseCommand, (InputGesture)new KeyGesture(Key.Left)));
+
+ }
+
+ public string Content1
+ {
+ get { return (string)GetValue(Content1Property); }
+ set { SetValue(Content1Property, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty Content1Property =
+ DependencyProperty.Register("Content1", typeof(string), typeof(Cs_Spinner), null);
+
+ private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ Cs_Spinner ks = d as Cs_Spinner;
+ ks.updatestr();
+ }
+
+
+
+
+ public int Maximun
+ {
+ get
+ {
+ return (int)this.GetValue(Cs_Spinner.MaximunProperty);
+ }
+ set
+ {
+ this.SetValue(Cs_Spinner.MaximunProperty, (object)value);
+ }
+ }
+ public static readonly DependencyProperty MaximunProperty =
+ DependencyProperty.Register("Maximun", typeof(int), typeof(Cs_Spinner), new PropertyMetadata(DefaultMaximun, null));
+
+ public int Minimun
+ {
+ get
+ {
+ return (int)this.GetValue(Cs_Spinner.MinimunProperty);
+ }
+ set
+ {
+ this.SetValue(Cs_Spinner.MinimunProperty, (object)value);
+ }
+ }
+ public static readonly DependencyProperty MinimunProperty =
+ DependencyProperty.Register("Minimun", typeof(int), typeof(Cs_Spinner), new PropertyMetadata(DefaultMinimun, null));
+ public delegate void SliderValueChanged(Object sender, int value);
+ public event SliderValueChanged OnKaSliderValueChanged;
+ public int ValueNum
+ {
+ get
+ {
+ return (int)this.GetValue(ValueChangedPropertyProperty);
+ }
+ set
+ {
+ if ((int)value > Maximun) return;
+ else if ((int)value < Minimun) return;
+ this.SetValue(ValueChangedPropertyProperty, (object)value);
+ }
+ }
+ //private static readonly DependencyProperty ValueChangedPropertyProperty = DependencyProperty.Register("ValueNum", typeof(int), typeof(Ka_Slider), (PropertyMetadata)new FrameworkPropertyMetadata((object)0, FrameworkPropertyMetadataOptions.None, new PropertyChangedCallback(OnValueChanged)));
+ public static readonly DependencyProperty ValueChangedPropertyProperty =
+ DependencyProperty.Register("ValueNum", typeof(int), typeof(Cs_Spinner), new PropertyMetadata(DefaultValueNum, OnValueChanged));
+
+ private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ //Cs_Spinner ks = d as Cs_Spinner;
+ //ks.updatestr();
+ }
+
+ private void Cs_Spinner_Loaded(object sender, RoutedEventArgs e)
+ {
+ updatestr();
+ }
+
+
+
+
+ private void updatestr()
+ {
+ Content1 = ValueNum.ToString();
+ }
+
+
+
+ private void btn_MouseMove(object sender, MouseEventArgs e)
+ {
+
+ }
+ protected static void OnIncreaseCommand(object sender, ExecutedRoutedEventArgs e)
+ {
+ Cs_Spinner Cs_Spinner = sender as Cs_Spinner;
+ if (Cs_Spinner == null)
+ return;
+ Cs_Spinner.OnIncrease();
+ }
+
+ protected void OnIncrease()
+ {
+ ValueNum = ValueNum + 1;
+ //this.Value = Cs_Spinner.LimitValueByBounds(this.Value + this.Change, this);
+ //int cvalue = Math.Max(this.Minimum, Math.Min(this.Maximum, this.Value));
+ //if (this.onSpinValueClickChangeEvent == null)
+ // return;
+ //this.onSpinValueClickChangeEvent((object)this, cvalue, this.UpeqType, this.iTag, new EventArgs());
+ }
+ protected static void OnDecreaseCommand(object sender, ExecutedRoutedEventArgs e)
+ {
+ Cs_Spinner Cs_SpinnerControl = sender as Cs_Spinner;
+ if (Cs_SpinnerControl == null)
+ return;
+ Cs_SpinnerControl.OnDecrease();
+ }
+ protected void OnDecrease()
+ {
+ ValueNum = ValueNum - 1;
+ //this.Value = Cs_SpinnerControl.LimitValueByBounds(this.Value - this.Change, this);
+ //int cvalue = Math.Max(this.Minimum, Math.Min(this.Maximum, this.Value));
+ //if (this.onSpinValueClickChangeEvent == null)
+ // return;
+ //this.onSpinValueClickChangeEvent((object)this, cvalue, this.UpeqType, this.iTag, new EventArgs());
+ }
+ private void btn_PreviewMouseMove(object sender, MouseEventArgs e)
+ {
+ //if (e.LeftButton == MouseButtonState.Pressed)
+ //{
+ // Button btn = sender as Button;
+ // if (Convert.ToInt16(btn.Tag) == 0)
+ // {
+ // ValueNum = ValueNum + 1;
+ // }
+ // else
+ // {
+ // ValueNum = ValueNum - 1;
+ // }
+ //}
+ }
+
+ enum sub_add
+ {
+ Add = 0,
+ Sub = 1
+ }
+ sub_add sa;
+ private void btn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ Button btn = sender as Button;
+
+ if (btn == null)
+ return;
+ //var element = (FrameworkElement)sender;
+ //element.
+ if (Convert.ToInt16(btn.Tag) == 0)
+ {
+ OnIncrease();
+ sa = sub_add.Add;
+ }
+ else
+ {
+ OnDecrease();
+ sa = sub_add.Sub;
+ }
+ if (OnKaSliderValueChanged != null)
+ OnKaSliderValueChanged(this, ValueNum);
+ //isStart = true;
+ //Timer time = new Timer(500);
+ //time.Elapsed += new ElapsedEventHandler((o, ex) => btn.Dispatcher.Invoke(new Action(() =>
+ //{
+ // if (isStart)
+ // {
+
+ // }
+ // time.Stop();
+ // time.Dispose();
+ //})));
+ time = new Timer(500);
+ time.AutoReset = false;
+ time.Elapsed += Time_Elapsed;
+ time.Close();
+ time.Start();
+ }
+ private void Time_Elapsed(object sender, ElapsedEventArgs e)
+ {
+ timer = new Timer();
+ timer.Interval = 50;
+ timer.Elapsed += Timer_Elapsed;
+ timer.Start();
+ }
+ private void btn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (sender == null)
+ return;
+ if (timer != null)
+ {
+ timer.Stop();
+ timer.Dispose();
+ }
+ if (time != null)
+ {
+ time.Stop();
+ time.Dispose();
+ }
+ }
+
+ public delegate void updateDo();
+ public void dtInvoke(updateDo fdo)
+ {
+ this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
+ (System.Threading.ThreadStart)delegate ()
+ {
+ fdo();
+ });
+ }
+
+ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
+ {
+
+ if (sa == sub_add.Add)
+ dtInvoke(() => {
+ if (this.UpBtn.IsPressed == true)
+ {
+ ValueNum = ValueNum + 1; if (OnKaSliderValueChanged != null)
+ OnKaSliderValueChanged(this, ValueNum);
+ }
+ });
+ else
+ dtInvoke(() => {
+ if (this.DownBtn.IsPressed == true)
+ {
+ ValueNum = ValueNum - 1; if (OnKaSliderValueChanged != null)
+ OnKaSliderValueChanged(this, ValueNum);
+ }
+ });
+
+ }
+
+ }
+}
+
diff --git a/CLinerStyle/src/CLinerStyle/Themes/GenericStyle.xaml b/CLinerStyle/src/CLinerStyle/Themes/GenericStyle.xaml
new file mode 100644
index 0000000..25a6c09
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/GenericStyle.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CLinerStyle/src/CLinerStyle/Themes/TextBox.xaml b/CLinerStyle/src/CLinerStyle/Themes/TextBox.xaml
new file mode 100644
index 0000000..aaf9cdc
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/TextBox.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/brush.scroll.down.xaml b/CLinerStyle/src/CLinerStyle/Themes/brush.scroll.down.xaml
new file mode 100644
index 0000000..7b2f37f
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/brush.scroll.down.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/brush.scroll.up.xaml b/CLinerStyle/src/CLinerStyle/Themes/brush.scroll.up.xaml
new file mode 100644
index 0000000..3cd1d22
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/brush.scroll.up.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/i_checked.png b/CLinerStyle/src/CLinerStyle/Themes/i_checked.png
new file mode 100644
index 0000000..862c75f
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/Themes/i_checked.png differ
diff --git a/CLinerStyle/src/CLinerStyle/Themes/i_uchecked.png b/CLinerStyle/src/CLinerStyle/Themes/i_uchecked.png
new file mode 100644
index 0000000..4b12f53
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/Themes/i_uchecked.png differ
diff --git a/CLinerStyle/src/CLinerStyle/Themes/progressBarStyle.xaml b/CLinerStyle/src/CLinerStyle/Themes/progressBarStyle.xaml
new file mode 100644
index 0000000..e7865eb
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/progressBarStyle.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/Themes/raditoStyle.xaml b/CLinerStyle/src/CLinerStyle/Themes/raditoStyle.xaml
new file mode 100644
index 0000000..4819a81
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/Themes/raditoStyle.xaml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/CLinerStyle.dll b/CLinerStyle/src/CLinerStyle/bin/Debug/CLinerStyle.dll
new file mode 100644
index 0000000..ece1cd6
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/CLinerStyle.dll differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/CLinerStyle.pdb b/CLinerStyle/src/CLinerStyle/bin/Debug/CLinerStyle.pdb
new file mode 100644
index 0000000..0260a61
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/CLinerStyle.pdb differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/CommLibrary.dll b/CLinerStyle/src/CLinerStyle/bin/Debug/CommLibrary.dll
new file mode 100644
index 0000000..f4c8422
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/CommLibrary.dll differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/CommLibrary.pdb b/CLinerStyle/src/CLinerStyle/bin/Debug/CommLibrary.pdb
new file mode 100644
index 0000000..ffb85fa
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/CommLibrary.pdb differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/Lib.Controls.MyControls.dll b/CLinerStyle/src/CLinerStyle/bin/Debug/Lib.Controls.MyControls.dll
new file mode 100644
index 0000000..b001dd7
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/Lib.Controls.MyControls.dll differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/Lib.Controls.MyControls.pdb b/CLinerStyle/src/CLinerStyle/bin/Debug/Lib.Controls.MyControls.pdb
new file mode 100644
index 0000000..1e514e7
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/Lib.Controls.MyControls.pdb differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/System.Data.SQLite.dll b/CLinerStyle/src/CLinerStyle/bin/Debug/System.Data.SQLite.dll
new file mode 100644
index 0000000..c989da5
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/bin/Debug/System.Data.SQLite.dll differ
diff --git a/CLinerStyle/src/CLinerStyle/bin/Debug/System.Data.SQLite.xml b/CLinerStyle/src/CLinerStyle/bin/Debug/System.Data.SQLite.xml
new file mode 100644
index 0000000..9a3dd9b
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/bin/Debug/System.Data.SQLite.xml
@@ -0,0 +1,17071 @@
+
+
+
+ System.Data.SQLite
+
+
+
+
+ Defines a source code identifier custom attribute for an assembly
+ manifest.
+
+
+
+
+ Constructs an instance of this attribute class using the specified
+ source code identifier value.
+
+
+ The source code identifier value to use.
+
+
+
+
+ Gets the source code identifier value.
+
+
+
+
+ Defines a source code time-stamp custom attribute for an assembly
+ manifest.
+
+
+
+
+ Constructs an instance of this attribute class using the specified
+ source code time-stamp value.
+
+
+ The source code time-stamp value to use.
+
+
+
+
+ Gets the source code time-stamp value.
+
+
+
+
+ This is the method signature for the SQLite core library logging callback
+ function for use with sqlite3_log() and the SQLITE_CONFIG_LOG.
+
+ WARNING: This delegate is used more-or-less directly by native code, do
+ not modify its type signature.
+
+
+ The extra data associated with this message, if any.
+
+
+ The error code associated with this message.
+
+
+ The message string to be logged.
+
+
+
+
+ This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET
+
+
+
+
+ This internal class provides the foundation of SQLite support. It defines all the abstract members needed to implement
+ a SQLite data provider, and inherits from SQLiteConvert which allows for simple translations of string to and from SQLite.
+
+
+
+
+ This base class provides datatype conversion services for the SQLite provider.
+
+
+
+
+ The fallback default database type when one cannot be obtained from an
+ existing connection instance.
+
+
+
+
+ The format string for DateTime values when using the InvariantCulture or CurrentCulture formats.
+
+
+
+
+ The fallback default database type name when one cannot be obtained from
+ an existing connection instance.
+
+
+
+
+ The value for the Unix epoch (e.g. January 1, 1970 at midnight, in UTC).
+
+
+
+
+ The value of the OLE Automation epoch represented as a Julian day. This
+ field cannot be removed as the test suite relies upon it.
+
+
+
+
+ This is the minimum Julian Day value supported by this library
+ (148731163200000).
+
+
+
+
+ This is the maximum Julian Day value supported by this library
+ (464269060799000).
+
+
+
+
+ An array of ISO-8601 DateTime formats that we support parsing.
+
+
+
+
+ The internal default format for UTC DateTime values when converting
+ to a string.
+
+
+
+
+ The internal default format for local DateTime values when converting
+ to a string.
+
+
+
+
+ An UTF-8 Encoding instance, so we can convert strings to and from UTF-8
+
+
+
+
+ The default DateTime format for this instance.
+
+
+
+
+ The default DateTimeKind for this instance.
+
+
+
+
+ The default DateTime format string for this instance.
+
+
+
+
+ Initializes the conversion class
+
+ The default date/time format to use for this instance
+ The DateTimeKind to use.
+ The DateTime format string to use.
+
+
+
+ Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.
+
+ The string to convert to UTF-8
+ A byte array containing the converted string plus an extra 0 terminating byte at the end of the array.
+
+
+
+ Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.
+
+
+ This function is a convenience function, which first calls ToString() on the DateTime, and then calls ToUTF8() with the
+ string result.
+
+ The DateTime to convert.
+ The UTF-8 encoded string, including a 0 terminating byte at the end of the array.
+
+
+
+ Converts a UTF-8 encoded IntPtr of the specified length into a .NET string
+
+ The pointer to the memory where the UTF-8 string is encoded
+ The number of bytes to decode
+ A string containing the translated character(s)
+
+
+
+ Converts a UTF-8 encoded IntPtr of the specified length into a .NET string
+
+ The pointer to the memory where the UTF-8 string is encoded
+ The number of bytes to decode
+ A string containing the translated character(s)
+
+
+
+ Checks if the specified is within the
+ supported range for a Julian Day value.
+
+
+ The Julian Day value to check.
+
+
+ Non-zero if the specified Julian Day value is in the supported
+ range; otherwise, zero.
+
+
+
+
+ Converts a Julian Day value from a to an
+ .
+
+
+ The Julian Day value to convert.
+
+
+ The resulting Julian Day value.
+
+
+
+
+ Converts a Julian Day value from an to a
+ .
+
+
+ The Julian Day value to convert.
+
+
+ The resulting Julian Day value.
+
+
+
+
+ Converts a Julian Day value to a .
+ This method was translated from the "computeYMD" function in the
+ "date.c" file belonging to the SQLite core library.
+
+
+ The Julian Day value to convert.
+
+
+ The value to return in the event that the
+ Julian Day is out of the supported range. If this value is null,
+ an exception will be thrown instead.
+
+
+ A value that contains the year, month, and
+ day values that are closest to the specified Julian Day value.
+
+
+
+
+ Converts a Julian Day value to a .
+ This method was translated from the "computeHMS" function in the
+ "date.c" file belonging to the SQLite core library.
+
+
+ The Julian Day value to convert.
+
+
+ The value to return in the event that the
+ Julian Day value is out of the supported range. If this value is
+ null, an exception will be thrown instead.
+
+
+ A value that contains the hour, minute, and
+ second, and millisecond values that are closest to the specified
+ Julian Day value.
+
+
+
+
+ Converts a to a Julian Day value.
+ This method was translated from the "computeJD" function in
+ the "date.c" file belonging to the SQLite core library.
+ Since the range of Julian Day values supported by this method
+ includes all possible (valid) values of a
+ value, it should be extremely difficult for this method to
+ raise an exception or return an undefined result.
+
+
+ The value to convert. This value
+ will be within the range of
+ (00:00:00.0000000, January 1, 0001) to
+ (23:59:59.9999999, December
+ 31, 9999).
+
+
+ The nearest Julian Day value corresponding to the specified
+ value.
+
+
+
+
+ Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind,
+ and DateTimeFormatString specified for the connection when it was opened.
+
+
+ Acceptable ISO8601 DateTime formats are:
+
+ - THHmmssK
+ - THHmmK
+ - HH:mm:ss.FFFFFFFK
+ - HH:mm:ssK
+ - HH:mmK
+ - yyyy-MM-dd HH:mm:ss.FFFFFFFK
+ - yyyy-MM-dd HH:mm:ssK
+ - yyyy-MM-dd HH:mmK
+ - yyyy-MM-ddTHH:mm:ss.FFFFFFFK
+ - yyyy-MM-ddTHH:mmK
+ - yyyy-MM-ddTHH:mm:ssK
+ - yyyyMMddHHmmssK
+ - yyyyMMddHHmmK
+ - yyyyMMddTHHmmssFFFFFFFK
+ - THHmmss
+ - THHmm
+ - HH:mm:ss.FFFFFFF
+ - HH:mm:ss
+ - HH:mm
+ - yyyy-MM-dd HH:mm:ss.FFFFFFF
+ - yyyy-MM-dd HH:mm:ss
+ - yyyy-MM-dd HH:mm
+ - yyyy-MM-ddTHH:mm:ss.FFFFFFF
+ - yyyy-MM-ddTHH:mm
+ - yyyy-MM-ddTHH:mm:ss
+ - yyyyMMddHHmmss
+ - yyyyMMddHHmm
+ - yyyyMMddTHHmmssFFFFFFF
+ - yyyy-MM-dd
+ - yyyyMMdd
+ - yy-MM-dd
+
+ If the string cannot be matched to one of the above formats -OR-
+ the DateTimeFormatString if one was provided, an exception will
+ be thrown.
+
+ The string containing either a long integer number of 100-nanosecond units since
+ System.DateTime.MinValue, a Julian day double, an integer number of seconds since the Unix epoch, a
+ culture-independent formatted date and time string, a formatted date and time string in the current
+ culture, or an ISO8601-format string.
+ A DateTime value
+
+
+
+ Converts a string into a DateTime, using the specified DateTimeFormat,
+ DateTimeKind and DateTimeFormatString.
+
+
+ Acceptable ISO8601 DateTime formats are:
+
+ - THHmmssK
+ - THHmmK
+ - HH:mm:ss.FFFFFFFK
+ - HH:mm:ssK
+ - HH:mmK
+ - yyyy-MM-dd HH:mm:ss.FFFFFFFK
+ - yyyy-MM-dd HH:mm:ssK
+ - yyyy-MM-dd HH:mmK
+ - yyyy-MM-ddTHH:mm:ss.FFFFFFFK
+ - yyyy-MM-ddTHH:mmK
+ - yyyy-MM-ddTHH:mm:ssK
+ - yyyyMMddHHmmssK
+ - yyyyMMddHHmmK
+ - yyyyMMddTHHmmssFFFFFFFK
+ - THHmmss
+ - THHmm
+ - HH:mm:ss.FFFFFFF
+ - HH:mm:ss
+ - HH:mm
+ - yyyy-MM-dd HH:mm:ss.FFFFFFF
+ - yyyy-MM-dd HH:mm:ss
+ - yyyy-MM-dd HH:mm
+ - yyyy-MM-ddTHH:mm:ss.FFFFFFF
+ - yyyy-MM-ddTHH:mm
+ - yyyy-MM-ddTHH:mm:ss
+ - yyyyMMddHHmmss
+ - yyyyMMddHHmm
+ - yyyyMMddTHHmmssFFFFFFF
+ - yyyy-MM-dd
+ - yyyyMMdd
+ - yy-MM-dd
+
+ If the string cannot be matched to one of the above formats -OR-
+ the DateTimeFormatString if one was provided, an exception will
+ be thrown.
+
+ The string containing either a long integer number of 100-nanosecond units since
+ System.DateTime.MinValue, a Julian day double, an integer number of seconds since the Unix epoch, a
+ culture-independent formatted date and time string, a formatted date and time string in the current
+ culture, or an ISO8601-format string.
+ The SQLiteDateFormats to use.
+ The DateTimeKind to use.
+ The DateTime format string to use.
+ A DateTime value
+
+
+
+ Converts a julianday value into a DateTime
+
+ The value to convert
+ A .NET DateTime
+
+
+
+ Converts a julianday value into a DateTime
+
+ The value to convert
+ The DateTimeKind to use.
+ A .NET DateTime
+
+
+
+ Converts the specified number of seconds from the Unix epoch into a
+ value.
+
+
+ The number of whole seconds since the Unix epoch.
+
+
+ Either Utc or Local time.
+
+
+ The new value.
+
+
+
+
+ Converts the specified number of ticks since the epoch into a
+ value.
+
+
+ The number of whole ticks since the epoch.
+
+
+ Either Utc or Local time.
+
+
+ The new value.
+
+
+
+
+ Converts a DateTime struct to a JulianDay double
+
+ The DateTime to convert
+ The JulianDay value the Datetime represents
+
+
+
+ Converts a DateTime struct to the whole number of seconds since the
+ Unix epoch.
+
+ The DateTime to convert
+ The whole number of seconds since the Unix epoch
+
+
+
+ Returns the DateTime format string to use for the specified DateTimeKind.
+ If is not null, it will be returned verbatim.
+
+ The DateTimeKind to use.
+ The DateTime format string to use.
+
+ The DateTime format string to use for the specified DateTimeKind.
+
+
+
+
+ Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind,
+ and DateTimeFormatString specified for the connection when it was opened.
+
+ The DateTime value to convert
+ Either a string containing the long integer number of 100-nanosecond units since System.DateTime.MinValue, a
+ Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time
+ string, a formatted date and time string in the current culture, or an ISO8601-format date/time string.
+
+
+
+ Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind,
+ and DateTimeFormatString specified for the connection when it was opened.
+
+ The DateTime value to convert
+ The SQLiteDateFormats to use.
+ The DateTimeKind to use.
+ The DateTime format string to use.
+ Either a string containing the long integer number of 100-nanosecond units since System.DateTime.MinValue, a
+ Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time
+ string, a formatted date and time string in the current culture, or an ISO8601-format date/time string.
+
+
+
+ Internal function to convert a UTF-8 encoded IntPtr of the specified length to a DateTime.
+
+
+ This is a convenience function, which first calls ToString() on the IntPtr to convert it to a string, then calls
+ ToDateTime() on the string to return a DateTime.
+
+ A pointer to the UTF-8 encoded string
+ The length in bytes of the string
+ The parsed DateTime value
+
+
+
+ Smart method of splitting a string. Skips quoted elements, removes the quotes.
+
+
+ This split function works somewhat like the String.Split() function in that it breaks apart a string into
+ pieces and returns the pieces as an array. The primary differences are:
+
+ - Only one character can be provided as a separator character
+ - Quoted text inside the string is skipped over when searching for the separator, and the quotes are removed.
+
+ Thus, if splitting the following string looking for a comma:
+ One,Two, "Three, Four", Five
+
+ The resulting array would contain
+ [0] One
+ [1] Two
+ [2] Three, Four
+ [3] Five
+
+ Note that the leading and trailing spaces were removed from each item during the split.
+
+ Source string to split apart
+ Separator character
+ A string array of the split up elements
+
+
+
+ Splits the specified string into multiple strings based on a separator
+ and returns the result as an array of strings.
+
+
+ The string to split into pieces based on the separator character. If
+ this string is null, null will always be returned. If this string is
+ empty, an array of zero strings will always be returned.
+
+
+ The character used to divide the original string into sub-strings.
+ This character cannot be a backslash or a double-quote; otherwise, no
+ work will be performed and null will be returned.
+
+
+ If this parameter is non-zero, all double-quote characters will be
+ retained in the returned list of strings; otherwise, they will be
+ dropped.
+
+
+ Upon failure, this parameter will be modified to contain an appropriate
+ error message.
+
+
+ The new array of strings or null if the input string is null -OR- the
+ separator character is a backslash or a double-quote -OR- the string
+ contains an unbalanced backslash or double-quote character.
+
+
+
+
+ Queries and returns the string representation for an object, using the
+ specified (or current) format provider.
+
+
+ The object instance to return the string representation for.
+
+
+ The format provider to use -OR- null if the current format provider for
+ the thread should be used instead.
+
+
+ The string representation for the object instance -OR- null if the
+ object instance is also null.
+
+
+
+
+ Attempts to convert an arbitrary object to the Boolean data type.
+ Null object values are converted to false. Throws an exception
+ upon failure.
+
+
+ The object value to convert.
+
+
+ The format provider to use.
+
+
+ If non-zero, a string value will be converted using the
+
+ method; otherwise, the
+ method will be used.
+
+
+ The converted boolean value.
+
+
+
+
+ Convert a value to true or false.
+
+ A string or number representing true or false
+
+
+
+
+ Attempts to convert a into a .
+
+
+ The to convert, cannot be null.
+
+
+ The converted value.
+
+
+ The supported strings are "yes", "no", "y", "n", "on", "off", "0", "1",
+ as well as any prefix of the strings
+ and . All strings are treated in a
+ case-insensitive manner.
+
+
+
+
+ Converts a SQLiteType to a .NET Type object
+
+ The SQLiteType to convert
+ Returns a .NET Type object
+
+
+
+ For a given intrinsic type, return a DbType
+
+ The native type to convert
+ The corresponding (closest match) DbType
+
+
+
+ Returns the ColumnSize for the given DbType
+
+ The DbType to get the size of
+
+
+
+
+ Determines the default database type name to be used when a
+ per-connection value is not available.
+
+
+ The connection context for type mappings, if any.
+
+
+ The default database type name to use.
+
+
+
+
+ If applicable, issues a trace log message warning about falling back to
+ the default database type name.
+
+
+ The database value type.
+
+
+ The flags associated with the parent connection object.
+
+
+ The textual name of the database type.
+
+
+
+
+ If applicable, issues a trace log message warning about falling back to
+ the default database value type.
+
+
+ The textual name of the database type.
+
+
+ The flags associated with the parent connection object.
+
+
+ The database value type.
+
+
+
+
+ For a given database value type, return the "closest-match" textual database type name.
+
+ The connection context for custom type mappings, if any.
+ The database value type.
+ The flags associated with the parent connection object.
+ The type name or an empty string if it cannot be determined.
+
+
+
+ Convert a DbType to a Type
+
+ The DbType to convert from
+ The closest-match .NET type
+
+
+
+ For a given type, return the closest-match SQLite TypeAffinity, which only understands a very limited subset of types.
+
+ The type to evaluate
+ The SQLite type affinity for that type.
+
+
+
+ Builds and returns a map containing the database column types
+ recognized by this provider.
+
+
+ A map containing the database column types recognized by this
+ provider.
+
+
+
+
+ Determines if a database type is considered to be a string.
+
+
+ The database type to check.
+
+
+ Non-zero if the database type is considered to be a string, zero
+ otherwise.
+
+
+
+
+ Determines and returns the runtime configuration setting string that
+ should be used in place of the specified object value.
+
+
+ The object value to convert to a string.
+
+
+ Either the string to use in place of the object value -OR- null if it
+ cannot be determined.
+
+
+
+
+ Determines the default value to be used when a
+ per-connection value is not available.
+
+
+ The connection context for type mappings, if any.
+
+
+ The default value to use.
+
+
+
+
+ Converts the object value, which is assumed to have originated
+ from a , to a string value.
+
+
+ The value to be converted to a string.
+
+
+ A null value will be returned if the original value is null -OR-
+ the original value is . Otherwise,
+ the original value will be converted to a string, using its
+ (possibly overridden) method and
+ then returned.
+
+
+
+
+ Determines if the specified textual value appears to be a
+ value.
+
+
+ The textual value to inspect.
+
+
+ Non-zero if the text looks like a value,
+ zero otherwise.
+
+
+
+
+ Determines if the specified textual value appears to be an
+ value.
+
+
+ The textual value to inspect.
+
+
+ Non-zero if the text looks like an value,
+ zero otherwise.
+
+
+
+
+ Determines if the specified textual value appears to be a
+ value.
+
+
+ The textual value to inspect.
+
+
+ Non-zero if the text looks like a value,
+ zero otherwise.
+
+
+
+
+ Determines if the specified textual value appears to be a
+ value.
+
+
+ The object instance configured with
+ the chosen format.
+
+
+ The textual value to inspect.
+
+
+ Non-zero if the text looks like a in the
+ configured format, zero otherwise.
+
+
+
+
+ For a given textual database type name, return the "closest-match" database type.
+ This method is called during query result processing; therefore, its performance
+ is critical.
+
+ The connection context for custom type mappings, if any.
+ The textual name of the database type to match.
+ The flags associated with the parent connection object.
+ The .NET DBType the text evaluates to.
+
+
+
+ The error code used for logging exceptions caught in user-provided
+ code.
+
+
+
+
+ Returns non-zero if this connection to the database is read-only.
+
+
+
+
+ Sets the status of the memory usage tracking subsystem in the SQLite core library. By default, this is enabled.
+ If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is
+ global to the process.
+
+ Non-zero to enable memory usage tracking, zero otherwise.
+ A standard SQLite return code (i.e. zero for success and non-zero for failure).
+
+
+
+ Attempts to free as much heap memory as possible for the database connection.
+
+ A standard SQLite return code (i.e. zero for success and non-zero for failure).
+
+
+
+ Shutdown the SQLite engine so that it can be restarted with different config options.
+ We depend on auto initialization to recover.
+
+
+
+
+ Determines if the associated native connection handle is open.
+
+
+ Non-zero if a database connection is open.
+
+
+
+
+ Returns the fully qualified path and file name for the currently open
+ database, if any.
+
+
+ The name of the attached database to query.
+
+
+ The fully qualified path and file name for the currently open database,
+ if any.
+
+
+
+
+ Opens a database.
+
+
+ Implementers should call SQLiteFunction.BindFunctions() and save the array after opening a connection
+ to bind all attributed user-defined functions and collating sequences to the new connection.
+
+ The filename of the database to open. SQLite automatically creates it if it doesn't exist.
+ The name of the VFS to use -OR- null to use the default VFS.
+ The flags associated with the parent connection object
+ The open flags to use when creating the connection
+ The maximum size of the pool for the given filename
+ If true, the connection can be pulled from the connection pool
+
+
+
+ Closes the currently-open database.
+
+
+ After the database has been closed implemeters should call SQLiteFunction.UnbindFunctions() to deallocate all interop allocated
+ memory associated with the user-defined functions and collating sequences tied to the closed connection.
+
+ Non-zero if the operation is allowed to throw exceptions, zero otherwise.
+
+
+
+ Sets the busy timeout on the connection. SQLiteCommand will call this before executing any command.
+
+ The number of milliseconds to wait before returning SQLITE_BUSY
+
+
+
+ Returns the text of the last error issued by SQLite
+
+
+
+
+
+ Returns the text of the last error issued by SQLite -OR- the specified default error text if
+ none is available from the SQLite core library.
+
+
+ The error text to return in the event that one is not available from the SQLite core library.
+
+
+ The error text.
+
+
+
+
+ When pooling is enabled, force this connection to be disposed rather than returned to the pool
+
+
+
+
+ When pooling is enabled, returns the number of pool entries matching the current file name.
+
+ The number of pool entries matching the current file name.
+
+
+
+ Prepares a SQL statement for execution.
+
+ The source connection preparing the command. Can be null for any caller except LINQ
+ The SQL command text to prepare
+ The previous statement in a multi-statement command, or null if no previous statement exists
+ The timeout to wait before aborting the prepare
+ The remainder of the statement that was not processed. Each call to prepare parses the
+ SQL up to to either the end of the text or to the first semi-colon delimiter. The remaining text is returned
+ here for a subsequent call to Prepare() until all the text has been processed.
+ Returns an initialized SQLiteStatement.
+
+
+
+ Steps through a prepared statement.
+
+ The SQLiteStatement to step through
+ True if a row was returned, False if not.
+
+
+
+ Returns non-zero if the specified statement is read-only in nature.
+
+ The statement to check.
+ True if the outer query is read-only.
+
+
+
+ Resets a prepared statement so it can be executed again. If the error returned is SQLITE_SCHEMA,
+ transparently attempt to rebuild the SQL statement and throw an error if that was not possible.
+
+ The statement to reset
+ Returns -1 if the schema changed while resetting, 0 if the reset was sucessful or 6 (SQLITE_LOCKED) if the reset failed due to a lock
+
+
+
+ Attempts to interrupt the query currently executing on the associated
+ native database connection.
+
+
+
+
+ This function binds a user-defined function to the connection.
+
+
+ The object instance containing
+ the metadata for the function to be bound.
+
+
+ The object instance that implements the
+ function to be bound.
+
+
+ The flags associated with the parent connection object.
+
+
+
+
+ This function unbinds a user-defined function from the connection.
+
+
+ The object instance containing
+ the metadata for the function to be unbound.
+
+
+ The flags associated with the parent connection object.
+
+ Non-zero if the function was unbound.
+
+
+
+ Calls the native SQLite core library in order to create a disposable
+ module containing the implementation of a virtual table.
+
+
+ The module object to be used when creating the native disposable module.
+
+
+ The flags for the associated object instance.
+
+
+
+
+ Calls the native SQLite core library in order to cleanup the resources
+ associated with a module containing the implementation of a virtual table.
+
+
+ The module object previously passed to the
+ method.
+
+
+ The flags for the associated object instance.
+
+
+
+
+ Calls the native SQLite core library in order to declare a virtual table
+ in response to a call into the
+ or virtual table methods.
+
+
+ The virtual table module that is to be responsible for the virtual table
+ being declared.
+
+
+ The string containing the SQL statement describing the virtual table to
+ be declared.
+
+
+ Upon success, the contents of this parameter are undefined. Upon failure,
+ it should contain an appropriate error message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Calls the native SQLite core library in order to declare a virtual table
+ function in response to a call into the
+ or virtual table methods.
+
+
+ The virtual table module that is to be responsible for the virtual table
+ function being declared.
+
+
+ The number of arguments to the function being declared.
+
+
+ The name of the function being declared.
+
+
+ Upon success, the contents of this parameter are undefined. Upon failure,
+ it should contain an appropriate error message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Enables or disables a configuration option for the database.
+ connection.
+
+
+ The database configuration option to enable or disable.
+
+
+ True to enable loading of extensions, false to disable.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Enables or disables extension loading by SQLite.
+
+
+ True to enable loading of extensions, false to disable.
+
+
+
+
+ Loads a SQLite extension library from the named file.
+
+
+ The name of the dynamic link library file containing the extension.
+
+
+ The name of the exported function used to initialize the extension.
+ If null, the default "sqlite3_extension_init" will be used.
+
+
+
+
+ Enables or disabled extened result codes returned by SQLite
+
+ true to enable extended result codes, false to disable.
+
+
+
+
+ Returns the numeric result code for the most recent failed SQLite API call
+ associated with the database connection.
+
+ Result code
+
+
+
+ Returns the extended numeric result code for the most recent failed SQLite API call
+ associated with the database connection.
+
+ Extended result code
+
+
+
+ Add a log message via the SQLite sqlite3_log interface.
+
+ Error code to be logged with the message.
+ String to be logged. Unlike the SQLite sqlite3_log()
+ interface, this should be pre-formatted. Consider using the
+ String.Format() function.
+
+
+
+
+ Checks if the SQLite core library has been initialized in the current process.
+
+
+ Non-zero if the SQLite core library has been initialized in the current process,
+ zero otherwise.
+
+
+
+
+ Creates a new SQLite backup object based on the provided destination
+ database connection. The source database connection is the one
+ associated with this object. The source and destination database
+ connections cannot be the same.
+
+ The destination database connection.
+ The destination database name.
+ The source database name.
+ The newly created backup object.
+
+
+
+ Copies up to N pages from the source database to the destination
+ database associated with the specified backup object.
+
+ The backup object to use.
+
+ The number of pages to copy or negative to copy all remaining pages.
+
+
+ Set to true if the operation needs to be retried due to database
+ locking issues.
+
+
+ True if there are more pages to be copied, false otherwise.
+
+
+
+
+ Returns the number of pages remaining to be copied from the source
+ database to the destination database associated with the specified
+ backup object.
+
+ The backup object to check.
+ The number of pages remaining to be copied.
+
+
+
+ Returns the total number of pages in the source database associated
+ with the specified backup object.
+
+ The backup object to check.
+ The total number of pages in the source database.
+
+
+
+ Destroys the backup object, rolling back any backup that may be in
+ progess.
+
+ The backup object to destroy.
+
+
+
+ Returns the error message for the specified SQLite return code using
+ the internal static lookup table.
+
+ The SQLite return code.
+ The error message or null if it cannot be found.
+
+
+
+ Returns a string representing the active version of SQLite
+
+
+
+
+ Returns an integer representing the active version of SQLite
+
+
+
+
+ Returns the rowid of the most recent successful INSERT into the database from this connection.
+
+
+
+
+ Returns the number of changes the last executing insert/update caused.
+
+
+
+
+ Returns the amount of memory (in bytes) currently in use by the SQLite core library. This is not really a per-connection
+ value, it is global to the process.
+
+
+
+
+ Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
+ This is not really a per-connection value, it is global to the process.
+
+
+
+
+ Returns non-zero if the underlying native connection handle is owned by this instance.
+
+
+
+
+ Returns the logical list of functions associated with this connection.
+
+
+
+
+ Returns non-zero if the given database connection is in autocommit mode.
+ Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN
+ statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
+
+
+
+
+ The opaque pointer returned to us by the sqlite provider
+
+
+
+
+ The user-defined functions registered on this connection
+
+
+
+
+ This is the name of the native library file that contains the
+ "vtshim" extension [wrapper].
+
+
+
+
+ This is the flag indicate whether the native library file that
+ contains the "vtshim" extension must be dynamically loaded by
+ this class prior to use.
+
+
+
+
+ This is the name of the native entry point for the "vtshim"
+ extension [wrapper].
+
+
+
+
+ The modules created using this connection.
+
+
+
+
+ Constructs the object used to interact with the SQLite core library
+ using the UTF-8 text encoding.
+
+
+ The DateTime format to be used when converting string values to a
+ DateTime and binding DateTime parameters.
+
+
+ The to be used when creating DateTime
+ values.
+
+
+ The format string to be used when parsing and formatting DateTime
+ values.
+
+
+ The native handle to be associated with the database connection.
+
+
+ The fully qualified file name associated with .
+
+
+ Non-zero if the newly created object instance will need to dispose
+ of when it is no longer needed.
+
+
+
+
+ This method attempts to dispose of all the derived
+ object instances currently associated with the native database connection.
+
+
+
+
+ Returns the number of times the method has been
+ called.
+
+
+
+
+ This method determines whether or not a
+ with a return code of should
+ be thrown after making a call into the SQLite core library.
+
+
+ Non-zero if a to be thrown. This method
+ will only return non-zero if the method was called
+ one or more times during a call into the SQLite core library (e.g. when
+ the sqlite3_prepare*() or sqlite3_step() APIs are used).
+
+
+
+
+ Resets the value of the field.
+
+
+
+
+ Attempts to interrupt the query currently executing on the associated
+ native database connection.
+
+
+
+
+ This function binds a user-defined function to the connection.
+
+
+ The object instance containing
+ the metadata for the function to be bound.
+
+
+ The object instance that implements the
+ function to be bound.
+
+
+ The flags associated with the parent connection object.
+
+
+
+
+ This function binds a user-defined function to the connection.
+
+
+ The object instance containing
+ the metadata for the function to be unbound.
+
+
+ The flags associated with the parent connection object.
+
+ Non-zero if the function was unbound and removed.
+
+
+
+ Attempts to free as much heap memory as possible for the database connection.
+
+ A standard SQLite return code (i.e. zero for success and non-zero for failure).
+
+
+
+ Attempts to free N bytes of heap memory by deallocating non-essential memory
+ allocations held by the database library. Memory used to cache database pages
+ to improve performance is an example of non-essential memory. This is a no-op
+ returning zero if the SQLite core library was not compiled with the compile-time
+ option SQLITE_ENABLE_MEMORY_MANAGEMENT. Optionally, attempts to reset and/or
+ compact the Win32 native heap, if applicable.
+
+
+ The requested number of bytes to free.
+
+
+ Non-zero to attempt a heap reset.
+
+
+ Non-zero to attempt heap compaction.
+
+
+ The number of bytes actually freed. This value may be zero.
+
+
+ This value will be non-zero if the heap reset was successful.
+
+
+ The size of the largest committed free block in the heap, in bytes.
+ This value will be zero unless heap compaction is enabled.
+
+
+ A standard SQLite return code (i.e. zero for success and non-zero
+ for failure).
+
+
+
+
+ Shutdown the SQLite engine so that it can be restarted with different
+ configuration options. We depend on auto initialization to recover.
+
+ Returns a standard SQLite result code.
+
+
+
+ Shutdown the SQLite engine so that it can be restarted with different
+ configuration options. We depend on auto initialization to recover.
+
+
+ Non-zero to reset the database and temporary directories to their
+ default values, which should be null for both. This parameter has no
+ effect on non-Windows operating systems.
+
+ Returns a standard SQLite result code.
+
+
+
+ Determines if the associated native connection handle is open.
+
+
+ Non-zero if the associated native connection handle is open.
+
+
+
+
+ Returns the fully qualified path and file name for the currently open
+ database, if any.
+
+
+ The name of the attached database to query.
+
+
+ The fully qualified path and file name for the currently open database,
+ if any.
+
+
+
+
+ Has the sqlite3_errstr() core library API been checked for yet?
+ If so, is it present?
+
+
+
+
+ Returns the error message for the specified SQLite return code using
+ the sqlite3_errstr() function, falling back to the internal lookup
+ table if necessary.
+
+ The SQLite return code.
+ The error message or null if it cannot be found.
+
+
+
+ Has the sqlite3_stmt_readonly() core library API been checked for yet?
+ If so, is it present?
+
+
+
+
+ Returns non-zero if the specified statement is read-only in nature.
+
+ The statement to check.
+ True if the outer query is read-only.
+
+
+
+ This field is used to keep track of whether or not the
+ "SQLite_ForceLogPrepare" environment variable has been queried. If so,
+ it will only be non-zero if the environment variable was present.
+
+
+
+
+ Determines if all calls to prepare a SQL query will be logged,
+ regardless of the flags for the associated connection.
+
+
+ Non-zero to log all calls to prepare a SQL query.
+
+
+
+
+ Determines the file name of the native library containing the native
+ "vtshim" extension -AND- whether it should be dynamically loaded by
+ this class.
+
+
+ This output parameter will be set to non-zero if the returned native
+ library file name should be dynamically loaded prior to attempting
+ the creation of native disposable extension modules.
+
+
+ The file name of the native library containing the native "vtshim"
+ extension -OR- null if it cannot be determined.
+
+
+
+
+ Calls the native SQLite core library in order to create a disposable
+ module containing the implementation of a virtual table.
+
+
+ The module object to be used when creating the native disposable module.
+
+
+ The flags for the associated object instance.
+
+
+
+
+ Calls the native SQLite core library in order to cleanup the resources
+ associated with a module containing the implementation of a virtual table.
+
+
+ The module object previously passed to the
+ method.
+
+
+ The flags for the associated object instance.
+
+
+
+
+ Calls the native SQLite core library in order to declare a virtual table
+ in response to a call into the
+ or virtual table methods.
+
+
+ The virtual table module that is to be responsible for the virtual table
+ being declared.
+
+
+ The string containing the SQL statement describing the virtual table to
+ be declared.
+
+
+ Upon success, the contents of this parameter are undefined. Upon failure,
+ it should contain an appropriate error message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Calls the native SQLite core library in order to declare a virtual table
+ function in response to a call into the
+ or virtual table methods.
+
+
+ The virtual table module that is to be responsible for the virtual table
+ function being declared.
+
+
+ The number of arguments to the function being declared.
+
+
+ The name of the function being declared.
+
+
+ Upon success, the contents of this parameter are undefined. Upon failure,
+ it should contain an appropriate error message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Enables or disables a configuration option for the database.
+ connection.
+
+
+ The database configuration option to enable or disable.
+
+
+ True to enable loading of extensions, false to disable.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Enables or disables extension loading by SQLite.
+
+
+ True to enable loading of extensions, false to disable.
+
+
+
+
+ Loads a SQLite extension library from the named file.
+
+
+ The name of the dynamic link library file containing the extension.
+
+
+ The name of the exported function used to initialize the extension.
+ If null, the default "sqlite3_extension_init" will be used.
+
+
+
+ Enables or disabled extended result codes returned by SQLite
+
+
+ Gets the last SQLite error code
+
+
+ Gets the last SQLite extended error code
+
+
+ Add a log message via the SQLite sqlite3_log interface.
+
+
+ Add a log message via the SQLite sqlite3_log interface.
+
+
+
+ Allows the setting of a logging callback invoked by SQLite when a
+ log event occurs. Only one callback may be set. If NULL is passed,
+ the logging callback is unregistered.
+
+ The callback function to invoke.
+ Returns a result code
+
+
+
+ Creates a new SQLite backup object based on the provided destination
+ database connection. The source database connection is the one
+ associated with this object. The source and destination database
+ connections cannot be the same.
+
+ The destination database connection.
+ The destination database name.
+ The source database name.
+ The newly created backup object.
+
+
+
+ Copies up to N pages from the source database to the destination
+ database associated with the specified backup object.
+
+ The backup object to use.
+
+ The number of pages to copy, negative to copy all remaining pages.
+
+
+ Set to true if the operation needs to be retried due to database
+ locking issues; otherwise, set to false.
+
+
+ True if there are more pages to be copied, false otherwise.
+
+
+
+
+ Returns the number of pages remaining to be copied from the source
+ database to the destination database associated with the specified
+ backup object.
+
+ The backup object to check.
+ The number of pages remaining to be copied.
+
+
+
+ Returns the total number of pages in the source database associated
+ with the specified backup object.
+
+ The backup object to check.
+ The total number of pages in the source database.
+
+
+
+ Destroys the backup object, rolling back any backup that may be in
+ progess.
+
+ The backup object to destroy.
+
+
+
+ Determines if the SQLite core library has been initialized for the
+ current process.
+
+
+ A boolean indicating whether or not the SQLite core library has been
+ initialized for the current process.
+
+
+
+
+ Determines if the SQLite core library has been initialized for the
+ current process.
+
+
+ A boolean indicating whether or not the SQLite core library has been
+ initialized for the current process.
+
+
+
+
+ Helper function to retrieve a column of data from an active statement.
+
+ The statement being step()'d through
+ The flags associated with the connection.
+ The column index to retrieve
+ The type of data contained in the column. If Uninitialized, this function will retrieve the datatype information.
+ Returns the data in the column
+
+
+
+ Returns non-zero if the underlying native connection handle is owned
+ by this instance.
+
+
+
+
+ Returns the logical list of functions associated with this connection.
+
+
+
+
+ Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode)
+
+
+
+
+ Constructs the object used to interact with the SQLite core library
+ using the UTF-8 text encoding.
+
+
+ The DateTime format to be used when converting string values to a
+ DateTime and binding DateTime parameters.
+
+
+ The to be used when creating DateTime
+ values.
+
+
+ The format string to be used when parsing and formatting DateTime
+ values.
+
+
+ The native handle to be associated with the database connection.
+
+
+ The fully qualified file name associated with .
+
+
+ Non-zero if the newly created object instance will need to dispose
+ of when it is no longer needed.
+
+
+
+
+ Overrides SQLiteConvert.ToString() to marshal UTF-16 strings instead of UTF-8
+
+ A pointer to a UTF-16 string
+ The length (IN BYTES) of the string
+ A .NET string
+
+
+
+ Represents a single SQL backup in SQLite.
+
+
+
+
+ The underlying SQLite object this backup is bound to.
+
+
+
+
+ The actual backup handle.
+
+
+
+
+ The destination database for the backup.
+
+
+
+
+ The destination database name for the backup.
+
+
+
+
+ The source database for the backup.
+
+
+
+
+ The source database name for the backup.
+
+
+
+
+ The last result from the StepBackup method of the SQLite3 class.
+ This is used to determine if the call to the FinishBackup method of
+ the SQLite3 class should throw an exception when it receives a non-Ok
+ return code from the core SQLite library.
+
+
+
+
+ Initializes the backup.
+
+ The base SQLite object.
+ The backup handle.
+ The destination database for the backup.
+ The destination database name for the backup.
+ The source database for the backup.
+ The source database name for the backup.
+
+
+
+ Disposes and finalizes the backup.
+
+
+
+
+
+
+
+
+
+ Creates temporary tables on the connection so schema information can be queried.
+
+
+ The connection upon which to build the schema tables.
+
+
+
+
+ The extra behavioral flags that can be applied to a connection.
+
+
+
+
+ No extra flags.
+
+
+
+
+ Enable logging of all SQL statements to be prepared.
+
+
+
+
+ Enable logging of all bound parameter types and raw values.
+
+
+
+
+ Enable logging of all bound parameter strongly typed values.
+
+
+
+
+ Enable logging of all exceptions caught from user-provided
+ managed code called from native code via delegates.
+
+
+
+
+ Enable logging of backup API errors.
+
+
+
+
+ Skip adding the extension functions provided by the native
+ interop assembly.
+
+
+
+
+ When binding parameter values with the
+ type, use the interop method that accepts an
+ value.
+
+
+
+
+ When binding parameter values, always bind them as though they were
+ plain text (i.e. no numeric, date/time, or other conversions should
+ be attempted).
+
+
+
+
+ When returning column values, always return them as though they were
+ plain text (i.e. no numeric, date/time, or other conversions should
+ be attempted).
+
+
+
+
+ Prevent this object instance from
+ loading extensions.
+
+
+
+
+ Prevent this object instance from
+ creating virtual table modules.
+
+
+
+
+ Skip binding any functions provided by other managed assemblies when
+ opening the connection.
+
+
+
+
+ Skip setting the logging related properties of the
+ object instance that was passed to
+ the method.
+
+
+
+
+ Enable logging of all virtual table module errors seen by the
+ method.
+
+
+
+
+ Enable logging of certain virtual table module exceptions that cannot
+ be easily discovered via other means.
+
+
+
+
+ Enable tracing of potentially important [non-fatal] error conditions
+ that cannot be easily reported through other means.
+
+
+
+
+ When binding parameter values, always use the invariant culture when
+ converting their values from strings.
+
+
+
+
+ When binding parameter values, always use the invariant culture when
+ converting their values to strings.
+
+
+
+
+ Disable using the connection pool by default. If the "Pooling"
+ connection string property is specified, its value will override
+ this flag. The precise outcome of combining this flag with the
+ flag is unspecified; however,
+ one of the flags will be in effect.
+
+
+
+
+ Enable using the connection pool by default. If the "Pooling"
+ connection string property is specified, its value will override
+ this flag. The precise outcome of combining this flag with the
+ flag is unspecified; however,
+ one of the flags will be in effect.
+
+
+
+
+ Enable using per-connection mappings between type names and
+ values. Also see the
+ ,
+ , and
+ methods. These
+ per-connection mappings, when present, override the corresponding
+ global mappings.
+
+
+
+
+ Disable using global mappings between type names and
+ values. This may be useful in some very narrow
+ cases; however, if there are no per-connection type mappings, the
+ fallback defaults will be used for both type names and their
+ associated values. Therefore, use of this flag
+ is not recommended.
+
+
+
+
+ When the property is used, it
+ should return non-zero if there were ever any rows in the associated
+ result sets.
+
+
+
+
+ Enable "strict" transaction enlistment semantics. Setting this flag
+ will cause an exception to be thrown if an attempt is made to enlist
+ in a transaction with an unavailable or unsupported isolation level.
+ In the future, more extensive checks may be enabled by this flag as
+ well.
+
+
+
+
+ Enable mapping of unsupported transaction isolation levels to the
+ closest supported transaction isolation level.
+
+
+
+
+ When returning column values, attempt to detect the affinity of
+ textual values by checking if they fully conform to those of the
+ ,
+ ,
+ ,
+ or types.
+
+
+
+
+ When returning column values, attempt to detect the type of
+ string values by checking if they fully conform to those of
+ the ,
+ ,
+ ,
+ or types.
+
+
+
+
+ Skip querying runtime configuration settings for use by the
+ class, including the default
+ value and default database type name.
+ NOTE: If the
+ and/or
+ properties are not set explicitly nor set via their connection
+ string properties and repeated calls to determine these runtime
+ configuration settings are seen to be a problem, this flag
+ should be set.
+
+
+
+
+ When binding parameter values with the
+ type, take their into account as
+ well as that of the associated .
+
+
+
+
+ If an exception is caught when raising the
+ event, the transaction
+ should be rolled back. If this is not specified, the transaction
+ will continue the commit process instead.
+
+
+
+
+ If an exception is caught when raising the
+ event, the action should
+ should be denied. If this is not specified, the action will be
+ allowed instead.
+
+
+
+
+ If an exception is caught when raising the
+ event, the operation
+ should be interrupted. If this is not specified, the operation
+ will simply continue.
+
+
+
+
+ Attempt to unbind all functions provided by other managed assemblies
+ when closing the connection.
+
+
+
+
+ When returning column values as a , skip
+ verifying their affinity.
+
+
+
+
+ Enable using per-connection mappings between type names and
+ values. Also see the
+ ,
+ , and
+ methods.
+
+
+
+
+ Enable using per-connection mappings between type names and
+ values. Also see the
+ ,
+ , and
+ methods.
+
+
+
+
+ If the database type name has not been explicitly set for the
+ parameter specified, fallback to using the parameter name.
+
+
+
+
+ If the database type name has not been explicitly set for the
+ parameter specified, fallback to using the database type name
+ associated with the value.
+
+
+
+
+ When returning column values, skip verifying their affinity.
+
+
+
+
+ Allow transactions to be nested. The outermost transaction still
+ controls whether or not any changes are ultimately committed or
+ rolled back. All non-outermost transactions are implemented using
+ the SAVEPOINT construct.
+
+
+
+
+ When binding parameter values or returning column values, always
+ treat them as though they were plain text (i.e. no numeric,
+ date/time, or other conversions should be attempted).
+
+
+
+
+ When binding parameter values, always use the invariant culture when
+ converting their values to strings or from strings.
+
+
+
+
+ When binding parameter values or returning column values, always
+ treat them as though they were plain text (i.e. no numeric,
+ date/time, or other conversions should be attempted) and always
+ use the invariant culture when converting their values to strings.
+
+
+
+
+ When binding parameter values or returning column values, always
+ treat them as though they were plain text (i.e. no numeric,
+ date/time, or other conversions should be attempted) and always
+ use the invariant culture when converting their values to strings
+ or from strings.
+
+
+
+
+ Enables use of all per-connection value handling callbacks.
+
+
+
+
+ Enables use of all applicable
+ properties as fallbacks for the database type name.
+
+
+
+
+ Enable all logging.
+
+
+
+
+ The default extra flags for new connections.
+
+
+
+
+ The default extra flags for new connections with all logging enabled.
+
+
+
+
+ These are the supported configuration verbs for use with the native
+ SQLite library. They are used with the
+ method.
+
+
+
+
+ This value represents an unknown (or invalid) option, do not use it.
+
+
+
+
+ This option is not currently supported by System.Data.SQLite. It
+ may be supported in the future.
+
+
+
+
+ This option is used to enable or disable the enforcement of
+ foreign key constraints.
+
+
+
+
+ This option is used to enable or disable triggers.
+
+
+
+
+ This option is used to enable or disable the two-argument version
+ of the fts3_tokenizer() function which is part of the FTS3 full-text
+ search engine extension.
+
+
+
+
+ This option is used to enable or disable the loading of extensions.
+
+
+
+
+ Represents a single SQL blob in SQLite.
+
+
+
+
+ The underlying SQLite object this blob is bound to.
+
+
+
+
+ The actual blob handle.
+
+
+
+
+ Initializes the blob.
+
+ The base SQLite object.
+ The blob handle.
+
+
+
+ Creates a object. This will not work
+ for tables that were created WITHOUT ROWID -OR- if the query
+ does not include the "rowid" column or one of its aliases -OR-
+ if the was not created with the
+ flag.
+
+
+ The instance with a result set
+ containing the desired blob column.
+
+
+ The index of the blob column.
+
+
+ Non-zero to open the blob object for read-only access.
+
+
+ The newly created instance -OR- null
+ if an error occurs.
+
+
+
+
+ Throws an exception if the blob object does not appear to be open.
+
+
+
+
+ Throws an exception if an invalid read/write parameter is detected.
+
+
+ When reading, this array will be populated with the bytes read from
+ the underlying database blob. When writing, this array contains new
+ values for the specified portion of the underlying database blob.
+
+
+ The number of bytes to read or write.
+
+
+ The byte offset, relative to the start of the underlying database
+ blob, where the read or write operation will begin.
+
+
+
+
+ Retargets this object to an underlying database blob for a
+ different row; the database, table, and column remain exactly
+ the same. If this operation fails for any reason, this blob
+ object is automatically disposed.
+
+
+ The integer identifier for the new row.
+
+
+
+
+ Queries the total number of bytes for the underlying database blob.
+
+
+ The total number of bytes for the underlying database blob.
+
+
+
+
+ Reads data from the underlying database blob.
+
+
+ This array will be populated with the bytes read from the
+ underlying database blob.
+
+
+ The number of bytes to read.
+
+
+ The byte offset, relative to the start of the underlying
+ database blob, where the read operation will begin.
+
+
+
+
+ Writes data into the underlying database blob.
+
+
+ This array contains the new values for the specified portion of
+ the underlying database blob.
+
+
+ The number of bytes to write.
+
+
+ The byte offset, relative to the start of the underlying
+ database blob, where the write operation will begin.
+
+
+
+
+ Closes the blob, freeing the associated resources.
+
+
+
+
+ Disposes and finalizes the blob.
+
+
+
+
+ The destructor.
+
+
+
+
+ SQLite implementation of DbCommand.
+
+
+
+
+ The default connection string to be used when creating a temporary
+ connection to execute a command via the static
+ or
+
+ methods.
+
+
+
+
+ The command text this command is based on
+
+
+
+
+ The connection the command is associated with
+
+
+
+
+ The version of the connection the command is associated with
+
+
+
+
+ Indicates whether or not a DataReader is active on the command.
+
+
+
+
+ The timeout for the command, kludged because SQLite doesn't support per-command timeout values
+
+
+
+
+ Designer support
+
+
+
+
+ Used by DbDataAdapter to determine updating behavior
+
+
+
+
+ The collection of parameters for the command
+
+
+
+
+ The SQL command text, broken into individual SQL statements as they are executed
+
+
+
+
+ Unprocessed SQL text that has not been executed
+
+
+
+
+ Transaction associated with this command
+
+
+
+
+ Constructs a new SQLiteCommand
+
+
+ Default constructor
+
+
+
+
+ Initializes the command with the given command text
+
+ The SQL command text
+
+
+
+ Initializes the command with the given SQL command text and attach the command to the specified
+ connection.
+
+ The SQL command text
+ The connection to associate with the command
+
+
+
+ Initializes the command and associates it with the specified connection.
+
+ The connection to associate with the command
+
+
+
+ Initializes a command with the given SQL, connection and transaction
+
+ The SQL command text
+ The connection to associate with the command
+ The transaction the command should be associated with
+
+
+
+ Disposes of the command and clears all member variables
+
+ Whether or not the class is being explicitly or implicitly disposed
+
+
+
+ This method attempts to query the flags associated with the database
+ connection in use. If the database connection is disposed, the default
+ flags will be returned.
+
+
+ The command containing the databse connection to query the flags from.
+
+
+ The connection flags value.
+
+
+
+
+ Clears and destroys all statements currently prepared
+
+
+
+
+ Builds an array of prepared statements for each complete SQL statement in the command text
+
+
+
+
+ Not implemented
+
+
+
+
+ Forwards to the local CreateParameter() function
+
+
+
+
+
+ Create a new parameter
+
+
+
+
+
+ Verifies that all SQL queries associated with the current command text
+ can be successfully compiled. A will be
+ raised if any errors occur.
+
+
+
+
+ This function ensures there are no active readers, that we have a valid connection,
+ that the connection is open, that all statements are prepared and all parameters are assigned
+ in preparation for allocating a data reader.
+
+
+
+
+ Creates a new SQLiteDataReader to execute/iterate the array of SQLite prepared statements
+
+ The behavior the data reader should adopt
+ Returns a SQLiteDataReader object
+
+
+
+ This method creates a new connection, executes the query using the given
+ execution type, closes the connection, and returns the results. If the
+ connection string is null, a temporary in-memory database connection will
+ be used.
+
+
+ The text of the command to be executed.
+
+
+ The execution type for the command. This is used to determine which method
+ of the command object to call, which then determines the type of results
+ returned, if any.
+
+
+ The connection string to the database to be opened, used, and closed. If
+ this parameter is null, a temporary in-memory databse will be used.
+
+
+ The SQL parameter values to be used when building the command object to be
+ executed, if any.
+
+
+ The results of the query -OR- null if no results were produced from the
+ given execution type.
+
+
+
+
+ This method creates a new connection, executes the query using the given
+ execution type and command behavior, closes the connection unless a data
+ reader is created, and returns the results. If the connection string is
+ null, a temporary in-memory database connection will be used.
+
+
+ The text of the command to be executed.
+
+
+ The execution type for the command. This is used to determine which method
+ of the command object to call, which then determines the type of results
+ returned, if any.
+
+
+ The command behavior flags for the command.
+
+
+ The connection string to the database to be opened, used, and closed. If
+ this parameter is null, a temporary in-memory databse will be used.
+
+
+ The SQL parameter values to be used when building the command object to be
+ executed, if any.
+
+
+ The results of the query -OR- null if no results were produced from the
+ given execution type.
+
+
+
+
+ Overrides the default behavior to return a SQLiteDataReader specialization class
+
+ The flags to be associated with the reader.
+ A SQLiteDataReader
+
+
+
+ Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class
+
+ A SQLiteDataReader
+
+
+
+ Called by the SQLiteDataReader when the data reader is closed.
+
+
+
+
+ Execute the command and return the number of rows inserted/updated affected by it.
+
+ The number of rows inserted/updated affected by it.
+
+
+
+ Execute the command and return the number of rows inserted/updated affected by it.
+
+ The flags to be associated with the reader.
+ The number of rows inserted/updated affected by it.
+
+
+
+ Execute the command and return the first column of the first row of the resultset
+ (if present), or null if no resultset was returned.
+
+ The first column of the first row of the first resultset from the query.
+
+
+
+ Execute the command and return the first column of the first row of the resultset
+ (if present), or null if no resultset was returned.
+
+ The flags to be associated with the reader.
+ The first column of the first row of the first resultset from the query.
+
+
+
+ This method resets all the prepared statements held by this instance
+ back to their initial states, ready to be re-executed.
+
+
+
+
+ This method resets all the prepared statements held by this instance
+ back to their initial states, ready to be re-executed.
+
+
+ Non-zero if the parameter bindings should be cleared as well.
+
+
+ If this is zero, a may be thrown for
+ any unsuccessful return codes from the native library; otherwise, a
+ will only be thrown if the connection
+ or its state is invalid.
+
+
+
+
+ Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards.
+
+
+
+
+ Clones a command, including all its parameters
+
+ A new SQLiteCommand with the same commandtext, connection and parameters
+
+
+
+ The SQL command text associated with the command
+
+
+
+
+ The amount of time to wait for the connection to become available before erroring out
+
+
+
+
+ The type of the command. SQLite only supports CommandType.Text
+
+
+
+
+ The connection associated with this command
+
+
+
+
+ Forwards to the local Connection property
+
+
+
+
+ Returns the SQLiteParameterCollection for the given command
+
+
+
+
+ Forwards to the local Parameters property
+
+
+
+
+ The transaction associated with this command. SQLite only supports one transaction per connection, so this property forwards to the
+ command's underlying connection.
+
+
+
+
+ Forwards to the local Transaction property
+
+
+
+
+ Sets the method the SQLiteCommandBuilder uses to determine how to update inserted or updated rows in a DataTable.
+
+
+
+
+ Determines if the command is visible at design time. Defaults to True.
+
+
+
+
+ SQLite implementation of DbCommandBuilder.
+
+
+
+
+ Default constructor
+
+
+
+
+ Initializes the command builder and associates it with the specified data adapter.
+
+
+
+
+
+ Cleans up resources (native and managed) associated with the current instance.
+
+
+ Zero when being disposed via garbage collection; otherwise, non-zero.
+
+
+
+
+ Minimal amount of parameter processing. Primarily sets the DbType for the parameter equal to the provider type in the schema
+
+ The parameter to use in applying custom behaviors to a row
+ The row to apply the parameter to
+ The type of statement
+ Whether the application of the parameter is part of a WHERE clause
+
+
+
+ Returns a valid named parameter
+
+ The name of the parameter
+ Error
+
+
+
+ Returns a named parameter for the given ordinal
+
+ The i of the parameter
+ Error
+
+
+
+ Returns a placeholder character for the specified parameter i.
+
+ The index of the parameter to provide a placeholder for
+ Returns a named parameter
+
+
+
+ Sets the handler for receiving row updating events. Used by the DbCommandBuilder to autogenerate SQL
+ statements that may not have previously been generated.
+
+ A data adapter to receive events on.
+
+
+
+ Returns the automatically-generated SQLite command to delete rows from the database
+
+
+
+
+
+ Returns the automatically-generated SQLite command to delete rows from the database
+
+
+
+
+
+
+ Returns the automatically-generated SQLite command to update rows in the database
+
+
+
+
+
+ Returns the automatically-generated SQLite command to update rows in the database
+
+
+
+
+
+
+ Returns the automatically-generated SQLite command to insert rows into the database
+
+
+
+
+
+ Returns the automatically-generated SQLite command to insert rows into the database
+
+
+
+
+
+
+ Places brackets around an identifier
+
+ The identifier to quote
+ The bracketed identifier
+
+
+
+ Removes brackets around an identifier
+
+ The quoted (bracketed) identifier
+ The undecorated identifier
+
+
+
+ Override helper, which can help the base command builder choose the right keys for the given query
+
+
+
+
+
+
+ Gets/sets the DataAdapter for this CommandBuilder
+
+
+
+
+ Overridden to hide its property from the designer
+
+
+
+
+ Overridden to hide its property from the designer
+
+
+
+
+ Overridden to hide its property from the designer
+
+
+
+
+ Overridden to hide its property from the designer
+
+
+
+
+ Overridden to hide its property from the designer
+
+
+
+
+ This class represents a single value to be returned
+ from the class via
+ its ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ , or
+ method. If the value of the
+ associated public field of this class is null upon returning from the
+ callback, the null value will only be used if the return type for the
+ method called is not a value type.
+ If the value to be returned from the
+ method is unsuitable (e.g. null with a value type), an exception will
+ be thrown.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method -OR- null to
+ indicate an error.
+
+
+
+
+ The value to be returned from the
+ method.
+
+
+
+
+ The value to be returned from the
+ method.
+
+
+
+
+ This class represents the parameters that are provided
+ to the methods, with
+ the exception of the column index (provided separately).
+
+
+
+
+ This class represents the parameters that are provided to
+ the method, with
+ the exception of the column index (provided separately).
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Constructs an instance of this class to pass into a user-defined
+ callback associated with the
+ method.
+
+
+ The value that was originally specified for the "readOnly"
+ parameter to the method.
+
+
+
+
+ The value that was originally specified for the "readOnly"
+ parameter to the method.
+
+
+
+
+ This class represents the parameters that are provided
+ to the and
+ methods, with
+ the exception of the column index (provided separately).
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Constructs an instance of this class to pass into a user-defined
+ callback associated with the
+ method.
+
+
+ The value that was originally specified for the "dataOffset"
+ parameter to the or
+ methods.
+
+
+ The value that was originally specified for the "buffer"
+ parameter to the
+ method.
+
+
+ The value that was originally specified for the "bufferOffset"
+ parameter to the or
+ methods.
+
+
+ The value that was originally specified for the "length"
+ parameter to the or
+ methods.
+
+
+
+
+ Constructs an instance of this class to pass into a user-defined
+ callback associated with the
+ method.
+
+
+ The value that was originally specified for the "dataOffset"
+ parameter to the or
+ methods.
+
+
+ The value that was originally specified for the "buffer"
+ parameter to the
+ method.
+
+
+ The value that was originally specified for the "bufferOffset"
+ parameter to the or
+ methods.
+
+
+ The value that was originally specified for the "length"
+ parameter to the or
+ methods.
+
+
+
+
+ The value that was originally specified for the "dataOffset"
+ parameter to the or
+ methods.
+
+
+
+
+ The value that was originally specified for the "buffer"
+ parameter to the
+ method.
+
+
+
+
+ The value that was originally specified for the "buffer"
+ parameter to the
+ method.
+
+
+
+
+ The value that was originally specified for the "bufferOffset"
+ parameter to the or
+ methods.
+
+
+
+
+ The value that was originally specified for the "length"
+ parameter to the or
+ methods.
+
+
+
+
+ This class represents the parameters and return values for the
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ , and
+ methods.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Constructs a new instance of this class. Depending on the method
+ being called, the and/or
+ parameters may be null.
+
+
+ The name of the method that was
+ responsible for invoking this callback.
+
+
+ If the or
+ method is being called,
+ this object will contain the array related parameters for that
+ method. If the method is
+ being called, this object will contain the blob related parameters
+ for that method.
+
+
+ This may be used by the callback to set the return value for the
+ called method.
+
+
+
+
+ The name of the method that was
+ responsible for invoking this callback.
+
+
+
+
+ If the or
+ method is being called,
+ this object will contain the array related parameters for that
+ method. If the method is
+ being called, this object will contain the blob related parameters
+ for that method.
+
+
+
+
+ This may be used by the callback to set the return value for the
+ called method.
+
+
+
+
+ This represents a method that will be called in response to a request to
+ bind a parameter to a command. If an exception is thrown, it will cause
+ the parameter binding operation to fail -AND- it will continue to unwind
+ the call stack.
+
+
+ The instance in use.
+
+
+ The instance in use.
+
+
+ The flags associated with the instance
+ in use.
+
+
+ The instance being bound to the command.
+
+
+ The database type name associated with this callback.
+
+
+ The ordinal of the parameter being bound to the command.
+
+
+ The data originally used when registering this callback.
+
+
+ Non-zero if the default handling for the parameter binding call should
+ be skipped (i.e. the parameter should not be bound at all). Great care
+ should be used when setting this to non-zero.
+
+
+
+
+ This represents a method that will be called in response to a request
+ to read a value from a data reader. If an exception is thrown, it will
+ cause the data reader operation to fail -AND- it will continue to unwind
+ the call stack.
+
+
+ The instance in use.
+
+
+ The instance in use.
+
+
+ The flags associated with the instance
+ in use.
+
+
+ The parameter and return type data for the column being read from the
+ data reader.
+
+
+ The database type name associated with this callback.
+
+
+ The zero based index of the column being read from the data reader.
+
+
+ The data originally used when registering this callback.
+
+
+ Non-zero if the default handling for the data reader call should be
+ skipped. If this is set to non-zero and the necessary return value
+ is unavailable or unsuitable, an exception will be thrown.
+
+
+
+
+ This class represents the custom data type handling callbacks
+ for a single type name.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Provides the underlying storage for the
+ property.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The custom paramater binding callback. This parameter may be null.
+
+
+ The custom data reader value callback. This parameter may be null.
+
+
+ The extra data to pass into the parameter binding callback. This
+ parameter may be null.
+
+
+ The extra data to pass into the data reader value callback. This
+ parameter may be null.
+
+
+
+
+ Creates an instance of the class.
+
+
+ The custom paramater binding callback. This parameter may be null.
+
+
+ The custom data reader value callback. This parameter may be null.
+
+
+ The extra data to pass into the parameter binding callback. This
+ parameter may be null.
+
+
+ The extra data to pass into the data reader value callback. This
+ parameter may be null.
+
+
+
+
+ The database type name that the callbacks contained in this class
+ will apply to. This value may not be null.
+
+
+
+
+ The custom paramater binding callback. This value may be null.
+
+
+
+
+ The custom data reader value callback. This value may be null.
+
+
+
+
+ The extra data to pass into the parameter binding callback. This
+ value may be null.
+
+
+
+
+ The extra data to pass into the data reader value callback. This
+ value may be null.
+
+
+
+
+ This class represents the mappings between database type names
+ and their associated custom data type handling callbacks.
+
+
+
+
+ Constructs an (empty) instance of this class.
+
+
+
+
+ Event data for connection event handlers.
+
+
+
+
+ The type of event being raised.
+
+
+
+
+ The associated with this event, if any.
+
+
+
+
+ The transaction associated with this event, if any.
+
+
+
+
+ The command associated with this event, if any.
+
+
+
+
+ The data reader associated with this event, if any.
+
+
+
+
+ The critical handle associated with this event, if any.
+
+
+
+
+ Command or message text associated with this event, if any.
+
+
+
+
+ Extra data associated with this event, if any.
+
+
+
+
+ Constructs the object.
+
+ The type of event being raised.
+ The base associated
+ with this event, if any.
+ The transaction associated with this event, if any.
+ The command associated with this event, if any.
+ The data reader associated with this event, if any.
+ The critical handle associated with this event, if any.
+ The command or message text, if any.
+ The extra data, if any.
+
+
+
+ Raised when an event pertaining to a connection occurs.
+
+ The connection involved.
+ Extra information about the event.
+
+
+
+ SQLite implentation of DbConnection.
+
+
+ The property can contain the following parameter(s), delimited with a semi-colon:
+
+
+ Parameter
+ Values
+ Required
+ Default
+
+ -
+ Data Source
+
+ This may be a file name, the string ":memory:", or any supported URI (starting with SQLite 3.7.7).
+ Starting with release 1.0.86.0, in order to use more than one consecutive backslash (e.g. for a
+ UNC path), each of the adjoining backslash characters must be doubled (e.g. "\\Network\Share\test.db"
+ would become "\\\\Network\Share\test.db").
+
+ Y
+
+
+ -
+ Uri
+
+ If specified, this must be a file name that starts with "file://", "file:", or "/". Any leading
+ "file://" or "file:" prefix will be stripped off and the resulting file name will be used to open
+ the database.
+
+ N
+ null
+
+ -
+ FullUri
+
+ If specified, this must be a URI in a format recognized by the SQLite core library (starting with
+ SQLite 3.7.7). It will be passed verbatim to the SQLite core library.
+
+ N
+ null
+
+ -
+ Version
+ 3
+ N
+ 3
+
+ -
+ UseUTF16Encoding
+
+ True - The UTF-16 encoding should be used.
+
+ False - The UTF-8 encoding should be used.
+
+ N
+ False
+
+ -
+ DefaultDbType
+
+ This is the default to use when one cannot be determined based on the
+ column metadata and the configured type mappings.
+
+ N
+ null
+
+ -
+ DefaultTypeName
+
+ This is the default type name to use when one cannot be determined based on the column metadata
+ and the configured type mappings.
+
+ N
+ null
+
+ -
+ NoDefaultFlags
+
+ True - Do not combine the specified (or existing) connection flags with the value of the
+ property.
+
+ False - Combine the specified (or existing) connection flags with the value of the
+ property.
+
+ N
+ False
+
+ -
+ NoSharedFlags
+
+ True - Do not combine the specified (or existing) connection flags with the value of the
+ property.
+
+ False - Combine the specified (or existing) connection flags with the value of the
+ property.
+
+ N
+ False
+
+ -
+ VfsName
+
+ The name of the VFS to use when opening the database connection.
+ If this is not specified, the default VFS will be used.
+
+ N
+ null
+
+ -
+ ZipVfsVersion
+
+ If non-null, this is the "version" of ZipVFS to use. This requires
+ the System.Data.SQLite interop assembly -AND- primary managed assembly
+ to be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this
+ property does nothing. The valid values are "v2" and "v3". Using
+ anyother value will cause an exception to be thrown. Please see the
+ ZipVFS documentation for more information on how to use this parameter.
+
+ N
+ null
+
+ -
+ DateTimeFormat
+
+ Ticks - Use the value of DateTime.Ticks.
+ ISO8601 - Use the ISO-8601 format. Uses the "yyyy-MM-dd HH:mm:ss.FFFFFFFK" format for UTC
+ DateTime values and "yyyy-MM-dd HH:mm:ss.FFFFFFF" format for local DateTime values).
+ JulianDay - The interval of time in days and fractions of a day since January 1, 4713 BC.
+ UnixEpoch - The whole number of seconds since the Unix epoch (January 1, 1970).
+ InvariantCulture - Any culture-independent string value that the .NET Framework can interpret as a valid DateTime.
+ CurrentCulture - Any string value that the .NET Framework can interpret as a valid DateTime using the current culture.
+ N
+ ISO8601
+
+ -
+ DateTimeKind
+
+ Unspecified - Not specified as either UTC or local time.
+
+ Utc - The time represented is UTC.
+
+ Local - The time represented is local time.
+
+ N
+ Unspecified
+
+ -
+ DateTimeFormatString
+
+ The exact DateTime format string to use for all formatting and parsing of all DateTime
+ values for this connection.
+
+ N
+ null
+
+ -
+ BaseSchemaName
+
+ Some base data classes in the framework (e.g. those that build SQL queries dynamically)
+ assume that an ADO.NET provider cannot support an alternate catalog (i.e. database) without supporting
+ alternate schemas as well; however, SQLite does not fit into this model. Therefore, this value is used
+ as a placeholder and removed prior to preparing any SQL statements that may contain it.
+
+ N
+ sqlite_default_schema
+
+ -
+ BinaryGUID
+
+ True - Store GUID columns in binary form
+
+ False - Store GUID columns as text
+
+ N
+ True
+
+ -
+ Cache Size
+
+ If the argument N is positive then the suggested cache size is set to N.
+ If the argument N is negative, then the number of cache pages is adjusted
+ to use approximately abs(N*4096) bytes of memory. Backwards compatibility
+ note: The behavior of cache_size with a negative N was different in SQLite
+ versions prior to 3.7.10. In version 3.7.9 and earlier, the number of
+ pages in the cache was set to the absolute value of N.
+
+ N
+ -2000
+
+ -
+ Synchronous
+
+ Normal - Normal file flushing behavior
+
+ Full - Full flushing after all writes
+
+ Off - Underlying OS flushes I/O's
+
+ N
+ Full
+
+ -
+ Page Size
+ {size in bytes}
+ N
+ 4096
+
+ -
+ Password
+
+ {password} - Using this parameter requires that the CryptoAPI based codec
+ be enabled at compile-time for both the native interop assembly and the
+ core managed assemblies; otherwise, using this parameter may result in an
+ exception being thrown when attempting to open the connection.
+
+ N
+
+
+ -
+ HexPassword
+
+ {hexPassword} - Must contain a sequence of zero or more hexadecimal encoded
+ byte values without a leading "0x" prefix. Using this parameter requires
+ that the CryptoAPI based codec be enabled at compile-time for both the native
+ interop assembly and the core managed assemblies; otherwise, using this
+ parameter may result in an exception being thrown when attempting to open
+ the connection.
+
+ N
+
+
+ -
+ Enlist
+
+ Y - Automatically enlist in distributed transactions
+
+ N - No automatic enlistment
+
+ N
+ Y
+
+ -
+ Pooling
+
+ True - Use connection pooling.
+ False - Do not use connection pooling.
+ WARNING: When using the default connection pool implementation,
+ setting this property to True should be avoided by applications that make
+ use of COM (either directly or indirectly) due to possible deadlocks that
+ can occur during the finalization of some COM objects.
+
+ N
+ False
+
+ -
+ FailIfMissing
+
+ True - Don't create the database if it does not exist, throw an error instead
+
+ False - Automatically create the database if it does not exist
+
+ N
+ False
+
+ -
+ Max Page Count
+ {size in pages} - Limits the maximum number of pages (limits the size) of the database
+ N
+ 0
+
+ -
+ Legacy Format
+
+ True - Use the more compatible legacy 3.x database format
+
+ False - Use the newer 3.3x database format which compresses numbers more effectively
+
+ N
+ False
+
+ -
+ Default Timeout
+ {time in seconds}
The default command timeout
+ N
+ 30
+
+ -
+ BusyTimeout
+ {time in milliseconds}
Sets the busy timeout for the core library.
+ N
+ 0
+
+ -
+ Journal Mode
+
+ Delete - Delete the journal file after a commit.
+
+ Persist - Zero out and leave the journal file on disk after a
+ commit.
+
+ Off - Disable the rollback journal entirely. This saves disk I/O
+ but at the expense of database safety and integrity. If the application
+ using SQLite crashes in the middle of a transaction when this journaling
+ mode is set, then the database file will very likely go corrupt.
+
+ Truncate - Truncate the journal file to zero-length instead of
+ deleting it.
+
+ Memory - Store the journal in volatile RAM. This saves disk I/O
+ but at the expense of database safety and integrity. If the application
+ using SQLite crashes in the middle of a transaction when this journaling
+ mode is set, then the database file will very likely go corrupt.
+
+ Wal - Use a write-ahead log instead of a rollback journal.
+
+ N
+ Delete
+
+ -
+ Read Only
+
+ True - Open the database for read only access
+
+ False - Open the database for normal read/write access
+
+ N
+ False
+
+ -
+ Max Pool Size
+ The maximum number of connections for the given connection string that can be in the connection pool
+ N
+ 100
+
+ -
+ Default IsolationLevel
+ The default transaciton isolation level
+ N
+ Serializable
+
+ -
+ Foreign Keys
+ Enable foreign key constraints
+ N
+ False
+
+ -
+ Flags
+ Extra behavioral flags for the connection. See the enumeration for possible values.
+ N
+ Default
+
+ -
+ SetDefaults
+
+ True - Apply the default connection settings to the opened database.
+ False - Skip applying the default connection settings to the opened database.
+
+ N
+ True
+
+ -
+ ToFullPath
+
+ True - Attempt to expand the data source file name to a fully qualified path before opening.
+
+ False - Skip attempting to expand the data source file name to a fully qualified path before opening.
+
+ N
+ True
+
+ -
+ PrepareRetries
+
+ The maximum number of retries when preparing SQL to be executed. This
+ normally only applies to preparation errors resulting from the database
+ schema being changed.
+
+ N
+ 3
+
+ -
+ ProgressOps
+
+ The approximate number of virtual machine instructions between progress
+ events. In order for progress events to actually fire, the event handler
+ must be added to the event as well.
+
+ N
+ 0
+
+ -
+ Recursive Triggers
+
+ True - Enable the recursive trigger capability.
+ False - Disable the recursive trigger capability.
+
+ N
+ False
+
+
+
+
+
+
+ The "invalid value" for the enumeration used
+ by the property. This constant is shared
+ by this class and the SQLiteConnectionStringBuilder class.
+
+
+
+
+ The default "stub" (i.e. placeholder) base schema name to use when
+ returning column schema information. Used as the initial value of
+ the BaseSchemaName property. This should start with "sqlite_*"
+ because those names are reserved for use by SQLite (i.e. they cannot
+ be confused with the names of user objects).
+
+
+
+
+ The managed assembly containing this type.
+
+
+
+
+ Object used to synchronize access to the static instance data
+ for this class.
+
+
+
+
+ The extra connection flags to be used for all opened connections.
+
+
+
+
+ The instance (for this thread) that
+ had the most recent call to .
+
+
+
+
+ State of the current connection
+
+
+
+
+ The connection string
+
+
+
+
+ Nesting level of the transactions open on the connection
+
+
+
+
+ Transaction counter for the connection. Currently, this is only used
+ to build SAVEPOINT names.
+
+
+
+
+ If this flag is non-zero, the method will have
+ no effect; however, the method will continue to
+ behave as normal.
+
+
+
+
+ If set, then the connection is currently being disposed.
+
+
+
+
+ The default isolation level for new transactions
+
+
+
+
+ Whether or not the connection is enlisted in a distrubuted transaction
+
+
+
+
+ The per-connection mappings between type names and
+ values. These mappings override the corresponding global mappings.
+
+
+
+
+ The per-connection mappings between type names and optional callbacks
+ for parameter binding and value reading.
+
+
+
+
+ The base SQLite object to interop with
+
+
+
+
+ The database filename minus path and extension
+
+
+
+
+ Temporary password storage, emptied after the database has been opened
+
+
+
+
+ The "stub" (i.e. placeholder) base schema name to use when returning
+ column schema information.
+
+
+
+
+ The extra behavioral flags for this connection, if any. See the
+ enumeration for a list of
+ possible values.
+
+
+
+
+ The cached values for all settings that have been fetched on behalf
+ of this connection. This cache may be cleared by calling the
+ method.
+
+
+
+
+ The default databse type for this connection. This value will only
+ be used if the
+ flag is set.
+
+
+
+
+ The default databse type name for this connection. This value will only
+ be used if the
+ flag is set.
+
+
+
+
+ The name of the VFS to be used when opening the database connection.
+
+
+
+
+ Default command timeout
+
+
+
+
+ The default busy timeout to use with the SQLite core library. This is
+ only used when opening a connection.
+
+
+
+
+ The maximum number of retries when preparing SQL to be executed. This
+ normally only applies to preparation errors resulting from the database
+ schema being changed.
+
+
+
+
+ The approximate number of virtual machine instructions between progress
+ events. In order for progress events to actually fire, the event handler
+ must be added to the event as
+ well. This value will only be used when opening the database.
+
+
+
+
+ Non-zero if the built-in (i.e. framework provided) connection string
+ parser should be used when opening the connection.
+
+
+
+
+ Constructs a new SQLiteConnection object
+
+
+ Default constructor
+
+
+
+
+ Initializes the connection with the specified connection string.
+
+ The connection string to use.
+
+
+
+ Initializes the connection with a pre-existing native connection handle.
+ This constructor overload is intended to be used only by the private
+ method.
+
+
+ The native connection handle to use.
+
+
+ The file name corresponding to the native connection handle.
+
+
+ Non-zero if this instance owns the native connection handle and
+ should dispose of it when it is no longer needed.
+
+
+
+
+ Initializes the connection with the specified connection string.
+
+
+ The connection string to use.
+
+
+ Non-zero to parse the connection string using the built-in (i.e.
+ framework provided) parser when opening the connection.
+
+
+
+
+ Clones the settings and connection string from an existing connection. If the existing connection is already open, this
+ function will open its own connection, enumerate any attached databases of the original connection, and automatically
+ attach to them.
+
+ The connection to copy the settings from.
+
+
+
+ Raises the event.
+
+
+ The connection associated with this event. If this parameter is not
+ null and the specified connection cannot raise events, then the
+ registered event handlers will not be invoked.
+
+
+ A that contains the event data.
+
+
+
+
+ Creates and returns a new managed database connection handle. This
+ method is intended to be used by implementations of the
+ interface only. In theory, it
+ could be used by other classes; however, that usage is not supported.
+
+
+ This must be a native database connection handle returned by the
+ SQLite core library and it must remain valid and open during the
+ entire duration of the calling method.
+
+
+ The new managed database connection handle or null if it cannot be
+ created.
+
+
+
+
+ Backs up the database, using the specified database connection as the
+ destination.
+
+ The destination database connection.
+ The destination database name.
+ The source database name.
+
+ The number of pages to copy or negative to copy all remaining pages.
+
+
+ The method to invoke between each step of the backup process. This
+ parameter may be null (i.e. no callbacks will be performed).
+
+
+ The number of milliseconds to sleep after encountering a locking error
+ during the backup process. A value less than zero means that no sleep
+ should be performed.
+
+
+
+
+ Clears the per-connection cached settings.
+
+
+ The total number of per-connection settings cleared.
+
+
+
+
+ Queries and returns the value of the specified setting, using the
+ cached setting names and values for this connection, when available.
+
+
+ The name of the setting.
+
+
+ The value to be returned if the setting has not been set explicitly
+ or cannot be determined.
+
+
+ The value of the cached setting is stored here if found; otherwise,
+ the value of is stored here.
+
+
+ Non-zero if the cached setting was found; otherwise, zero.
+
+
+
+
+ Adds or sets the cached setting specified by
+ to the value specified by .
+
+
+ The name of the cached setting to add or replace.
+
+
+ The new value of the cached setting.
+
+
+
+
+ Clears the per-connection type mappings.
+
+
+ The total number of per-connection type mappings cleared.
+
+
+
+
+ Returns the per-connection type mappings.
+
+
+ The per-connection type mappings -OR- null if they are unavailable.
+
+
+
+
+ Adds a per-connection type mapping, possibly replacing one or more
+ that already exist.
+
+
+ The case-insensitive database type name (e.g. "MYDATE"). The value
+ of this parameter cannot be null. Using an empty string value (or
+ a string value consisting entirely of whitespace) for this parameter
+ is not recommended.
+
+
+ The value that should be associated with the
+ specified type name.
+
+
+ Non-zero if this mapping should be considered to be the primary one
+ for the specified .
+
+
+ A negative value if nothing was done. Zero if no per-connection type
+ mappings were replaced (i.e. it was a pure add operation). More than
+ zero if some per-connection type mappings were replaced.
+
+
+
+
+ Clears the per-connection type callbacks.
+
+
+ The total number of per-connection type callbacks cleared.
+
+
+
+
+ Attempts to get the per-connection type callbacks for the specified
+ database type name.
+
+
+ The database type name.
+
+
+ Upon success, this parameter will contain the object holding the
+ callbacks for the database type name. Upon failure, this parameter
+ will be null.
+
+
+ Non-zero upon success; otherwise, zero.
+
+
+
+
+ Sets, resets, or clears the per-connection type callbacks for the
+ specified database type name.
+
+
+ The database type name.
+
+
+ The object holding the callbacks for the database type name. If
+ this parameter is null, any callbacks for the database type name
+ will be removed if they are present.
+
+
+ Non-zero if callbacks were set or removed; otherwise, zero.
+
+
+
+
+ Attempts to bind the specified object
+ instance to this connection.
+
+
+ The object instance containing
+ the metadata for the function to be bound.
+
+
+ The object instance that implements the
+ function to be bound.
+
+
+
+
+ Attempts to bind the specified object
+ instance to this connection.
+
+
+ The object instance containing
+ the metadata for the function to be bound.
+
+
+ A object instance that helps implement the
+ function to be bound. For scalar functions, this corresponds to the
+ type. For aggregate functions,
+ this corresponds to the type. For
+ collation functions, this corresponds to the
+ type.
+
+
+ A object instance that helps implement the
+ function to be bound. For aggregate functions, this corresponds to the
+ type. For other callback types, it
+ is not used and must be null.
+
+
+
+
+ Attempts to unbind the specified object
+ instance to this connection.
+
+
+ The object instance containing
+ the metadata for the function to be unbound.
+
+ Non-zero if the function was unbound.
+
+
+
+ This method unbinds all registered (known) functions -OR- all previously
+ bound user-defined functions from this connection.
+
+
+ Non-zero to unbind all registered (known) functions -OR- zero to unbind
+ all functions currently bound to the connection.
+
+
+ Non-zero if all the specified user-defined functions were unbound.
+
+
+
+
+ Parses a connection string into component parts using the custom
+ connection string parser. An exception may be thrown if the syntax
+ of the connection string is incorrect.
+
+
+ The connection string to parse.
+
+
+ Non-zero to parse the connection string using the algorithm provided
+ by the framework itself. This is not applicable when running on the
+ .NET Compact Framework.
+
+
+ Non-zero if names are allowed without values.
+
+
+ The list of key/value pairs corresponding to the parameters specified
+ within the connection string.
+
+
+
+
+ Parses a connection string into component parts using the custom
+ connection string parser. An exception may be thrown if the syntax
+ of the connection string is incorrect.
+
+
+ The connection that will be using the parsed connection string.
+
+
+ The connection string to parse.
+
+
+ Non-zero to parse the connection string using the algorithm provided
+ by the framework itself. This is not applicable when running on the
+ .NET Compact Framework.
+
+
+ Non-zero if names are allowed without values.
+
+
+ The list of key/value pairs corresponding to the parameters specified
+ within the connection string.
+
+
+
+
+ Disposes and finalizes the connection, if applicable.
+
+
+
+
+ Cleans up resources (native and managed) associated with the current instance.
+
+
+ Zero when being disposed via garbage collection; otherwise, non-zero.
+
+
+
+
+ Creates a clone of the connection. All attached databases and user-defined functions are cloned. If the existing connection is open, the cloned connection
+ will also be opened.
+
+
+
+
+
+ Creates a database file. This just creates a zero-byte file which SQLite
+ will turn into a database when the file is opened properly.
+
+ The file to create
+
+
+
+ Raises the state change event when the state of the connection changes
+
+ The new connection state. If this is different
+ from the previous state, the event is
+ raised.
+ The event data created for the raised event, if
+ it was actually raised.
+
+
+
+ Determines and returns the fallback default isolation level when one cannot be
+ obtained from an existing connection instance.
+
+
+ The fallback default isolation level for this connection instance -OR-
+ if it cannot be determined.
+
+
+
+
+ Determines and returns the default isolation level for this connection instance.
+
+
+ The default isolation level for this connection instance -OR-
+ if it cannot be determined.
+
+
+
+
+ OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.
+
+ This parameter is ignored.
+ When TRUE, SQLite defers obtaining a write lock until a write operation is requested.
+ When FALSE, a writelock is obtained immediately. The default is TRUE, but in a multi-threaded multi-writer
+ environment, one may instead choose to lock the database immediately to avoid any possible writer deadlock.
+ Returns a SQLiteTransaction object.
+
+
+
+ OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.
+
+ When TRUE, SQLite defers obtaining a write lock until a write operation is requested.
+ When FALSE, a writelock is obtained immediately. The default is false, but in a multi-threaded multi-writer
+ environment, one may instead choose to lock the database immediately to avoid any possible writer deadlock.
+ Returns a SQLiteTransaction object.
+
+
+
+ Creates a new if one isn't already active on the connection.
+
+ Supported isolation levels are Serializable, ReadCommitted and Unspecified.
+
+ Unspecified will use the default isolation level specified in the connection string. If no isolation level is specified in the
+ connection string, Serializable is used.
+ Serializable transactions are the default. In this mode, the engine gets an immediate lock on the database, and no other threads
+ may begin a transaction. Other threads may read from the database, but not write.
+ With a ReadCommitted isolation level, locks are deferred and elevated as needed. It is possible for multiple threads to start
+ a transaction in ReadCommitted mode, but if a thread attempts to commit a transaction while another thread
+ has a ReadCommitted lock, it may timeout or cause a deadlock on both threads until both threads' CommandTimeout's are reached.
+
+ Returns a SQLiteTransaction object.
+
+
+
+ Creates a new if one isn't already
+ active on the connection.
+
+ Returns the new transaction object.
+
+
+
+ Forwards to the local function
+
+ Supported isolation levels are Unspecified, Serializable, and ReadCommitted
+
+
+
+
+ This method is not implemented; however, the
+ event will still be raised.
+
+
+
+
+
+ When the database connection is closed, all commands linked to this connection are automatically reset.
+
+
+
+
+ Clears the connection pool associated with the connection. Any other active connections using the same database file
+ will be discarded instead of returned to the pool when they are closed.
+
+
+
+
+
+ Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed.
+
+
+
+
+ Create a new and associate it with this connection.
+
+ Returns a new command object already assigned to this connection.
+
+
+
+ Forwards to the local function.
+
+
+
+
+
+ Determines if the legacy connection string parser should be used.
+
+
+ The connection that will be using the parsed connection string.
+
+
+ Non-zero if the legacy connection string parser should be used.
+
+
+
+
+ Parses a connection string into component parts using the custom
+ connection string parser. An exception may be thrown if the syntax
+ of the connection string is incorrect.
+
+
+ The connection string to parse.
+
+
+ Non-zero if names are allowed without values.
+
+
+ The list of key/value pairs corresponding to the parameters specified
+ within the connection string.
+
+
+
+
+ Parses a connection string into component parts using the custom
+ connection string parser. An exception may be thrown if the syntax
+ of the connection string is incorrect.
+
+
+ The connection that will be using the parsed connection string.
+
+
+ The connection string to parse.
+
+
+ Non-zero if names are allowed without values.
+
+
+ The list of key/value pairs corresponding to the parameters specified
+ within the connection string.
+
+
+
+
+ Parses a connection string using the built-in (i.e. framework provided)
+ connection string parser class and returns the key/value pairs. An
+ exception may be thrown if the connection string is invalid or cannot be
+ parsed. When compiled for the .NET Compact Framework, the custom
+ connection string parser is always used instead because the framework
+ provided one is unavailable there.
+
+
+ The connection that will be using the parsed connection string.
+
+
+ The connection string to parse.
+
+
+ Non-zero to throw an exception if any connection string values are not of
+ the type. This is not applicable when running on
+ the .NET Compact Framework.
+
+ The list of key/value pairs.
+
+
+
+ Manual distributed transaction enlistment support
+
+ The distributed transaction to enlist in
+
+
+
+ Looks for a key in the array of key/values of the parameter string. If not found, return the specified default value
+
+ The list to look in
+ The key to find
+ The default value to return if the key is not found
+ The value corresponding to the specified key, or the default value if not found.
+
+
+
+ Attempts to convert the string value to an enumerated value of the specified type.
+
+ The enumerated type to convert the string value to.
+ The string value to be converted.
+ Non-zero to make the conversion case-insensitive.
+ The enumerated value upon success or null upon error.
+
+
+
+ Attempts to convert an input string into a byte value.
+
+
+ The string value to be converted.
+
+
+ The number styles to use for the conversion.
+
+
+ Upon sucess, this will contain the parsed byte value.
+ Upon failure, the value of this parameter is undefined.
+
+
+ Non-zero upon success; zero on failure.
+
+
+
+
+ Enables or disables a configuration option for the database.
+
+
+ The database configuration option to enable or disable.
+
+
+ True to enable loading of extensions, false to disable.
+
+
+
+
+ Enables or disabled extension loading.
+
+
+ True to enable loading of extensions, false to disable.
+
+
+
+
+ Loads a SQLite extension library from the named dynamic link library file.
+
+
+ The name of the dynamic link library file containing the extension.
+
+
+
+
+ Loads a SQLite extension library from the named dynamic link library file.
+
+
+ The name of the dynamic link library file containing the extension.
+
+
+ The name of the exported function used to initialize the extension.
+ If null, the default "sqlite3_extension_init" will be used.
+
+
+
+
+ Creates a disposable module containing the implementation of a virtual
+ table.
+
+
+ The module object to be used when creating the disposable module.
+
+
+
+
+ Parses a string containing a sequence of zero or more hexadecimal
+ encoded byte values and returns the resulting byte array. The
+ "0x" prefix is not allowed on the input string.
+
+
+ The input string containing zero or more hexadecimal encoded byte
+ values.
+
+
+ A byte array containing the parsed byte values or null if an error
+ was encountered.
+
+
+
+
+ Creates and returns a string containing the hexadecimal encoded byte
+ values from the input array.
+
+
+ The input array of bytes.
+
+
+ The resulting string or null upon failure.
+
+
+
+
+ Parses a string containing a sequence of zero or more hexadecimal
+ encoded byte values and returns the resulting byte array. The
+ "0x" prefix is not allowed on the input string.
+
+
+ The input string containing zero or more hexadecimal encoded byte
+ values.
+
+
+ Upon failure, this will contain an appropriate error message.
+
+
+ A byte array containing the parsed byte values or null if an error
+ was encountered.
+
+
+
+
+ This method figures out what the default connection pool setting should
+ be based on the connection flags. When present, the "Pooling" connection
+ string property value always overrides the value returned by this method.
+
+
+ Non-zero if the connection pool should be enabled by default; otherwise,
+ zero.
+
+
+
+
+ Determines the transaction isolation level that should be used by
+ the caller, primarily based upon the one specified by the caller.
+ If mapping of transaction isolation levels is enabled, the returned
+ transaction isolation level may be significantly different than the
+ originally specified one.
+
+
+ The originally specified transaction isolation level.
+
+
+ The transaction isolation level that should be used.
+
+
+
+
+ Opens the connection using the parameters found in the .
+
+
+
+
+ Opens the connection using the parameters found in the and then returns it.
+
+ The current connection object.
+
+
+
+ This method causes any pending database operation to abort and return at
+ its earliest opportunity. This routine is typically called in response
+ to a user action such as pressing "Cancel" or Ctrl-C where the user wants
+ a long query operation to halt immediately. It is safe to call this
+ routine from any thread. However, it is not safe to call this routine
+ with a database connection that is closed or might close before this method
+ returns.
+
+
+
+
+ Checks if this connection to the specified database should be considered
+ read-only. An exception will be thrown if the database name specified
+ via cannot be found.
+
+
+ The name of a database associated with this connection -OR- null for the
+ main database.
+
+
+ Non-zero if this connection to the specified database should be considered
+ read-only.
+
+
+
+
+ Returns various global memory statistics for the SQLite core library via
+ a dictionary of key/value pairs. Currently, only the "MemoryUsed" and
+ "MemoryHighwater" keys are returned and they have values that correspond
+ to the values that could be obtained via the
+ and connection properties.
+
+
+ This dictionary will be populated with the global memory statistics. It
+ will be created if necessary.
+
+
+
+
+ Attempts to free as much heap memory as possible for this database connection.
+
+
+
+
+ Attempts to free N bytes of heap memory by deallocating non-essential memory
+ allocations held by the database library. Memory used to cache database pages
+ to improve performance is an example of non-essential memory. This is a no-op
+ returning zero if the SQLite core library was not compiled with the compile-time
+ option SQLITE_ENABLE_MEMORY_MANAGEMENT. Optionally, attempts to reset and/or
+ compact the Win32 native heap, if applicable.
+
+
+ The requested number of bytes to free.
+
+
+ Non-zero to attempt a heap reset.
+
+
+ Non-zero to attempt heap compaction.
+
+
+ The number of bytes actually freed. This value may be zero.
+
+
+ This value will be non-zero if the heap reset was successful.
+
+
+ The size of the largest committed free block in the heap, in bytes.
+ This value will be zero unless heap compaction is enabled.
+
+
+ A standard SQLite return code (i.e. zero for success and non-zero
+ for failure).
+
+
+
+
+ Sets the status of the memory usage tracking subsystem in the SQLite core library. By default, this is enabled.
+ If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is
+ global to the process.
+
+ Non-zero to enable memory usage tracking, zero otherwise.
+ A standard SQLite return code (i.e. zero for success and non-zero for failure).
+
+
+
+ Queries and returns the value of the specified setting, using the
+ cached setting names and values for the last connection that used
+ by the method, when available.
+
+
+ The name of the setting.
+
+
+ The value to be returned if the setting has not been set explicitly
+ or cannot be determined.
+
+
+ The value of the cached setting is stored here if found; otherwise,
+ the value of is stored here.
+
+
+ Non-zero if the cached setting was found; otherwise, zero.
+
+
+
+
+ Passes a shutdown request to the SQLite core library. Does not throw
+ an exception if the shutdown request fails.
+
+
+ A standard SQLite return code (i.e. zero for success and non-zero for
+ failure).
+
+
+
+
+ Passes a shutdown request to the SQLite core library. Throws an
+ exception if the shutdown request fails and the no-throw parameter
+ is non-zero.
+
+
+ Non-zero to reset the database and temporary directories to their
+ default values, which should be null for both.
+
+
+ When non-zero, throw an exception if the shutdown request fails.
+
+
+
+ Enables or disabled extended result codes returned by SQLite
+
+
+ Enables or disabled extended result codes returned by SQLite
+
+
+ Enables or disabled extended result codes returned by SQLite
+
+
+ Add a log message via the SQLite sqlite3_log interface.
+
+
+ Add a log message via the SQLite sqlite3_log interface.
+
+
+
+ Change the password (or assign a password) to an open database.
+
+
+ No readers or writers may be active for this process. The database must already be open
+ and if it already was password protected, the existing password must already have been supplied.
+
+ The new password to assign to the database
+
+
+
+ Change the password (or assign a password) to an open database.
+
+
+ No readers or writers may be active for this process. The database must already be open
+ and if it already was password protected, the existing password must already have been supplied.
+
+ The new password to assign to the database
+
+
+
+ Sets the password for a password-protected database. A password-protected database is
+ unusable for any operation until the password has been set.
+
+ The password for the database
+
+
+
+ Sets the password for a password-protected database. A password-protected database is
+ unusable for any operation until the password has been set.
+
+ The password for the database
+
+
+
+ Queries or modifies the number of retries or the retry interval (in milliseconds) for
+ certain I/O operations that may fail due to anti-virus software.
+
+ The number of times to retry the I/O operation. A negative value
+ will cause the current count to be queried and replace that negative value.
+ The number of milliseconds to wait before retrying the I/O
+ operation. This number is multiplied by the number of retry attempts so far to come
+ up with the final number of milliseconds to wait. A negative value will cause the
+ current interval to be queried and replace that negative value.
+ Zero for success, non-zero for error.
+
+
+
+ Sets the chunk size for the primary file associated with this database
+ connection.
+
+
+ The new chunk size for the main database, in bytes.
+
+
+ Zero for success, non-zero for error.
+
+
+
+
+ Removes one set of surrounding single -OR- double quotes from the string
+ value and returns the resulting string value. If the string is null, empty,
+ or contains quotes that are not balanced, nothing is done and the original
+ string value will be returned.
+
+ The string value to process.
+
+ The string value, modified to remove one set of surrounding single -OR-
+ double quotes, if applicable.
+
+
+
+
+ Determines the directory to be used when dealing with the "|DataDirectory|"
+ macro in a database file name.
+
+
+ The directory to use in place of the "|DataDirectory|" macro -OR- null if it
+ cannot be determined.
+
+
+
+
+ Expand the filename of the data source, resolving the |DataDirectory|
+ macro as appropriate.
+
+ The database filename to expand
+
+ Non-zero if the returned file name should be converted to a full path
+ (except when using the .NET Compact Framework).
+
+ The expanded path and filename of the filename
+
+
+
+ The following commands are used to extract schema information out of the database. Valid schema types are:
+
+ -
+ MetaDataCollections
+
+ -
+ DataSourceInformation
+
+ -
+ Catalogs
+
+ -
+ Columns
+
+ -
+ ForeignKeys
+
+ -
+ Indexes
+
+ -
+ IndexColumns
+
+ -
+ Tables
+
+ -
+ Views
+
+ -
+ ViewColumns
+
+
+
+
+ Returns the MetaDataCollections schema
+
+ A DataTable of the MetaDataCollections schema
+
+
+
+ Returns schema information of the specified collection
+
+ The schema collection to retrieve
+ A DataTable of the specified collection
+
+
+
+ Retrieves schema information using the specified constraint(s) for the specified collection
+
+ The collection to retrieve.
+
+ The restrictions to impose. Typically, this may include:
+
+
+ restrictionValues element index
+ usage
+
+ -
+ 0
+ The database (or catalog) name, if applicable.
+
+ -
+ 1
+ The schema name. This is not used by this provider.
+
+ -
+ 2
+ The table name, if applicable.
+
+ -
+ 3
+
+ Depends on .
+ When "IndexColumns", it is the index name; otherwise, it is the column name.
+
+
+ -
+ 4
+
+ Depends on .
+ When "IndexColumns", it is the column name; otherwise, it is not used.
+
+
+
+
+ A DataTable of the specified collection
+
+
+
+ Builds a MetaDataCollections schema datatable
+
+ DataTable
+
+
+
+ Builds a DataSourceInformation datatable
+
+ DataTable
+
+
+
+ Build a Columns schema
+
+ The catalog (attached database) to query, can be null
+ The table to retrieve schema information for, must not be null
+ The column to retrieve schema information for, can be null
+ DataTable
+
+
+
+ Returns index information for the given database and catalog
+
+ The catalog (attached database) to query, can be null
+ The name of the index to retrieve information for, can be null
+ The table to retrieve index information for, can be null
+ DataTable
+
+
+
+ Retrieves table schema information for the database and catalog
+
+ The catalog (attached database) to retrieve tables on
+ The table to retrieve, can be null
+ The table type, can be null
+ DataTable
+
+
+
+ Retrieves view schema information for the database
+
+ The catalog (attached database) to retrieve views on
+ The view name, can be null
+ DataTable
+
+
+
+ Retrieves catalog (attached databases) schema information for the database
+
+ The catalog to retrieve, can be null
+ DataTable
+
+
+
+ Returns the base column information for indexes in a database
+
+ The catalog to retrieve indexes for (can be null)
+ The table to restrict index information by (can be null)
+ The index to restrict index information by (can be null)
+ The source column to restrict index information by (can be null)
+ A DataTable containing the results
+
+
+
+ Returns detailed column information for a specified view
+
+ The catalog to retrieve columns for (can be null)
+ The view to restrict column information by (can be null)
+ The source column to restrict column information by (can be null)
+ A DataTable containing the results
+
+
+
+ Retrieves foreign key information from the specified set of filters
+
+ An optional catalog to restrict results on
+ An optional table to restrict results on
+ An optional foreign key name to restrict results on
+ A DataTable with the results of the query
+
+
+
+ Static variable to store the connection event handlers to call.
+
+
+
+
+ This event is raised whenever the database is opened or closed.
+
+
+
+
+ This event is raised when events related to the lifecycle of a
+ SQLiteConnection object occur.
+
+
+
+
+ This property is used to obtain or set the custom connection pool
+ implementation to use, if any. Setting this property to null will
+ cause the default connection pool implementation to be used.
+
+
+
+
+ Returns the number of pool entries for the file name associated with this connection.
+
+
+
+
+ The connection string containing the parameters for the connection
+
+
+ For the complete list of supported connection string properties,
+ please see .
+
+
+
+
+ Returns the data source file name without extension or path.
+
+
+
+
+ Returns the fully qualified path and file name for the currently open
+ database, if any.
+
+
+
+
+ Returns the string "main".
+
+
+
+
+ Gets/sets the default command timeout for newly-created commands. This is especially useful for
+ commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible.
+ This can also be set in the ConnectionString with "Default Timeout"
+
+
+
+
+ Gets/sets the default busy timeout to use with the SQLite core library. This is only used when
+ opening a connection.
+
+
+
+
+ The maximum number of retries when preparing SQL to be executed. This
+ normally only applies to preparation errors resulting from the database
+ schema being changed.
+
+
+
+
+ The approximate number of virtual machine instructions between progress
+ events. In order for progress events to actually fire, the event handler
+ must be added to the event as
+ well. This value will only be used when the underlying native progress
+ callback needs to be changed.
+
+
+
+
+ Non-zero if the built-in (i.e. framework provided) connection string
+ parser should be used when opening the connection.
+
+
+
+
+ Gets/sets the extra behavioral flags for this connection. See the
+ enumeration for a list of
+ possible values.
+
+
+
+
+ Gets/sets the default database type for this connection. This value
+ will only be used when not null.
+
+
+
+
+ Gets/sets the default database type name for this connection. This
+ value will only be used when not null.
+
+
+
+
+ Gets/sets the VFS name for this connection. This value will only be
+ used when opening the database.
+
+
+
+
+ Returns non-zero if the underlying native connection handle is
+ owned by this instance.
+
+
+
+
+ Returns the version of the underlying SQLite database engine
+
+
+
+
+ Returns the rowid of the most recent successful INSERT into the database from this connection.
+
+
+
+
+ Returns the number of rows changed by the last INSERT, UPDATE, or DELETE statement executed on
+ this connection.
+
+
+
+
+ Returns non-zero if the given database connection is in autocommit mode.
+ Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN
+ statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
+
+
+
+
+ Returns the amount of memory (in bytes) currently in use by the SQLite core library.
+
+
+
+
+ Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
+
+
+
+
+ Returns a string containing the define constants (i.e. compile-time
+ options) used to compile the core managed assembly, delimited with
+ spaces.
+
+
+
+
+ Returns the version of the underlying SQLite core library.
+
+
+
+
+ This method returns the string whose value is the same as the
+ SQLITE_SOURCE_ID C preprocessor macro used when compiling the
+ SQLite core library.
+
+
+
+
+ Returns a string containing the compile-time options used to
+ compile the SQLite core native library, delimited with spaces.
+
+
+
+
+ This method returns the version of the interop SQLite assembly
+ used. If the SQLite interop assembly is not in use or the
+ necessary information cannot be obtained for any reason, a null
+ value may be returned.
+
+
+
+
+ This method returns the string whose value contains the unique
+ identifier for the source checkout used to build the interop
+ assembly. If the SQLite interop assembly is not in use or the
+ necessary information cannot be obtained for any reason, a null
+ value may be returned.
+
+
+
+
+ Returns a string containing the compile-time options used to
+ compile the SQLite interop assembly, delimited with spaces.
+
+
+
+
+ This method returns the version of the managed components used
+ to interact with the SQLite core library. If the necessary
+ information cannot be obtained for any reason, a null value may
+ be returned.
+
+
+
+
+ This method returns the string whose value contains the unique
+ identifier for the source checkout used to build the managed
+ components currently executing. If the necessary information
+ cannot be obtained for any reason, a null value may be returned.
+
+
+
+
+ The default connection flags to be used for all opened connections
+ when they are not present in the connection string.
+
+
+
+
+ The extra connection flags to be used for all opened connections.
+
+
+
+
+ Returns the state of the connection.
+
+
+
+
+ This event is raised periodically during long running queries. Changing
+ the value of the property will
+ determine if the operation in progress will continue or be interrupted.
+ For the entire duration of the event, the associated connection and
+ statement objects must not be modified, either directly or indirectly, by
+ the called code.
+
+
+
+
+ This event is raised whenever SQLite encounters an action covered by the
+ authorizer during query preparation. Changing the value of the
+ property will determine if
+ the specific action will be allowed, ignored, or denied. For the entire
+ duration of the event, the associated connection and statement objects
+ must not be modified, either directly or indirectly, by the called code.
+
+
+
+
+ This event is raised whenever SQLite makes an update/delete/insert into the database on
+ this connection. It only applies to the given connection.
+
+
+
+
+ This event is raised whenever SQLite is committing a transaction.
+ Return non-zero to trigger a rollback.
+
+
+
+
+ This event is raised whenever SQLite statement first begins executing on
+ this connection. It only applies to the given connection.
+
+
+
+
+ This event is raised whenever SQLite is rolling back a transaction.
+
+
+
+
+ Returns the instance.
+
+
+
+
+ The I/O file cache flushing behavior for the connection
+
+
+
+
+ Normal file flushing at critical sections of the code
+
+
+
+
+ Full file flushing after every write operation
+
+
+
+
+ Use the default operating system's file flushing, SQLite does not explicitly flush the file buffers after writing
+
+
+
+
+ Raised each time the number of virtual machine instructions is
+ approximately equal to the value of the
+ property.
+
+ The connection performing the operation.
+ A that contains the
+ event data.
+
+
+
+ Raised when authorization is required to perform an action contained
+ within a SQL query.
+
+ The connection performing the action.
+ A that contains the
+ event data.
+
+
+
+ Raised when a transaction is about to be committed. To roll back a transaction, set the
+ rollbackTrans boolean value to true.
+
+ The connection committing the transaction
+ Event arguments on the transaction
+
+
+
+ Raised when data is inserted, updated and deleted on a given connection
+
+ The connection committing the transaction
+ The event parameters which triggered the event
+
+
+
+ Raised when a statement first begins executing on a given connection
+
+ The connection executing the statement
+ Event arguments of the trace
+
+
+
+ Raised between each backup step.
+
+
+ The source database connection.
+
+
+ The source database name.
+
+
+ The destination database connection.
+
+
+ The destination database name.
+
+
+ The number of pages copied with each step.
+
+
+ The number of pages remaining to be copied.
+
+
+ The total number of pages in the source database.
+
+
+ Set to true if the operation needs to be retried due to database
+ locking issues; otherwise, set to false.
+
+
+ True to continue with the backup process or false to halt the backup
+ process, rolling back any changes that have been made so far.
+
+
+
+
+ The event data associated with progress reporting events.
+
+
+
+
+ The user-defined native data associated with this event. Currently,
+ this will always contain the value of .
+
+
+
+
+ The return code for the current call into the progress callback.
+
+
+
+
+ Constructs an instance of this class with default property values.
+
+
+
+
+ Constructs an instance of this class with specific property values.
+
+
+ The user-defined native data associated with this event.
+
+
+ The progress return code.
+
+
+
+
+ The data associated with a call into the authorizer.
+
+
+
+
+ The user-defined native data associated with this event. Currently,
+ this will always contain the value of .
+
+
+
+
+ The action code responsible for the current call into the authorizer.
+
+
+
+
+ The first string argument for the current call into the authorizer.
+ The exact value will vary based on the action code, see the
+ enumeration for possible
+ values.
+
+
+
+
+ The second string argument for the current call into the authorizer.
+ The exact value will vary based on the action code, see the
+ enumeration for possible
+ values.
+
+
+
+
+ The database name for the current call into the authorizer, if
+ applicable.
+
+
+
+
+ The name of the inner-most trigger or view that is responsible for
+ the access attempt or a null value if this access attempt is directly
+ from top-level SQL code.
+
+
+
+
+ The return code for the current call into the authorizer.
+
+
+
+
+ Constructs an instance of this class with default property values.
+
+
+
+
+ Constructs an instance of this class with specific property values.
+
+
+ The user-defined native data associated with this event.
+
+
+ The authorizer action code.
+
+
+ The first authorizer argument.
+
+
+ The second authorizer argument.
+
+
+ The database name, if applicable.
+
+
+ The name of the inner-most trigger or view that is responsible for
+ the access attempt or a null value if this access attempt is directly
+ from top-level SQL code.
+
+
+ The authorizer return code.
+
+
+
+
+ Whenever an update event is triggered on a connection, this enum will indicate
+ exactly what type of operation is being performed.
+
+
+
+
+ A row is being deleted from the given database and table
+
+
+
+
+ A row is being inserted into the table.
+
+
+
+
+ A row is being updated in the table.
+
+
+
+
+ Passed during an Update callback, these event arguments detail the type of update operation being performed
+ on the given connection.
+
+
+
+
+ The name of the database being updated (usually "main" but can be any attached or temporary database)
+
+
+
+
+ The name of the table being updated
+
+
+
+
+ The type of update being performed (insert/update/delete)
+
+
+
+
+ The RowId affected by this update.
+
+
+
+
+ Event arguments raised when a transaction is being committed
+
+
+
+
+ Set to true to abort the transaction and trigger a rollback
+
+
+
+
+ Passed during an Trace callback, these event arguments contain the UTF-8 rendering of the SQL statement text
+
+
+
+
+ SQL statement text as the statement first begins executing
+
+
+
+
+ This interface represents a custom connection pool implementation
+ usable by System.Data.SQLite.
+
+
+
+
+ Counts the number of pool entries matching the specified file name.
+
+
+ The file name to match or null to match all files.
+
+
+ The pool entry counts for each matching file.
+
+
+ The total number of connections successfully opened from any pool.
+
+
+ The total number of connections successfully closed from any pool.
+
+
+ The total number of pool entries for all matching files.
+
+
+
+
+ Disposes of all pooled connections associated with the specified
+ database file name.
+
+
+ The database file name.
+
+
+
+
+ Disposes of all pooled connections.
+
+
+
+
+ Adds a connection to the pool of those associated with the
+ specified database file name.
+
+
+ The database file name.
+
+
+ The database connection handle.
+
+
+ The connection pool version at the point the database connection
+ handle was received from the connection pool. This is also the
+ connection pool version that the database connection handle was
+ created under.
+
+
+
+
+ Removes a connection from the pool of those associated with the
+ specified database file name with the intent of using it to
+ interact with the database.
+
+
+ The database file name.
+
+
+ The new maximum size of the connection pool for the specified
+ database file name.
+
+
+ The connection pool version associated with the returned database
+ connection handle, if any.
+
+
+ The database connection handle associated with the specified
+ database file name or null if it cannot be obtained.
+
+
+
+
+ This default method implementations in this class should not be used by
+ applications that make use of COM (either directly or indirectly) due
+ to possible deadlocks that can occur during finalization of some COM
+ objects.
+
+
+
+
+ This field is used to synchronize access to the private static data
+ in this class.
+
+
+
+
+ When this field is non-null, it will be used to provide the
+ implementation of all the connection pool methods; otherwise,
+ the default method implementations will be used.
+
+
+
+
+ The dictionary of connection pools, based on the normalized file
+ name of the SQLite database.
+
+
+
+
+ The default version number new pools will get.
+
+
+
+
+ The number of connections successfully opened from any pool.
+ This value is incremented by the Remove method.
+
+
+
+
+ The number of connections successfully closed from any pool.
+ This value is incremented by the Add method.
+
+
+
+
+ Counts the number of pool entries matching the specified file name.
+
+
+ The file name to match or null to match all files.
+
+
+ The pool entry counts for each matching file.
+
+
+ The total number of connections successfully opened from any pool.
+
+
+ The total number of connections successfully closed from any pool.
+
+
+ The total number of pool entries for all matching files.
+
+
+
+
+ Disposes of all pooled connections associated with the specified
+ database file name.
+
+
+ The database file name.
+
+
+
+
+ Disposes of all pooled connections.
+
+
+
+
+ Adds a connection to the pool of those associated with the
+ specified database file name.
+
+
+ The database file name.
+
+
+ The database connection handle.
+
+
+ The connection pool version at the point the database connection
+ handle was received from the connection pool. This is also the
+ connection pool version that the database connection handle was
+ created under.
+
+
+
+
+ Removes a connection from the pool of those associated with the
+ specified database file name with the intent of using it to
+ interact with the database.
+
+
+ The database file name.
+
+
+ The new maximum size of the connection pool for the specified
+ database file name.
+
+
+ The connection pool version associated with the returned database
+ connection handle, if any.
+
+
+ The database connection handle associated with the specified
+ database file name or null if it cannot be obtained.
+
+
+
+
+ This method is used to obtain a reference to the custom connection
+ pool implementation currently in use, if any.
+
+
+ The custom connection pool implementation or null if the default
+ connection pool implementation should be used.
+
+
+
+
+ This method is used to set the reference to the custom connection
+ pool implementation to use, if any.
+
+
+ The custom connection pool implementation to use or null if the
+ default connection pool implementation should be used.
+
+
+
+
+ We do not have to thread-lock anything in this function, because it
+ is only called by other functions above which already take the lock.
+
+
+ The pool queue to resize.
+
+
+ If a function intends to add to the pool, this is true, which
+ forces the resize to take one more than it needs from the pool.
+
+
+
+
+ Keeps track of connections made on a specified file. The PoolVersion
+ dictates whether old objects get returned to the pool or discarded
+ when no longer in use.
+
+
+
+
+ The queue of weak references to the actual database connection
+ handles.
+
+
+
+
+ This pool version associated with the database connection
+ handles in this pool queue.
+
+
+
+
+ The maximum size of this pool queue.
+
+
+
+
+ Constructs a connection pool queue using the specified version
+ and maximum size. Normally, all the database connection
+ handles in this pool are associated with a single database file
+ name.
+
+
+ The initial pool version for this connection pool queue.
+
+
+ The initial maximum size for this connection pool queue.
+
+
+
+
+ SQLite implementation of DbConnectionStringBuilder.
+
+
+
+
+ Properties of this class
+
+
+
+
+ Constructs a new instance of the class
+
+
+ Default constructor
+
+
+
+
+ Constructs a new instance of the class using the specified connection string.
+
+ The connection string to parse
+
+
+
+ Private initializer, which assigns the connection string and resets the builder
+
+ The connection string to assign
+
+
+
+ Helper function for retrieving values from the connectionstring
+
+ The keyword to retrieve settings for
+ The resulting parameter value
+ Returns true if the value was found and returned
+
+
+
+ Fallback method for MONO, which doesn't implement DbConnectionStringBuilder.GetProperties()
+
+ The hashtable to fill with property descriptors
+
+
+
+ Gets/Sets the default version of the SQLite engine to instantiate. Currently the only valid value is 3, indicating version 3 of the sqlite library.
+
+
+
+
+ Gets/Sets the synchronization mode (file flushing) of the connection string. Default is "Normal".
+
+
+
+
+ Gets/Sets the encoding for the connection string. The default is "False" which indicates UTF-8 encoding.
+
+
+
+
+ Gets/Sets whether or not to use connection pooling. The default is "False"
+
+
+
+
+ Gets/Sets whethor not to store GUID's in binary format. The default is True
+ which saves space in the database.
+
+
+
+
+ Gets/Sets the filename to open on the connection string.
+
+
+
+
+ An alternate to the data source property
+
+
+
+
+ An alternate to the data source property that uses the SQLite URI syntax.
+
+
+
+
+ Gets/sets the default command timeout for newly-created commands. This is especially useful for
+ commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible.
+
+
+
+
+ Gets/sets the busy timeout to use with the SQLite core library.
+
+
+
+
+ Gets/sets the maximum number of retries when preparing SQL to be executed.
+ This normally only applies to preparation errors resulting from the database
+ schema being changed.
+
+
+
+
+ Gets/sets the approximate number of virtual machine instructions between
+ progress events. In order for progress events to actually fire, the event
+ handler must be added to the event
+ as well.
+
+
+
+
+ Determines whether or not the connection will automatically participate
+ in the current distributed transaction (if one exists)
+
+
+
+
+ If set to true, will throw an exception if the database specified in the connection
+ string does not exist. If false, the database will be created automatically.
+
+
+
+
+ If enabled, uses the legacy 3.xx format for maximum compatibility, but results in larger
+ database sizes.
+
+
+
+
+ When enabled, the database will be opened for read-only access and writing will be disabled.
+
+
+
+
+ Gets/sets the database encryption password
+
+
+
+
+ Gets/sets the database encryption hexadecimal password
+
+
+
+
+ Gets/Sets the page size for the connection.
+
+
+
+
+ Gets/Sets the maximum number of pages the database may hold
+
+
+
+
+ Gets/Sets the cache size for the connection.
+
+
+
+
+ Gets/Sets the DateTime format for the connection.
+
+
+
+
+ Gets/Sets the DateTime kind for the connection.
+
+
+
+
+ Gets/sets the DateTime format string used for formatting
+ and parsing purposes.
+
+
+
+
+ Gets/Sets the placeholder base schema name used for
+ .NET Framework compatibility purposes.
+
+
+
+
+ Determines how SQLite handles the transaction journal file.
+
+
+
+
+ Sets the default isolation level for transactions on the connection.
+
+
+
+
+ Gets/sets the default database type for the connection.
+
+
+
+
+ Gets/sets the default type name for the connection.
+
+
+
+
+ Gets/sets the VFS name for the connection.
+
+
+
+
+ If enabled, use foreign key constraints
+
+
+
+
+ Enable or disable the recursive trigger capability.
+
+
+
+
+ If non-null, this is the version of ZipVFS to use. This requires the
+ System.Data.SQLite interop assembly -AND- primary managed assembly to
+ be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this
+ property does nothing.
+
+
+
+
+ Gets/Sets the extra behavioral flags.
+
+
+
+
+ If enabled, apply the default connection settings to opened databases.
+
+
+
+
+ If enabled, attempt to resolve the provided data source file name to a
+ full path before opening.
+
+
+
+
+ If enabled, skip using the configured default connection flags.
+
+
+
+
+ If enabled, skip using the configured shared connection flags.
+
+
+
+
+ SQLite has very limited types, and is inherently text-based. The first 5 types below represent the sum of all types SQLite
+ understands. The DateTime extension to the spec is for internal use only.
+
+
+
+
+ Not used
+
+
+
+
+ All integers in SQLite default to Int64
+
+
+
+
+ All floating point numbers in SQLite default to double
+
+
+
+
+ The default data type of SQLite is text
+
+
+
+
+ Typically blob types are only seen when returned from a function
+
+
+
+
+ Null types can be returned from functions
+
+
+
+
+ Used internally by this provider
+
+
+
+
+ Used internally by this provider
+
+
+
+
+ These are the event types associated with the
+
+ delegate (and its corresponding event) and the
+ class.
+
+
+
+
+ Not used.
+
+
+
+
+ Not used.
+
+
+
+
+ The connection is being opened.
+
+
+
+
+ The connection string has been parsed.
+
+
+
+
+ The connection was opened.
+
+
+
+
+ The method was called on the
+ connection.
+
+
+
+
+ A transaction was created using the connection.
+
+
+
+
+ The connection was enlisted into a transaction.
+
+
+
+
+ A command was created using the connection.
+
+
+
+
+ A data reader was created using the connection.
+
+
+
+
+ An instance of a derived class has
+ been created to wrap a native resource.
+
+
+
+
+ The connection is being closed.
+
+
+
+
+ The connection was closed.
+
+
+
+
+ A command is being disposed.
+
+
+
+
+ A data reader is being disposed.
+
+
+
+
+ A data reader is being closed.
+
+
+
+
+ A native resource was opened (i.e. obtained) from the pool.
+
+
+
+
+ A native resource was closed (i.e. released) to the pool.
+
+
+
+
+ This implementation of SQLite for ADO.NET can process date/time fields in
+ databases in one of six formats.
+
+
+ ISO8601 format is more compatible, readable, fully-processable, but less
+ accurate as it does not provide time down to fractions of a second.
+ JulianDay is the numeric format the SQLite uses internally and is arguably
+ the most compatible with 3rd party tools. It is not readable as text
+ without post-processing. Ticks less compatible with 3rd party tools that
+ query the database, and renders the DateTime field unreadable as text
+ without post-processing. UnixEpoch is more compatible with Unix systems.
+ InvariantCulture allows the configured format for the invariant culture
+ format to be used and is human readable. CurrentCulture allows the
+ configured format for the current culture to be used and is also human
+ readable.
+
+ The preferred order of choosing a DateTime format is JulianDay, ISO8601,
+ and then Ticks. Ticks is mainly present for legacy code support.
+
+
+
+
+ Use the value of DateTime.Ticks. This value is not recommended and is not well supported with LINQ.
+
+
+
+
+ Use the ISO-8601 format. Uses the "yyyy-MM-dd HH:mm:ss.FFFFFFFK" format for UTC DateTime values and
+ "yyyy-MM-dd HH:mm:ss.FFFFFFF" format for local DateTime values).
+
+
+
+
+ The interval of time in days and fractions of a day since January 1, 4713 BC.
+
+
+
+
+ The whole number of seconds since the Unix epoch (January 1, 1970).
+
+
+
+
+ Any culture-independent string value that the .NET Framework can interpret as a valid DateTime.
+
+
+
+
+ Any string value that the .NET Framework can interpret as a valid DateTime using the current culture.
+
+
+
+
+ The default format for this provider.
+
+
+
+
+ This enum determines how SQLite treats its journal file.
+
+
+ By default SQLite will create and delete the journal file when needed during a transaction.
+ However, for some computers running certain filesystem monitoring tools, the rapid
+ creation and deletion of the journal file can cause those programs to fail, or to interfere with SQLite.
+
+ If a program or virus scanner is interfering with SQLite's journal file, you may receive errors like "unable to open database file"
+ when starting a transaction. If this is happening, you may want to change the default journal mode to Persist.
+
+
+
+
+ The default mode, this causes SQLite to use the existing journaling mode for the database.
+
+
+
+
+ SQLite will create and destroy the journal file as-needed.
+
+
+
+
+ When this is set, SQLite will keep the journal file even after a transaction has completed. It's contents will be erased,
+ and the journal re-used as often as needed. If it is deleted, it will be recreated the next time it is needed.
+
+
+
+
+ This option disables the rollback journal entirely. Interrupted transactions or a program crash can cause database
+ corruption in this mode!
+
+
+
+
+ SQLite will truncate the journal file to zero-length instead of deleting it.
+
+
+
+
+ SQLite will store the journal in volatile RAM. This saves disk I/O but at the expense of database safety and integrity.
+ If the application using SQLite crashes in the middle of a transaction when the MEMORY journaling mode is set, then the
+ database file will very likely go corrupt.
+
+
+
+
+ SQLite uses a write-ahead log instead of a rollback journal to implement transactions. The WAL journaling mode is persistent;
+ after being set it stays in effect across multiple database connections and after closing and reopening the database. A database
+ in WAL journaling mode can only be accessed by SQLite version 3.7.0 or later.
+
+
+
+
+ Possible values for the "synchronous" database setting. This setting determines
+ how often the database engine calls the xSync method of the VFS.
+
+
+
+
+ Use the default "synchronous" database setting. Currently, this should be
+ the same as using the FULL mode.
+
+
+
+
+ The database engine continues without syncing as soon as it has handed
+ data off to the operating system. If the application running SQLite
+ crashes, the data will be safe, but the database might become corrupted
+ if the operating system crashes or the computer loses power before that
+ data has been written to the disk surface.
+
+
+
+
+ The database engine will still sync at the most critical moments, but
+ less often than in FULL mode. There is a very small (though non-zero)
+ chance that a power failure at just the wrong time could corrupt the
+ database in NORMAL mode.
+
+
+
+
+ The database engine will use the xSync method of the VFS to ensure that
+ all content is safely written to the disk surface prior to continuing.
+ This ensures that an operating system crash or power failure will not
+ corrupt the database. FULL synchronous is very safe, but it is also
+ slower.
+
+
+
+
+ The requested command execution type. This controls which method of the
+ object will be called.
+
+
+
+
+ Do nothing. No method will be called.
+
+
+
+
+ The command is not expected to return a result -OR- the result is not
+ needed. The or
+ method
+ will be called.
+
+
+
+
+ The command is expected to return a scalar result -OR- the result should
+ be limited to a scalar result. The
+ or method will
+ be called.
+
+
+
+
+ The command is expected to return result.
+ The or
+ method will
+ be called.
+
+
+
+
+ Use the default command execution type. Using this value is the same
+ as using the value.
+
+
+
+
+ The action code responsible for the current call into the authorizer.
+
+
+
+
+ No action is being performed. This value should not be used from
+ external code.
+
+
+
+
+ No longer used.
+
+
+
+
+ An index will be created. The action-specific arguments are the
+ index name and the table name.
+
+
+
+
+
+ A table will be created. The action-specific arguments are the
+ table name and a null value.
+
+
+
+
+ A temporary index will be created. The action-specific arguments
+ are the index name and the table name.
+
+
+
+
+ A temporary table will be created. The action-specific arguments
+ are the table name and a null value.
+
+
+
+
+ A temporary trigger will be created. The action-specific arguments
+ are the trigger name and the table name.
+
+
+
+
+ A temporary view will be created. The action-specific arguments are
+ the view name and a null value.
+
+
+
+
+ A trigger will be created. The action-specific arguments are the
+ trigger name and the table name.
+
+
+
+
+ A view will be created. The action-specific arguments are the view
+ name and a null value.
+
+
+
+
+ A DELETE statement will be executed. The action-specific arguments
+ are the table name and a null value.
+
+
+
+
+ An index will be dropped. The action-specific arguments are the
+ index name and the table name.
+
+
+
+
+ A table will be dropped. The action-specific arguments are the tables
+ name and a null value.
+
+
+
+
+ A temporary index will be dropped. The action-specific arguments are
+ the index name and the table name.
+
+
+
+
+ A temporary table will be dropped. The action-specific arguments are
+ the table name and a null value.
+
+
+
+
+ A temporary trigger will be dropped. The action-specific arguments
+ are the trigger name and the table name.
+
+
+
+
+ A temporary view will be dropped. The action-specific arguments are
+ the view name and a null value.
+
+
+
+
+ A trigger will be dropped. The action-specific arguments are the
+ trigger name and the table name.
+
+
+
+
+ A view will be dropped. The action-specific arguments are the view
+ name and a null value.
+
+
+
+
+ An INSERT statement will be executed. The action-specific arguments
+ are the table name and a null value.
+
+
+
+
+ A PRAGMA statement will be executed. The action-specific arguments
+ are the name of the PRAGMA and the new value or a null value.
+
+
+
+
+ A table column will be read. The action-specific arguments are the
+ table name and the column name.
+
+
+
+
+ A SELECT statement will be executed. The action-specific arguments
+ are both null values.
+
+
+
+
+ A transaction will be started, committed, or rolled back. The
+ action-specific arguments are the name of the operation (BEGIN,
+ COMMIT, or ROLLBACK) and a null value.
+
+
+
+
+ An UPDATE statement will be executed. The action-specific arguments
+ are the table name and the column name.
+
+
+
+
+ A database will be attached to the connection. The action-specific
+ arguments are the database file name and a null value.
+
+
+
+
+ A database will be detached from the connection. The action-specific
+ arguments are the database name and a null value.
+
+
+
+
+ The schema of a table will be altered. The action-specific arguments
+ are the database name and the table name.
+
+
+
+
+ An index will be deleted and then recreated. The action-specific
+ arguments are the index name and a null value.
+
+
+
+
+ A table will be analyzed to gathers statistics about it. The
+ action-specific arguments are the table name and a null value.
+
+
+
+
+ A virtual table will be created. The action-specific arguments are
+ the table name and the module name.
+
+
+
+
+ A virtual table will be dropped. The action-specific arguments are
+ the table name and the module name.
+
+
+
+
+ A SQL function will be called. The action-specific arguments are a
+ null value and the function name.
+
+
+
+
+ A savepoint will be created, released, or rolled back. The
+ action-specific arguments are the name of the operation (BEGIN,
+ RELEASE, or ROLLBACK) and the savepoint name.
+
+
+
+
+ A recursive query will be executed. The action-specific arguments
+ are two null values.
+
+
+
+
+ The possible return codes for the progress callback.
+
+
+
+
+ The operation should continue.
+
+
+
+
+ The operation should be interrupted.
+
+
+
+
+ The return code for the current call into the authorizer.
+
+
+
+
+ The action will be allowed.
+
+
+
+
+ The overall action will be disallowed and an error message will be
+ returned from the query preparation method.
+
+
+
+
+ The specific action will be disallowed; however, the overall action
+ will continue. The exact effects of this return code vary depending
+ on the specific action, please refer to the SQLite core library
+ documentation for futher details.
+
+
+
+
+ Class used internally to determine the datatype of a column in a resultset
+
+
+
+
+ The DbType of the column, or DbType.Object if it cannot be determined
+
+
+
+
+ The affinity of a column, used for expressions or when Type is DbType.Object
+
+
+
+
+ Constructs a default instance of this type.
+
+
+
+
+ Constructs an instance of this type with the specified field values.
+
+
+ The type affinity to use for the new instance.
+
+
+ The database type to use for the new instance.
+
+
+
+
+ SQLite implementation of DbDataAdapter.
+
+
+
+
+ This class is just a shell around the DbDataAdapter. Nothing from
+ DbDataAdapter is overridden here, just a few constructors are defined.
+
+
+ Default constructor.
+
+
+
+
+ Constructs a data adapter using the specified select command.
+
+
+ The select command to associate with the adapter.
+
+
+
+
+ Constructs a data adapter with the supplied select command text and
+ associated with the specified connection.
+
+
+ The select command text to associate with the data adapter.
+
+
+ The connection to associate with the select command.
+
+
+
+
+ Constructs a data adapter with the specified select command text,
+ and using the specified database connection string.
+
+
+ The select command text to use to construct a select command.
+
+
+ A connection string suitable for passing to a new SQLiteConnection,
+ which is associated with the select command.
+
+
+
+
+ Constructs a data adapter with the specified select command text,
+ and using the specified database connection string.
+
+
+ The select command text to use to construct a select command.
+
+
+ A connection string suitable for passing to a new SQLiteConnection,
+ which is associated with the select command.
+
+
+ Non-zero to parse the connection string using the built-in (i.e.
+ framework provided) parser when opening the connection.
+
+
+
+
+ Cleans up resources (native and managed) associated with the current instance.
+
+
+ Zero when being disposed via garbage collection; otherwise, non-zero.
+
+
+
+
+ Raised by the underlying DbDataAdapter when a row is being updated
+
+ The event's specifics
+
+
+
+ Raised by DbDataAdapter after a row is updated
+
+ The event's specifics
+
+
+
+ Row updating event handler
+
+
+
+
+ Row updated event handler
+
+
+
+
+ Gets/sets the select command for this DataAdapter
+
+
+
+
+ Gets/sets the insert command for this DataAdapter
+
+
+
+
+ Gets/sets the update command for this DataAdapter
+
+
+
+
+ Gets/sets the delete command for this DataAdapter
+
+
+
+
+ SQLite implementation of DbDataReader.
+
+
+
+
+ Underlying command this reader is attached to
+
+
+
+
+ The flags pertaining to the associated connection (via the command).
+
+
+
+
+ Index of the current statement in the command being processed
+
+
+
+
+ Current statement being Read()
+
+
+
+
+ State of the current statement being processed.
+ -1 = First Step() executed, so the first Read() will be ignored
+ 0 = Actively reading
+ 1 = Finished reading
+ 2 = Non-row-returning statement, no records
+
+
+
+
+ Number of records affected by the insert/update statements executed on the command
+
+
+
+
+ Count of fields (columns) in the row-returning statement currently being processed
+
+
+
+
+ The number of calls to Step() that have returned true (i.e. the number of rows that
+ have been read in the current result set).
+
+
+
+
+ Maps the field (column) names to their corresponding indexes within the results.
+
+
+
+
+ Datatypes of active fields (columns) in the current statement, used for type-restricting data
+
+
+
+
+ The behavior of the datareader
+
+
+
+
+ If set, then dispose of the command object when the reader is finished
+
+
+
+
+ If set, then raise an exception when the object is accessed after being disposed.
+
+
+
+
+ An array of rowid's for the active statement if CommandBehavior.KeyInfo is specified
+
+
+
+
+ Matches the version of the connection.
+
+
+
+
+ The "stub" (i.e. placeholder) base schema name to use when returning
+ column schema information. Matches the base schema name used by the
+ associated connection.
+
+
+
+
+ Internal constructor, initializes the datareader and sets up to begin executing statements
+
+ The SQLiteCommand this data reader is for
+ The expected behavior of the data reader
+
+
+
+ Dispose of all resources used by this datareader.
+
+
+
+
+
+ Closes the datareader, potentially closing the connection as well if CommandBehavior.CloseConnection was specified.
+
+
+
+
+ Throw an error if the datareader is closed
+
+
+
+
+ Throw an error if a row is not loaded
+
+
+
+
+ Enumerator support
+
+ Returns a DbEnumerator object.
+
+
+
+ Forces the connection flags cached by this data reader to be refreshed
+ from the underlying connection.
+
+
+
+
+ This method is used to make sure the result set is open and a row is currently available.
+
+
+
+
+ SQLite is inherently un-typed. All datatypes in SQLite are natively strings. The definition of the columns of a table
+ and the affinity of returned types are all we have to go on to type-restrict data in the reader.
+
+ This function attempts to verify that the type of data being requested of a column matches the datatype of the column. In
+ the case of columns that are not backed into a table definition, we attempt to match up the affinity of a column (int, double, string or blob)
+ to a set of known types that closely match that affinity. It's not an exact science, but its the best we can do.
+
+
+ This function throws an InvalidTypeCast() exception if the requested type doesn't match the column's definition or affinity.
+
+ The index of the column to type-check
+ The type we want to get out of the column
+
+
+
+ Invokes the data reader value callback configured for the database
+ type name associated with the specified column. If no data reader
+ value callback is available for the database type name, do nothing.
+
+
+ The index of the column being read.
+
+
+ The extra event data to pass into the callback.
+
+
+ Non-zero if the default handling for the data reader call should be
+ skipped. If this is set to non-zero and the necessary return value
+ is unavailable or unsuitable, an exception will be thrown.
+
+
+
+
+ Attempts to query the integer identifier for the current row. This
+ will not work for tables that were created WITHOUT ROWID -OR- if the
+ query does not include the "rowid" column or one of its aliases -OR-
+ if the was not created with the
+ flag.
+
+
+ The index of the BLOB column.
+
+
+ The integer identifier for the current row -OR- null if it could not
+ be determined.
+
+
+
+
+ Retrieves the column as a object.
+ This will not work for tables that were created WITHOUT ROWID
+ -OR- if the query does not include the "rowid" column or one
+ of its aliases -OR- if the was
+ not created with the
+ flag.
+
+ The index of the column.
+
+ Non-zero to open the blob object for read-only access.
+
+ A new object.
+
+
+
+ Retrieves the column as a boolean value
+
+ The index of the column.
+ bool
+
+
+
+ Retrieves the column as a single byte value
+
+ The index of the column.
+ byte
+
+
+
+ Retrieves a column as an array of bytes (blob)
+
+ The index of the column.
+ The zero-based index of where to begin reading the data
+ The buffer to write the bytes into
+ The zero-based index of where to begin writing into the array
+ The number of bytes to retrieve
+ The actual number of bytes written into the array
+
+ To determine the number of bytes in the column, pass a null value for the buffer. The total length will be returned.
+
+
+
+
+ Returns the column as a single character
+
+ The index of the column.
+ char
+
+
+
+ Retrieves a column as an array of chars (blob)
+
+ The index of the column.
+ The zero-based index of where to begin reading the data
+ The buffer to write the characters into
+ The zero-based index of where to begin writing into the array
+ The number of bytes to retrieve
+ The actual number of characters written into the array
+
+ To determine the number of characters in the column, pass a null value for the buffer. The total length will be returned.
+
+
+
+
+ Retrieves the name of the back-end datatype of the column
+
+ The index of the column.
+ string
+
+
+
+ Retrieve the column as a date/time value
+
+ The index of the column.
+ DateTime
+
+
+
+ Retrieve the column as a decimal value
+
+ The index of the column.
+ decimal
+
+
+
+ Returns the column as a double
+
+ The index of the column.
+ double
+
+
+
+ Returns the .NET type of a given column
+
+ The index of the column.
+ Type
+
+
+
+ Returns a column as a float value
+
+ The index of the column.
+ float
+
+
+
+ Returns the column as a Guid
+
+ The index of the column.
+ Guid
+
+
+
+ Returns the column as a short
+
+ The index of the column.
+ Int16
+
+
+
+ Retrieves the column as an int
+
+ The index of the column.
+ Int32
+
+
+
+ Retrieves the column as a long
+
+ The index of the column.
+ Int64
+
+
+
+ Retrieves the name of the column
+
+ The index of the column.
+ string
+
+
+
+ Returns the name of the database associated with the specified column.
+
+ The index of the column.
+ string
+
+
+
+ Returns the name of the table associated with the specified column.
+
+ The index of the column.
+ string
+
+
+
+ Returns the original name of the specified column.
+
+ The index of the column.
+ string
+
+
+
+ Retrieves the i of a column, given its name
+
+ The name of the column to retrieve
+ The int i of the column
+
+
+
+ Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done
+ to gather the necessary information so it can be represented in an ADO.NET manner.
+
+ Returns a DataTable containing the schema information for the active SELECT statement being processed.
+
+
+
+ Retrieves the column as a string
+
+ The index of the column.
+ string
+
+
+
+ Retrieves the column as an object corresponding to the underlying datatype of the column
+
+ The index of the column.
+ object
+
+
+
+ Retreives the values of multiple columns, up to the size of the supplied array
+
+ The array to fill with values from the columns in the current resultset
+ The number of columns retrieved
+
+
+
+ Returns a collection containing all the column names and values for the
+ current row of data in the current resultset, if any. If there is no
+ current row or no current resultset, an exception may be thrown.
+
+
+ The collection containing the column name and value information for the
+ current row of data in the current resultset or null if this information
+ cannot be obtained.
+
+
+
+
+ Returns True if the specified column is null
+
+ The index of the column.
+ True or False
+
+
+
+ Moves to the next resultset in multiple row-returning SQL command.
+
+ True if the command was successful and a new resultset is available, False otherwise.
+
+
+
+ This method attempts to query the database connection associated with
+ the data reader in use. If the underlying command or connection is
+ unavailable, a null value will be returned.
+
+
+ The connection object -OR- null if it is unavailable.
+
+
+
+
+ Retrieves the SQLiteType for a given column and row value.
+
+
+ The original SQLiteType structure, based only on the column.
+
+
+ The textual value of the column for a given row.
+
+
+ The SQLiteType structure.
+
+
+
+
+ Retrieves the SQLiteType for a given column, and caches it to avoid repetetive interop calls.
+
+ The flags associated with the parent connection object.
+ The index of the column.
+ A SQLiteType structure
+
+
+
+ Reads the next row from the resultset
+
+ True if a new row was successfully loaded and is ready for processing
+
+
+
+ Not implemented. Returns 0
+
+
+
+
+ Returns the number of columns in the current resultset
+
+
+
+
+ Returns the number of rows seen so far in the current result set.
+
+
+
+
+ Returns the number of visible fields in the current resultset
+
+
+
+
+ Returns True if the resultset has rows that can be fetched
+
+
+
+
+ Returns True if the data reader is closed
+
+
+
+
+ Returns the number of rows affected by the statement being executed.
+ The value returned may not be accurate for DDL statements. Also, it
+ will be -1 for any statement that does not modify the database (e.g.
+ SELECT). If an otherwise read-only statement modifies the database
+ indirectly (e.g. via a virtual table or user-defined function), the
+ value returned is undefined.
+
+
+
+
+ Indexer to retrieve data from a column given its name
+
+ The name of the column to retrieve data for
+ The value contained in the column
+
+
+
+ Indexer to retrieve data from a column given its i
+
+ The index of the column.
+ The value contained in the column
+
+
+
+ SQLite exception class.
+
+
+
+
+ Private constructor for use with serialization.
+
+
+ Holds the serialized object data about the exception being thrown.
+
+
+ Contains contextual information about the source or destination.
+
+
+
+
+ Public constructor for generating a SQLite exception given the error
+ code and message.
+
+
+ The SQLite return code to report.
+
+
+ Message text to go along with the return code message text.
+
+
+
+
+ Public constructor that uses the base class constructor for the error
+ message.
+
+ Error message text.
+
+
+
+ Public constructor that uses the default base class constructor.
+
+
+
+
+ Public constructor that uses the base class constructor for the error
+ message and inner exception.
+
+ Error message text.
+ The original (inner) exception.
+
+
+
+ Adds extra information to the serialized object data specific to this
+ class type. This is only used for serialization.
+
+
+ Holds the serialized object data about the exception being thrown.
+
+
+ Contains contextual information about the source or destination.
+
+
+
+
+ Returns the error message for the specified SQLite return code.
+
+ The SQLite return code.
+ The error message or null if it cannot be found.
+
+
+
+ Returns the composite error message based on the SQLite return code
+ and the optional detailed error message.
+
+ The SQLite return code.
+ Optional detailed error message.
+ Error message text for the return code.
+
+
+
+ Gets the associated SQLite result code for this exception as a
+ . This property returns the same
+ underlying value as the property.
+
+
+
+
+ Gets the associated SQLite return code for this exception as an
+ . For desktop versions of the .NET Framework,
+ this property overrides the property of the same name within the
+
+ class. This property returns the same underlying value as the
+ property.
+
+
+
+
+ SQLite error codes. Actually, this enumeration represents a return code,
+ which may also indicate success in one of several ways (e.g. SQLITE_OK,
+ SQLITE_ROW, and SQLITE_DONE). Therefore, the name of this enumeration is
+ something of a misnomer.
+
+
+
+
+ The error code is unknown. This error code
+ is only used by the managed wrapper itself.
+
+
+
+
+ Successful result
+
+
+
+
+ SQL error or missing database
+
+
+
+
+ Internal logic error in SQLite
+
+
+
+
+ Access permission denied
+
+
+
+
+ Callback routine requested an abort
+
+
+
+
+ The database file is locked
+
+
+
+
+ A table in the database is locked
+
+
+
+
+ A malloc() failed
+
+
+
+
+ Attempt to write a readonly database
+
+
+
+
+ Operation terminated by sqlite3_interrupt()
+
+
+
+
+ Some kind of disk I/O error occurred
+
+
+
+
+ The database disk image is malformed
+
+
+
+
+ Unknown opcode in sqlite3_file_control()
+
+
+
+
+ Insertion failed because database is full
+
+
+
+
+ Unable to open the database file
+
+
+
+
+ Database lock protocol error
+
+
+
+
+ Database is empty
+
+
+
+
+ The database schema changed
+
+
+
+
+ String or BLOB exceeds size limit
+
+
+
+
+ Abort due to constraint violation
+
+
+
+
+ Data type mismatch
+
+
+
+
+ Library used incorrectly
+
+
+
+
+ Uses OS features not supported on host
+
+
+
+
+ Authorization denied
+
+
+
+
+ Auxiliary database format error
+
+
+
+
+ 2nd parameter to sqlite3_bind out of range
+
+
+
+
+ File opened that is not a database file
+
+
+
+
+ Notifications from sqlite3_log()
+
+
+
+
+ Warnings from sqlite3_log()
+
+
+
+
+ sqlite3_step() has another row ready
+
+
+
+
+ sqlite3_step() has finished executing
+
+
+
+
+ Used to mask off extended result codes
+
+
+
+
+ A file read operation failed.
+
+
+
+
+ A file read operation returned less data than requested.
+
+
+
+
+ A file write operation failed.
+
+
+
+
+ A file synchronization operation failed.
+
+
+
+
+ A directory synchronization operation failed.
+
+
+
+
+ A file truncate operation failed.
+
+
+
+
+ A file metadata operation failed.
+
+
+
+
+ A file unlock operation failed.
+
+
+
+
+ A file lock operation failed.
+
+
+
+
+ A file delete operation failed.
+
+
+
+
+ Not currently used.
+
+
+
+
+ Out-of-memory during a file operation.
+
+
+
+
+ A file existence/status operation failed.
+
+
+
+
+ A check for a reserved lock failed.
+
+
+
+
+ A file lock operation failed.
+
+
+
+
+ A file close operation failed.
+
+
+
+
+ A directory close operation failed.
+
+
+
+
+ A shared memory open operation failed.
+
+
+
+
+ A shared memory size operation failed.
+
+
+
+
+ A shared memory lock operation failed.
+
+
+
+
+ A shared memory map operation failed.
+
+
+
+
+ A file seek operation failed.
+
+
+
+
+ A file delete operation failed because it does not exist.
+
+
+
+
+ A file memory mapping operation failed.
+
+
+
+
+ The temporary directory path could not be obtained.
+
+
+
+
+ A path string conversion operation failed.
+
+
+
+
+ Reserved.
+
+
+
+
+ An attempt to authenticate failed.
+
+
+
+
+ A database table is locked in shared-cache mode.
+
+
+
+
+ A database file is locked due to a recovery operation.
+
+
+
+
+ A database file is locked due to snapshot semantics.
+
+
+
+
+ A database file cannot be opened because no temporary directory is available.
+
+
+
+
+ A database file cannot be opened because its path represents a directory.
+
+
+
+
+ A database file cannot be opened because its full path could not be obtained.
+
+
+
+
+ A database file cannot be opened because a path string conversion operation failed.
+
+
+
+
+ A virtual table is malformed.
+
+
+
+
+ A database file is read-only due to a recovery operation.
+
+
+
+
+ A database file is read-only because a lock could not be obtained.
+
+
+
+
+ A database file is read-only because it needs rollback processing.
+
+
+
+
+ A database file is read-only because it was moved while open.
+
+
+
+
+ An operation is being aborted due to rollback processing.
+
+
+
+
+ A CHECK constraint failed.
+
+
+
+
+ A commit hook produced a unsuccessful return code.
+
+
+
+
+ A FOREIGN KEY constraint failed.
+
+
+
+
+ Not currently used.
+
+
+
+
+ A NOT NULL constraint failed.
+
+
+
+
+ A PRIMARY KEY constraint failed.
+
+
+
+
+ The RAISE function was used by a trigger-program.
+
+
+
+
+ A UNIQUE constraint failed.
+
+
+
+
+ Not currently used.
+
+
+
+
+ A ROWID constraint failed.
+
+
+
+
+ Frames were recovered from the WAL log file.
+
+
+
+
+ Pages were recovered from the journal file.
+
+
+
+
+ An automatic index was created to process a query.
+
+
+
+
+ User authentication failed.
+
+
+
+
+ Success. Prevents the extension from unloading until the process
+ terminates.
+
+
+
+
+ SQLite implementation of .
+
+
+ SQLite implementation of .
+
+
+
+
+ Constructs a new instance.
+
+
+
+
+ Cleans up resources (native and managed) associated with the current instance.
+
+
+
+
+ Cleans up resources associated with the current instance.
+
+
+
+
+ Static instance member which returns an instanced class.
+
+
+
+
+ Creates and returns a new object.
+
+ The new object.
+
+
+
+ Creates and returns a new object.
+
+ The new object.
+
+
+
+ Creates and returns a new object.
+
+ The new object.
+
+
+
+ Creates and returns a new object.
+
+ The new object.
+
+
+
+ Creates and returns a new object.
+
+ The new object.
+
+
+
+ Creates and returns a new object.
+
+ The new object.
+
+
+
+ Will provide a object in .NET 3.5.
+
+ The class or interface type to query for.
+
+
+
+
+ This event is raised whenever SQLite raises a logging event.
+ Note that this should be set as one of the first things in the
+ application. This event is provided for backward compatibility only.
+ New code should use the class instead.
+
+
+
+
+ This abstract class is designed to handle user-defined functions easily. An instance of the derived class is made for each
+ connection to the database.
+
+
+ Although there is one instance of a class derived from SQLiteFunction per database connection, the derived class has no access
+ to the underlying connection. This is necessary to deter implementers from thinking it would be a good idea to make database
+ calls during processing.
+
+ It is important to distinguish between a per-connection instance, and a per-SQL statement context. One instance of this class
+ services all SQL statements being stepped through on that connection, and there can be many. One should never store per-statement
+ information in member variables of user-defined function classes.
+
+ For aggregate functions, always create and store your per-statement data in the contextData object on the 1st step. This data will
+ be automatically freed for you (and Dispose() called if the item supports IDisposable) when the statement completes.
+
+
+
+
+ The base connection this function is attached to
+
+
+
+
+ Internal array used to keep track of aggregate function context data
+
+
+
+
+ The connection flags associated with this object (this should be the
+ same value as the flags associated with the parent connection object).
+
+
+
+
+ Holds a reference to the callback function for user functions
+
+
+
+
+ Holds a reference to the callbakc function for stepping in an aggregate function
+
+
+
+
+ Holds a reference to the callback function for finalizing an aggregate function
+
+
+
+
+ Holds a reference to the callback function for collating sequences
+
+
+
+
+ Current context of the current callback. Only valid during a callback
+
+
+
+
+ This static dictionary contains all the registered (known) user-defined
+ functions declared using the proper attributes. The contained dictionary
+ values are always null and are not currently used.
+
+
+
+
+ Internal constructor, initializes the function's internal variables.
+
+
+
+
+ Constructs an instance of this class using the specified data-type
+ conversion parameters.
+
+
+ The DateTime format to be used when converting string values to a
+ DateTime and binding DateTime parameters.
+
+
+ The to be used when creating DateTime
+ values.
+
+
+ The format string to be used when parsing and formatting DateTime
+ values.
+
+
+ Non-zero to create a UTF-16 data-type conversion context; otherwise,
+ a UTF-8 data-type conversion context will be created.
+
+
+
+
+ Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if
+ someone closes the connection while a DataReader is open.
+
+
+
+
+ Placeholder for a user-defined disposal routine
+
+ True if the object is being disposed explicitly
+
+
+
+ Cleans up resources associated with the current instance.
+
+
+
+
+ Scalar functions override this method to do their magic.
+
+
+ Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available
+ to force them into a certain type. Therefore the only types you will ever see as parameters are
+ DBNull.Value, Int64, Double, String or byte[] array.
+
+ The arguments for the command to process
+ You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or
+ you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error,
+ just return it!
+
+
+
+ Aggregate functions override this method to do their magic.
+
+
+ Typically you'll be updating whatever you've placed in the contextData field and returning as quickly as possible.
+
+ The arguments for the command to process
+ The 1-based step number. This is incrememted each time the step method is called.
+ A placeholder for implementers to store contextual data pertaining to the current context.
+
+
+
+ Aggregate functions override this method to finish their aggregate processing.
+
+
+ If you implemented your aggregate function properly,
+ you've been recording and keeping track of your data in the contextData object provided, and now at this stage you should have
+ all the information you need in there to figure out what to return.
+ NOTE: It is possible to arrive here without receiving a previous call to Step(), in which case the contextData will
+ be null. This can happen when no rows were returned. You can either return null, or 0 or some other custom return value
+ if that is the case.
+
+ Your own assigned contextData, provided for you so you can return your final results.
+ You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or
+ you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error,
+ just return it!
+
+
+
+
+ User-defined collating sequences override this method to provide a custom string sorting algorithm.
+
+ The first string to compare.
+ The second strnig to compare.
+ 1 if param1 is greater than param2, 0 if they are equal, or -1 if param1 is less than param2.
+
+
+
+ Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to.
+
+
+ Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available
+ to force them into a certain type. Therefore the only types you will ever see as parameters are
+ DBNull.Value, Int64, Double, String or byte[] array.
+
+ The number of arguments
+ A pointer to the array of arguments
+ An object array of the arguments once they've been converted to .NET values
+
+
+
+ Takes the return value from Invoke() and Final() and figures out how to return it to SQLite's context.
+
+ The context the return value applies to
+ The parameter to return to SQLite
+
+
+
+ Internal scalar callback function, which wraps the raw context pointer and calls the virtual Invoke() method.
+ WARNING: Must not throw exceptions.
+
+ A raw context pointer
+ Number of arguments passed in
+ A pointer to the array of arguments
+
+
+
+ Internal collating sequence function, which wraps up the raw string pointers and executes the Compare() virtual function.
+ WARNING: Must not throw exceptions.
+
+ Not used
+ Length of the string pv1
+ Pointer to the first string to compare
+ Length of the string pv2
+ Pointer to the second string to compare
+ Returns -1 if the first string is less than the second. 0 if they are equal, or 1 if the first string is greater
+ than the second. Returns 0 if an exception is caught.
+
+
+
+ Internal collating sequence function, which wraps up the raw string pointers and executes the Compare() virtual function.
+ WARNING: Must not throw exceptions.
+
+ Not used
+ Length of the string pv1
+ Pointer to the first string to compare
+ Length of the string pv2
+ Pointer to the second string to compare
+ Returns -1 if the first string is less than the second. 0 if they are equal, or 1 if the first string is greater
+ than the second. Returns 0 if an exception is caught.
+
+
+
+ The internal aggregate Step function callback, which wraps the raw context pointer and calls the virtual Step() method.
+ WARNING: Must not throw exceptions.
+
+
+ This function takes care of doing the lookups and getting the important information put together to call the Step() function.
+ That includes pulling out the user's contextData and updating it after the call is made. We use a sorted list for this so
+ binary searches can be done to find the data.
+
+ A raw context pointer
+ Number of arguments passed in
+ A pointer to the array of arguments
+
+
+
+ An internal aggregate Final function callback, which wraps the context pointer and calls the virtual Final() method.
+ WARNING: Must not throw exceptions.
+
+ A raw context pointer
+
+
+
+ Using reflection, enumerate all assemblies in the current appdomain looking for classes that
+ have a SQLiteFunctionAttribute attribute, and registering them accordingly.
+
+
+
+
+ Manual method of registering a function. The type must still have the SQLiteFunctionAttributes in order to work
+ properly, but this is a workaround for the Compact Framework where enumerating assemblies is not currently supported.
+
+ The type of the function to register
+
+
+
+ Alternative method of registering a function. This method
+ does not require the specified type to be annotated with
+ .
+
+
+ The name of the function to register.
+
+
+ The number of arguments accepted by the function.
+
+
+ The type of SQLite function being resitered (e.g. scalar,
+ aggregate, or collating sequence).
+
+
+ The that actually implements the function.
+ This will only be used if the
+ and parameters are null.
+
+
+ The to be used for all calls into the
+ ,
+ ,
+ and virtual methods.
+
+
+ The to be used for all calls into the
+ virtual method. This
+ parameter is only necessary for aggregate functions.
+
+
+
+
+ Replaces a registered function, disposing of the associated (old)
+ value if necessary.
+
+
+ The attribute that describes the function to replace.
+
+
+ The new value to use.
+
+
+ Non-zero if an existing registered function was replaced; otherwise,
+ zero.
+
+
+
+
+ Creates a instance based on the specified
+ .
+
+
+ The containing the metadata about
+ the function to create.
+
+
+ The created function -OR- null if the function could not be created.
+
+
+ Non-zero if the function was created; otherwise, zero.
+
+
+
+
+ Called by the SQLiteBase derived classes, this method binds all registered (known) user-defined functions to a connection.
+ It is done this way so that all user-defined functions will access the database using the same encoding scheme
+ as the connection (UTF-8 or UTF-16).
+
+
+ The wrapper functions that interop with SQLite will create a unique cookie value, which internally is a pointer to
+ all the wrapped callback functions. The interop function uses it to map CDecl callbacks to StdCall callbacks.
+
+ The base object on which the functions are to bind.
+ The flags associated with the parent connection object.
+ Returns a logical list of functions which the connection should retain until it is closed.
+
+
+
+ Called by the SQLiteBase derived classes, this method unbinds all registered (known)
+ functions -OR- all previously bound user-defined functions from a connection.
+
+ The base object from which the functions are to be unbound.
+ The flags associated with the parent connection object.
+
+ Non-zero to unbind all registered (known) functions -OR- zero to unbind all functions
+ currently bound to the connection.
+
+ Non-zero if all the specified user-defined functions were unbound.
+
+
+
+ This function binds a user-defined function to a connection.
+
+
+ The object instance associated with the
+ that the function should be bound to.
+
+
+ The object instance containing
+ the metadata for the function to be bound.
+
+
+ The object instance that implements the
+ function to be bound.
+
+
+ The flags associated with the parent connection object.
+
+
+
+
+ This function unbinds a user-defined functions from a connection.
+
+
+ The object instance associated with the
+ that the function should be bound to.
+
+
+ The object instance containing
+ the metadata for the function to be bound.
+
+
+ The object instance that implements the
+ function to be bound.
+
+
+ The flags associated with the parent connection object.
+
+ Non-zero if the function was unbound.
+
+
+
+ Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert
+ strings and DateTime's into the current connection's encoding schema.
+
+
+
+
+ This type is used with the
+ method.
+
+
+ This is always the string literal "Invoke".
+
+
+ The arguments for the scalar function.
+
+
+ The result of the scalar function.
+
+
+
+
+ This type is used with the
+ method.
+
+
+ This is always the string literal "Step".
+
+
+ The arguments for the aggregate function.
+
+
+ The step number (one based). This is incrememted each time the
+ method is called.
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+
+
+ This type is used with the
+ method.
+
+
+ This is always the string literal "Final".
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+ The result of the aggregate function.
+
+
+
+
+ This type is used with the
+ method.
+
+
+ This is always the string literal "Compare".
+
+
+ The first string to compare.
+
+
+ The second strnig to compare.
+
+
+ A positive integer if the parameter is
+ greater than the parameter, a negative
+ integer if the parameter is less than
+ the parameter, or zero if they are
+ equal.
+
+
+
+
+ This class implements a SQLite function using a .
+ All the virtual methods of the class are
+ implemented using calls to the ,
+ , ,
+ and strongly typed delegate types
+ or via the method.
+ The arguments are presented in the same order they appear in
+ the associated methods with one exception:
+ the first argument is the name of the virtual method being implemented.
+
+
+
+
+ This error message is used by the overridden virtual methods when
+ a required property (e.g.
+ or ) has not been
+ set.
+
+
+
+
+ This error message is used by the overridden
+ method when the result does not have a type of .
+
+
+
+
+ Constructs an empty instance of this class.
+
+
+
+
+ Constructs an instance of this class using the specified
+ as the
+ implementation.
+
+
+ The to be used for all calls into the
+ , , and
+ virtual methods needed by the
+ base class.
+
+
+ The to be used for all calls into the
+ virtual methods needed by the
+ base class.
+
+
+
+
+ Returns the list of arguments for the method,
+ as an of . The first
+ argument is always the literal string "Invoke".
+
+
+ The original arguments received by the method.
+
+
+ Non-zero if the returned arguments are going to be used with the
+ type; otherwise, zero.
+
+
+ The arguments to pass to the configured .
+
+
+
+
+ Returns the list of arguments for the method,
+ as an of . The first
+ argument is always the literal string "Step".
+
+
+ The original arguments received by the method.
+
+
+ The step number (one based). This is incrememted each time the
+ method is called.
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+ Non-zero if the returned arguments are going to be used with the
+ type; otherwise, zero.
+
+
+ The arguments to pass to the configured .
+
+
+
+
+ Updates the output arguments for the method,
+ using an of . The first
+ argument is always the literal string "Step". Currently, only the
+ parameter is updated.
+
+
+ The original arguments received by the method.
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+ Non-zero if the returned arguments are going to be used with the
+ type; otherwise, zero.
+
+
+ The arguments to pass to the configured .
+
+
+
+
+ Returns the list of arguments for the method,
+ as an of . The first
+ argument is always the literal string "Final".
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+ Non-zero if the returned arguments are going to be used with the
+ type; otherwise, zero.
+
+
+ The arguments to pass to the configured .
+
+
+
+
+ Returns the list of arguments for the method,
+ as an of . The first
+ argument is always the literal string "Compare".
+
+
+ The first string to compare.
+
+
+ The second strnig to compare.
+
+
+ Non-zero if the returned arguments are going to be used with the
+ type; otherwise, zero.
+
+
+ The arguments to pass to the configured .
+
+
+
+
+ This virtual method is the implementation for scalar functions.
+ See the method for more
+ details.
+
+
+ The arguments for the scalar function.
+
+
+ The result of the scalar function.
+
+
+
+
+ This virtual method is part of the implementation for aggregate
+ functions. See the method
+ for more details.
+
+
+ The arguments for the aggregate function.
+
+
+ The step number (one based). This is incrememted each time the
+ method is called.
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+
+
+ This virtual method is part of the implementation for aggregate
+ functions. See the method
+ for more details.
+
+
+ A placeholder for implementers to store contextual data pertaining
+ to the current context.
+
+
+ The result of the aggregate function.
+
+
+
+
+ This virtual method is part of the implementation for collating
+ sequences. See the method
+ for more details.
+
+
+ The first string to compare.
+
+
+ The second strnig to compare.
+
+
+ A positive integer if the parameter is
+ greater than the parameter, a negative
+ integer if the parameter is less than
+ the parameter, or zero if they are
+ equal.
+
+
+
+
+ The to be used for all calls into the
+ , , and
+ virtual methods needed by the
+ base class.
+
+
+
+
+ The to be used for all calls into the
+ virtual methods needed by the
+ base class.
+
+
+
+
+ Extends SQLiteFunction and allows an inherited class to obtain the collating sequence associated with a function call.
+
+
+ User-defined functions can call the GetCollationSequence() method in this class and use it to compare strings and char arrays.
+
+
+
+
+ Obtains the collating sequence in effect for the given function.
+
+
+
+
+
+ Cleans up resources (native and managed) associated with the current instance.
+
+
+ Zero when being disposed via garbage collection; otherwise, non-zero.
+
+
+
+
+ The type of user-defined function to declare
+
+
+
+
+ Scalar functions are designed to be called and return a result immediately. Examples include ABS(), Upper(), Lower(), etc.
+
+
+
+
+ Aggregate functions are designed to accumulate data until the end of a call and then return a result gleaned from the accumulated data.
+ Examples include SUM(), COUNT(), AVG(), etc.
+
+
+
+
+ Collating sequences are used to sort textual data in a custom manner, and appear in an ORDER BY clause. Typically text in an ORDER BY is
+ sorted using a straight case-insensitive comparison function. Custom collating sequences can be used to alter the behavior of text sorting
+ in a user-defined manner.
+
+
+
+
+ An internal callback delegate declaration.
+
+ Raw native context pointer for the user function.
+ Total number of arguments to the user function.
+ Raw native pointer to the array of raw native argument pointers.
+
+
+
+ An internal final callback delegate declaration.
+
+ Raw context pointer for the user function
+
+
+
+ Internal callback delegate for implementing collating sequences
+
+ Not used
+ Length of the string pv1
+ Pointer to the first string to compare
+ Length of the string pv2
+ Pointer to the second string to compare
+ Returns -1 if the first string is less than the second. 0 if they are equal, or 1 if the first string is greater
+ than the second.
+
+
+
+ The type of collating sequence
+
+
+
+
+ The built-in BINARY collating sequence
+
+
+
+
+ The built-in NOCASE collating sequence
+
+
+
+
+ The built-in REVERSE collating sequence
+
+
+
+
+ A custom user-defined collating sequence
+
+
+
+
+ The encoding type the collation sequence uses
+
+
+
+
+ The collation sequence is UTF8
+
+
+
+
+ The collation sequence is UTF16 little-endian
+
+
+
+
+ The collation sequence is UTF16 big-endian
+
+
+
+
+ A struct describing the collating sequence a function is executing in
+
+
+
+
+ The name of the collating sequence
+
+
+
+
+ The type of collating sequence
+
+
+
+
+ The text encoding of the collation sequence
+
+
+
+
+ Context of the function that requested the collating sequence
+
+
+
+
+ Calls the base collating sequence to compare two strings
+
+ The first string to compare
+ The second string to compare
+ -1 if s1 is less than s2, 0 if s1 is equal to s2, and 1 if s1 is greater than s2
+
+
+
+ Calls the base collating sequence to compare two character arrays
+
+ The first array to compare
+ The second array to compare
+ -1 if c1 is less than c2, 0 if c1 is equal to c2, and 1 if c1 is greater than c2
+
+
+
+ A simple custom attribute to enable us to easily find user-defined functions in
+ the loaded assemblies and initialize them in SQLite as connections are made.
+
+
+
+
+ Default constructor, initializes the internal variables for the function.
+
+
+
+
+ Constructs an instance of this class. This sets the initial
+ , , and
+ properties to null.
+
+
+ The name of the function, as seen by the SQLite core library.
+
+
+ The number of arguments that the function will accept.
+
+
+ The type of function being declared. This will either be Scalar,
+ Aggregate, or Collation.
+
+
+
+
+ The function's name as it will be used in SQLite command text.
+
+
+
+
+ The number of arguments this function expects. -1 if the number of arguments is variable.
+
+
+
+
+ The type of function this implementation will be.
+
+
+
+
+ The object instance that describes the class
+ containing the implementation for the associated function. The value of
+ this property will not be used if either the or
+ property values are set to non-null.
+
+
+
+
+ The that refers to the implementation for the
+ associated function. If this property value is set to non-null, it will
+ be used instead of the property value.
+
+
+
+
+ The that refers to the implementation for the
+ associated function. If this property value is set to non-null, it will
+ be used instead of the property value.
+
+
+
+
+ This class provides key info for a given SQLite statement.
+
+ Providing key information for a given statement is non-trivial :(
+
+
+
+
+
+ This function does all the nasty work at determining what keys need to be returned for
+ a given statement.
+
+
+
+
+
+
+
+ Make sure all the subqueries are open and ready and sync'd with the current rowid
+ of the table they're supporting
+
+
+
+
+ Release any readers on any subqueries
+
+
+
+
+ Append all the columns we've added to the original query to the schema
+
+
+
+
+
+ How many additional columns of keyinfo we're holding
+
+
+
+
+ Used to support CommandBehavior.KeyInfo
+
+
+
+
+ Used to keep track of the per-table RowId column metadata.
+
+
+
+
+ A single sub-query for a given table/database.
+
+
+
+
+ Event data for logging event handlers.
+
+
+
+
+ The error code. The type of this object value should be
+ or .
+
+
+
+
+ SQL statement text as the statement first begins executing
+
+
+
+
+ Extra data associated with this event, if any.
+
+
+
+
+ Constructs the object.
+
+ Should be null.
+
+ The error code. The type of this object value should be
+ or .
+
+ The error message, if any.
+ The extra data, if any.
+
+
+
+ Raised when a log event occurs.
+
+ The current connection
+ Event arguments of the trace
+
+
+
+ Manages the SQLite custom logging functionality and the associated
+ callback for the whole process.
+
+
+
+
+ Object used to synchronize access to the static instance data
+ for this class.
+
+
+
+
+ Member variable to store the AppDomain.DomainUnload event handler.
+
+
+
+
+ The default log event handler.
+
+
+
+
+ The log callback passed to native SQLite engine. This must live
+ as long as the SQLite library has a pointer to it.
+
+
+
+
+ The base SQLite object to interop with.
+
+
+
+
+ This will be non-zero if logging is currently enabled.
+
+
+
+
+ Initializes the SQLite logging facilities.
+
+
+
+
+ Handles the AppDomain being unloaded.
+
+ Should be null.
+ The data associated with this event.
+
+
+
+ Log a message to all the registered log event handlers without going
+ through the SQLite library.
+
+ The message to be logged.
+
+
+
+ Log a message to all the registered log event handlers without going
+ through the SQLite library.
+
+ The SQLite error code.
+ The message to be logged.
+
+
+
+ Log a message to all the registered log event handlers without going
+ through the SQLite library.
+
+ The integer error code.
+ The message to be logged.
+
+
+
+ Log a message to all the registered log event handlers without going
+ through the SQLite library.
+
+
+ The error code. The type of this object value should be
+ System.Int32 or SQLiteErrorCode.
+
+ The message to be logged.
+
+
+
+ Creates and initializes the default log event handler.
+
+
+
+
+ Adds the default log event handler to the list of handlers.
+
+
+
+
+ Removes the default log event handler from the list of handlers.
+
+
+
+
+ Internal proxy function that calls any registered application log
+ event handlers.
+
+ WARNING: This method is used more-or-less directly by native code,
+ do not modify its type signature.
+
+
+ The extra data associated with this message, if any.
+
+
+ The error code associated with this message.
+
+
+ The message string to be logged.
+
+
+
+
+ Default logger. Currently, uses the Trace class (i.e. sends events
+ to the current trace listeners, if any).
+
+ Should be null.
+ The data associated with this event.
+
+
+
+ Member variable to store the application log handler to call.
+
+
+
+
+ This event is raised whenever SQLite raises a logging event.
+ Note that this should be set as one of the first things in the
+ application.
+
+
+
+
+ If this property is true, logging is enabled; otherwise, logging is
+ disabled. When logging is disabled, no logging events will fire.
+
+
+
+
+ MetaDataCollections specific to SQLite
+
+
+
+
+ Returns a list of databases attached to the connection
+
+
+
+
+ Returns column information for the specified table
+
+
+
+
+ Returns index information for the optionally-specified table
+
+
+
+
+ Returns base columns for the given index
+
+
+
+
+ Returns the tables in the given catalog
+
+
+
+
+ Returns user-defined views in the given catalog
+
+
+
+
+ Returns underlying column information on the given view
+
+
+
+
+ Returns foreign key information for the given catalog
+
+
+
+
+ Returns the triggers on the database
+
+
+
+
+ SQLite implementation of DbParameter.
+
+
+
+
+ This value represents an "unknown" .
+
+
+
+
+ The command associated with this parameter.
+
+
+
+
+ The data type of the parameter
+
+
+
+
+ The version information for mapping the parameter
+
+
+
+
+ The value of the data in the parameter
+
+
+
+
+ The source column for the parameter
+
+
+
+
+ The column name
+
+
+
+
+ The data size, unused by SQLite
+
+
+
+
+ The database type name associated with this parameter, if any.
+
+
+
+
+ Constructor used when creating for use with a specific command.
+
+
+ The command associated with this parameter.
+
+
+
+
+ Default constructor
+
+
+
+
+ Constructs a named parameter given the specified parameter name
+
+ The parameter name
+
+
+
+ Constructs a named parameter given the specified parameter name and initial value
+
+ The parameter name
+ The initial value of the parameter
+
+
+
+ Constructs a named parameter of the specified type
+
+ The parameter name
+ The datatype of the parameter
+
+
+
+ Constructs a named parameter of the specified type and source column reference
+
+ The parameter name
+ The data type
+ The source column
+
+
+
+ Constructs a named parameter of the specified type, source column and row version
+
+ The parameter name
+ The data type
+ The source column
+ The row version information
+
+
+
+ Constructs an unnamed parameter of the specified data type
+
+ The datatype of the parameter
+
+
+
+ Constructs an unnamed parameter of the specified data type and sets the initial value
+
+ The datatype of the parameter
+ The initial value of the parameter
+
+
+
+ Constructs an unnamed parameter of the specified data type and source column
+
+ The datatype of the parameter
+ The source column
+
+
+
+ Constructs an unnamed parameter of the specified data type, source column and row version
+
+ The data type
+ The source column
+ The row version information
+
+
+
+ Constructs a named parameter of the specified type and size
+
+ The parameter name
+ The data type
+ The size of the parameter
+
+
+
+ Constructs a named parameter of the specified type, size and source column
+
+ The name of the parameter
+ The data type
+ The size of the parameter
+ The source column
+
+
+
+ Constructs a named parameter of the specified type, size, source column and row version
+
+ The name of the parameter
+ The data type
+ The size of the parameter
+ The source column
+ The row version information
+
+
+
+ Constructs a named parameter of the specified type, size, source column and row version
+
+ The name of the parameter
+ The data type
+ The size of the parameter
+ Only input parameters are supported in SQLite
+ Ignored
+ Ignored
+ Ignored
+ The source column
+ The row version information
+ The initial value to assign the parameter
+
+
+
+ Constructs a named parameter, yet another flavor
+
+ The name of the parameter
+ The data type
+ The size of the parameter
+ Only input parameters are supported in SQLite
+ Ignored
+ Ignored
+ The source column
+ The row version information
+ Whether or not this parameter is for comparing NULL's
+ The intial value to assign the parameter
+
+
+
+ Constructs an unnamed parameter of the specified type and size
+
+ The data type
+ The size of the parameter
+
+
+
+ Constructs an unnamed parameter of the specified type, size, and source column
+
+ The data type
+ The size of the parameter
+ The source column
+
+
+
+ Constructs an unnamed parameter of the specified type, size, source column and row version
+
+ The data type
+ The size of the parameter
+ The source column
+ The row version information
+
+
+
+ Resets the DbType of the parameter so it can be inferred from the value
+
+
+
+
+ Clones a parameter
+
+ A new, unassociated SQLiteParameter
+
+
+
+ The command associated with this parameter.
+
+
+
+
+ Whether or not the parameter can contain a null value
+
+
+
+
+ Returns the datatype of the parameter
+
+
+
+
+ Supports only input parameters
+
+
+
+
+ Returns the parameter name
+
+
+
+
+ Returns the size of the parameter
+
+
+
+
+ Gets/sets the source column
+
+
+
+
+ Used by DbCommandBuilder to determine the mapping for nullable fields
+
+
+
+
+ Gets and sets the row version
+
+
+
+
+ Gets and sets the parameter value. If no datatype was specified, the datatype will assume the type from the value given.
+
+
+
+
+ The database type name associated with this parameter, if any.
+
+
+
+
+ SQLite implementation of DbParameterCollection.
+
+
+
+
+ The underlying command to which this collection belongs
+
+
+
+
+ The internal array of parameters in this collection
+
+
+
+
+ Determines whether or not all parameters have been bound to their statement(s)
+
+
+
+
+ Initializes the collection
+
+ The command to which the collection belongs
+
+
+
+ Retrieves an enumerator for the collection
+
+ An enumerator for the underlying array
+
+
+
+ Adds a parameter to the collection
+
+ The parameter name
+ The data type
+ The size of the value
+ The source column
+ A SQLiteParameter object
+
+
+
+ Adds a parameter to the collection
+
+ The parameter name
+ The data type
+ The size of the value
+ A SQLiteParameter object
+
+
+
+ Adds a parameter to the collection
+
+ The parameter name
+ The data type
+ A SQLiteParameter object
+
+
+
+ Adds a parameter to the collection
+
+ The parameter to add
+ A zero-based index of where the parameter is located in the array
+
+
+
+ Adds a parameter to the collection
+
+ The parameter to add
+ A zero-based index of where the parameter is located in the array
+
+
+
+ Adds a named/unnamed parameter and its value to the parameter collection.
+
+ Name of the parameter, or null to indicate an unnamed parameter
+ The initial value of the parameter
+ Returns the SQLiteParameter object created during the call.
+
+
+
+ Adds an array of parameters to the collection
+
+ The array of parameters to add
+
+
+
+ Adds an array of parameters to the collection
+
+ The array of parameters to add
+
+
+
+ Clears the array and resets the collection
+
+
+
+
+ Determines if the named parameter exists in the collection
+
+ The name of the parameter to check
+ True if the parameter is in the collection
+
+
+
+ Determines if the parameter exists in the collection
+
+ The SQLiteParameter to check
+ True if the parameter is in the collection
+
+
+
+ Not implemented
+
+
+
+
+
+
+ Retrieve a parameter by name from the collection
+
+ The name of the parameter to fetch
+ A DbParameter object
+
+
+
+ Retrieves a parameter by its index in the collection
+
+ The index of the parameter to retrieve
+ A DbParameter object
+
+
+
+ Returns the index of a parameter given its name
+
+ The name of the parameter to find
+ -1 if not found, otherwise a zero-based index of the parameter
+
+
+
+ Returns the index of a parameter
+
+ The parameter to find
+ -1 if not found, otherwise a zero-based index of the parameter
+
+
+
+ Inserts a parameter into the array at the specified location
+
+ The zero-based index to insert the parameter at
+ The parameter to insert
+
+
+
+ Removes a parameter from the collection
+
+ The parameter to remove
+
+
+
+ Removes a parameter from the collection given its name
+
+ The name of the parameter to remove
+
+
+
+ Removes a parameter from the collection given its index
+
+ The zero-based parameter index to remove
+
+
+
+ Re-assign the named parameter to a new parameter object
+
+ The name of the parameter to replace
+ The new parameter
+
+
+
+ Re-assign a parameter at the specified index
+
+ The zero-based index of the parameter to replace
+ The new parameter
+
+
+
+ Un-binds all parameters from their statements
+
+
+
+
+ This function attempts to map all parameters in the collection to all statements in a Command.
+ Since named parameters may span multiple statements, this function makes sure all statements are bound
+ to the same named parameter. Unnamed parameters are bound in sequence.
+
+
+
+
+ Returns false
+
+
+
+
+ Returns false
+
+
+
+
+ Returns false
+
+
+
+
+ Returns null
+
+
+
+
+ Returns a count of parameters in the collection
+
+
+
+
+ Overloaded to specialize the return value of the default indexer
+
+ Name of the parameter to get/set
+ The specified named SQLite parameter
+
+
+
+ Overloaded to specialize the return value of the default indexer
+
+ The index of the parameter to get/set
+ The specified SQLite parameter
+
+
+
+ Represents a single SQL statement in SQLite.
+
+
+
+
+ The underlying SQLite object this statement is bound to
+
+
+
+
+ The command text of this SQL statement
+
+
+
+
+ The actual statement pointer
+
+
+
+
+ An index from which unnamed parameters begin
+
+
+
+
+ Names of the parameters as SQLite understands them to be
+
+
+
+
+ Parameters for this statement
+
+
+
+
+ Command this statement belongs to (if any)
+
+
+
+
+ The flags associated with the parent connection object.
+
+
+
+
+ Initializes the statement and attempts to get all information about parameters in the statement
+
+ The base SQLite object
+ The flags associated with the parent connection object
+ The statement
+ The command text for this statement
+ The previous command in a multi-statement command
+
+
+
+ Disposes and finalizes the statement
+
+
+
+
+ If the underlying database connection is open, fetches the number of changed rows
+ resulting from the most recent query; otherwise, does nothing.
+
+
+ The number of changes when true is returned.
+ Undefined if false is returned.
+
+
+ The read-only flag when true is returned.
+ Undefined if false is returned.
+
+ Non-zero if the number of changed rows was fetched.
+
+
+
+ Called by SQLiteParameterCollection, this function determines if the specified parameter name belongs to
+ this statement, and if so, keeps a reference to the parameter so it can be bound later.
+
+ The parameter name to map
+ The parameter to assign it
+
+
+
+ Bind all parameters, making sure the caller didn't miss any
+
+
+
+
+ This method attempts to query the database connection associated with
+ the statement in use. If the underlying command or connection is
+ unavailable, a null value will be returned.
+
+
+ The connection object -OR- null if it is unavailable.
+
+
+
+
+ Invokes the parameter binding callback configured for the database
+ type name associated with the specified column. If no parameter
+ binding callback is available for the database type name, do
+ nothing.
+
+
+ The index of the column being read.
+
+
+ The instance being bound to the
+ command.
+
+
+ Non-zero if the default handling for the parameter binding call
+ should be skipped (i.e. the parameter should not be bound at all).
+ Great care should be used when setting this to non-zero.
+
+
+
+
+ Perform the bind operation for an individual parameter
+
+ The index of the parameter to bind
+ The parameter we're binding
+
+
+
+ SQLite implementation of DbTransaction that does not support nested transactions.
+
+
+
+
+ Base class used by to implement DbTransaction for SQLite.
+
+
+
+
+ The connection to which this transaction is bound.
+
+
+
+
+ Matches the version of the connection.
+
+
+
+
+ The isolation level for this transaction.
+
+
+
+
+ Constructs the transaction object, binding it to the supplied connection
+
+ The connection to open a transaction on
+ TRUE to defer the writelock, or FALSE to lock immediately
+
+
+
+ Disposes the transaction. If it is currently active, any changes are rolled back.
+
+
+
+
+ Rolls back the active transaction.
+
+
+
+
+ Attempts to start a transaction. An exception will be thrown if the transaction cannot
+ be started for any reason.
+
+ TRUE to defer the writelock, or FALSE to lock immediately
+
+
+
+ Issue a ROLLBACK command against the database connection,
+ optionally re-throwing any caught exception.
+
+
+ Non-zero to re-throw caught exceptions.
+
+
+
+
+ Checks the state of this transaction, optionally throwing an exception if a state
+ inconsistency is found.
+
+
+ Non-zero to throw an exception if a state inconsistency is found.
+
+
+ Non-zero if this transaction is valid; otherwise, false.
+
+
+
+
+ Gets the isolation level of the transaction. SQLite only supports Serializable transactions.
+
+
+
+
+ Returns the underlying connection to which this transaction applies.
+
+
+
+
+ Forwards to the local Connection property
+
+
+
+
+ Constructs the transaction object, binding it to the supplied connection
+
+ The connection to open a transaction on
+ TRUE to defer the writelock, or FALSE to lock immediately
+
+
+
+ Disposes the transaction. If it is currently active, any changes are rolled back.
+
+
+
+
+ Commits the current transaction.
+
+
+
+
+ Attempts to start a transaction. An exception will be thrown if the transaction cannot
+ be started for any reason.
+
+ TRUE to defer the writelock, or FALSE to lock immediately
+
+
+
+ Issue a ROLLBACK command against the database connection,
+ optionally re-throwing any caught exception.
+
+
+ Non-zero to re-throw caught exceptions.
+
+
+
+
+ SQLite implementation of DbTransaction that does support nested transactions.
+
+
+
+
+ The original transaction level for the associated connection
+ when this transaction was created (i.e. begun).
+
+
+
+
+ The SAVEPOINT name for this transaction, if any. This will
+ only be non-null if this transaction is a nested one.
+
+
+
+
+ Constructs the transaction object, binding it to the supplied connection
+
+ The connection to open a transaction on
+ TRUE to defer the writelock, or FALSE to lock immediately
+
+
+
+ Disposes the transaction. If it is currently active, any changes are rolled back.
+
+
+
+
+ Commits the current transaction.
+
+
+
+
+ Attempts to start a transaction. An exception will be thrown if the transaction cannot
+ be started for any reason.
+
+ TRUE to defer the writelock, or FALSE to lock immediately
+
+
+
+ Issue a ROLLBACK command against the database connection,
+ optionally re-throwing any caught exception.
+
+
+ Non-zero to re-throw caught exceptions.
+
+
+
+
+ Constructs the name of a new savepoint for this transaction. It
+ should only be called from the constructor of this class.
+
+
+ The name of the new savepoint -OR- null if it cannot be constructed.
+
+
+
+
+ This static class provides some methods that are shared between the
+ native library pre-loader and other classes.
+
+
+
+
+ This lock is used to protect the static field.
+
+
+
+
+ This type is only present when running on Mono.
+
+
+
+
+ Keeps track of whether we are running on Mono. Initially null, it is
+ set by the method on its first call. Later, it
+ is returned verbatim by the method.
+
+
+
+
+ Determines whether or not this assembly is running on Mono.
+
+
+ Non-zero if this assembly is running on Mono.
+
+
+
+
+ Determines if the current process is running on one of the Windows
+ [sub-]platforms.
+
+
+ Non-zero when running on Windows; otherwise, zero.
+
+
+
+
+ This is a wrapper around the
+ method.
+ On Mono, it has to call the method overload without the
+ parameter, due to a bug in Mono.
+
+
+ This is used for culture-specific formatting.
+
+
+ The format string.
+
+
+ An array the objects to format.
+
+
+ The resulting string.
+
+
+
+
+ This static class provides a thin wrapper around the native library
+ loading features of the underlying platform.
+
+
+
+
+ Attempts to load the specified native library file using the Win32
+ API.
+
+
+ The file name of the native library to load.
+
+
+ The native module handle upon success -OR- IntPtr.Zero on failure.
+
+
+
+
+ Attempts to load the specified native library file using the POSIX
+ API.
+
+
+ The file name of the native library to load.
+
+
+ The native module handle upon success -OR- IntPtr.Zero on failure.
+
+
+
+
+ Attempts to load the specified native library file.
+
+
+ The file name of the native library to load.
+
+
+ The native module handle upon success -OR- IntPtr.Zero on failure.
+
+
+
+
+ This delegate is used to wrap the concept of loading a native
+ library, based on a file name, and returning the loaded module
+ handle.
+
+
+ The file name of the native library to load.
+
+
+ The native module handle upon success -OR- IntPtr.Zero on failure.
+
+
+
+
+ This class declares P/Invoke methods to call native POSIX APIs.
+
+
+
+
+ For use with dlopen(), bind function calls lazily.
+
+
+
+
+ For use with dlopen(), bind function calls immediately.
+
+
+
+
+ For use with dlopen(), make symbols globally available.
+
+
+
+
+ For use with dlopen(), opposite of RTLD_GLOBAL, and the default.
+
+
+
+
+ For use with dlopen(), the defaults used by this class.
+
+
+
+
+ This is the P/Invoke method that wraps the native Unix dlopen
+ function. See the POSIX documentation for full details on what it
+ does.
+
+
+ The name of the executable library.
+
+
+ This must be a combination of the individual bit flags RTLD_LAZY,
+ RTLD_NOW, RTLD_GLOBAL, and/or RTLD_LOCAL.
+
+
+ The native module handle upon success -OR- IntPtr.Zero on failure.
+
+
+
+
+ This class declares P/Invoke methods to call native Win32 APIs.
+
+
+
+
+ This is the P/Invoke method that wraps the native Win32 LoadLibrary
+ function. See the MSDN documentation for full details on what it
+ does.
+
+
+ The name of the executable library.
+
+
+ The native module handle upon success -OR- IntPtr.Zero on failure.
+
+
+
+
+ This class declares P/Invoke methods to call native SQLite APIs.
+
+
+
+
+ The file extension used for dynamic link libraries.
+
+
+
+
+ The file extension used for the XML configuration file.
+
+
+
+
+ This is the name of the XML configuration file specific to the
+ System.Data.SQLite assembly.
+
+
+
+
+ This is the XML configuratrion file token that will be replaced with
+ the qualified path to the directory containing the XML configuration
+ file.
+
+
+
+
+ This is the environment variable token that will be replaced with
+ the qualified path to the directory containing this assembly.
+
+
+
+
+ This is the environment variable token that will be replaced with an
+ abbreviation of the target framework attribute value associated with
+ this assembly.
+
+
+
+
+ This lock is used to protect the static _SQLiteNativeModuleFileName,
+ _SQLiteNativeModuleHandle, and processorArchitecturePlatforms fields.
+
+
+
+
+ This dictionary stores the mappings between processor architecture
+ names and platform names. These mappings are now used for two
+ purposes. First, they are used to determine if the assembly code
+ base should be used instead of the location, based upon whether one
+ or more of the named sub-directories exist within the assembly code
+ base. Second, they are used to assist in loading the appropriate
+ SQLite interop assembly into the current process.
+
+
+
+
+ For now, this method simply calls the Initialize method.
+
+
+
+
+ Attempts to initialize this class by pre-loading the native SQLite
+ library for the processor architecture of the current process.
+
+
+
+
+ Combines two path strings.
+
+
+ The first path -OR- null.
+
+
+ The second path -OR- null.
+
+
+ The combined path string -OR- null if both of the original path
+ strings are null.
+
+
+
+
+ Queries and returns the XML configuration file name for the assembly
+ containing the managed System.Data.SQLite components.
+
+
+ The XML configuration file name -OR- null if it cannot be determined
+ or does not exist.
+
+
+
+
+ If necessary, replaces all supported XML configuration file tokens
+ with their associated values.
+
+
+ The name of the XML configuration file being read.
+
+
+ A setting value read from the XML configuration file.
+
+
+ The value of the will all supported XML
+ configuration file tokens replaced. No return value is reserved
+ to indicate an error. This method cannot fail.
+
+
+
+
+ Queries and returns the value of the specified setting, using the
+ specified XML configuration file.
+
+
+ The name of the XML configuration file to read.
+
+
+ The name of the setting.
+
+
+ The value to be returned if the setting has not been set explicitly
+ or cannot be determined.
+
+
+ Non-zero to expand any environment variable references contained in
+ the setting value to be returned. This has no effect on the .NET
+ Compact Framework.
+
+
+ The value of the setting -OR- the default value specified by
+ if it has not been set explicitly or
+ cannot be determined.
+
+
+
+
+ Attempts to determine the target framework attribute value that is
+ associated with the specified managed assembly, if applicable.
+
+
+ The managed assembly to read the target framework attribute value
+ from.
+
+
+ The value of the target framework attribute value for the specified
+ managed assembly -OR- null if it cannot be determined. If this
+ assembly was compiled with a version of the .NET Framework prior to
+ version 4.0, the value returned MAY reflect that version of the .NET
+ Framework instead of the one associated with the specified managed
+ assembly.
+
+
+
+
+ Accepts a long target framework attribute value and makes it into a
+ much shorter version, suitable for use with NuGet packages.
+
+
+ The long target framework attribute value to convert.
+
+
+ The short target framework attribute value -OR- null if it cannot
+ be determined or converted.
+
+
+
+
+ If necessary, replaces all supported environment variable tokens
+ with their associated values.
+
+
+ A setting value read from an environment variable.
+
+
+ The value of the will all supported
+ environment variable tokens replaced. No return value is reserved
+ to indicate an error. This method cannot fail.
+
+
+
+
+ Queries and returns the value of the specified setting, using the XML
+ configuration file and/or the environment variables for the current
+ process and/or the current system, when available.
+
+
+ The name of the setting.
+
+
+ The value to be returned if the setting has not been set explicitly
+ or cannot be determined.
+
+
+ The value of the setting -OR- the default value specified by
+ if it has not been set explicitly or
+ cannot be determined. By default, all references to existing
+ environment variables will be expanded to their corresponding values
+ within the value to be returned unless either the "No_Expand" or
+ "No_Expand_" environment variable is set [to
+ anything].
+
+
+
+
+ Queries and returns the directory for the assembly currently being
+ executed.
+
+
+ The directory for the assembly currently being executed -OR- null if
+ it cannot be determined.
+
+
+
+
+ The name of the environment variable containing the processor
+ architecture of the current process.
+
+
+
+
+ The native module file name for the native SQLite library or null.
+
+
+
+
+ The native module handle for the native SQLite library or the value
+ IntPtr.Zero.
+
+
+
+
+ Determines the base file name (without any directory information)
+ for the native SQLite library to be pre-loaded by this class.
+
+
+ The base file name for the native SQLite library to be pre-loaded by
+ this class -OR- null if its value cannot be determined.
+
+
+
+
+ Searches for the native SQLite library in the directory containing
+ the assembly currently being executed as well as the base directory
+ for the current application domain.
+
+
+ Upon success, this parameter will be modified to refer to the base
+ directory containing the native SQLite library.
+
+
+ Upon success, this parameter will be modified to refer to the name
+ of the immediate directory (i.e. the offset from the base directory)
+ containing the native SQLite library.
+
+
+ Non-zero (success) if the native SQLite library was found; otherwise,
+ zero (failure).
+
+
+
+
+ Queries and returns the base directory of the current application
+ domain.
+
+
+ The base directory for the current application domain -OR- null if it
+ cannot be determined.
+
+
+
+
+ Determines if the dynamic link library file name requires a suffix
+ and adds it if necessary.
+
+
+ The original dynamic link library file name to inspect.
+
+
+ The dynamic link library file name, possibly modified to include an
+ extension.
+
+
+
+
+ Queries and returns the processor architecture of the current
+ process.
+
+
+ The processor architecture of the current process -OR- null if it
+ cannot be determined.
+
+
+
+
+ Given the processor architecture, returns the name of the platform.
+
+
+ The processor architecture to be translated to a platform name.
+
+
+ The platform name for the specified processor architecture -OR- null
+ if it cannot be determined.
+
+
+
+
+ Attempts to load the native SQLite library based on the specified
+ directory and processor architecture.
+
+
+ The base directory to use, null for default (the base directory of
+ the current application domain). This directory should contain the
+ processor architecture specific sub-directories.
+
+
+ The requested processor architecture, null for default (the
+ processor architecture of the current process). This caller should
+ almost always specify null for this parameter.
+
+
+ The candidate native module file name to load will be stored here,
+ if necessary.
+
+
+ The native module handle as returned by LoadLibrary will be stored
+ here, if necessary. This value will be IntPtr.Zero if the call to
+ LoadLibrary fails.
+
+
+ Non-zero if the native module was loaded successfully; otherwise,
+ zero.
+
+
+
+
+ A strongly-typed resource class, for looking up localized strings, etc.
+
+
+
+
+ Returns the cached ResourceManager instance used by this class.
+
+
+
+
+ Overrides the current thread's CurrentUICulture property for all
+ resource lookups using this strongly typed resource class.
+
+
+
+
+ Looks up a localized string similar to <?xml version="1.0" standalone="yes"?>
+ <DocumentElement>
+ <DataTypes>
+ <TypeName>smallint</TypeName>
+ <ProviderDbType>10</ProviderDbType>
+ <ColumnSize>5</ColumnSize>
+ <DataType>System.Int16</DataType>
+ <CreateFormat>smallint</CreateFormat>
+ <IsAutoIncrementable>false</IsAutoIncrementable>
+ <IsCaseSensitive>false</IsCaseSensitive>
+ <IsFixedLength>true</IsFixedLength>
+ <IsFixedPrecisionScale>true</IsFixedPrecisionScale>
+ <IsLong>false</IsLong>
+ <IsNullable>true</ [rest of string was truncated]";.
+
+
+
+
+ Looks up a localized string similar to ALL,ALTER,AND,AS,AUTOINCREMENT,BETWEEN,BY,CASE,CHECK,COLLATE,COMMIT,CONSTRAINT,CREATE,CROSS,DEFAULT,DEFERRABLE,DELETE,DISTINCT,DROP,ELSE,ESCAPE,EXCEPT,FOREIGN,FROM,FULL,GROUP,HAVING,IN,INDEX,INNER,INSERT,INTERSECT,INTO,IS,ISNULL,JOIN,LEFT,LIMIT,NATURAL,NOT,NOTNULL,NULL,ON,OR,ORDER,OUTER,PRIMARY,REFERENCES,RIGHT,ROLLBACK,SELECT,SET,TABLE,THEN,TO,TRANSACTION,UNION,UNIQUE,UPDATE,USING,VALUES,WHEN,WHERE.
+
+
+
+
+ Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?>
+ <DocumentElement>
+ <MetaDataCollections>
+ <CollectionName>MetaDataCollections</CollectionName>
+ <NumberOfRestrictions>0</NumberOfRestrictions>
+ <NumberOfIdentifierParts>0</NumberOfIdentifierParts>
+ </MetaDataCollections>
+ <MetaDataCollections>
+ <CollectionName>DataSourceInformation</CollectionName>
+ <NumberOfRestrictions>0</NumberOfRestrictions>
+ <NumberOfIdentifierParts>0</NumberOfIdentifierParts>
+ </MetaDataCollections>
+ <MetaDataC [rest of string was truncated]";.
+
+
+
+
+ This interface represents a virtual table implementation written in
+ native code.
+
+
+
+
+
+ int (*xCreate)(sqlite3 *db, void *pAux,
+ int argc, char **argv,
+ sqlite3_vtab **ppVTab,
+ char **pzErr);
+
+
+ The xCreate method is called to create a new instance of a virtual table
+ in response to a CREATE VIRTUAL TABLE statement.
+ If the xCreate method is the same pointer as the xConnect method, then the
+ virtual table is an eponymous virtual table.
+ If the xCreate method is omitted (if it is a NULL pointer) then the virtual
+ table is an eponymous-only virtual table.
+
+
+ The db parameter is a pointer to the SQLite database connection that
+ is executing the CREATE VIRTUAL TABLE statement.
+ The pAux argument is the copy of the client data pointer that was the
+ fourth argument to the sqlite3_create_module() or
+ sqlite3_create_module_v2() call that registered the
+ virtual table module.
+ The argv parameter is an array of argc pointers to null terminated strings.
+ The first string, argv[0], is the name of the module being invoked. The
+ module name is the name provided as the second argument to
+ sqlite3_create_module() and as the argument to the USING clause of the
+ CREATE VIRTUAL TABLE statement that is running.
+ The second, argv[1], is the name of the database in which the new virtual table is being created. The database name is "main" for the primary database, or
+ "temp" for TEMP database, or the name given at the end of the ATTACH
+ statement for attached databases. The third element of the array, argv[2],
+ is the name of the new virtual table, as specified following the TABLE
+ keyword in the CREATE VIRTUAL TABLE statement.
+ If present, the fourth and subsequent strings in the argv[] array report
+ the arguments to the module name in the CREATE VIRTUAL TABLE statement.
+
+
+ The job of this method is to construct the new virtual table object
+ (an sqlite3_vtab object) and return a pointer to it in *ppVTab.
+
+
+ As part of the task of creating a new sqlite3_vtab structure, this
+ method must invoke sqlite3_declare_vtab() to tell the SQLite
+ core about the columns and datatypes in the virtual table.
+ The sqlite3_declare_vtab() API has the following prototype:
+
+
+ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable)
+
+
+ The first argument to sqlite3_declare_vtab() must be the same
+ database connection pointer as the first parameter to this method.
+ The second argument to sqlite3_declare_vtab() must a zero-terminated
+ UTF-8 string that contains a well-formed CREATE TABLE statement that
+ defines the columns in the virtual table and their data types.
+ The name of the table in this CREATE TABLE statement is ignored,
+ as are all constraints. Only the column names and datatypes matter.
+ The CREATE TABLE statement string need not to be
+ held in persistent memory. The string can be
+ deallocated and/or reused as soon as the sqlite3_declare_vtab()
+ routine returns.
+
+
+ The xCreate method need not initialize the pModule, nRef, and zErrMsg
+ fields of the sqlite3_vtab object. The SQLite core will take care of
+ that chore.
+
+
+ The xCreate should return SQLITE_OK if it is successful in
+ creating the new virtual table, or SQLITE_ERROR if it is not successful.
+ If not successful, the sqlite3_vtab structure must not be allocated.
+ An error message may optionally be returned in *pzErr if unsuccessful.
+ Space to hold the error message string must be allocated using
+ an SQLite memory allocation function like
+ sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will
+ attempt to free the space using sqlite3_free() after the error has
+ been reported up to the application.
+
+
+ If the xCreate method is omitted (left as a NULL pointer) then the
+ virtual table is an eponymous-only virtual table. New instances of
+ the virtual table cannot be created using CREATE VIRTUAL TABLE and the
+ virtual table can only be used via its module name.
+ Note that SQLite versions prior to 3.9.0 do not understand
+ eponymous-only virtual tables and will segfault if an attempt is made
+ to CREATE VIRTUAL TABLE on an eponymous-only virtual table because
+ the xCreate method was not checked for null.
+
+
+ If the xCreate method is the exact same pointer as the xConnect method,
+ that indicates that the virtual table does not need to initialize backing
+ store. Such a virtual table can be used as an eponymous virtual table
+ or as a named virtual table using CREATE VIRTUAL TABLE or both.
+
+
+ If a column datatype contains the special keyword "HIDDEN"
+ (in any combination of upper and lower case letters) then that keyword
+ it is omitted from the column datatype name and the column is marked
+ as a hidden column internally.
+ A hidden column differs from a normal column in three respects:
+
+
+ ]]>
+ ]]> Hidden columns are not listed in the dataset returned by
+ "PRAGMA table_info",
+ ]]>]]> Hidden columns are not included in the expansion of a "*"
+ expression in the result set of a SELECT, and
+ ]]>]]> Hidden columns are not included in the implicit column-list
+ used by an INSERT statement that lacks an explicit column-list.
+ ]]>]]>
+
+
+ For example, if the following SQL is passed to sqlite3_declare_vtab():
+
+
+ CREATE TABLE x(a HIDDEN VARCHAR(12), b INTEGER, c INTEGER Hidden);
+
+
+ Then the virtual table would be created with two hidden columns,
+ and with datatypes of "VARCHAR(12)" and "INTEGER".
+
+
+ An example use of hidden columns can be seen in the FTS3 virtual
+ table implementation, where every FTS virtual table
+ contains an FTS hidden column that is used to pass information from the
+ virtual table into FTS auxiliary functions and to the FTS MATCH operator.
+
+
+ A virtual table that contains hidden columns can be used like
+ a table-valued function in the FROM clause of a SELECT statement.
+ The arguments to the table-valued function become constraints on
+ the HIDDEN columns of the virtual table.
+
+
+ For example, the "generate_series" extension (located in the
+ ext/misc/series.c
+ file in the source tree)
+ implements an eponymous virtual table with the following schema:
+
+
+ CREATE TABLE generate_series(
+ value,
+ start HIDDEN,
+ stop HIDDEN,
+ step HIDDEN
+ );
+
+
+ The sqlite3_module.xBestIndex method in the implementation of this
+ table checks for equality constraints against the HIDDEN columns, and uses
+ those as input parameters to determine the range of integer "value" outputs
+ to generate. Reasonable defaults are used for any unconstrained columns.
+ For example, to list all integers between 5 and 50:
+
+
+ SELECT value FROM generate_series(5,50);
+
+
+ The previous query is equivalent to the following:
+
+
+ SELECT value FROM generate_series WHERE start=5 AND stop=50;
+
+
+ Arguments on the virtual table name are matched to hidden columns
+ in order. The number of arguments can be less than the
+ number of hidden columns, in which case the latter hidden columns are
+ unconstrained. However, an error results if there are more arguments
+ than there are hidden columns in the virtual table.
+
+
+ Beginning with SQLite version 3.14.0 (2016-08-08),
+ the CREATE TABLE statement that
+ is passed into sqlite3_declare_vtab() may contain a WITHOUT ROWID clause.
+ This is useful for cases where the virtual table rows
+ cannot easily be mapped into unique integers. A CREATE TABLE
+ statement that includes WITHOUT ROWID must define one or more columns as
+ the PRIMARY KEY. Every column of the PRIMARY KEY must individually be
+ NOT NULL and all columns for each row must be collectively unique.
+
+
+ Note that SQLite does not enforce the PRIMARY KEY for a WITHOUT ROWID
+ virtual table. Enforcement is the responsibility of the underlying
+ virtual table implementation. But SQLite does assume that the PRIMARY KEY
+ constraint is valid - that the identified columns really are UNIQUE and
+ NOT NULL - and it uses that assumption to optimize queries against the
+ virtual table.
+
+
+ The rowid column is not accessible on a
+ WITHOUT ROWID virtual table (of course). Furthermore, since the
+ xUpdate method depends on having a valid rowid, the xUpdate method
+ must be NULL for a WITHOUT ROWID virtual table. That in turn means that
+ WITHOUT ROWID virtual tables must be read-only.
+
+
+
+ The native database connection handle.
+
+
+ The original native pointer value that was provided to the
+ sqlite3_create_module(), sqlite3_create_module_v2() or
+ sqlite3_create_disposable_module() functions.
+
+
+ The number of arguments from the CREATE VIRTUAL TABLE statement.
+
+
+ The array of string arguments from the CREATE VIRTUAL TABLE
+ statement.
+
+
+ Upon success, this parameter must be modified to point to the newly
+ created native sqlite3_vtab derived structure.
+
+
+ Upon failure, this parameter must be modified to point to the error
+ message, with the underlying memory having been obtained from the
+ sqlite3_malloc() function.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xConnect)(sqlite3*, void *pAux,
+ int argc, char **argv,
+ sqlite3_vtab **ppVTab,
+ char **pzErr);
+
+
+ The xConnect method is very similar to xCreate.
+ It has the same parameters and constructs a new sqlite3_vtab structure
+ just like xCreate.
+ And it must also call sqlite3_declare_vtab() like xCreate.
+
+
+ The difference is that xConnect is called to establish a new
+ connection to an existing virtual table whereas xCreate is called
+ to create a new virtual table from scratch.
+
+
+ The xCreate and xConnect methods are only different when the
+ virtual table has some kind of backing store that must be initialized
+ the first time the virtual table is created. The xCreate method creates
+ and initializes the backing store. The xConnect method just connects
+ to an existing backing store. When xCreate and xConnect are the same,
+ the table is an eponymous virtual table.
+
+
+ As an example, consider a virtual table implementation that
+ provides read-only access to existing comma-separated-value (CSV)
+ files on disk. There is no backing store that needs to be created
+ or initialized for such a virtual table (since the CSV files already
+ exist on disk) so the xCreate and xConnect methods will be identical
+ for that module.
+
+
+ Another example is a virtual table that implements a full-text index.
+ The xCreate method must create and initialize data structures to hold
+ the dictionary and posting lists for that index. The xConnect method,
+ on the other hand, only has to locate and use an existing dictionary
+ and posting lists that were created by a prior xCreate call.
+
+
+ The xConnect method must return SQLITE_OK if it is successful
+ in creating the new virtual table, or SQLITE_ERROR if it is not
+ successful. If not successful, the sqlite3_vtab structure must not be
+ allocated. An error message may optionally be returned in *pzErr if
+ unsuccessful.
+ Space to hold the error message string must be allocated using
+ an SQLite memory allocation function like
+ sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will
+ attempt to free the space using sqlite3_free() after the error has
+ been reported up to the application.
+
+
+ The xConnect method is required for every virtual table implementation,
+ though the xCreate and xConnect pointers of the sqlite3_module object
+ may point to the same function if the virtual table does not need to
+ initialize backing store.
+
+
+
+ The native database connection handle.
+
+
+ The original native pointer value that was provided to the
+ sqlite3_create_module(), sqlite3_create_module_v2() or
+ sqlite3_create_disposable_module() functions.
+
+
+ The number of arguments from the CREATE VIRTUAL TABLE statement.
+
+
+ The array of string arguments from the CREATE VIRTUAL TABLE
+ statement.
+
+
+ Upon success, this parameter must be modified to point to the newly
+ created native sqlite3_vtab derived structure.
+
+
+ Upon failure, this parameter must be modified to point to the error
+ message, with the underlying memory having been obtained from the
+ sqlite3_malloc() function.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ SQLite uses the xBestIndex method of a virtual table module to determine
+ the best way to access the virtual table.
+ The xBestIndex method has a prototype like this:
+
+
+ int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
+
+
+ The SQLite core communicates with the xBestIndex method by filling
+ in certain fields of the sqlite3_index_info structure and passing a
+ pointer to that structure into xBestIndex as the second parameter.
+ The xBestIndex method fills out other fields of this structure which
+ forms the reply. The sqlite3_index_info structure looks like this:
+
+
+ struct sqlite3_index_info {
+ /* Inputs */
+ const int nConstraint; /* Number of entries in aConstraint */
+ const struct sqlite3_index_constraint {
+ int iColumn; /* Column constrained. -1 for ROWID */
+ unsigned char op; /* Constraint operator */
+ unsigned char usable; /* True if this constraint is usable */
+ int iTermOffset; /* Used internally - xBestIndex should ignore */
+ } *const aConstraint; /* Table of WHERE clause constraints */
+ const int nOrderBy; /* Number of terms in the ORDER BY clause */
+ const struct sqlite3_index_orderby {
+ int iColumn; /* Column number */
+ unsigned char desc; /* True for DESC. False for ASC. */
+ } *const aOrderBy; /* The ORDER BY clause */
+ /* Outputs */
+ struct sqlite3_index_constraint_usage {
+ int argvIndex; /* if >0, constraint is part of argv to xFilter */
+ unsigned char omit; /* Do not code a test for this constraint */
+ } *const aConstraintUsage;
+ int idxNum; /* Number used to identify the index */
+ char *idxStr; /* String, possibly obtained from sqlite3_malloc */
+ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
+ int orderByConsumed; /* True if output is already ordered */
+ double estimatedCost; /* Estimated cost of using this index */
+ ]]>/* Fields below are only available in SQLite 3.8.2 and later */]]>
+ sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
+ ]]>/* Fields below are only available in SQLite 3.9.0 and later */]]>
+ int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */
+ ]]>/* Fields below are only available in SQLite 3.10.0 and later */]]>
+ sqlite3_uint64 colUsed; /* Input: Mask of columns used by statement */
+ };
+
+
+ Note the warnings on the "estimatedRows", "idxFlags", and colUsed fields.
+ These fields were added with SQLite versions 3.8.2, 3.9.0, and 3.10.0, respectively.
+ Any extension that reads or writes these fields must first check that the
+ version of the SQLite library in use is greater than or equal to appropriate
+ version - perhaps comparing the value returned from sqlite3_libversion_number()
+ against constants 3008002, 3009000, and/or 3010000. The result of attempting
+ to access these fields in an sqlite3_index_info structure created by an
+ older version of SQLite are undefined.
+
+
+ In addition, there are some defined constants:
+
+
+ #define SQLITE_INDEX_CONSTRAINT_EQ 2
+ #define SQLITE_INDEX_CONSTRAINT_GT 4
+ #define SQLITE_INDEX_CONSTRAINT_LE 8
+ #define SQLITE_INDEX_CONSTRAINT_LT 16
+ #define SQLITE_INDEX_CONSTRAINT_GE 32
+ #define SQLITE_INDEX_CONSTRAINT_MATCH 64
+ #define SQLITE_INDEX_CONSTRAINT_LIKE 65 /* 3.10.0 and later only */
+ #define SQLITE_INDEX_CONSTRAINT_GLOB 66 /* 3.10.0 and later only */
+ #define SQLITE_INDEX_CONSTRAINT_REGEXP 67 /* 3.10.0 and later only */
+ #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
+
+
+ The SQLite core calls the xBestIndex method when it is compiling a query
+ that involves a virtual table. In other words, SQLite calls this method
+ when it is running sqlite3_prepare() or the equivalent.
+ By calling this method, the
+ SQLite core is saying to the virtual table that it needs to access
+ some subset of the rows in the virtual table and it wants to know the
+ most efficient way to do that access. The xBestIndex method replies
+ with information that the SQLite core can then use to conduct an
+ efficient search of the virtual table.
+
+
+ While compiling a single SQL query, the SQLite core might call
+ xBestIndex multiple times with different settings in sqlite3_index_info.
+ The SQLite core will then select the combination that appears to
+ give the best performance.
+
+
+ Before calling this method, the SQLite core initializes an instance
+ of the sqlite3_index_info structure with information about the
+ query that it is currently trying to process. This information
+ derives mainly from the WHERE clause and ORDER BY or GROUP BY clauses
+ of the query, but also from any ON or USING clauses if the query is a
+ join. The information that the SQLite core provides to the xBestIndex
+ method is held in the part of the structure that is marked as "Inputs".
+ The "Outputs" section is initialized to zero.
+
+
+ The information in the sqlite3_index_info structure is ephemeral
+ and may be overwritten or deallocated as soon as the xBestIndex method
+ returns. If the xBestIndex method needs to remember any part of the
+ sqlite3_index_info structure, it should make a copy. Care must be
+ take to store the copy in a place where it will be deallocated, such
+ as in the idxStr field with needToFreeIdxStr set to 1.
+
+
+ Note that xBestIndex will always be called before xFilter, since
+ the idxNum and idxStr outputs from xBestIndex are required inputs to
+ xFilter. However, there is no guarantee that xFilter will be called
+ following a successful xBestIndex.
+
+
+ The xBestIndex method is required for every virtual table implementation.
+
+
+ The main thing that the SQLite core is trying to communicate to
+ the virtual table is the constraints that are available to limit
+ the number of rows that need to be searched. The aConstraint[] array
+ contains one entry for each constraint. There will be exactly
+ nConstraint entries in that array.
+
+
+ Each constraint will correspond to a term in the WHERE clause
+ or in a USING or ON clause that is of the form
+
+
+ column OP EXPR
+
+
+ Where "column" is a column in the virtual table, OP is an operator
+ like "=" or "<", and EXPR is an arbitrary expression. So, for example,
+ if the WHERE clause contained a term like this:
+
+
+ a = 5
+
+
+ Then one of the constraints would be on the "a" column with
+ operator "=" and an expression of "5". Constraints need not have a
+ literal representation of the WHERE clause. The query optimizer might
+ make transformations to the
+ WHERE clause in order to extract as many constraints
+ as it can. So, for example, if the WHERE clause contained something
+ like this:
+
+
+ x BETWEEN 10 AND 100 AND 999>y
+
+
+ The query optimizer might translate this into three separate constraints:
+
+
+ x >= 10
+ x <= 100
+ y < 999
+
+
+ For each constraint, the aConstraint[].iColumn field indicates which
+ column appears on the left-hand side of the constraint.
+ The first column of the virtual table is column 0.
+ The rowid of the virtual table is column -1.
+ The aConstraint[].op field indicates which operator is used.
+ The SQLITE_INDEX_CONSTRAINT_* constants map integer constants
+ into operator values.
+ Columns occur in the order they were defined by the call to
+ sqlite3_declare_vtab() in the xCreate or xConnect method.
+ Hidden columns are counted when determining the column index.
+
+
+ The aConstraint[] array contains information about all constraints
+ that apply to the virtual table. But some of the constraints might
+ not be usable because of the way tables are ordered in a join.
+ The xBestIndex method must therefore only consider constraints
+ that have an aConstraint[].usable flag which is true.
+
+
+ In addition to WHERE clause constraints, the SQLite core also
+ tells the xBestIndex method about the ORDER BY clause.
+ (In an aggregate query, the SQLite core might put in GROUP BY clause
+ information in place of the ORDER BY clause information, but this fact
+ should not make any difference to the xBestIndex method.)
+ If all terms of the ORDER BY clause are columns in the virtual table,
+ then nOrderBy will be the number of terms in the ORDER BY clause
+ and the aOrderBy[] array will identify the column for each term
+ in the order by clause and whether or not that column is ASC or DESC.
+
+
+ In SQLite version 3.10.0 (2016-01-06) and later,
+ the colUsed field is available
+ to indicate which fields of the virtual table are actually used by the
+ statement being prepared. If the lowest bit of colUsed is set, that
+ means that the first column is used. The second lowest bit corresponds
+ to the second column. And so forth. If the most significant bit of
+ colUsed is set, that means that one or more columns other than the
+ first 63 columns are used. If column usage information is needed by the
+ xFilter method, then the required bits must be encoded into either
+ the idxNum or idxStr output fields.
+
+
+ Given all of the information above, the job of the xBestIndex
+ method it to figure out the best way to search the virtual table.
+
+
+ The xBestIndex method fills the idxNum and idxStr fields with
+ information that communicates an indexing strategy to the xFilter
+ method. The information in idxNum and idxStr is arbitrary as far
+ as the SQLite core is concerned. The SQLite core just copies the
+ information through to the xFilter method. Any desired meaning can
+ be assigned to idxNum and idxStr as long as xBestIndex and xFilter
+ agree on what that meaning is.
+
+
+ The idxStr value may be a string obtained from an SQLite
+ memory allocation function such as sqlite3_mprintf().
+ If this is the case, then the needToFreeIdxStr flag must be set to
+ true so that the SQLite core will know to call sqlite3_free() on
+ that string when it has finished with it, and thus avoid a memory leak.
+
+
+ If the virtual table will output rows in the order specified by
+ the ORDER BY clause, then the orderByConsumed flag may be set to
+ true. If the output is not automatically in the correct order
+ then orderByConsumed must be left in its default false setting.
+ This will indicate to the SQLite core that it will need to do a
+ separate sorting pass over the data after it comes out of the virtual table.
+
+
+ The estimatedCost field should be set to the estimated number
+ of disk access operations required to execute this query against
+ the virtual table. The SQLite core will often call xBestIndex
+ multiple times with different constraints, obtain multiple cost
+ estimates, then choose the query plan that gives the lowest estimate.
+
+
+ If the current version of SQLite is 3.8.2 or greater, the estimatedRows
+ field may be set to an estimate of the number of rows returned by the
+ proposed query plan. If this value is not explicitly set, the default
+ estimate of 25 rows is used.
+
+
+ If the current version of SQLite is 3.9.0 or greater, the idxFlags field
+ may be set to SQLITE_INDEX_SCAN_UNIQUE to indicate that the virtual table
+ will return only zero or one rows given the input constraints. Additional
+ bits of the idxFlags field might be understood in later versions of SQLite.
+
+
+ The aConstraintUsage[] array contains one element for each of
+ the nConstraint constraints in the inputs section of the
+ sqlite3_index_info structure.
+ The aConstraintUsage[] array is used by xBestIndex to tell the
+ core how it is using the constraints.
+
+
+ The xBestIndex method may set aConstraintUsage[].argvIndex
+ entries to values greater than zero.
+ Exactly one entry should be set to 1, another to 2, another to 3,
+ and so forth up to as many or as few as the xBestIndex method wants.
+ The EXPR of the corresponding constraints will then be passed
+ in as the argv[] parameters to xFilter.
+
+
+ For example, if the aConstraint[3].argvIndex is set to 1, then
+ when xFilter is called, the argv[0] passed to xFilter will have
+ the EXPR value of the aConstraint[3] constraint.
+
+
+ By default, the SQLite core double checks all constraints on
+ each row of the virtual table that it receives. If such a check
+ is redundant, the xBestFilter method can suppress that double-check by
+ setting aConstraintUsage[].omit.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The native pointer to the sqlite3_index_info structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xDisconnect)(sqlite3_vtab *pVTab);
+
+
+ This method releases a connection to a virtual table.
+ Only the sqlite3_vtab object is destroyed.
+ The virtual table is not destroyed and any backing store
+ associated with the virtual table persists.
+
+ This method undoes the work of xConnect.
+
+ This method is a destructor for a connection to the virtual table.
+ Contrast this method with xDestroy. The xDestroy is a destructor
+ for the entire virtual table.
+
+
+ The xDisconnect method is required for every virtual table implementation,
+ though it is acceptable for the xDisconnect and xDestroy methods to be
+ the same function if that makes sense for the particular virtual table.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xDestroy)(sqlite3_vtab *pVTab);
+
+
+ This method releases a connection to a virtual table, just like
+ the xDisconnect method, and it also destroys the underlying
+ table implementation. This method undoes the work of xCreate.
+
+
+ The xDisconnect method is called whenever a database connection
+ that uses a virtual table is closed. The xDestroy method is only
+ called when a DROP TABLE statement is executed against the virtual table.
+
+
+ The xDestroy method is required for every virtual table implementation,
+ though it is acceptable for the xDisconnect and xDestroy methods to be
+ the same function if that makes sense for the particular virtual table.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
+
+
+ The xOpen method creates a new cursor used for accessing (read and/or
+ writing) a virtual table. A successful invocation of this method
+ will allocate the memory for the sqlite3_vtab_cursor (or a subclass),
+ initialize the new object, and make *ppCursor point to the new object.
+ The successful call then returns SQLITE_OK.
+
+
+ For every successful call to this method, the SQLite core will
+ later invoke the xClose method to destroy
+ the allocated cursor.
+
+
+ The xOpen method need not initialize the pVtab field of the
+ sqlite3_vtab_cursor structure. The SQLite core will take care
+ of that chore automatically.
+
+
+ A virtual table implementation must be able to support an arbitrary
+ number of simultaneously open cursors.
+
+
+ When initially opened, the cursor is in an undefined state.
+ The SQLite core will invoke the xFilter method
+ on the cursor prior to any attempt to position or read from the cursor.
+
+
+ The xOpen method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ Upon success, this parameter must be modified to point to the newly
+ created native sqlite3_vtab_cursor derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xClose)(sqlite3_vtab_cursor*);
+
+
+ The xClose method closes a cursor previously opened by
+ xOpen.
+ The SQLite core will always call xClose once for each cursor opened
+ using xOpen.
+
+
+ This method must release all resources allocated by the
+ corresponding xOpen call. The routine will not be called again even if it
+ returns an error. The SQLite core will not use the
+ sqlite3_vtab_cursor again after it has been closed.
+
+
+ The xClose method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
+ int argc, sqlite3_value **argv);
+
+
+ This method begins a search of a virtual table.
+ The first argument is a cursor opened by xOpen.
+ The next two arguments define a particular search index previously
+ chosen by xBestIndex. The specific meanings of idxNum and idxStr
+ are unimportant as long as xFilter and xBestIndex agree on what
+ that meaning is.
+
+
+ The xBestIndex function may have requested the values of
+ certain expressions using the aConstraintUsage[].argvIndex values
+ of the sqlite3_index_info structure.
+ Those values are passed to xFilter using the argc and argv parameters.
+
+
+ If the virtual table contains one or more rows that match the
+ search criteria, then the cursor must be left point at the first row.
+ Subsequent calls to xEof must return false (zero).
+ If there are no rows match, then the cursor must be left in a state
+ that will cause the xEof to return true (non-zero).
+ The SQLite engine will use
+ the xColumn and xRowid methods to access that row content.
+ The xNext method will be used to advance to the next row.
+
+
+ This method must return SQLITE_OK if successful, or an sqlite
+ error code if an error occurs.
+
+
+ The xFilter method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ Number used to help identify the selected index.
+
+
+ The native pointer to the UTF-8 encoded string containing the
+ string used to help identify the selected index.
+
+
+ The number of native pointers to sqlite3_value structures specified
+ in .
+
+
+ An array of native pointers to sqlite3_value structures containing
+ filtering criteria for the selected index.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xNext)(sqlite3_vtab_cursor*);
+
+
+ The xNext method advances a virtual table cursor
+ to the next row of a result set initiated by xFilter.
+ If the cursor is already pointing at the last row when this
+ routine is called, then the cursor no longer points to valid
+ data and a subsequent call to the xEof method must return true (non-zero).
+ If the cursor is successfully advanced to another row of content, then
+ subsequent calls to xEof must return false (zero).
+
+
+ This method must return SQLITE_OK if successful, or an sqlite
+ error code if an error occurs.
+
+
+ The xNext method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xEof)(sqlite3_vtab_cursor*);
+
+
+ The xEof method must return false (zero) if the specified cursor
+ currently points to a valid row of data, or true (non-zero) otherwise.
+ This method is called by the SQL engine immediately after each
+ xFilter and xNext invocation.
+
+
+ The xEof method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ Non-zero if no more rows are available; zero otherwise.
+
+
+
+
+
+ int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int N);
+
+
+ The SQLite core invokes this method in order to find the value for
+ the N-th column of the current row. N is zero-based so the first column
+ is numbered 0.
+ The xColumn method may return its result back to SQLite using one of the
+ following interface:
+
+
+ ]]>
+ ]]> sqlite3_result_blob()
+ ]]>]]> sqlite3_result_double()
+ ]]>]]> sqlite3_result_int()
+ ]]>]]> sqlite3_result_int64()
+ ]]>]]> sqlite3_result_null()
+ ]]>]]> sqlite3_result_text()
+ ]]>]]> sqlite3_result_text16()
+ ]]>]]> sqlite3_result_text16le()
+ ]]>]]> sqlite3_result_text16be()
+ ]]>]]> sqlite3_result_zeroblob()
+ ]]>]]>
+
+
+ If the xColumn method implementation calls none of the functions above,
+ then the value of the column defaults to an SQL NULL.
+
+
+ To raise an error, the xColumn method should use one of the result_text()
+ methods to set the error message text, then return an appropriate
+ error code. The xColumn method must return SQLITE_OK on success.
+
+
+ The xColumn method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ The native pointer to the sqlite3_context structure to be used
+ for returning the specified column value to the SQLite core
+ library.
+
+
+ The zero-based index corresponding to the column containing the
+ value to be returned.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xRowid)(sqlite3_vtab_cursor *pCur, sqlite_int64 *pRowid);
+
+
+ A successful invocation of this method will cause *pRowid to be
+ filled with the rowid of row that the
+ virtual table cursor pCur is currently pointing at.
+ This method returns SQLITE_OK on success.
+ It returns an appropriate error code on failure.
+
+
+ The xRowid method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ Upon success, this parameter must be modified to contain the unique
+ integer row identifier for the current row for the specified cursor.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xUpdate)(
+ sqlite3_vtab *pVTab,
+ int argc,
+ sqlite3_value **argv,
+ sqlite_int64 *pRowid
+ );
+
+
+ All changes to a virtual table are made using the xUpdate method.
+ This one method can be used to insert, delete, or update.
+
+
+ The argc parameter specifies the number of entries in the argv array.
+ The value of argc will be 1 for a pure delete operation or N+2 for an insert
+ or replace or update where N is the number of columns in the table.
+ In the previous sentence, N includes any hidden columns.
+
+
+ Every argv entry will have a non-NULL value in C but may contain the
+ SQL value NULL. In other words, it is always true that
+ ]]>argv[i]!=0]]> for ]]>i]]> between 0 and ]]>argc-1]]>.
+ However, it might be the case that
+ ]]>sqlite3_value_type(argv[i])==SQLITE_NULL]]>.
+
+
+ The argv[0] parameter is the rowid of a row in the virtual table
+ to be deleted. If argv[0] is an SQL NULL, then no deletion occurs.
+
+
+ The argv[1] parameter is the rowid of a new row to be inserted
+ into the virtual table. If argv[1] is an SQL NULL, then the implementation
+ must choose a rowid for the newly inserted row. Subsequent argv[]
+ entries contain values of the columns of the virtual table, in the
+ order that the columns were declared. The number of columns will
+ match the table declaration that the xConnect or xCreate method made
+ using the sqlite3_declare_vtab() call. All hidden columns are included.
+
+
+ When doing an insert without a rowid (argc>1, argv[1] is an SQL NULL), the
+ implementation must set *pRowid to the rowid of the newly inserted row;
+ this will become the value returned by the sqlite3_last_insert_rowid()
+ function. Setting this value in all the other cases is a harmless no-op;
+ the SQLite engine ignores the *pRowid return value if argc==1 or
+ argv[1] is not an SQL NULL.
+
+
+ Each call to xUpdate will fall into one of cases shown below.
+ Not that references to ]]>argv[i]]]> mean the SQL value
+ held within the argv[i] object, not the argv[i]
+ object itself.
+
+
+ ]]>
+ ]]>]]>argc = 1]]>
+ ]]>]]>The single row with rowid equal to argv[0] is deleted. No insert occurs.
+ ]]>]]>]]>argc > 1 ]]> argv[0] = NULL]]>
+ ]]>]]>A new row is inserted with a rowid argv[1] and column values in
+ argv[2] and following. If argv[1] is an SQL NULL,
+ the a new unique rowid is generated automatically.
+ ]]>]]>]]>argc > 1 ]]> argv[0] ≠ NULL ]]> argv[0] = argv[1]]]>
+ ]]>]]>The row with rowid argv[0] is updated with new values
+ in argv[2] and following parameters.
+ ]]>]]>]]>argc > 1 ]]> argv[0] ≠ NULL ]]> argv[0] ≠ argv[1]]]>
+ ]]>]]> The row with rowid argv[0] is updated with rowid argv[1]
+ and new values in argv[2] and following parameters. This will occur
+ when an SQL statement updates a rowid, as in the statement:
+
+ UPDATE table SET rowid=rowid+1 WHERE ...;
+
+ ]]>]]>
+
+
+ The xUpdate method must return SQLITE_OK if and only if it is
+ successful. If a failure occurs, the xUpdate must return an appropriate
+ error code. On a failure, the pVTab->zErrMsg element may optionally
+ be replaced with error message text stored in memory allocated from SQLite
+ using functions such as sqlite3_mprintf() or sqlite3_malloc().
+
+
+ If the xUpdate method violates some constraint of the virtual table
+ (including, but not limited to, attempting to store a value of the wrong
+ datatype, attempting to store a value that is too
+ large or too small, or attempting to change a read-only value) then the
+ xUpdate must fail with an appropriate error code.
+
+
+ There might be one or more sqlite3_vtab_cursor objects open and in use
+ on the virtual table instance and perhaps even on the row of the virtual
+ table when the xUpdate method is invoked. The implementation of
+ xUpdate must be prepared for attempts to delete or modify rows of the table
+ out from other existing cursors. If the virtual table cannot accommodate
+ such changes, the xUpdate method must return an error code.
+
+
+ The xUpdate method is optional.
+ If the xUpdate pointer in the sqlite3_module for a virtual table
+ is a NULL pointer, then the virtual table is read-only.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The number of new or modified column values contained in
+ .
+
+
+ The array of native pointers to sqlite3_value structures containing
+ the new or modified column values, if any.
+
+
+ Upon success, this parameter must be modified to contain the unique
+ integer row identifier for the row that was inserted, if any.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xBegin)(sqlite3_vtab *pVTab);
+
+
+ This method begins a transaction on a virtual table.
+ This is method is optional. The xBegin pointer of sqlite3_module
+ may be NULL.
+
+
+ This method is always followed by one call to either the
+ xCommit or xRollback method. Virtual table transactions do
+ not nest, so the xBegin method will not be invoked more than once
+ on a single virtual table
+ without an intervening call to either xCommit or xRollback.
+ Multiple calls to other methods can and likely will occur in between
+ the xBegin and the corresponding xCommit or xRollback.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xSync)(sqlite3_vtab *pVTab);
+
+
+ This method signals the start of a two-phase commit on a virtual
+ table.
+ This is method is optional. The xSync pointer of sqlite3_module
+ may be NULL.
+
+
+ This method is only invoked after call to the xBegin method and
+ prior to an xCommit or xRollback. In order to implement two-phase
+ commit, the xSync method on all virtual tables is invoked prior to
+ invoking the xCommit method on any virtual table. If any of the
+ xSync methods fail, the entire transaction is rolled back.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xCommit)(sqlite3_vtab *pVTab);
+
+
+ This method causes a virtual table transaction to commit.
+ This is method is optional. The xCommit pointer of sqlite3_module
+ may be NULL.
+
+
+ A call to this method always follows a prior call to xBegin and
+ xSync.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xRollback)(sqlite3_vtab *pVTab);
+
+
+ This method causes a virtual table transaction to rollback.
+ This is method is optional. The xRollback pointer of sqlite3_module
+ may be NULL.
+
+
+ A call to this method always follows a prior call to xBegin.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xFindFunction)(
+ sqlite3_vtab *pVtab,
+ int nArg,
+ const char *zName,
+ void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
+ void **ppArg
+ );
+
+
+ This method is called during sqlite3_prepare() to give the virtual
+ table implementation an opportunity to overload functions.
+ This method may be set to NULL in which case no overloading occurs.
+
+
+ When a function uses a column from a virtual table as its first
+ argument, this method is called to see if the virtual table would
+ like to overload the function. The first three parameters are inputs:
+ the virtual table, the number of arguments to the function, and the
+ name of the function. If no overloading is desired, this method
+ returns 0. To overload the function, this method writes the new
+ function implementation into *pxFunc and writes user data into *ppArg
+ and returns 1.
+
+
+ Note that infix functions (LIKE, GLOB, REGEXP, and MATCH) reverse
+ the order of their arguments. So "like(A,B)" is equivalent to "B like A".
+ For the form "B like A" the B term is considered the first argument
+ to the function. But for "like(A,B)" the A term is considered the
+ first argument.
+
+
+ The function pointer returned by this routine must be valid for
+ the lifetime of the sqlite3_vtab object given in the first parameter.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The number of arguments to the function being sought.
+
+
+ The name of the function being sought.
+
+
+ Upon success, this parameter must be modified to contain the
+ delegate responsible for implementing the specified function.
+
+
+ Upon success, this parameter must be modified to contain the
+ native user-data pointer associated with
+ .
+
+
+ Non-zero if the specified function was found; zero otherwise.
+
+
+
+
+
+ int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
+
+
+ This method provides notification that the virtual table implementation
+ that the virtual table will be given a new name.
+ If this method returns SQLITE_OK then SQLite renames the table.
+ If this method returns an error code then the renaming is prevented.
+
+
+ The xRename method is required for every virtual table implementation.
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The native pointer to the UTF-8 encoded string containing the new
+ name for the virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xSavepoint)(sqlite3_vtab *pVtab, int);
+ int (*xRelease)(sqlite3_vtab *pVtab, int);
+ int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
+
+
+ These methods provide the virtual table implementation an opportunity to
+ implement nested transactions. They are always optional and will only be
+ called in SQLite version 3.7.7 (2011-06-23) and later.
+
+
+ When xSavepoint(X,N) is invoked, that is a signal to the virtual table X
+ that it should save its current state as savepoint N.
+ A subsequent call
+ to xRollbackTo(X,R) means that the state of the virtual table should return
+ to what it was when xSavepoint(X,R) was last called.
+ The call
+ to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the
+ invalided savepoints will be rolled back or released without first
+ being reinitialized by a call to xSavepoint().
+ A call to xRelease(X,M) invalidates all savepoints where N>=M.
+
+
+ None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever
+ be called except in between calls to xBegin() and
+ either xCommit() or xRollback().
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ This is an integer identifier under which the the current state of
+ the virtual table should be saved.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xSavepoint)(sqlite3_vtab *pVtab, int);
+ int (*xRelease)(sqlite3_vtab *pVtab, int);
+ int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
+
+
+ These methods provide the virtual table implementation an opportunity to
+ implement nested transactions. They are always optional and will only be
+ called in SQLite version 3.7.7 (2011-06-23) and later.
+
+
+ When xSavepoint(X,N) is invoked, that is a signal to the virtual table X
+ that it should save its current state as savepoint N.
+ A subsequent call
+ to xRollbackTo(X,R) means that the state of the virtual table should return
+ to what it was when xSavepoint(X,R) was last called.
+ The call
+ to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the
+ invalided savepoints will be rolled back or released without first
+ being reinitialized by a call to xSavepoint().
+ A call to xRelease(X,M) invalidates all savepoints where N>=M.
+
+
+ None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever
+ be called except in between calls to xBegin() and
+ either xCommit() or xRollback().
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ This is an integer used to indicate that any saved states with an
+ identifier greater than or equal to this should be deleted by the
+ virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+
+ int (*xSavepoint)(sqlite3_vtab *pVtab, int);
+ int (*xRelease)(sqlite3_vtab *pVtab, int);
+ int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
+
+
+ These methods provide the virtual table implementation an opportunity to
+ implement nested transactions. They are always optional and will only be
+ called in SQLite version 3.7.7 (2011-06-23) and later.
+
+
+ When xSavepoint(X,N) is invoked, that is a signal to the virtual table X
+ that it should save its current state as savepoint N.
+ A subsequent call
+ to xRollbackTo(X,R) means that the state of the virtual table should return
+ to what it was when xSavepoint(X,R) was last called.
+ The call
+ to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the
+ invalided savepoints will be rolled back or released without first
+ being reinitialized by a call to xSavepoint().
+ A call to xRelease(X,M) invalidates all savepoints where N>=M.
+
+
+ None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever
+ be called except in between calls to xBegin() and
+ either xCommit() or xRollback().
+
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ This is an integer identifier used to specify a specific saved
+ state for the virtual table for it to restore itself back to, which
+ should also have the effect of deleting all saved states with an
+ integer identifier greater than this one.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This class represents a context from the SQLite core library that can
+ be passed to the sqlite3_result_*() and associated functions.
+
+
+
+
+ This interface represents a native handle provided by the SQLite core
+ library.
+
+
+
+
+ The native handle value.
+
+
+
+
+ The native context handle.
+
+
+
+
+ Constructs an instance of this class using the specified native
+ context handle.
+
+
+ The native context handle to use.
+
+
+
+
+ Sets the context result to NULL.
+
+
+
+
+ Sets the context result to the specified
+ value.
+
+
+ The value to use.
+
+
+
+
+ Sets the context result to the specified
+ value.
+
+
+ The value to use.
+
+
+
+
+ Sets the context result to the specified
+ value.
+
+
+ The value to use.
+
+
+
+
+ Sets the context result to the specified
+ value.
+
+
+ The value to use. This value will be
+ converted to the UTF-8 encoding prior to being used.
+
+
+
+
+ Sets the context result to the specified
+ value containing an error message.
+
+
+ The value containing the error message text.
+ This value will be converted to the UTF-8 encoding prior to being
+ used.
+
+
+
+
+ Sets the context result to the specified
+ value.
+
+
+ The value to use.
+
+
+
+
+ Sets the context result to contain the error code SQLITE_TOOBIG.
+
+
+
+
+ Sets the context result to contain the error code SQLITE_NOMEM.
+
+
+
+
+ Sets the context result to the specified array
+ value.
+
+
+ The array value to use.
+
+
+
+
+ Sets the context result to a BLOB of zeros of the specified size.
+
+
+ The number of zero bytes to use for the BLOB context result.
+
+
+
+
+ Sets the context result to the specified .
+
+
+ The to use.
+
+
+
+
+ Returns the underlying SQLite native handle associated with this
+ object instance.
+
+
+
+
+ This class represents a value from the SQLite core library that can be
+ passed to the sqlite3_value_*() and associated functions.
+
+
+
+
+ The native value handle.
+
+
+
+
+ Constructs an instance of this class using the specified native
+ value handle.
+
+
+ The native value handle to use.
+
+
+
+
+ Invalidates the native value handle, thereby preventing further
+ access to it from this object instance.
+
+
+
+
+ Converts a logical array of native pointers to native sqlite3_value
+ structures into a managed array of
+ object instances.
+
+
+ The number of elements in the logical array of native sqlite3_value
+ structures.
+
+
+ The native pointer to the logical array of native sqlite3_value
+ structures to convert.
+
+
+ The managed array of object instances or
+ null upon failure.
+
+
+
+
+ Gets and returns the type affinity associated with this value.
+
+
+ The type affinity associated with this value.
+
+
+
+
+ Gets and returns the number of bytes associated with this value, if
+ it refers to a UTF-8 encoded string.
+
+
+ The number of bytes associated with this value. The returned value
+ may be zero.
+
+
+
+
+ Gets and returns the associated with this
+ value.
+
+
+ The associated with this value.
+
+
+
+
+ Gets and returns the associated with
+ this value.
+
+
+ The associated with this value.
+
+
+
+
+ Gets and returns the associated with this
+ value.
+
+
+ The associated with this value.
+
+
+
+
+ Gets and returns the associated with this
+ value.
+
+
+ The associated with this value. The value is
+ converted from the UTF-8 encoding prior to being returned.
+
+
+
+
+ Gets and returns the array associated with this
+ value.
+
+
+ The array associated with this value.
+
+
+
+
+ Uses the native value handle to obtain and store the managed value
+ for this object instance, thus saving it for later use. The type
+ of the managed value is determined by the type affinity of the
+ native value. If the type affinity is not recognized by this
+ method, no work is done and false is returned.
+
+
+ Non-zero if the native value was persisted successfully.
+
+
+
+
+ Returns the underlying SQLite native handle associated with this
+ object instance.
+
+
+
+
+ Returns non-zero if the native SQLite value has been successfully
+ persisted as a managed value within this object instance (i.e. the
+ property may then be read successfully).
+
+
+
+
+ If the managed value for this object instance is available (i.e. it
+ has been previously persisted via the ) method,
+ that value is returned; otherwise, an exception is thrown. The
+ returned value may be null.
+
+
+
+
+ These are the allowed values for the operators that are part of a
+ constraint term in the WHERE clause of a query that uses a virtual
+ table.
+
+
+
+
+ This value represents the equality operator.
+
+
+
+
+ This value represents the greater than operator.
+
+
+
+
+ This value represents the less than or equal to operator.
+
+
+
+
+ This value represents the less than operator.
+
+
+
+
+ This value represents the greater than or equal to operator.
+
+
+
+
+ This value represents the MATCH operator.
+
+
+
+
+ This value represents the LIKE operator.
+
+
+
+
+ This value represents the GLOB operator.
+
+
+
+
+ This value represents the REGEXP operator.
+
+
+
+
+ These are the allowed values for the index flags from the
+ method.
+
+
+
+
+ No special handling. This is the default.
+
+
+
+
+ This value indicates that the scan of the index will visit at
+ most one row.
+
+
+
+
+ This class represents the native sqlite3_index_constraint structure
+ from the SQLite core library.
+
+
+
+
+ Constructs an instance of this class using the specified native
+ sqlite3_index_constraint structure.
+
+
+ The native sqlite3_index_constraint structure to use.
+
+
+
+
+ Constructs an instance of this class using the specified field
+ values.
+
+
+ Column on left-hand side of constraint.
+
+
+ Constraint operator ().
+
+
+ True if this constraint is usable.
+
+
+ Used internally -
+ should ignore.
+
+
+
+
+ Column on left-hand side of constraint.
+
+
+
+
+ Constraint operator ().
+
+
+
+
+ True if this constraint is usable.
+
+
+
+
+ Used internally -
+ should ignore.
+
+
+
+
+ This class represents the native sqlite3_index_orderby structure from
+ the SQLite core library.
+
+
+
+
+ Constructs an instance of this class using the specified native
+ sqlite3_index_orderby structure.
+
+
+ The native sqlite3_index_orderby structure to use.
+
+
+
+
+ Constructs an instance of this class using the specified field
+ values.
+
+
+ Column number.
+
+
+ True for DESC. False for ASC.
+
+
+
+
+ Column number.
+
+
+
+
+ True for DESC. False for ASC.
+
+
+
+
+ This class represents the native sqlite3_index_constraint_usage
+ structure from the SQLite core library.
+
+
+
+
+ Constructs a default instance of this class.
+
+
+
+
+ Constructs an instance of this class using the specified native
+ sqlite3_index_constraint_usage structure.
+
+
+ The native sqlite3_index_constraint_usage structure to use.
+
+
+
+
+ Constructs an instance of this class using the specified field
+ values.
+
+
+ If greater than 0, constraint is part of argv to xFilter.
+
+
+ Do not code a test for this constraint.
+
+
+
+
+ If greater than 0, constraint is part of argv to xFilter.
+
+
+
+
+ Do not code a test for this constraint.
+
+
+
+
+ This class represents the various inputs provided by the SQLite core
+ library to the method.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The number of instances to
+ pre-allocate space for.
+
+
+ The number of instances to
+ pre-allocate space for.
+
+
+
+
+ An array of object instances,
+ each containing information supplied by the SQLite core library.
+
+
+
+
+ An array of object instances,
+ each containing information supplied by the SQLite core library.
+
+
+
+
+ This class represents the various outputs provided to the SQLite core
+ library by the method.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The number of instances
+ to pre-allocate space for.
+
+
+
+
+ Determines if the native estimatedRows field can be used, based on
+ the available version of the SQLite core library.
+
+
+ Non-zero if the property is supported
+ by the SQLite core library.
+
+
+
+
+ Determines if the native flags field can be used, based on the
+ available version of the SQLite core library.
+
+
+ Non-zero if the property is supported by
+ the SQLite core library.
+
+
+
+
+ Determines if the native flags field can be used, based on the
+ available version of the SQLite core library.
+
+
+ Non-zero if the property is supported by
+ the SQLite core library.
+
+
+
+
+ An array of object
+ instances, each containing information to be supplied to the SQLite
+ core library.
+
+
+
+
+ Number used to help identify the selected index. This value will
+ later be provided to the
+ method.
+
+
+
+
+ String used to help identify the selected index. This value will
+ later be provided to the
+ method.
+
+
+
+
+ Non-zero if the index string must be freed by the SQLite core
+ library.
+
+
+
+
+ True if output is already ordered.
+
+
+
+
+ Estimated cost of using this index. Using a null value here
+ indicates that a default estimated cost value should be used.
+
+
+
+
+ Estimated number of rows returned. Using a null value here
+ indicates that a default estimated rows value should be used.
+ This property has no effect if the SQLite core library is not at
+ least version 3.8.2.
+
+
+
+
+ The flags that should be used with this index. Using a null value
+ here indicates that a default flags value should be used. This
+ property has no effect if the SQLite core library is not at least
+ version 3.9.0.
+
+
+
+
+
+ Indicates which columns of the virtual table may be required by the
+ current scan. Virtual table columns are numbered from zero in the
+ order in which they appear within the CREATE TABLE statement passed
+ to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
+ the corresponding bit is set within the bit mask if the column may
+ be required by SQLite. If the table has at least 64 columns and
+ any column to the right of the first 63 is required, then bit 63 of
+ colUsed is also set. In other words, column iCol may be required
+ if the expression
+
+
+ (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol)))
+
+
+ evaluates to non-zero. Using a null value here indicates that a
+ default flags value should be used. This property has no effect if
+ the SQLite core library is not at least version 3.10.0.
+
+
+
+
+
+ This class represents the various inputs and outputs used with the
+ method.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The number of (and
+ ) instances to
+ pre-allocate space for.
+
+
+ The number of instances to
+ pre-allocate space for.
+
+
+
+
+ Attempts to determine the structure sizes needed to create and
+ populate a native
+
+ structure.
+
+
+ The size of the native
+
+ structure is stored here.
+
+
+ The size of the native
+
+ structure is stored here.
+
+
+ The size of the native
+
+ structure is stored here.
+
+
+ The size of the native
+
+ structure is stored here.
+
+
+
+
+ Attempts to allocate and initialize a native
+
+ structure.
+
+
+ The number of instances to
+ pre-allocate space for.
+
+
+ The number of instances to
+ pre-allocate space for.
+
+
+ The newly allocated native
+ structure
+ -OR- if it could not be fully allocated.
+
+
+
+
+ Frees all the memory associated with a native
+
+ structure.
+
+
+ The native pointer to the native sqlite3_index_info structure to
+ free.
+
+
+
+
+ Converts a native pointer to a native sqlite3_index_info structure
+ into a new object instance.
+
+
+ The native pointer to the native sqlite3_index_info structure to
+ convert.
+
+
+ Non-zero to include fields from the outputs portion of the native
+ structure; otherwise, the "output" fields will not be read.
+
+
+ Upon success, this parameter will be modified to contain the newly
+ created object instance.
+
+
+
+
+ Populates the outputs of a pre-allocated native sqlite3_index_info
+ structure using an existing object
+ instance.
+
+
+ The existing object instance containing
+ the output data to use.
+
+
+ The native pointer to the pre-allocated native sqlite3_index_info
+ structure.
+
+
+ Non-zero to include fields from the inputs portion of the native
+ structure; otherwise, the "input" fields will not be written.
+
+
+
+
+ The object instance containing
+ the inputs to the
+ method.
+
+
+
+
+ The object instance containing
+ the outputs from the
+ method.
+
+
+
+
+ This class represents a managed virtual table implementation. It is
+ not sealed and should be used as the base class for any user-defined
+ virtual table classes implemented in managed code.
+
+
+
+
+ The index within the array of strings provided to the
+ and
+ methods containing the
+ name of the module implementing this virtual table.
+
+
+
+
+ The index within the array of strings provided to the
+ and
+ methods containing the
+ name of the database containing this virtual table.
+
+
+
+
+ The index within the array of strings provided to the
+ and
+ methods containing the
+ name of the virtual table.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The original array of strings provided to the
+ and
+ methods.
+
+
+
+
+ This method should normally be used by the
+ method in order to
+ perform index selection based on the constraints provided by the
+ SQLite core library.
+
+
+ The object instance containing all the
+ data for the inputs and outputs relating to index selection.
+
+
+ Non-zero upon success.
+
+
+
+
+ Attempts to record the renaming of the virtual table associated
+ with this object instance.
+
+
+ The new name for the virtual table.
+
+
+ Non-zero upon success.
+
+
+
+
+ Disposes of this object instance.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is being called
+ from the finalizer.
+
+
+
+
+ Finalizes this object instance.
+
+
+
+
+ The original array of strings provided to the
+ and
+ methods.
+
+
+
+
+ The name of the module implementing this virtual table.
+
+
+
+
+ The name of the database containing this virtual table.
+
+
+
+
+ The name of the virtual table.
+
+
+
+
+ The object instance containing all the
+ data for the inputs and outputs relating to the most recent index
+ selection.
+
+
+
+
+ Returns the underlying SQLite native handle associated with this
+ object instance.
+
+
+
+
+ This class represents a managed virtual table cursor implementation.
+ It is not sealed and should be used as the base class for any
+ user-defined virtual table cursor classes implemented in managed code.
+
+
+
+
+ This value represents an invalid integer row sequence number.
+
+
+
+
+ The field holds the integer row sequence number for the current row
+ pointed to by this cursor object instance.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The object instance associated
+ with this object instance.
+
+
+
+
+ Constructs an instance of this class.
+
+
+
+
+ Attempts to persist the specified object
+ instances in order to make them available after the
+ method returns.
+
+
+ The array of object instances to be
+ persisted.
+
+
+ The number of object instances that were
+ successfully persisted.
+
+
+
+
+ This method should normally be used by the
+ method in order to
+ perform filtering of the result rows and/or to record the filtering
+ criteria provided by the SQLite core library.
+
+
+ Number used to help identify the selected index.
+
+
+ String used to help identify the selected index.
+
+
+ The values corresponding to each column in the selected index.
+
+
+
+
+ Determines the integer row sequence number for the current row.
+
+
+ The integer row sequence number for the current row -OR- zero if
+ it cannot be determined.
+
+
+
+
+ Adjusts the integer row sequence number so that it refers to the
+ next row.
+
+
+
+
+ Disposes of this object instance.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is being called
+ from the finalizer.
+
+
+
+
+ Finalizes this object instance.
+
+
+
+
+ The object instance associated
+ with this object instance.
+
+
+
+
+ Number used to help identify the selected index. This value will
+ be set via the method.
+
+
+
+
+ String used to help identify the selected index. This value will
+ be set via the method.
+
+
+
+
+ The values used to filter the rows returned via this cursor object
+ instance. This value will be set via the
+ method.
+
+
+
+
+ Returns the underlying SQLite native handle associated with this
+ object instance.
+
+
+
+
+ This interface represents a virtual table implementation written in
+ managed code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated with
+ the virtual table.
+
+
+ The native user-data pointer associated with this module, as it was
+ provided to the SQLite core library when the native module instance
+ was created.
+
+
+ The module name, database name, virtual table name, and all other
+ arguments passed to the CREATE VIRTUAL TABLE statement.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance associated with
+ the virtual table.
+
+
+ Upon failure, this parameter must be modified to contain an error
+ message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated with
+ the virtual table.
+
+
+ The native user-data pointer associated with this module, as it was
+ provided to the SQLite core library when the native module instance
+ was created.
+
+
+ The module name, database name, virtual table name, and all other
+ arguments passed to the CREATE VIRTUAL TABLE statement.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance associated with
+ the virtual table.
+
+
+ Upon failure, this parameter must be modified to contain an error
+ message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The object instance containing all the
+ data for the inputs and outputs relating to index selection.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance associated
+ with the newly opened virtual table cursor.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ Number used to help identify the selected index.
+
+
+ String used to help identify the selected index.
+
+
+ The values corresponding to each column in the selected index.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ Non-zero if no more rows are available; zero otherwise.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ The object instance to be used for
+ returning the specified column value to the SQLite core library.
+
+
+ The zero-based index corresponding to the column containing the
+ value to be returned.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ Upon success, this parameter must be modified to contain the unique
+ integer row identifier for the current row for the specified cursor.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The array of object instances containing
+ the new or modified column values, if any.
+
+
+ Upon success, this parameter must be modified to contain the unique
+ integer row identifier for the row that was inserted, if any.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The number of arguments to the function being sought.
+
+
+ The name of the function being sought.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance responsible for
+ implementing the specified function.
+
+
+ Upon success, this parameter must be modified to contain the
+ native user-data pointer associated with
+ .
+
+
+ Non-zero if the specified function was found; zero otherwise.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The new name for the virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ This is an integer identifier under which the the current state of
+ the virtual table should be saved.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ This is an integer used to indicate that any saved states with an
+ identifier greater than or equal to this should be deleted by the
+ virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ This is an integer identifier used to specify a specific saved
+ state for the virtual table for it to restore itself back to, which
+ should also have the effect of deleting all saved states with an
+ integer identifier greater than this one.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Returns non-zero if the schema for the virtual table has been
+ declared.
+
+
+
+
+ Returns the name of the module as it was registered with the SQLite
+ core library.
+
+
+
+
+ This class contains static methods that are used to allocate,
+ manipulate, and free native memory provided by the SQLite core library.
+
+
+
+
+ Allocates at least the specified number of bytes of native memory
+ via the SQLite core library sqlite3_malloc() function and returns
+ the resulting native pointer.
+
+
+ The number of bytes to allocate.
+
+
+ The native pointer that points to a block of memory of at least the
+ specified size -OR- if the memory could
+ not be allocated.
+
+
+
+
+ Gets and returns the actual size of the specified memory block that
+ was previously obtained from the method.
+
+
+ The native pointer to the memory block previously obtained from the
+ method.
+
+
+ The actual size, in bytes, of the memory block specified via the
+ native pointer.
+
+
+
+
+ Frees a memory block previously obtained from the
+ method.
+
+
+ The native pointer to the memory block previously obtained from the
+ method.
+
+
+
+
+ This class contains static methods that are used to deal with native
+ UTF-8 string pointers to be used with the SQLite core library.
+
+
+
+
+ This is the maximum possible length for the native UTF-8 encoded
+ strings used with the SQLite core library.
+
+
+
+
+ This is the object instance used to handle
+ conversions from/to UTF-8.
+
+
+
+
+ Converts the specified managed string into the UTF-8 encoding and
+ returns the array of bytes containing its representation in that
+ encoding.
+
+
+ The managed string to convert.
+
+
+ The array of bytes containing the representation of the managed
+ string in the UTF-8 encoding or null upon failure.
+
+
+
+
+ Converts the specified array of bytes representing a string in the
+ UTF-8 encoding and returns a managed string.
+
+
+ The array of bytes to convert.
+
+
+ The managed string or null upon failure.
+
+
+
+
+ Probes a native pointer to a string in the UTF-8 encoding for its
+ terminating NUL character, within the specified length limit.
+
+
+ The native NUL-terminated string pointer.
+
+
+ The maximum length of the native string, in bytes.
+
+
+ The length of the native string, in bytes -OR- zero if the length
+ could not be determined.
+
+
+
+
+ Converts the specified native NUL-terminated UTF-8 string pointer
+ into a managed string.
+
+
+ The native NUL-terminated UTF-8 string pointer.
+
+
+ The managed string or null upon failure.
+
+
+
+
+ Converts the specified native UTF-8 string pointer of the specified
+ length into a managed string.
+
+
+ The native UTF-8 string pointer.
+
+
+ The length of the native string, in bytes.
+
+
+ The managed string or null upon failure.
+
+
+
+
+ Converts the specified managed string into a native NUL-terminated
+ UTF-8 string pointer using memory obtained from the SQLite core
+ library.
+
+
+ The managed string to convert.
+
+
+ The native NUL-terminated UTF-8 string pointer or
+ upon failure.
+
+
+
+
+ Converts a logical array of native NUL-terminated UTF-8 string
+ pointers into an array of managed strings.
+
+
+ The number of elements in the logical array of native
+ NUL-terminated UTF-8 string pointers.
+
+
+ The native pointer to the logical array of native NUL-terminated
+ UTF-8 string pointers to convert.
+
+
+ The array of managed strings or null upon failure.
+
+
+
+
+ Converts an array of managed strings into an array of native
+ NUL-terminated UTF-8 string pointers.
+
+
+ The array of managed strings to convert.
+
+
+ The array of native NUL-terminated UTF-8 string pointers or null
+ upon failure.
+
+
+
+
+ This class contains static methods that are used to deal with native
+ pointers to memory blocks that logically contain arrays of bytes to be
+ used with the SQLite core library.
+
+
+
+
+ Converts a native pointer to a logical array of bytes of the
+ specified length into a managed byte array.
+
+
+ The native pointer to the logical array of bytes to convert.
+
+
+ The length, in bytes, of the logical array of bytes to convert.
+
+
+ The managed byte array or null upon failure.
+
+
+
+
+ Converts a managed byte array into a native pointer to a logical
+ array of bytes.
+
+
+ The managed byte array to convert.
+
+
+ The native pointer to a logical byte array or null upon failure.
+
+
+
+
+ This class contains static methods that are used to perform several
+ low-level data marshalling tasks between native and managed code.
+
+
+
+
+ Returns a new object instance based on the
+ specified object instance and an integer
+ offset.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location that the new
+ object instance should point to.
+
+
+ The new object instance.
+
+
+
+
+ Rounds up an integer size to the next multiple of the alignment.
+
+
+ The size, in bytes, to be rounded up.
+
+
+ The required alignment for the return value.
+
+
+ The size, in bytes, rounded up to the next multiple of the
+ alignment. This value may end up being the same as the original
+ size.
+
+
+
+
+ Determines the offset, in bytes, of the next structure member.
+
+
+ The offset, in bytes, of the current structure member.
+
+
+ The size, in bytes, of the current structure member.
+
+
+ The alignment, in bytes, of the next structure member.
+
+
+ The offset, in bytes, of the next structure member.
+
+
+
+
+ Reads a value from the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be read is located.
+
+
+ The value at the specified memory location.
+
+
+
+
+ Reads a value from the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be read is located.
+
+
+ The value at the specified memory location.
+
+
+
+
+ Reads a value from the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ to be read is located.
+
+
+ The value at the specified memory location.
+
+
+
+
+ Reads an value from the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be read is located.
+
+
+ The value at the specified memory location.
+
+
+
+
+ Writes an value to the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be written is located.
+
+
+ The value to write.
+
+
+
+
+ Writes an value to the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be written is located.
+
+
+ The value to write.
+
+
+
+
+ Writes a value to the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be written is located.
+
+
+ The value to write.
+
+
+
+
+ Writes a value to the specified memory
+ location.
+
+
+ The object instance representing the base
+ memory location.
+
+
+ The integer offset from the base memory location where the
+ value to be written is located.
+
+
+ The value to write.
+
+
+
+
+ Generates a hash code value for the object.
+
+
+ The object instance used to calculate the hash code.
+
+
+ Non-zero if different object instances with the same value should
+ generate different hash codes, where applicable. This parameter
+ has no effect on the .NET Compact Framework.
+
+
+ The hash code value -OR- zero if the object is null.
+
+
+
+
+ This class represents a managed virtual table module implementation.
+ It is not sealed and must be used as the base class for any
+ user-defined virtual table module classes implemented in managed code.
+
+
+
+
+ The default version of the native sqlite3_module structure in use.
+
+
+
+
+ This field is used to store the native sqlite3_module structure
+ associated with this object instance.
+
+
+
+
+ This field is used to store the destructor delegate to be passed to
+ the SQLite core library via the sqlite3_create_disposable_module()
+ function.
+
+
+
+
+ This field is used to store a pointer to the native sqlite3_module
+ structure returned by the sqlite3_create_disposable_module
+ function.
+
+
+
+
+ This field is used to store the virtual table instances associated
+ with this module. The native pointer to the sqlite3_vtab derived
+ structure is used to key into this collection.
+
+
+
+
+ This field is used to store the virtual table cursor instances
+ associated with this module. The native pointer to the
+ sqlite3_vtab_cursor derived structure is used to key into this
+ collection.
+
+
+
+
+ This field is used to store the virtual table function instances
+ associated with this module. The case-insensitive function name
+ and the number of arguments (with -1 meaning "any") are used to
+ construct the string that is used to key into this collection.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+
+
+ Calls the native SQLite core library in order to create a new
+ disposable module containing the implementation of a virtual table.
+
+
+ The native database connection pointer to use.
+
+
+ Non-zero upon success.
+
+
+
+
+ This method is called by the SQLite core library when the native
+ module associated with this object instance is being destroyed due
+ to its parent connection being closed. It may also be called by
+ the "vtshim" module if/when the sqlite3_dispose_module() function
+ is called.
+
+
+ The native user-data pointer associated with this module, as it was
+ provided to the SQLite core library when the native module instance
+ was created.
+
+
+
+
+ Creates and returns the native sqlite_module structure using the
+ configured (or default)
+ interface implementation.
+
+
+ The native sqlite_module structure using the configured (or
+ default) interface
+ implementation.
+
+
+
+
+ Creates and returns the native sqlite_module structure using the
+ specified interface
+ implementation.
+
+
+ The interface implementation to
+ use.
+
+
+ The native sqlite_module structure using the specified
+ interface implementation.
+
+
+
+
+ Creates a copy of the specified
+ object instance,
+ using default implementations for the contained delegates when
+ necessary.
+
+
+ The object
+ instance to copy.
+
+
+ The new object
+ instance.
+
+
+
+
+ Calls one of the virtual table initialization methods.
+
+
+ Non-zero to call the
+ method; otherwise, the
+ method will be called.
+
+
+ The native database connection handle.
+
+
+ The original native pointer value that was provided to the
+ sqlite3_create_module(), sqlite3_create_module_v2() or
+ sqlite3_create_disposable_module() functions.
+
+
+ The number of arguments from the CREATE VIRTUAL TABLE statement.
+
+
+ The array of string arguments from the CREATE VIRTUAL TABLE
+ statement.
+
+
+ Upon success, this parameter must be modified to point to the newly
+ created native sqlite3_vtab derived structure.
+
+
+ Upon failure, this parameter must be modified to point to the error
+ message, with the underlying memory having been obtained from the
+ sqlite3_malloc() function.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Calls one of the virtual table finalization methods.
+
+
+ Non-zero to call the
+ method; otherwise, the
+ method will be
+ called.
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The object instance to be used.
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ Non-zero if this error message should also be logged using the
+ class.
+
+
+ Non-zero if caught exceptions should be logged using the
+ class.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The object instance to be used.
+
+
+ The object instance used to
+ lookup the native pointer to the sqlite3_vtab derived structure.
+
+
+ Non-zero if this error message should also be logged using the
+ class.
+
+
+ Non-zero if caught exceptions should be logged using the
+ class.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The object instance to be used.
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure
+ used to get the native pointer to the sqlite3_vtab derived
+ structure.
+
+
+ Non-zero if this error message should also be logged using the
+ class.
+
+
+ Non-zero if caught exceptions should be logged using the
+ class.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The object instance to be used.
+
+
+ The object instance used to
+ lookup the native pointer to the sqlite3_vtab derived structure.
+
+
+ Non-zero if this error message should also be logged using the
+ class.
+
+
+ Non-zero if caught exceptions should be logged using the
+ class.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Gets and returns the interface
+ implementation to be used when creating the native sqlite3_module
+ structure. Derived classes may override this method to supply an
+ alternate implementation for the
+ interface.
+
+
+ The interface implementation to
+ be used when populating the native sqlite3_module structure. If
+ the returned value is null, the private methods provided by the
+ class and relating to the
+ interface will be used to
+ create the necessary delegates.
+
+
+
+
+ Creates and returns the
+ interface implementation corresponding to the current
+ object instance.
+
+
+ The interface implementation
+ corresponding to the current object
+ instance.
+
+
+
+
+ Allocates a native sqlite3_vtab derived structure and returns a
+ native pointer to it.
+
+
+ A native pointer to a native sqlite3_vtab derived structure.
+
+
+
+
+ Zeros out the fields of a native sqlite3_vtab derived structure.
+
+
+ The native pointer to the native sqlite3_vtab derived structure to
+ zero.
+
+
+
+
+ Frees a native sqlite3_vtab structure using the provided native
+ pointer to it.
+
+
+ A native pointer to a native sqlite3_vtab derived structure.
+
+
+
+
+ Allocates a native sqlite3_vtab_cursor derived structure and
+ returns a native pointer to it.
+
+
+ A native pointer to a native sqlite3_vtab_cursor derived structure.
+
+
+
+
+ Frees a native sqlite3_vtab_cursor structure using the provided
+ native pointer to it.
+
+
+ A native pointer to a native sqlite3_vtab_cursor derived structure.
+
+
+
+
+ Reads and returns the native pointer to the sqlite3_vtab derived
+ structure based on the native pointer to the sqlite3_vtab_cursor
+ derived structure.
+
+
+ The object instance to be used.
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure
+ from which to read the native pointer to the sqlite3_vtab derived
+ structure.
+
+
+ The native pointer to the sqlite3_vtab derived structure -OR-
+ if it cannot be determined.
+
+
+
+
+ Reads and returns the native pointer to the sqlite3_vtab derived
+ structure based on the native pointer to the sqlite3_vtab_cursor
+ derived structure.
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure
+ from which to read the native pointer to the sqlite3_vtab derived
+ structure.
+
+
+ The native pointer to the sqlite3_vtab derived structure -OR-
+ if it cannot be determined.
+
+
+
+
+ Looks up and returns the object
+ instance based on the native pointer to the sqlite3_vtab derived
+ structure.
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The object instance or null if
+ the corresponding one cannot be found.
+
+
+
+
+ Allocates and returns a native pointer to a sqlite3_vtab derived
+ structure and creates an association between it and the specified
+ object instance.
+
+
+ The object instance to be used
+ when creating the association.
+
+
+ The native pointer to a sqlite3_vtab derived structure or
+ if the method fails for any reason.
+
+
+
+
+ Looks up and returns the
+ object instance based on the native pointer to the
+ sqlite3_vtab_cursor derived structure.
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The native pointer to the sqlite3_vtab_cursor derived structure.
+
+
+ The object instance or null
+ if the corresponding one cannot be found.
+
+
+
+
+ Allocates and returns a native pointer to a sqlite3_vtab_cursor
+ derived structure and creates an association between it and the
+ specified object instance.
+
+
+ The object instance to be
+ used when creating the association.
+
+
+ The native pointer to a sqlite3_vtab_cursor derived structure or
+ if the method fails for any reason.
+
+
+
+
+ Deterimines the key that should be used to identify and store the
+ object instance for the virtual table
+ (i.e. to be returned via the
+ method).
+
+
+ The number of arguments to the virtual table function.
+
+
+ The name of the virtual table function.
+
+
+ The object instance associated with
+ this virtual table function.
+
+
+ The string that should be used to identify and store the virtual
+ table function instance. This method cannot return null. If null
+ is returned from this method, the behavior is undefined.
+
+
+
+
+ Attempts to declare the schema for the virtual table using the
+ specified database connection.
+
+
+ The object instance to use when
+ declaring the schema of the virtual table. This parameter may not
+ be null.
+
+
+ The string containing the CREATE TABLE statement that completely
+ describes the schema for the virtual table. This parameter may not
+ be null.
+
+
+ Upon failure, this parameter must be modified to contain an error
+ message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Calls the native SQLite core library in order to declare a virtual
+ table function in response to a call into the
+
+ or virtual table
+ methods.
+
+
+ The object instance to use when
+ declaring the schema of the virtual table.
+
+
+ The number of arguments to the function being declared.
+
+
+ The name of the function being declared.
+
+
+ Upon success, the contents of this parameter are undefined. Upon
+ failure, it should contain an appropriate error message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The object instance used to
+ lookup the native pointer to the sqlite3_vtab derived structure.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Arranges for the specified error message to be placed into the
+ zErrMsg field of a sqlite3_vtab derived structure, freeing the
+ existing error message, if any.
+
+
+ The object instance used to
+ lookup the native pointer to the sqlite3_vtab derived structure.
+
+
+ The error message.
+
+
+ Non-zero upon success.
+
+
+
+
+ Modifies the specified object instance
+ to contain the specified estimated cost.
+
+
+ The object instance to modify.
+
+
+ The estimated cost value to use. Using a null value means that the
+ default value provided by the SQLite core library should be used.
+
+
+ Non-zero upon success.
+
+
+
+
+ Modifies the specified object instance
+ to contain the default estimated cost.
+
+
+ The object instance to modify.
+
+
+ Non-zero upon success.
+
+
+
+
+ Modifies the specified object instance
+ to contain the specified estimated rows.
+
+
+ The object instance to modify.
+
+
+ The estimated rows value to use. Using a null value means that the
+ default value provided by the SQLite core library should be used.
+
+
+ Non-zero upon success.
+
+
+
+
+ Modifies the specified object instance
+ to contain the default estimated rows.
+
+
+ The object instance to modify.
+
+
+ Non-zero upon success.
+
+
+
+
+ Modifies the specified object instance
+ to contain the specified flags.
+
+
+ The object instance to modify.
+
+
+ The index flags value to use. Using a null value means that the
+ default value provided by the SQLite core library should be used.
+
+
+ Non-zero upon success.
+
+
+
+
+ Modifies the specified object instance
+ to contain the default index flags.
+
+
+ The object instance to modify.
+
+
+ Non-zero upon success.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated with
+ the virtual table.
+
+
+ The native user-data pointer associated with this module, as it was
+ provided to the SQLite core library when the native module instance
+ was created.
+
+
+ The module name, database name, virtual table name, and all other
+ arguments passed to the CREATE VIRTUAL TABLE statement.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance associated with
+ the virtual table.
+
+
+ Upon failure, this parameter must be modified to contain an error
+ message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated with
+ the virtual table.
+
+
+ The native user-data pointer associated with this module, as it was
+ provided to the SQLite core library when the native module instance
+ was created.
+
+
+ The module name, database name, virtual table name, and all other
+ arguments passed to the CREATE VIRTUAL TABLE statement.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance associated with
+ the virtual table.
+
+
+ Upon failure, this parameter must be modified to contain an error
+ message.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The object instance containing all the
+ data for the inputs and outputs relating to index selection.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance associated
+ with the newly opened virtual table cursor.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ Number used to help identify the selected index.
+
+
+ String used to help identify the selected index.
+
+
+ The values corresponding to each column in the selected index.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ Non-zero if no more rows are available; zero otherwise.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ The object instance to be used for
+ returning the specified column value to the SQLite core library.
+
+
+ The zero-based index corresponding to the column containing the
+ value to be returned.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ Upon success, this parameter must be modified to contain the unique
+ integer row identifier for the current row for the specified cursor.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The array of object instances containing
+ the new or modified column values, if any.
+
+
+ Upon success, this parameter must be modified to contain the unique
+ integer row identifier for the row that was inserted, if any.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The number of arguments to the function being sought.
+
+
+ The name of the function being sought.
+
+
+ Upon success, this parameter must be modified to contain the
+ object instance responsible for
+ implementing the specified function.
+
+
+ Upon success, this parameter must be modified to contain the
+ native user-data pointer associated with
+ .
+
+
+ Non-zero if the specified function was found; zero otherwise.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ The new name for the virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ This is an integer identifier under which the the current state of
+ the virtual table should be saved.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ This is an integer used to indicate that any saved states with an
+ identifier greater than or equal to this should be deleted by the
+ virtual table.
+
+
+ A standard SQLite return code.
+
+
+
+
+ This method is called in response to the
+ method.
+
+
+ The object instance associated
+ with this virtual table.
+
+
+ This is an integer identifier used to specify a specific saved
+ state for the virtual table for it to restore itself back to, which
+ should also have the effect of deleting all saved states with an
+ integer identifier greater than this one.
+
+
+ A standard SQLite return code.
+
+
+
+
+ Disposes of this object instance.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is being
+ called from the finalizer.
+
+
+
+
+ Finalizes this object instance.
+
+
+
+
+ Returns or sets a boolean value indicating whether virtual table
+ errors should be logged using the class.
+
+
+
+
+ Returns or sets a boolean value indicating whether exceptions
+ caught in the
+ method,
+ the method,
+ the method,
+ the method,
+ and the method should be logged using the
+ class.
+
+
+
+
+ Returns or sets a boolean value indicating whether virtual table
+ errors should be logged using the class.
+
+
+
+
+ Returns or sets a boolean value indicating whether exceptions
+ caught in the
+ method,
+ method, and the
+ method should be logged using the
+ class.
+
+
+
+
+ Returns non-zero if the schema for the virtual table has been
+ declared.
+
+
+
+
+ Returns the name of the module as it was registered with the SQLite
+ core library.
+
+
+
+
+ This class implements the
+ interface by forwarding those method calls to the
+ object instance it contains. If the
+ contained object instance is null, all
+ the methods simply generate an
+ error.
+
+
+
+
+ This is the value that is always used for the "logErrors"
+ parameter to the various static error handling methods provided
+ by the class.
+
+
+
+
+ This is the value that is always used for the "logExceptions"
+ parameter to the various static error handling methods provided
+ by the class.
+
+
+
+
+ This is the error message text used when the contained
+ object instance is not available
+ for any reason.
+
+
+
+
+ The object instance used to provide
+ an implementation of the
+ interface.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The object instance used to provide
+ an implementation of the
+ interface.
+
+
+
+
+ Sets the table error message to one that indicates the native
+ module implementation is not available.
+
+
+ The native pointer to the sqlite3_vtab derived structure.
+
+
+ The value of .
+
+
+
+
+ Sets the table error message to one that indicates the native
+ module implementation is not available.
+
+
+ The native pointer to the sqlite3_vtab_cursor derived
+ structure.
+
+
+ The value of .
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ Disposes of this object instance.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is being
+ called from the finalizer.
+
+
+
+
+ Finalizes this object instance.
+
+
+
+
+ This class contains some virtual methods that may be useful for other
+ virtual table classes. It specifically does NOT implement any of the
+ interface methods.
+
+
+
+
+ This class implements a virtual table module that does nothing by
+ providing "empty" implementations for all of the
+ interface methods. The result
+ codes returned by these "empty" method implementations may be
+ controlled on a per-method basis by using and/or overriding the
+ ,
+ ,
+ ,
+ , and
+ methods from within derived classes.
+
+
+
+
+ This field is used to store the
+ values to return, on a per-method basis, for all methods that are
+ part of the interface.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+
+
+ Determines the default value to be
+ returned by methods of the
+ interface that lack an overridden implementation in all classes
+ derived from the class.
+
+
+ The value that should be returned
+ by all interface methods unless
+ a more specific result code has been set for that interface method.
+
+
+
+
+ Converts a value into a boolean
+ return value for use with the
+ method.
+
+
+ The value to convert.
+
+
+ The value.
+
+
+
+
+ Converts a value into a boolean
+ return value for use with the
+ method.
+
+
+ The value to convert.
+
+
+ The value.
+
+
+
+
+ Determines the value that should be
+ returned by the specified
+ interface method if it lack an overridden implementation. If no
+ specific value is available (or set)
+ for the specified method, the value
+ returned by the method will be
+ returned instead.
+
+
+ The name of the method. Currently, this method must be part of
+ the interface.
+
+
+ The value that should be returned
+ by the interface method.
+
+
+
+
+ Sets the value that should be
+ returned by the specified
+ interface method if it lack an overridden implementation.
+
+
+ The name of the method. Currently, this method must be part of
+ the interface.
+
+
+ The value that should be returned
+ by the interface method.
+
+
+ Non-zero upon success.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is
+ being called from the finalizer.
+
+
+
+
+ The CREATE TABLE statement used to declare the schema for the
+ virtual table.
+
+
+
+
+ Non-zero if different object instances with the same value should
+ generate different row identifiers, where applicable. This has no
+ effect on the .NET Compact Framework.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+ Non-zero if different object instances with the same value should
+ generate different row identifiers, where applicable. This
+ parameter has no effect on the .NET Compact Framework.
+
+
+
+
+ Determines the SQL statement used to declare the virtual table.
+ This method should be overridden in derived classes if they require
+ a custom virtual table schema.
+
+
+ The SQL statement used to declare the virtual table -OR- null if it
+ cannot be determined.
+
+
+
+
+ Sets the table error message to one that indicates the virtual
+ table cursor is of the wrong type.
+
+
+ The object instance.
+
+
+ The that the virtual table cursor should be.
+
+
+ The value of .
+
+
+
+
+ Determines the string to return as the column value for the object
+ instance value.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ The object instance to return a string representation for.
+
+
+ The string representation of the specified object instance or null
+ upon failure.
+
+
+
+
+ Constructs an unique row identifier from two
+ values. The first value
+ must contain the row sequence number for the current row and the
+ second value must contain the hash code of the key column value
+ for the current row.
+
+
+ The integer row sequence number for the current row.
+
+
+ The hash code of the key column value for the current row.
+
+
+ The unique row identifier or zero upon failure.
+
+
+
+
+ Determines the unique row identifier for the current row.
+
+
+ The object instance
+ associated with the previously opened virtual table cursor to be
+ used.
+
+
+ The object instance to return a unique row identifier for.
+
+
+ The unique row identifier or zero upon failure.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is
+ being called from the finalizer.
+
+
+
+
+ This class represents a virtual table cursor to be used with the
+ class. It is not sealed and may
+ be used as the base class for any user-defined virtual table cursor
+ class that wraps an object instance.
+
+
+
+
+ The instance provided when this cursor
+ was created.
+
+
+
+
+ This value will be non-zero if false has been returned from the
+ method.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The object instance associated
+ with this object instance.
+
+
+ The instance to expose as a virtual
+ table cursor.
+
+
+
+
+ Advances to the next row of the virtual table cursor using the
+ method of the
+ object instance.
+
+
+ Non-zero if the current row is valid; zero otherwise. If zero is
+ returned, no further rows are available.
+
+
+
+
+ Resets the virtual table cursor position, also invalidating the
+ current row, using the method of
+ the object instance.
+
+
+
+
+ Closes the virtual table cursor. This method must not throw any
+ exceptions.
+
+
+
+
+ Throws an if the virtual
+ table cursor has been closed.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is
+ being called from the finalizer.
+
+
+
+
+ Returns the value for the current row of the virtual table cursor
+ using the property of the
+ object instance.
+
+
+
+
+ Returns non-zero if the end of the virtual table cursor has been
+ seen (i.e. no more rows are available, including the current one).
+
+
+
+
+ Returns non-zero if the virtual table cursor is open.
+
+
+
+
+ This class implements a virtual table module that exposes an
+ object instance as a read-only virtual
+ table. It is not sealed and may be used as the base class for any
+ user-defined virtual table class that wraps an
+ object instance. The following short
+ example shows it being used to treat an array of strings as a table
+ data source:
+
+ public static class Sample
+ {
+ public static void Main()
+ {
+ using (SQLiteConnection connection = new SQLiteConnection(
+ "Data Source=:memory:;"))
+ {
+ connection.Open();
+
+ connection.CreateModule(new SQLiteModuleEnumerable(
+ "sampleModule", new string[] { "one", "two", "three" }));
+
+ using (SQLiteCommand command = connection.CreateCommand())
+ {
+ command.CommandText =
+ "CREATE VIRTUAL TABLE t1 USING sampleModule;";
+
+ command.ExecuteNonQuery();
+ }
+
+ using (SQLiteCommand command = connection.CreateCommand())
+ {
+ command.CommandText = "SELECT * FROM t1;";
+
+ using (SQLiteDataReader dataReader = command.ExecuteReader())
+ {
+ while (dataReader.Read())
+ Console.WriteLine(dataReader[0].ToString());
+ }
+ }
+
+ connection.Close();
+ }
+ }
+ }
+
+
+
+
+
+ The instance containing the backing data
+ for the virtual table.
+
+
+
+
+ Non-zero if different object instances with the same value should
+ generate different row identifiers, where applicable. This has no
+ effect on the .NET Compact Framework.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+ The instance to expose as a virtual
+ table. This parameter cannot be null.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+ The instance to expose as a virtual
+ table. This parameter cannot be null.
+
+
+ Non-zero if different object instances with the same value should
+ generate different row identifiers, where applicable. This
+ parameter has no effect on the .NET Compact Framework.
+
+
+
+
+ Sets the table error message to one that indicates the virtual
+ table cursor has no current row.
+
+
+ The object instance.
+
+
+ The value of .
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is
+ being called from the finalizer.
+
+
+
+
+ This class represents a virtual table cursor to be used with the
+ class. It is not sealed and may
+ be used as the base class for any user-defined virtual table cursor
+ class that wraps an object instance.
+
+
+
+
+ The instance provided when this
+ cursor was created.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The object instance associated
+ with this object instance.
+
+
+ The instance to expose as a virtual
+ table cursor.
+
+
+
+
+ Closes the virtual table cursor. This method must not throw any
+ exceptions.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is
+ being called from the finalizer.
+
+
+
+
+ Returns the value for the current row of the virtual table cursor
+ using the property of the
+ object instance.
+
+
+
+
+ This class implements a virtual table module that exposes an
+ object instance as a read-only virtual
+ table. It is not sealed and may be used as the base class for any
+ user-defined virtual table class that wraps an
+ object instance.
+
+
+
+
+ The instance containing the backing
+ data for the virtual table.
+
+
+
+
+ Constructs an instance of this class.
+
+
+ The name of the module. This parameter cannot be null.
+
+
+ The instance to expose as a virtual
+ table. This parameter cannot be null.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+ See the method.
+
+
+
+
+ Throws an if this object
+ instance has been disposed.
+
+
+
+
+ Disposes of this object instance.
+
+
+ Non-zero if this method is being called from the
+ method. Zero if this method is
+ being called from the finalizer.
+
+
+
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.csproj.FileListAbsolute.txt b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.csproj.FileListAbsolute.txt
new file mode 100644
index 0000000..7a4fccb
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.csproj.FileListAbsolute.txt
@@ -0,0 +1,114 @@
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\CLinerStyle.dll
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\CLinerStyle.pdb
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\Lib.Controls.MyControls.dll
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\System.Data.SQLite.dll
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\Lib.Controls.MyControls.pdb
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\System.Data.SQLite.xml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\GenericStyle.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\Border.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\brush.scroll.down.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\brush.scroll.up.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\Button.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\ComboBox.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\CsColor.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\raditoStyle.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\TextBox.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\Cs_Slider.g.cs
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\Cs_Spinner.g.cs
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.cache
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.lref
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\CheckBox.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\Cs_Slider.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\Themes\Cs_Spinner.baml
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\CLinerStyle.g.resources
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\CLinerStyle.dll
+D:\William\work\VCsharp\work\CLinerStyle\CLinerStyle\obj\Debug\CLinerStyle.pdb
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\CLinerStyle.dll
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\CLinerStyle.pdb
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\Lib.Controls.MyControls.dll
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\System.Data.SQLite.dll
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\Lib.Controls.MyControls.pdb
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\System.Data.SQLite.xml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.csprojResolveAssemblyReference.cache
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\GenericStyle.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Border.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\brush.scroll.down.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\brush.scroll.up.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Button.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\ComboBox.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CsColor.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\raditoStyle.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\TextBox.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Slider.g.cs
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Spinner.g.cs
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.cache
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.lref
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CheckBox.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Slider.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Spinner.baml
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.g.resources
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.dll
+D:\William\work\VCsharp\work\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.pdb
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CLinerStyle.dll
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CLinerStyle.pdb
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\Lib.Controls.MyControls.dll
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\System.Data.SQLite.dll
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\Lib.Controls.MyControls.pdb
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\System.Data.SQLite.xml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.csprojResolveAssemblyReference.cache
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\progressBarStyle.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\GenericStyle.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Border.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\brush.scroll.down.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\brush.scroll.up.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Button.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\ComboBox.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CsColor.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\raditoStyle.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\TextBox.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Slider.g.cs
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Spinner.g.cs
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.cache
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.lref
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CheckBox.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Slider.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Spinner.baml
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.g.resources
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.dll
+D:\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.pdb
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CLinerStyle.dll
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CLinerStyle.pdb
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\Lib.Controls.MyControls.dll
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\System.Data.SQLite.dll
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CommLibrary.dll
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\Lib.Controls.MyControls.pdb
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\System.Data.SQLite.xml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\bin\Debug\CommLibrary.pdb
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.csprojResolveAssemblyReference.cache
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CircleLabelStyle.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\progressBarStyle.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\GenericStyle.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Border.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\brush.scroll.down.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\brush.scroll.up.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Button.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\ComboBox.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CsColor.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\raditoStyle.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\TextBox.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Slider.g.cs
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Spinner.g.cs
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.cache
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle_MarkupCompile.lref
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\CheckBox.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Slider.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\Themes\Cs_Spinner.baml
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.g.resources
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.dll
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\CLinerStyle.pdb
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.csprojResolveAssemblyReference.cache b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.csprojResolveAssemblyReference.cache
new file mode 100644
index 0000000..0f40e9d
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.csprojResolveAssemblyReference.cache differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.dll b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.dll
new file mode 100644
index 0000000..ece1cd6
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.dll differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.g.resources b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.g.resources
new file mode 100644
index 0000000..c6964b1
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.g.resources differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.pdb b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.pdb
new file mode 100644
index 0000000..0260a61
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle.pdb differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.cache b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.cache
new file mode 100644
index 0000000..a71eec6
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.cache
@@ -0,0 +1,20 @@
+CLinerStyle
+
+
+library
+C#
+.cs
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\
+CLinerStyle
+none
+false
+DEBUG;TRACE
+
+14-1557736272
+
+3-1704764288
+13-840469135
+Themes\CircleLabelStyle.xaml;Themes\progressBarStyle.xaml;Themes\GenericStyle.xaml;Themes\Border.xaml;Themes\brush.scroll.down.xaml;Themes\brush.scroll.up.xaml;Themes\Button.xaml;Themes\CheckBox.xaml;Themes\ComboBox.xaml;Themes\CsColor.xaml;Themes\Cs_Slider.xaml;Themes\Cs_Spinner.xaml;Themes\raditoStyle.xaml;Themes\TextBox.xaml;
+
+False
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.i.cache b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.i.cache
new file mode 100644
index 0000000..d6d1150
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.i.cache
@@ -0,0 +1,20 @@
+CLinerStyle
+
+
+library
+C#
+.cs
+D:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\obj\Debug\
+CLinerStyle
+none
+false
+DEBUG;TRACE
+
+14-1557736272
+
+7-2122167466
+13-840469135
+Themes\CircleLabelStyle.xaml;Themes\progressBarStyle.xaml;Themes\GenericStyle.xaml;Themes\Border.xaml;Themes\brush.scroll.down.xaml;Themes\brush.scroll.up.xaml;Themes\Button.xaml;Themes\CheckBox.xaml;Themes\ComboBox.xaml;Themes\CsColor.xaml;Themes\Cs_Slider.xaml;Themes\Cs_Spinner.xaml;Themes\raditoStyle.xaml;Themes\TextBox.xaml;
+
+False
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.lref b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.lref
new file mode 100644
index 0000000..08541ff
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/CLinerStyle_MarkupCompile.lref
@@ -0,0 +1,6 @@
+
+
+FD:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\Themes\CheckBox.xaml;;
+FD:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\Themes\Cs_Slider.xaml;;
+FD:\JinHeng\William\work\VCsharp\Control\CLinerStyle\src\CLinerStyle\Themes\Cs_Spinner.xaml;;
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/CLinerStyle/src/CLinerStyle/obj/Debug/DesignTimeResolveAssemblyReferences.cache
new file mode 100644
index 0000000..a9a8e95
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/CLinerStyle/src/CLinerStyle/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
new file mode 100644
index 0000000..c2ab6ac
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/TempPE/Resource1.Designer.cs.dll b/CLinerStyle/src/CLinerStyle/obj/Debug/TempPE/Resource1.Designer.cs.dll
new file mode 100644
index 0000000..ad60419
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/TempPE/Resource1.Designer.cs.dll differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
new file mode 100644
index 0000000..e69de29
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
new file mode 100644
index 0000000..e69de29
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
new file mode 100644
index 0000000..e69de29
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Border.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Border.baml
new file mode 100644
index 0000000..3021b4a
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Border.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Button.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Button.baml
new file mode 100644
index 0000000..8817cc7
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Button.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CheckBox.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CheckBox.baml
new file mode 100644
index 0000000..6cb1fa9
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CheckBox.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CircleLabelStyle.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CircleLabelStyle.baml
new file mode 100644
index 0000000..a2dd22a
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CircleLabelStyle.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/ComboBox.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/ComboBox.baml
new file mode 100644
index 0000000..af54592
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/ComboBox.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CsColor.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CsColor.baml
new file mode 100644
index 0000000..7cef1ea
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/CsColor.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.baml
new file mode 100644
index 0000000..d9e16fb
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.g.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.g.cs
new file mode 100644
index 0000000..1f45425
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.g.cs
@@ -0,0 +1,106 @@
+#pragma checksum "..\..\..\Themes\Cs_Slider.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "88DF0BFBC71BDB995FA9085B53F77FE3"
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using CLinerStyle;
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Media.TextFormatting;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+
+namespace CLinerStyle {
+
+
+ ///
+ /// Cs_Slider
+ ///
+ public partial class Cs_Slider : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
+
+
+ #line 7 "..\..\..\Themes\Cs_Slider.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal CLinerStyle.Cs_Slider ks;
+
+ #line default
+ #line hidden
+
+
+ #line 10 "..\..\..\Themes\Cs_Slider.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Primitives.Thumb thumb;
+
+ #line default
+ #line hidden
+
+ private bool _contentLoaded;
+
+ ///
+ /// InitializeComponent
+ ///
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent() {
+ if (_contentLoaded) {
+ return;
+ }
+ _contentLoaded = true;
+ System.Uri resourceLocater = new System.Uri("/CLinerStyle;component/themes/cs_slider.xaml", System.UriKind.Relative);
+
+ #line 1 "..\..\..\Themes\Cs_Slider.xaml"
+ System.Windows.Application.LoadComponent(this, resourceLocater);
+
+ #line default
+ #line hidden
+ }
+
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
+ switch (connectionId)
+ {
+ case 1:
+ this.ks = ((CLinerStyle.Cs_Slider)(target));
+ return;
+ case 2:
+ this.thumb = ((System.Windows.Controls.Primitives.Thumb)(target));
+
+ #line 10 "..\..\..\Themes\Cs_Slider.xaml"
+ this.thumb.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler(this.thumb_DragDelta);
+
+ #line default
+ #line hidden
+ return;
+ }
+ this._contentLoaded = true;
+ }
+ }
+}
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.g.i.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.g.i.cs
new file mode 100644
index 0000000..1f45425
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Slider.g.i.cs
@@ -0,0 +1,106 @@
+#pragma checksum "..\..\..\Themes\Cs_Slider.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "88DF0BFBC71BDB995FA9085B53F77FE3"
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using CLinerStyle;
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Media.TextFormatting;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+
+namespace CLinerStyle {
+
+
+ ///
+ /// Cs_Slider
+ ///
+ public partial class Cs_Slider : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
+
+
+ #line 7 "..\..\..\Themes\Cs_Slider.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal CLinerStyle.Cs_Slider ks;
+
+ #line default
+ #line hidden
+
+
+ #line 10 "..\..\..\Themes\Cs_Slider.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Primitives.Thumb thumb;
+
+ #line default
+ #line hidden
+
+ private bool _contentLoaded;
+
+ ///
+ /// InitializeComponent
+ ///
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent() {
+ if (_contentLoaded) {
+ return;
+ }
+ _contentLoaded = true;
+ System.Uri resourceLocater = new System.Uri("/CLinerStyle;component/themes/cs_slider.xaml", System.UriKind.Relative);
+
+ #line 1 "..\..\..\Themes\Cs_Slider.xaml"
+ System.Windows.Application.LoadComponent(this, resourceLocater);
+
+ #line default
+ #line hidden
+ }
+
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
+ switch (connectionId)
+ {
+ case 1:
+ this.ks = ((CLinerStyle.Cs_Slider)(target));
+ return;
+ case 2:
+ this.thumb = ((System.Windows.Controls.Primitives.Thumb)(target));
+
+ #line 10 "..\..\..\Themes\Cs_Slider.xaml"
+ this.thumb.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler(this.thumb_DragDelta);
+
+ #line default
+ #line hidden
+ return;
+ }
+ this._contentLoaded = true;
+ }
+ }
+}
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.baml
new file mode 100644
index 0000000..e17a3bd
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.g.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.g.cs
new file mode 100644
index 0000000..5e7513a
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.g.cs
@@ -0,0 +1,152 @@
+#pragma checksum "..\..\..\Themes\Cs_Spinner.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "FD4E328EFFF8523FFEE3F3A4FECA8C23"
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using CLinerStyle;
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Media.TextFormatting;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+
+namespace CLinerStyle {
+
+
+ ///
+ /// Cs_Spinner
+ ///
+ public partial class Cs_Spinner : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
+
+
+ #line 8 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal CLinerStyle.Cs_Spinner sp;
+
+ #line default
+ #line hidden
+
+
+ #line 25 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox textbox;
+
+ #line default
+ #line hidden
+
+
+ #line 49 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button UpBtn;
+
+ #line default
+ #line hidden
+
+
+ #line 55 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button DownBtn;
+
+ #line default
+ #line hidden
+
+ private bool _contentLoaded;
+
+ ///
+ /// InitializeComponent
+ ///
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent() {
+ if (_contentLoaded) {
+ return;
+ }
+ _contentLoaded = true;
+ System.Uri resourceLocater = new System.Uri("/CLinerStyle;component/themes/cs_spinner.xaml", System.UriKind.Relative);
+
+ #line 1 "..\..\..\Themes\Cs_Spinner.xaml"
+ System.Windows.Application.LoadComponent(this, resourceLocater);
+
+ #line default
+ #line hidden
+ }
+
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
+ switch (connectionId)
+ {
+ case 1:
+ this.sp = ((CLinerStyle.Cs_Spinner)(target));
+
+ #line 9 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.sp.Loaded += new System.Windows.RoutedEventHandler(this.Cs_Spinner_Loaded);
+
+ #line default
+ #line hidden
+ return;
+ case 2:
+ this.textbox = ((System.Windows.Controls.TextBox)(target));
+ return;
+ case 3:
+ this.UpBtn = ((System.Windows.Controls.Button)(target));
+
+ #line 49 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.UpBtn.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonDown);
+
+ #line default
+ #line hidden
+
+ #line 49 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.UpBtn.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonUp);
+
+ #line default
+ #line hidden
+ return;
+ case 4:
+ this.DownBtn = ((System.Windows.Controls.Button)(target));
+
+ #line 55 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.DownBtn.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonDown);
+
+ #line default
+ #line hidden
+
+ #line 55 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.DownBtn.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonUp);
+
+ #line default
+ #line hidden
+ return;
+ }
+ this._contentLoaded = true;
+ }
+ }
+}
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.g.i.cs b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.g.i.cs
new file mode 100644
index 0000000..5e7513a
--- /dev/null
+++ b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/Cs_Spinner.g.i.cs
@@ -0,0 +1,152 @@
+#pragma checksum "..\..\..\Themes\Cs_Spinner.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "FD4E328EFFF8523FFEE3F3A4FECA8C23"
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using CLinerStyle;
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Media.TextFormatting;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+
+namespace CLinerStyle {
+
+
+ ///
+ /// Cs_Spinner
+ ///
+ public partial class Cs_Spinner : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
+
+
+ #line 8 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal CLinerStyle.Cs_Spinner sp;
+
+ #line default
+ #line hidden
+
+
+ #line 25 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox textbox;
+
+ #line default
+ #line hidden
+
+
+ #line 49 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button UpBtn;
+
+ #line default
+ #line hidden
+
+
+ #line 55 "..\..\..\Themes\Cs_Spinner.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button DownBtn;
+
+ #line default
+ #line hidden
+
+ private bool _contentLoaded;
+
+ ///
+ /// InitializeComponent
+ ///
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent() {
+ if (_contentLoaded) {
+ return;
+ }
+ _contentLoaded = true;
+ System.Uri resourceLocater = new System.Uri("/CLinerStyle;component/themes/cs_spinner.xaml", System.UriKind.Relative);
+
+ #line 1 "..\..\..\Themes\Cs_Spinner.xaml"
+ System.Windows.Application.LoadComponent(this, resourceLocater);
+
+ #line default
+ #line hidden
+ }
+
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
+ switch (connectionId)
+ {
+ case 1:
+ this.sp = ((CLinerStyle.Cs_Spinner)(target));
+
+ #line 9 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.sp.Loaded += new System.Windows.RoutedEventHandler(this.Cs_Spinner_Loaded);
+
+ #line default
+ #line hidden
+ return;
+ case 2:
+ this.textbox = ((System.Windows.Controls.TextBox)(target));
+ return;
+ case 3:
+ this.UpBtn = ((System.Windows.Controls.Button)(target));
+
+ #line 49 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.UpBtn.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonDown);
+
+ #line default
+ #line hidden
+
+ #line 49 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.UpBtn.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonUp);
+
+ #line default
+ #line hidden
+ return;
+ case 4:
+ this.DownBtn = ((System.Windows.Controls.Button)(target));
+
+ #line 55 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.DownBtn.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonDown);
+
+ #line default
+ #line hidden
+
+ #line 55 "..\..\..\Themes\Cs_Spinner.xaml"
+ this.DownBtn.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.btn_PreviewMouseLeftButtonUp);
+
+ #line default
+ #line hidden
+ return;
+ }
+ this._contentLoaded = true;
+ }
+ }
+}
+
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/GenericStyle.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/GenericStyle.baml
new file mode 100644
index 0000000..20ce818
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/GenericStyle.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/TextBox.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/TextBox.baml
new file mode 100644
index 0000000..a780da7
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/TextBox.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/brush.scroll.down.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/brush.scroll.down.baml
new file mode 100644
index 0000000..14f404d
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/brush.scroll.down.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/brush.scroll.up.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/brush.scroll.up.baml
new file mode 100644
index 0000000..9010020
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/brush.scroll.up.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/progressBarStyle.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/progressBarStyle.baml
new file mode 100644
index 0000000..d414eee
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/progressBarStyle.baml differ
diff --git a/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/raditoStyle.baml b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/raditoStyle.baml
new file mode 100644
index 0000000..d2712a7
Binary files /dev/null and b/CLinerStyle/src/CLinerStyle/obj/Debug/Themes/raditoStyle.baml differ
diff --git a/CommLibrary/CommLibrary.sln b/CommLibrary/CommLibrary.sln
new file mode 100644
index 0000000..6f1af2e
--- /dev/null
+++ b/CommLibrary/CommLibrary.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommLibrary", "CommLibrary\CommLibrary.csproj", "{DF646D67-5F08-464A-A026-79037E032EAD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DF646D67-5F08-464A-A026-79037E032EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DF646D67-5F08-464A-A026-79037E032EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DF646D67-5F08-464A-A026-79037E032EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DF646D67-5F08-464A-A026-79037E032EAD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/CommLibrary/CommLibrary.v12.suo b/CommLibrary/CommLibrary.v12.suo
new file mode 100644
index 0000000..79802e4
Binary files /dev/null and b/CommLibrary/CommLibrary.v12.suo differ
diff --git a/CommLibrary/CommLibrary/CDeviceInfo.cs b/CommLibrary/CommLibrary/CDeviceInfo.cs
new file mode 100644
index 0000000..60c559c
--- /dev/null
+++ b/CommLibrary/CommLibrary/CDeviceInfo.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: CDeviceInfo
+ *版本号: V1.0.0.0
+ *唯一标识:8ecf212b-17ad-43fd-946f-cf7fe131a1b2
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/8/2016 8:47:05 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/8/2016 8:47:05 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+
+ public class cPortInfo //connected port information
+ {
+ byte portindex;
+ byte portType; //port in,port out,text port,rd port etc.
+ bool isHasJoined;
+ public cPortInfo()
+ {
+
+ }
+
+ }
+
+
+ public enum Module_Type
+ {
+ Mod_CLIV = 100, //cl-4
+ Mod_LAN = 101, //lan interface
+ Mod_DLM808 = 102,//dlm808
+ Mod_MAVIII = 103,//matrxiA8
+ Mod_RVA100 = 104,//RVA200
+ Mod_RVC100 = 105,//rvc1000
+ Mod_RIO100 = 106,//rio100
+
+ Mod_RPM100 = 107,//rpm100
+ Mod_TxtLft = 108,//textleft
+ Mod_TxtRht = 109,//text right
+ }
+
+
+ public enum SPecial_DevID
+ {
+ DevID_LTXT = 0x5000,
+ DevID_RTXT = 0x5001,
+ DevID_LanRouter = 0x5002,
+ DevID_CLIV = 0x5003,
+ //--------------------
+ DevID_Normal = 0x1000,
+ }
+
+ public class DeviceProvision
+ {
+ public const int DefaultSerialNumberLen = 5;
+ public const int Len_DevName = 16;
+ public const int Len_FirmVer = 2;
+ public UInt16 pMachineID; //also name appID
+ public UInt16 pDeviceID;
+ public byte[] pDeviceName;
+ public byte[] pFirmwareVer;//mcu,dsp ver each one byte
+ public byte[] pDevSNONumber; //DeviceserialNumber
+
+
+ public DeviceProvision()
+ {
+ pDeviceID = 0;
+ pMachineID = 0;
+ pDeviceName = new byte[Len_DevName];
+ pDevSNONumber = new byte[DefaultSerialNumberLen];
+ pFirmwareVer = new byte[Len_FirmVer];
+ }
+
+ public string strDevName
+ {
+ get
+ {
+ return getStrDevName();
+
+ }
+ set
+ {
+ setStrDevName(value);
+ }
+ }
+
+
+ public bool isSameToAnotherDevice(DeviceProvision anotherDev)
+ {
+ return (pDeviceID == anotherDev.pDeviceID && pMachineID == anotherDev.pMachineID);
+ }
+
+ public string getStrDevName()
+ {
+ return UtilCover.bytesToString(pDeviceName, Len_DevName);
+ }
+ ///
+ ///
+ ///
+ ///
+ public void setStrDevName(string strname)
+ {
+ Array.Clear(pDeviceName, 0, Len_DevName);
+ byte[] mData = UtilCover.stringToBytes(strname, Len_DevName);
+ Array.Copy(mData, pDeviceName, mData.Length);
+ }
+
+ public void devProvisionCopy(DeviceProvision devp)
+ {
+ pDeviceID = devp.pDeviceID;
+ pMachineID = devp.pMachineID;
+ Array.Copy(devp.pDeviceName, pDeviceName, Len_DevName);
+ Array.Copy(devp.pFirmwareVer, pFirmwareVer, 2);
+ //no copy the device name
+ Array.Copy(devp.pDevSNONumber, pDevSNONumber, DefaultSerialNumberLen);
+ }
+
+ }
+
+ public enum Device_AccesType
+ {
+ Device_Lan = 100,
+ Device_AP = 101,
+ Device_Com = 102
+ };
+
+ public class RouterInfo
+ {
+ public string RouterAddr { get; set; } //IP
+ public string RouterMac { get; set; }
+ private Device_AccesType RouterType;
+
+ public Device_AccesType RouterStyle
+ {
+ get { return RouterType; }
+ set { RouterType = value; }
+ }
+ public RouterInfo()
+ {
+ RouterStyle = Device_AccesType.Device_Lan;
+ }
+
+ };
+
+ public class CDeviceInfo
+ {
+
+ public Module_Type devModuleType;
+ public string noteTxt { get; set; }
+
+ public DeviceProvision devProv; //contain appID,devid
+ public Point DevPoint;//Device point
+ public int lineIndex { get; set; } //for CL-4 device
+
+
+ public bool iIsReady { get; set; } //preserved
+ public int workedHours { get; set; } //preserved
+ public int burnedCount { get; set; } //preserved
+
+ #region for preserved used...
+ public UInt16 DeviceID { get; set; } //preserved
+ public UInt16 AppID { get; set; } //preserved
+ public string strDevName { get; set; } //preserved
+ public string iFirmwareVersion { get; set; } //preserved
+ #endregion
+
+
+
+
+ ///
+ /// device is comserial or lan interface
+ ///
+ public Device_AccesType routerStyle { get; set; }
+
+
+ public CDeviceInfo()
+ {
+ routerStyle = Device_AccesType.Device_Lan;
+ devProv = new DeviceProvision();
+ devProv.pDeviceID = 0x1000;
+ devProv.setStrDevName("Device");
+
+
+ }
+
+ public string getDevInfo()
+ {
+ string devstr = string.Format("App ID:{0} Device ID:{1} Device Name:{2}",
+ devProv.pMachineID.ToString("X2"), devProv.pDeviceID.ToString("X2"), devProv.strDevName);
+ return devstr;
+ }
+
+ public void copyDevinfo(CDeviceInfo devf)
+ {
+ if (devf != null && devf.devModuleType == devModuleType)
+ {
+ devProv.devProvisionCopy(devf.devProv);
+ DevPoint = devf.DevPoint;//device position
+ noteTxt = devf.noteTxt; //note text or not
+ lineIndex = devf.lineIndex; //lineindex
+ workedHours = devf.workedHours;
+ burnedCount = devf.burnedCount;
+ iFirmwareVersion = devf.iFirmwareVersion;
+
+ }
+
+ }
+
+ public void printDevInfo()
+ {
+ StringBuilder strb = new StringBuilder();
+ strb.AppendFormat("device moduletype is : {0}", devModuleType);
+ strb.AppendFormat(" deviceName: {0}", devProv.pDeviceName);
+ strb.AppendFormat(" machineID: {0}", devProv.pMachineID);
+ strb.AppendFormat(" deviceID: {0}", devProv.pDeviceID);
+ strb.AppendFormat(" module point: {0}", DevPoint);
+
+ Debug.WriteLine(strb.ToString());
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/CDeviceInfo.cs~RF59738a9.TMP b/CommLibrary/CommLibrary/CDeviceInfo.cs~RF59738a9.TMP
new file mode 100644
index 0000000..1c3669c
--- /dev/null
+++ b/CommLibrary/CommLibrary/CDeviceInfo.cs~RF59738a9.TMP
@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: CDeviceInfo
+ *版本号: V1.0.0.0
+ *唯一标识:8ecf212b-17ad-43fd-946f-cf7fe131a1b2
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/8/2016 8:47:05 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/8/2016 8:47:05 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+
+ public class cPortInfo //connected port information
+ {
+ byte portindex;
+ byte portType; //port in,port out,text port,rd port etc.
+ bool isHasJoined;
+ public cPortInfo()
+ {
+
+ }
+
+ }
+
+
+ public enum Module_Type
+ {
+ Mod_CLIV = 100, //cl-4
+ Mod_LAN = 101, //lan interface
+ Mod_DLM808 = 102,//dlm808
+ Mod_MAVIII = 103,//matrxiA8
+ Mod_RVC200 = 104,//rvc200
+ Mod_RIO100 = 105,//rio100
+ Mod_RPM100 = 106,//rpm100
+ Mod_TxtLft = 107,//textleft
+ Mod_TxtRht = 108,//text right
+ }
+
+
+ public enum SPecial_DevID
+ {
+ DevID_LTXT = 0x5000,
+ DevID_RTXT = 0x5001,
+ DevID_LanRouter = 0x5002,
+ DevID_CLIV = 0x5003,
+ //--------------------
+ DevID_Normal = 0x1000,
+ }
+
+ public class DeviceProvision
+ {
+ public const int DefaultSerialNumberLen = 5;
+ public const int Len_FirmVer = 2;
+ public int pMachineID; //also name appID
+ public int pDeviceID;
+ public string pDeviceName { get; set; }
+ public byte[] pFirmwareVer;//mcu,dsp ver each one byte
+ public byte[] pDevSNONumber; //DeviceserialNumber
+
+
+ public DeviceProvision()
+ {
+ pDeviceID = 0;
+ pMachineID = 0;
+ pDeviceName = string.Empty;
+ pDevSNONumber = new byte[DefaultSerialNumberLen];
+ pFirmwareVer = new byte[Len_FirmVer];
+
+ }
+
+ public void devProvisionCopy(DeviceProvision devp)
+ {
+ pDeviceID = devp.pDeviceID;
+ pMachineID = devp.pMachineID;
+ Array.Copy(devp.pFirmwareVer, pFirmwareVer, 2);
+ pFirmwareVer=devp.
+ //no copy the device name
+ Array.Copy(devp.pDevSNONumber, pDevSNONumber, DefaultSerialNumberLen);
+ }
+
+ }
+
+ public enum Device_AccesType
+ {
+ Device_Lan = 100,
+ Device_AP = 101,
+ Device_Com = 102
+ };
+
+ public class RouterInfo
+ {
+ public string RouterAddr { get; set; } //IP
+ public string RouterMac { get; set; }
+ private Device_AccesType RouterType;
+
+ public Device_AccesType RouterStyle
+ {
+ get { return RouterType; }
+ set { RouterType = value; }
+ }
+ public RouterInfo()
+ {
+ RouterStyle = Device_AccesType.Device_Lan;
+ }
+
+ };
+
+ public class CDeviceInfo
+ {
+
+ public Module_Type devModuleType;
+ public string noteTxt { get; set; }
+
+ public DeviceProvision devProv; //contain appID,devid
+ public Point DevPoint;//Device point
+ public int lineIndex { get; set; } //for CL-4 device
+
+ public string iFirmwareVersion { get; set; } //preserved
+ public bool iIsReady { get; set; } //preserved
+ public int workedHours { get; set; } //preserved
+ public int burnedCount { get; set; } //preserved
+
+ ///
+ /// device is comserial or lan interface
+ ///
+ public Device_AccesType routerStyle { get; set; }
+
+
+ public CDeviceInfo()
+ {
+ routerStyle = Device_AccesType.Device_Lan;
+ devProv = new DeviceProvision();
+ devProv.pDeviceID = 0x1000;
+ devProv.pDeviceName = "Device";
+
+
+ }
+
+ public string getDevInfo()
+ {
+ string devstr = string.Format("App ID:{0} Device ID:{1} Device Name:{2}",
+ devProv.pMachineID.ToString("X2"), devProv.pDeviceID.ToString("X2"), devProv.pDeviceName);
+ return devstr;
+ }
+
+ public void copyDevinfo(CDeviceInfo devf)
+ {
+ if (devf != null && devf.devModuleType == devModuleType)
+ {
+ devProv.devProvisionCopy(devf.devProv);
+ DevPoint = devf.DevPoint;//device position
+ noteTxt = devf.noteTxt; //note text or not
+ lineIndex = devf.lineIndex; //lineindex
+ workedHours = devf.workedHours;
+ burnedCount = devf.burnedCount;
+ iFirmwareVersion = devf.iFirmwareVersion;
+
+ }
+
+ }
+
+ public void printDevInfo()
+ {
+ StringBuilder strb = new StringBuilder();
+ strb.AppendFormat("device moduletype is : {0}", devModuleType);
+ strb.AppendFormat(" deviceName: {0}", devProv.pDeviceName);
+ strb.AppendFormat(" machineID: {0}", devProv.pMachineID);
+ strb.AppendFormat(" deviceID: {0}", devProv.pDeviceID);
+ strb.AppendFormat(" module point: {0}", DevPoint);
+
+ Debug.WriteLine(strb.ToString());
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/CDeviceInfo.cs~RF9da391.TMP b/CommLibrary/CommLibrary/CDeviceInfo.cs~RF9da391.TMP
new file mode 100644
index 0000000..27a0e95
--- /dev/null
+++ b/CommLibrary/CommLibrary/CDeviceInfo.cs~RF9da391.TMP
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: CDeviceInfo
+ *版本号: V1.0.0.0
+ *唯一标识:8ecf212b-17ad-43fd-946f-cf7fe131a1b2
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/8/2016 8:47:05 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/8/2016 8:47:05 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+
+ public class DeviceProvision
+ {
+ public const int DefaultSerialNumberLen = 5;
+
+ public int pDeviceID;
+ public int pMachineID;
+ public byte[] pDeviceNumber; //DeviceserialNumber
+
+ public DeviceProvision()
+ {
+ pDeviceID = 0;
+ pMachineID = 0;
+ pDeviceNumber = new byte[DefaultSerialNumberLen];
+ }
+
+ public void devProvisionCopy(DeviceProvision devp)
+ {
+ pDeviceID = devp.pDeviceID;
+ pMachineID = devp.pMachineID;
+ Array.Copy(devp.pDeviceNumber, pDeviceNumber, DefaultSerialNumberLen);
+
+ }
+ }
+
+ public enum Device_AccesType
+ {
+ Device_Lan = 100,
+ Device_AP = 101,
+ Device_Com = 102
+ };
+
+ public class RouterInfo
+ {
+ public string RouterAddr { get; set; } //IP
+ public string RouterMac { get; set; }
+ private Device_AccesType RouterType;
+
+ public Device_AccesType RouterStyle
+ {
+ get { return RouterType; }
+ set { RouterType = value; }
+ }
+ public RouterInfo()
+ {
+ RouterStyle = Device_AccesType.Device_Lan;
+ }
+
+ };
+
+ public class CDeviceInfo
+ {
+
+
+ public string iDeviceName { get; set; }
+ public int iAppID { get; set; }
+ public int iDeviceID { get; set; }
+ public string iFirmwareVersion { get; set; }
+ public bool iIsReady { get; set; }
+ public int workedHours { get; set; }
+ public int burnedCount { get; set; }
+
+ private Device_AccesType routerType;
+
+ public Device_AccesType routerStyle
+ {
+ get { return routerType; }
+ set { routerType = value; }
+ }
+ public CDeviceInfo()
+ {
+ routerStyle = Device_AccesType.Device_Lan;
+ }
+
+ public string getDevInfo()
+ {
+ string devstr = string.Format("App ID:{0} Device ID:{1} Device Name:{2}",
+ iAppID.ToString("X2"), iDeviceID.ToString("X2"), iDeviceName);
+ return devstr;
+
+
+ }
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/CMessageTranser.cs b/CommLibrary/CommLibrary/CMessageTranser.cs
new file mode 100644
index 0000000..aa00d8f
--- /dev/null
+++ b/CommLibrary/CommLibrary/CMessageTranser.cs
@@ -0,0 +1,366 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Input;
+using CommLibrary;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MSTest
+ *文件名: CMessageTranser
+ *版本号: V1.0.0.0
+ *唯一标识:0ff5d35f-0825-4657-b621-05e1b0d5615d
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:8/18/2016 2:31:45 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:8/18/2016 2:31:45 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ ///
+ /// CMessageReceiver devine
+ ///
+ public class MessageReceiver
+ {
+
+ #region Const
+ private const int ERROR_CLASS_ALREADY_EXISTS = 1410;
+ #endregion
+ #region Delegate
+ delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
+ #endregion
+
+ #region Struct
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ struct WNDCLASS
+ {
+ public uint style;
+ public WndProcDelegate lpfnWndProc; //williamxia modify
+ public int cbClsExtra;
+ public int cbWndExtra;
+ public IntPtr hInstance;
+ public IntPtr hIcon;
+ public IntPtr hCursor;
+ public IntPtr hbrBackground;
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string lpszMenuName;
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string lpszClassName;
+ }
+ #endregion
+
+ #region DllImport......begin
+ ///
+ /// Registers the class W.
+ ///
+ /// The lp WND class.
+ ///
+ [DllImport("user32.dll", SetLastError = true)]
+ static extern UInt16 RegisterClassW(
+ [In] ref WNDCLASS lpWndClass
+ );
+
+ ///
+ /// Creates the window ex W.
+ ///
+ /// The dw ex style.
+ /// Name of the lp class.
+ /// Name of the lp window.
+ /// The dw style.
+ /// The x.
+ /// The y.
+ /// Width of the n.
+ /// Height of the n.
+ /// The h WND parent.
+ /// The h menu.
+ /// The h instance.
+ /// The lp param.
+ ///
+ [DllImport("user32.dll", SetLastError = true)]
+ static extern IntPtr CreateWindowExW(
+ UInt32 dwExStyle,
+ [MarshalAs(UnmanagedType.LPWStr)]
+ string lpClassName,
+ [MarshalAs(UnmanagedType.LPWStr)]
+ string lpWindowName,
+ UInt32 dwStyle,
+ Int32 x,
+ Int32 y,
+ Int32 nWidth,
+ Int32 nHeight,
+ IntPtr hWndParent,
+ IntPtr hMenu,
+ IntPtr hInstance,
+ IntPtr lpParam
+ );
+
+ ///
+ /// Defs the window proc W.
+ ///
+ /// The h WND.
+ /// The MSG.
+ /// The w param.
+ /// The l param.
+ ///
+ [DllImport("user32.dll", SetLastError = true)]
+ static extern IntPtr DefWindowProcW(
+ IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam
+ );
+
+ ///
+ /// Destroys the window.
+ ///
+ /// The h WND.
+ ///
+ [DllImport("user32.dll", SetLastError = true)]
+ static extern bool DestroyWindow(
+ IntPtr hWnd
+ );
+ #endregion
+
+
+
+
+ #region Static Var
+ private static Dictionary _receiverPool;
+ #endregion
+
+
+ #region Private Static Property
+ ///
+ /// Gets the m_ receiver pool.
+ ///
+ ///
+ /// The m_ receiver pool. the prperty of _receiverPool
+ ///
+ public static Dictionary m_ReceiverPool
+ {
+ get
+ {
+ return _receiverPool ?? (_receiverPool = new Dictionary());
+ }
+ }
+ #endregion
+
+
+ #region Private Property
+ ///
+ /// Gets or sets a value indicating whether [m_ disposed].
+ ///
+ ///
+ /// true if [m_ disposed]; otherwise, false.
+ ///
+ private bool m_Disposed { get; set; }
+
+ ///
+ /// Gets or sets the M_HWND.
+ ///
+ ///
+ /// The M_HWND.
+ ///
+ private IntPtr m_Hwnd { get; set; }
+ #endregion
+
+ #region Event
+ public event EventHandler WndProc;
+ #endregion
+
+
+ #region Constructor
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Name of the class.
+ /// The title.
+ /// Could not register window class
+ ///
+
+ WNDCLASS wndClass = new WNDCLASS();
+
+ public MessageReceiver(string className, string title)
+ {
+ if (string.IsNullOrEmpty(className))
+ className = Guid.NewGuid().ToString();
+
+ // Create WNDCLASS struct
+ // 111
+ //{
+ wndClass.lpszClassName = className;
+ wndClass.lpfnWndProc = CustomWndProc;
+ //};
+
+
+
+ UInt16 class_atom = RegisterClassW(ref wndClass); //registerClassW
+
+ int last_error = Marshal.GetLastWin32Error();
+
+ if (class_atom == 0 && last_error != ERROR_CLASS_ALREADY_EXISTS)
+ {
+ throw new System.Exception("Could not register window class");
+ }
+
+ // Create window
+ m_Hwnd = CreateWindowExW(
+ 0,
+ className,
+ title,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ IntPtr.Zero
+ );
+
+ if (m_Hwnd == IntPtr.Zero)
+ return;
+
+ m_ReceiverPool[m_Hwnd] = this;
+ }
+ #endregion
+
+
+ #region Private Static Method
+ ///
+ /// Customs the WND proc.
+ ///
+ /// The h WND.
+ /// The MSG.
+ /// The w param.
+ /// The l param.
+ ///
+ private static IntPtr CustomWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
+ {
+ if (m_ReceiverPool.ContainsKey(hWnd))
+ m_ReceiverPool[hWnd].OnWndProc(new MessageEventArgs(msg, wParam, lParam));
+
+ return DefWindowProcW(hWnd, msg, wParam, lParam);
+ }
+ #endregion
+
+
+ #region Private Method
+ private void Dispose(bool disposing)
+ {
+ if (!m_Disposed)
+ {
+ if (disposing)
+ {
+ // Dispose managed resources
+ }
+
+ // Dispose unmanaged resources
+ if (m_Hwnd != IntPtr.Zero)
+ {
+ m_ReceiverPool.Remove(m_Hwnd);
+ DestroyWindow(m_Hwnd);
+ m_Hwnd = IntPtr.Zero;
+ }
+ m_Disposed = true;
+ }
+ }
+ #endregion
+
+
+ #region Protected Method
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
+ protected void OnWndProc(MessageEventArgs e)
+ {
+ if (WndProc == null)
+ return;
+ WndProc(this, e);
+ }
+ #endregion
+
+
+ #region Public Method
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose() //显示调用回收资源处理
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ #endregion
+ }
+
+
+ ///
+ /// MessageEventArgs registry-------------
+ ///
+ public class MessageEventArgs
+ {
+ #region Property
+ public uint Message { get; set; }
+ public IntPtr wParam { get; set; }
+ public IntPtr lParam { get; set; }
+ #endregion
+
+ #region Constructor
+ public MessageEventArgs(uint message, IntPtr wparam, IntPtr lparam)
+ {
+ Message = message;
+ wParam = wparam;
+ lParam = lparam;
+ }
+ #endregion
+ }
+
+ ///
+ /// Message sender class
+ ///
+ public class MessageHelper
+ {
+
+ // [DllImport("user32.dll", SetLastError = true)]
+ [DllImport("User32.dll", EntryPoint = "FindWindowEx")]
+ //findwindow 第一个是class,第二个是窗口标题
+ public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChild, string lpClassName, string lpWindowName);
+
+ [DllImport("User32.dll", EntryPoint = "FindWindow",CharSet=CharSet.Auto)]
+ //findwindow 第一个是class,第二个是窗口标题
+ public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+
+ [DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)]
+ public static extern int SendMessage(IntPtr wnd, int msg, IntPtr wP, IntPtr lP);
+
+ [DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)]
+ public static extern int SendMessage(IntPtr wnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lparam);
+
+
+ [DllImport("User32.dll", EntryPoint = "PostMessage", CharSet = CharSet.Auto)]
+ public static extern int PostMessage(IntPtr wnd, int msg, IntPtr wP, IntPtr lP);
+
+
+
+ }
+
+}
diff --git a/CommLibrary/CommLibrary/CommConst.cs b/CommLibrary/CommLibrary/CommConst.cs
new file mode 100644
index 0000000..128c920
--- /dev/null
+++ b/CommLibrary/CommLibrary/CommConst.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:CommLibrary
+ *文件名: CommConstraint
+ *版本号: V1.0.0.0
+ *唯一标识:fbd630cf-dfe8-4e67-81c6-1ae5d627c835
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:11/28/2016 8:22:29 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:11/28/2016 8:22:29 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class CommConst
+ {
+ public const int UTRAL_H0 = 0x01;
+ public const int UTRAL_H1 = 0x20;
+ public const int UTRAL_H2 = 0x03;
+ public const int UTRAL_End = 0x40;
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/CommLibrary.csproj b/CommLibrary/CommLibrary/CommLibrary.csproj
new file mode 100644
index 0000000..d18c692
--- /dev/null
+++ b/CommLibrary/CommLibrary/CommLibrary.csproj
@@ -0,0 +1,88 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {DF646D67-5F08-464A-A026-79037E032EAD}
+ Library
+ Properties
+ CommLibrary
+ CommLibrary
+ v4.5
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WScanForm.xaml
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
\ No newline at end of file
diff --git a/CommLibrary/CommLibrary/CommLibrary.csproj.user b/CommLibrary/CommLibrary/CommLibrary.csproj.user
new file mode 100644
index 0000000..a4a6cdf
--- /dev/null
+++ b/CommLibrary/CommLibrary/CommLibrary.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ ProjectFiles
+
+
\ No newline at end of file
diff --git a/CommLibrary/CommLibrary/CommuteStatus.cs b/CommLibrary/CommLibrary/CommuteStatus.cs
new file mode 100644
index 0000000..76ca4a1
--- /dev/null
+++ b/CommLibrary/CommLibrary/CommuteStatus.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2017 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixSystemEditor
+ *文件名: CommuteStatus
+ *版本号: V1.0.0.0
+ *唯一标识:ae864e70-dc83-46d9-ba52-09b45a647624
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:1/3/2017 1:55:23 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:1/3/2017 1:55:23 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+
+ public class ACK_Status
+ {
+ public const int M_ConectedNormal =0; //after connected
+ public const int M_ConNormalDetect = 99; //normal
+ public const int M_Disconnected = 100; //disconnect
+
+ public const int Max_Status_Counter = 150;
+
+ }
+
+ public class CommunicateStatus
+ {
+ public CommunicateStatus()
+ {
+ commuteStatus = ACK_Status.M_Disconnected;
+ responseAckCounter = 1;
+ }
+ public int commuteStatus = ACK_Status.M_Disconnected;
+ public int responseAckCounter = 1;
+
+ public void resetComuniStatus()
+ {
+ commuteStatus = ACK_Status.M_ConectedNormal;
+ responseAckCounter = 1;
+
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/CopyDataStructs.cs b/CommLibrary/CommLibrary/CopyDataStructs.cs
new file mode 100644
index 0000000..b20d2b1
--- /dev/null
+++ b/CommLibrary/CommLibrary/CopyDataStructs.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CommLibrary
+{
+ public struct COPYDATASTRUCT
+ {
+ public IntPtr hData;
+ public int dLength;
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string stringData;
+
+ public int preWph;//high
+ public int preWpl;//low
+
+
+
+ public void pringData()
+ {
+ if(hData!=null && dLength>0)
+ {
+ byte[] tmp = new byte[dLength];
+ Marshal.Copy(hData, tmp, 0, dLength);
+
+ string str="structData len:"+dLength.ToString() +" "+BitConverter.ToString(tmp);
+ str += " \n preWh: " + preWph.ToString();
+ str += " \n preWpl " + preWpl.ToString();
+ Console.WriteLine(str);
+
+
+ }
+
+ }
+ ///
+ /// get the bit Array to return
+ ///
+ ///
+ public byte[] getBitAry()
+ {
+
+ byte[] tmp = new byte[dLength];
+ Marshal.Copy(hData, tmp, 0, dLength);
+ return tmp;
+ }
+
+
+
+
+ }
+
+
+}
diff --git a/CommLibrary/CommLibrary/CorprationInfo.cs b/CommLibrary/CommLibrary/CorprationInfo.cs
new file mode 100644
index 0000000..bb99a44
--- /dev/null
+++ b/CommLibrary/CommLibrary/CorprationInfo.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:CommLibrary
+ *文件名: CorprationInfo
+ *版本号: V1.0.0.0
+ *唯一标识:c5334f20-ab6b-4f14-ae7c-23e028359b92
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:12/29/2016 5:07:00 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:12/29/2016 5:07:00 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class CorprationInfo
+ {
+
+ //string ProductName=string.Empty; //such Matrix
+ //string ProductVer; //such as v0.1.1
+ //string corpENName; //such ass Seikaku Technical Group
+ //string corpWebSite; //such as http://www.seikaku.hk
+ public string ProductName { get; set; }
+ public string ProductVer { get; set; }
+ public string corpENName { get; set; }
+ public string corpWebSite { get; set; }
+
+ public CorprationInfo() //initial
+ {
+ ProductName = "Editor system";
+ ProductVer = "V0.1";
+ corpENName = "Seikaku Technical Group";
+ corpWebSite = "http://www.seikaku.hk";
+ }
+ ///
+ ///
+ ///
+ ///
+ public string getProcesTitle()
+ {
+ return string.Format("{0} {1}", ProductName, ProductVer);
+
+ }
+
+ }
+
+}
diff --git a/CommLibrary/CommLibrary/DeviceScaner.cs b/CommLibrary/CommLibrary/DeviceScaner.cs
new file mode 100644
index 0000000..f7b9f1e
--- /dev/null
+++ b/CommLibrary/CommLibrary/DeviceScaner.cs
@@ -0,0 +1,529 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Diagnostics;
+using System.Threading;
+using System.Net;
+using System.Net.Sockets;
+using System.Windows.Threading;
+using System.Collections;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:CommLibrary
+ *文件名: NoVisualScan
+ *版本号: V1.0.0.0
+ *唯一标识:d6d739ae-84c9-43a5-aff1-5e73c4e02653
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/18/2016 4:51:09 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/18/2016 4:51:09 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述: scan in novisual like wscanForm ,but it is in noVisual
+ *
+/************************************************************************************/
+///support udp/comport to scan the device,
+///the last updated date:2016.10.27
+namespace CommLibrary
+{
+ public class DeviceScaner : Object
+ {
+
+ public delegate void onDeviceStopScan(Object sender, EventArgs e);//socket disconnect
+ public event onDeviceStopScan onUDPStopScanEvent;
+ //
+ public delegate void onDeviceBeginScan(Object sender, EventArgs e);//socket disconnect
+ public event onDeviceBeginScan onUDPBeinScanEvent;
+ //
+ public delegate void onDeviceScanChanged(Object sender, RouterInfo rpinfo, EventArgs e);//socket disconnect
+ public event onDeviceScanChanged onScanChangedEvent;
+
+ public bool hasStopScan { get; set; }
+ ///
+ /// udpSocket begin.........................................
+ ///
+ ///
+
+ public bool isSupportUSB
+ {
+ get;
+ set;
+ }
+
+ private ScanThreader thread_IP210Receive; //IP210
+ private ScanThreader thread_IP210Sender; //IP210
+ private Socket udpSock_IP210;
+ private EndPoint remotePoint_IP210;
+
+ private const int Port_IP210 = 8000;
+ //HAF11 --module
+ private ScanThreader thread_HAF11Receive;
+ private ScanThreader thread_HAF11Sender;
+ private Socket udpSock_HAF11;
+ private const string Chek_CMD_HF11 = "HF-A11ASSISTHREAD";
+ private const int Port_HAF11 = 48899;
+ private EndPoint remotePoint_HAF11;
+ //
+ private const int Send_Delay = 50;
+ private string localIP;
+ public List scanedIpList = new List();
+
+ public bool DoReceiveFlag = false;
+ public int delayMills = 4;
+
+ private DispatcherTimer timer;
+
+ public int indexOfScanedIP(String strIP)
+ {
+ int result = -1;
+ if (strIP.Trim().Length < 1 || scanedIpList.Count < 1)
+ result = -1;
+ result = scanedIpList.FindIndex(r => r.RouterAddr.Equals(strIP));
+ return result;
+ }
+
+ public DeviceScaner()
+ {
+ try
+ {
+ initParameters();
+ isLoadedFailure = false;
+ isSupportUSB = false;
+ }
+ catch (Exception e)
+ {
+ isLoadedFailure = true;
+ Debug.WriteLine("load socket failure....................");
+ }
+
+ }
+
+ public bool isLoadedFailure = false;
+ public int DelayMills
+ {
+ get;
+ set;
+ }
+ public const int SCAN_DES = 3;
+
+ private void initSocket()
+ {
+ initIP210();
+ initHAF11();
+ }
+ public void initParameters()
+ {
+ hasStopScan = true;
+ initSocket();
+ localIP = IPProces.getIPAddress();//localIP;;
+ //-------------------------------
+ timer = new DispatcherTimer();
+ timer.Tick += timer_Tick;
+ timer.Interval = new TimeSpan(0, 0, SCAN_DES);
+ timer.Stop();
+ //ip210
+ thread_IP210Receive.DoSomethingEvent += new ScanThreader.threadDosomething(scanThread_IP210Receive);
+ thread_IP210Sender.DoSomethingEvent += new ScanThreader.threadDosomething(scanthread_ip210sender);
+ //haf11
+ thread_HAF11Receive.DoSomethingEvent += new ScanThreader.threadDosomething(scanThread_HFA11Receive);
+ thread_HAF11Sender.DoSomethingEvent += new ScanThreader.threadDosomething(scanthread_HAF11sender);
+
+ }
+
+ private void timer_Tick(object sender, EventArgs e)
+ {
+ Debug.WriteLine("timer_tick gogogog1");
+ stopScan();
+
+ }
+ public void stopScan()
+ {
+ if (!hasStopScan)
+ {
+ Debug.WriteLine("close socket and stopscan....................");
+
+ DoReceiveFlag = false;
+ if (thread_IP210Receive != null)
+ thread_IP210Receive.Stop();
+
+ if (thread_IP210Sender != null)
+ thread_IP210Sender.Stop();
+
+ if (thread_HAF11Sender != null)
+ thread_HAF11Sender.Stop();
+ if (thread_HAF11Receive != null)
+ thread_HAF11Receive.Stop();
+
+ hasStopScan = true;
+ if (timer != null)
+ timer.Stop();
+ resetRemotPoint();
+
+ Thread.Sleep(100);
+ if (onUDPStopScanEvent != null)
+ {
+ onUDPStopScanEvent(this, new EventArgs());
+
+ }
+ }
+ else
+ {
+
+ // Debug.WriteLine("stopscan is false so no need to close xxxx....................");
+ }
+
+ }
+
+ ///
+ ///
+ ///
+
+
+ public void resetRemotPoint()
+ {
+ //remote
+ IPEndPoint ipep = new IPEndPoint(IPAddress.Broadcast, Port_IP210);
+ remotePoint_IP210 = (EndPoint)(ipep);
+ //remote
+ ipep = new IPEndPoint(IPAddress.Broadcast, Port_HAF11);
+ remotePoint_HAF11 = (EndPoint)(ipep);
+ }
+
+ #region IP210 module define
+ ///
+ /// initIP210 module about
+ ///
+ public void initIP210()
+ {
+
+ udpSock_IP210 = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+ // udpSock_IP210.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+ udpSock_IP210.Blocking = false;
+
+
+
+ thread_IP210Sender = new ScanThreader();
+ thread_IP210Receive = new ScanThreader();
+ localIP = IPProces.getIPAddress();//localIP;
+
+
+ IPEndPoint ipLocalPoint = new IPEndPoint(IPAddress.Any, Port_IP210 - 1);
+ udpSock_IP210.Bind(ipLocalPoint);
+ udpSock_IP210.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
+ //remote
+ IPEndPoint ipep = new IPEndPoint(IPAddress.Broadcast, Port_IP210);
+ remotePoint_IP210 = (EndPoint)(ipep);
+
+ }
+ public void sendIP210()
+ {
+ try
+ {
+ if (udpSock_IP210 != null)
+ {
+ byte[] data_IP210 = { 0x01, 0x02, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF };
+ udpSock_IP210.SendTo(data_IP210, data_IP210.Length, SocketFlags.None, remotePoint_IP210);
+ // string strIP = string.Format("send ip210 udp socket send ip:{0} ", udpSock_IP210.ToString());
+ // Debug.WriteLine(strIP);
+ }
+ }
+ catch
+ {
+
+ }
+
+ }
+
+ public void udpRecive_IP210()
+ {
+
+ byte[] data = new byte[1024];
+ string strIP;
+ while (DoReceiveFlag)
+ {
+
+ if (udpSock_IP210 == null || udpSock_IP210.Available < 1)
+ {
+ Thread.Sleep(delayMills + 10);
+ continue;
+ }
+
+
+ // Debug.WriteLine("IP 210 receiver wake now...............");
+ int rlen = udpSock_IP210.ReceiveFrom(data, ref remotePoint_IP210);
+ byte[] kb = new byte[rlen + 1];
+ Array.Copy(data, kb, rlen);
+ IPProces.printAryByte("IP210 data receive ", kb);
+ strIP = remotePoint_IP210.ToString();
+ // string strIPN = "IP210 reciev.... " + strIP + " data: " + BitConverter.ToString(data);
+ // IPProces.printAryByte("thread receive-- ", data, rlen);
+ addToNewIP(strIP, Device_AccesType.Device_Lan);
+ }
+
+ }
+ #endregion
+ //-------------------------------
+ #region HAF11 module
+ public void initHAF11()
+ {
+ //
+
+ udpSock_HAF11 = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+ // udpSock_HAF11.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+ udpSock_HAF11.Blocking = false;
+
+
+ thread_HAF11Sender = new ScanThreader();
+ thread_HAF11Receive = new ScanThreader();
+
+
+ IPEndPoint ipLocalPoint = new IPEndPoint(IPAddress.Any, Port_HAF11); //- 1
+ udpSock_HAF11.Bind(ipLocalPoint);
+ udpSock_HAF11.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
+ //remote
+ IPEndPoint ipep = new IPEndPoint(IPAddress.Broadcast, Port_HAF11);
+ remotePoint_HAF11 = (EndPoint)(ipep);
+
+ }
+ ///
+ /// sendHAF11
+ ///
+ public void sendHAF11()
+ {
+ try
+ {
+ if (udpSock_HAF11 != null)
+ {
+ //Chek_CMD_HF11
+ byte[] data_HF11 = System.Text.Encoding.ASCII.GetBytes(Chek_CMD_HF11);
+ udpSock_HAF11.SendTo(data_HF11, data_HF11.Length, SocketFlags.None, remotePoint_HAF11);
+ string strIP = string.Format("send haf11 udp socket send ip:{0} ", data_HF11);
+ Debug.WriteLine(strIP);
+ }
+ else
+ {
+ Debug.WriteLine("send haf11 ,but is udpsock haff11 is null........");
+
+ }
+ }
+ catch
+ {
+
+ }
+ }
+
+ //receive HAF11
+ public void udpRecive_HAF11()
+ {
+
+ byte[] data = new byte[1024];
+ string strIP;
+ // Debug.WriteLine("Haf11 receive begin.........................{0}",DoReceiveFlag);
+ while (DoReceiveFlag)
+ {
+
+ if (udpSock_HAF11 == null || udpSock_HAF11.Available < 1)
+ {
+ Thread.Sleep(delayMills);
+ // Debug.WriteLine("no condition in haf11.........................");
+ continue;
+ }
+
+ //Debug.WriteLine("haf11 wake now...............");
+ int rlen = udpSock_HAF11.ReceiveFrom(data, ref remotePoint_HAF11);
+ byte[] kb = new byte[rlen + 1];
+ Array.Copy(data, kb, rlen);
+ IPProces.printAryByte("haf11 data receive ", kb);
+ strIP = remotePoint_HAF11.ToString();
+ addToNewIP(strIP, Device_AccesType.Device_AP);
+
+ // string strIPN = "HAF11 reciev.... " + strIP + " data: " + BitConverter.ToString(data);
+ // Debug.WriteLine(strIPN);
+
+ }
+
+
+
+
+ }
+ #endregion
+
+ public bool isExistAddr(string strIP)
+ {
+ bool isExist = false;
+ foreach (RouterInfo rp in scanedIpList)
+ {
+ // Debug.WriteLine("compare ip is : " + strTemp+" with iP: "+strIP);
+ if (string.Compare(rp.RouterAddr, strIP) == 0)
+ {
+ isExist = true;
+ break;
+ }
+ }
+ return isExist;
+
+ }
+ //-------------------------
+ public void addToNewIP(string strIP, Device_AccesType routerType)
+ {
+
+ string tmpIP = strIP.Trim();
+
+ if (routerType != Device_AccesType.Device_Com)
+ tmpIP = tmpIP.Substring(0, tmpIP.IndexOf(":"));
+
+ Debug.WriteLine("now.........add to new IP is :" + tmpIP);
+
+ if ((tmpIP.Length < 1) || (tmpIP == localIP) || isExistAddr(tmpIP)) return;
+
+ RouterInfo iRP = new RouterInfo();
+ iRP.RouterStyle = routerType;
+ if (routerType == Device_AccesType.Device_Com)
+ iRP.RouterMac = "FF-FF-FF-FF-FF-FF";
+ else //ip condition,state
+ iRP.RouterMac = IPProces.getMac(tmpIP);
+
+ iRP.RouterAddr = tmpIP;
+
+ scanedIpList.Add(iRP);
+ // Debug.WriteLine("tedected ip is : " + tmpIP);
+
+ if (onScanChangedEvent != null)
+ {
+ onScanChangedEvent(this, iRP, new EventArgs());
+ }
+
+
+ }
+ public static string ProficUSB = "Prolific USB";//PL2303
+ //-------------------------------------------------------------------------------------------------
+ public void startScan()
+ {
+ scanedIpList.Clear();
+
+ hasStopScan = false;
+ DoReceiveFlag = true;
+ thread_IP210Receive.Start();
+ thread_IP210Sender.Start();
+
+ thread_HAF11Receive.Start();
+ thread_HAF11Sender.Start();
+
+ timer.Start();
+ if (onUDPBeinScanEvent != null)
+ {
+ onUDPBeinScanEvent(this, new EventArgs());
+
+ }
+ if (isSupportUSB)
+ {
+ string comList = ComCilent.listUsbPort(ProficUSB);
+ if (comList != null && comList.Trim().Length > 3)
+ addToNewIP(comList, Device_AccesType.Device_Com);
+ ////serialport scan below
+ //string[] comList = ComCilent.listUsbPort();
+ //for (int i = 0; i < comList.Length; i++)
+ //{
+ // addToNewIP(comList[i], Device_AccesType.Device_Com);
+
+ //}
+ }
+
+ }
+
+
+
+ ///
+ /// event define..
+ ///
+ ///
+ ///
+ private void scanThread_IP210Receive(object sender, EventArgs e)
+ {
+ udpRecive_IP210();
+ Debug.WriteLine("scan thread IP210 receive now...");
+
+ }
+
+ private void scanthread_ip210sender(object sender, EventArgs e)
+ {
+ if (DoReceiveFlag)
+ sendIP210();
+ Debug.WriteLine("scan thread IP210 sender now...");
+
+ }
+
+ private void scanThread_HFA11Receive(object sender, EventArgs e)
+ {
+ Debug.WriteLine("scan thread hfa11 recevie now.....");
+ udpRecive_HAF11();
+
+
+ }
+
+ private void scanthread_HAF11sender(object sender, EventArgs e)
+ {
+ if (DoReceiveFlag)
+ sendHAF11();
+ Debug.WriteLine("scan thread haff11 sender now...");
+
+ }
+ //---------------------------
+
+ public void clearSocket() //when it close
+ {
+ DoReceiveFlag = false;
+ if (udpSock_IP210 != null)
+ udpSock_IP210.Shutdown(SocketShutdown.Both);
+
+ if (thread_IP210Receive != null)
+ thread_IP210Receive.Stop();
+
+ if (thread_IP210Sender != null)
+ thread_IP210Sender.Stop();
+
+ if (udpSock_IP210 != null)
+ udpSock_IP210.Close();
+
+ //
+ if (udpSock_HAF11 != null)
+ udpSock_HAF11.Shutdown(SocketShutdown.Both);
+
+
+ if (thread_HAF11Sender != null)
+ thread_HAF11Sender.Stop();
+
+ if (thread_HAF11Receive != null)
+ thread_HAF11Receive.Stop();
+
+ if (udpSock_HAF11 != null)
+ udpSock_HAF11.Close();
+ hasStopScan = true;
+ if (timer != null)
+ timer.Stop();
+ // GC.Collect();
+ }
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/IOBinaryOperation.cs b/CommLibrary/CommLibrary/IOBinaryOperation.cs
new file mode 100644
index 0000000..b9e0e8c
--- /dev/null
+++ b/CommLibrary/CommLibrary/IOBinaryOperation.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:SaveOpenDialog
+ *文件名: IOBinaryOperation
+ *版本号: V1.0.0.0
+ *唯一标识:e8fa87f2-841a-42ec-848d-7a92dddb68fb
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:8/24/2016 3:11:42 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:8/24/2016 3:11:42 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class IOBinaryOperation
+ {
+
+
+ public const int FILE_MAX_LEN = 1024;
+ public static int calcDataSegments_fromFileLen(int fileLen)
+ {
+ int res = 0;
+ int ch = fileLen / FILE_MAX_LEN;
+ int cl = fileLen % FILE_MAX_LEN;
+
+ if (cl == 0)
+ res = ch;
+ else
+ {
+ res = (ch + 1);
+ }
+
+ return res;
+
+ }
+
+ public static long fileLength(string filePath)
+ {
+ long mlen = 0;
+
+ if(File.Exists(filePath))
+ {
+
+ FileInfo mfile = new FileInfo(filePath);
+ mlen = mfile.Length;
+ }
+ else
+ {
+ return 0;
+ }
+
+
+ return mlen;
+ }
+
+ //----------------------------------------
+ ///
+ /// readBinar from file
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static byte[] readBinaryFile(string strPath, int len)
+ {
+ byte[] dest = new byte[len];
+
+
+ if (string.IsNullOrEmpty(strPath.Trim()))
+ {
+
+ return dest;
+ }
+
+ if (!File.Exists(strPath)) //Directory.Exists(判断目录是否存在)
+ {
+ Console.WriteLine("file not exist");
+ return dest;
+ }
+
+ try
+ {
+ FileStream mystream = new FileStream(strPath, FileMode.Open, FileAccess.Read);
+ BinaryReader myReader = new BinaryReader(mystream);
+ dest = myReader.ReadBytes(len);
+ // string sk = BitConverter.ToString(dest);
+ // Console.WriteLine("read binary : {0}", sk);
+ myReader.Close();
+ mystream.Close();
+ }
+
+ catch
+ {
+ }
+
+ return dest;
+
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool writeBinaryToFile(string strPath, byte[] wdata)
+ {
+ bool res = false;
+ if (String.IsNullOrEmpty(strPath.Trim()))
+ {
+
+ System.Windows.MessageBox.Show("Please choose the file path");
+ return res;
+ }
+
+ if (wdata == null || wdata.Length < 1)
+ {
+ System.Windows.MessageBox.Show("Empty data");
+ return res;
+ }
+
+ try
+ {
+ FileStream myStream = new FileStream(strPath, FileMode.Create);
+ BinaryWriter myWriter = new BinaryWriter(myStream);
+
+ myWriter.Write(wdata);
+ myWriter.Close();
+ myStream.Close();
+ res = true;
+ // System.Windows.MessageBox.Show("Successful to write to file!");
+ }
+ catch (Exception ex)
+ {
+ res = false;
+ // System.Windows.MessageBox.Show(ex.Message);
+ }
+ return res;
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/IOOperationINI.cs b/CommLibrary/CommLibrary/IOOperationINI.cs
new file mode 100644
index 0000000..48ab32e
--- /dev/null
+++ b/CommLibrary/CommLibrary/IOOperationINI.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: IOOperationINI
+ *版本号: V1.0.0.0
+ *唯一标识:6103e885-48d1-4ef0-b9bf-0916f22c0280
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/13/2016 1:51:06 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/13/2016 1:51:06 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class IOOperationINI
+ {
+
+ public string inipath;
+ [DllImport("kernel32")]
+ private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
+ [DllImport("kernel32")]
+ private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
+ ///
+ /// 构造方法
+ ///
+ /// 文件路径
+ public IOOperationINI(string INIPath)
+ {
+ inipath = INIPath;
+ }
+ ///
+ /// 写入INI文件
+ ///
+ /// 项目名称(如 [TypeName] )
+ /// 键
+ /// 值
+ public void IniWriteValue(string Section, string Key, string Value)
+ {
+ WritePrivateProfileString(Section, Key, Value, this.inipath);
+ }
+ ///
+ /// 读出INI文件
+ ///
+ /// 项目名称(如 [TypeName] )
+ /// 键
+ public string IniReadValue(string Section, string Key)
+ {
+ StringBuilder temp = new StringBuilder(500);
+ int i = GetPrivateProfileString(Section, Key, "", temp, 500, this.inipath);
+ return temp.ToString();
+ }
+ ///
+ /// 验证文件是否存在
+ ///
+ /// 布尔值
+ public bool ExistINIFile()
+ {
+ return File.Exists(inipath);
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/IPAddressExtensions.7z b/CommLibrary/CommLibrary/IPAddressExtensions.7z
new file mode 100644
index 0000000..1a6c80e
Binary files /dev/null and b/CommLibrary/CommLibrary/IPAddressExtensions.7z differ
diff --git a/CommLibrary/CommLibrary/IPAddressExtensions.cs b/CommLibrary/CommLibrary/IPAddressExtensions.cs
new file mode 100644
index 0000000..0959e65
--- /dev/null
+++ b/CommLibrary/CommLibrary/IPAddressExtensions.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Net;
+
+namespace CommLibrary
+{
+ public static class SubnetMask
+ {
+ public static readonly IPAddress ClassA = IPAddress.Parse("255.0.0.0");
+ public static readonly IPAddress ClassB = IPAddress.Parse("255.255.0.0");
+ public static readonly IPAddress ClassC = IPAddress.Parse("255.255.255.0");
+
+ public static IPAddress CreateByHostBitLength(int hostpartLength)
+ {
+ int hostPartLength = hostpartLength;
+ int netPartLength = 32 - hostPartLength;
+
+ if (netPartLength < 2)
+ throw new ArgumentException("Number of hosts is to large for IPv4");
+
+ Byte[] binaryMask = new byte[4];
+
+ for (int i = 0; i < 4; i++)
+ {
+ if (i * 8 + 8 <= netPartLength)
+ binaryMask[i] = (byte)255;
+ else if (i * 8 > netPartLength)
+ binaryMask[i] = (byte)0;
+ else
+ {
+ int oneLength = netPartLength - i * 8;
+ string binaryDigit =
+ String.Empty.PadLeft(oneLength, '1').PadRight(8, '0');
+ binaryMask[i] = Convert.ToByte(binaryDigit, 2);
+ }
+ }
+ return new IPAddress(binaryMask);
+ }
+
+ public static IPAddress CreateByNetBitLength(int netpartLength)
+ {
+ int hostPartLength = 32 - netpartLength;
+ return CreateByHostBitLength(hostPartLength);
+ }
+
+ public static IPAddress CreateByHostNumber(int numberOfHosts)
+ {
+ int maxNumber = numberOfHosts + 1;
+
+ string b = Convert.ToString(maxNumber, 2);
+
+ return CreateByHostBitLength(b.Length);
+ }
+ }
+
+ public static class IPAddressExtensions
+ {
+ public static IPAddress GetBroadcastAddress(this IPAddress address, IPAddress subnetMask)
+ {
+ byte[] ipAdressBytes = address.GetAddressBytes();
+ byte[] subnetMaskBytes = subnetMask.GetAddressBytes();
+
+ if (ipAdressBytes.Length != subnetMaskBytes.Length)
+ throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
+
+ byte[] broadcastAddress = new byte[ipAdressBytes.Length];
+ for (int i = 0; i < broadcastAddress.Length; i++)
+ {
+ broadcastAddress[i] = (byte)(ipAdressBytes[i] | (subnetMaskBytes[i] ^ 255));
+ }
+ return new IPAddress(broadcastAddress);
+ }
+
+ public static IPAddress GetNetworkAddress(this IPAddress address, IPAddress subnetMask)
+ {
+ byte[] ipAdressBytes = address.GetAddressBytes();
+ byte[] subnetMaskBytes = subnetMask.GetAddressBytes();
+
+ if (ipAdressBytes.Length != subnetMaskBytes.Length)
+ throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
+
+ byte[] broadcastAddress = new byte[ipAdressBytes.Length];
+ for (int i = 0; i < broadcastAddress.Length; i++)
+ {
+ broadcastAddress[i] = (byte)(ipAdressBytes[i] & (subnetMaskBytes[i]));
+ }
+ return new IPAddress(broadcastAddress);
+ }
+
+ public static bool IsInSameSubnet(this IPAddress address2, IPAddress address, IPAddress subnetMask)
+ {
+ IPAddress network1 = address.GetNetworkAddress(subnetMask);
+ IPAddress network2 = address2.GetNetworkAddress(subnetMask);
+
+ return network1.Equals(network2);
+ }
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/IPProces.cs b/CommLibrary/CommLibrary/IPProces.cs
new file mode 100644
index 0000000..29fd3af
--- /dev/null
+++ b/CommLibrary/CommLibrary/IPProces.cs
@@ -0,0 +1,172 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.NetworkInformation;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: IPProces
+ *版本号: V1.0.0.0
+ *唯一标识:82c86802-257a-4dda-9463-646c5e62f2d0
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:8/27/2016 2:53:39 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:8/27/2016 2:53:39 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+
+ public class IPProces
+ {
+
+ public static string getIPAddress()
+ {
+ //get local address IP
+ IPAddress[] adressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
+ if (adressList.Length < 1)
+ {
+ return "";
+ }
+ return adressList[0].ToString();
+ }
+ public static bool isInSameSubnet(string sip1, string sip2)
+ {
+ var ip1 = IPAddress.Parse(sip1);
+ var ip2 = IPAddress.Parse(sip2);
+ return ip1.IsInSameSubnet(ip2, SubnetMask.ClassC); //invoke example
+
+ }
+
+
+ public static IPAddress getValidIP(String ip)
+ {
+ IPAddress lip = null;
+ try
+ {
+ if (IPAddress.TryParse(ip, out lip))
+ {
+ throw new ArgumentException("Invalid IP ,cannot startup");
+ }
+
+ }
+ catch (Exception e)
+ {
+
+ Console.WriteLine("invalid IP " + e.ToString());
+ return null;
+
+ }
+
+ return lip;
+ }
+
+ ///
+ /// send Arp and fetch MAC address
+ ///
+ ///
+ ///
+ ///
+ [DllImport("Iphlpapi.dll")]
+ static extern int SendARP(Int32 destIP,Int32 scrcIP,ref Int64 macAddress,ref Int32 PhyAddrLen);
+
+
+
+ public static string getMac(string p_id)
+ {
+ IPAddress _address;
+
+ if (!IPAddress.TryParse(p_id, out _address)) return "";
+ uint DestIP = BitConverter.ToUInt32(_address.GetAddressBytes(), 0);
+
+ Int64 pMacAddr = 0;
+ Int32 PhyAddLen = 6;
+ int error_code = SendARP((int)DestIP, 0, ref pMacAddr, ref PhyAddLen);
+ byte[] _bytes=BitConverter.GetBytes(pMacAddr);
+ return BitConverter.ToString(_bytes,0,6);
+
+ }
+
+ public static int getValidPort(string port)
+ {
+
+ int lport = 0;
+
+ try
+ {
+ if (port == "")
+ {
+ throw new ArgumentException("Port is invalid,cannot startup");
+ }
+ lport = System.Convert.ToInt32(port.Trim());//string to int
+
+
+
+ }
+ catch (Exception e)
+ {
+
+ Console.WriteLine("invalid port " + e.ToString());
+
+ }
+ return lport;
+ }
+
+ ///
+ /// print ary byte
+ ///
+ ///
+ ///
+ public static void printAryByte(String prestr, byte[] mdata)
+ {
+
+ string strm = string.Format("{0} data length {1}", prestr, mdata.Length);
+ strm += " " + BitConverter.ToString(mdata);
+
+ System.Console.WriteLine(strm);
+
+ }
+
+ ///
+ /// printbyte
+ ///
+ ///
+ ///
+ ///
+ public static void printAryByte(string prestr, byte[] mdata, int length)
+ {
+ if (length <= mdata.Length)
+ {
+ StringBuilder buder = new StringBuilder();
+ buder.Append(prestr);
+ for (int i = 0; i < length; i++)
+ {
+ buder.Append(" " + mdata[i].ToString("X2"));
+ }
+ Console.WriteLine(buder.ToString());
+ }
+ }
+
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/IoSocketProces.7z b/CommLibrary/CommLibrary/IoSocketProces.7z
new file mode 100644
index 0000000..769a872
Binary files /dev/null and b/CommLibrary/CommLibrary/IoSocketProces.7z differ
diff --git a/CommLibrary/CommLibrary/IoSocketProces.cs b/CommLibrary/CommLibrary/IoSocketProces.cs
new file mode 100644
index 0000000..c95fe21
--- /dev/null
+++ b/CommLibrary/CommLibrary/IoSocketProces.cs
@@ -0,0 +1,452 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+using System.Diagnostics;
+using System.Net;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: IoSocketProces
+ *版本号: V1.0.0.0
+ *唯一标识:b2ea57f1-026d-478b-9e90-81c2fb27a55c
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:8/30/2016 2:53:03 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:8/30/2016 2:53:03 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+//this is udp transport..........below for reference
+private void OnReceive(IAsyncResult ar)
+{
+ try
+ {
+ if (ar == currentAynchResult)
+ {
+ IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
+ EndPoint epSender = (EndPoint)ipeSender;
+
+ //Error comes here if we didn't have (ar == currentAynchResult) check
+ int bytesRead = udpSocket.EndReceiveFrom(ar, ref epSender);
+ //process further
+ }
+ else
+ {
+ //Ignore
+ }
+ BeginReceive();
+ }
+ catch (Exception ex)
+ {
+ //Log exception. Don't throw exception. Most probably BeginReceive failed.
+ }
+}
+
+private IAsyncResult oldAynchResult;
+private void BeginReceive()
+{
+IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
+//The epSender identifies the incoming clients
+EndPoint epSender = (EndPoint)ipeSender;
+
+//Start receiving data
+oldAynchResult = udpSocket.BeginReceiveFrom(DataBuffer, 0, DataBuffer.Length,
+SocketFlags.None, ref epSender, new AsyncCallback(OnReceive), epSender);
+}
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class IoSocketProces //tcp process
+ {
+ public static IoSocketProces ioProc = null;
+
+ public Socket netCilent; //= new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ //---------------------------------
+ public delegate void socketReceive(byte[] m_rData, int dlen, EventArgs e); //socketReceive
+ public event socketReceive ReceiveByteEvent;
+
+ public delegate void socketDisconnect(Object sender, EventArgs e);//socket disconnect
+ public event socketDisconnect SockDisconnectEvent;
+
+
+ public delegate void socketConnected(string conIP, EventArgs e);//socket connected
+ public event socketConnected SockConnectEvent;
+
+
+
+ ///
+ /// socket connected event
+ ///
+ private void OnSocketConnect(string strip)
+ {
+ try
+ {
+ if (SockConnectEvent != null)
+ {
+ SockConnectEvent(strip, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+
+
+ }
+
+
+
+ ///
+ /// socket disconnect event
+ ///
+ private void OnSocketDisconnect()
+ {
+ try
+ {
+ if (SockDisconnectEvent != null)
+ {
+ SockDisconnectEvent(this, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+
+
+ }
+
+ ///
+ /// onSocket Recieve
+ ///
+ ///
+ ///
+ private void OnSocketReceiveEvent(byte[] pData, int rlen)
+ {
+ try
+ {
+ if (ReceiveByteEvent != null)
+ {
+ ReceiveByteEvent(pData, rlen, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+ }
+ //
+
+ public const int TCP_PORT = 5000;
+
+ public int connetPort = TCP_PORT;
+
+ private byte[] m_recData = new byte[8192];
+
+ public int ConnectPort
+ {
+ get
+ {
+ return connetPort;
+ }
+ set
+ {
+ connetPort = value;
+
+ }
+ }
+ //
+
+ public bool IsConnected
+ {
+ get
+ {
+ return netCilent.Connected;
+ }
+
+ }
+
+ ///
+ /// static object---------
+ ///
+ ///
+ public static IoSocketProces shareIoSocket()
+ {
+ if (ioProc == null)
+ {
+ ioProc = new IoSocketProces();
+ }
+
+ return ioProc;
+ }
+
+
+ public void initSocket()
+ {
+ if (netCilent != null)
+ {
+ if (netCilent.Connected)
+ {
+ netCilent.Disconnect(true);
+ }
+
+ // Debug.WriteLine("init socket here.....................................");
+ }
+
+ netCilent = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ //|SocketOptionName.KeepAlive
+ netCilent.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+ netCilent.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
+ netCilent.Blocking = false;
+
+
+ }
+
+ public IoSocketProces()
+ {
+ initParameter();
+ initSocket();
+ }
+
+ private void initParameter()
+ {
+ if (m_recData == null)
+ m_recData = new byte[8192];
+ }
+ //
+ public bool isNULL()
+ {
+ bool isnul = false;
+ if (netCilent == null)
+ isnul = true;
+ else
+ isnul = false;
+ return isnul;
+ }
+
+
+ private void DisconnectCallBack(IAsyncResult result)
+ {
+ try
+ {
+
+ Socket remotesock = (Socket)result.AsyncState;
+ if (remotesock != null)
+ {
+ remotesock.EndDisconnect(result);
+ OnSocketDisconnect();
+ }
+ }
+ catch (Exception ec)
+ {
+ Debug.WriteLine("endconnect error.............{0}..",ec.Message);
+
+ }
+
+ }
+ //
+ ///
+ /// socket close for temp
+ ///
+ public void Disconnect()
+ {
+ try
+ {
+ if (netCilent != null && netCilent.Connected)
+ {
+ // netCilent.Shutdown(SocketShutdown.Both);
+ netCilent.BeginDisconnect(true, new AsyncCallback(DisconnectCallBack), netCilent);
+
+ }
+ }
+ catch(Exception ec)
+ {
+ Debug.WriteLine("error message {0}", ec.Message);
+
+ }
+
+ }
+ //--------check the socket is ready or no
+ public bool isReady()
+ {
+ return ((!isNULL() && IsConnected));
+ }
+
+ //private override void dipos
+
+ ///
+ /// connect to IP with tcp
+ ///
+ ///
+ public void connectWithIP(string strip)
+ {
+ if (string.IsNullOrEmpty(strip)) return;
+ IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(strip), connetPort);
+
+ try
+ {
+ initSocket();
+ netCilent.Connect(ipe);
+ BeginReceive();
+ OnSocketConnect(strip);
+ // netCilent.BeginConnect(ipe, asyncResult =>
+ // {
+ // netCilent.EndConnect(asyncResult);
+
+
+ // }
+
+ //, null);
+ }
+ catch(SocketException e)
+ {
+ Debug.WriteLine(e.ToString());
+ }
+ catch (Exception e)
+ {
+ Debug.WriteLine(e.ToString());
+ }
+
+ }
+
+ //
+ ///
+ /// sendByte
+ ///
+ ///
+ public void sendByte(byte[] sdata)
+ {
+ sendByte(netCilent, sdata);
+ }
+
+ public bool showSockLog
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// sendByte with socket
+ ///
+ ///
+ ///
+ public void sendByte(Socket socket, Byte[] sdata) //send Byte array
+ {
+
+ if (socket == null || sdata.Length < 1 || !socket.Connected) return;
+ try
+ {
+ socket.BeginSend(sdata, 0, sdata.Length, SocketFlags.None, asyncResult =>
+ {
+
+ int length = socket.EndSend(asyncResult);
+ //完成发送消息
+ // if (showSockLog)
+ // IPProces.printAryByte("client send :", sdata);
+ // Debug.WriteLine("socket send byte over....");
+
+ }, null);
+ }
+ catch (Exception ec)
+ {
+ Debug.WriteLine("Send error catch...",ec.Message);
+ }
+
+
+ }
+
+ // private IAsyncResult oldAynchResult;
+ private IAsyncResult currentAynchResult;
+ private void BeginReceive()
+ {
+ Array.Clear(m_recData, 0, m_recData.Length);
+ if (netCilent == null || !netCilent.Connected) return;
+ currentAynchResult = netCilent.BeginReceive(m_recData, 0, m_recData.Length,
+
+ SocketFlags.None, new AsyncCallback(OnReceive),netCilent);
+
+ }
+ //if app is closed suddenly
+ public void clearSocket()
+ {
+ try
+ {
+ if (netCilent != null && netCilent.Connected)
+ {
+
+ netCilent.Shutdown(SocketShutdown.Both);
+ netCilent.Disconnect(false);
+ netCilent = null;
+ GC.Collect();
+ }
+ }
+ catch(Exception ec)
+ {
+ Debug.WriteLine(ec.Message);
+ }
+
+ }
+
+ private void OnReceive(IAsyncResult ar)
+ {
+ try
+ {
+ // if (ar == currentAynchResult)
+ {
+ try
+ {
+ Socket remote = (Socket)ar.AsyncState;
+ if (remote!= null)
+ {
+ SocketError ercode;
+ int bytesRead = remote.EndReceive(ar,out ercode); //netCilent.EndReceive(ar);
+
+ if (bytesRead > 0)
+ OnSocketReceiveEvent(m_recData, bytesRead);
+ }
+ }
+ catch (Exception ec)
+ {
+ Debug.WriteLine("Onreceive error.....catch..{0}",ec.Message);
+ }
+ }
+ // else
+ // {
+ //Ignore
+ // }
+ BeginReceive();
+ }
+ catch (Exception ex)
+ {
+ //Log exception. Don't throw exception. Most probably BeginReceive failed.
+ }
+ }
+
+
+
+ }
+
+
+
+}
diff --git a/CommLibrary/CommLibrary/ListenerApparatus.cs b/CommLibrary/CommLibrary/ListenerApparatus.cs
new file mode 100644
index 0000000..3d97188
--- /dev/null
+++ b/CommLibrary/CommLibrary/ListenerApparatus.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Threading;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:CommLibrary
+ *文件名: ListenerApparatus
+ *版本号: V1.0.0.0
+ *唯一标识:a38358e6-78de-43be-9ecd-addcc8a3935c
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:12/9/2016 2:30:29 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:12/9/2016 2:30:29 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ListenerApparatus
+ {
+ //
+
+ public delegate void listenDoEvent(object sender, EventArgs e);
+ public event listenDoEvent onListenDoEvent;
+
+ public bool hasStopListening { get; set; }
+ ///
+ /// udpSocket begin.........................................
+ ///
+ ///
+
+
+ private ScanThreader thread_apparatus; //
+
+ public ListenerApparatus(int milliDelay=5000)
+ {
+ DelayMills = milliDelay;
+ hasStopListening = true;
+ thread_apparatus = new ScanThreader();
+ //task to do in future
+ thread_apparatus.DoSomethingEvent += new ScanThreader.threadDosomething(onlistennerEvent);
+ isBeginCheck = false;
+ caculateCounter = 0;
+
+ }
+
+ public bool isBeginCheck= false;
+ public int DelayMills
+ {
+ get;
+ set;
+ }
+
+ private int caculateCounter = 0;
+
+ private void onlistennerEvent(object sender, EventArgs e)
+ {
+ if (onListenDoEvent != null && caculateCounter>0) //first time not do
+ {
+
+ onListenDoEvent(this, e);
+ Debug.WriteLine("listenning check now.......");
+ }
+ caculateCounter++;
+ Thread.Sleep(DelayMills);
+
+ }
+
+ private void timer_Tick(object sender, EventArgs e)
+ {
+ Debug.WriteLine("timer_tick gogogog1");
+ // stopListen();
+
+ }
+ public void stopListen()
+ {
+ if (!hasStopListening)
+ {
+ Debug.WriteLine("close socket and stopscan....................");
+ caculateCounter = 0;
+ thread_apparatus.Stop();
+
+
+ hasStopListening = true;
+ // timer.Stop();
+
+ Thread.Sleep(100);
+
+ }
+ else
+ {
+
+ // Debug.WriteLine("stopscan is false so no need to close xxxx....................");
+ }
+
+ }
+
+
+ //-------------------------------
+
+ //-------------------------
+
+ //-------------------------------------------------------------------------------------------------
+ public void startListen()
+ {
+ caculateCounter = 0;
+ hasStopListening = false;
+ thread_apparatus.Start(); //
+ // timer.Start();
+
+ }
+
+ //---------------------------
+
+ public void clear() //when it close
+ {
+ caculateCounter = 0;
+ thread_apparatus.Stop();
+ hasStopListening = true;
+
+ }
+
+
+
+ }
+
+
+
+}
diff --git a/CommLibrary/CommLibrary/Properties/AssemblyInfo.cs b/CommLibrary/CommLibrary/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..fb0a06e
--- /dev/null
+++ b/CommLibrary/CommLibrary/Properties/AssemblyInfo.cs
@@ -0,0 +1,46 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows.Markup;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CommLibrary")]
+[assembly: AssemblyDescription("William oem controls for WPF")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CommLibrary")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly:AssemblyVersion("2.1.3.5")]
+[assembly:AssemblyFileVersion("3.4.5.8.9")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("57f71aa6-0360-43cd-a46f-477850a8e152")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+//should add System.Xaml.dll to reference
+[assembly: XmlnsDefinition("http://system.control-wpf.com/2016/xaml/presentation", "CommLibrary")]
+[assembly:XmlnsPrefix("http://system.control-wpf.com/2016/xaml/presentation","comx")]
+//[assembly:AssemblyDescriptionAttribute("William oem controls for WPF")]
+
+
+
+
diff --git a/CommLibrary/CommLibrary/ReverClock.cs b/CommLibrary/CommLibrary/ReverClock.cs
new file mode 100644
index 0000000..efdfb4f
--- /dev/null
+++ b/CommLibrary/CommLibrary/ReverClock.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Threading;
+using System.Diagnostics;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:ReverseCount
+ *文件名: ReverClock
+ *版本号: V1.0.0.0
+ *唯一标识:48bd31cb-682f-45b0-8f5d-e490227ea0d4
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/12/2016 1:44:11 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/12/2016 1:44:11 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ * 注意在dll中虽然不能直接引用DispatchTimer之类的组件,但是可以在msdn中找到该类所属的dll库
+ * 然后添加这个dll库引用(找到dll库,一般地址在
+ * C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework 选择相应的版本目录下找到windowsbase.dll
+ * 即可
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ReverClock
+ {
+ public delegate void clockCountDown(int cDown, EventArgs e);
+ public event clockCountDown countDownEvent;
+
+
+ public delegate void clockOver(EventArgs e);
+ public event clockOver clockOverEvent;
+
+
+
+ public int reverseCount
+ {
+ get;
+ set;
+ }
+
+ public int GameTime { get; set; }
+ private static DispatcherTimer disTimer = new DispatcherTimer();
+
+ public ReverClock(int delayT)
+ {
+
+ disTimer.Interval = new TimeSpan(0, 0, 0, 1);
+ disTimer.Tick += new EventHandler(disTimer_Tick);
+ disTimer.Stop();
+ GameTime = reverseCount = delayT;
+
+ }
+
+ void disTimer_Tick(object sender, EventArgs e)
+ {
+ if (reverseCount >= 0)
+ {
+
+ // Debug.WriteLine("game over........");
+
+ //判断lblSecond是否处于UI线程上
+ if (countDownEvent != null)
+ {
+ countDownEvent(reverseCount, e);
+
+ }
+ --reverseCount;
+
+ }
+ else
+ {
+
+ if (clockOverEvent != null)
+ {
+ clockOverEvent(e);
+ }
+ disTimer.Stop();
+ Debug.WriteLine("game over........");
+ }
+
+ }
+
+ public void startClock()
+ {
+ reverseCount = GameTime;
+ disTimer.Start();
+ }
+ public void StopClock()
+ {
+ disTimer.Stop();
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/ScanThreadLooper.cs b/CommLibrary/CommLibrary/ScanThreadLooper.cs
new file mode 100644
index 0000000..4983e46
--- /dev/null
+++ b/CommLibrary/CommLibrary/ScanThreadLooper.cs
@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: ScanThread
+ *版本号: V1.0.0.0
+ *唯一标识:40af76b9-9cd2-49c5-8a4f-1e87eaf74e61
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:8/27/2016 11:36:37 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:8/27/2016 11:36:37 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Diagnostics;
+
+
+namespace CommLibrary
+{
+ public class ScanThreadOnce
+ {
+ bool _threadSwitch = false; //线程启动开关
+ bool _pauseSwitch = false;//暂停开关
+ AutoResetEvent _resetEvent = new AutoResetEvent(false); //自动重设事件
+ Thread _worker = null;
+ object _locker = new object();
+
+ public int ErrorCounter;
+
+ public delegate void threadDosomething(object sender, EventArgs e);
+
+ public event threadDosomething DoSomethingEvent;
+
+ private void OnDoSomethingEvent()
+ {
+ try
+ {
+ if (DoSomethingEvent != null)
+ {
+ DoSomethingEvent(this, new EventArgs());
+ }
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+ }
+ public void Start()
+ {
+ lock(_locker)
+ {
+ ErrorCounter = 0;
+ if (_worker == null)
+ {
+ _threadSwitch = true;
+ _worker = new Thread(Run);
+ _worker.IsBackground = true;
+ _worker.Start();
+ }
+ }
+
+ }
+
+ void Run()
+ {
+ while (_threadSwitch)
+ {
+ try
+ {
+ if (_pauseSwitch)
+ {
+ _resetEvent.WaitOne();
+ }
+ OnDoSomethingEvent();
+ }
+ catch (System.Exception ex)
+ {
+
+ Debug.WriteLine(ex.Message); //MessageBox.Show(ex.Message);
+ }
+ Thread.Sleep(1);
+ }
+ }
+
+ public void Continue()
+ {
+ lock (_locker)
+ {
+ if (!_pauseSwitch)
+ {
+ return;
+ }
+ _pauseSwitch = false;
+ _resetEvent.Set();
+ }
+ }
+
+ public void Pause()
+ {
+ lock (_locker)
+ {
+ if (_pauseSwitch)
+ {
+ return;
+ }
+ _pauseSwitch = true;
+ }
+ }
+
+ public void Stop()
+ {
+ lock (_locker)
+ {
+ if (_worker == null)
+ {
+ return;
+ }
+ _threadSwitch = false;
+ _pauseSwitch = false;
+ _resetEvent.Set();
+ if (_worker.IsAlive)
+ {
+ try
+ {
+ _worker.Abort();
+ }
+ catch(Exception ex)
+ {
+ ErrorCounter++;
+ Debug.WriteLine("scan number is {0}", ErrorCounter);
+
+ }
+ }
+ _worker = null;
+ }
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/ScanThreader.cs b/CommLibrary/CommLibrary/ScanThreader.cs
new file mode 100644
index 0000000..88f015c
--- /dev/null
+++ b/CommLibrary/CommLibrary/ScanThreader.cs
@@ -0,0 +1,162 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: ScanThread
+ *版本号: V1.0.0.0
+ *唯一标识:40af76b9-9cd2-49c5-8a4f-1e87eaf74e61
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:8/27/2016 11:36:37 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:8/27/2016 11:36:37 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Diagnostics;
+
+
+namespace CommLibrary
+{
+ public class ScanThreader
+ {
+
+ bool _threadSwitch = false; //线程启动开关
+ bool _pauseSwitch = false;//暂停开关
+ AutoResetEvent _resetEvent = new AutoResetEvent(false); //自动重设事件
+ Thread _worker = null;
+ object _locker = new object();
+
+ public int ErrorCounter;
+
+ public delegate void threadDosomething(object sender, EventArgs e);
+
+ public event threadDosomething DoSomethingEvent;
+
+ private void OnDoSomethingEvent()
+ {
+ try
+ {
+ if (DoSomethingEvent != null)
+ {
+ DoSomethingEvent(this, new EventArgs());
+ }
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+ }
+ public void Start()
+ {
+ lock(_locker)
+ {
+ ErrorCounter = 0;
+ if (_worker == null)
+ {
+ _threadSwitch = true;
+ _worker = new Thread(Run);
+ _worker.IsBackground = true;
+ _worker.Start();
+ }
+ }
+
+ }
+
+ void Run()
+ {
+ // while (_threadSwitch)
+ {
+ try
+ {
+ if (_pauseSwitch)
+ {
+ _resetEvent.WaitOne();
+ }
+ OnDoSomethingEvent();
+ }
+ catch (System.Exception ex)
+ {
+
+ Debug.WriteLine(ex.Message); //MessageBox.Show(ex.Message);
+ }
+ Thread.Sleep(0);
+ }
+ }
+
+ public void Continue()
+ {
+ lock (_locker)
+ {
+ if (!_pauseSwitch)
+ {
+ return;
+ }
+ _pauseSwitch = false;
+ _resetEvent.Set();
+ }
+ }
+
+ public void Pause()
+ {
+ lock (_locker)
+ {
+ if (_pauseSwitch)
+ {
+ return;
+ }
+ _pauseSwitch = true;
+ }
+ }
+
+ public void Stop()
+ {
+ lock (_locker)
+ {
+ if (_worker == null)
+ {
+ return;
+ }
+ _threadSwitch = false;
+ _pauseSwitch = false;
+ _resetEvent.Set();
+ if (_worker.IsAlive)
+ {
+ try
+ {
+ _worker.Abort();
+ }
+ catch(Exception ex)
+ {
+ ErrorCounter++;
+ Debug.WriteLine("scan number is {0}", ErrorCounter);
+
+ }
+ }
+ _worker = null;
+ }
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/SetupDiWrap.cs b/CommLibrary/CommLibrary/SetupDiWrap.cs
new file mode 100644
index 0000000..f1720f8
--- /dev/null
+++ b/CommLibrary/CommLibrary/SetupDiWrap.cs
@@ -0,0 +1,257 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:ListDemo
+ *文件名: Class1
+ *版本号: V1.0.0.0
+ *唯一标识:b0c8169f-8a9f-4aa7-a65f-020e51cd5ad1
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:12/27/2016 11:34:59 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:12/27/2016 11:34:59 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class SetupDiWrap
+ {
+ static public string ComPortNameFromFriendlyNamePrefix(string friendlyNamePrefix)
+ {
+ const string className = "Ports";
+ Guid[] guids = GetClassGUIDs(className);
+
+ System.Text.RegularExpressions.Regex friendlyNameToComPort =
+ new System.Text.RegularExpressions.Regex(@".? \((COM\d+)\)$"); // "..... (COMxxx)" -> COMxxxx
+
+ #region begin loop---
+ foreach (Guid guid in guids)
+ {
+ // We start at the "root" of the device tree and look for all
+ // devices that match the interface GUID of a disk
+ Guid guidClone = guid;
+ IntPtr h = SetupDiGetClassDevs(ref guidClone, IntPtr.Zero, IntPtr.Zero, DIGCF_PRESENT | DIGCF_PROFILE);
+ if (h.ToInt32() != INVALID_HANDLE_VALUE)
+ {
+ int nDevice = 0;
+ while (true)
+ {
+ SP_DEVINFO_DATA da = new SP_DEVINFO_DATA();
+ da.cbSize = (uint)Marshal.SizeOf(da);
+
+ if (0 == SetupDiEnumDeviceInfo(h, nDevice++, ref da))
+ break;
+
+ uint RegType;
+ byte[] ptrBuf = new byte[BUFFER_SIZE];
+ uint RequiredSize;
+ if (SetupDiGetDeviceRegistryProperty(h, ref da,
+ (uint)SPDRP.FRIENDLYNAME, out RegType, ptrBuf,
+ BUFFER_SIZE, out RequiredSize))
+ {
+ const int utf16terminatorSize_bytes = 2;
+ string friendlyName = System.Text.UnicodeEncoding.Unicode.GetString(ptrBuf, 0, (int)RequiredSize - utf16terminatorSize_bytes);
+
+ if (!friendlyName.StartsWith(friendlyNamePrefix))
+ continue;
+
+ if (!friendlyNameToComPort.IsMatch(friendlyName))
+ continue;
+
+ return friendlyNameToComPort.Match(friendlyName).Groups[1].Value;
+ }
+ } // devices
+ SetupDiDestroyDeviceInfoList(h);
+ }
+ } // class guids
+ #endregion
+ return null;
+ }
+
+ ///
+ /// The SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set.
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ private struct SP_DEVINFO_DATA
+ {
+ /// Size of the structure, in bytes.
+ public uint cbSize;
+ /// GUID of the device interface class.
+ public Guid ClassGuid;
+ /// Handle to this device instance.
+ public uint DevInst;
+ /// Reserved; do not use.
+ public uint Reserved;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct SP_DEVICE_INTERFACE_DATA
+ {
+ public Int32 cbSize;
+ public Guid interfaceClassGuid;
+ public Int32 flags;
+ private UIntPtr reserved;
+ }
+
+ const int BUFFER_SIZE = 1024;
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ private struct SP_DEVICE_INTERFACE_DETAIL_DATA
+ {
+ public int cbSize;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = BUFFER_SIZE)]
+ public string DevicePath;
+ }
+
+ private enum SPDRP
+ {
+ DEVICEDESC = 0x00000000,
+ HARDWAREID = 0x00000001,
+ COMPATIBLEIDS = 0x00000002,
+ NTDEVICEPATHS = 0x00000003,
+ SERVICE = 0x00000004,
+ CONFIGURATION = 0x00000005,
+ CONFIGURATIONVECTOR = 0x00000006,
+ CLASS = 0x00000007,
+ CLASSGUID = 0x00000008,
+ DRIVER = 0x00000009,
+ CONFIGFLAGS = 0x0000000A,
+ MFG = 0x0000000B,
+ FRIENDLYNAME = 0x0000000C,
+ LOCATION_INFORMATION = 0x0000000D,
+ PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000E,
+ CAPABILITIES = 0x0000000F,
+ UI_NUMBER = 0x00000010,
+ UPPERFILTERS = 0x00000011,
+ LOWERFILTERS = 0x00000012,
+ MAXIMUM_PROPERTY = 0x00000013,
+ }
+
+ [DllImport("setupapi.dll", SetLastError = true)]
+ static extern bool SetupDiClassGuidsFromName(string ClassName,
+ ref Guid ClassGuidArray1stItem, UInt32 ClassGuidArraySize,
+ out UInt32 RequiredSize);
+
+ [DllImport("setupapi.dll")]
+ internal static extern IntPtr SetupDiGetClassDevsEx(IntPtr ClassGuid,
+ [MarshalAs(UnmanagedType.LPStr)]String enumerator,
+ IntPtr hwndParent, Int32 Flags, IntPtr DeviceInfoSet,
+ [MarshalAs(UnmanagedType.LPStr)]String MachineName, IntPtr Reserved);
+
+ [DllImport("setupapi.dll")]
+ internal static extern Int32 SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);
+
+ [DllImport(@"setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern Boolean SetupDiEnumDeviceInterfaces(
+ IntPtr hDevInfo,
+ IntPtr optionalCrap, //ref SP_DEVINFO_DATA devInfo,
+ ref Guid interfaceClassGuid,
+ UInt32 memberIndex,
+ ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData
+ );
+
+ [DllImport("setupapi.dll")]
+ private static extern Int32 SetupDiEnumDeviceInfo(IntPtr DeviceInfoSet,
+ Int32 MemberIndex, ref SP_DEVINFO_DATA DeviceInterfaceData);
+
+ [DllImport("setupapi.dll")]
+ private static extern Int32 SetupDiClassNameFromGuid(ref Guid ClassGuid,
+ StringBuilder className, Int32 ClassNameSize, ref Int32 RequiredSize);
+
+ [DllImport("setupapi.dll")]
+ private static extern Int32 SetupDiGetClassDescription(ref Guid ClassGuid,
+ StringBuilder classDescription, Int32 ClassDescriptionSize, ref Int32 RequiredSize);
+
+ [DllImport("setupapi.dll")]
+ private static extern Int32 SetupDiGetDeviceInstanceId(IntPtr DeviceInfoSet,
+ ref SP_DEVINFO_DATA DeviceInfoData,
+ StringBuilder DeviceInstanceId, Int32 DeviceInstanceIdSize, ref Int32 RequiredSize);
+
+ [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
+ static extern IntPtr SetupDiGetClassDevs( // 1st form using a ClassGUID only, with null Enumerator
+ ref Guid ClassGuid,
+ IntPtr Enumerator,
+ IntPtr hwndParent,
+ int Flags
+ );
+
+ [DllImport(@"setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern Boolean SetupDiGetDeviceInterfaceDetail(
+ IntPtr hDevInfo,
+ ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData,
+ ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData,
+ UInt32 deviceInterfaceDetailDataSize,
+ out UInt32 requiredSize,
+ ref SP_DEVINFO_DATA deviceInfoData
+ );
+
+ ///
+ /// The SetupDiGetDeviceRegistryProperty function retrieves the specified device property.
+ /// This handle is typically returned by the SetupDiGetClassDevs or SetupDiGetClassDevsEx function.
+ ///
+ /// Handle to the device information set that contains the interface and its underlying device.
+ /// Pointer to an SP_DEVINFO_DATA structure that defines the device instance.
+ /// Device property to be retrieved. SEE MSDN
+ /// Pointer to a variable that receives the registry data Type. This parameter can be NULL.
+ /// Pointer to a buffer that receives the requested device property.
+ /// Size of the buffer, in bytes.
+ /// Pointer to a variable that receives the required buffer size, in bytes. This parameter can be NULL.
+ /// If the function succeeds, the return value is nonzero.
+ [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern bool SetupDiGetDeviceRegistryProperty(
+ IntPtr DeviceInfoSet,
+ ref SP_DEVINFO_DATA DeviceInfoData,
+ uint Property,
+ out UInt32 PropertyRegDataType,
+ byte[] PropertyBuffer,
+ uint PropertyBufferSize,
+ out UInt32 RequiredSize);
+
+
+ const int DIGCF_DEFAULT = 0x1;
+ const int DIGCF_PRESENT = 0x2;
+ const int DIGCF_ALLCLASSES = 0x4;
+ const int DIGCF_PROFILE = 0x8;
+ const int DIGCF_DEVICEINTERFACE = 0x10;
+ const int INVALID_HANDLE_VALUE = -1;
+
+ private static Guid[] GetClassGUIDs(string className)
+ {
+ UInt32 requiredSize = 0;
+ Guid[] guidArray = new Guid[1];
+ SetupDiClassGuidsFromName(className, ref guidArray[0], 1, out requiredSize);
+ //bool status = SetupDiClassGuidsFromName(className, ref guidArray[0], 1, out requiredSize);
+ //if (true == status)
+ {
+ if (1 < requiredSize)
+ {
+ guidArray = new Guid[requiredSize];
+ SetupDiClassGuidsFromName(className, ref guidArray[0], requiredSize, out requiredSize);
+ }
+ }
+ //else
+ // throw new System.ComponentModel.Win32Exception();
+
+ return guidArray;
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/UtilCover.cs b/CommLibrary/CommLibrary/UtilCover.cs
new file mode 100644
index 0000000..8b6a4f4
--- /dev/null
+++ b/CommLibrary/CommLibrary/UtilCover.cs
@@ -0,0 +1,152 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:sysLib
+ *文件名: UtilCover
+ *版本号: V1.0.0.0
+ *唯一标识:4b8301ff-75b6-451f-aef7-ca82b0746a16
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/13/2016 2:50:11 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/13/2016 2:50:11 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class UtilCover
+ {
+ //
+ public const int MIN_IP_LEN = 11;//192.168.1.1
+ public static bool IPCheck(string IP)
+ {
+ if (IP == null || IP.Trim().Length < MIN_IP_LEN) return false;
+
+ string num = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)";//创建正则表达式字符串
+ return Regex.IsMatch(IP,//使用正则表达式判断是否匹配
+ ("^" + num + "\\." + num + "\\." + num + "\\." + num + "$"));
+ }
+
+ public static bool isASCII(byte b)
+ {
+ bool res = false;
+ if (
+ (b >= 48 && b <= 57) ||
+ (b >= 41 && b <= 90) ||
+ (b >= 97 && b <= 122) ||
+ (b == 46 || b == 32)
+ )
+ {
+ res = true;
+ }
+ return res;
+
+ }
+
+ public const byte SPACE = 0x20;
+ //----------------------
+ public static string bytesToString(byte[] ktmp, int len)
+ {
+
+ int lt = (ktmp.Length >= len ? len : ktmp.Length);
+ byte[] m_temp = new byte[lt];
+ Array.Clear(m_temp, 0, lt);
+ Array.Copy(ktmp, m_temp, lt);
+
+ for (int i = 0; i < m_temp.Length;i++)
+ {
+ if (!isASCII(m_temp[i]))
+ m_temp[i] = SPACE;
+
+ }
+ return System.Text.Encoding.Default.GetString(m_temp);//auto for different OS
+
+
+ }
+ ///
+ /// decode to bytes
+ ///
+ ///
+ ///
+ public static byte[] stringToBytes(string str, int maxlen)
+ {
+ string tmp = str;
+ if (str.Length > maxlen)
+ tmp = str.Substring(0, maxlen);
+ return System.Text.ASCIIEncoding.Default.GetBytes(tmp);
+
+ }
+
+
+ ///
+ /// registry for search
+ ///
+ ///
+ public static bool Get45or451FromRegistry()
+ {
+ bool res = false;
+ using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\"))
+ {
+ if (ndpKey != null && ndpKey.GetValue("Release") != null)
+ {
+ Console.WriteLine("Version: " + CheckFor45DotVersion((int)ndpKey.GetValue("Release")));
+ res = true;
+ }
+ else
+ {
+ Console.WriteLine("Version 4.5 or later is not detected.");
+ res = false;
+ }
+ }
+
+ return res;
+
+ }
+
+ // Checking the version using >= will enable forward compatibility,
+ // however you should always compile your code on newer versions of
+ // the framework to ensure your app works the same.
+ private static string CheckFor45DotVersion(int releaseKey)
+ {
+ if (releaseKey >= 393295)
+ {
+ return "4.6 or later";
+ }
+ if ((releaseKey >= 379893))
+ {
+ return "4.5.2 or later";
+ }
+ if ((releaseKey >= 378675))
+ {
+ return "4.5.1 or later";
+ }
+ if ((releaseKey >= 378389))
+ {
+ return "4.5 or later";
+ }
+ // This line should never execute. A non-null release key should mean
+ // that 4.5 or later is installed.
+ return "No 4.5 or later version detected";
+ }
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/WScanForm.xaml b/CommLibrary/CommLibrary/WScanForm.xaml
new file mode 100644
index 0000000..2d77b5a
--- /dev/null
+++ b/CommLibrary/CommLibrary/WScanForm.xaml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IP
+ MAC
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Port:
+ 5000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CommLibrary/CommLibrary/WScanForm.xaml.cs b/CommLibrary/CommLibrary/WScanForm.xaml.cs
new file mode 100644
index 0000000..711f223
--- /dev/null
+++ b/CommLibrary/CommLibrary/WScanForm.xaml.cs
@@ -0,0 +1,239 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Diagnostics;
+using System.Threading;
+using System.Net;
+using System.Net.Sockets;
+using System.Windows.Threading;
+using System.Collections;
+
+
+namespace CommLibrary
+{
+
+
+ ///
+ /// Interaction logic for WScanForm.xaml
+ ///
+ public partial class WScanForm : Window
+ {
+
+ ///
+ /// udpSocket begin.........................................
+ ///
+ ///
+ private DeviceScaner udpScan = new DeviceScaner();
+ //
+ private const int Send_Delay = 50;
+ private string localIP;
+ public int delayMills = 5;
+
+ public WScanForm()
+ {
+ initialSocket_and_Data();
+ InitializeComponent();
+
+ }
+
+ public int DelayMills
+ {
+ get;
+ set;
+ }
+
+
+ private void onScanStop(object sender, EventArgs e)
+ {
+ Debug.WriteLine("udp scan stop now...");
+ dtInvoke(stopScanUpdateRefresh);
+ }
+
+ public delegate void updateDo();
+ public void dtInvoke(updateDo fdo)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
+ (ThreadStart)delegate()
+ {
+ fdo();
+ });
+
+ }
+
+ public void stopScanUpdateRefresh()
+ {
+ pbar.IsIndeterminate = false;
+ beginScanBtn.IsEnabled = true;
+ beginScanBtn.Content = "Scan";
+ }
+ public void startScanUpdateRefresh()
+ {
+ scanBox.Items.Clear();
+ pbar.IsIndeterminate = true;
+ beginScanBtn.IsEnabled = false;
+ beginScanBtn.Content = "Stop";
+
+ }
+ private void onScanBegin(object sender, EventArgs e)
+ {
+ // Debug.WriteLine("udp scan begin now...");
+ dtInvoke(startScanUpdateRefresh);
+
+
+ }
+
+ private void initialSocket_and_Data()
+ {
+
+ if (udpScan == null)
+ {
+ udpScan = new DeviceScaner();
+ Debug.WriteLine("nvscan is null");
+ }
+ udpScan.onUDPBeinScanEvent += new DeviceScaner.onDeviceBeginScan(onScanBegin);
+ udpScan.onUDPStopScanEvent += new DeviceScaner.onDeviceStopScan(onScanStop);
+ udpScan.onScanChangedEvent += new DeviceScaner.onDeviceScanChanged(onScanChanged);
+
+ Debug.WriteLine("nvscan load status result is : {0}", udpScan.isLoadedFailure);
+
+
+
+ }
+
+ private void onScanChanged(Object sender, RouterInfo rpinfo, EventArgs e)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
+ (ThreadStart)delegate()
+ {
+ string res = string.Format(" {0} {1}", rpinfo.RouterAddr, rpinfo.RouterMac);
+ scanBox.Items.Add(res);
+ });
+ Debug.WriteLine("udp scan receive.......ip is : " + rpinfo.RouterAddr);
+
+ }
+
+ private void beginScanBtn_Click(object sender, RoutedEventArgs e)
+ {
+ Thread.Sleep(100);
+ try
+ {
+ if (!udpScan.isLoadedFailure)
+ udpScan.startScan();
+ else
+ {
+ Debug.WriteLine("");
+ if (udpScan != null)
+ {
+ udpScan.hasStopScan = false;
+ udpScan.stopScan();
+ MessageBox.Show("Socket port 8000 or 4899 is occupied!");
+
+ }
+
+ // return;
+ }
+ }
+ catch (Exception ec)
+ {
+
+
+ }
+
+ }
+ public void setPbarStyle(Style mstyle)
+ {
+ pbar.Style = mstyle;
+ }
+
+ private void beginConBtn_Click(object sender, RoutedEventArgs e)
+ {
+
+
+ }
+
+
+
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ //
+ // Debug.WriteLine("windows is closing now.........................");
+ beginScanBtn.Content = "Scan";
+ udpScan.clearSocket();
+ pbar.IsIndeterminate = false;
+ this.DialogResult = true;
+ // Debug.WriteLine("windows is closing over.........................");
+
+ }
+
+ private void btnMac_Click(object sender, RoutedEventArgs e)
+ {
+ //for test
+
+
+
+ }
+
+ private void scanBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+
+ ListBox box = (ListBox)e.OriginalSource;
+ int index = box.SelectedIndex;
+
+ // Debug.WriteLine("select item index is : {0}", index);
+ if (index >= 0 && index < udpScan.scanedIpList.Count)
+ ipBox.Text = udpScan.scanedIpList[index].RouterAddr;
+
+ }
+
+ private void beginClose_Click(object sender, RoutedEventArgs e)
+ {
+ //close
+ beginScanBtn.Content = "Scan";
+ pbar.IsIndeterminate = false;
+ this.DialogResult = true;
+
+ }
+
+
+ ///
+ /// getScan IP case when close form
+ ///
+ ///
+ public string getScanedIP()
+ {
+
+ if (udpScan.scanedIpList.Count < 1)
+ return null;
+ else
+ {
+ if (scanBox.SelectedIndex == -1)
+ return udpScan.scanedIpList[0].ToString();
+ else
+ {
+ int index = scanBox.SelectedIndex;
+ return udpScan.scanedIpList[index].RouterAddr;
+
+ }
+ }
+
+
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/WScanForm.xaml~RF780cfe3.TMP b/CommLibrary/CommLibrary/WScanForm.xaml~RF780cfe3.TMP
new file mode 100644
index 0000000..17c216a
--- /dev/null
+++ b/CommLibrary/CommLibrary/WScanForm.xaml~RF780cfe3.TMP
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IP
+ MAC
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Port:
+ 5000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CommLibrary/CommLibrary/bin/Debug/CommLibrary.dll b/CommLibrary/CommLibrary/bin/Debug/CommLibrary.dll
new file mode 100644
index 0000000..792502c
Binary files /dev/null and b/CommLibrary/CommLibrary/bin/Debug/CommLibrary.dll differ
diff --git a/CommLibrary/CommLibrary/bin/Debug/CommLibrary.pdb b/CommLibrary/CommLibrary/bin/Debug/CommLibrary.pdb
new file mode 100644
index 0000000..baf0b95
Binary files /dev/null and b/CommLibrary/CommLibrary/bin/Debug/CommLibrary.pdb differ
diff --git a/CommLibrary/CommLibrary/bk/WScanForm.xaml b/CommLibrary/CommLibrary/bk/WScanForm.xaml
new file mode 100644
index 0000000..d21a50c
--- /dev/null
+++ b/CommLibrary/CommLibrary/bk/WScanForm.xaml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IP
+ MAC
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Port:
+ 5000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CommLibrary/CommLibrary/bk/WScanForm.xaml.cs b/CommLibrary/CommLibrary/bk/WScanForm.xaml.cs
new file mode 100644
index 0000000..3840be4
--- /dev/null
+++ b/CommLibrary/CommLibrary/bk/WScanForm.xaml.cs
@@ -0,0 +1,236 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Diagnostics;
+using System.Threading;
+using System.Net;
+using System.Net.Sockets;
+using System.Windows.Threading;
+using System.Collections;
+
+
+namespace CommLibrary
+{
+
+
+ ///
+ /// Interaction logic for WScanForm.xaml
+ ///
+ public partial class WScanForm : Window
+ {
+
+ ///
+ /// udpSocket begin.........................................
+ ///
+ ///
+ private DeviceScaner udpScan;
+ //
+ private const int Send_Delay = 50;
+ private string localIP;
+ public int delayMills = 5;
+
+ public WScanForm()
+ {
+ initialSocket_and_Data();
+ InitializeComponent();
+
+ }
+
+ public int DelayMills
+ {
+ get;
+ set;
+ }
+
+
+ private void onScanStop(object sender, EventArgs e)
+ {
+ Debug.WriteLine("udp scan stop now...");
+ dtInvoke(stopScanUpdateRefresh);
+ }
+
+ public delegate void updateDo();
+ public void dtInvoke(updateDo fdo)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
+ (ThreadStart)delegate()
+ {
+ fdo();
+ });
+
+ }
+
+ public void stopScanUpdateRefresh()
+ {
+ pbar.IsIndeterminate = false;
+ beginScanBtn.IsEnabled = true;
+ beginScanBtn.Content = "Scan";
+ }
+ public void startScanUpdateRefresh()
+ {
+ scanBox.Items.Clear();
+ pbar.IsIndeterminate = true;
+ beginScanBtn.IsEnabled = false;
+ beginScanBtn.Content = "Stop";
+
+ }
+ private void onScanBegin(object sender, EventArgs e)
+ {
+ // Debug.WriteLine("udp scan begin now...");
+ dtInvoke(startScanUpdateRefresh);
+
+
+ }
+
+ private void initialSocket_and_Data()
+ {
+
+ if (udpScan == null)
+ {
+ udpScan = new DeviceScaner();
+ Debug.WriteLine("nvscan is null");
+ }
+ udpScan.onUDPBeinScanEvent += new DeviceScaner.onDeviceBeginScan(onScanBegin);
+ udpScan.onUDPStopScanEvent += new DeviceScaner.onDeviceStopScan(onScanStop);
+ udpScan.onScanChangedEvent += new DeviceScaner.onDeviceScanChanged(onScanChanged);
+
+ Debug.WriteLine("nvscan load status result is : {0}", udpScan.isLoadedFailure);
+
+
+
+ }
+
+ private void onScanChanged(Object sender, RouterInfo rpinfo, EventArgs e)
+ {
+ this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
+ (ThreadStart)delegate()
+ {
+ string res = string.Format(" {0} {1}", rpinfo.RouterAddr, rpinfo.RouterMac);
+ scanBox.Items.Add(res);
+ });
+ Debug.WriteLine("udp scan receive.......ip is : " + rpinfo.RouterAddr);
+
+ }
+
+ private void beginScanBtn_Click(object sender, RoutedEventArgs e)
+ {
+ Thread.Sleep(100);
+ // try
+ {
+ if (!udpScan.isLoadedFailure)
+ udpScan.startScan();
+ else
+ {
+ Debug.WriteLine("");
+ if(udpScan!=null)
+ {
+ udpScan.hasStopScan = false;
+ udpScan.stopScan();
+ MessageBox.Show("Socket port 8000 or 4899 is occupied!");
+
+ }
+
+ // return;
+ }
+ }
+ // catch(Exception ec)
+ // {
+
+//
+ // }
+
+ }
+
+ private void beginConBtn_Click(object sender, RoutedEventArgs e)
+ {
+
+
+ }
+
+
+
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+
+ //
+ // Debug.WriteLine("windows is closing now.........................");
+ beginScanBtn.Content = "Scan";
+ udpScan.clearSocket();
+ pbar.IsIndeterminate = false;
+ this.DialogResult = true;
+ // Debug.WriteLine("windows is closing over.........................");
+
+ }
+
+ private void btnMac_Click(object sender, RoutedEventArgs e)
+ {
+ //for test
+
+
+
+ }
+
+ private void scanBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+
+ ListBox box = (ListBox)e.OriginalSource;
+ int index = box.SelectedIndex;
+
+ // Debug.WriteLine("select item index is : {0}", index);
+ if (index >= 0 && index < udpScan.scanedIpList.Count)
+ ipBox.Text = udpScan.scanedIpList[index].RouterAddr;
+
+ }
+
+ private void beginClose_Click(object sender, RoutedEventArgs e)
+ {
+ //close
+ beginScanBtn.Content = "Scan";
+ pbar.IsIndeterminate = false;
+ this.DialogResult = true;
+
+ }
+
+
+ ///
+ /// getScan IP case when close form
+ ///
+ ///
+ public string getScanedIP()
+ {
+
+ if (udpScan.scanedIpList.Count < 1)
+ return null;
+ else
+ {
+ if (scanBox.SelectedIndex == -1)
+ return udpScan.scanedIpList[0].ToString();
+ else
+ {
+ int index = scanBox.SelectedIndex;
+ return udpScan.scanedIpList[index].RouterAddr;
+
+ }
+ }
+
+
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/Cilent.cs b/CommLibrary/CommLibrary/cilent/Cilent.cs
new file mode 100644
index 0000000..d47fc4c
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/Cilent.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: comCilent
+ *版本号: V1.0.0.0
+ *唯一标识:3b371b32-c1b8-48ae-a1a7-1a38c0189a22
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:19:12 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:19:12 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+
+
+namespace CommLibrary
+{
+
+ //public enum ClientType
+ //{
+ // COM_Type = 0x101,
+ // Net_Type = 0x102
+ //};
+
+ public abstract class Cilent : Object
+ {
+ ///
+ //delegate define below:
+ public delegate void onByteReceive(String addr, byte[] m_rData, int dlen, EventArgs e); //socketReceive
+
+ public delegate void onDisconnect(String addr, EventArgs e);//socket disconnect
+
+ public delegate void onConnected(string conIP, EventArgs e);//socket connected
+
+ public string Param { get; set; }
+
+ public int iTag { get; set; }
+
+ public Cilent()
+ {
+
+
+ }
+
+ public virtual void clearRlease()
+ {
+
+ }
+ //
+ public virtual void connect(string mparam)
+ {
+
+ }
+
+ public virtual void disConnect()
+ {
+
+ }
+
+ public abstract bool isConnected();
+
+
+ protected virtual void beginReceive()
+ {
+
+ }
+
+ public virtual void sendByte(byte[] sdata)
+ {
+
+ }
+
+ public virtual void clear()
+ {
+
+
+ }
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/Cilent.cs~RF8ca35dc.TMP b/CommLibrary/CommLibrary/cilent/Cilent.cs~RF8ca35dc.TMP
new file mode 100644
index 0000000..48c8a24
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/Cilent.cs~RF8ca35dc.TMP
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: comCilent
+ *版本号: V1.0.0.0
+ *唯一标识:3b371b32-c1b8-48ae-a1a7-1a38c0189a22
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:19:12 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:19:12 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+
+
+namespace CommLibrary
+{
+
+ //public enum ClientType
+ //{
+ // COM_Type = 0x101,
+ // Net_Type = 0x102
+ //};
+
+ public abstract class Cilent : Object
+ {
+ ///
+ //delegate define below:
+ public delegate void onByteReceive(Object sender, byte[] m_rData, int dlen, EventArgs e); //socketReceive
+
+ public delegate void onDisconnect(Object sender, EventArgs e);//socket disconnect
+
+ public delegate void onConnected(Object sender, string conIP, EventArgs e);//socket connected
+
+ public string Param { get; set; }
+
+ public int iTag = 0;
+
+ public Cilent()
+ {
+
+
+ }
+
+ //
+ public virtual void connect(string mparam)
+ {
+
+ }
+
+ public virtual void disConnect()
+ {
+
+ }
+
+ public abstract bool isConnected();
+
+
+ protected virtual void beginReceive()
+ {
+
+ }
+
+ public virtual void sendByte(byte[] sdata)
+ {
+
+ }
+
+ public virtual void clear()
+ {
+
+
+ }
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/ComCilent.cs b/CommLibrary/CommLibrary/cilent/ComCilent.cs
new file mode 100644
index 0000000..1c96cf4
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/ComCilent.cs
@@ -0,0 +1,313 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.Diagnostics;
+using System.Management;
+using System.IO;
+using System.IO.Ports;
+using System.Threading; //used to perform WMI queries,and add to the reference of system.Management.dll
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: Comport
+ *版本号: V1.0.0.0
+ *唯一标识:3094d7a7-8154-4fb8-b1a4-6c53fc733758
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:15:50 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:15:50 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ComCilent : Cilent
+ {
+
+
+ public static ComCilent comCilent = null;
+
+
+ private SerialPort _comport;
+ public event onByteReceive ReceiveByteEvent;
+ public event onDisconnect onDisconnectEvent;
+ public event onConnected onConnectedEvent;
+
+
+ public int conPort
+ {
+
+ get
+ {
+ return _comport.BaudRate;
+ }
+ set
+ {
+ _comport.BaudRate = value;
+ }
+
+ }
+
+ public string PortName
+ {
+
+ get
+ {
+ return _comport.PortName;
+ }
+ set
+ {
+ _comport.PortName = value;
+ }
+
+ }
+
+ public static ComCilent shareCilent()
+ {
+ if (comCilent == null)
+ {
+ comCilent = new ComCilent();
+ }
+
+ return comCilent;
+ }
+ public ComCilent(string strPortname,int baudRate)
+ {
+ initalProperty();
+ PortName = strPortname;
+ conPort = baudRate;
+ }
+ public ComCilent()
+ {
+
+ initalProperty();
+ conPort = 57600;
+ }
+
+ private const int DefaultBaudRate = 57600;
+ private void initalProperty()
+ {
+ if (_comport == null)
+ _comport = new SerialPort();
+ //_comport.BaudRate = conPort;
+ _comport.ReadBufferSize = 8192;
+ _comport.WriteBufferSize = 8192;
+ _comport.Parity = Parity.None;//无奇偶校验位
+ _comport.StopBits = StopBits.One;//两个停止位8
+ _comport.DataBits = 8;
+ _comport.Handshake = Handshake.None;
+ _comport.RtsEnable = false;
+ _comport.DtrEnable = false;
+ _comport.ReceivedBytesThreshold = 1;//设置 DataReceived 事件发生前内部输入缓冲区中的字节数
+ _comport.WriteTimeout = 500;
+ _comport.ReadTimeout = 500;
+ _comport.DataReceived += new SerialDataReceivedEventHandler(dataReceiveHandler);
+
+ }
+
+ private void dataReceiveHandler(object sender, SerialDataReceivedEventArgs e)
+ {
+ // throw new NotImplementedException();
+ var mport = sender as SerialPort;
+ int toRead = mport.BytesToRead;
+ mport.Read(m_read, 0, toRead);
+ if (toRead > 0)
+ {
+ if (ReceiveByteEvent != null)
+ {
+ // Debug.WriteLine("on receive byte now..........");
+
+ ReceiveByteEvent(mport.PortName, m_read, toRead, new EventArgs());
+
+ }
+
+ }
+
+ }
+
+ public override bool isConnected()
+ {
+ return (_comport != null && _comport.IsOpen);
+ }
+
+ public override void disConnect()
+ {
+
+ if (_comport != null)
+ {
+ _comport.Close();
+
+ }
+
+ if (onDisconnectEvent != null)
+ {
+ onDisconnectEvent(_comport.PortName, new EventArgs());
+ }
+
+
+ }
+ public void Reconnect()
+ {
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.Flush();
+ _comport.Close();
+ }
+ initalProperty();
+ _comport.Open();
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(_comport.PortName, new EventArgs());
+ }
+ }
+
+ public override void connect(string mparam)
+ {
+ // base.connect();
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.Flush();
+ _comport.Close();
+
+
+ // GC.Collect();
+
+ }
+ Param = mparam;
+ initalProperty();
+ _comport.PortName = Param;
+ _comport.Open();
+
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(Param,new EventArgs());
+ }
+ //if (_comport.IsOpen)
+ // beginReceive();
+ }
+
+
+ public override void sendByte(byte[] sdata)
+ {
+ //_comport.DiscardOutBuffer();
+ //_comport.Write(sdata, 0, sdata.Length);
+ if (_comport == null || sdata.Length < 1 || !_comport.IsOpen) return;
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.WriteAsync(sdata, 0, sdata.Length);
+ //_comport.BaseStream.BeginWrite(sdata, 0, sdata.Length, asyncResult =>
+ //{
+ // _comport.BaseStream.EndWrite(asyncResult);
+
+
+ //}, _comport);
+
+
+ }
+
+ ///
+ ///
+ ///
+ private static byte[] m_read = new byte[8192];
+
+ ///
+ /// receive byte being
+ ///
+ protected override void beginReceive()
+ {
+ ///
+
+ }
+
+ public static string listUsbPort(string prefex = null)
+ {
+ return SetupDiWrap.ComPortNameFromFriendlyNamePrefix(prefex);
+ }
+
+ public override void clear()
+ {
+ if (_comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.Close();
+
+
+ }
+ else
+ _comport.Dispose();
+
+ _comport = null;
+ GC.Collect();
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ public static string[] listUsbPort()
+ {
+ List portList = new List();
+ try
+ {
+
+ ManagementObjectSearcher searcher =
+ new ManagementObjectSearcher("root\\WMI",
+ "SELECT * FROM MSSerial_PortName");
+
+ foreach (ManagementObject queryObj in searcher.Get())
+ {
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
+
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("PortName: {0}", queryObj["PortName"]);
+
+
+ //If the serial port's instance name contains USB it must be a USB to serial device
+ if (queryObj["InstanceName"].ToString().Contains("USB"))
+ {
+ // Console.WriteLine(queryObj["PortName"] + " is a USB to SERIAL adapter/converter");
+ portList.Add(queryObj["PortName"] as string);
+
+ }
+ }
+
+ }
+ catch (ManagementException e)
+ {
+ Debug.WriteLine("An error occurred while querying for WMI data: " + e.Message);
+ // MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
+ }
+ return portList.ToArray();
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/ComCilent.cs~RF27c41fc.TMP b/CommLibrary/CommLibrary/cilent/ComCilent.cs~RF27c41fc.TMP
new file mode 100644
index 0000000..6b43faa
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/ComCilent.cs~RF27c41fc.TMP
@@ -0,0 +1,312 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.Diagnostics;
+using System.Management;
+using System.IO;
+using System.IO.Ports;
+using System.Threading; //used to perform WMI queries,and add to the reference of system.Management.dll
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: Comport
+ *版本号: V1.0.0.0
+ *唯一标识:3094d7a7-8154-4fb8-b1a4-6c53fc733758
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:15:50 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:15:50 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ComCilent : Cilent
+ {
+
+
+ public static ComCilent comCilent = null;
+
+
+ private SerialPort _comport;
+ public event onByteReceive ReceiveByteEvent;
+ public event onDisconnect onDisconnectEvent;
+ public event onConnected onConnectedEvent;
+
+
+ public int conPort
+ {
+
+ get
+ {
+ return _comport.BaudRate;
+ }
+ set
+ {
+ _comport.BaudRate = value;
+ }
+
+ }
+
+ public string PortName
+ {
+
+ get
+ {
+ return _comport.PortName;
+ }
+ set
+ {
+ _comport.PortName = value;
+ }
+
+ }
+
+ public static ComCilent shareCilent()
+ {
+ if (comCilent == null)
+ {
+ comCilent = new ComCilent();
+ }
+
+ return comCilent;
+ }
+ public ComCilent(string strPortname,int baudRate)
+ {
+ initalProperty();
+ PortName = strPortname;
+ conPort = baudRate;
+ }
+ public ComCilent()
+ {
+
+ initalProperty();
+ conPort = 57600;
+ }
+
+ private const int DefaultBaudRate = 57600;
+ private void initalProperty()
+ {
+ if (_comport == null)
+ _comport = new SerialPort();
+ //_comport.BaudRate = conPort;
+ _comport.ReadBufferSize = 8192;
+ _comport.WriteBufferSize = 8192;
+ _comport.Parity = Parity.None;//无奇偶校验位
+ _comport.StopBits = StopBits.One;//两个停止位8
+ _comport.DataBits = 8;
+ _comport.Handshake = Handshake.None;
+ _comport.RtsEnable = false;
+ _comport.DtrEnable = false;
+ _comport.ReceivedBytesThreshold = 1;//设置 DataReceived 事件发生前内部输入缓冲区中的字节数
+ _comport.WriteTimeout = 500;
+ _comport.ReadTimeout = 500;
+ _comport.DataReceived += new SerialDataReceivedEventHandler(dataReceiveHandler);
+
+ }
+
+ private void dataReceiveHandler(object sender, SerialDataReceivedEventArgs e)
+ {
+ // throw new NotImplementedException();
+ var mport = sender as SerialPort;
+ int toRead = mport.BytesToRead;
+ mport.Read(m_read, 0, toRead);
+ if (toRead > 0)
+ {
+ if (ReceiveByteEvent != null)
+ {
+ // Debug.WriteLine("on receive byte now..........");
+ ReceiveByteEvent(iTag,m_read, toRead, new EventArgs());
+
+ }
+
+ }
+
+ }
+
+ public override bool isConnected()
+ {
+ return (_comport != null && _comport.IsOpen);
+ }
+
+ public override void disConnect()
+ {
+
+ if (_comport != null)
+ {
+ _comport.Close();
+
+ }
+
+ if (onDisconnectEvent != null)
+ {
+ onDisconnectEvent(iTag, new EventArgs());
+ }
+
+
+ }
+ public void Reconnect()
+ {
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.Flush();
+ _comport.Close();
+ }
+ initalProperty();
+ _comport.Open();
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(iTag,Param, new EventArgs());
+ }
+ }
+
+ public override void connect(string mparam)
+ {
+ // base.connect();
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.Flush();
+ _comport.Close();
+
+
+ // GC.Collect();
+
+ }
+ Param = mparam;
+ initalProperty();
+ _comport.PortName = Param;
+ _comport.Open();
+
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(iTag,Param, new EventArgs());
+ }
+ //if (_comport.IsOpen)
+ // beginReceive();
+ }
+
+
+ public override void sendByte(byte[] sdata)
+ {
+ //_comport.DiscardOutBuffer();
+ //_comport.Write(sdata, 0, sdata.Length);
+ if (_comport == null || sdata.Length < 1 || !_comport.IsOpen) return;
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.WriteAsync(sdata, 0, sdata.Length);
+ //_comport.BaseStream.BeginWrite(sdata, 0, sdata.Length, asyncResult =>
+ //{
+ // _comport.BaseStream.EndWrite(asyncResult);
+
+
+ //}, _comport);
+
+
+ }
+
+ ///
+ ///
+ ///
+ private static byte[] m_read = new byte[8192];
+
+ ///
+ /// receive byte being
+ ///
+ protected override void beginReceive()
+ {
+ ///
+
+ }
+
+ public static string listUsbPort(string prefex = null)
+ {
+ return SetupDiWrap.ComPortNameFromFriendlyNamePrefix(prefex);
+ }
+
+ public override void clear()
+ {
+ if (_comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.Close();
+
+
+ }
+ else
+ _comport.Dispose();
+
+ _comport = null;
+ GC.Collect();
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ public static string[] listUsbPort()
+ {
+ List portList = new List();
+ try
+ {
+
+ ManagementObjectSearcher searcher =
+ new ManagementObjectSearcher("root\\WMI",
+ "SELECT * FROM MSSerial_PortName");
+
+ foreach (ManagementObject queryObj in searcher.Get())
+ {
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
+
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("PortName: {0}", queryObj["PortName"]);
+
+
+ //If the serial port's instance name contains USB it must be a USB to serial device
+ if (queryObj["InstanceName"].ToString().Contains("USB"))
+ {
+ // Console.WriteLine(queryObj["PortName"] + " is a USB to SERIAL adapter/converter");
+ portList.Add(queryObj["PortName"] as string);
+
+ }
+ }
+
+ }
+ catch (ManagementException e)
+ {
+ Debug.WriteLine("An error occurred while querying for WMI data: " + e.Message);
+ // MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
+ }
+ return portList.ToArray();
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/ComCilent.cs~RF27cfc64.TMP b/CommLibrary/CommLibrary/cilent/ComCilent.cs~RF27cfc64.TMP
new file mode 100644
index 0000000..c8d61b9
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/ComCilent.cs~RF27cfc64.TMP
@@ -0,0 +1,313 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.Diagnostics;
+using System.Management;
+using System.IO;
+using System.IO.Ports;
+using System.Threading; //used to perform WMI queries,and add to the reference of system.Management.dll
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: Comport
+ *版本号: V1.0.0.0
+ *唯一标识:3094d7a7-8154-4fb8-b1a4-6c53fc733758
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:15:50 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:15:50 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ComCilent : Cilent
+ {
+
+
+ public static ComCilent comCilent = null;
+
+
+ private SerialPort _comport;
+ public event onByteReceive ReceiveByteEvent;
+ public event onDisconnect onDisconnectEvent;
+ public event onConnected onConnectedEvent;
+
+
+ public int conPort
+ {
+
+ get
+ {
+ return _comport.BaudRate;
+ }
+ set
+ {
+ _comport.BaudRate = value;
+ }
+
+ }
+
+ public string PortName
+ {
+
+ get
+ {
+ return _comport.PortName;
+ }
+ set
+ {
+ _comport.PortName = value;
+ }
+
+ }
+
+ public static ComCilent shareCilent()
+ {
+ if (comCilent == null)
+ {
+ comCilent = new ComCilent();
+ }
+
+ return comCilent;
+ }
+ public ComCilent(string strPortname,int baudRate)
+ {
+ initalProperty();
+ PortName = strPortname;
+ conPort = baudRate;
+ }
+ public ComCilent()
+ {
+
+ initalProperty();
+ conPort = 57600;
+ }
+
+ private const int DefaultBaudRate = 57600;
+ private void initalProperty()
+ {
+ if (_comport == null)
+ _comport = new SerialPort();
+ //_comport.BaudRate = conPort;
+ _comport.ReadBufferSize = 8192;
+ _comport.WriteBufferSize = 8192;
+ _comport.Parity = Parity.None;//无奇偶校验位
+ _comport.StopBits = StopBits.One;//两个停止位8
+ _comport.DataBits = 8;
+ _comport.Handshake = Handshake.None;
+ _comport.RtsEnable = false;
+ _comport.DtrEnable = false;
+ _comport.ReceivedBytesThreshold = 1;//设置 DataReceived 事件发生前内部输入缓冲区中的字节数
+ _comport.WriteTimeout = 500;
+ _comport.ReadTimeout = 500;
+ _comport.DataReceived += new SerialDataReceivedEventHandler(dataReceiveHandler);
+
+ }
+
+ private void dataReceiveHandler(object sender, SerialDataReceivedEventArgs e)
+ {
+ // throw new NotImplementedException();
+ var mport = sender as SerialPort;
+ int toRead = mport.BytesToRead;
+ mport.Read(m_read, 0, toRead);
+ if (toRead > 0)
+ {
+ if (ReceiveByteEvent != null)
+ {
+ // Debug.WriteLine("on receive byte now..........");
+
+ ReceiveByteEvent(mport.PortName, m_read, toRead, new EventArgs());
+
+ }
+
+ }
+
+ }
+
+ public override bool isConnected()
+ {
+ return (_comport != null && _comport.IsOpen);
+ }
+
+ public override void disConnect()
+ {
+
+ if (_comport != null)
+ {
+ _comport.Close();
+
+ }
+
+ if (onDisconnectEvent != null)
+ {
+ onDisconnectEvent(mport.PortName, new EventArgs());
+ }
+
+
+ }
+ public void Reconnect()
+ {
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.Flush();
+ _comport.Close();
+ }
+ initalProperty();
+ _comport.Open();
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(iTag,Param, new EventArgs());
+ }
+ }
+
+ public override void connect(string mparam)
+ {
+ // base.connect();
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.Flush();
+ _comport.Close();
+
+
+ // GC.Collect();
+
+ }
+ Param = mparam;
+ initalProperty();
+ _comport.PortName = Param;
+ _comport.Open();
+
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(iTag,Param, new EventArgs());
+ }
+ //if (_comport.IsOpen)
+ // beginReceive();
+ }
+
+
+ public override void sendByte(byte[] sdata)
+ {
+ //_comport.DiscardOutBuffer();
+ //_comport.Write(sdata, 0, sdata.Length);
+ if (_comport == null || sdata.Length < 1 || !_comport.IsOpen) return;
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.WriteAsync(sdata, 0, sdata.Length);
+ //_comport.BaseStream.BeginWrite(sdata, 0, sdata.Length, asyncResult =>
+ //{
+ // _comport.BaseStream.EndWrite(asyncResult);
+
+
+ //}, _comport);
+
+
+ }
+
+ ///
+ ///
+ ///
+ private static byte[] m_read = new byte[8192];
+
+ ///
+ /// receive byte being
+ ///
+ protected override void beginReceive()
+ {
+ ///
+
+ }
+
+ public static string listUsbPort(string prefex = null)
+ {
+ return SetupDiWrap.ComPortNameFromFriendlyNamePrefix(prefex);
+ }
+
+ public override void clear()
+ {
+ if (_comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.Close();
+
+
+ }
+ else
+ _comport.Dispose();
+
+ _comport = null;
+ GC.Collect();
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ public static string[] listUsbPort()
+ {
+ List portList = new List();
+ try
+ {
+
+ ManagementObjectSearcher searcher =
+ new ManagementObjectSearcher("root\\WMI",
+ "SELECT * FROM MSSerial_PortName");
+
+ foreach (ManagementObject queryObj in searcher.Get())
+ {
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
+
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("PortName: {0}", queryObj["PortName"]);
+
+
+ //If the serial port's instance name contains USB it must be a USB to serial device
+ if (queryObj["InstanceName"].ToString().Contains("USB"))
+ {
+ // Console.WriteLine(queryObj["PortName"] + " is a USB to SERIAL adapter/converter");
+ portList.Add(queryObj["PortName"] as string);
+
+ }
+ }
+
+ }
+ catch (ManagementException e)
+ {
+ Debug.WriteLine("An error occurred while querying for WMI data: " + e.Message);
+ // MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
+ }
+ return portList.ToArray();
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/ComCilent_async.7z b/CommLibrary/CommLibrary/cilent/ComCilent_async.7z
new file mode 100644
index 0000000..e04c150
Binary files /dev/null and b/CommLibrary/CommLibrary/cilent/ComCilent_async.7z differ
diff --git a/CommLibrary/CommLibrary/cilent/ComCilent_b.cs b/CommLibrary/CommLibrary/cilent/ComCilent_b.cs
new file mode 100644
index 0000000..95bbc67
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/ComCilent_b.cs
@@ -0,0 +1,292 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.Diagnostics;
+using System.Management;
+using System.IO;
+using System.IO.Ports;
+using System.Threading; //used to perform WMI queries,and add to the reference of system.Management.dll
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: Comport
+ *版本号: V1.0.0.0
+ *唯一标识:3094d7a7-8154-4fb8-b1a4-6c53fc733758
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:15:50 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:15:50 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ComCilent : Cilent
+ {
+
+
+ public static ComCilent comCilent = null;
+
+
+ private SerialPort _comport;
+ public event onByteReceive ReceiveByteEvent;
+ public event onDisconnect onDisconnectEvent;
+ public event onConnected onConnectedEvent;
+
+
+
+ public int conPort
+ {
+
+ get
+ {
+ return _comport.BaudRate;
+ }
+ set
+ {
+ _comport.BaudRate = value;
+ }
+
+ }
+
+ public static ComCilent shareCilent()
+ {
+ if (comCilent == null)
+ {
+ comCilent = new ComCilent();
+ }
+
+ return comCilent;
+ }
+
+ public ComCilent()
+ {
+
+ initalProperty();
+ }
+
+
+ private void initalProperty()
+ {
+ if (_comport == null)
+ _comport = new SerialPort();
+
+ conPort = 57600;
+ _comport.BaudRate = 57600;
+ _comport.ReadBufferSize = 8192;
+ _comport.WriteBufferSize = 8192;
+
+ _comport.Parity = Parity.None;//无奇偶校验位
+ _comport.StopBits = StopBits.One;//两个停止位8
+ _comport.DataBits = 8;
+ _comport.Handshake = Handshake.None;
+ _comport.RtsEnable = true;
+ _comport.DtrEnable = true;
+ _comport.ReceivedBytesThreshold = 1;//设置 DataReceived 事件发生前内部输入缓冲区中的字节数
+ _comport.WriteTimeout = 1000;
+ _comport.ReadTimeout = 100;
+
+ }
+
+ public override bool isConnected()
+ {
+ return (_comport!=null &&_comport.IsOpen);
+ }
+
+ public override void disConnect()
+ {
+ // base.disConnect();
+ if (_comport != null)
+ {
+ _comport.Close();
+ _comport.Dispose();
+
+ }
+
+ // _comport.Close();
+
+ if (onDisconnectEvent != null)
+ {
+ onDisconnectEvent(this, new EventArgs());
+ }
+
+
+ }
+
+ public override void connect(string mparam)
+ {
+ // base.connect();
+ if (_comport!=null && _comport.IsOpen)
+ {
+ _comport.Close();
+ _comport.Dispose();
+ }
+ Param = mparam;
+ initalProperty();
+ _comport.PortName = Param;
+ _comport.Open();
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(Param, new EventArgs());
+ }
+ if (_comport.IsOpen)
+ beginReceive();
+ }
+
+ ///
+ /// onReceiveEvent
+ ///
+ ///
+ ///
+ private void OnReceiveEvent(byte[] pData, int rlen)
+ {
+ try
+ {
+ if (ReceiveByteEvent != null)
+ {
+ ReceiveByteEvent(pData, rlen, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+ }
+
+ public override void sendByte(byte[] sdata)
+ {
+ if (_comport == null || sdata.Length < 1 || !_comport.IsOpen) return;
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.BaseStream.BeginWrite(sdata, 0, sdata.Length, asyncResult =>
+ {
+ _comport.BaseStream.EndWrite(asyncResult);
+ _comport.BaseStream.Flush();
+ }, null);
+
+
+ }
+
+ private IAsyncResult currentAynchResult;
+ private void onReceive(IAsyncResult ar)
+ {
+
+ if (ar == currentAynchResult)
+ {
+
+ SerialPort sport = (SerialPort)ar.AsyncState;
+ if (sport != null && sport.IsOpen)
+ {
+
+ int byteRead = sport.BaseStream.EndRead(ar);
+ if (byteRead > 0)
+ {
+ OnReceiveEvent(m_read, byteRead);
+ }
+
+ }
+
+
+ }
+ beginReceive();
+
+ }
+ ///
+ ///
+ ///
+ private static byte[] m_read = new byte[8192];
+
+ ///
+ /// receive byte being
+ ///
+ protected override void beginReceive()
+ {
+ if (_comport == null || !_comport.IsOpen) return;
+ Array.Clear(m_read, 0, m_read.Length);
+ currentAynchResult = _comport.BaseStream.BeginRead(m_read, 0, m_read.Length
+ , new AsyncCallback(onReceive), _comport);
+
+ }
+
+
+ public override void clear()
+ {
+ if (_comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.Close();
+
+ }
+ _comport = new SerialPort(Param);
+ _comport.Dispose();
+ _comport = null;
+ GC.Collect();
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ public static string[] listUsbPort()
+ {
+ List portList = new List();
+ try
+ {
+
+ ManagementObjectSearcher searcher =
+ new ManagementObjectSearcher("root\\WMI",
+ "SELECT * FROM MSSerial_PortName");
+
+ foreach (ManagementObject queryObj in searcher.Get())
+ {
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
+
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("PortName: {0}", queryObj["PortName"]);
+
+
+ //If the serial port's instance name contains USB it must be a USB to serial device
+ if (queryObj["InstanceName"].ToString().Contains("USB"))
+ {
+ // Console.WriteLine(queryObj["PortName"] + " is a USB to SERIAL adapter/converter");
+ portList.Add(queryObj["PortName"] as string);
+
+ }
+ }
+
+ }
+ catch (ManagementException e)
+ {
+ Debug.WriteLine("An error occurred while querying for WMI data: " + e.Message);
+ // MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
+ }
+ return portList.ToArray();
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/ComCilent_dd.cs b/CommLibrary/CommLibrary/cilent/ComCilent_dd.cs
new file mode 100644
index 0000000..8e71d41
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/ComCilent_dd.cs
@@ -0,0 +1,314 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.Diagnostics;
+using System.Management;
+using System.IO;
+using System.IO.Ports;
+using System.Threading; //used to perform WMI queries,and add to the reference of system.Management.dll
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: Comport
+ *版本号: V1.0.0.0
+ *唯一标识:3094d7a7-8154-4fb8-b1a4-6c53fc733758
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 11:15:50 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 11:15:50 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class ComCilent : Cilent
+ {
+
+
+ public static ComCilent comCilent = null;
+
+
+ private SerialPort _comport;
+ public event onByteReceive ReceiveByteEvent;
+ public event onDisconnect onDisconnectEvent;
+ public event onConnected onConnectedEvent;
+
+ private bool stopping=false;
+
+ public int conPort
+ {
+
+ get
+ {
+ return _comport.BaudRate;
+ }
+ set
+ {
+ _comport.BaudRate = value;
+ }
+
+ }
+
+ public static ComCilent shareCilent()
+ {
+ if (comCilent == null)
+ {
+ comCilent = new ComCilent();
+ }
+
+ return comCilent;
+ }
+
+ public ComCilent()
+ {
+
+ initalProperty();
+ }
+
+
+ private void initalProperty()
+ {
+ if (_comport == null)
+ _comport = new SerialPort();
+
+ conPort = 57600;
+ _comport.BaudRate = 57600;
+ _comport.ReadBufferSize = 8192;
+ _comport.WriteBufferSize = 8192;
+ _comport.Parity = Parity.None;//无奇偶校验位
+ _comport.StopBits = StopBits.One;//两个停止位8
+ _comport.DataBits = 8;
+ _comport.Handshake = Handshake.None;
+ _comport.RtsEnable = false;
+ _comport.DtrEnable = false;
+ _comport.ReceivedBytesThreshold = 1;//设置 DataReceived 事件发生前内部输入缓冲区中的字节数
+ _comport.WriteTimeout = 500;
+ _comport.ReadTimeout = 500;
+
+
+
+ }
+
+
+ public override bool isConnected()
+ {
+ return (_comport != null && _comport.IsOpen);
+ }
+
+ public override void disConnect()
+ {
+ // base.disConnect();
+ if (_comport != null)
+ {
+ _comport.Close();
+ stopping = true;
+
+ }
+ // _comport.Close();
+
+ if (onDisconnectEvent != null)
+ {
+ onDisconnectEvent(this, new EventArgs());
+ }
+
+
+ }
+
+ public override void connect(string mparam)
+ {
+ // base.connect();
+ if (_comport != null && _comport.IsOpen)
+ {
+ _comport.Close();
+ stopping = true;
+ // GC.Collect();
+
+ }
+ Param = mparam;
+ initalProperty();
+ _comport.PortName = Param;
+ _comport.Open();
+ stopping = false;
+ GC.SuppressFinalize(_comport.BaseStream);//add here
+
+ if (_comport.IsOpen && onConnectedEvent != null)
+ {
+ onConnectedEvent(Param, new EventArgs());
+ }
+ if (_comport.IsOpen)
+ beginReceive();
+ }
+
+ ///
+ /// onReceiveEvent
+ ///
+ ///
+ ///
+ private void OnReceiveEvent(byte[] pData, int rlen)
+ {
+ try
+ {
+ if (ReceiveByteEvent != null)
+ {
+ ReceiveByteEvent(pData, rlen, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+ }
+
+ public override void sendByte(byte[] sdata)
+ {
+ if (_comport == null || sdata.Length < 1 || !_comport.IsOpen) return;
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ //GC.SuppressFinalize(_comport.BaseStream);//add here
+ _comport.BaseStream.BeginWrite(sdata, 0, sdata.Length, asyncResult =>
+ {
+ _comport.BaseStream.EndWrite(asyncResult);
+
+ }, null);
+
+
+ }
+
+ ///
+ ///
+ ///
+ private static byte[] m_read = new byte[8192];
+
+ ///
+ /// receive byte being
+ ///
+ protected override void beginReceive()
+ {
+ if (_comport == null || !_comport.IsOpen || stopping) return;
+ Array.Clear(m_read, 0, m_read.Length);
+ currentAynchResult = _comport.BaseStream.BeginRead(m_read, 0, m_read.Length
+ , onEndRead, _comport);
+
+ }
+
+
+ private IAsyncResult currentAynchResult;
+ private void onEndRead(IAsyncResult ar)
+ {
+ //try
+ // {
+ if (ar == currentAynchResult && !stopping)
+ {
+
+ SerialPort remote = (SerialPort)ar.AsyncState;
+ if (remote != null)
+ {
+ int byteRead = remote.BaseStream.EndRead(ar);
+ if (byteRead > 0)
+ {
+
+ OnReceiveEvent(m_read, byteRead);
+ }
+
+ }
+
+
+ }
+ beginReceive();
+ // }
+ //catch (System.IO.IOException error)
+ //{
+ // return;
+
+ //}
+ //catch(System.InvalidOperationException error)
+ //{
+ // return;
+ //}
+
+
+ }
+
+
+ public override void clear()
+ {
+ if (_comport.IsOpen)
+ {
+ _comport.DiscardInBuffer();
+ _comport.DiscardOutBuffer();
+ _comport.Close();
+
+
+ }
+ else
+ _comport.Dispose();
+
+ _comport = null;
+ GC.Collect();
+ }
+
+
+ ///
+ ///
+ ///
+ ///
+ public static string[] listUsbPort()
+ {
+ List portList = new List();
+ try
+ {
+
+ ManagementObjectSearcher searcher =
+ new ManagementObjectSearcher("root\\WMI",
+ "SELECT * FROM MSSerial_PortName");
+
+ foreach (ManagementObject queryObj in searcher.Get())
+ {
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
+
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("MSSerial_PortName instance");
+ //Console.WriteLine("-----------------------------------");
+ //Console.WriteLine("PortName: {0}", queryObj["PortName"]);
+
+
+ //If the serial port's instance name contains USB it must be a USB to serial device
+ if (queryObj["InstanceName"].ToString().Contains("USB"))
+ {
+ // Console.WriteLine(queryObj["PortName"] + " is a USB to SERIAL adapter/converter");
+ portList.Add(queryObj["PortName"] as string);
+
+ }
+ }
+
+ }
+ catch (ManagementException e)
+ {
+ Debug.WriteLine("An error occurred while querying for WMI data: " + e.Message);
+ // MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
+ }
+ return portList.ToArray();
+ }
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/cilent/NetCilent.cs b/CommLibrary/CommLibrary/cilent/NetCilent.cs
new file mode 100644
index 0000000..b9621e8
--- /dev/null
+++ b/CommLibrary/CommLibrary/cilent/NetCilent.cs
@@ -0,0 +1,336 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+using System.Diagnostics;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:seriportDemo
+ *文件名: NetCilent
+ *版本号: V1.0.0.0
+ *唯一标识:bb88aa74-6bee-45a5-8f3e-e5df6800537f
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:10/27/2016 1:41:16 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:10/27/2016 1:41:16 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace CommLibrary
+{
+ public class NetCilent : Cilent
+ {
+ private Socket _socket;
+
+ public static NetCilent netCilent = null;
+
+ public event onByteReceive ReceiveByteEvent;
+ public event onDisconnect onDisconnectEvent;
+ public event onConnected onConnectedEvent;
+
+
+ public NetCilent()
+ {
+ connectPort = DefaultConnetPort;
+ initSocket();
+ }
+
+ public static NetCilent shareCilent()
+ {
+
+ if (netCilent == null)
+ {
+ netCilent = new NetCilent();
+ }
+ return netCilent;
+ }
+
+ ///
+ ///
+ ///
+ private int DefaultConnetPort = 5000;
+ private byte[] m_recData = new byte[8192];
+ public int connectPort { get; set; }
+
+
+ public override bool isConnected()
+ {
+ return _socket.Connected;
+ }
+
+ #region disconnect socket define...........
+ ///
+ /// disconnect define....below..
+ ///
+ public override void disConnect()
+ {
+ // base.disConnect();
+ if (_socket != null && _socket.Connected)
+ {
+ _socket.BeginDisconnect(true, new AsyncCallback(disconnectCallBack), _socket);
+
+ }
+
+ }
+ private void disconnectCallBack(IAsyncResult result)
+ {
+ try
+ {
+
+ Socket remotesock = (Socket)result.AsyncState;
+ if (remotesock != null)
+ {
+ remotesock.EndDisconnect(result);
+ OnSocketDisconnect();
+ }
+ }
+ catch
+ {
+ /// Debug.WriteLine("endconnect error...............");
+
+ }
+
+ }
+ #endregion
+
+ ///
+ ///
+ ///
+
+ public void initSocket()
+ {
+ if (_socket != null)
+ {
+ if (_socket.Connected)
+ {
+ _socket.Disconnect(true);
+ }
+
+ // Debug.WriteLine("init socket here.....................................");
+ }
+
+ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ //|SocketOptionName.KeepAlive
+ _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+ _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
+ _socket.Blocking = false;
+
+
+ }
+
+ ///
+ /// onReceiveEvent
+ ///
+ ///
+ ///
+ private void OnReceiveEvent(byte[] pData, int rlen)
+ {
+ try
+ {
+ if (ReceiveByteEvent != null)
+ {
+
+ String strRIP = ((System.Net.IPEndPoint)_socket.RemoteEndPoint).Address.ToString();
+ ReceiveByteEvent(strRIP, pData, rlen, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+ }
+ //----------------
+ ///
+ /// socket connected event
+ ///
+ private void OnSocketConnect(string strip)
+ {
+ try
+ {
+ if (onConnectedEvent != null)
+ {
+ onConnectedEvent(strip, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+
+ }
+
+ ///
+ /// socket disconnect event
+ ///
+ private void OnSocketDisconnect()
+ {
+ try
+ {
+ if (onDisconnectEvent != null)
+ {
+ String strRIP = ((System.Net.IPEndPoint)_socket.RemoteEndPoint).Address.ToString();
+ onDisconnectEvent(strRIP, new EventArgs());
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ //MessageBox.Show(ex.Message);
+ }
+
+
+ }
+
+
+
+
+ public override void connect(string strip)
+ {
+ if (string.IsNullOrEmpty(strip)) return;
+ IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(strip), connectPort);
+
+ try
+ {
+ initSocket();
+ _socket.BeginConnect(ipe, asyncResult =>
+ {
+ _socket.EndConnect(asyncResult);
+ beginReceive();
+ OnSocketConnect(strip);
+
+ }
+
+
+ , null);
+ }
+ catch (Exception e)
+ {
+ Debug.WriteLine(e.ToString());
+ }
+ }
+
+ #region sendbyte define.......................
+
+ ///
+ /// send byte ov
+ ///
+ ///
+ public override void sendByte(byte[] sdata)
+ {
+ sendByte(_socket, sdata);
+ }
+ ///
+ /// sendByte with socket
+ ///
+ ///
+ ///
+ protected void sendByte(Socket socket, Byte[] sdata) //send Byte array
+ {
+
+ if (socket == null || sdata.Length < 1 || !socket.Connected) return;
+ try
+ {
+ socket.BeginSend(sdata, 0, sdata.Length, SocketFlags.None, asyncResult =>
+ {
+
+ int length = socket.EndSend(asyncResult);
+ //完成发送消息
+ // if (showSockLog)
+ // IPProces.printAryByte("client send :", sdata);
+ // Debug.WriteLine("socket send byte over....");
+
+ }, null);
+ }
+ catch
+ {
+ Debug.WriteLine("Send error catch...");
+ }
+
+
+ }
+ #endregion
+
+ //if app is closed suddenly
+ public override void clear()
+ {
+ if (_socket != null && _socket.Connected)
+ {
+
+ _socket.Shutdown(SocketShutdown.Both);
+ _socket.Disconnect(false);
+ _socket = null;
+ GC.Collect();
+ }
+
+ }
+ // private IAsyncResult oldAynchResult;
+ private IAsyncResult currentAynchResult;
+
+
+ private void OnReceive(IAsyncResult ar)
+ {
+ try
+ {
+ // if (ar == currentAynchResult) //if add this,it will mispackage sometimes.,so comment it.
+ {
+ try
+ {
+ Socket remote = (Socket)ar.AsyncState;
+ if (remote != null)
+ {
+ SocketError ercode;
+ int bytesRead = remote.EndReceive(ar, out ercode);
+ if (bytesRead > 0)
+ OnReceiveEvent(m_recData, bytesRead);
+ }
+ }
+ catch
+ {
+ Debug.WriteLine("Onreceive error.....catch..");
+ }
+ }
+ // else
+ /// {
+ //Ignore
+ // }
+ beginReceive();
+ }
+ catch (Exception ex)
+ {
+ //Log exception. Don't throw exception. Most probably BeginReceive failed.
+ }
+ }
+ protected override void beginReceive()
+ {
+ if (_socket == null || !_socket.Connected) return;
+ Array.Clear(m_recData, 0, m_recData.Length);
+ currentAynchResult = _socket.BeginReceive(m_recData, 0, m_recData.Length,
+ SocketFlags.None, new AsyncCallback(OnReceive), _socket);
+ }
+
+
+
+
+
+ }
+}
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary.csproj.FileListAbsolute.txt b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.csproj.FileListAbsolute.txt
new file mode 100644
index 0000000..4b2140b
--- /dev/null
+++ b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.csproj.FileListAbsolute.txt
@@ -0,0 +1,56 @@
+D:\William\work\VCsharp\Sharp1\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Sharp1\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\Sharp1\CommLibrary\CommLibrary\obj\Debug\CommLibrary.csprojResolveAssemblyReference.cache
+D:\William\work\VCsharp\Sharp1\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Sharp1\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
+F:\wrok\CSharp\Pro\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+F:\wrok\CSharp\Pro\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+F:\wrok\CSharp\Pro\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+F:\wrok\CSharp\Pro\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\CMessageTranser.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\IOBinaryOperation.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\IOOperationINI.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\IoSocketProces.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\IPProces.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\CopyDataStructs.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\ReverClock.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\ScanThread.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\UtilCover.cs
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+F:\wrok\CSharp\Pro\Matrix\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\obj\Debug\WScanForm.baml
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\obj\Debug\WScanForm.g.cs
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\obj\Debug\CommLibrary_MarkupCompile.cache
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\obj\Debug\CommLibrary.g.resources
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+D:\William\work\VCsharp\work\MatrixUpdate\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\CommLibrary.csprojResolveAssemblyReference.cache
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\WScanForm.baml
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\WScanForm.g.cs
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\CommLibrary_MarkupCompile.cache
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\CommLibrary.g.resources
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Control\CommLibrary_temp\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\obj\Debug\WScanForm.baml
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\obj\Debug\WScanForm.g.cs
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\obj\Debug\CommLibrary_MarkupCompile.cache
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.g.resources
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+D:\William\work\VCsharp\Control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\bin\Debug\CommLibrary.pdb
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.csprojResolveAssemblyReference.cache
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\WScanForm.baml
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\WScanForm.g.cs
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\CommLibrary_MarkupCompile.cache
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.g.resources
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.dll
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\CommLibrary.pdb
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary.csprojResolveAssemblyReference.cache b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.csprojResolveAssemblyReference.cache
new file mode 100644
index 0000000..cf4e83f
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.csprojResolveAssemblyReference.cache differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary.dll b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.dll
new file mode 100644
index 0000000..792502c
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.dll differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary.g.resources b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.g.resources
new file mode 100644
index 0000000..ec6421a
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.g.resources differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary.pdb b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.pdb
new file mode 100644
index 0000000..baf0b95
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/CommLibrary.pdb differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary_MarkupCompile.cache b/CommLibrary/CommLibrary/obj/Debug/CommLibrary_MarkupCompile.cache
new file mode 100644
index 0000000..70d5672
--- /dev/null
+++ b/CommLibrary/CommLibrary/obj/Debug/CommLibrary_MarkupCompile.cache
@@ -0,0 +1,20 @@
+CommLibrary
+
+
+library
+C#
+.cs
+D:\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\
+CommLibrary
+none
+false
+DEBUG;TRACE
+
+11726377811
+
+22-750296341
+15527237378
+WScanForm.xaml;
+
+False
+
diff --git a/CommLibrary/CommLibrary/obj/Debug/CommLibrary_MarkupCompile.i.cache b/CommLibrary/CommLibrary/obj/Debug/CommLibrary_MarkupCompile.i.cache
new file mode 100644
index 0000000..cac9d75
--- /dev/null
+++ b/CommLibrary/CommLibrary/obj/Debug/CommLibrary_MarkupCompile.i.cache
@@ -0,0 +1,20 @@
+CommLibrary
+
+
+library
+C#
+.cs
+D:\JinHeng\William\work\VCsharp\work\MatrixSystemEditor\control\CommLibrary\CommLibrary\obj\Debug\
+CommLibrary
+none
+false
+DEBUG;TRACE
+
+11726377811
+
+26-1167699519
+15527237378
+WScanForm.xaml;
+
+False
+
diff --git a/CommLibrary/CommLibrary/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/CommLibrary/CommLibrary/obj/Debug/DesignTimeResolveAssemblyReferences.cache
new file mode 100644
index 0000000..b96f4fc
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/CommLibrary/CommLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
new file mode 100644
index 0000000..52de726
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/CommLibrary/CommLibrary/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
new file mode 100644
index 0000000..e69de29
diff --git a/CommLibrary/CommLibrary/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/CommLibrary/CommLibrary/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
new file mode 100644
index 0000000..e69de29
diff --git a/CommLibrary/CommLibrary/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/CommLibrary/CommLibrary/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
new file mode 100644
index 0000000..e69de29
diff --git a/CommLibrary/CommLibrary/obj/Debug/WScanForm.baml b/CommLibrary/CommLibrary/obj/Debug/WScanForm.baml
new file mode 100644
index 0000000..d48b241
Binary files /dev/null and b/CommLibrary/CommLibrary/obj/Debug/WScanForm.baml differ
diff --git a/CommLibrary/CommLibrary/obj/Debug/WScanForm.g.cs b/CommLibrary/CommLibrary/obj/Debug/WScanForm.g.cs
new file mode 100644
index 0000000..f9511cc
--- /dev/null
+++ b/CommLibrary/CommLibrary/obj/Debug/WScanForm.g.cs
@@ -0,0 +1,175 @@
+#pragma checksum "..\..\WScanForm.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "527627D3493DB5ACC8BBCB7E6D69BB7F"
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Media.TextFormatting;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+
+namespace CommLibrary {
+
+
+ ///
+ /// WScanForm
+ ///
+ public partial class WScanForm : System.Windows.Window, System.Windows.Markup.IComponentConnector {
+
+
+ #line 23 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.ListBox scanBox;
+
+ #line default
+ #line hidden
+
+
+ #line 32 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.ProgressBar pbar;
+
+ #line default
+ #line hidden
+
+
+ #line 38 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox ipBox;
+
+ #line default
+ #line hidden
+
+
+ #line 40 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox portBox;
+
+ #line default
+ #line hidden
+
+
+ #line 46 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button beginScanBtn;
+
+ #line default
+ #line hidden
+
+
+ #line 47 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button beginClose;
+
+ #line default
+ #line hidden
+
+ private bool _contentLoaded;
+
+ ///
+ /// InitializeComponent
+ ///
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent() {
+ if (_contentLoaded) {
+ return;
+ }
+ _contentLoaded = true;
+ System.Uri resourceLocater = new System.Uri("/CommLibrary;component/wscanform.xaml", System.UriKind.Relative);
+
+ #line 1 "..\..\WScanForm.xaml"
+ System.Windows.Application.LoadComponent(this, resourceLocater);
+
+ #line default
+ #line hidden
+ }
+
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
+ switch (connectionId)
+ {
+ case 1:
+
+ #line 4 "..\..\WScanForm.xaml"
+ ((CommLibrary.WScanForm)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
+
+ #line default
+ #line hidden
+
+ #line 6 "..\..\WScanForm.xaml"
+ ((CommLibrary.WScanForm)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);
+
+ #line default
+ #line hidden
+ return;
+ case 2:
+ this.scanBox = ((System.Windows.Controls.ListBox)(target));
+
+ #line 24 "..\..\WScanForm.xaml"
+ this.scanBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.scanBox_SelectionChanged);
+
+ #line default
+ #line hidden
+ return;
+ case 3:
+ this.pbar = ((System.Windows.Controls.ProgressBar)(target));
+ return;
+ case 4:
+ this.ipBox = ((System.Windows.Controls.TextBox)(target));
+ return;
+ case 5:
+ this.portBox = ((System.Windows.Controls.TextBox)(target));
+ return;
+ case 6:
+ this.beginScanBtn = ((System.Windows.Controls.Button)(target));
+
+ #line 46 "..\..\WScanForm.xaml"
+ this.beginScanBtn.Click += new System.Windows.RoutedEventHandler(this.beginScanBtn_Click);
+
+ #line default
+ #line hidden
+ return;
+ case 7:
+ this.beginClose = ((System.Windows.Controls.Button)(target));
+
+ #line 47 "..\..\WScanForm.xaml"
+ this.beginClose.Click += new System.Windows.RoutedEventHandler(this.beginClose_Click);
+
+ #line default
+ #line hidden
+ return;
+ }
+ this._contentLoaded = true;
+ }
+ }
+}
+
diff --git a/CommLibrary/CommLibrary/obj/Debug/WScanForm.g.i.cs b/CommLibrary/CommLibrary/obj/Debug/WScanForm.g.i.cs
new file mode 100644
index 0000000..f9511cc
--- /dev/null
+++ b/CommLibrary/CommLibrary/obj/Debug/WScanForm.g.i.cs
@@ -0,0 +1,175 @@
+#pragma checksum "..\..\WScanForm.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "527627D3493DB5ACC8BBCB7E6D69BB7F"
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Media.TextFormatting;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+
+namespace CommLibrary {
+
+
+ ///
+ /// WScanForm
+ ///
+ public partial class WScanForm : System.Windows.Window, System.Windows.Markup.IComponentConnector {
+
+
+ #line 23 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.ListBox scanBox;
+
+ #line default
+ #line hidden
+
+
+ #line 32 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.ProgressBar pbar;
+
+ #line default
+ #line hidden
+
+
+ #line 38 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox ipBox;
+
+ #line default
+ #line hidden
+
+
+ #line 40 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox portBox;
+
+ #line default
+ #line hidden
+
+
+ #line 46 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button beginScanBtn;
+
+ #line default
+ #line hidden
+
+
+ #line 47 "..\..\WScanForm.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button beginClose;
+
+ #line default
+ #line hidden
+
+ private bool _contentLoaded;
+
+ ///
+ /// InitializeComponent
+ ///
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent() {
+ if (_contentLoaded) {
+ return;
+ }
+ _contentLoaded = true;
+ System.Uri resourceLocater = new System.Uri("/CommLibrary;component/wscanform.xaml", System.UriKind.Relative);
+
+ #line 1 "..\..\WScanForm.xaml"
+ System.Windows.Application.LoadComponent(this, resourceLocater);
+
+ #line default
+ #line hidden
+ }
+
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
+ switch (connectionId)
+ {
+ case 1:
+
+ #line 4 "..\..\WScanForm.xaml"
+ ((CommLibrary.WScanForm)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
+
+ #line default
+ #line hidden
+
+ #line 6 "..\..\WScanForm.xaml"
+ ((CommLibrary.WScanForm)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);
+
+ #line default
+ #line hidden
+ return;
+ case 2:
+ this.scanBox = ((System.Windows.Controls.ListBox)(target));
+
+ #line 24 "..\..\WScanForm.xaml"
+ this.scanBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.scanBox_SelectionChanged);
+
+ #line default
+ #line hidden
+ return;
+ case 3:
+ this.pbar = ((System.Windows.Controls.ProgressBar)(target));
+ return;
+ case 4:
+ this.ipBox = ((System.Windows.Controls.TextBox)(target));
+ return;
+ case 5:
+ this.portBox = ((System.Windows.Controls.TextBox)(target));
+ return;
+ case 6:
+ this.beginScanBtn = ((System.Windows.Controls.Button)(target));
+
+ #line 46 "..\..\WScanForm.xaml"
+ this.beginScanBtn.Click += new System.Windows.RoutedEventHandler(this.beginScanBtn_Click);
+
+ #line default
+ #line hidden
+ return;
+ case 7:
+ this.beginClose = ((System.Windows.Controls.Button)(target));
+
+ #line 47 "..\..\WScanForm.xaml"
+ this.beginClose.Click += new System.Windows.RoutedEventHandler(this.beginClose_Click);
+
+ #line default
+ #line hidden
+ return;
+ }
+ this._contentLoaded = true;
+ }
+ }
+}
+
diff --git a/LibControl/.vs/Lib.Controls/v15/.suo b/LibControl/.vs/Lib.Controls/v15/.suo
new file mode 100644
index 0000000..6bf5b7a
Binary files /dev/null and b/LibControl/.vs/Lib.Controls/v15/.suo differ
diff --git a/LibControl/Controls/Arrow.cs b/LibControl/Controls/Arrow.cs
new file mode 100644
index 0000000..a143692
--- /dev/null
+++ b/LibControl/Controls/Arrow.cs
@@ -0,0 +1,122 @@
+using System;
+using System.ComponentModel;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Input;
+using System.Windows.Controls;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ public sealed class Arrow : Shape
+ {
+ #region Dependency Properties
+
+ public static readonly DependencyProperty X1Property = DependencyProperty.Register("X1", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ public static readonly DependencyProperty Y1Property = DependencyProperty.Register("Y1", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ public static readonly DependencyProperty X2Property = DependencyProperty.Register("X2", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ public static readonly DependencyProperty Y2Property = DependencyProperty.Register("Y2", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ public static readonly DependencyProperty HeadWidthProperty = DependencyProperty.Register("HeadWidth", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ public static readonly DependencyProperty HeadHeightProperty = DependencyProperty.Register("HeadHeight", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
+
+ #endregion
+
+ #region CLR Properties
+
+ [TypeConverter(typeof(LengthConverter))]
+ public double X1
+ {
+ get { return (double)base.GetValue(X1Property); }
+ set { base.SetValue(X1Property, value); }
+ }
+
+ [TypeConverter(typeof(LengthConverter))]
+ public double Y1
+ {
+ get { return (double)base.GetValue(Y1Property); }
+ set { base.SetValue(Y1Property, value); }
+ }
+
+ [TypeConverter(typeof(LengthConverter))]
+ public double X2
+ {
+ get { return (double)base.GetValue(X2Property); }
+ set { base.SetValue(X2Property, value); }
+ }
+
+ [TypeConverter(typeof(LengthConverter))]
+ public double Y2
+ {
+ get { return (double)base.GetValue(Y2Property); }
+ set { base.SetValue(Y2Property, value); }
+ }
+
+ [TypeConverter(typeof(LengthConverter))]
+ public double HeadWidth
+ {
+ get { return (double)base.GetValue(HeadWidthProperty); }
+ set { base.SetValue(HeadWidthProperty, value); }
+ }
+
+ [TypeConverter(typeof(LengthConverter))]
+ public double HeadHeight
+ {
+ get { return (double)base.GetValue(HeadHeightProperty); }
+ set { base.SetValue(HeadHeightProperty, value); }
+ }
+
+ #endregion
+
+ #region Overrides
+
+ protected override Geometry DefiningGeometry
+ {
+ get
+ {
+ // Create a StreamGeometry for describing the shape
+ StreamGeometry geometry = new StreamGeometry();
+ geometry.FillRule = FillRule.EvenOdd;
+
+ using (StreamGeometryContext context = geometry.Open())
+ {
+ InternalDrawArrowGeometry(context);
+ }
+
+ // Freeze the geometry for performance benefits
+ geometry.Freeze();//yes ,this state is very important
+
+ return geometry;
+ }
+ }
+
+ #endregion
+
+ #region Privates
+
+ private void InternalDrawArrowGeometry(StreamGeometryContext context)
+ {
+ double theta = Math.Atan2(Y1 - Y2, X1 - X2);
+ double sint = Math.Sin(theta);
+ double cost = Math.Cos(theta);
+
+ Point pt1 = new Point(X1, this.Y1);
+ Point pt2 = new Point(X2, this.Y2);
+
+ Point pt3 = new Point(
+ X2 + (HeadWidth * cost - HeadHeight * sint),
+ Y2 + (HeadWidth * sint + HeadHeight * cost));
+
+ Point pt4 = new Point(
+ X2 + (HeadWidth * cost + HeadHeight * sint),
+ Y2 - (HeadHeight * cost - HeadWidth * sint));
+
+ context.BeginFigure(pt1, true, false);
+ context.LineTo(pt2, true, true);
+ context.LineTo(pt3, true, true);
+ context.LineTo(pt2, true, true);
+ context.LineTo(pt4, true, true);
+ }
+
+ #endregion
+ }
+}
diff --git a/LibControl/Controls/CBorderSwitcher.cs b/LibControl/Controls/CBorderSwitcher.cs
new file mode 100644
index 0000000..d30a3ae
--- /dev/null
+++ b/LibControl/Controls/CBorderSwitcher.cs
@@ -0,0 +1,220 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls;assembly=Lib.Controls"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ public class CBorderSwitcher : Button
+ {
+ static CBorderSwitcher()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CBorderSwitcher),
+ new FrameworkPropertyMetadata(typeof(CBorderSwitcher)));
+ }
+ [Category("CBorderSwitcher")]
+
+ public CBorderSwitcher()
+ {
+
+
+ }
+
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(CBorderSwitcher), new PropertyMetadata(0));
+
+
+
+ ///
+ /// default brush
+ ///
+ private static SolidColorBrush DefaultUActiveBrush = Brushes.Gray;
+ private static SolidColorBrush DefaultActiveBrush = Brushes.Red;
+
+ public Brush activeBrush
+ {
+ get { return (Brush)GetValue(activeBrushPropertyProperty); }
+ set { SetValue(activeBrushPropertyProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeBrushProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty activeBrushPropertyProperty =
+ DependencyProperty.Register("activeBrush",
+ typeof(Brush), typeof(CBorderSwitcher),
+ new FrameworkPropertyMetadata(DefaultActiveBrush,
+ FrameworkPropertyMetadataOptions.None, OnActiveBrushChanged));
+
+
+
+
+ public Brush unActiveBrush
+ {
+ get { return (Brush)GetValue(unActiveBrushPropertyProperty); }
+ set { SetValue(unActiveBrushPropertyProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeBrushProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty unActiveBrushPropertyProperty =
+ DependencyProperty.Register("unActiveBrush",
+ typeof(Brush), typeof(CBorderSwitcher),
+ new FrameworkPropertyMetadata(DefaultUActiveBrush,
+ FrameworkPropertyMetadataOptions.None, OnUnactiveBrushChanged));
+
+
+ //new PropertyMetadata(DefaultUActiveBrush));
+
+ private static void OnActiveBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var btn = obj as CBorderSwitcher;
+ if (btn != null)
+ {
+ var newValue = (Brush)args.NewValue;
+ var oldValue = (Brush)args.OldValue;
+ btn.activeBrush = newValue;
+ btn.updateBrushWithValue();
+
+ }
+ }
+
+ private static void OnUnactiveBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var btn = obj as CBorderSwitcher;
+ if (btn != null)
+ {
+ var newValue = (Brush)args.NewValue;
+ var oldValue = (Brush)args.OldValue;
+ btn.unActiveBrush = newValue;
+ btn.updateBrushWithValue();
+ }
+ }
+
+ ///
+ /// registry a property for just bool isselected
+ ///
+ public bool IsSelected
+ {
+ get { return (bool)GetValue(IsSelectedPropertyProperty); }
+ set { SetValue(IsSelectedPropertyProperty, value); }
+
+ }
+ // Using a DependencyProperty as the backing store for IsSelectedProperty. This enables animation, styling, binding, etc...
+ //public static readonly DependencyProperty IsSelectedPropertyProperty =
+ // DependencyProperty.Register("IsSelectedProperty", typeof(bool), typeof(CBorderSwitcher), new PropertyMetadata(0));
+
+ private static bool DefaultValue = false;
+
+ private static readonly DependencyProperty IsSelectedPropertyProperty =
+ DependencyProperty.Register("IsSelected", typeof(bool), typeof(CBorderSwitcher),
+ new FrameworkPropertyMetadata(DefaultValue,
+ FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
+ OnSelectedChanged
+ ));
+
+
+ private static void OnSelectedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var btn = obj as CBorderSwitcher;
+ if (btn != null)
+ {
+ var newValue = (bool)args.NewValue;
+ var oldValue = (bool)args.OldValue;
+ btn.IsSelected = newValue;
+ // control.UpdateFormattedValue(newValue);
+ // if(newValue!=oldValue)
+ btn.updateBrushWithValue();
+ // Debug.WriteLine("updated new value is :{0} ", newValue);
+ RoutedPropertyChangedEventArgs e =
+ new RoutedPropertyChangedEventArgs(oldValue, newValue, ValueChangedEvent);
+ btn.OnValueChanged(e);
+
+ }
+ }
+ public void updateBrushWithValue()
+ {
+ Brush brush = (IsSelected ? activeBrush : unActiveBrush);
+ BorderBrush = brush;
+ // Debug.WriteLine("update brush now.........123456............");
+ }
+
+ ///
+ /// for the subclass
+ ///
+ ///
+ virtual protected void OnValueChanged(RoutedPropertyChangedEventArgs e)
+ {
+ RaiseEvent(e);
+ }
+
+ #region Events
+
+ ///
+ /// The ValueChangedEvent, raised if the value changes.
+ ///
+ private static readonly RoutedEvent ValueChangedEvent =
+ EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
+ typeof(RoutedPropertyChangedEventHandler), typeof(CBorderSwitcher));
+
+ ///
+ /// Occurs when the Value property changes.
+ ///
+ public event RoutedPropertyChangedEventHandler ValueChanged
+ {
+ add { AddHandler(ValueChangedEvent, value); }
+ remove { RemoveHandler(ValueChangedEvent, value); }
+ }
+ #endregion
+
+
+
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/CFBC_horMarker.cs b/LibControl/Controls/CFBC_horMarker.cs
new file mode 100644
index 0000000..aa1953e
--- /dev/null
+++ b/LibControl/Controls/CFBC_horMarker.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls;assembly=Lib.Controls"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ public class CFBC_horMarker : CommControl
+ {
+ static CFBC_horMarker()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CFBC_horMarker), new FrameworkPropertyMetadata(typeof(CFBC_horMarker)));
+ }
+
+ public string[] StrMark =
+ {
+ "-∞" ,
+ "-50",
+ "-40",
+ "-30",
+ "-20",
+ "-10",
+ "-5",
+ "0",
+ "5",
+ "dB",
+ "10"
+ };
+ private readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+ private void drawMark(DrawingContext dc)
+ {
+ double wd = this.ActualWidth;
+ int num = StrMark.Length - 1;
+ int fontSize = 10;
+ SolidColorBrush markBrush = Brushes.White;
+
+ FormattedText text = null;
+ double horPerseg = (double)wd/num;
+ int ty = 1;
+ double tx = 0;
+
+
+ for (int i = 0; i < num+1; i++)
+ {
+ tx = horPerseg * i;
+ text = new FormattedText(StrMark[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, markBrush);
+ dc.DrawText(text, new Point(tx, ty));
+ }
+
+ }
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ dc.DrawRectangle(Brushes.Transparent, new Pen(), new Rect(0, 0, wd, ht));
+ drawMark(dc);
+ }
+ public void redraw()
+ {
+ // Debug.WriteLine("readraw.....");
+ InvalidateVisual();
+ }
+ }
+}
diff --git a/LibControl/Controls/CLed.cs b/LibControl/Controls/CLed.cs
new file mode 100644
index 0000000..363b9c1
--- /dev/null
+++ b/LibControl/Controls/CLed.cs
@@ -0,0 +1,328 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Diagnostics;
+using CommLibrary;
+using System.Windows.Threading;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: CLed
+ *版本号: V1.0.0.0
+ *唯一标识:807d453a-96f4-4a67-82cd-815c224de77a
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/30/2016 9:49:10 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/30/2016 9:49:10 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public enum LED_Status
+ {
+ LED_Normal = 0,
+ LED_Red = 1,
+ LED_Yellow = 2,
+ LED_Green = 3
+ };
+
+ public class CLed : CommControl
+ {
+ private DispatcherTimer blinkApparatus = new DispatcherTimer();
+
+ public CLed()
+ {
+ if (blinkApparatus == null)
+ blinkApparatus = new DispatcherTimer();
+
+
+ blinkApparatus.Interval = new TimeSpan(0, 0, 0, 0, 500);
+ blinkApparatus.Tick += blinkApparatus_Tick;
+ blinkApparatus.Stop();
+ // Debug.WriteLine("cled construct now....");
+ string ko = "";
+
+
+ }
+
+ private const bool DefaultBlinking = false;
+ public bool isBlinking
+ {
+ get { return (bool)GetValue(isBlinkingProperty); }
+ set { SetValue(isBlinkingProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isBlinking. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isBlinkingProperty =
+ DependencyProperty.Register("isBlinking", typeof(bool), typeof(CLed), new PropertyMetadata(DefaultBlinking));
+
+
+ private SolidColorBrush tempBrush = Brushes.Gray;
+
+
+ private void blinkApparatus_Tick(object sender, EventArgs e)
+ {
+ // this.Dispatcher.BeginInvoke(new Action(() =>
+ // {
+ if (useBlink)
+ {
+ isBlinking = true;
+ counter++;
+ if (counter % 2 == 0)
+ {
+ BackBrush = NormalBrush;
+ }
+ else
+ {
+ BackBrush = tempBrush;
+ }
+
+ }
+ //}));
+
+ }
+
+ ///
+ /// on blink event
+ ///
+ ///
+ ///
+ ///
+ public void setBlinkInterval(int smiliTime)
+ {
+ blinkApparatus.Interval = new TimeSpan(0, 0, 0, 0, smiliTime);
+ }
+
+ private int counter = 0;
+
+ public void stopBlink()
+ {
+ BackBrush = NormalBrush;
+ blinkApparatus.Stop();
+ counter = 0;
+ isBlinking = false;
+ }
+
+ public void startRedBlink()
+ {
+ tempBrush =BackBrush = new SolidColorBrush(Color.FromRgb(255,0,0));
+ startBlink();
+ }
+
+ public void startGreenBlink()
+ {
+ tempBrush = BackBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
+ startBlink();
+ }
+
+ public void startBlink()
+ {
+ // tempBrush = BackBrush;
+ blinkApparatus.Start();
+ counter = 0;
+ isBlinking = true;
+ }
+
+ private const bool DefaultBlink = false;
+
+ public bool useBlink
+ {
+ get { return (bool)GetValue(useBlinkProperty); }
+ set { SetValue(useBlinkProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for useBlink. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty useBlinkProperty =
+ DependencyProperty.Register("useBlink", typeof(bool), typeof(CLed), new PropertyMetadata(DefaultBlink));
+
+
+
+ ///
+ ///
+ ///
+ ///
+ ///
+
+
+
+
+ private const LED_Status DefaultLedStatus = LED_Status.LED_Normal;
+
+ private static SolidColorBrush DefaultNormalBrush = Brushes.Gray;
+ public SolidColorBrush NormalBrush
+ {
+ get { return (SolidColorBrush)GetValue(NormalBrushProperty); }
+ set { SetValue(NormalBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for NormalBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty NormalBrushProperty =
+ DependencyProperty.Register("NormalBrush", typeof(SolidColorBrush), typeof(CLed), new PropertyMetadata(DefaultNormalBrush));
+
+
+ private static SolidColorBrush DefaultRedBrush = Brushes.Red;
+ public SolidColorBrush RedBrush
+ {
+ get { return (SolidColorBrush)GetValue(RedBrushProperty); }
+ set { SetValue(RedBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for RedBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty RedBrushProperty =
+ DependencyProperty.Register("RedBrush", typeof(SolidColorBrush), typeof(CLed), new PropertyMetadata(DefaultRedBrush));
+
+
+
+
+ private static SolidColorBrush DefaultBlinkBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
+ public SolidColorBrush BlinkBrush
+ {
+ get { return (SolidColorBrush)GetValue(BlinkBrushProperty); }
+ set { SetValue(BlinkBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BlinkBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BlinkBrushProperty =
+ DependencyProperty.Register("BlinkBrush", typeof(SolidColorBrush), typeof(CLed), new PropertyMetadata(DefaultBlinkBrush));
+
+
+
+
+ private static SolidColorBrush DefaultYelloBrush = Brushes.Yellow;
+ public SolidColorBrush YellowBrush
+ {
+ get { return (SolidColorBrush)GetValue(YellowBrushProperty); }
+ set { SetValue(YellowBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for RedBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty YellowBrushProperty =
+ DependencyProperty.Register("YellowBrush", typeof(SolidColorBrush), typeof(CLed), new PropertyMetadata(DefaultYelloBrush));
+
+
+ private static SolidColorBrush DefaultGreenBrush = new SolidColorBrush(Color.FromRgb(0, 0xff, 0));
+ public SolidColorBrush GreenBrush
+ {
+ get { return (SolidColorBrush)GetValue(GreenBrushProperty); }
+ set { SetValue(GreenBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for GreenBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty GreenBrushProperty =
+ DependencyProperty.Register("GreenBrush", typeof(SolidColorBrush), typeof(CLed), new PropertyMetadata(DefaultGreenBrush));
+
+
+ public LED_Status LedStatus
+ {
+ get { return (LED_Status)GetValue(LedStatusProperty); }
+ set { SetValue(LedStatusProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LedStatus. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LedStatusProperty =
+ DependencyProperty.Register("LedStatus", typeof(LED_Status), typeof(CLed),
+ new FrameworkPropertyMetadata(DefaultLedStatus, FrameworkPropertyMetadataOptions.None, onLedStatusChange
+ ));
+
+
+ private static SolidColorBrush DefaultPenBrush = Brushes.Black;
+ public SolidColorBrush penBrush
+ {
+ get { return (SolidColorBrush)GetValue(penBrushProperty); }
+ set { SetValue(penBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for penBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty penBrushProperty =
+ DependencyProperty.Register("penBrush", typeof(SolidColorBrush), typeof(CLed), new PropertyMetadata(DefaultPenBrush));
+
+
+ private const double DefaultBorderThick = 0.5;
+ public double borderThick
+ {
+ get { return (double)GetValue(borderThickProperty); }
+ set { SetValue(borderThickProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for borderThick. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty borderThickProperty =
+ DependencyProperty.Register("borderThick", typeof(double), typeof(CLed),
+ new FrameworkPropertyMetadata(DefaultBorderThick, FrameworkPropertyMetadataOptions.None, onBorderThickChange
+ ));
+
+ private static void onBorderThickChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLed;
+ if (mcontrol != null)
+ {
+
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.borderThick = (double)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+
+ private static void onLedStatusChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLed;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.LedStatus = (LED_Status)args.NewValue;
+ mcontrol.UpdateLedStatus();
+ }
+
+ }
+
+
+ public void UpdateLedStatus()
+ {
+ LED_Status lsts = LedStatus;
+ switch (lsts)
+ {
+ case LED_Status.LED_Normal:
+ BackBrush = NormalBrush;
+ break;
+ case LED_Status.LED_Green:
+ BackBrush = GreenBrush;
+ break;
+ case LED_Status.LED_Red:
+ BackBrush = RedBrush;
+ break;
+ case LED_Status.LED_Yellow:
+ BackBrush = YellowBrush;
+ break;
+ }
+ Redraw();
+ }
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ dc.DrawRectangle(BackBrush, new Pen(penBrush, borderThick), new Rect(0, 0, wd, ht));
+
+ }
+
+
+ }
+}
diff --git a/LibControl/Controls/CLimitGDSlider.cs b/LibControl/Controls/CLimitGDSlider.cs
new file mode 100644
index 0000000..674278c
--- /dev/null
+++ b/LibControl/Controls/CLimitGDSlider.cs
@@ -0,0 +1,568 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+using System.Diagnostics;
+using System.Globalization;
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:MatrixSystemEditor"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:MatrixSystemEditor;assembly=MatrixSystemEditor"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ public enum GDSliderType
+ {
+ GDSLIDER_Gate = 20,
+ GDSLIDER_Exp = 21,
+ GDSLIDER_Dyn = 22,
+ };
+
+ public class CLimitGDSlider : CommControl
+ {
+ public static double[] dynExpRatioTable =
+ {
+
+ 1.0, //0
+ 1.2, //1
+ 1.3, //2
+ 1.5, //3
+ 1.7, //4
+ 2.0, //5
+ 2.2, //6
+ 2.3, //6
+ 2.5, //7
+ 3.0, //9
+ 3.5, //10
+ 4.0, //11
+ 4.5, //12
+ 5.0, //13
+ 5.5, //14
+ 5.6, //15
+ 5.9, //16
+ 6.0, //17
+ 6.2, //18
+ 6.5, //19
+ 7.0, //20
+ 7.2, //21
+ 7.4, //22
+ 7.8, //23
+ 8.0, //19
+
+};
+
+ public static double[] dynRatioTable =
+ {
+ 1.0, //0
+ 1.2, //1
+ 1.3, //2
+ 1.5, //3
+ 1.7, //4
+ 2.0, //5
+ 2.2, //6
+ 2.3, //6
+ 2.5, //7
+ 3.0, //9
+ 3.5, //10
+ 4.0, //11
+ 4.5, //12
+ 5.0, //13
+ 5.5, //14
+ 6.0, //15
+ 6.5, //16
+ 7.0, //17
+ 7.5, //18
+ 8.0, //19
+ 8.5, //20
+ 9.0, //21
+ 9.5, //22
+ 10.0, //23
+ 20.0, //24
+ };
+
+ static CLimitGDSlider()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CLimitGDSlider), new FrameworkPropertyMetadata(typeof(CLimitGDSlider)));
+ }
+
+ private static System.Windows.Point[] dPoints = new Point[3]; //double type
+
+ //
+
+
+ private const int DefaultGDRatioMax = 24;
+ public int dp_gdRatioMax
+ {
+ get { return (int)GetValue(dp_gdRatioMaxProperty); }
+ set { SetValue(dp_gdRatioMaxProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for dp_gdRatioMax. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_gdRatioMaxProperty =
+ DependencyProperty.Register("dp_gdRatioMax", typeof(int), typeof(CLimitGDSlider), new PropertyMetadata(DefaultGDRatioMax));
+
+
+
+
+ private const int DefaultGDRatioPos = 0;
+ public int dp_gdRatioPos
+ {
+ get { return (int)GetValue(dp_gdRatioPosProperty); }
+ set { SetValue(dp_gdRatioPosProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for dp_gdRatioPos. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_gdRatioPosProperty =
+ DependencyProperty.Register("dp_gdRatioPos", typeof(int), typeof(CLimitGDSlider),
+ new PropertyMetadata(DefaultGDRatioPos));
+
+
+ //
+
+ private const int DefaultGDThreshold = 0;
+ public int dp_gdThresholdPos
+ {
+ get { return (int)GetValue(dp_gdThresholdPosProperty); }
+ set { SetValue(dp_gdThresholdPosProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for dp_dgThresholdPos. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_gdThresholdPosProperty =
+ DependencyProperty.Register("dp_gdThresholdPos", typeof(int), typeof(CLimitGDSlider), new PropertyMetadata(DefaultGDThreshold));
+
+#if _KMD
+ new FrameworkPropertyMetadata(DefaultGDThreshold, FrameworkPropertyMetadataOptions.None, onThresholdChange
+ ));
+
+ private static void onThresholdChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLimitGDSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.dp_gdThresholdPos = (int)args.NewValue;
+ mcontrol.Redraw();
+
+ }
+ }
+#endif
+
+
+
+ //
+
+
+ private const int DefaultGDThresdMax = 50;
+ public int dp_gdThresholdMax
+ {
+ get { return (int)GetValue(dp_gdThresholdMaxProperty); }
+ set { SetValue(dp_gdThresholdMaxProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for dp_gdThresholdMax. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_gdThresholdMaxProperty =
+ DependencyProperty.Register("dp_gdThresholdMax", typeof(int), typeof(CLimitGDSlider), new PropertyMetadata(DefaultGDThresdMax));
+
+
+
+
+ private const int DefaultGDGainMax = 24;
+ public int dp_gdGainMax
+ {
+ get { return (int)GetValue(dp_gdGainMaxProperty); }
+ set { SetValue(dp_gdGainMaxProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for dp_gdGainMax. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_gdGainMaxProperty =
+ DependencyProperty.Register("dp_gdGainMax", typeof(int), typeof(CLimitGDSlider), new PropertyMetadata(DefaultGDGainMax));
+
+
+
+ //
+ private const int DefaultGDGainPos = 0;
+ public int dp_gdGainPos
+ {
+ get { return (int)GetValue(dp_gdGainPosProperty); }
+ set { SetValue(dp_gdGainPosProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for dp_gdGainPos. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_gdGainPosProperty =
+ DependencyProperty.Register("dp_gdGainPos", typeof(int), typeof(CLimitGDSlider),
+ new PropertyMetadata(DefaultGDGainPos));
+
+ private const GDSliderType DefaultSliderType = GDSliderType.GDSLIDER_Exp;
+
+ public GDSliderType dp_GDSliderType
+ {
+ get { return (GDSliderType)GetValue(dp_GDSliderTypeProperty); }
+ set { SetValue(dp_GDSliderTypeProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for dp_GDSliderType. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty dp_GDSliderTypeProperty =
+ DependencyProperty.Register("dp_GDSliderType", typeof(GDSliderType), typeof(CLimitGDSlider),
+ new PropertyMetadata(DefaultSliderType));
+
+
+ public CLimitGDSlider()
+ {
+
+
+
+ }
+
+ ///
+ /// transfor data
+ ///
+ ///
+ public void setLimitData_fresh(LimitEdit limData)
+ {
+
+ dp_gdRatioPos = limData.limit_ratio;
+ dp_gdThresholdPos = limData.limit_threshold;
+ this.Redraw();
+ }
+
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+ ///
+ /// flat to initial draw
+ ///
+ public void flatControl()
+ {
+ dp_gdGainPos = dp_gdRatioPos = dp_gdThresholdPos = 0;
+ this.Redraw();
+ }
+ #region EXPGatemark
+ public static string[] strLeftExpMark ={
+ " 20"," 10"," 0","-10","-20","-30","-40","-50","-60","-70","-80"};
+
+ public static string[] strDownExpMark ={
+ "-70","-60","-50","-40","-30","-20","-10"," 0","10","20"};
+ #endregion
+ //
+ #region DynMark
+ public static string[] strLeftDynMark ={
+ " 20"," 12"," 6"," 0 ","-6","-12","-18","-24","-30"};
+
+ public static string[] strDownDynMark ={
+ "-24","-18"," -12"," -6"," 0"," 6"," 12"," 20" };
+
+
+ #endregion
+
+
+ private void drawMark(DrawingContext cvs)
+ {
+ string ftext = string.Empty;
+ int i = 0;
+ double fontsize = 9.0;
+ double xleftOffset = -18;
+ double yExpQOffset = 2;
+
+
+ FormattedText texte = null;
+ double leftExpStep = (double)this.ActualHeight / (strLeftExpMark.Length-1)-0.2;
+ double bottomExpStep = (double)this.ActualWidth / strDownExpMark.Length;
+
+
+ double leftDynStep = (double)this.ActualHeight / (strLeftDynMark.Length - 1) - 0.35;
+ double bottomDynStep = (double)this.ActualWidth / strDownDynMark.Length;
+
+ switch (dp_GDSliderType)
+ {
+ case GDSliderType.GDSLIDER_Gate:
+ case GDSliderType.GDSLIDER_Exp:
+ {
+ for (i = 0; i < strLeftExpMark.Length; i++) //left mark
+ {
+ ftext = strLeftExpMark[i];
+ texte=new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, Brushes.White);
+
+ cvs.DrawText(texte, new Point(xleftOffset, i * leftExpStep));
+
+ }
+
+ for (i = 0; i < strDownExpMark.Length; i++) //bottom mark
+ {
+ ftext = strDownExpMark[i];
+ texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, Brushes.White);
+
+ cvs.DrawText(texte, new Point(bottomExpStep-8+i*bottomExpStep,this.ActualHeight+1));
+
+ }
+
+
+
+ }
+ break;
+ case GDSliderType.GDSLIDER_Dyn:
+ {
+
+ for (i = 0; i < strLeftDynMark.Length; i++) //left mark
+ {
+ ftext = strLeftDynMark[i];
+ texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, Brushes.White);
+
+ cvs.DrawText(texte, new Point(xleftOffset, i * leftDynStep));
+
+ }
+
+ for (i = 0; i < strDownDynMark.Length; i++) //bottom mark
+ {
+ ftext = strDownDynMark[i];
+ texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, Brushes.White);
+
+ cvs.DrawText(texte, new Point(bottomDynStep - 8 + i * bottomDynStep, this.ActualHeight + 1));
+
+ }
+
+ }
+ break;
+
+ }
+
+ }
+
+ ///
+ /// paint below..
+ ///
+ ///
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double wd = this.ActualWidth;
+ double ht = this.ActualHeight;
+ dc.DrawRectangle(BackBrush, new Pen(), new Rect(0, 0, wd, ht));
+ //
+ double K = 0;
+ double K1 = 0;
+ #region switch code to condition
+ switch (dp_GDSliderType)
+ {
+ case GDSliderType.GDSLIDER_Gate:
+ {
+
+
+ }
+ break;
+ case GDSliderType.GDSLIDER_Exp:
+ {
+ K = (double)ht / wd;
+ K1 = (double)1.0 / dynExpRatioTable[dp_gdRatioPos];
+ double vrStep = ht / dp_gdThresholdMax;
+
+ double m = (dp_gdThresholdMax - dp_gdThresholdPos) * vrStep;
+ double dt = K1 * (ht - m);
+ dPoints[0].X = wd - dt - m / K;
+ dPoints[0].Y = ht;
+ dPoints[1].X = dPoints[0].X + dt;
+ dPoints[1].Y = m;
+
+ if (dp_gdThresholdPos == 0)
+ {
+ dPoints[0].X = dPoints[1].X = 0;
+ dPoints[0].Y = dPoints[1].Y = ht;
+ }
+ else if (dp_gdThresholdPos == dp_gdThresholdMax)
+ {
+ dPoints[1].X = wd;
+ dPoints[1].Y = 0;
+ }
+
+ if (dp_gdRatioPos == dp_gdRatioMax)
+ {
+ dPoints[0].X = dPoints[1].X;
+ }
+ dPoints[2].X = wd;
+ dPoints[2].Y = 0;
+
+ }
+ break;
+
+ case GDSliderType.GDSLIDER_Dyn:
+ {
+
+ K = (double)ht / wd;
+ K1 = 1 / dynRatioTable[dp_gdRatioPos];
+ double vrStep = ht / dp_gdThresholdMax;
+ double h = (dp_gdThresholdMax - dp_gdThresholdPos) * vrStep;
+
+ dPoints[0].X = 0;
+ dPoints[0].Y = ht;
+
+ if (dp_gdThresholdPos == 0 && dp_gdRatioPos == 0)
+ {
+ dPoints[1].X = 0;
+ dPoints[1].Y = ht;
+ dPoints[2].X = wd;
+ dPoints[2].Y = 0;
+ }
+ else if (dp_gdRatioPos == 0 && dp_gdThresholdPos > 0 && dp_gdThresholdPos < dp_gdThresholdMax)
+ {
+
+ dPoints[1].X = wd - h / K;
+ dPoints[1].Y = h;
+
+ dPoints[2].X = wd;
+ dPoints[2].Y = 0;
+ }
+ else if (dp_gdRatioPos == 0 && (dp_gdThresholdPos == dp_gdThresholdMax))
+ {
+
+ dPoints[1].X = wd;
+ dPoints[1].Y = 0;
+ dPoints[2].X = wd;
+ dPoints[2].Y = 0;
+ }
+ else if (dp_gdRatioPos > 0 && dp_gdRatioPos < dp_gdRatioMax && dp_gdThresholdPos > 0 && dp_gdThresholdPos < dp_gdThresholdMax)
+ {
+
+ dPoints[1].X = (ht - h) / K;
+ dPoints[1].Y = h;
+ dPoints[2].X = wd;
+ dPoints[2].Y = h - K1 * (wd - dPoints[1].X);
+
+ }
+ else if (dp_gdRatioPos > 0 && dp_gdRatioPos < dp_gdRatioMax && dp_gdThresholdPos == dp_gdThresholdMax)
+ {
+
+ dPoints[1].X = wd;
+ dPoints[1].Y = 0;
+ dPoints[2].X = wd;
+ dPoints[2].Y = 0;
+
+ }
+ else if (dp_gdThresholdPos == 0 && dp_gdRatioPos > 0 && dp_gdRatioPos < dp_gdRatioMax)//thres=0 ratio!=0
+ {
+
+ dPoints[1].X = 0;
+ dPoints[1].Y = ht;
+ dPoints[2].X = wd;
+ dPoints[2].Y = ht - K1 * wd;
+
+ }
+ else if (dp_gdRatioPos == dp_gdRatioMax && dp_gdThresholdPos == dp_gdThresholdMax) //ratio max,thresMax
+ {
+ dPoints[1].X = wd;
+ dPoints[1].Y = 0;
+ dPoints[2].X = wd;
+ dPoints[2].Y = 0;
+ }
+ else if (dp_gdRatioPos == dp_gdRatioMax && dp_gdThresholdPos == 0) //ratio max
+ {
+ dPoints[1].X = wd;
+ dPoints[1].Y = ht;
+
+ dPoints[2].X = wd;
+ dPoints[2].Y = ht;
+
+ }
+ else if (dp_gdRatioPos == dp_gdRatioMax && dp_gdThresholdPos < dp_gdThresholdMax && dp_gdThresholdPos > 0)
+ {
+
+ dPoints[1].X = (ht - h) / K;
+ dPoints[1].Y = h;
+ dPoints[2].X = wd;
+ dPoints[2].Y = h - 2;
+
+ }
+
+
+
+ }
+ break;
+
+ }
+ #endregion
+ if (dPoints[0].X < 0) dPoints[0].X = 0;
+
+ dc.DrawLine(new Pen(penBrush, 1), dPoints[0], dPoints[1]);
+ dc.DrawLine(new Pen(penBrush, 1), dPoints[1], dPoints[2]);
+ // Debug.WriteLine("on render drawing now...................");
+
+ drawMark(dc);
+
+ }
+
+
+ ///
+
+ private static SolidColorBrush DefaultPen = Brushes.Yellow;
+ public SolidColorBrush penBrush
+ {
+ get { return (SolidColorBrush)GetValue(penBrushProperty); }
+ set { SetValue(penBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for penBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty penBrushProperty =
+ DependencyProperty.Register("penBrush", typeof(SolidColorBrush), typeof(CLimitGDSlider),
+
+ new FrameworkPropertyMetadata(DefaultPen, FrameworkPropertyMetadataOptions.None, onPenBrushChanged
+
+ ));
+
+ private static void onPenBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLimitGDSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.penBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/CLineArrow.cs b/LibControl/Controls/CLineArrow.cs
new file mode 100644
index 0000000..d0491ef
--- /dev/null
+++ b/LibControl/Controls/CLineArrow.cs
@@ -0,0 +1,257 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:LineArrowDemo"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:LineArrowDemo;assembly=LineArrowDemo"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ ///
+
+
+
+ public enum ArowType
+ {
+ Arow_Left = 98,
+ Arow_Right = 99
+ }
+
+ public class CLineArrow : Control
+ {
+
+ #region property define begin
+
+ private const int DefaultArrowLen = 18;
+ public int ArrowLength
+ {
+ get { return (int)GetValue(ArrowLengthProperty); }
+ set { SetValue(ArrowLengthProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for ArrowLength. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ArrowLengthProperty =
+ DependencyProperty.Register("ArrowLength", typeof(int), typeof(CLineArrow),
+
+ new FrameworkPropertyMetadata(DefaultArrowLen, FrameworkPropertyMetadataOptions.None, onArrowLenChange
+ ));
+
+ private static void onArrowLenChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLineArrow;
+ if (mcontrol != null)
+ {
+ mcontrol.ArrowLength= (int)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+ private const double DefaultRowAngle = 30;
+ public double RrowAngle
+ {
+ get { return (double)GetValue(RrowAngleProperty); }
+ set { SetValue(RrowAngleProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for RrowAngle. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty RrowAngleProperty =
+ DependencyProperty.Register("RrowAngle", typeof(double), typeof(CLineArrow),
+
+ new FrameworkPropertyMetadata(DefaultRowAngle, FrameworkPropertyMetadataOptions.None, onArrowAngleChange
+ ));
+
+ private static void onArrowAngleChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLineArrow;
+ if (mcontrol != null)
+ {
+ mcontrol.RrowAngle = (double)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+ private const ArowType DefaultFlag = ArowType.Arow_Left;
+ public ArowType ArowFlag
+ {
+ get { return (ArowType)GetValue(ArowFlagProperty); }
+ set { SetValue(ArowFlagProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for ArowFlag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ArowFlagProperty =
+ DependencyProperty.Register("ArowFlag", typeof(ArowType), typeof(CLineArrow),
+
+ new FrameworkPropertyMetadata(DefaultFlag, FrameworkPropertyMetadataOptions.None, onArrowTypeChange
+ ));
+
+ private static void onArrowTypeChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLineArrow;
+ if (mcontrol != null)
+ {
+ mcontrol.ArowFlag = (ArowType)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+ private static SolidColorBrush DefaultBorderBrush = Brushes.Black;
+
+ public SolidColorBrush ArowBorderBrush
+ {
+ get { return (SolidColorBrush)GetValue(ArowBorderBrushProperty); }
+ set { SetValue(ArowBorderBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for ArowBorderBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ArowBorderBrushProperty =
+ DependencyProperty.Register("ArowBorderBrush", typeof(SolidColorBrush), typeof(CLineArrow),
+
+ new FrameworkPropertyMetadata(DefaultFillBrush, FrameworkPropertyMetadataOptions.None, onBorderBrushChange
+ ));
+
+ private static void onBorderBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLineArrow;
+ if (mcontrol != null)
+ {
+ mcontrol.ArowBorderBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+ private static SolidColorBrush DefaultFillBrush = Brushes.Black;
+ public SolidColorBrush ArowFilBrush
+ {
+ get { return (SolidColorBrush)GetValue(ArowFilBrushProperty); }
+ set { SetValue(ArowFilBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for ArowFilBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ArowFilBrushProperty =
+ DependencyProperty.Register("ArowFilBrush", typeof(SolidColorBrush), typeof(CLineArrow),
+ new FrameworkPropertyMetadata(DefaultFillBrush, FrameworkPropertyMetadataOptions.None, onBackBrushChange
+ ));
+
+ private static void onBackBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CLineArrow;
+ if (mcontrol != null)
+ {
+ mcontrol.ArowFilBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.redraw();
+ }
+
+
+ }
+ #endregion
+
+ static CLineArrow()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CLineArrow), new FrameworkPropertyMetadata(typeof(CLineArrow)));
+ }
+
+
+ public void redraw()
+ {
+ this.InvalidateVisual();
+ }
+
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ //dc.DrawRectangle(BackBrush, new Pen(penBrush, borderThick), new Rect(0, 0, wd, ht));
+
+ int ax = ArrowLength;
+ double kb = ((double)RrowAngle / 180) * Math.PI;
+
+ kb = Math.Tan(kb);
+
+ Point[] pt = new Point[3];
+ if (ArowFlag == ArowType.Arow_Left)
+ {
+ pt[0].X = 0;
+ pt[1].X = ax;
+ }
+ else if (ArowFlag == ArowType.Arow_Right)
+ {
+ pt[0].X = wd;
+ pt[1].X = pt[0].X - ax;
+ }
+
+ pt[0].Y = ht / 2;
+ pt[1].Y = ht / 2 - kb * ax;
+
+ pt[2].X = pt[1].X;
+ pt[2].Y = ht - pt[1].Y;
+
+
+
+ #region draw triangle
+ StreamGeometry streamGtry = new StreamGeometry();
+
+ using (StreamGeometryContext gemContext = streamGtry.Open())
+ {
+ gemContext.BeginFigure(pt[0], true, true);
+ PointCollection poins = new PointCollection { pt[1], pt[2] };
+ gemContext.PolyLineTo(poins, true, true);
+ }
+ if(streamGtry!=null)
+ streamGtry.Freeze();
+ dc.DrawGeometry(ArowFilBrush, new Pen(ArowBorderBrush, 1), streamGtry);
+ #endregion
+
+ if (ArowFlag == ArowType.Arow_Left)
+ {
+ dc.DrawLine(new Pen(ArowFilBrush, 1), new Point(pt[1].X, pt[0].Y), new Point(wd, pt[0].Y));
+
+ }
+ else if (ArowFlag == ArowType.Arow_Right)
+ {
+ dc.DrawLine(new Pen(ArowFilBrush, 1), new Point(pt[1].X, pt[0].Y), new Point(0, pt[0].Y));
+ }
+
+
+ }
+ }
+}
diff --git a/LibControl/Controls/CMeter.cs b/LibControl/Controls/CMeter.cs
new file mode 100644
index 0000000..cafbd9f
--- /dev/null
+++ b/LibControl/Controls/CMeter.cs
@@ -0,0 +1,445 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows;
+using System.Windows.Media;
+using System.Diagnostics;
+using System.Globalization;
+
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:DrawDemo
+ *文件名: DrawClass
+ *版本号: V1.0.0.0
+ *唯一标识:29f6e020-b88a-4994-97fb-a7287a658814
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/24/2016 4:29:57 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/24/2016 4:29:57 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class CMeter : CommControl
+ {
+
+ public static int DefaultMaximum = 16;
+ public static double DefaultSegGap = 4.0;
+ public static SolidColorBrush DefaultBrush = Brushes.Gray;
+ public static SolidColorBrush DefaultLimitBrush = new SolidColorBrush(Color.FromRgb(255, 255, 0));
+ public static SolidColorBrush DefaultLightBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
+ public static SolidColorBrush DefaultClipBrush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
+ public static SolidColorBrush DefaultBackBrush = Brushes.Black;
+
+ #region about DependencyProperty define.................
+
+ public CMeter()
+ {
+
+ }
+ private static double DefaultDistanceGap = 2.0;
+ public double topDistanceGap
+ {
+ get { return (double)GetValue(topDistanceGapProperty); }
+ set { SetValue(topDistanceGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for topDistanceGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty topDistanceGapProperty =
+ DependencyProperty.Register("topDistanceGap", typeof(double), typeof(CMeter), new PropertyMetadata(DefaultDistanceGap));
+
+
+
+
+ public SolidColorBrush BackBroundBrush
+ {
+ get { return (SolidColorBrush)GetValue(BackBroundBrushProperty); }
+ set { SetValue(BackBroundBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BackBroundBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BackBroundBrushProperty =
+ DependencyProperty.Register("BackBroundBrush", typeof(SolidColorBrush),
+ typeof(CMeter), new PropertyMetadata(DefaultBackBrush));
+
+ public SolidColorBrush ClipBrush
+ {
+ get { return (SolidColorBrush)GetValue(ClipBrushProperty); }
+ set { SetValue(ClipBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for ClipBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ClipBrushProperty =
+ DependencyProperty.Register("ClipBrush", typeof(SolidColorBrush), typeof(CMeter), new PropertyMetadata(DefaultClipBrush));
+
+
+
+ public SolidColorBrush LimitBrush
+ {
+ get { return (SolidColorBrush)GetValue(LimitBrushProperty); }
+ set { SetValue(LimitBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LimitBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LimitBrushProperty =
+ DependencyProperty.Register("LimitBrush", typeof(SolidColorBrush), typeof(CMeter), new PropertyMetadata(DefaultLimitBrush));
+
+
+ public SolidColorBrush LightNormalBrush
+ {
+ get { return (SolidColorBrush)GetValue(LightNormalBrushProperty); }
+ set { SetValue(LightNormalBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LightNormalBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LightNormalBrushProperty =
+ DependencyProperty.Register("LightNormalBrush", typeof(SolidColorBrush), typeof(CMeter), new PropertyMetadata(DefaultLightBrush));
+
+ public SolidColorBrush UnlightBrush
+ {
+ get { return (SolidColorBrush)GetValue(UnlightBrushProperty); }
+ set { SetValue(UnlightBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for UnlightBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty UnlightBrushProperty =
+ DependencyProperty.Register("UnlightBrush", typeof(SolidColorBrush), typeof(CMeter), new PropertyMetadata(DefaultBrush));
+
+
+
+
+ public static int DefaultLimitSegNum = 3;
+ public static int DefaultClipSegNum = 2;
+
+ public int LimitSegNum
+ {
+ get { return (int)GetValue(LimitSegNumProperty); }
+ set { SetValue(LimitSegNumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LimitSegNum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LimitSegNumProperty =
+ DependencyProperty.Register("LimitSegNum", typeof(int), typeof(CMeter), new PropertyMetadata(DefaultLimitSegNum));
+
+
+
+ public int ClipSegNum
+ {
+ get { return (int)GetValue(ClipSegNumProperty); }
+ set { SetValue(ClipSegNumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for ClipSegNum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ClipSegNumProperty =
+ DependencyProperty.Register("ClipSegNum", typeof(int), typeof(CMeter), new PropertyMetadata(DefaultClipSegNum));
+
+
+
+
+ public double segGap
+ {
+ get { return (double)GetValue(segGapProperty); }
+ set { SetValue(segGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for segGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty segGapProperty =
+ DependencyProperty.Register("segGap", typeof(double), typeof(CMeter), new PropertyMetadata(DefaultSegGap));
+
+
+
+ public int Maximum
+ {
+ get { return (int)GetValue(MaxminumProperty); }
+ set { SetValue(MaxminumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for Maxminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MaxminumProperty =
+ DependencyProperty.Register("Maximum", typeof(int), typeof(CMeter), new PropertyMetadata(DefaultMaximum));
+
+
+
+ public int Minimum
+ {
+ get { return (int)GetValue(MinminumProperty); }
+ set { SetValue(MinminumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for Minminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MinminumProperty =
+ DependencyProperty.Register("Minimum", typeof(int), typeof(CMeter), new PropertyMetadata(0));
+
+
+ private static SolidColorBrush DefaultLbBrush = Brushes.Black;
+
+
+ public SolidColorBrush MarkBrush
+ {
+ get { return (SolidColorBrush)GetValue(MarkBrushProperty); }
+ set { SetValue(MarkBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MarkBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MarkBrushProperty =
+ DependencyProperty.Register("MarkBrush", typeof(SolidColorBrush), typeof(CMeter),
+ new FrameworkPropertyMetadata(DefaultLbBrush, FrameworkPropertyMetadataOptions.None, onMarkBrushChange
+ ));
+
+ private static void onMarkBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ CMeter meter = obj as CMeter;
+ if (meter != null)
+ {
+ meter.MarkBrush = (SolidColorBrush)args.NewValue;
+ meter.redraw();
+ }
+
+ }
+
+
+ private static int DefaultPosValue = 0;
+ public int posvalue
+ {
+ get { return (int)GetValue(posvalueProperty); }
+ set { SetValue(posvalueProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for posvalue. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty posvalueProperty =
+ DependencyProperty.Register("posvalue", typeof(int), typeof(CMeter),
+ new FrameworkPropertyMetadata(DefaultPosValue, FrameworkPropertyMetadataOptions.None, onPosValueChange
+ ));
+
+
+ private static void onPosValueChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ CMeter meter = obj as CMeter;
+ if (meter != null)
+ {
+ meter.posvalue = (int)args.NewValue;
+ meter.redraw();
+ }
+
+ }
+
+
+ private static bool DeafultLoopRevse = false;
+ public bool isLoopReverse
+ {
+ get { return (bool)GetValue(isLoopReverseProperty); }
+ set { SetValue(isLoopReverseProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isLoopReverse. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isLoopReverseProperty =
+ DependencyProperty.Register("isLoopReverse", typeof(bool), typeof(CMeter),
+ new FrameworkPropertyMetadata(DeafultLoopRevse, FrameworkPropertyMetadataOptions.None, onLoopReverse
+ ));
+ // new PropertyMetadata(DeafultLoopRevse));
+
+
+ private static void onLoopReverse(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ CMeter meter = obj as CMeter;
+ if (meter != null)
+ {
+ meter.isLoopReverse = (bool)args.NewValue;
+ meter.redraw();
+ }
+
+ }
+
+ #endregion
+
+ static CMeter()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CMeter), new FrameworkPropertyMetadata(typeof(CMeter)));
+ }
+
+
+
+
+ private const bool DefaultMarked = false;
+ public bool isEnableMark
+ {
+ get { return (bool)GetValue(isEnableMarkProperty); }
+ set { SetValue(isEnableMarkProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isEnableMark. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isEnableMarkProperty =
+ DependencyProperty.Register("isEnableMark", typeof(bool), typeof(CMeter), new PropertyMetadata(DefaultMarked));
+
+ //draw
+ ///
+ ///
+ ///
+ ///
+ ///
+ public string[] meterStr =
+ {
+ "clip",
+ "+14",
+ "+10",
+ " +6",
+ " +2",
+ " 0",
+ " -2",
+ " -4",
+ " -5",
+ "-15",
+ "-25",
+ "-40"
+ };
+
+ private double fontSize = 9;
+ private double markXoffset = -19;
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+ private void drawMark(DrawingContext dc)
+ {
+ double ht = this.ActualHeight;
+
+ if (isEnableMark)
+ {
+ FormattedText text = null;
+ double heightPerseg = (double)ht / Maximum - segGap;
+ double FontH = 12;
+ double ty = 0;
+ int len = meterStr.Length;
+ for (int i = 0; i < len; i++)
+ {
+ ty = topDistanceGap + (double)ht / Maximum *2* i + (heightPerseg - FontH) / 2;
+
+ text = new FormattedText(meterStr[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, MarkBrush);
+
+ dc.DrawText(text, new Point(markXoffset, ty));
+ }
+ }
+
+ }
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ dc.DrawRectangle(BackBroundBrush, new Pen(), new Rect(0, 0, wd, ht));
+ //Pen pen = new Pen(Brushes.Red, 1);
+ //dc.DrawLine(pen, new Point(15, 80), new Point(80, 150));
+ // this.UpdateLayout() relayout
+
+
+ // Debug.WriteLine("draw now.....with ...width height is :{0} {1} ", wd, ht);
+
+ double heightPerseg = (double)ht / Maximum - segGap;
+
+ drawMark(dc);
+
+ for (int i = 0; i < Maximum; i++)
+ {
+ Rect segRect = new Rect(1, topDistanceGap + (heightPerseg + segGap) * i, wd - 2, heightPerseg);
+ dc.DrawRectangle(UnlightBrush, new Pen(), segRect);
+
+ }
+ if (isLoopReverse) //from up to down
+ {
+
+ for (int i = 0; i < posvalue; i++) //first draw normal lighted led
+ {
+
+ Rect segRect = new Rect(1, topDistanceGap + (heightPerseg + segGap) * i, wd - 2, heightPerseg);
+ dc.DrawRectangle(LightNormalBrush, new Pen(), segRect);
+
+ }
+
+ if (posvalue > Maximum - (LimitSegNum + ClipSegNum)) //> normal led seg
+ {
+ for (int i = Maximum - (LimitSegNum + ClipSegNum); i < posvalue; i++)
+ {
+ Rect segRect = new Rect(1, topDistanceGap + (heightPerseg + segGap) * i, wd - 2, heightPerseg);
+ dc.DrawRectangle(LimitBrush, new Pen(), segRect);
+
+ }
+
+ }
+
+ if (posvalue >= Maximum - ClipSegNum)
+ {
+
+ for (int i = Maximum - ClipSegNum; i < posvalue; i++)
+ {
+
+ Rect segRect = new Rect(1, topDistanceGap + (heightPerseg + segGap) * i, wd - 2, heightPerseg);
+ dc.DrawRectangle(ClipBrush, new Pen(), segRect);
+
+ }
+
+
+ }
+
+ }
+ else
+ {
+
+ for (int i = 0; i < posvalue; i++) //first draw normal lighted led
+ {
+
+ Rect segRect = new Rect(1, ht + topDistanceGap - (heightPerseg + segGap) * (i + 1), wd - 2, heightPerseg);
+ dc.DrawRectangle(LightNormalBrush, new Pen(), segRect);
+
+ }
+
+ if (posvalue > Maximum - (LimitSegNum + ClipSegNum)) //> normal led seg
+ {
+ for (int i = Maximum - (LimitSegNum + ClipSegNum); i < posvalue; i++)
+ {
+ Rect segRect = new Rect(1, ht + topDistanceGap - (heightPerseg + segGap) * (i + 1), wd - 2, heightPerseg);
+ dc.DrawRectangle(LimitBrush, new Pen(), segRect);
+
+ }
+
+ }
+
+ if (posvalue >= Maximum - ClipSegNum)
+ {
+
+ for (int i = Maximum - ClipSegNum; i < posvalue; i++)
+ {
+ Rect segRect = new Rect(1, ht + topDistanceGap - (heightPerseg + segGap) * (i + 1), wd - 2, heightPerseg);
+ dc.DrawRectangle(ClipBrush, new Pen(), segRect);
+
+ }
+
+ }
+
+ }
+
+ }
+ public void redraw()
+ {
+ // Debug.WriteLine("readraw.....");
+ InvalidateVisual();
+ }
+
+ }
+}
diff --git a/LibControl/Controls/CSlider.cs b/LibControl/Controls/CSlider.cs
new file mode 100644
index 0000000..594e426
--- /dev/null
+++ b/LibControl/Controls/CSlider.cs
@@ -0,0 +1,791 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Diagnostics;
+using System.Windows.Media;
+using System.Windows.Input;
+using System.Globalization;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: SKillerView
+ *版本号: V1.0.0.0
+ *唯一标识:55ec11d9-4d2c-41cb-92be-b93c9f5b555b
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/29/2016 8:52:14 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/29/2016 8:52:14 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:if the object is
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class CSlider : Control
+ {
+ public static int DefaultMaximum = 100;
+ public static ImageSource DefaultImgsrc = null;
+ private static Color DefaultLineColor = Color.FromRgb(40, 40, 40);
+ private const double DefaultLineWidth = 1.0;
+ private static double DefaultTopGap = 15.0;
+ private static double DefaultBotomGap = 14.0;
+
+
+ private int _posvalue = 0;
+ private bool isTouched = false;
+ private const double offsetY = 3.0;
+ private int shift = 0;
+ private double step = 0;
+
+
+
+ private TextBlock numberLabel;
+ private double lastPosition = 0; //the posvalue last at position
+ private int lastPosValue = 0; //the posvalue last
+
+
+ private static Rect thumbRect = new Rect();
+
+ public delegate void sliderMouseDown(Object sender, EventArgs e);
+ public event sliderMouseDown onSliderMouseDownEvent;
+ //
+ public delegate void sliderMouseMove(Object sender, int newPos, EventArgs e);
+ public event sliderMouseMove onSliderMouseMoveEvent;
+
+
+ private const bool DefaultMark = false;
+ public bool isSupportMark
+ {
+ get { return (bool)GetValue(isSupportMarkProperty); }
+ set { SetValue(isSupportMarkProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isSupportMark. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isSupportMarkProperty =
+ DependencyProperty.Register("isSupportMark", typeof(bool), typeof(CSlider), new PropertyMetadata(DefaultMark));
+
+
+
+ private const double DefaultMarkStep = 6.0;
+ public double MarkStep
+ {
+ get { return (double)GetValue(MarkStepProperty); }
+ set { SetValue(MarkStepProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MarkStep. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MarkStepProperty =
+ DependencyProperty.Register("MarkStep", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultMarkStep, FrameworkPropertyMetadataOptions.None, onMarkStepChange
+ ));
+
+ private static void onMarkStepChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.MarkStep = (double)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ private const bool DefaultLineStyle = false;
+ public bool lineStyle
+ {
+ get { return (bool)GetValue(lineStyleProperty); }
+ set { SetValue(lineStyleProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for lineStyle. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty lineStyleProperty =
+ DependencyProperty.Register("lineStyle", typeof(bool), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultLineStyle, FrameworkPropertyMetadataOptions.None, onLineStyleChange));
+
+ private static void onLineStyleChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.lineStyle = (bool)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ static CSlider()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CSlider), new FrameworkPropertyMetadata(typeof(CSlider)));
+
+ }
+
+
+
+ public ImageSource thumb
+ {
+ get { return (ImageSource)GetValue(thumbProperty); }
+ set { SetValue(thumbProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for thumb. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty thumbProperty =
+ DependencyProperty.Register("thumb", typeof(ImageSource), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultImgsrc, FrameworkPropertyMetadataOptions.None, onThumbChange
+ ));
+
+ private static void onThumbChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+
+ mcontrol.thumb = (ImageSource)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+ private const bool DefaultIsVertial = true;
+ public bool isVerticalSlider
+ {
+ get { return (bool)GetValue(isVerticalSliderProperty); }
+ set { SetValue(isVerticalSliderProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isVerticalSlider. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isVerticalSliderProperty =
+ DependencyProperty.Register("isVerticalSlider", typeof(bool), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultIsVertial, FrameworkPropertyMetadataOptions.None, onSliderOrietainChange
+ ));
+ private static void onSliderOrietainChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse =
+ mcontrol.isVerticalSlider = (bool)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ ///
+ ///
+ ///
+ public Color LineColor
+ {
+ get { return (Color)GetValue(LineColorProperty); }
+ set { SetValue(LineColorProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LineColor. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LineColorProperty =
+ DependencyProperty.Register("LineColor", typeof(Color), typeof(CSlider), new PropertyMetadata(DefaultLineColor));
+
+
+
+
+ public double lineWidth
+ {
+ get { return (double)GetValue(lineWidthProperty); }
+ set { SetValue(lineWidthProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for lineWidth. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty lineWidthProperty =
+ DependencyProperty.Register("lineWidth", typeof(double), typeof(CSlider), new PropertyMetadata(DefaultLineWidth));
+
+
+
+ protected override void OnMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseDown(e);
+ // e.GetPosition()
+
+ Point pt = e.GetPosition(this);
+
+ if ((pt.Y >= (thumbRect.Top - offsetY)) && (pt.Y < (thumbRect.Top + thumbRect.Height + offsetY)))
+ {
+ isTouched = true;
+ if (isVerticalSlider)
+ {
+ lastPosition = pt.Y;
+ }
+ else
+ {
+ lastPosition = pt.X;
+
+ }
+ lastPosValue = Posvalue;//record the posvalue as save
+
+ redraw();
+ }
+ else
+ {
+ if (onSliderMouseDownEvent != null)
+ {
+ onSliderMouseDownEvent(this, new EventArgs());
+ }
+
+ }
+
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (!isTouched) return;
+ if (e.LeftButton == MouseButtonState.Released)
+ {
+ isTouched = false;
+ shift = 0;
+ return;
+ }
+ Point pt = e.GetPosition(this);
+ double deltaV = 0;
+ if (isVerticalSlider)
+ deltaV = pt.Y - lastPosition;
+ else
+ deltaV = pt.X - lastPosition;
+ shift = (int)(deltaV / step);
+
+ // int tmpValue=limitValue()
+ int tmpValue = 0;
+ if (isVerticalSlider)
+ tmpValue = Maximum - (lastPosValue + shift);
+ else
+ tmpValue = (lastPosValue + shift);
+ tmpValue = limitValue(tmpValue);
+ // Debug.WriteLine("shift is : {0}...step is : {1}..new value is.......", shift,step,tmpValue);
+ if (onSliderMouseMoveEvent != null)
+ {
+ onSliderMouseMoveEvent(this, tmpValue, new EventArgs());
+ }
+
+
+ }
+
+
+
+ //protected override void OnMouseLeave(MouseEventArgs e)
+ //{
+ // base.OnMouseLeave(e);
+ // Debug.WriteLine(" ");
+ // if (e.LeftButton == MouseButtonState.Released)
+ // {
+ // isTouched = false;
+ // shift = 0;
+ // }
+ //}
+
+ protected override void OnMouseUp(MouseButtonEventArgs e)
+ {
+ base.OnMouseUp(e);
+ // Debug.WriteLine("on mouse up...............");
+ isTouched = false;
+ shift = 0;
+ redraw();
+
+
+ }
+
+ public int Maximum
+ {
+ get { return (int)GetValue(MaxminumProperty); }
+ set { SetValue(MaxminumProperty, value); }
+ }
+
+
+ // Using a DependencyProperty as the backing store for Maxminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MaxminumProperty =
+ DependencyProperty.Register("Maximum", typeof(int), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultMaximum, FrameworkPropertyMetadataOptions.None, onMaximumChange
+ ));
+
+ private static void onMaximumChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+
+ if (mcontrol != null)
+ {
+ int tmax = (int)args.NewValue;
+ if (tmax > 0)
+ {
+ mcontrol.Maximum = tmax;
+ // Debug.WriteLine("maximum change.........................{0}", mcontrol.Maximum);
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+
+ }
+
+ }
+
+ public int Minimum
+ {
+ get { return (int)GetValue(MinminumProperty); }
+ set { SetValue(MinminumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for Minminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MinminumProperty =
+ DependencyProperty.Register("Minimum", typeof(int), typeof(CSlider), new PropertyMetadata(0));
+
+
+
+ public int Posvalue
+ {
+ get
+ {
+ return _posvalue;
+
+ }
+ set
+ {
+ setPosValue(value);
+ }
+ }
+
+ public void setPosValue(int mpos)
+ {
+ int mv = limitValue(mpos);
+ if (isVerticalSlider)
+ _posvalue = Maximum - mv;
+ else
+ _posvalue = mv;
+ redraw();
+ }
+
+
+ public int limitValue(int mva)
+ {
+ return Math.Max(Minimum, Math.Min(Maximum, mva));
+ }
+ //
+
+ public double TopGap
+ {
+ get { return (double)GetValue(TopGapProperty); }
+ set { SetValue(TopGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for TopGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty TopGapProperty =
+ DependencyProperty.Register("TopGap", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultTopGap, FrameworkPropertyMetadataOptions.None, onTopGapChange
+ ));
+
+ private static void onTopGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.TopGap = (double)args.NewValue;
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+ public double BottomGap
+ {
+ get { return (double)GetValue(BottomGapProperty); }
+ set { SetValue(BottomGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BottomGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BottomGapProperty =
+ DependencyProperty.Register("BottomGap", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultBotomGap, FrameworkPropertyMetadataOptions.None, onBotomGapChange
+ ));
+
+ private static void onBotomGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.BottomGap = (double)args.NewValue;
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+
+
+ }
+ //
+ public void recaculateThumb()
+ {
+ if (thumb != null)
+ {
+ thumbRect.Width = thumb.Width;
+ thumbRect.Height = thumb.Height;
+ if (isVerticalSlider)
+ {
+ thumbRect.X = (this.ActualWidth - thumb.Width) / 2 + xoffset;
+ thumbRect.Y = TopGap + Posvalue * step;
+
+ }
+ else //horizontal
+ {
+ thumbRect.X = TopGap + Posvalue * step;
+ thumbRect.Y = (this.ActualHeight - thumb.Height) / 2;
+
+ }
+ }
+ }
+
+ double precal(double k, int fbase)
+ {
+ int l;
+ double m;
+ int KG = (int)Math.Pow(10, fbase);
+ l = (int)(k * KG);
+ m = (double)l / KG;
+ return m;
+
+ }
+
+
+ private const double DefaultXoffset = 0;
+ public double xoffset
+ {
+ get { return (double)GetValue(xoffsetProperty); }
+ set { SetValue(xoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for xoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty xoffsetProperty =
+ DependencyProperty.Register("xoffset", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultXoffset, FrameworkPropertyMetadataOptions.None, onXoffsetChange
+ ));
+
+ private static void onXoffsetChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.xoffset = (double)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.redraw();
+ }
+
+
+ }
+
+
+ public void recaculate()
+ {
+
+ if (thumb != null && Maximum > 0)
+ {
+ double sliderRange = 0;
+ if (isVerticalSlider)
+ {
+ double ht = this.ActualHeight;
+ sliderRange = ht - TopGap - BottomGap - thumb.Height;
+ }
+ else
+ {
+ double wd = this.ActualWidth;
+ sliderRange = wd - TopGap - BottomGap - thumb.Width;
+ }
+
+ step = (double)sliderRange / Maximum;
+ // Debug.WriteLine(".xxx...cliser isvertical ? {0} step is {1}", isVerticalSlider, step);
+
+ }
+
+ }
+
+
+ private static SolidColorBrush DefaultBackBrush = new SolidColorBrush();
+
+ public SolidColorBrush BackBrush
+ {
+ get { return (SolidColorBrush)GetValue(BackBrushProperty); }
+ set { SetValue(BackBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BackBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BackBrushProperty =
+ DependencyProperty.Register("BackBrush", typeof(SolidColorBrush), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultBackBrush, FrameworkPropertyMetadataOptions.None, onBackBrushChange
+ ));
+
+ private static void onBackBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.BackBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.redraw();
+ }
+
+
+ }
+
+ public static string[] strMarkHR
+ = {
+
+ "-∞",
+ "-50",
+ "-40",
+ "-30",
+ "-20",
+ "-10",
+ "-5",
+ " 0",
+ " +5",
+ "dB",
+ "+15"
+
+ };
+
+ public static string[] strMarkVR
+ = {
+ "+15",
+ " dB",
+ " 0",
+ "-10",
+ "-20",
+ "-30",
+ "-40",
+ "-50",
+ "-60",
+ "-70",
+ "-80",
+ };
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+
+
+ private const double DefaultmarkXoffset = 4.0;
+ public double markXoffset
+ {
+ get { return (double)GetValue(markXoffsetProperty); }
+ set { SetValue(markXoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for markXoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty markXoffsetProperty =
+ DependencyProperty.Register("markXoffset", typeof(double), typeof(CSlider), new PropertyMetadata(DefaultmarkXoffset));
+
+
+ private double fontSize = 10;
+ private double markLineLengthVR = 8;
+ private double markLineHeightHR = 4;
+
+ private void drawMarkVR(DrawingContext dc)
+ {
+ int last = strMarkVR.Length - 1;
+ FormattedText text = null;
+
+ int len = strMarkVR.Length;
+ double wd = this.ActualWidth;
+
+ double markxoffsets = wd / 2 + xoffset - 5 - markLineLengthVR;
+ double markShortGap = 4.0;
+ double markYoffset = 2.0;
+ Pen tmpPen = new Pen(Brushes.Red, 1);
+ double tmpYset = TopGap + 8;
+ if (len > 0 && isSupportMark)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ if (i < len - 1)
+ {
+ text = new FormattedText(strMarkVR[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, Brushes.White);
+ }
+ else
+ {
+ text = new FormattedText(strMarkVR[last], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize + 2, Brushes.White);
+ }
+
+ if(i==2 || i==3)
+ dc.DrawText(text, new Point(markXoffset, (tmpYset + (MarkStep + 0.35) * i - 4)));
+ else
+ dc.DrawText(text, new Point(markXoffset, tmpYset + (MarkStep + 0.35) * i));
+#if _koc
+ if (i == 3)
+ tmpPen = new Pen(Brushes.Red, 1);
+ else
+ tmpPen = new Pen(Brushes.Black, 1);
+
+ dc.DrawLine(tmpPen, new Point(markxoffsets, MarkStep * i + tmpYset + markYoffset),
+ new Point(markxoffsets + markLineLengthVR - 2, MarkStep * i + tmpYset + markYoffset));
+
+ dc.DrawLine(tmpPen, new Point(markxoffsets, MarkStep * i + tmpYset + markShortGap + markYoffset),
+ new Point(markxoffsets + markLineLengthVR, MarkStep * i + tmpYset + markShortGap + markYoffset));
+#endif
+
+ }
+ }
+
+
+ }
+
+
+
+
+
+
+ private void drawMarkHR(DrawingContext dc)
+ {
+ int last = strMarkHR.Length - 1;
+ FormattedText text = null;
+
+ int len = strMarkHR.Length;
+ double ht = this.ActualHeight;
+ double markxoffsets = TopGap + 1;
+ double markYoffset = ht - markLineHeightHR;
+ Pen tmpPen = new Pen(Brushes.Red, 1);
+ if (len > 0 && isSupportMark)
+ {
+ //Debug.WriteLine("drawmark hr len is :{0}", len);
+ for (int k = 0; k <= len; k++)
+ {
+#if KOV
+ if (i >0)
+ {
+ text = new FormattedText(strMarkHR[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, Brushes.Black);
+
+
+
+ }
+ else
+ {
+ text = new FormattedText(strMarkHR[last], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize + 2, Brushes.Black);
+ }
+
+ dc.DrawText(text, new Point(markXoffset, (MarkStep) * i));
+#endif
+ if (k == len - 3)
+ tmpPen = new Pen(Brushes.Red, 1);
+ else
+ tmpPen = new Pen(Brushes.Black, 1);
+
+ double tmpX = markxoffsets + MarkStep * k - 3;
+ if (tmpX >= this.ActualWidth)
+ tmpX = this.ActualWidth - 5;
+
+ if (k > 0)
+ dc.DrawLine(tmpPen, new Point(tmpX, markYoffset - 2),
+ new Point(tmpX, markYoffset - 8));
+
+ tmpX = markxoffsets + MarkStep * k;
+ if (tmpX >= this.ActualWidth)
+ tmpX = this.ActualWidth - 2;
+ dc.DrawLine(tmpPen, new Point(tmpX, markYoffset),
+ new Point(tmpX, markYoffset - 8));
+
+ }
+ }
+
+
+ }
+
+ private const double trackRectangleXoffset = 4.0;
+ private const double trackRectangRadius = 3.0;
+ ///
+ ///
+ ///
+ ///
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ recaculate();
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ recaculateThumb();
+ if (isVerticalSlider)
+ MarkStep = (int)((ht - TopGap - BottomGap - thumb.Height) / (strMarkVR.Length - 1));
+ else //hr
+ MarkStep = (int)((wd - TopGap - BottomGap - thumb.Width) / (strMarkVR.Length - 1));
+
+ dc.DrawRectangle(BackBrush, new Pen(), new Rect(0, 0, wd, ht));
+
+
+ // Debug.WriteLine("cslider width is : {0} ,ht is :{1}", wd, ht);
+ Pen apen = new Pen(new SolidColorBrush(LineColor), lineWidth);
+ if (isVerticalSlider)
+ {
+ drawMarkVR(dc);
+ if (lineStyle)
+ {
+ dc.DrawLine(apen, new Point(wd / 2 + xoffset, TopGap), new Point(wd / 2 + xoffset, ht - BottomGap));
+ }
+ else
+ {
+
+ // Rect tmprect = new Rect(thumbRect.Left + trackRectangleXoffset, TopGap, thumbRect.Width - trackRectangleXoffset * 2, ht - BottomGap * 2);
+ // dc.DrawRoundedRectangle(Brushes.Transparent, apen, tmprect, trackRectangRadius, trackRectangRadius);
+ }
+
+ }
+ else
+ {
+ drawMarkHR(dc);
+ if (lineStyle)
+ dc.DrawLine(apen, new Point(TopGap, ht / 2), new Point(wd - BottomGap, ht / 2));
+ else
+ {
+
+ // Rect tmprect = new Rect(TopGap, thumbRect.Top + trackRectangleXoffset, wd - 2 * BottomGap, thumbRect.Height - trackRectangleXoffset * 2);
+ // dc.DrawRoundedRectangle(Brushes.Transparent, apen, tmprect, trackRectangRadius, trackRectangRadius);
+ }
+
+ }
+ dc.DrawImage(thumb, thumbRect);
+
+ }
+
+ ///
+ /// slider Tag here
+ ///
+ private const int DefaultTag = 0;
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(CSlider), new PropertyMetadata(DefaultTag));
+
+
+
+ public void redraw()
+ {
+ InvalidateVisual();
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/CSlider.cs~RF1f4137a.TMP b/LibControl/Controls/CSlider.cs~RF1f4137a.TMP
new file mode 100644
index 0000000..936ee6f
--- /dev/null
+++ b/LibControl/Controls/CSlider.cs~RF1f4137a.TMP
@@ -0,0 +1,798 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Diagnostics;
+using System.Windows.Media;
+using System.Windows.Input;
+using System.Globalization;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: SKillerView
+ *版本号: V1.0.0.0
+ *唯一标识:55ec11d9-4d2c-41cb-92be-b93c9f5b555b
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/29/2016 8:52:14 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/29/2016 8:52:14 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:if the object is
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class CSlider : Control
+ {
+ public static int DefaultMaximum = 100;
+ public static ImageSource DefaultImgsrc = null;
+ private static Color DefaultLineColor = Color.FromRgb(40, 40, 40);
+ private const double DefaultLineWidth = 1.0;
+ private static double DefaultTopGap = 15.0;
+ private static double DefaultBotomGap = 14.0;
+
+
+ private int _posvalue = 0;
+ private bool isTouched = false;
+ private const double offsetY = 3.0;
+ private int shift = 0;
+ private double step = 0;
+
+
+
+
+ private double lastPosition = 0; //the posvalue last at position
+ private int lastPosValue = 0; //the posvalue last
+
+
+ private static Rect thumbRect = new Rect();
+
+ public delegate void sliderMouseDown(Object sender, EventArgs e);
+ public event sliderMouseDown onSliderMouseDownEvent;
+ //
+ public delegate void sliderMouseMove(Object sender, int newPos, EventArgs e);
+ public event sliderMouseMove onSliderMouseMoveEvent;
+
+
+ private const bool DefaultMark = false;
+ public bool isSupportMark
+ {
+ get { return (bool)GetValue(isSupportMarkProperty); }
+ set { SetValue(isSupportMarkProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isSupportMark. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isSupportMarkProperty =
+ DependencyProperty.Register("isSupportMark", typeof(bool), typeof(CSlider), new PropertyMetadata(DefaultMark));
+
+
+
+ private const double DefaultMarkStep = 6.0;
+ public double MarkStep
+ {
+ get { return (double)GetValue(MarkStepProperty); }
+ set { SetValue(MarkStepProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MarkStep. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MarkStepProperty =
+ DependencyProperty.Register("MarkStep", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultMarkStep, FrameworkPropertyMetadataOptions.None, onMarkStepChange
+ ));
+
+ private static void onMarkStepChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.MarkStep = (double)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ private const bool DefaultLineStyle = false;
+ public bool lineStyle
+ {
+ get { return (bool)GetValue(lineStyleProperty); }
+ set { SetValue(lineStyleProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for lineStyle. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty lineStyleProperty =
+ DependencyProperty.Register("lineStyle", typeof(bool), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultLineStyle, FrameworkPropertyMetadataOptions.None, onLineStyleChange));
+
+ private static void onLineStyleChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.lineStyle = (bool)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ public CSlider()
+ {
+
+ }
+
+
+ static CSlider()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CSlider), new FrameworkPropertyMetadata(typeof(CSlider)));
+
+ }
+
+
+
+ public ImageSource thumb
+ {
+ get { return (ImageSource)GetValue(thumbProperty); }
+ set { SetValue(thumbProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for thumb. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty thumbProperty =
+ DependencyProperty.Register("thumb", typeof(ImageSource), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultImgsrc, FrameworkPropertyMetadataOptions.None, onThumbChange
+ ));
+
+ private static void onThumbChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+
+ mcontrol.thumb = (ImageSource)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+ private const bool DefaultIsVertial = true;
+ public bool isVerticalSlider
+ {
+ get { return (bool)GetValue(isVerticalSliderProperty); }
+ set { SetValue(isVerticalSliderProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isVerticalSlider. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isVerticalSliderProperty =
+ DependencyProperty.Register("isVerticalSlider", typeof(bool), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultIsVertial, FrameworkPropertyMetadataOptions.None, onSliderOrietainChange
+ ));
+ private static void onSliderOrietainChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse =
+ mcontrol.isVerticalSlider = (bool)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ ///
+ ///
+ ///
+ public Color LineColor
+ {
+ get { return (Color)GetValue(LineColorProperty); }
+ set { SetValue(LineColorProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LineColor. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LineColorProperty =
+ DependencyProperty.Register("LineColor", typeof(Color), typeof(CSlider), new PropertyMetadata(DefaultLineColor));
+
+
+
+
+ public double lineWidth
+ {
+ get { return (double)GetValue(lineWidthProperty); }
+ set { SetValue(lineWidthProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for lineWidth. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty lineWidthProperty =
+ DependencyProperty.Register("lineWidth", typeof(double), typeof(CSlider), new PropertyMetadata(DefaultLineWidth));
+
+
+
+ protected override void OnMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseDown(e);
+ // e.GetPosition()
+
+ Point pt = e.GetPosition(this);
+
+ if ((pt.Y >= (thumbRect.Top - offsetY)) && (pt.Y < (thumbRect.Top + thumbRect.Height + offsetY)))
+ {
+ isTouched = true;
+ if (isVerticalSlider)
+ {
+ lastPosition = pt.Y;
+ }
+ else
+ {
+ lastPosition = pt.X;
+
+ }
+ lastPosValue = Posvalue;//record the posvalue as save
+
+ redraw();
+ }
+ else
+ {
+ if (onSliderMouseDownEvent != null)
+ {
+ onSliderMouseDownEvent(this, new EventArgs());
+ }
+
+ }
+
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (!isTouched) return;
+ if (e.LeftButton == MouseButtonState.Released)
+ {
+ isTouched = false;
+ shift = 0;
+ return;
+ }
+ Point pt = e.GetPosition(this);
+ double deltaV = 0;
+ if (isVerticalSlider)
+ deltaV = pt.Y - lastPosition;
+ else
+ deltaV = pt.X - lastPosition;
+ shift = (int)(deltaV / step);
+
+ // int tmpValue=limitValue()
+ int tmpValue = 0;
+ if (isVerticalSlider)
+ tmpValue = Maximum - (lastPosValue + shift);
+ else
+ tmpValue = (lastPosValue + shift);
+ tmpValue = limitValue(tmpValue);
+ // Debug.WriteLine("shift is : {0}...step is : {1}..new value is.......", shift,step,tmpValue);
+ if (onSliderMouseMoveEvent != null)
+ {
+ onSliderMouseMoveEvent(this, tmpValue, new EventArgs());
+ }
+
+
+ }
+
+
+
+ //protected override void OnMouseLeave(MouseEventArgs e)
+ //{
+ // base.OnMouseLeave(e);
+ // Debug.WriteLine(" ");
+ // if (e.LeftButton == MouseButtonState.Released)
+ // {
+ // isTouched = false;
+ // shift = 0;
+ // }
+ //}
+
+ protected override void OnMouseUp(MouseButtonEventArgs e)
+ {
+ base.OnMouseUp(e);
+ // Debug.WriteLine("on mouse up...............");
+ isTouched = false;
+ shift = 0;
+ redraw();
+
+
+ }
+
+ public int Maximum
+ {
+ get { return (int)GetValue(MaxminumProperty); }
+ set { SetValue(MaxminumProperty, value); }
+ }
+
+
+ // Using a DependencyProperty as the backing store for Maxminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MaxminumProperty =
+ DependencyProperty.Register("Maximum", typeof(int), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultMaximum, FrameworkPropertyMetadataOptions.None, onMaximumChange
+ ));
+
+ private static void onMaximumChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+
+ if (mcontrol != null)
+ {
+ int tmax = (int)args.NewValue;
+ if (tmax > 0)
+ {
+ mcontrol.Maximum = tmax;
+ // Debug.WriteLine("maximum change.........................{0}", mcontrol.Maximum);
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+
+ }
+
+ }
+
+ public int Minimum
+ {
+ get { return (int)GetValue(MinminumProperty); }
+ set { SetValue(MinminumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for Minminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MinminumProperty =
+ DependencyProperty.Register("Minimum", typeof(int), typeof(CSlider), new PropertyMetadata(0));
+
+
+
+ public int Posvalue
+ {
+ get
+ {
+ return _posvalue;
+
+ }
+ set
+ {
+ setPosValue(value);
+ }
+ }
+
+ public void setPosValue(int mpos)
+ {
+ int mv = limitValue(mpos);
+ if (isVerticalSlider)
+ _posvalue = Maximum - mv;
+ else
+ _posvalue = mv;
+ redraw();
+ }
+
+
+ public int limitValue(int mva)
+ {
+ return Math.Max(Minimum, Math.Min(Maximum, mva));
+ }
+ //
+
+ public double TopGap
+ {
+ get { return (double)GetValue(TopGapProperty); }
+ set { SetValue(TopGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for TopGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty TopGapProperty =
+ DependencyProperty.Register("TopGap", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultTopGap, FrameworkPropertyMetadataOptions.None, onTopGapChange
+ ));
+
+ private static void onTopGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.TopGap = (double)args.NewValue;
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+ public double BottomGap
+ {
+ get { return (double)GetValue(BottomGapProperty); }
+ set { SetValue(BottomGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BottomGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BottomGapProperty =
+ DependencyProperty.Register("BottomGap", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultBotomGap, FrameworkPropertyMetadataOptions.None, onBotomGapChange
+ ));
+
+ private static void onBotomGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.BottomGap = (double)args.NewValue;
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+
+
+ }
+ //
+ public void recaculateThumb()
+ {
+ if (thumb != null)
+ {
+ thumbRect.Width = thumb.Width;
+ thumbRect.Height = thumb.Height;
+ if (isVerticalSlider)
+ {
+ thumbRect.X = (this.ActualWidth - thumb.Width) / 2 + xoffset;
+ thumbRect.Y = TopGap + Posvalue * step;
+
+ }
+ else //horizontal
+ {
+ thumbRect.X = TopGap + Posvalue * step;
+ thumbRect.Y = (this.ActualHeight - thumb.Height) / 2;
+
+ }
+ }
+ }
+
+ double precal(double k, int fbase)
+ {
+ int l;
+ double m;
+ int KG = (int)Math.Pow(10, fbase);
+ l = (int)(k * KG);
+ m = (double)l / KG;
+ return m;
+
+ }
+
+
+ private const double DefaultXoffset = 0;
+ public double xoffset
+ {
+ get { return (double)GetValue(xoffsetProperty); }
+ set { SetValue(xoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for xoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty xoffsetProperty =
+ DependencyProperty.Register("xoffset", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultXoffset, FrameworkPropertyMetadataOptions.None, onXoffsetChange
+ ));
+
+ private static void onXoffsetChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.xoffset = (double)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.redraw();
+ }
+
+
+ }
+
+
+ public void recaculate()
+ {
+
+ if (thumb != null && Maximum > 0)
+ {
+ double sliderRange = 0;
+ if (isVerticalSlider)
+ {
+ double ht = this.ActualHeight;
+ sliderRange = ht - TopGap - BottomGap - thumb.Height;
+ }
+ else
+ {
+ double wd = this.ActualWidth;
+ sliderRange = wd - TopGap - BottomGap - thumb.Width;
+ }
+
+ step = (double)sliderRange / Maximum;
+ // Debug.WriteLine(".xxx...cliser isvertical ? {0} step is {1}", isVerticalSlider, step);
+
+ }
+
+ }
+
+
+ private static SolidColorBrush DefaultBackBrush = new SolidColorBrush();
+
+ public SolidColorBrush BackBrush
+ {
+ get { return (SolidColorBrush)GetValue(BackBrushProperty); }
+ set { SetValue(BackBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BackBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BackBrushProperty =
+ DependencyProperty.Register("BackBrush", typeof(SolidColorBrush), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultBackBrush, FrameworkPropertyMetadataOptions.None, onBackBrushChange
+ ));
+
+ private static void onBackBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.BackBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.redraw();
+ }
+
+
+ }
+
+ public static string[] strMarkHR
+ = {
+
+ "-∞",
+ "-50",
+ "-40",
+ "-30",
+ "-20",
+ "-10",
+ "-5",
+ " 0",
+ " +5",
+ "dB",
+ "+15"
+
+ };
+
+ public static string[] strMarkVR
+ = {
+ "15",
+ "dB",
+ "+5",
+ " 0",
+ "-5",
+ "-10",
+ "-20",
+ "-30",
+ "-40",
+ "-50",
+ "-∞",
+ };
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+
+
+ private const double DefaultmarkXoffset = 4.0;
+ public double markXoffset
+ {
+ get { return (double)GetValue(markXoffsetProperty); }
+ set { SetValue(markXoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for markXoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty markXoffsetProperty =
+ DependencyProperty.Register("markXoffset", typeof(double), typeof(CSlider), new PropertyMetadata(DefaultmarkXoffset));
+
+
+ private double fontSize = 10;
+ private double markLineLengthVR = 8;
+ private double markLineHeightHR = 4;
+
+ private void drawMarkVR(DrawingContext dc)
+ {
+ int last = strMarkVR.Length - 1;
+ FormattedText text = null;
+
+ int len = strMarkVR.Length;
+ double wd = this.ActualWidth;
+
+ double markxoffsets = wd / 2 + xoffset - 5 - markLineLengthVR;
+ double markShortGap = 4.0;
+ double markYoffset = 2.0;
+ Pen tmpPen = new Pen(Brushes.Red, 1);
+ double tmpYset = TopGap + 8;
+ if (len > 0 && isSupportMark)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ if (i < len - 1)
+ {
+ text = new FormattedText(strMarkVR[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, Brushes.Black);
+
+
+
+ }
+ else
+ {
+ text = new FormattedText(strMarkVR[last], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize + 2, Brushes.Black);
+ }
+
+ dc.DrawText(text, new Point(markXoffset, tmpYset+(MarkStep) * i));
+#if _koc
+ if (i == 3)
+ tmpPen = new Pen(Brushes.Red, 1);
+ else
+ tmpPen = new Pen(Brushes.Black, 1);
+
+ dc.DrawLine(tmpPen, new Point(markxoffsets, MarkStep * i + tmpYset + markYoffset),
+ new Point(markxoffsets + markLineLengthVR - 2, MarkStep * i + tmpYset + markYoffset));
+
+ dc.DrawLine(tmpPen, new Point(markxoffsets, MarkStep * i + tmpYset + markShortGap + markYoffset),
+ new Point(markxoffsets + markLineLengthVR, MarkStep * i + tmpYset + markShortGap + markYoffset));
+#endif
+
+ }
+ }
+
+
+ }
+
+
+
+
+
+
+ private void drawMarkHR(DrawingContext dc)
+ {
+ int last = strMarkHR.Length - 1;
+ FormattedText text = null;
+
+ int len = strMarkHR.Length;
+ double ht = this.ActualHeight;
+ double markxoffsets = TopGap + 1;
+ double markYoffset = ht - markLineHeightHR;
+ Pen tmpPen = new Pen(Brushes.Red, 1);
+ if (len > 0 && isSupportMark)
+ {
+ //Debug.WriteLine("drawmark hr len is :{0}", len);
+ for (int k = 0; k <= len; k++)
+ {
+#if KOV
+ if (i >0)
+ {
+ text = new FormattedText(strMarkHR[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, Brushes.Black);
+
+
+
+ }
+ else
+ {
+ text = new FormattedText(strMarkHR[last], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize + 2, Brushes.Black);
+ }
+
+ dc.DrawText(text, new Point(markXoffset, (MarkStep) * i));
+#endif
+ if (k == len - 3)
+ tmpPen = new Pen(Brushes.Red, 1);
+ else
+ tmpPen = new Pen(Brushes.Black, 1);
+
+ double tmpX = markxoffsets + MarkStep * k-3;
+ if (tmpX >= this.ActualWidth)
+ tmpX =this.ActualWidth-5;
+
+ if(k>0)
+ dc.DrawLine(tmpPen, new Point(tmpX, markYoffset-2),
+ new Point(tmpX, markYoffset - 8));
+
+ tmpX = markxoffsets + MarkStep * k;
+ if (tmpX >= this.ActualWidth)
+ tmpX =this.ActualWidth-2;
+ dc.DrawLine(tmpPen, new Point(tmpX, markYoffset),
+ new Point(tmpX, markYoffset - 8));
+
+ }
+ }
+
+
+ }
+
+ private const double trackRectangleXoffset = 4.0;
+ private const double trackRectangRadius = 3.0;
+ ///
+ ///
+ ///
+ ///
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ recaculate();
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ recaculateThumb();
+ if (isVerticalSlider)
+ MarkStep = (int)((ht - TopGap - BottomGap - thumb.Height) / (strMarkVR.Length - 1));
+ else //hr
+ MarkStep = (int)((wd - TopGap - BottomGap - thumb.Width) / (strMarkVR.Length - 1));
+
+ dc.DrawRectangle(BackBrush, new Pen(), new Rect(0, 0, wd, ht));
+
+
+ // Debug.WriteLine("cslider width is : {0} ,ht is :{1}", wd, ht);
+ Pen apen = new Pen(new SolidColorBrush(LineColor), lineWidth);
+ if (isVerticalSlider)
+ {
+ drawMarkVR(dc);
+ if (lineStyle)
+ {
+ dc.DrawLine(apen, new Point(wd / 2 + xoffset, TopGap), new Point(wd / 2 + xoffset, ht - BottomGap));
+ }
+ else
+ {
+
+ Rect tmprect = new Rect(thumbRect.Left + trackRectangleXoffset, TopGap, thumbRect.Width - trackRectangleXoffset * 2, ht - BottomGap * 2);
+ dc.DrawRoundedRectangle(Brushes.Transparent, apen, tmprect, trackRectangRadius, trackRectangRadius);
+ }
+
+ }
+ else
+ {
+ drawMarkHR(dc);
+
+ if (lineStyle)
+ dc.DrawLine(apen, new Point(TopGap, ht / 2), new Point(wd - BottomGap, ht / 2));
+ else
+ {
+
+ Rect tmprect = new Rect(TopGap, thumbRect.Top + trackRectangleXoffset, wd - 2 * BottomGap, thumbRect.Height - trackRectangleXoffset * 2);
+ dc.DrawRoundedRectangle(Brushes.Transparent, apen, tmprect, trackRectangRadius, trackRectangRadius);
+ }
+
+ }
+ dc.DrawImage(thumb, thumbRect);
+
+ }
+
+ ///
+ /// slider Tag here
+ ///
+ private const int DefaultTag = 0;
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(CSlider), new PropertyMetadata(DefaultTag));
+
+
+
+ public void redraw()
+ {
+ InvalidateVisual();
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/CSlider_back.cs b/LibControl/Controls/CSlider_back.cs
new file mode 100644
index 0000000..b4991b9
--- /dev/null
+++ b/LibControl/Controls/CSlider_back.cs
@@ -0,0 +1,795 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Diagnostics;
+using System.Windows.Media;
+using System.Windows.Input;
+using System.Globalization;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: SKillerView
+ *版本号: V1.0.0.0
+ *唯一标识:55ec11d9-4d2c-41cb-92be-b93c9f5b555b
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/29/2016 8:52:14 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/29/2016 8:52:14 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:if the object is
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class CSlider : Control
+ {
+ public static int DefaultMaximum = 100;
+ public static ImageSource DefaultImgsrc = null;
+ private static Color DefaultLineColor = Color.FromRgb(40, 40, 40);
+ private const double DefaultLineWidth = 1.0;
+ private static double DefaultTopGap = 15.0;
+ private static double DefaultBotomGap = 14.0;
+
+
+ private int _posvalue = 0;
+ private bool isTouched = false;
+ private const double offsetY = 3.0;
+ private int shift = 0;
+ private double step = 0;
+
+
+
+ private TextBlock numberLabel;
+ private double lastPosition = 0; //the posvalue last at position
+ private int lastPosValue = 0; //the posvalue last
+
+
+ private static Rect thumbRect = new Rect();
+
+ public delegate void sliderMouseDown(Object sender, EventArgs e);
+ public event sliderMouseDown onSliderMouseDownEvent;
+ //
+ public delegate void sliderMouseMove(Object sender, int newPos, EventArgs e);
+ public event sliderMouseMove onSliderMouseMoveEvent;
+
+
+ private const bool DefaultMark = false;
+ public bool isSupportMark
+ {
+ get { return (bool)GetValue(isSupportMarkProperty); }
+ set { SetValue(isSupportMarkProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isSupportMark. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isSupportMarkProperty =
+ DependencyProperty.Register("isSupportMark", typeof(bool), typeof(CSlider), new PropertyMetadata(DefaultMark));
+
+
+
+ private const double DefaultMarkStep = 6.0;
+ public double MarkStep
+ {
+ get { return (double)GetValue(MarkStepProperty); }
+ set { SetValue(MarkStepProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MarkStep. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MarkStepProperty =
+ DependencyProperty.Register("MarkStep", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultMarkStep, FrameworkPropertyMetadataOptions.None, onMarkStepChange
+ ));
+
+ private static void onMarkStepChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.MarkStep = (double)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ private const bool DefaultLineStyle = false;
+ public bool lineStyle
+ {
+ get { return (bool)GetValue(lineStyleProperty); }
+ set { SetValue(lineStyleProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for lineStyle. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty lineStyleProperty =
+ DependencyProperty.Register("lineStyle", typeof(bool), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultLineStyle, FrameworkPropertyMetadataOptions.None, onLineStyleChange));
+
+ private static void onLineStyleChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.lineStyle = (bool)args.NewValue;
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ static CSlider()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CSlider), new FrameworkPropertyMetadata(typeof(CSlider)));
+
+ }
+
+
+
+ public ImageSource thumb
+ {
+ get { return (ImageSource)GetValue(thumbProperty); }
+ set { SetValue(thumbProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for thumb. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty thumbProperty =
+ DependencyProperty.Register("thumb", typeof(ImageSource), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultImgsrc, FrameworkPropertyMetadataOptions.None, onThumbChange
+ ));
+
+ private static void onThumbChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+
+ mcontrol.thumb = (ImageSource)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+ private const bool DefaultIsVertial = true;
+ public bool isVerticalSlider
+ {
+ get { return (bool)GetValue(isVerticalSliderProperty); }
+ set { SetValue(isVerticalSliderProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isVerticalSlider. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isVerticalSliderProperty =
+ DependencyProperty.Register("isVerticalSlider", typeof(bool), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultIsVertial, FrameworkPropertyMetadataOptions.None, onSliderOrietainChange
+ ));
+ private static void onSliderOrietainChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse =
+ mcontrol.isVerticalSlider = (bool)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+
+ ///
+ ///
+ ///
+ public Color LineColor
+ {
+ get { return (Color)GetValue(LineColorProperty); }
+ set { SetValue(LineColorProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LineColor. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LineColorProperty =
+ DependencyProperty.Register("LineColor", typeof(Color), typeof(CSlider), new PropertyMetadata(DefaultLineColor));
+
+
+
+
+ public double lineWidth
+ {
+ get { return (double)GetValue(lineWidthProperty); }
+ set { SetValue(lineWidthProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for lineWidth. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty lineWidthProperty =
+ DependencyProperty.Register("lineWidth", typeof(double), typeof(CSlider), new PropertyMetadata(DefaultLineWidth));
+
+
+
+ protected override void OnMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseDown(e);
+ // e.GetPosition()
+
+ Point pt = e.GetPosition(this);
+
+ if ((pt.Y >= (thumbRect.Top - offsetY)) && (pt.Y < (thumbRect.Top + thumbRect.Height + offsetY)))
+ {
+ isTouched = true;
+ if (isVerticalSlider)
+ {
+ lastPosition = pt.Y;
+ }
+ else
+ {
+ lastPosition = pt.X;
+
+ }
+ lastPosValue = Posvalue;//record the posvalue as save
+
+ redraw();
+ }
+ else
+ {
+ if (onSliderMouseDownEvent != null)
+ {
+ onSliderMouseDownEvent(this, new EventArgs());
+ }
+
+ }
+
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (!isTouched) return;
+ if (e.LeftButton == MouseButtonState.Released)
+ {
+ isTouched = false;
+ shift = 0;
+ return;
+ }
+ Point pt = e.GetPosition(this);
+ double deltaV = 0;
+ if (isVerticalSlider)
+ deltaV = pt.Y - lastPosition;
+ else
+ deltaV = pt.X - lastPosition;
+ shift = (int)(deltaV / step);
+
+ // int tmpValue=limitValue()
+ int tmpValue = 0;
+ if (isVerticalSlider)
+ tmpValue = Maximum - (lastPosValue + shift);
+ else
+ tmpValue = (lastPosValue + shift);
+ tmpValue = limitValue(tmpValue);
+ // Debug.WriteLine("shift is : {0}...step is : {1}..new value is.......", shift,step,tmpValue);
+ if (onSliderMouseMoveEvent != null)
+ {
+ onSliderMouseMoveEvent(this, tmpValue, new EventArgs());
+ }
+
+
+ }
+
+
+
+ //protected override void OnMouseLeave(MouseEventArgs e)
+ //{
+ // base.OnMouseLeave(e);
+ // Debug.WriteLine(" ");
+ // if (e.LeftButton == MouseButtonState.Released)
+ // {
+ // isTouched = false;
+ // shift = 0;
+ // }
+ //}
+
+ protected override void OnMouseUp(MouseButtonEventArgs e)
+ {
+ base.OnMouseUp(e);
+ // Debug.WriteLine("on mouse up...............");
+ isTouched = false;
+ shift = 0;
+ redraw();
+
+
+ }
+
+ public int Maximum
+ {
+ get { return (int)GetValue(MaxminumProperty); }
+ set { SetValue(MaxminumProperty, value); }
+ }
+
+
+ // Using a DependencyProperty as the backing store for Maxminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MaxminumProperty =
+ DependencyProperty.Register("Maximum", typeof(int), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultMaximum, FrameworkPropertyMetadataOptions.None, onMaximumChange
+ ));
+
+ private static void onMaximumChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+
+ if (mcontrol != null)
+ {
+ int tmax = (int)args.NewValue;
+ if (tmax > 0)
+ {
+ mcontrol.Maximum = tmax;
+ // Debug.WriteLine("maximum change.........................{0}", mcontrol.Maximum);
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+
+ }
+
+ }
+
+ public int Minimum
+ {
+ get { return (int)GetValue(MinminumProperty); }
+ set { SetValue(MinminumProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for Minminum. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MinminumProperty =
+ DependencyProperty.Register("Minimum", typeof(int), typeof(CSlider), new PropertyMetadata(0));
+
+
+
+ public int Posvalue
+ {
+ get
+ {
+ return _posvalue;
+
+ }
+ set
+ {
+ setPosValue(value);
+ }
+ }
+
+ public void setPosValue(int mpos)
+ {
+ int mv = limitValue(mpos);
+ if (isVerticalSlider)
+ _posvalue = Maximum - mv;
+ else
+ _posvalue = mv;
+ redraw();
+ }
+
+
+ public int limitValue(int mva)
+ {
+ return Math.Max(Minimum, Math.Min(Maximum, mva));
+ }
+ //
+
+ public double TopGap
+ {
+ get { return (double)GetValue(TopGapProperty); }
+ set { SetValue(TopGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for TopGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty TopGapProperty =
+ DependencyProperty.Register("TopGap", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultTopGap, FrameworkPropertyMetadataOptions.None, onTopGapChange
+ ));
+
+ private static void onTopGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.TopGap = (double)args.NewValue;
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+ }
+
+
+ public double BottomGap
+ {
+ get { return (double)GetValue(BottomGapProperty); }
+ set { SetValue(BottomGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BottomGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BottomGapProperty =
+ DependencyProperty.Register("BottomGap", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultBotomGap, FrameworkPropertyMetadataOptions.None, onBotomGapChange
+ ));
+
+ private static void onBotomGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.BottomGap = (double)args.NewValue;
+ mcontrol.recaculate();
+ mcontrol.redraw();
+ }
+
+
+ }
+ //
+ public void recaculateThumb()
+ {
+ if (thumb != null)
+ {
+ thumbRect.Width = thumb.Width;
+ thumbRect.Height = thumb.Height;
+ if (isVerticalSlider)
+ {
+ thumbRect.X = (this.ActualWidth - thumb.Width) / 2 + xoffset;
+ thumbRect.Y = TopGap + Posvalue * step;
+
+ }
+ else //horizontal
+ {
+ thumbRect.X = TopGap + Posvalue * step;
+ thumbRect.Y = (this.ActualHeight - thumb.Height) / 2;
+
+ }
+ }
+ }
+
+ double precal(double k, int fbase)
+ {
+ int l;
+ double m;
+ int KG = (int)Math.Pow(10, fbase);
+ l = (int)(k * KG);
+ m = (double)l / KG;
+ return m;
+
+ }
+
+
+ private const double DefaultXoffset = 0;
+ public double xoffset
+ {
+ get { return (double)GetValue(xoffsetProperty); }
+ set { SetValue(xoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for xoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty xoffsetProperty =
+ DependencyProperty.Register("xoffset", typeof(double), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultXoffset, FrameworkPropertyMetadataOptions.None, onXoffsetChange
+ ));
+
+ private static void onXoffsetChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.xoffset = (double)args.NewValue;
+ mcontrol.recaculateThumb();
+ mcontrol.redraw();
+ }
+
+
+ }
+
+
+ public void recaculate()
+ {
+
+ if (thumb != null && Maximum > 0)
+ {
+ double sliderRange = 0;
+ if (isVerticalSlider)
+ {
+ double ht = this.ActualHeight;
+ sliderRange = ht - TopGap - BottomGap - thumb.Height;
+ }
+ else
+ {
+ double wd = this.ActualWidth;
+ sliderRange = wd - TopGap - BottomGap - thumb.Width;
+ }
+
+ step = (double)sliderRange / Maximum;
+ // Debug.WriteLine(".xxx...cliser isvertical ? {0} step is {1}", isVerticalSlider, step);
+
+ }
+
+ }
+
+
+ private static SolidColorBrush DefaultBackBrush = new SolidColorBrush();
+
+ public SolidColorBrush BackBrush
+ {
+ get { return (SolidColorBrush)GetValue(BackBrushProperty); }
+ set { SetValue(BackBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BackBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BackBrushProperty =
+ DependencyProperty.Register("BackBrush", typeof(SolidColorBrush), typeof(CSlider),
+ new FrameworkPropertyMetadata(DefaultBackBrush, FrameworkPropertyMetadataOptions.None, onBackBrushChange
+ ));
+
+ private static void onBackBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CSlider;
+ if (mcontrol != null)
+ {
+ mcontrol.BackBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.redraw();
+ }
+
+
+ }
+
+ public static string[] strMarkHR
+ = {
+
+ "-∞",
+ "-50",
+ "-40",
+ "-30",
+ "-20",
+ "-10",
+ "-5",
+ " 0",
+ " +5",
+ "dB",
+ "+15"
+
+ };
+
+ public static string[] strMarkVR
+ = {
+ "+15",
+ " dB",
+ " 0",
+ "-10",
+ "-20",
+ "-30",
+ "-40",
+ "-50",
+ "-60",
+ "-70",
+ "-80",
+ };
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+
+
+ private const double DefaultmarkXoffset = 4.0;
+ public double markXoffset
+ {
+ get { return (double)GetValue(markXoffsetProperty); }
+ set { SetValue(markXoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for markXoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty markXoffsetProperty =
+ DependencyProperty.Register("markXoffset", typeof(double), typeof(CSlider), new PropertyMetadata(DefaultmarkXoffset));
+
+
+ private double fontSize = 10;
+ private double markLineLengthVR = 8;
+ private double markLineHeightHR = 4;
+
+ private void drawMarkVR(DrawingContext dc)
+ {
+ int last = strMarkVR.Length - 1;
+ FormattedText text = null;
+
+ int len = strMarkVR.Length;
+ double wd = this.ActualWidth;
+
+ double markxoffsets = wd / 2 + xoffset - 5 - markLineLengthVR;
+ double markShortGap = 4.0;
+ double markYoffset = 2.0;
+ Pen tmpPen = new Pen(Brushes.Red, 1);
+ double tmpYset = TopGap + 8;
+ if (len > 0 && isSupportMark)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ if (i < len - 1)
+ {
+ text = new FormattedText(strMarkVR[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, Brushes.Black);
+
+
+
+ }
+ else
+ {
+ text = new FormattedText(strMarkVR[last], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize + 2, Brushes.Black);
+ }
+
+ if(i==2 || i==3)
+ dc.DrawText(text, new Point(markXoffset, (tmpYset + (MarkStep + 0.35) * i - 4)));
+ else
+ dc.DrawText(text, new Point(markXoffset, tmpYset + (MarkStep + 0.35) * i));
+#if _koc
+ if (i == 3)
+ tmpPen = new Pen(Brushes.Red, 1);
+ else
+ tmpPen = new Pen(Brushes.Black, 1);
+
+ dc.DrawLine(tmpPen, new Point(markxoffsets, MarkStep * i + tmpYset + markYoffset),
+ new Point(markxoffsets + markLineLengthVR - 2, MarkStep * i + tmpYset + markYoffset));
+
+ dc.DrawLine(tmpPen, new Point(markxoffsets, MarkStep * i + tmpYset + markShortGap + markYoffset),
+ new Point(markxoffsets + markLineLengthVR, MarkStep * i + tmpYset + markShortGap + markYoffset));
+#endif
+
+ }
+ }
+
+
+ }
+
+
+
+
+
+
+ private void drawMarkHR(DrawingContext dc)
+ {
+ int last = strMarkHR.Length - 1;
+ FormattedText text = null;
+
+ int len = strMarkHR.Length;
+ double ht = this.ActualHeight;
+ double markxoffsets = TopGap + 1;
+ double markYoffset = ht - markLineHeightHR;
+ Pen tmpPen = new Pen(Brushes.Red, 1);
+ if (len > 0 && isSupportMark)
+ {
+ //Debug.WriteLine("drawmark hr len is :{0}", len);
+ for (int k = 0; k <= len; k++)
+ {
+#if KOV
+ if (i >0)
+ {
+ text = new FormattedText(strMarkHR[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize, Brushes.Black);
+
+
+
+ }
+ else
+ {
+ text = new FormattedText(strMarkHR[last], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontSize + 2, Brushes.Black);
+ }
+
+ dc.DrawText(text, new Point(markXoffset, (MarkStep) * i));
+#endif
+ if (k == len - 3)
+ tmpPen = new Pen(Brushes.Red, 1);
+ else
+ tmpPen = new Pen(Brushes.Black, 1);
+
+ double tmpX = markxoffsets + MarkStep * k - 3;
+ if (tmpX >= this.ActualWidth)
+ tmpX = this.ActualWidth - 5;
+
+ if (k > 0)
+ dc.DrawLine(tmpPen, new Point(tmpX, markYoffset - 2),
+ new Point(tmpX, markYoffset - 8));
+
+ tmpX = markxoffsets + MarkStep * k;
+ if (tmpX >= this.ActualWidth)
+ tmpX = this.ActualWidth - 2;
+ dc.DrawLine(tmpPen, new Point(tmpX, markYoffset),
+ new Point(tmpX, markYoffset - 8));
+
+ }
+ }
+
+
+ }
+
+ private const double trackRectangleXoffset = 4.0;
+ private const double trackRectangRadius = 3.0;
+ ///
+ ///
+ ///
+ ///
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ recaculate();
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ recaculateThumb();
+ if (isVerticalSlider)
+ MarkStep = (int)((ht - TopGap - BottomGap - thumb.Height) / (strMarkVR.Length - 1));
+ else //hr
+ MarkStep = (int)((wd - TopGap - BottomGap - thumb.Width) / (strMarkVR.Length - 1));
+
+ dc.DrawRectangle(BackBrush, new Pen(), new Rect(0, 0, wd, ht));
+
+
+ // Debug.WriteLine("cslider width is : {0} ,ht is :{1}", wd, ht);
+ Pen apen = new Pen(new SolidColorBrush(LineColor), lineWidth);
+ if (isVerticalSlider)
+ {
+ drawMarkVR(dc);
+ if (lineStyle)
+ {
+ dc.DrawLine(apen, new Point(wd / 2 + xoffset, TopGap), new Point(wd / 2 + xoffset, ht - BottomGap));
+ }
+ else
+ {
+
+ Rect tmprect = new Rect(thumbRect.Left + trackRectangleXoffset, TopGap, thumbRect.Width - trackRectangleXoffset * 2, ht - BottomGap * 2);
+ dc.DrawRoundedRectangle(Brushes.Transparent, apen, tmprect, trackRectangRadius, trackRectangRadius);
+ }
+
+ }
+ else
+ {
+ drawMarkHR(dc);
+
+ if (lineStyle)
+ dc.DrawLine(apen, new Point(TopGap, ht / 2), new Point(wd - BottomGap, ht / 2));
+ else
+ {
+
+ Rect tmprect = new Rect(TopGap, thumbRect.Top + trackRectangleXoffset, wd - 2 * BottomGap, thumbRect.Height - trackRectangleXoffset * 2);
+ dc.DrawRoundedRectangle(Brushes.Transparent, apen, tmprect, trackRectangRadius, trackRectangRadius);
+ }
+
+ }
+ dc.DrawImage(thumb, thumbRect);
+
+ }
+
+ ///
+ /// slider Tag here
+ ///
+ private const int DefaultTag = 0;
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(CSlider), new PropertyMetadata(DefaultTag));
+
+
+
+ public void redraw()
+ {
+ InvalidateVisual();
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/CSwitcher.cs b/LibControl/Controls/CSwitcher.cs
new file mode 100644
index 0000000..2993f06
--- /dev/null
+++ b/LibControl/Controls/CSwitcher.cs
@@ -0,0 +1,225 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Diagnostics;
+using System.ComponentModel;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls;assembly=Lib.Controls"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ public class CSwitcher : Button
+ {
+
+ static CSwitcher()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CSwitcher), new FrameworkPropertyMetadata(typeof(CSwitcher)));
+ }
+
+
+ [Category("CSwitcher")]
+ public CSwitcher()
+ {
+ // Color
+ }
+
+
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(CSwitcher), new PropertyMetadata(0));
+
+
+
+ ///
+ /// default brush
+ ///
+ private static SolidColorBrush DefaultActiveBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0, 255, 0));
+ private static SolidColorBrush DefaultUActiveBrush = new SolidColorBrush(Color.FromArgb(0xFF, 212, 208, 200));
+
+ public Brush activeBrush
+ {
+ get { return (Brush)GetValue(activeBrushPropertyProperty); }
+ set { SetValue(activeBrushPropertyProperty, value); }
+
+
+ }
+
+ // Using a DependencyProperty as the backing store for activeBrushProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty activeBrushPropertyProperty =
+ DependencyProperty.Register("activeBrush",
+ typeof(Brush), typeof(CSwitcher),
+ new FrameworkPropertyMetadata(DefaultActiveBrush,
+ FrameworkPropertyMetadataOptions.None, OnActiveBrushChanged));
+
+
+
+
+ public Brush unActiveBrush
+ {
+ get { return (Brush)GetValue(unActiveBrushPropertyProperty); }
+ set { SetValue(unActiveBrushPropertyProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeBrushProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty unActiveBrushPropertyProperty =
+ DependencyProperty.Register("unActiveBrush",
+ typeof(Brush), typeof(CSwitcher),
+ new FrameworkPropertyMetadata(DefaultUActiveBrush,
+ FrameworkPropertyMetadataOptions.None, OnUnactiveBrushChanged));
+
+
+ //new PropertyMetadata(DefaultUActiveBrush));
+ private static void OnActiveBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var btn = obj as CSwitcher;
+ if (btn != null)
+ {
+ var newValue = (Brush)args.NewValue;
+ var oldValue = (Brush)args.OldValue;
+ btn.activeBrush = newValue;
+ btn.updateBrushWithValue();
+ }
+
+ }
+
+ private static void OnUnactiveBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var btn = obj as CSwitcher;
+ if (btn != null)
+ {
+ var newValue = (Brush)args.NewValue;
+ var oldValue = (Brush)args.OldValue;
+ btn.unActiveBrush = newValue;
+ btn.updateBrushWithValue();
+ }
+ }
+
+
+ ///
+ /// registry a property for just bool isselected
+ ///
+ public bool IsSelected
+ {
+ get { return (bool)GetValue(IsSelectedPropertyProperty); }
+ set { SetValue(IsSelectedPropertyProperty, value); }
+
+ }
+ // Using a DependencyProperty as the backing store for IsSelectedProperty. This enables animation, styling, binding, etc...
+ //public static readonly DependencyProperty IsSelectedPropertyProperty =
+ // DependencyProperty.Register("IsSelectedProperty", typeof(bool), typeof(CSwitcher), new PropertyMetadata(0));
+
+ private static bool DefaultValue = false;
+
+ private static readonly DependencyProperty IsSelectedPropertyProperty =
+ DependencyProperty.Register("IsSelected", typeof(bool), typeof(CSwitcher),
+ new FrameworkPropertyMetadata(DefaultValue,
+ FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
+ OnSelectedChanged
+ ));
+
+
+ private static void OnSelectedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var btn = obj as CSwitcher;
+ if (btn != null)
+ {
+ var newValue = (bool)args.NewValue;
+ var oldValue = (bool)args.OldValue;
+ btn.IsSelected = newValue;
+ // control.UpdateFormattedValue(newValue);
+ // if(newValue!=oldValue)
+ btn.updateBrushWithValue();
+ // Debug.WriteLine("updated new value is :{0} ", newValue);
+ RoutedPropertyChangedEventArgs e =
+ new RoutedPropertyChangedEventArgs(oldValue, newValue, ValueChangedEvent);
+ btn.OnValueChanged(e);
+
+ }
+ }
+
+ public void updateBrushWithValue()
+ {
+
+ Brush brush = (IsSelected ? activeBrush : unActiveBrush);
+ Background = brush;
+// Debug.WriteLine("update brush now.........123456............");
+
+
+ }
+
+
+ ///
+ /// for the subclass
+ ///
+ ///
+ virtual protected void OnValueChanged(RoutedPropertyChangedEventArgs e)
+ {
+ RaiseEvent(e);
+ }
+
+ #region Events
+
+ ///
+ /// The ValueChangedEvent, raised if the value changes.
+ ///
+ private static readonly RoutedEvent ValueChangedEvent =
+ EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
+ typeof(RoutedPropertyChangedEventHandler), typeof(CSwitcher));
+
+ ///
+ /// Occurs when the Value property changes.
+ ///
+ public event RoutedPropertyChangedEventHandler ValueChanged
+ {
+ add { AddHandler(ValueChangedEvent, value); }
+ remove { RemoveHandler(ValueChangedEvent, value); }
+ }
+ #endregion
+
+
+
+ }
+}
diff --git a/LibControl/Controls/CTreeView.cs b/LibControl/Controls/CTreeView.cs
new file mode 100644
index 0000000..191a0b0
--- /dev/null
+++ b/LibControl/Controls/CTreeView.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Diagnostics;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:delayctlDemo"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:delayctlDemo;assembly=delayctlDemo"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+
+ public class CTreeView : TreeView
+ {
+ private const double XMouseoffset = 10.0;
+ private Point _lastMouseDown;
+ private TreeViewItem draggedItem;
+ static CTreeView()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CTreeView), new FrameworkPropertyMetadata(typeof(CTreeView)));
+
+ }
+
+ public CTreeView()
+ {
+ this.DragOver += treeView_DragOver;
+ this.MouseMove += treeView_MouseMove;
+ // Debug.WriteLine("ctree view construct now................");
+
+ }
+
+ private void treeView_DragOver(object sender, DragEventArgs e) //must keep
+ {
+ e.Handled = true;
+
+ }
+
+
+ private void treeView_MouseMove(object sender, MouseEventArgs e) //must
+ {
+ try
+ {
+
+ if (e.LeftButton == MouseButtonState.Pressed)
+ {
+ Point currentPosition = e.GetPosition(this);
+ if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) ||
+ (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0))
+ {
+ draggedItem = (TreeViewItem)this.SelectedItem;
+ if (draggedItem != null)
+ {
+ DragDropEffects finalDropEffect = DragDrop.DoDragDrop(this, this.SelectedValue,
+ DragDropEffects.Move);
+
+ }
+ }
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ static TObject FindVisualParent(UIElement child) where TObject : UIElement
+ {
+ if (child == null)
+ {
+ return null;
+ }
+
+ UIElement parent = VisualTreeHelper.GetParent(child) as UIElement;
+
+ while (parent != null)
+ {
+ TObject found = parent as TObject;
+ if (found != null)
+ {
+ return found;
+ }
+ else
+ {
+ parent = VisualTreeHelper.GetParent(parent) as UIElement;
+ }
+ }
+
+ return null;
+ }
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/CTreeViewItem.xaml b/LibControl/Controls/CTreeViewItem.xaml
new file mode 100644
index 0000000..7d1d4e8
--- /dev/null
+++ b/LibControl/Controls/CTreeViewItem.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/LibControl/Controls/CTreeViewItem.xaml.cs b/LibControl/Controls/CTreeViewItem.xaml.cs
new file mode 100644
index 0000000..15efaba
--- /dev/null
+++ b/LibControl/Controls/CTreeViewItem.xaml.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CTreeViewItem.xaml
+ ///
+ public partial class CTreeViewItem : UserControl
+ {
+
+
+ private static string strItem = "";
+ public string itemText
+ {
+ get { return (string)GetValue(itemTextProperty); }
+ set { SetValue(itemTextProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for itemText. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty itemTextProperty =
+ DependencyProperty.Register("itemText", typeof(string), typeof(CTreeViewItem),
+ new FrameworkPropertyMetadata(strItem, FrameworkPropertyMetadataOptions.None, onItemTextChange
+ ));
+
+ private static void onItemTextChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CTreeViewItem;
+ if (mcontrol != null)
+ {
+ mcontrol.edTitle.Text= (string)args.NewValue;
+
+ mcontrol.InvalidateVisual();
+ }
+ }
+
+
+
+ private static ImageSource DefaultItemSrc = null;
+ public ImageSource itemSource
+ {
+ get { return (ImageSource)GetValue(itemSourceProperty); }
+ set { SetValue(itemSourceProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for itemSource. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty itemSourceProperty =
+ DependencyProperty.Register("itemSource", typeof(ImageSource), typeof(CTreeViewItem),
+ new FrameworkPropertyMetadata(DefaultItemSrc, FrameworkPropertyMetadataOptions.None, onImageChange
+ ));
+
+ private static void onImageChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CTreeViewItem;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ //mcontrol.img.Source.SetValue()
+ mcontrol.img.Source = (ImageSource)args.NewValue;
+ mcontrol.InvalidateVisual();
+
+ }
+ }
+
+
+ ///
+ ///
+ ///
+ public CTreeViewItem()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/LibControl/Controls/CTreeViewItem.xaml~RF1933c5c.TMP b/LibControl/Controls/CTreeViewItem.xaml~RF1933c5c.TMP
new file mode 100644
index 0000000..7d1d4e8
--- /dev/null
+++ b/LibControl/Controls/CTreeViewItem.xaml~RF1933c5c.TMP
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/LibControl/Controls/CommControl.cs b/LibControl/Controls/CommControl.cs
new file mode 100644
index 0000000..6b23a33
--- /dev/null
+++ b/LibControl/Controls/CommControl.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: CommControl
+ *版本号: V1.0.0.0
+ *唯一标识:53749f43-2a0e-486e-bba5-dcaeebe30a79
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/30/2016 9:54:34 AM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/30/2016 9:54:34 AM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class CommControl : Control
+ {
+ static CommControl()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CommControl), new FrameworkPropertyMetadata(typeof(CommControl)));
+ }
+
+ public int limitValue(int mva,int nMax,int nMin)
+ {
+ return Math.Max(nMin - 1, Math.Min(nMax + 1, mva));
+ }
+ //
+ //------
+ #region property define
+ private const int DefaultTag = 0;
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTag. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(CommControl), new PropertyMetadata(DefaultTag));
+
+
+ private static SolidColorBrush DefaultBackBrush = Brushes.Gray;
+
+ public SolidColorBrush BackBrush
+ {
+ get { return (SolidColorBrush)GetValue(BackBrushProperty); }
+ set { SetValue(BackBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for BackBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BackBrushProperty =
+ DependencyProperty.Register("BackBrush", typeof(SolidColorBrush), typeof(CommControl),
+ new FrameworkPropertyMetadata(DefaultBackBrush, FrameworkPropertyMetadataOptions.None, onBackBrushChange
+ ));
+
+ private static void onBackBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as CommControl;
+ if (mcontrol != null)
+ {
+ mcontrol.BackBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+
+ }
+ #endregion
+
+ public void Redraw()
+ {
+
+ InvalidateVisual();
+ }
+
+
+ }
+}
diff --git a/LibControl/Controls/DynGainMark.cs b/LibControl/Controls/DynGainMark.cs
new file mode 100644
index 0000000..0b03096
--- /dev/null
+++ b/LibControl/Controls/DynGainMark.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls;assembly=Lib.Controls"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ public class DynGainMark : CommControl
+ {
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+
+ static DynGainMark()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(DynGainMark), new FrameworkPropertyMetadata(typeof(DynGainMark)));
+ }
+
+ public static string[] strDYNMark = {
+ " -2"," -6","-10","-14","-18","-22","-26","-30","-34","-38","-42","-46","-48","-50"
+ };
+
+
+
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ double leftDynStep = (double)this.ActualHeight / (strDYNMark.Length) -0.25;
+
+ double xleftOffset = 1.0;
+ FormattedText texte = null;
+ double fontsize = 9.0;
+ string ftext = string.Empty;
+ for (int i = 0; i < strDYNMark.Length; i++)
+ {
+ ftext = strDYNMark[i];
+ texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, Brushes.White);
+ dc.DrawText(texte, new Point(xleftOffset, i * leftDynStep));
+
+ }
+
+ }
+
+
+ }
+}
diff --git a/LibControl/Controls/FFTControl/FBCFFTDraw.cs b/LibControl/Controls/FFTControl/FBCFFTDraw.cs
new file mode 100644
index 0000000..1ce59b4
--- /dev/null
+++ b/LibControl/Controls/FFTControl/FBCFFTDraw.cs
@@ -0,0 +1,585 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls.FFTControl
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls.FFTControl"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:Lib.Controls.FFTControl;assembly=Lib.Controls.FFTControl"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ public class FBCFFTDraw : CommControl
+ {
+ ///
+ /// constructor
+ ///
+ public FBCFFTDraw()
+ {
+ initalProperty();
+ }
+ private const double DefaultMasterGain = 0;
+ public double masterGain
+ {
+ get { return (double)GetValue(masterGainProperty); }
+ set { SetValue(masterGainProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for masterGainI. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty masterGainProperty =
+ DependencyProperty.Register("masterGain", typeof(double), typeof(FBCFFTDraw), new PropertyMetadata(DefaultMasterGain));
+
+
+ #region fftData define
+ private double[] PointArray = new double[FFTConstaint.NFFT];
+ private double[] FreqTemp = new double[FFTConstaint.FBC_FFTNum];
+ private double[] GainTemp = new double[FFTConstaint.FBC_FFTNum];
+ public byte[] m_FlatFlag = new byte[FFTConstaint.FBC_FFTNum];
+ #endregion
+
+
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+ private const double DefaultBlockRadius = 10;
+ public double fBlockRadius
+ {
+ get { return (double)GetValue(fBlockRadiusProperty); }
+ set { SetValue(fBlockRadiusProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for BlockRadius. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fBlockRadiusProperty =
+ DependencyProperty.Register("fBlockRadius", typeof(double), typeof(FBCFFTDraw), new PropertyMetadata(DefaultBlockRadius));
+
+
+ ///
+ /// inital
+ ///
+ protected void initalProperty()
+ {
+ if (m_FlatFlag == null)
+ m_FlatFlag = new byte[FFTConstaint.FBC_FFTNum];
+
+ if (PointArray == null)
+ PointArray = new double[FFTConstaint.NFFT];
+ if (FreqTemp == null)
+ FreqTemp = new double[FFTConstaint.FBC_FFTNum];
+ if (GainTemp == null)
+ GainTemp = new double[FFTConstaint.FBC_FFTNum];
+ }
+
+ ///
+ ///
+ ///
+ /// 0,1,2
+ /// base 0...23
+ public void setBlockFlat(int flag, int index)
+ {
+ if(flag<=0||index<=0||index>23)return;
+ m_FlatFlag[index] = (byte)flag;
+ this.Redraw();
+ }
+
+ private static SolidColorBrush DefaultTextBrush = Brushes.White;
+
+ public SolidColorBrush ftextBlockBrush
+ {
+ get { return (SolidColorBrush)GetValue(ftextBlockBrushProperty); }
+ set { SetValue(ftextBlockBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for textBlockBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ftextBlockBrushProperty =
+ DependencyProperty.Register("ftextBlockBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw), new PropertyMetadata(DefaultTextBrush));
+
+
+
+ public SolidColorBrush fcircleBlockBrush
+ {
+ get { return (SolidColorBrush)GetValue(fcircleBlockBrushProperty); }
+ set { SetValue(fcircleBlockBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for circleBlockBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fcircleBlockBrushProperty =
+ DependencyProperty.Register("fcircleBlockBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw), new PropertyMetadata(DefaultTextBrush));
+
+
+
+ private static SolidColorBrush DefaultFilBrush = Brushes.Transparent;
+ public SolidColorBrush ffillBlockBrush
+ {
+ get { return (SolidColorBrush)GetValue(ffillBlockBrushProperty); }
+ set { SetValue(ffillBlockBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for fillBlockBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ffillBlockBrushProperty =
+ DependencyProperty.Register("ffillBlockBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw), new PropertyMetadata(DefaultFilBrush));
+
+
+
+
+
+
+ private static SolidColorBrush DefaultOutBrush = new SolidColorBrush(Color.FromRgb(0, 0xFF, 0));
+ public SolidColorBrush OutBrush
+ {
+ get { return (SolidColorBrush)GetValue(OutBrushProperty); }
+ set { SetValue(OutBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for OutBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty OutBrushProperty =
+ DependencyProperty.Register("OutBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw), new PropertyMetadata(DefaultOutBrush));
+
+
+
+
+
+
+
+ public void drawBlock(DrawingContext cvs, int eindex)
+ {
+ int eqindex = eindex;
+ if (m_FlatFlag[eindex] <= 0) return;
+
+ double px = getBlockPosX(eqindex);
+ double py = getBlockPosY(eqindex);
+
+ // Debug.WriteLine("block pos x:{0}:y:{1} eqindex is : {2}", px, py, eindex);
+ string ftext = (eindex + 1).ToString();
+ double fontsize = 10.0;
+
+ double offsetX = (eindex > 10 ? 7.8 : 3.0);
+ if (eindex == 10 || eindex == 9)
+ offsetX = 6.0;
+
+ double offsetY = 7.0;
+
+
+ SolidColorBrush penbrush = fgLineBrush;
+ penbrush = fcircleBlockBrush;
+
+ FormattedText texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, ftextBlockBrush);
+ if (py > this.ActualHeight - offsetY * 2) return;
+
+ cvs.DrawText(texte, new Point(px - offsetX, py - DefaultBlockRadius - offsetY));
+ //cvs.DrawRectangle(ffillBlockBrush, new Pen(penbrush, 1),new ret)
+ // cvs.DrawEllipse( new Point(px, py), circleRadiosX, circleRadiosY);
+
+ Rect cRect = new Rect(px - DefaultBlockRadius / 2, py - DefaultBlockRadius / 2, DefaultBlockRadius, DefaultBlockRadius);
+ if (py <= this.ActualHeight)
+ cvs.DrawRectangle(ffillBlockBrush, new Pen(penbrush, 1), cRect);
+
+
+ }
+ #region output interface to invoke.........
+ ///
+ /// for output invoke interface
+ ///
+ ///
+
+ public void setGlobalEQData(double[] gData)
+ {
+ Array.Clear(PointArray, 0, FFTConstaint.NFFT); //first clear
+ Array.Copy(gData, PointArray, FFTConstaint.NFFT);
+ }
+ public void setBlockData(double freq, double gain, int eindex)
+ {
+ FreqTemp[eindex] = freq;
+ GainTemp[eindex] = gain;
+ }
+ #endregion
+
+
+
+ ///
+ /// pen brush for the border
+ ///
+ private static SolidColorBrush DefaultPenBrush = Brushes.Black;
+ public SolidColorBrush fpenBrush
+ {
+ get { return (SolidColorBrush)GetValue(fpenBrushProperty); }
+ set { SetValue(fpenBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for penBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fpenBrushProperty =
+ DependencyProperty.Register("fpenBrush", typeof(SolidColorBrush),
+ typeof(FFTDrawer), new PropertyMetadata(DefaultPenBrush));
+
+
+
+ private static SolidColorBrush DefaultGridBrush = Brushes.LightBlue;
+ public SolidColorBrush fGridBrush
+ {
+ get { return (SolidColorBrush)GetValue(fGridBrushProperty); }
+ set { SetValue(fGridBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for GridBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fGridBrushProperty =
+ DependencyProperty.Register("fGridBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw),
+ new FrameworkPropertyMetadata(DefaultGridBrush, FrameworkPropertyMetadataOptions.None, onGridBrushChange
+ ));
+
+ private static void onGridBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.GridBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+
+
+ private static SolidColorBrush DefaultLineBrush = Brushes.Red;
+ public SolidColorBrush fgLineBrush
+ {
+ get { return (SolidColorBrush)GetValue(fgLineBrushProperty); }
+ set { SetValue(fgLineBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for gLineBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fgLineBrushProperty =
+ DependencyProperty.Register("fgLineBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw),
+ new FrameworkPropertyMetadata(DefaultLineBrush, FrameworkPropertyMetadataOptions.None, onGridBrushChange
+ ));
+
+ private static void onLineBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.gLineBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+ }
+ //new PropertyMetadata(0));
+
+ ///
+ /// borderThick
+ ///
+ private const double DefaultBorderThick = 0.5;
+ public double fBorderThick
+ {
+ get { return (double)GetValue(fBorderThickProperty); }
+ set { SetValue(fBorderThickProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for borderThick. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fBorderThickProperty =
+ DependencyProperty.Register("fBorderThick", typeof(double), typeof(FBCFFTDraw),
+ new FrameworkPropertyMetadata(DefaultBorderThick, FrameworkPropertyMetadataOptions.None, onBorderThickChange
+ ));
+
+ private static void onBorderThickChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.BorderThick = (double)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+ //
+
+
+
+ public static SolidColorBrush DefaultInterBrush = new SolidColorBrush(Color.FromRgb(0, 0x80, 0)); //light green
+ public SolidColorBrush InterGridBrush
+ {
+ get { return (SolidColorBrush)GetValue(InterGridBrushProperty); }
+ set { SetValue(InterGridBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for InterGridBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty InterGridBrushProperty =
+ DependencyProperty.Register("InterGridBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw), new PropertyMetadata(DefaultInterBrush));
+
+
+
+ public static SolidColorBrush DefaultLabelBrush = new SolidColorBrush(Color.FromRgb(255, 255, 0)); //yellow
+ public SolidColorBrush LabelBrush
+ {
+ get { return (SolidColorBrush)GetValue(LabelBrushProperty); }
+ set { SetValue(LabelBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for LabelBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty LabelBrushProperty =
+ DependencyProperty.Register("LabelBrush", typeof(SolidColorBrush), typeof(FBCFFTDraw), new PropertyMetadata(DefaultLabelBrush));
+
+
+
+
+ protected void drawGrid(DrawingContext cvs)
+ {
+ double anx = this.ActualWidth;
+ double any = this.ActualHeight;
+ double delta, yy;
+ delta = (FFTConstaint.FYMax - FFTConstaint.FYMin) / (FFTConstaint.FNumHorzGrid + 1);
+
+ FormattedText texte = new FormattedText("+30", CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), 10, LabelBrush);
+ cvs.DrawText(texte, new Point(0 - 22, 0));
+ cvs.DrawLine(new Pen(OutBrush, 1), new Point(0, 0), new Point(anx, 0));
+ for (int i = 0; i < FFTConstaint.FNumHorzGrid; i++) //
+ {
+
+ yy = logValue_ToFFTScreenY(FFTConstaint.FYMin + delta * (i + 1));
+ if (i != (FFTConstaint.FNumHorzGrid - 1) / 2)
+ {
+ cvs.DrawLine(new Pen(InterGridBrush, 1), new Point(0, yy), new Point(anx, yy));
+ }
+ texte = new FormattedText(FFTConstaint.strFBCGridGTable[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), 10, LabelBrush);
+ cvs.DrawText(texte, new Point(0 - 22, yy - 5));
+
+ }
+ //draw middle
+ double midle = logValue_ToFFTScreenY(FFTConstaint.FYMin + delta * 3);
+ cvs.DrawLine(new Pen(InterGridBrush, 1), new Point(0, midle), new Point(anx, midle));
+ for (int i = 0; i < FFTConstaint.GridFreqTable.Length; i++) //for test the coordinate stand FFTConstaint.BZPlotBNum
+ {
+ double xx = freqToLogPosX(FFTConstaint.GridFreqTable[i]);
+
+ double kpos = logPosXToFFTScreenPos(xx);
+ // Debug.WriteLine("xx zuobiao is : {0} kpos is :{1} with freqindex : {2} freq {3}", xx, kpos, FFTConstaint.GridFreqTable[i], i);
+ cvs.DrawLine(new Pen(InterGridBrush, 1), new Point(kpos, 0), new Point(kpos, any));
+
+ texte = new FormattedText(FFTConstaint.strGridFreqTable[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), 10, LabelBrush);
+ cvs.DrawText(texte, new Point(kpos - 6, any));
+
+
+ }
+ texte = new FormattedText("-30", CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), 10, LabelBrush);
+ cvs.DrawText(texte, new Point(0 - 22, ActualHeight - 5));
+ cvs.DrawLine(new Pen(OutBrush, 1), new Point(0, any), new Point(anx, any));
+
+ }
+
+
+
+ private const double DefaultCaptureRadius = 6.0;
+ public double fCaptureRadius
+ {
+ get { return (double)GetValue(fCaptureRadiusProperty); }
+ set { SetValue(fCaptureRadiusProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for CaptureRadius. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fCaptureRadiusProperty =
+ DependencyProperty.Register("fCaptureRadius", typeof(double), typeof(FBCFFTDraw), new PropertyMetadata(DefaultCaptureRadius));
+
+
+
+ private const double DefaultGLineWidth = 2.8;
+ public double fgLineWidth
+ {
+ get { return (double)GetValue(fgLineWidthProperty); }
+ set { SetValue(fgLineWidthProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for gLineWidth. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fgLineWidthProperty =
+ DependencyProperty.Register("fgLineWidth", typeof(double), typeof(FBCFFTDraw), new PropertyMetadata(DefaultGLineWidth));
+
+ #region freq-->lgopos->fftscreenPos
+ ///
+ /// convert freq(double) to Log Pos
+ ///
+ ///
+ ///
+ /// freq-->logpos->screenpos
+ public static double freqToLogPosX(double freq)
+ {
+
+ return Math.Log10(freq) / Math.Log10(FFTConstaint.SAMPLERATE) * FFTConstaint.NFFT;
+
+ }
+
+ ///
+ /// convert x log Pos to fftdraw sceen pos
+ ///
+ ///
+ ///
+ public double logPosXToFFTScreenPos(double x) //screenX
+ {
+
+ double fWidth = ActualWidth;
+ return fWidth * (x - FFTConstaint.FXMin) / (FFTConstaint.FXMax - FFTConstaint.FXMin);
+
+ }
+
+ public double freqToFFTScreenPosX(double freq)
+ {
+ return logPosXToFFTScreenPos(freqToLogPosX(freq));
+ }
+
+ #endregion
+ #region fftscreenpos--->logpos--->freqs
+ public static double logPosX_ToFreq(double screen)
+ {
+ return Math.Pow(10, screen / FFTConstaint.NFFT * Math.Log10(FFTConstaint.SAMPLERATE));
+ }
+
+ ///
+ /// convert screen x at point to freq
+ ///
+ /// s
+ ///
+ public double fftScreenPosX_ToLogPosX(double x)
+ {
+ double fWidth = this.ActualWidth;
+ return x * (FFTConstaint.FXMax - FFTConstaint.FXMin) / fWidth + FFTConstaint.FXMin;//fftScreenPos_toLogPoss
+ }
+ public double fftScreenPosXToFreq(double x)
+ {
+ return logPosX_ToFreq(fftScreenPosX_ToLogPosX(x));
+ }
+
+ #endregion
+ public double logValue_ToFFTScreenY(double y) //screenY
+ {
+ double fHeight = this.ActualHeight;
+ return fHeight - fHeight * (y - FFTConstaint.FYMin) / (FFTConstaint.FYMax - FFTConstaint.FYMin);
+ }
+
+ public double fftScreenY_ToLogValueY(double y)
+ {
+ double fHeight = this.ActualHeight;
+ return (fHeight - y) * (FFTConstaint.FYMax - FFTConstaint.FYMin) / fHeight + FFTConstaint.FYMin;
+
+ }
+
+ ///
+ /// drawGlobalLine,note in wpf draw with DrawingContext can draw outside line (left or right end)
+ ///
+ ///
+ private void drawGlobalLine(DrawingContext dc)
+ {
+
+ Point p1 = new Point();
+ Point p2 = new Point();
+ Pen mPen = null;
+ double gMaster = 0;
+ mPen = new Pen(fgLineBrush, fgLineWidth);
+ gMaster = masterGain;
+
+ int i = 0;
+ for (i = 0; i < FFTConstaint.NFFT - 1; i++)
+ {
+
+ p1.X = logPosXToFFTScreenPos(i);
+ if (p1.X >= 0)
+ {
+ // Debug.WriteLine("point 1 x is :{0} i is :{1}", p1.X, i);
+
+ p1.Y = logValue_ToFFTScreenY(PointArray[i] + gMaster);
+ if (p1.Y > this.ActualHeight)
+ p1.Y = this.ActualHeight;
+
+ p2.X = logPosXToFFTScreenPos(i + 1);
+ if (p2.X <= ActualWidth)
+ {
+ p2.Y = logValue_ToFFTScreenY(PointArray[i + 1] + gMaster);
+ if (p2.Y > this.ActualHeight)
+ p2.Y = this.ActualHeight;
+ }
+ else
+ break;
+ dc.DrawLine(mPen, p1, p2);
+ }
+
+ }
+ //dc.DrawLine()
+ }
+
+ public void drawAllPlots(DrawingContext dc)
+ {
+ drawGlobalLine(dc);
+
+ for (int i = 0; i < FFTConstaint.FBC_FFTNum; i++) //FFTConstaint.CEQ_MAX/2
+ drawBlock(dc, i);
+ }
+
+ ///
+ /// onRender Main Method
+ ///
+ ///
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ // Debug.WriteLine("on render width ,height is : {0} {1}", wd, ht);
+ dc.DrawRectangle(BackBrush, new Pen(fpenBrush, fBorderThick), new Rect(0, 0, wd, ht));
+ drawGrid(dc);
+ drawAllPlots(dc);
+
+ }
+
+ #region function define below..........
+ public double getBlockPosX(int eindex)
+ {
+ return freqToFFTScreenPosX(FreqTemp[eindex]);
+ }
+ //but only changed of the entire y position
+ public double getBlockPosY(int eindex)
+ {
+ return logValue_ToFFTScreenY(GainTemp[eindex] + masterGain);
+ }
+ #endregion
+
+
+
+
+ // protected double screenx
+
+
+
+ }
+}
diff --git a/LibControl/Controls/FFTControl/FFTConstaint.cs b/LibControl/Controls/FFTControl/FFTConstaint.cs
new file mode 100644
index 0000000..262f5c4
--- /dev/null
+++ b/LibControl/Controls/FFTControl/FFTConstaint.cs
@@ -0,0 +1,691 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: FFTConstaint
+ *版本号: V1.0.0.0
+ *唯一标识:71b68fa1-76d5-487f-a683-c2b97b37e42b
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/30/2016 6:44:09 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/30/2016 6:44:09 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+
+ public enum HLPassType
+ {
+ HLBYPASS = 10, LP6dB, HP6dB, BWLP12dB, BESLP12dB, LKLP12dB, CHVLP12dB, BWHP12dB, BESHP12dB, LKHP12dB, CHVHP12dB,
+ BWLP24dB, BESLP24dB, LKLP24dB, CHVLP24dB, BWHP24dB, BESHP24dB, LKHP24dB, CHVHP24dB,
+ BWLP36dB, BESLP36dB, LKLP36dB, CHVLP36dB, BWHP36dB, BESHP36dB, LKHP36dB, CHVHP36dB
+ };
+
+ public class FFTConstaint
+ {
+
+ public const int NONQvalue = -100;
+ public const int NONFreq = -101;
+ public const int NONGain = -102;
+
+
+ public const int QMoveLeft = 100;
+ public const int QMoveRight = 101;
+
+
+ public static double[,] fButterWorthCoef ={
+ {1, 0, 0, 0, 0}, // 1rd order - 6dB/oct
+ {0, 1.4142, 0, 0, 0}, // 2nd order -12dB/oct
+ {1, 1, 0, 0, 0}, // 3rd order -18dB/oct
+ {0, 0.7654, 1.8478, 0, 0}, // 4th order -24dB/oct
+ {1, 0.6180, 1.6180, 0, 0}, // 5th order -30dB/oct
+ {0, 0.5176, 1.4142, 1.9319, 0}, // 6th order -36dB/oct
+ {1, 0.4450, 1.2470, 1.8019, 0}, // 7th order -42dB/oct
+ {0, 0.3902, 1.1111, 1.6629, 1.9616}, // 8th order -48dB/oct
+};
+
+ public static double[, ,] fBesselCoef ={
+ { {1,0}, {0,0}, {0,0}, {0,0}, {0,0}}, // 1nd order - 6dB/oct
+ { {0,0},{1.3617,0.6180}, {0,0}, {0,0}, {0,0}}, // 2nd order -12dB/oct
+ {{0.7560,0},{0.9996,0.4772}, {0,0}, {0,0}, {0,0}}, // 3rd order -18dB/oct
+ { {0,0},{1.3397,0.4889},{0.7743,0.3890}, {0,0}, {0,0}}, // 4th order -24dB/oct
+ {{0.6656,0},{1.1402,0.4128},{0.6216,0.3245}, {0,0}, {0,0}}, // 5th order -30dB/oct
+ { {0,0},{1.2217,0.3887},{0.9686,0.3505},{0.5131,0.2756}, {0,0}}, // 6th order -36dB/oct
+ {{0.5937,0},{1.0944,0.3395},{0.8304,0.3011},{0.4332,0.2381}, {0,0}}, // 7th order -42dB/oct
+ { {0,0},{1.1112,0.3126},{0.9754,0.2979},{0.7202,0.2621},{0.3728,0.2087}}, // 8th order -48dB/oct
+};
+
+
+ public static double[] GridFreqTable ={ //base log sonsume caculate 128
+ 10.0,
+ 20.0, //00s
+ 30.0, //06 // -------30
+ 40.0, //13 // -------40
+ 50.0, //17 // -------50
+
+ 60.0, //20 //-------60
+
+ 70.0, //23 //-------70
+ 80.0, //26 //-------80
+ 90.0, //28 //-------90
+
+ 100.0, //30 //-------100
+ 200.0, //43 //-------200
+ 300.0, //50 //-------300
+ 400.0, //56 //-------400
+ 500.0, //60 //-------500
+ 600.0, //63 //-------600
+
+ 700.0, //66 //-------700
+ 800.0, //68 //-------800
+ 900.0, //71 //-------900
+ 1000, //73 //-------1k
+ 2000, //85 //-------2k
+ 3000, //93//-------3k
+ 4000, //98 //-------4k
+ 5000, //103 //-------5k
+ 6000, //106 //-------6k
+ 7000, //109 //-------7k
+ 8000, //111 //-------8k
+
+ 9000, //114 //-------9k
+
+ 10000, //115 //-------10k
+ 20000,
+ 22000, //128
+ };
+ public static string[] strGridGainTable ={
+ "-24",
+ "-12",
+ "0dB",
+ "+12",
+ "+24"
+ };
+ //
+ public static string[] strFBCGridGTable ={
+ // "-30",
+ "+24",
+ "+12",
+ " 0",
+ "-12",
+ "-24",
+ // " +6",
+ };
+
+
+ public enum XoverType
+ {
+ ByPass = 0, BW6dB, BES6dB, BW12dB, BES12dB, LK12dB,
+ BW18dB, BES18dB, BW24dB, BES24dB, LK24dB,
+ BW30dB, BES30dB, BW36dB, BES36dB, LK36dB,
+ BW42dB, BES42dB, BW48dB, BES48dB, LK48dB
+ };
+
+ public static int getFilterWithType(XoverType type)
+ {
+ int ret = 0;
+ switch (type)
+ {
+ case XoverType.ByPass:
+ ret = 0; // Bypass
+ break;
+ case XoverType.BW6dB: // Butterworth -6dB/oct
+ ret = 1;
+ break;
+ case XoverType.BW12dB: // Butterworth -12dB/oct
+ ret = 2;
+ break;
+ case XoverType.BW18dB: // Butterworth -18dB/oct
+ ret = 3;
+ break;
+ case XoverType.BW24dB: // Butterworth -24dB/oct
+ ret = 4;
+ break;
+ case XoverType.BW30dB: // Butterworth -30dB/oct
+ ret = 5;
+ break;
+ case XoverType.BW36dB: // Butterworth -36dB/oct
+ ret = 6;
+ break;
+ case XoverType.BW42dB: // Butterworth -42dB/oct
+ ret = 7;
+ break;
+ case XoverType.BW48dB: // Butterworth -48dB/oct
+ ret = 8;
+ break;
+ case XoverType.BES6dB: // Bessel -6dB/oct
+ ret = 9;
+ break;
+ case XoverType.BES12dB: // Bessel -12dB/oct
+ ret = 10;
+ break;
+ case XoverType.BES18dB: // Bessel -18dB/oct
+ ret = 11;
+ break;
+ case XoverType.BES24dB: // Bessel -24dB/oct
+ ret = 12;
+ break;
+ case XoverType.BES30dB: // Bessel -30dB/oct
+ ret = 13;
+ break;
+ case XoverType.BES36dB: // Bessel -36dB/oct
+ ret = 14;
+ break;
+ case XoverType.BES42dB: // Bessel -42dB/oct
+ ret = 15;
+ break;
+ case XoverType.BES48dB: // Bessel -48dB/oct
+ ret = 16;
+ break;
+ case XoverType.LK12dB:
+ ret = 17; // Link/Riley -12dB/oct
+ break;
+ case XoverType.LK24dB:
+ ret = 19; // Link/Riley -24dB/oct
+ break;
+ case XoverType.LK36dB: // Link/Riley -36dB/oct
+ ret = 18;
+ break;
+ case XoverType.LK48dB: // Link/Riley -48dB/oct
+ ret = 20;
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+ }
+
+
+ public static string[] strGridFreqTable ={ //base log sonsume caculate 128
+ "",
+ "20", //00s
+ "30", //06 // -------30
+ "40", //13 // -------40
+ "50", //17 // -------50
+
+ "60", //20 //-------60
+
+ "", //23 //-------70
+ "", //26 //-------80
+ "", //28 //-------90
+
+ "100", //30 //-------100
+ "200", //43 //-------200
+ "300", //50 //-------300
+ "", //56 //-------400
+ "500", //60 //-------500
+ "", //63 //-------600
+
+ "", //66 //-------700
+ "", //68 //-------800
+ "", //71 //-------900
+ "1KHz", //73 //-------1k
+ "2K", //85 //-------2k
+ "3K", //93//-------3k
+ "4K", //98 //-------4k
+ "5K", //103 //-------5k
+ "", //106 //-------6k
+ "", //109 //-------7k
+ "", //111 //-------8k
+
+ "", //114 //-------9k
+
+ "10KHz", //115 //-------10k
+ "20K",
+ "", //128
+ };
+ public static double[] FreqTable =
+ {
+ 19.7, //00
+ 20.1, //01
+ 20.6, //02
+ 21.1, //03
+ 21.6, //04
+ 22.1, //05
+ 22.6, //06
+ 23.1, //07
+ 23.7, //08
+ 24.2, //09
+
+ 24.8, //10
+ 25.4, //11
+ 26.0, //12
+ 26.6, //13
+ 27.2, //14
+ 27.8, //15
+ 28.5, //16
+ 29.2, //17
+ 29.8, //18
+ 30.5, //19
+
+ 31.2, //20
+ 32.0, //21
+ 32.7, //22
+ 33.5, //23
+ 34.3, //24
+ 35.1, //25
+ 35.9, //26
+ 36.7, //27
+ 37.6, //28
+ 38.5, //29
+
+ 39.4, //30
+ 40.3, //31
+ 41.2, //32
+ 42.2, //33
+ 43.2, //34
+ 44.2, //35
+ 45.2, //36
+ 46.3, //37
+ 47.4, //38
+ 48.5, //39
+
+ 49.6, //40
+ 50.8, //41
+ 52.0, //42
+ 53.2, //43
+ 54.4, //44
+ 55.7, //45
+ 57.0, //46
+ 58.3, //47
+ 59.7, //48
+ 61.1, //49
+
+ 62.5, //50
+ 64.0, //51
+ 65.5, //52
+ 67.0, //53
+ 68.6, //54
+ 70.2, //55
+ 71.8, //56
+ 73.5, //57
+ 75.2, //58
+ 76.9, //59
+
+ 78.7, //60
+ 80.6, //61
+ 82.5, //62
+ 84.4, //63
+ 86.4, //64
+ 88.4, //65
+ 90.5, //66
+ 92.6, //67
+ 94.7, //68
+ 96.9, //69
+
+ 99.2, //70
+ 101.5, //71
+ 103.9, //72
+ 106.3, //73
+ 108.8, //74
+ 111.4, //75
+ 114.0, //76
+ 116.6, //77
+ 119.4, //78
+ 122.1, //79
+
+ 125.0, //80
+ 127.9, //81
+ 130.9, //82
+ 134.0, //83
+ 137.1, //84
+ 140.3, //85
+ 143.6, //86
+ 146.9, //87
+ 150.4, //88
+ 153.9, //89
+
+ 157.5, //90
+ 161.2, //91
+ 164.9, //92
+ 168.8, //93
+ 172.7, //94
+ 176.8, //95
+ 180.9, //96
+ 185.1, //97
+ 189.5, //98
+ 193.9, //99
+
+ 198.4, //100
+ 203.1, //101
+ 207.8, //102
+ 212.7, //103
+ 217.6, //104
+ 222.7, //105
+ 227.9, //106
+ 233.3, //107
+ 238.7, //108
+ 244.3, //109
+
+ 250.0, //110
+ 255.8, //111
+ 261.8, //112
+ 267.9, //113
+ 274.2, //114
+ 280.6, //115
+ 287.2, //116
+ 293.9, //117
+ 300.8, //118
+ 307.8, //119
+
+ 315.0, //120
+ 322.3, //121
+ 329.9, //122
+ 337.6, //123
+ 345.5, //124
+ 353.6, //125
+ 361.8, //126
+ 370.3, //127
+ 378.9, //128
+ 387.8, //129
+
+ 396.9, //130
+ 406.1, //131
+ 415.6, //132
+ 425.3, //133
+ 435.3, //134
+ 445.4, //135
+ 455.9, //136
+ 466.5, //137
+ 477.4, //138
+ 488.6, //139
+
+ 500.0, //140
+ 511.7, //141
+ 523.6, //142
+ 535.9, //143
+ 548.4, //144
+ 561.2, //145
+ 574.3, //146
+ 587.8, //147
+ 601.5, //148
+ 615.6, //149
+
+ 630.0, //150
+ 644.7, //151
+ 659.8, //152
+ 675.2, //153
+ 691.0, //154
+ 707.1, //155
+ 723.6, //156
+ 740.5, //157
+ 757.9, //158
+ 775.6, //159
+
+ 793.7, //160
+ 812.3, //161
+ 831.2, //162
+ 850.7, //163
+ 870.6, //164
+ 890.9, //165
+ 911.7, //166
+ 933.0, //167
+ 954.8, //168
+ 977.2, //169
+
+ 1000.0, //170
+ 1030.0, //171
+ 1050.0, //172
+ 1080.0, //173
+ 1100.0, //174
+ 1130.0, //175
+ 1150.0, //176
+ 1180.0, //177
+ 1210.0, //178
+ 1240.0, //179
+
+ 1260.0, //180
+ 1290.0, //181
+ 1320.0, //182
+ 1350.0, //183
+ 1390.0, //184
+ 1420.0, //185
+ 1450.0, //186
+ 1490.0, //187
+ 1520.0, //188
+ 1560.0, //189
+
+ 1590.0, //190
+ 1630.0, //191
+ 1670.0, //192
+ 1710.0, //193
+ 1750.0, //194
+ 1790.0, //195
+ 1830.0, //196
+ 1870.0, //197
+ 1910.0, //198
+ 1960.0, //199
+
+ 2010.0, //200
+ 2050.0, //201
+ 2100.0, //202
+ 2150.0, //203
+ 2200.0, //204
+ 2250.0, //205
+ 2300.0, //206
+ 2360.0, //207
+ 2410.0, //208
+ 2470.0, //209
+
+ 2520.0, //210
+ 2580.0, //211
+ 2640.0, //212
+ 2700.0, //213
+ 2770.0, //214
+ 2830.0, //215
+ 2900.0, //216
+ 2970.0, //217
+ 3040.0, //218
+ 3110.0, //219
+
+ 3180.0, //220
+ 3250.0, //221
+ 3330.0, //222
+ 3410.0, //223
+ 3490.0, //224
+ 3570.0, //225
+ 3650.0, //226
+ 3740.0, //227
+ 3820.0, //228
+ 3910.0, //229
+
+ 4010.0, //230
+ 4100.0, //231
+ 4190.0, //232
+ 4290.0, //233
+ 4390.0, //234
+ 4490.0, //235
+ 4600.0, //236
+ 4710.0, //237
+ 4820.0, //238
+ 4930.0, //239
+
+ 5040.0, //240
+ 5160.0, //241
+ 5280.0, //242
+ 5410.0, //243
+ 5530.0, //244
+ 5660.0, //245
+ 5790.0, //246
+ 5930.0, //247
+ 6070.0, //248
+ 6210.0, //249
+
+ 6350.0, //250
+ 6500.0, //251
+ 6650.0, //252
+ 6810.0, //253
+ 6970.0, //254
+ 7130.0, //255
+ 7300.0, //256
+ 7470.0, //257
+ 7640.0, //258
+ 7820.0, //259
+
+ 8000.0, //260
+ 8190.0, //261
+ 8380.0, //262
+ 8580.0, //263
+ 8780.0, //264
+ 8980.0, //265
+ 9190.0, //266
+ 9410.0, //267
+ 9630.0, //268
+ 9850.0, //269
+
+ 10080.0, //270
+ 10320.0, //271
+ 10560.0, //272
+ 10810.0, //273
+ 11060.0, //274
+ 11320.0, //275
+ 11580.0, //276
+ 11850.0, //277
+ 12130.0, //278
+ 12410.0, //279
+
+ 12700.0, //280
+ 13000.0, //281
+ 13300.0, //282
+ 13610.0, //283
+ 13930.0, //284
+ 14260.0, //285
+ 14590.0, //286
+ 14930.0, //287
+ 15280.0, //288
+ 15640.0, //289
+
+ 16010.0, //290
+ 16380.0, //291
+ 16760.0, //292
+ 17150.0, //293
+ 17550.0, //294
+ 17960.0, //295
+ 18380.0, //296
+ 18810.0, //297
+ 19250.0, //298
+ 19700.0, //299
+ 20160.0, //300
+};
+
+
+ public static double[] EqGain =
+ {
+ -18, //0
+-17.5,//1
+-17,//2
+-16.5,//3
+-16,//4
+-15.5,//5
+-15,//6
+-14.5,//7
+-14,//8
+-13.5,//9
+-13,//10
+-12.5,//11
+-12,//12
+-11.5,//13
+-11,//14
+-10.5,//15
+-10,//16
+-9.5,//17
+-9,//18
+-8.5,//19
+-8,//20
+-7.5,//21
+-7,//22
+-6.5,//23
+-6,//24
+-5.5,//25
+-5,//26
+-4.5,//27
+-4,//28
+-3.5,//29
+-3,//30
+-2.5,//31
+-2,//32
+-1.5,//33
+-1,//34
+-0.5,//35
+0, //36
+0.5,//37
+1,//38
+1.5,//39
+2,//40
+2.5,//41
+3,//42
+3.5,//43
+4,//44
+4.5,//45
+5,//46
+5.5,//47
+6,//48
+6.5,//49
+7,//50
+7.5,//51
+8,//52
+8.5,//53
+9,//54
+9.5,//55
+10,//56
+10.5,//57
+11,//58
+11.5,//59
+12,//60
+12.5,//61
+13,//62
+13.5,//63
+14,//64
+14.5,//65
+15,//66
+15.5,//67
+16,//68
+16.5,//69
+17,//70
+17.5,//71
+18//72
+};
+
+
+ public const double FXMin = 233; //越小越向左偏, fxmin is more samller and more offset to left
+ public const double FXMax = 1016;//越小越向右偏出 fxMax is more smaller and more offset to out
+
+ public const int FYMin = -36;
+ public const int FYMax = 36;
+ public const int NFFT = 1024;
+ public const int SAMPLERATE = 24000;
+ public const int SAMPLE_RATE = 48000;
+
+ public const int FNumHorzGrid = 5;
+ public const int FNumVertGrid = 30;
+ public const int BZPlotBNum = 29;
+ public const int CEQ_MAX = 10;
+ public const int LINE_MAX = 2;
+ public const int CH_I = 0;
+ public const int CH_II = 1;
+ public const int FBC_FFTNum = 24;
+ public const double PI = 3.1415926535897932384626433832795;
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/FFTControl/FFTDrawer.cs b/LibControl/Controls/FFTControl/FFTDrawer.cs
new file mode 100644
index 0000000..7b57b72
--- /dev/null
+++ b/LibControl/Controls/FFTControl/FFTDrawer.cs
@@ -0,0 +1,1351 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Diagnostics;
+using System.Globalization;
+using System.Windows.Input;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:HelloMove
+ *文件名: FFTDrawer
+ *版本号: V1.0.0.0
+ *唯一标识:e625d99f-867a-4a20-a2a4-16c4befa45f4
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/30/2016 2:27:37 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/30/2016 2:27:37 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *suppose there are two channels to caculate.so channel is referecne now.
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+
+ public enum FFT_LineType
+ {
+ LineI = 0, LineII = 1
+ };
+ public class FFTDrawer : CommControl
+ {
+
+
+
+ private const double DefaultMasterGain = 0;
+ public double masterGainI
+ {
+ get { return (double)GetValue(masterGainIProperty); }
+ set { SetValue(masterGainIProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for masterGainI. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty masterGainIProperty =
+ DependencyProperty.Register("masterGainI", typeof(double), typeof(FFTDrawer), new PropertyMetadata(DefaultMasterGain));
+
+
+ ///
+ /// masterGainII change event popup
+ ///
+
+ public double masterGainII
+ {
+ get { return (double)GetValue(masterGainIIProperty); }
+ set { SetValue(masterGainIIProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for masterGainII. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty masterGainIIProperty =
+ DependencyProperty.Register("masterGainII", typeof(double), typeof(FFTDrawer), new PropertyMetadata(DefaultMasterGain));
+
+ private double[][] PointArray = new double[FFTConstaint.LINE_MAX][];
+ private double[][] curvePointArray = new double[FFTConstaint.CEQ_MAX * 2][];
+
+ private double[] FreqTemp = new double[FFTConstaint.CEQ_MAX * 2];
+ private double[] GainTemp = new double[FFTConstaint.CEQ_MAX * 2];
+ private int[] qIndexTemp = new int[FFTConstaint.CEQ_MAX * 2];
+
+ private bool isTouched = false;
+ // private bool isNeedDrawBlock = false;
+
+ private const FFT_LineType DefaultLineType = FFT_LineType.LineI;
+ public FFT_LineType activeLine
+ {
+ get { return (FFT_LineType)GetValue(activeLineProperty); }
+ set { SetValue(activeLineProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeLine. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty activeLineProperty =
+ DependencyProperty.Register("activeLine", typeof(FFT_LineType), typeof(FFTDrawer), new PropertyMetadata(DefaultLineType));
+
+ private const bool DefaultDrawWave = true;
+ public bool isDrawWave
+ {
+ get { return (bool)GetValue(isDrawWaveProperty); }
+ set { SetValue(isDrawWaveProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isDrawBlock. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isDrawWaveProperty =
+ DependencyProperty.Register("isDrawWave", typeof(bool), typeof(FFTDrawer),
+ new FrameworkPropertyMetadata(DefaultDrawWave, FrameworkPropertyMetadataOptions.None, onIsNeedWaveChange
+ ));
+
+ private static void onIsNeedWaveChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.isDrawWave = (bool)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+
+ private bool[] curveFlats = new bool[FFTConstaint.CEQ_MAX * 2]; //false as default
+ private Color[] curveColor = new Color[FFTConstaint.CEQ_MAX];
+
+ private Color[] circumColor = new Color[FFTConstaint.CEQ_MAX];
+
+
+ private const byte ColorAlpha = 134;
+
+
+ private const bool DefaultSupportMutiLine = false;
+ public bool isSupportMutiLine
+ {
+ get { return (bool)GetValue(isSupportMutiLineProperty); }
+ set { SetValue(isSupportMutiLineProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isSupportMutiLine. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isSupportMutiLineProperty =
+ DependencyProperty.Register("isSupportMutiLine", typeof(bool), typeof(FFTDrawer), new PropertyMetadata(DefaultSupportMutiLine));
+
+ private const bool DefaultHasHLPF = false;
+ public bool isHasHLPF
+ {
+ get { return (bool)GetValue(isHasHLPFProperty); }
+ set { SetValue(isHasHLPFProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isHasHLPF. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isHasHLPFProperty =
+ DependencyProperty.Register("isHasHLPF", typeof(bool), typeof(FFTDrawer), new PropertyMetadata(DefaultHasHLPF));
+
+ private static readonly CultureInfo CIR = System.Globalization.CultureInfo.CurrentCulture;
+
+ public void setCureFlat(bool isFlat, int eindex, bool isRedraw)
+ {
+ curveFlats[eindex] = isFlat;
+ if (isRedraw)
+ Redraw();
+ }
+
+ ///
+ ///
+ ///
+ private const double DefaultBlockDiameter = 10;
+
+ public double BlockDiameter
+ {
+ get { return (double)GetValue(BlockDiameterProperty); }
+ set { SetValue(BlockDiameterProperty, value); }
+ }
+ // Using a DependencyProperty as the backing store for BlockDiameter. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BlockDiameterProperty =
+ DependencyProperty.Register("BlockDiameter", typeof(double), typeof(FFTDrawer), new PropertyMetadata(DefaultBlockDiameter));
+
+
+
+ private const int DefaultSelIndex = 0;
+
+
+ ///
+ /// is used for mark left/right q block
+ ///
+ public int activeSelectBlockIndex
+ {
+ get { return (int)GetValue(activeSelectBlockIndexProperty); }
+ set { SetValue(activeSelectBlockIndexProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeSelectBlockIndex. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty activeSelectBlockIndexProperty =
+ DependencyProperty.Register("activeSelectBlockIndex", typeof(int), typeof(FFTDrawer), new PropertyMetadata(DefaultSelIndex));
+
+
+
+
+
+
+
+ private const int DefaultPKMouseIndex = -1;
+ public int PKMouseIndex
+ {
+ get { return (int)GetValue(PKMouseIndexProperty); }
+ set { SetValue(PKMouseIndexProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for PKMouseIndex. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty PKMouseIndexProperty =
+ DependencyProperty.Register("PKMouseIndex", typeof(int), typeof(FFTDrawer), new PropertyMetadata(DefaultPKMouseIndex));
+
+ public void setBlockData(double freq, double gain, double qvalue, int eindex)
+ {
+ FreqTemp[eindex] = freq;
+ GainTemp[eindex] = gain;
+ int qvindex = HalfSearcher.search(StrValueTables.QVFactorTable, StrValueTables.QVFactorTable.Length, qvalue);
+ if (qvindex >= 0)
+ {
+ qIndexTemp[eindex] = qvindex;
+ // Debug.WriteLine("fftdrawer listener writinto for save qindex {0} eqindex {1}", qvindex, eindex);
+
+ }
+
+
+ }
+
+ ///
+ /// initial parameters
+ ///
+ protected void initalProperty()
+ {
+ if (PointArray == null)
+ PointArray = new double[FFTConstaint.LINE_MAX][];
+ if (curvePointArray == null)
+ curvePointArray = new double[FFTConstaint.CEQ_MAX * 2][];
+
+ if (FreqTemp == null)
+ FreqTemp = new double[FFTConstaint.CEQ_MAX * 2];
+
+ if (GainTemp == null)
+ GainTemp = new double[FFTConstaint.CEQ_MAX * 2];
+
+
+ for (int i = 0; i < FFTConstaint.LINE_MAX; i++)
+ {
+ PointArray[i] = new double[FFTConstaint.NFFT];
+ }
+
+ for (int i = 0; i < FFTConstaint.CEQ_MAX * 2; i++)
+ {
+ curvePointArray[i] = new double[FFTConstaint.NFFT];
+ }
+ curveColor[0] = Color.FromArgb(ColorAlpha, 233, 252, 227);
+ //high ,low for reserved
+ curveColor[1] = Color.FromArgb(ColorAlpha, 0, 140, 245);
+ curveColor[2] = Color.FromArgb(ColorAlpha, 166, 202, 240);
+ curveColor[3] = Color.FromArgb(ColorAlpha, 255, 0, 255);
+ curveColor[4] = Color.FromArgb(ColorAlpha, 28, 163, 97);
+
+ curveColor[5] = Color.FromArgb(ColorAlpha, 58, 110, 165);
+ curveColor[6] = Color.FromArgb(ColorAlpha, 255, 0, 0);
+ curveColor[7] = Color.FromArgb(ColorAlpha, 255, 255, 0);
+
+ curveColor[8] = Color.FromArgb(ColorAlpha, 28, 163, 97); //high filterPas
+ curveColor[9] = Color.FromArgb(ColorAlpha, 0, 255, 0);//low filterPas
+
+
+ //circumColor
+ circumColor[0] = Color.FromRgb(233, 252, 227);
+ //high ,low for reserved
+ circumColor[1] = Color.FromRgb(0xFF, 0xFF, 0xFF);
+ circumColor[2] = Color.FromRgb(166, 202, 240);
+ circumColor[3] = Color.FromRgb(255, 0, 255);
+ circumColor[4] = Color.FromRgb(28, 163, 97);
+
+ circumColor[5] = Color.FromRgb(0xFF, 0xFF, 0xFF);
+ circumColor[6] = Color.FromRgb(255, 0, 0);
+ circumColor[7] = Color.FromRgb(255, 255, 0);
+
+ circumColor[8] = Color.FromRgb(0xFF, 0xFF, 0xFF); //high filterPas
+ circumColor[9] = Color.FromRgb(0, 255, 0);//low filterPas
+
+
+
+
+ }
+
+
+
+
+ public void set_CurveEQData(int eindex, double[] eData) //[0..19]
+ {
+ if (eData == null || eData.Length != FFTConstaint.NFFT) return;
+ Array.Copy(eData, 0, curvePointArray[eindex], 0, FFTConstaint.NFFT);
+
+ }
+
+
+
+ private static SolidColorBrush DefaultTextBrush = Brushes.White;
+
+ public SolidColorBrush textBlockBrush
+ {
+ get { return (SolidColorBrush)GetValue(textBlockBrushProperty); }
+ set { SetValue(textBlockBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for textBlockBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty textBlockBrushProperty =
+ DependencyProperty.Register("textBlockBrush", typeof(SolidColorBrush), typeof(FFTDrawer), new PropertyMetadata(DefaultTextBrush));
+
+
+
+ public SolidColorBrush circleBlockBrush
+ {
+ get { return (SolidColorBrush)GetValue(circleBlockBrushProperty); }
+ set { SetValue(circleBlockBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for circleBlockBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty circleBlockBrushProperty =
+ DependencyProperty.Register("circleBlockBrush", typeof(SolidColorBrush), typeof(FFTDrawer), new PropertyMetadata(DefaultTextBrush));
+
+
+
+ private static SolidColorBrush DefaultFilBrush = Brushes.Transparent;
+ public SolidColorBrush fillBlockBrush
+ {
+ get { return (SolidColorBrush)GetValue(fillBlockBrushProperty); }
+ set { SetValue(fillBlockBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for fillBlockBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fillBlockBrushProperty =
+ DependencyProperty.Register("fillBlockBrush", typeof(SolidColorBrush), typeof(FFTDrawer), new PropertyMetadata(DefaultFilBrush));
+
+
+ public void drawCircleBlock_withInnerText(DrawingContext cvs, int eindex, int chindex)
+ {
+ int eqindex = (chindex == 0 ? eindex : eindex + FFTConstaint.CEQ_MAX);
+ //double gMaster = (chindex == 0 ? masterGainI : masterGainII);
+
+ if (!curveFlats[eqindex])
+ {
+ double px = getBlockPosX(eqindex);
+ double py = getBlockPosY(eqindex);
+
+ // Debug.WriteLine("block pos x:{0}:y:{1} eqindex is : {2}", px, py, eindex);
+ string ftext = (eindex + 1).ToString();
+ double fontsize = 10.0;
+ double offsetX = 3.0;
+ double offsetY = 7.0;
+ double circleRadiosX = DefaultBlockDiameter - 2;
+ double circleRadiosY = DefaultBlockDiameter - 2;
+
+ SolidColorBrush penbrush = (chindex == 0 ? gLineBrush : gLineBrushII);
+ if (!isSupportMutiLine)
+ penbrush = circleBlockBrush;
+ if (eindex == FFTConstaint.CEQ_MAX - 2)
+ {
+ ftext = "HPF";
+ fontsize = 7;
+ offsetX = 6.5;
+ offsetY = 5;
+ circleRadiosX = DefaultBlockDiameter;
+ circleRadiosY = DefaultBlockDiameter - 2;
+ }
+ else if (eindex == FFTConstaint.CEQ_MAX - 1)
+ {
+ ftext = "LPF";
+ fontsize = 7;
+ offsetX = 6.5;
+ offsetY = 5;
+ circleRadiosX = DefaultBlockDiameter;
+ circleRadiosY = DefaultBlockDiameter - 2;
+
+ }
+ FormattedText texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, textBlockBrush);
+ if (py > this.ActualHeight - offsetY * 2) return;
+
+ cvs.DrawEllipse(fillBlockBrush, new Pen(penbrush, 1), new Point(px, py), circleRadiosX, circleRadiosY);
+
+
+ }
+
+ }
+ private const double Qdistance = 2.0;
+
+
+
+ private const double QDefaultRatio = 0.40;
+ public double QShiftRatio
+ {
+ get { return (double)GetValue(QShiftRatioProperty); }
+ set { SetValue(QShiftRatioProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for QShiftRatio. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty QShiftRatioProperty =
+ DependencyProperty.Register("QShiftRatio", typeof(double), typeof(FFTDrawer), new PropertyMetadata(QDefaultRatio));
+
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void drawSquareQBlock_withLine(DrawingContext cvs, int eindex, int chindex)
+ {
+ if (eindex < 0 || eindex >= FFTConstaint.CEQ_MAX) return;
+ int eqindex = (chindex == 0 ? eindex : eindex + FFTConstaint.CEQ_MAX);
+ //double gMaster = (chindex == 0 ? masterGainI : masterGainII);
+ if (!curveFlats[eqindex])
+ {
+ double px = getBlockPosX(eqindex);
+ double py = getBlockPosY(eqindex);
+
+ // Debug.WriteLine("block pos x:{0}:y:{1} eqindex is : {2}", px, py, eindex);
+
+ double diameter = DefaultBlockDiameter;
+
+ SolidColorBrush penbrush = Brushes.White; //(chindex == 0 ? gLineBrush : gLineBrushII);
+ //if (!isSupportMutiLine)
+ // penbrush = circleBlockBrush;
+ if (eindex < FFTConstaint.CEQ_MAX - 2)
+ {
+
+ double qvalue = QShiftRatio * qIndexTemp[eqindex];
+ Rect leftQblock = new Rect(px - 1.5 * diameter - Qdistance - qvalue, py - diameter / 2, diameter, diameter);
+ Rect rightQblock = new Rect(px + diameter / 2 + Qdistance + qvalue, py - diameter / 2, diameter, diameter);
+
+
+
+
+ //draw a line from left Qblock to right qblock with two center point
+ double leftQCenterX = px - diameter / 2 - Qdistance - diameter / 2 - qvalue;
+ double rightQCenterX = px + diameter / 2 + Qdistance + diameter / 2 + qvalue;
+ Pen linePen = new Pen(Brushes.Red, 1);
+ linePen.DashStyle = DashStyles.Dash;
+
+ if (py <= this.ActualHeight)
+ {
+ cvs.DrawLine(new Pen(Brushes.Red, 1), new Point(leftQCenterX, py), new Point(rightQCenterX, py));
+ //draw two left and right block
+ cvs.DrawRectangle(Brushes.Black, new Pen(penbrush, 2), leftQblock);
+ cvs.DrawRectangle(Brushes.Black, new Pen(penbrush, 2), rightQblock);
+ }
+
+
+ // if (py <= this.ActualHeight)
+ /// cvs.DrawRectangle(fillBlockBrush, new Pen(penbrush, 1), cRect);
+
+
+
+
+
+
+
+ }
+
+
+
+
+ }
+
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void drawSquareMainBlock_withUpText(DrawingContext cvs, int eindex, int chindex)
+ {
+ int eqindex = (chindex == 0 ? eindex : eindex + FFTConstaint.CEQ_MAX);
+ //double gMaster = (chindex == 0 ? masterGainI : masterGainII);
+
+ if (!curveFlats[eqindex])
+ {
+ double px = getBlockPosX(eqindex);
+ double py = getBlockPosY(eqindex);
+
+ // Debug.WriteLine("block pos x:{0}:y:{1} eqindex is : {2}", px, py, eindex);
+ string ftext = (eindex + 1).ToString();
+ double fontsize = 10.0;
+ double offsetX = 3.0;
+ double offsetY = 7.0 + DefaultBlockDiameter;
+ double squalRadius = DefaultBlockDiameter;
+
+ const double circleRadius = 7;
+ SolidColorBrush penbrush = Brushes.White; //(chindex == 0 ? gLineBrush : gLineBrushII);
+ if (isSupportMutiLine)
+ textBlockBrush = (chindex == 0 ? gLineBrush : gLineBrushII);
+
+ // if (!isSupportMutiLine)
+ // penbrush = circleBlockBrush;
+ if (eindex == FFTConstaint.CEQ_MAX - 2)
+ {
+ ftext = "HPF";
+ fontsize = 8;
+ offsetX = 6.5;
+ offsetY = 5 + DefaultBlockDiameter;
+ if (py <= this.ActualHeight)
+ cvs.DrawEllipse(fillBlockBrush, new Pen(penbrush, 1), new Point(px, py), circleRadius, circleRadius);
+ }
+ else if (eindex == FFTConstaint.CEQ_MAX - 1)
+ {
+ ftext = "LPF";
+ fontsize = 8;
+ offsetX = 6.5;
+ offsetY = 5 + DefaultBlockDiameter;
+ if (py <= this.ActualHeight)
+ cvs.DrawEllipse(fillBlockBrush, new Pen(penbrush, 1), new Point(px, py), circleRadius, circleRadius);
+ }
+ else
+ {
+ Rect cRect = new Rect(px - squalRadius / 2, py - squalRadius / 2, squalRadius, squalRadius);
+ if (py <= this.ActualHeight)
+ cvs.DrawRectangle(fillBlockBrush, new Pen(penbrush, 1), cRect);
+ }
+ FormattedText texte = new FormattedText(ftext, CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), fontsize, textBlockBrush);
+
+
+ if (py > this.ActualHeight) return;
+ cvs.DrawText(texte, new Point(px - offsetX, py - offsetY));
+
+
+
+ }
+
+ }
+
+ public void setGlobalEQData(double[] gData, int chindex)
+ {
+ if (gData == null || gData.Length != FFTConstaint.NFFT || chindex >= FFTConstaint.LINE_MAX || chindex < 0) return;
+ Array.Clear(PointArray[chindex], 0, FFTConstaint.NFFT); //first clear
+ Array.Copy(gData, PointArray[chindex], FFTConstaint.NFFT);
+ }
+
+
+
+ public FFTDrawer()
+ {
+ initalProperty();
+
+
+ }
+
+ ///
+ /// pen brush for the border
+ ///
+ private static SolidColorBrush DefaultPenBrush = Brushes.Black;
+ public SolidColorBrush penBrush
+ {
+ get { return (SolidColorBrush)GetValue(penBrushProperty); }
+ set { SetValue(penBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for penBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty penBrushProperty =
+ DependencyProperty.Register("penBrush", typeof(SolidColorBrush),
+ typeof(FFTDrawer), new PropertyMetadata(DefaultPenBrush));
+
+
+
+ private static SolidColorBrush DefaultGridHeadBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
+ public SolidColorBrush GridHeaderBrush
+ {
+ get { return (SolidColorBrush)GetValue(GridHeaderBrushProperty); }
+ set { SetValue(GridHeaderBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for GridHeaderBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty GridHeaderBrushProperty =
+ DependencyProperty.Register("GridHeaderBrush", typeof(SolidColorBrush), typeof(FFTDrawer), new PropertyMetadata(DefaultGridHeadBrush));
+
+
+
+ private static SolidColorBrush DefaultGridBrush = Brushes.LightBlue;
+ public SolidColorBrush GridBrush
+ {
+ get { return (SolidColorBrush)GetValue(GridBrushProperty); }
+ set { SetValue(GridBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for GridBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty GridBrushProperty =
+ DependencyProperty.Register("GridBrush", typeof(SolidColorBrush), typeof(FFTDrawer),
+ new FrameworkPropertyMetadata(DefaultGridBrush, FrameworkPropertyMetadataOptions.None, onGridBrushChange
+ ));
+
+ private static void onGridBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.GridBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+
+
+
+ private static SolidColorBrush DefaultLineBrush = Brushes.Red;
+ public SolidColorBrush gLineBrush
+ {
+ get { return (SolidColorBrush)GetValue(gLineBrushProperty); }
+ set { SetValue(gLineBrushProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for gLineBrush. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty gLineBrushProperty =
+ DependencyProperty.Register("gLineBrush", typeof(SolidColorBrush), typeof(FFTDrawer),
+ new FrameworkPropertyMetadata(DefaultLineBrush, FrameworkPropertyMetadataOptions.None, onGridBrushChange
+ ));
+
+ private static void onLineBrushChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.gLineBrush = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+ }
+
+ private static SolidColorBrush DefaultLineBrushII = Brushes.Blue;
+ public SolidColorBrush gLineBrushII
+ {
+ get { return (SolidColorBrush)GetValue(gLineBrushIIProperty); }
+ set { SetValue(gLineBrushIIProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for gLineBrushII. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty gLineBrushIIProperty =
+ DependencyProperty.Register("gLineBrushII", typeof(SolidColorBrush), typeof(FFTDrawer),
+ new FrameworkPropertyMetadata(DefaultLineBrushII, FrameworkPropertyMetadataOptions.None, onLineBrushIIChange
+ ));
+ private static void onLineBrushIIChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.gLineBrushII = (SolidColorBrush)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+
+ //new PropertyMetadata(0));
+
+ ///
+ /// borderThick
+ ///
+ private const double DefaultBorderThick = 0.5;
+ public double BorderThick
+ {
+ get { return (double)GetValue(BorderThickProperty); }
+ set { SetValue(BorderThickProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for borderThick. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty BorderThickProperty =
+ DependencyProperty.Register("BorderThick", typeof(double), typeof(FFTDrawer),
+ new FrameworkPropertyMetadata(DefaultBorderThick, FrameworkPropertyMetadataOptions.None, onBorderThickChange
+ ));
+
+ private static void onBorderThickChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var mcontrol = obj as FFTDrawer;
+ if (mcontrol != null)
+ {
+ // mcontrol.isLoopReverse = (bool)args.NewValue;
+ mcontrol.BorderThick = (double)args.NewValue;
+ mcontrol.Redraw();
+ }
+
+ }
+ //
+ private SolidColorBrush txtBrush = new SolidColorBrush(Color.FromRgb(255, 255, 0));
+ protected void drawGrid(DrawingContext cvs)
+ {
+ double anx = this.ActualWidth;
+ double any = this.ActualHeight;
+ double delta, yy;
+ delta = (FFTConstaint.FYMax - FFTConstaint.FYMin) / (FFTConstaint.FNumHorzGrid + 1);
+
+ cvs.DrawLine(new Pen(GridHeaderBrush, 1), new Point(0, 0), new Point(anx, 0));
+
+ for (int i = 0; i < FFTConstaint.FNumHorzGrid; i++) //
+ {
+
+ yy = logValue_ToFFTScreenY(FFTConstaint.FYMin + delta * (i + 1));
+ if (i != (FFTConstaint.FNumHorzGrid - 1) / 2)
+ {
+ cvs.DrawLine(new Pen(GridBrush, 1), new Point(0, yy), new Point(anx, yy));
+ }
+ FormattedText texte = new FormattedText(FFTConstaint.strGridGainTable[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), 10, txtBrush);
+ cvs.DrawText(texte, new Point(0 - 22, yy - 5));
+
+ }
+ //draw middle
+ double midle = logValue_ToFFTScreenY(FFTConstaint.FYMin + delta * 3);
+ cvs.DrawLine(new Pen(GridBrush, 1), new Point(0, midle), new Point(anx, midle));
+ for (int i = 0; i < FFTConstaint.GridFreqTable.Length; i++) //for test the coordinate stand FFTConstaint.BZPlotBNum
+ {
+ double xx = freqToLogPosX(FFTConstaint.GridFreqTable[i]);
+
+ double kpos = logPosXToFFTScreenPos(xx);
+ // Debug.WriteLine("xx zuobiao is : {0} kpos is :{1} with freqindex : {2} freq {3}", xx, kpos, FFTConstaint.GridFreqTable[i], i);
+ cvs.DrawLine(new Pen(GridBrush, 1), new Point(kpos, 0), new Point(kpos, any));
+
+ FormattedText texte = new FormattedText(FFTConstaint.strGridFreqTable[i], CIR, FlowDirection.LeftToRight,
+ new Typeface("Verdana"), 10, txtBrush);
+ cvs.DrawText(texte, new Point(kpos - 6, any));
+
+
+ }
+
+ cvs.DrawLine(new Pen(GridHeaderBrush, 1), new Point(0, any), new Point(anx, any));
+
+ }
+
+ ///
+ /// mouse Event below
+ ///
+ public delegate void fftDrawMouseDown(Point px, MouseButtonEventArgs e);
+ public event fftDrawMouseDown onFFTMouseDownEvent;
+ //
+ public delegate void fftDrawMouseMove(int freqindex, int gaindex, int qindex, int pkindex, MouseEventArgs e);
+ public event fftDrawMouseMove onFFTMouseMoveEvent;
+
+ public delegate void fftDrawMouseUp(Point px, MouseButtonEventArgs e);
+ public event fftDrawMouseUp onFFTMouseUpEvent;
+
+
+
+ private const double DefaultCaptureRadius = 6.0;
+ public double CaptureRadius
+ {
+ get { return (double)GetValue(CaptureRadiusProperty); }
+ set { SetValue(CaptureRadiusProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for CaptureRadius. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty CaptureRadiusProperty =
+ DependencyProperty.Register("CaptureRadius", typeof(double), typeof(FFTDrawer), new PropertyMetadata(DefaultCaptureRadius));
+
+ private int PKMouSelectingQindex = -1;
+
+ protected override void OnMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseDown(e);
+ // QMoveOrignal = 0;
+ isTouched = true;
+ int sa = 0;
+ int sb = 0;
+ double diameter = DefaultBlockDiameter;
+ if (isSupportMutiLine && activeLine == FFT_LineType.LineII)
+ {
+ sa = FFTConstaint.CEQ_MAX;
+ sb = FFTConstaint.CEQ_MAX * 2;
+ }
+ else
+ {
+ sa = 0;
+ sb = FFTConstaint.CEQ_MAX;
+ }
+ for (int i = sa; i < sb; i++)
+ {
+ double px = getBlockPosX(i);
+ double py = getBlockPosY(i);
+ Point epx = e.GetPosition(this);
+ if ((Math.Abs(px - epx.X) <= CaptureRadius) && (Math.Abs(py - epx.Y) <= CaptureRadius))
+ {
+ Mouse.SetCursor(Cursors.Hand);
+ PKMouseIndex = (i >= FFTConstaint.CEQ_MAX ? i - FFTConstaint.CEQ_MAX : i);
+
+ if (PKMouseIndex >= 0 && PKMouseIndex < FFTConstaint.CEQ_MAX - 2)
+ {
+ activeSelectBlockIndex = PKMouseIndex; //0..9 for q block active select ,defaut is 0
+ // PKMouSelectingQindex = -1;
+ }
+
+ //Debug.WriteLine("mouseDown here....search index is : {0}", PKindex);
+ if (onFFTMouseDownEvent != null)
+ {
+ onFFTMouseDownEvent(e.GetPosition(this), e);
+ }
+ break;
+ }
+
+ double qvalue = QShiftRatio * qIndexTemp[i];
+ double leftQCenterX = px - diameter / 2 - Qdistance - diameter / 2 - qvalue;
+ double rightQCenterX = px + diameter / 2 + Qdistance + diameter / 2 + qvalue;
+ if ((Math.Abs(leftQCenterX - epx.X) <= CaptureRadius) && (Math.Abs(py - epx.Y) <= CaptureRadius))
+ {
+ QMoveOrignal = FFTConstaint.QMoveLeft;//left qvalue
+ PKMouSelectingQindex = (i >= FFTConstaint.CEQ_MAX ? i - FFTConstaint.CEQ_MAX : i); //0..9
+ Debug.WriteLine("eq qvalue detect index is {0} qmove orignal is {1} ", PKMouSelectingQindex, QMoveOrignal);
+ break;
+ }
+ else if ((Math.Abs(rightQCenterX - epx.X) <= CaptureRadius) && (Math.Abs(py - epx.Y) <= CaptureRadius))
+ {
+ QMoveOrignal = FFTConstaint.QMoveRight;//right qvalue
+ PKMouSelectingQindex = (i >= FFTConstaint.CEQ_MAX ? i - FFTConstaint.CEQ_MAX : i); //0..9
+ // PKMouseIndex = -1;
+ Debug.WriteLine("eq qvalue detect index is {0} qmove orignal is {1} ", PKMouSelectingQindex, QMoveOrignal);
+ Mouse.SetCursor(Cursors.Hand);
+ break;
+ }
+
+ }
+ }
+ private int QMoveOrignal = 0;
+
+ protected override void OnMouseUp(MouseButtonEventArgs e)
+ {
+ base.OnMouseUp(e);
+ isTouched = false;
+ PKMouseIndex = -1;
+ PKMouSelectingQindex = -1;
+ Mouse.SetCursor(Cursors.None);
+ // Debug.WriteLine("on mouse up...............");
+ if (onFFTMouseUpEvent != null)
+ {
+ onFFTMouseUpEvent(e.GetPosition(this), e);
+ Redraw();
+ }
+
+ // shift = 0;
+ // redraw();
+ }
+
+
+
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (!isTouched || (PKMouseIndex == -1 && PKMouSelectingQindex == -1))
+ {
+ #region detect the active mainblock and switch it case when is not touched.
+ int sa = 0;
+ int sb = 0;
+ if (isSupportMutiLine && activeLine == FFT_LineType.LineII)
+ {
+ sa = FFTConstaint.CEQ_MAX;
+ sb = FFTConstaint.CEQ_MAX * 2;
+ }
+ else
+ {
+ sa = 0;
+ sb = FFTConstaint.CEQ_MAX;
+ }
+ for (int i = sa; i < sb; i++)
+ {
+ double px = getBlockPosX(i);
+ double py = getBlockPosY(i);
+ Point fepx = e.GetPosition(this);
+ if ((Math.Abs(px - fepx.X) <= CaptureRadius) && (Math.Abs(py - fepx.Y) <= CaptureRadius))
+ {
+ // Mouse.SetCursor(Cursors.Hand);
+ int tmpMouseIndex = (i >= FFTConstaint.CEQ_MAX ? i - FFTConstaint.CEQ_MAX : i);
+
+ if (tmpMouseIndex >= 0 && tmpMouseIndex < FFTConstaint.CEQ_MAX - 2)
+ {
+ activeSelectBlockIndex = tmpMouseIndex;
+ Redraw();
+ }
+ break;
+ }
+
+ }
+ #endregion
+ return;
+ }
+
+ if (e.LeftButton == MouseButtonState.Released)
+ {
+ isTouched = false;
+ PKMouseIndex = -1;
+ PKMouSelectingQindex = -1;
+
+ Mouse.SetCursor(Cursors.None);
+ return;
+ }
+
+ #region begin move the mainblock in condition
+
+ Mouse.SetCursor(Cursors.Hand);
+ Point epx = e.GetPosition(this);
+ double mx = epx.X;
+ double my = epx.Y;
+
+ if (PKMouseIndex >= 0)
+ {
+ double freq = fftScreenPosXToFreq(mx);
+ double gMaster = 0;
+ if (isSupportMutiLine && activeLine == FFT_LineType.LineII)
+ gMaster = masterGainII;
+ else
+ gMaster = masterGainI;
+
+ double gain = fftScreenY_ToLogValueY(my) - gMaster;
+ int freqindex = HalfSearcher.search(FFTConstaint.FreqTable, FFTConstaint.FreqTable.Length, freq);
+ int gaindex = HalfSearcher.search(FFTConstaint.EqGain, FFTConstaint.EqGain.Length, gain);
+
+ if (freqindex >= 0 && freqindex < FFTConstaint.FreqTable.Length && gaindex >= 0 && gaindex < FFTConstaint.EqGain.Length)
+ {
+ if (isHasHLPF && (PKMouseIndex == FFTConstaint.CEQ_MAX - 2 || PKMouseIndex == FFTConstaint.CEQ_MAX - 1))
+ gaindex = FFTConstaint.EqGain.Length / 2;
+
+ if (onFFTMouseMoveEvent != null)
+ {
+
+ onFFTMouseMoveEvent(freqindex, gaindex, FFTConstaint.NONQvalue, PKMouseIndex, e);
+ }
+
+ // Debug.WriteLine("on mouse move now..............");
+
+ }
+ }
+ #endregion
+ //left q or right q block is selected
+ if (PKMouSelectingQindex >= 0)
+ {
+ int eindex = PKMouSelectingQindex;
+ if (activeLine == FFT_LineType.LineII)
+ eindex += FFTConstaint.CEQ_MAX;
+
+ double px = getBlockPosX(eindex);
+ double py = getBlockPosY(eindex);
+
+ double currentCentQX = 0;
+
+ Debug.WriteLine("qvalue mouse move index is ---------------: {0} ", eindex);
+ if (QMoveOrignal == FFTConstaint.QMoveLeft || QMoveOrignal == FFTConstaint.QMoveRight)
+ {
+ if (QMoveOrignal == FFTConstaint.QMoveLeft)
+ currentCentQX = px - BlockDiameter - Qdistance;
+ else
+ currentCentQX = px + BlockDiameter + Qdistance;
+ //caculate the distance between the Qvalue center block x and current mouse x point
+ double deltaQ = (mx - currentCentQX);
+ // if (deltaQ >= 0)
+ {
+ double movQ = (double)deltaQ / QShiftRatio;
+
+ if (QMoveOrignal == FFTConstaint.QMoveLeft && movQ > 0)
+ movQ = 0;
+ else if (QMoveOrignal == FFTConstaint.QMoveRight && movQ < 0)
+ movQ = 0;
+ // Debug.WriteLine("qmove orignal is : {0} deltaQ is {1} movQ index is {2} eqindex :{3}",QMoveOrignal,deltaQ, movQ,eindex);
+
+ movQ = Math.Abs(Math.Round(movQ));
+ int tmpQindex = limitQvalue((int)movQ);
+ // Debug.WriteLine("move qvalue is : {0} tmpqindex is :{1} currentCentQX {2}", movQ, tmpQindex, currentCentQX);
+ if (onFFTMouseMoveEvent != null)
+ {
+ onFFTMouseMoveEvent(FFTConstaint.NONFreq, FFTConstaint.NONGain, tmpQindex, PKMouSelectingQindex, e);
+ }
+
+ }
+
+ }
+
+
+ }
+
+
+
+
+ }
+ private const int MaxQvalue = 100;
+
+ public int limitQvalue(int newvalue)
+ {
+ return Math.Max(0, Math.Min(MaxQvalue, newvalue)); //very good
+ }
+
+
+ private const double DefaultGLineWidth = 2.8;
+ public double gLineWidth
+ {
+ get { return (double)GetValue(gLineWidthProperty); }
+ set { SetValue(gLineWidthProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for gLineWidth. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty gLineWidthProperty =
+ DependencyProperty.Register("gLineWidth", typeof(double), typeof(FFTDrawer), new PropertyMetadata(DefaultGLineWidth));
+
+ #region freq-->lgopos->fftscreenPos
+ ///
+ /// convert freq(double) to Log Pos
+ ///
+ ///
+ ///
+ /// freq-->logpos->screenpos
+ public static double freqToLogPosX(double freq)
+ {
+
+ return Math.Log10(freq) / Math.Log10(FFTConstaint.SAMPLERATE) * FFTConstaint.NFFT;
+
+ }
+
+ ///
+ /// convert x log Pos to fftdraw sceen pos
+ ///
+ ///
+ ///
+ public double logPosXToFFTScreenPos(double x) //screenX
+ {
+
+ double fWidth = ActualWidth;
+ return fWidth * (x - FFTConstaint.FXMin) / (FFTConstaint.FXMax - FFTConstaint.FXMin);
+
+ }
+
+ public double freqToFFTScreenPosX(double freq)
+ {
+ return logPosXToFFTScreenPos(freqToLogPosX(freq));
+ }
+
+ #endregion
+ #region fftscreenpos--->logpos--->freqs
+ public static double logPosX_ToFreq(double screen)
+ {
+ return Math.Pow(10, screen / FFTConstaint.NFFT * Math.Log10(FFTConstaint.SAMPLERATE));
+ }
+
+ ///
+ /// convert screen x at point to freq
+ ///
+ /// s
+ ///
+ public double fftScreenPosX_ToLogPosX(double x)
+ {
+ double fWidth = this.ActualWidth;
+ return x * (FFTConstaint.FXMax - FFTConstaint.FXMin) / fWidth + FFTConstaint.FXMin;//fftScreenPos_toLogPoss
+ }
+ public double fftScreenPosXToFreq(double x)
+ {
+ return logPosX_ToFreq(fftScreenPosX_ToLogPosX(x));
+ }
+
+ #endregion
+ public double logValue_ToFFTScreenY(double y) //screenY
+ {
+ double fHeight = this.ActualHeight;
+ return fHeight - fHeight * (y - FFTConstaint.FYMin) / (FFTConstaint.FYMax - FFTConstaint.FYMin);
+ }
+
+ public double fftScreenY_ToLogValueY(double y)
+ {
+ double fHeight = this.ActualHeight;
+ return (fHeight - y) * (FFTConstaint.FYMax - FFTConstaint.FYMin) / fHeight + FFTConstaint.FYMin;
+
+ }
+
+
+ private void drawGlobalLineOld(DrawingContext dc, int chindex)
+ {
+ Point p1 = new Point();
+ Point p2 = new Point();
+ Pen mPen = null;
+ double gMaster = 0;
+ if (chindex == 0)
+ {
+ mPen = new Pen(gLineBrush, gLineWidth);
+ gMaster = masterGainI;
+
+ }
+ else
+ {
+ mPen = new Pen(gLineBrushII, gLineWidth);
+ gMaster = masterGainII;
+ }
+ if(mPen!=null)
+ mPen.Freeze();
+
+ int i = 0;
+ for (i = 0; i < FFTConstaint.NFFT - 1; i++)
+ {
+
+ p1.X = logPosXToFFTScreenPos(i);
+ if (p1.X >= 0)
+ {
+ // Debug.WriteLine("point 1 x is :{0} i is :{1}", p1.X, i);
+ double tmp = logValue_ToFFTScreenY(PointArray[chindex][i] + gMaster);
+ if (tmp <= this.ActualHeight)
+ p1.Y = tmp;
+ // if (p1.Y > this.ActualHeight)
+ // p1.Y = this.ActualHeight;
+ // mPen = new Pen(Brushes.Transparent, gLineWidth);
+ // else
+ // mPen = mPen; //new Pen(gLineBrush, gLineWidth);
+
+ // p1.Y = this.ActualHeight;
+
+ p2.X = logPosXToFFTScreenPos(i + 1);
+ if (p2.X <= ActualWidth)
+ {
+
+ tmp = logValue_ToFFTScreenY(PointArray[chindex][i + 1] + gMaster);
+ if (tmp <= this.ActualHeight)
+ p2.Y = tmp;
+ //if (p2.Y > this.ActualHeight)
+ // mPen = new Pen(Brushes.Transparent, gLineWidth);
+ // if (p2.Y > this.ActualHeight)
+ // p2.Y = this.ActualHeight;
+ // else
+ //mPen = new Pen(gLineBrush, gLineWidth);
+ }
+ // else
+ // break;
+ dc.DrawLine(mPen, p1, p2);
+ }
+
+ }
+ //dc.DrawLine()
+ }
+
+ public bool isPointInRect(Point pt)
+ {
+
+ return (pt.X >= 0 && pt.X <= this.ActualWidth && pt.Y >= 0 && pt.Y <= this.ActualHeight);
+
+ }
+ ///
+ /// drawGlobalLine,note in wpf draw with DrawingContext can draw outside line (left or right end)
+ ///
+ ///
+ private void drawGlobalLine(DrawingContext dc, int chindex)
+ {
+
+ Point p1 = new Point();
+ Point p2 = new Point();
+ Pen mPen = null;
+ double gMaster = 0;
+ if (chindex == 0)
+ {
+ mPen = new Pen(gLineBrush, gLineWidth);
+ gMaster = masterGainI;
+
+ }
+ else
+ {
+ mPen = new Pen(gLineBrushII, gLineWidth);
+ gMaster = masterGainII;
+ }
+ if (mPen != null)
+ mPen.Freeze();
+ int i = 0;
+ for (i = 0; i < FFTConstaint.NFFT - 1; i++)
+ {
+
+ p1.X = logPosXToFFTScreenPos(i);
+ // Debug.WriteLine("point 1 x is :{0} i is :{1}", p1.X, i);
+ p1.Y = logValue_ToFFTScreenY(PointArray[chindex][i] + gMaster);
+
+ p2.X = logPosXToFFTScreenPos(i + 1);
+ p2.Y = logValue_ToFFTScreenY(PointArray[chindex][i + 1] + gMaster);
+ if (isPointInRect(p1) && isPointInRect(p2))
+ dc.DrawLine(mPen, p1, p2);
+
+
+ }
+
+ }
+
+ public void drawWave(DrawingContext dc, int eindex, int chindex)
+ {
+
+ double[] tmpAray = new double[FFTConstaint.NFFT]; //+ 2
+ double gMaster = 0;
+ if (chindex == 0)
+ {
+ Array.Copy(curvePointArray[eindex], 0, tmpAray, 0, FFTConstaint.NFFT);
+ gMaster = masterGainI;
+ }
+
+ else
+ {
+ Array.Copy(curvePointArray[eindex + FFTConstaint.CEQ_MAX], 0, tmpAray, 0, FFTConstaint.NFFT);
+ gMaster = masterGainII;
+ }
+
+ //tmpAray[FFTConstaint.NFFT+1]=
+
+ PathFigure pf = new PathFigure();
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ if (logPosXToFFTScreenPos(i) >= 0 && logPosXToFFTScreenPos(i) <= this.ActualWidth)
+ {
+ Point pt = new Point(logPosXToFFTScreenPos(i), logValue_ToFFTScreenY(tmpAray[i] + gMaster));
+ if (pt.Y > this.ActualHeight)
+ pt.Y = this.ActualHeight;
+
+ PathSegment ps = new LineSegment(pt, true);
+ pf.Segments.Add(ps);
+ }
+ }
+
+ Point pt1 = new Point(this.ActualWidth, logValue_ToFFTScreenY(0 + gMaster));
+ if (pt1.Y > this.ActualHeight)
+ pt1.Y = this.ActualHeight;
+ PathSegment ps1 = new LineSegment(pt1, true);
+ pf.Segments.Add(ps1);
+ //point2
+ Point pt2 = new Point(0, logValue_ToFFTScreenY(0 + gMaster));
+ if (pt2.Y > this.ActualHeight)
+ pt2.Y = this.ActualHeight;
+
+ PathSegment ps2 = new LineSegment(pt2, true);
+ pf.Segments.Add(ps2);
+ Geometry g = new PathGeometry(new[] { pf });
+
+ dc.DrawGeometry(new SolidColorBrush(curveColor[eindex]), null, g);
+
+
+
+ }
+
+ private Rect combRect(int chindex)
+ {
+ double gMaster = 0;
+ if (chindex == 0)
+ gMaster = masterGainI;
+ else
+ gMaster = masterGainII;
+ Point pt0 = new Point(0, this.ActualHeight / 2 - gMaster);
+ // Point pt1 = new Point(0, this.ActualHeight / 2 + gMaster);
+ Point pt2 = new Point(this.ActualWidth, this.ActualHeight / 2 - gMaster * 4);
+ //Point pt3 = new Point(this.ActualWidth, this.ActualHeight / 2);
+ return (new Rect(pt0, pt2));
+ }
+
+
+ public int CEQNumber
+ {
+ get
+ {
+ return (isHasHLPF ? FFTConstaint.CEQ_MAX : FFTConstaint.CEQ_MAX - 2);
+ }
+
+
+ }
+
+ public void drawAllPlots(DrawingContext dc)
+ {
+ drawGlobalLine(dc, 0);
+ if (isSupportMutiLine)
+ drawGlobalLine(dc, 1);
+ if (isDrawWave)
+ {
+ for (int i = 0; i < CEQNumber; i++) //FFTConstaint.CEQ_MAX/2
+ drawWave(dc, i, 0);
+ }
+ for (int i = 0; i < CEQNumber; i++) //FFTConstaint.CEQ_MAX/2
+ drawSquareMainBlock_withUpText(dc, i, 0);
+
+ // drawSquareQBlock_withLine(dc, activeSelectBlockIndex, 0);
+ if (isSupportMutiLine)
+ {
+ if (isDrawWave)
+ {
+ for (int i = 0; i < CEQNumber; i++) //FFTConstaint.CEQ_MAX/2
+ drawWave(dc, i, 1);
+ }
+
+ for (int i = 0; i < CEQNumber; i++) //FFTConstaint.CEQ_MAX/2
+ {
+ drawSquareMainBlock_withUpText(dc, i, 1);
+ }
+
+ }
+
+ int chindex = (int)activeLine; //0 or 1
+ drawSquareQBlock_withLine(dc, activeSelectBlockIndex, chindex);
+
+ }
+
+ ///
+ /// onRender Main Method
+ ///
+ ///
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ double wd = ActualWidth;
+ double ht = ActualHeight;
+ // Debug.WriteLine("on render width ,height is : {0} {1}", wd, ht);
+ dc.DrawRectangle(BackBrush, new Pen(penBrush, BorderThick), new Rect(0, 0, wd, ht));
+ drawGrid(dc);
+ drawAllPlots(dc);
+
+ }
+
+
+
+ #region function define below..........
+
+ public double getBlockPosX(int eindex)
+ {
+ return freqToFFTScreenPosX(FreqTemp[eindex]);
+ }
+
+
+ //but only changed of the entire y position
+ public double getBlockPosY(int eindex)
+ {
+ double gMastr = masterGainI;
+ if (eindex >= FFTConstaint.CEQ_MAX)
+ gMastr = this.masterGainII;
+ return logValue_ToFFTScreenY(GainTemp[eindex] + gMastr);
+ }
+ #endregion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // protected double screenx
+
+
+ }
+
+
+
+}
diff --git a/LibControl/Controls/FFTControl/HalfSearcher.cs b/LibControl/Controls/FFTControl/HalfSearcher.cs
new file mode 100644
index 0000000..16ac615
--- /dev/null
+++ b/LibControl/Controls/FFTControl/HalfSearcher.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lib.Controls
+{
+ public class HalfSearcher
+ {
+ public static int search(double[] buf, int length, double mvalue)
+ {
+ int mid, start = 0, end = length - 1;
+ while (start < end)
+ {
+ mid = (start + end) / 2;
+ if (buf[mid] < mvalue)
+ {
+ start = mid + 1;
+ }
+ else if (buf[mid] > mvalue)
+ {
+ end = mid - 1;
+ }
+ else
+ {
+ return mid;
+ }
+ }
+ return start;
+ }
+ }
+}
+
+
+
diff --git a/LibControl/Controls/FFTControl/XChannelFFTDataGenerator.cs b/LibControl/Controls/FFTControl/XChannelFFTDataGenerator.cs
new file mode 100644
index 0000000..66c7f4d
--- /dev/null
+++ b/LibControl/Controls/FFTControl/XChannelFFTDataGenerator.cs
@@ -0,0 +1,272 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Diagnostics;
+using System.Threading;
+using System.Windows.Threading;
+using Lib.Controls.FFTControl;
+namespace Lib.Controls
+{
+ public class EQParam
+ {
+ public double Freq { get; set; }
+ public double Gain { get; set; }
+ public double QValue { get; set; }
+ public int TypeFilter { get; set; }
+ public byte ByPass { get; set; }
+ public EQParam()
+ {
+
+ }
+ public EQParam(double freq, double gain, double qvalue, int typef, byte bypass)
+ {
+ Freq = freq;
+ Gain = gain;
+ QValue = qvalue;
+ TypeFilter = typef;
+ ByPass = bypass;
+ }
+ public void setEQParam(double freq, double gain, double qvalue, int typef, byte bypass)
+ {
+ Freq = freq;
+ Gain = gain;
+ QValue = qvalue;
+ TypeFilter = typef;
+ ByPass = bypass;
+ }
+
+ public void showEQParam()
+ {
+ StringBuilder strParam = new StringBuilder();
+ strParam.AppendFormat("param freq :{0}", Freq);
+ strParam.AppendFormat("\tparam Gai :{1}", Gain);
+ strParam.AppendFormat("\tparam Qvalue :{2}", QValue);
+ strParam.AppendFormat("\tparam typfilter :{3}", TypeFilter);
+ strParam.AppendFormat("\tparam bypass :{4}", ByPass);
+ Debug.WriteLine("param print : " + strParam.ToString());
+ }
+
+
+ }
+ ///
+ ///
+ /// for XFBCFFT Draw Generator
+ ///
+ public class XFBCFFTDataGenerator
+ {
+ #region FBCFFT data define
+ private const double DefaultEQffCofA = 0;
+ private const int FBCEQMax = FFTConstaint.FBC_FFTNum;
+ private EQParam[] m_EQParam = new EQParam[FBCEQMax];
+ private double[] gEQData = new double[FFTConstaint.NFFT];
+ #endregion
+
+
+ public XFBCFFTDataGenerator() //10 segment EQ
+ {
+ //0:HPF,1..8 EQ 9:LPF
+ if(gEQData==null)
+ gEQData = new double[FFTConstaint.NFFT];
+ if(m_EQParam==null)
+ m_EQParam = new EQParam[FBCEQMax];
+
+ for (int i = 0; i < FBCEQMax; i++)
+ {
+ m_EQParam[i] = new EQParam();
+ }
+
+
+ }
+ ///
+ /// fbc eq setparam
+ ///
+ ///
+ ///
+ ///
+ public void setEQParam(EQParam param, int eindex, FBCFFTDraw fftD) //[0..23]
+ {
+ if (eindex < FBCEQMax)
+ {
+ m_EQParam[eindex] = param;
+ fftD.setBlockData(param.Freq, param.Gain, eindex);
+ }
+ }
+ public void clearEQData()
+ {
+ Array.Clear(gEQData, 0, FFTConstaint.NFFT);
+ }
+
+ public void setFBCFFTAdapter(FBCFFTDraw fbcDrawer)
+ {
+
+ XCoverFFTCaculate coverfft = new XCoverFFTCaculate();
+ clearEQData();
+ double[] tmpData=new double[FFTConstaint.NFFT];
+ for (int j = 0; j < FBCEQMax; j++) //0...23
+ {
+ tmpData = coverfft.calculateEQ_FFT(m_EQParam[j].Gain, m_EQParam[j].Freq,
+ m_EQParam[j].QValue, m_EQParam[j].TypeFilter, DefaultEQffCofA, DefaultEQffCofA);
+
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQData[i] += tmpData[i];
+ }
+ Array.Clear(tmpData,0,FFTConstaint.NFFT);
+ }
+
+ fbcDrawer.setGlobalEQData(gEQData);
+
+
+ }
+
+ }
+
+
+ ///
+ /// for FFTChannel Draw Generator
+ ///
+ public class XChannelFFTDataGenerator
+ {
+ private const double DefaultEQffCofA = 0;
+ private const int EQMax = FFTConstaint.CEQ_MAX;
+ private static EQParam[] m_EQParam = new EQParam[FFTConstaint.CEQ_MAX * 2];
+ private static double[][] s_EQData = new double[FFTConstaint.CEQ_MAX * 2][];
+ private static double[] gEQData = new double[FFTConstaint.NFFT];
+ private static double[] gEQDataII = new double[FFTConstaint.NFFT];
+
+ public int EQNumber { get; set; }
+ public XChannelFFTDataGenerator(int EQNum) //10 segment EQ
+ {
+ //0:HPF,1..8 EQ 9:LPF
+ EQNumber = EQNum;
+ for (int i = 0; i < EQNum * 2; i++)
+ {
+ m_EQParam[i] = new EQParam();
+ s_EQData[i] = new double[FFTConstaint.NFFT];
+ }
+
+
+ }
+
+ public void setEQParam(EQParam param, int eindex, FFTDrawer fftD) //[0..19]
+ {
+ if (eindex < EQNumber * 2)
+ {
+ m_EQParam[eindex] = param;
+ // param.QValue
+ fftD.setBlockData(param.Freq, param.Gain, param.QValue,eindex);
+ fftD.setCureFlat((param.ByPass == 1), eindex, false);
+ }
+ }
+ public void clearWaveEQData()
+ {
+ Array.Clear(gEQData, 0, FFTConstaint.NFFT);
+ Array.Clear(gEQDataII, 0, FFTConstaint.NFFT);
+ for (int k = 0; k < EQMax * 2; k++)
+ {
+ Array.Clear(s_EQData[k], 0, FFTConstaint.NFFT);
+ }
+ }
+ private static Object stateObject = new Object();
+ public void setFFTAdapter(FFTDrawer fftDrawer)
+ {
+ // int chindex = 0;
+ bool isHasHLPF = fftDrawer.isHasHLPF;
+ bool isSupportDoubleLine = fftDrawer.isSupportMutiLine;
+ // lock (stateObject)
+ // {
+ // new Thread(() =>
+ {
+ XCoverFFTCaculate coverfft = new XCoverFFTCaculate();
+ clearWaveEQData();
+ for (int j = 0; j < EQNumber - 2; j++) //0...7
+ {
+ s_EQData[j] = coverfft.calculateEQ_FFT(m_EQParam[j].Gain, m_EQParam[j].Freq,
+ m_EQParam[j].QValue, m_EQParam[j].TypeFilter, DefaultEQffCofA, DefaultEQffCofA);
+
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQData[i] += s_EQData[j][i];
+ }
+ }
+ if (isHasHLPF)
+ {
+ //HPF by pass filter //HPLFGlags 0 high pass 1:low pass
+ int eindex = EQMax - 2;
+ s_EQData[eindex] = coverfft.calculateHLPF_FFT(0, (byte)m_EQParam[eindex].TypeFilter, m_EQParam[eindex].Freq);
+
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQData[i] += s_EQData[eindex][i];
+
+ }
+ //low by pass filter
+ eindex = EQMax - 1;
+ s_EQData[eindex] = coverfft.calculateHLPF_FFT(1, (byte)m_EQParam[eindex].TypeFilter, m_EQParam[eindex].Freq);
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQData[i] += s_EQData[eindex][i];
+ }
+ }
+ //sencond channel 1 chindex = 1;
+ if (isSupportDoubleLine)
+ {
+ for (int j = FFTConstaint.CEQ_MAX; j < EQNumber * 2 - 2; j++) //[10...17]
+ {
+ s_EQData[j] = coverfft.calculateEQ_FFT(m_EQParam[j].Gain, m_EQParam[j].Freq,
+ m_EQParam[j].QValue, m_EQParam[j].TypeFilter, DefaultEQffCofA, DefaultEQffCofA);
+
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQDataII[i] += s_EQData[j][i];
+
+ }
+
+ }
+ if (isHasHLPF)
+ {
+ //HPF by pass filter
+ int eindex = EQMax * 2 - 2;
+
+ s_EQData[eindex] = coverfft.calculateHLPF_FFT(0, (byte)m_EQParam[eindex].TypeFilter, m_EQParam[eindex].Freq);
+
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQDataII[i] += s_EQData[eindex][i];
+
+ }
+ //low by pass filter
+ eindex = EQMax * 2 - 1;
+ s_EQData[eindex] = coverfft.calculateHLPF_FFT(1, (byte)m_EQParam[eindex].TypeFilter, m_EQParam[eindex].Freq);
+
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ gEQDataII[i] += s_EQData[eindex][i];
+ }
+ }
+ }
+
+ //GUI BeginInvoke is Asynchronously but Invoke is synchronously
+ // mWnd.Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(delegate()
+ //{
+ for (int k = 0; k < EQMax * 2; k++)
+ {
+ fftDrawer.set_CurveEQData(k, s_EQData[k]);
+ }
+ fftDrawer.setGlobalEQData(gEQData, 0);
+ fftDrawer.setGlobalEQData(gEQDataII, 1);
+ // }));
+ // }).Start();
+ //}
+
+
+ }
+ // }
+ }
+ }
+}
+
+
diff --git a/LibControl/Controls/FFTControl/XCoverFFTCaculate.cs b/LibControl/Controls/FFTControl/XCoverFFTCaculate.cs
new file mode 100644
index 0000000..62463ae
--- /dev/null
+++ b/LibControl/Controls/FFTControl/XCoverFFTCaculate.cs
@@ -0,0 +1,630 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Lib.Controls
+{
+
+ public class XCoverFFTCaculate
+ {
+ public double MatsterGain
+ {
+ get;
+ set;
+ }
+ // private static double[] PointArray = new double[FFTConstaint.NFFT];
+ private static double[] a = new double[3];
+ private static double[] b = new double[3];
+ private const double DefaultHLGain = 0.0;
+ private const double DefaultQValue = 0.05;
+
+ private const int cENum = 6;
+ private double[][] butterWorthAray = new double[cENum][];
+
+ public XCoverFFTCaculate()
+ {
+ for(int i=0;i
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private bool PeakShlv(double Gain, double Frequency, double QFactor, double FiltType, double fCoeffA, double fCoeffB)
+ {
+
+ double k, v0;
+ double Den, Den1, Den2;
+ Array.Clear(a, 0, 3);
+ Array.Clear(b, 0, 3);
+
+ k = Math.Tan(FFTConstaint.PI * Frequency / FFTConstaint.SAMPLE_RATE);
+ if (FiltType == 1)
+ {
+ if (Gain >= 0) // Peak with positive gain
+ {
+ v0 = Math.Pow(10.0, Gain / 20.0);
+ Den = 1 + (k / QFactor) + k * k;
+ a[0] = (1 + (v0 * k / QFactor) + k * k) / Den;
+ a[1] = (2 * (k * k - 1)) / Den;
+ a[2] = (1 - (v0 * k / QFactor) + k * k) / Den;
+ b[0] = 1;
+ b[1] = a[1];
+ b[2] = (1 - (k / QFactor) + k * k) / Den;
+ }
+ else // Peak with negative gain
+ {
+ try
+ {
+ v0 = Math.Pow(10.0, -Gain / 20.0);
+ }
+ catch (Exception e)
+ {
+ v0 = 0.0;
+
+ }
+ Den = 1 + (v0 * k / QFactor) + k * k;
+ a[0] = (1 + k / QFactor + k * k) / Den;
+ a[1] = (2 * (k * k - 1)) / Den;
+ a[2] = (1 - k / QFactor + k * k) / Den;
+ b[0] = 1;
+ b[1] = a[1];
+ b[2] = (1 - (v0 * k / QFactor) + k * k) / Den;
+ }
+ }
+ else if (FiltType == 4) // Low-pass filter (Butterworth)
+ {
+ Den = 1 + Math.Sqrt(2.0) * k + k * k;
+ a[0] = (k * k) / Den;
+ a[1] = (2 * k * k) / Den;
+ a[2] = a[0];
+ b[0] = 1;
+ b[1] = (2 * (k * k - 1)) / Den;
+ b[2] = (1 - Math.Sqrt(2.0) * k + k * k) / Den;
+ }
+ else if (FiltType == 5) // High-pass filter (Butterworth)
+ {
+ Den = 1 + Math.Sqrt(2.0) * k + k * k;
+ a[0] = 1 / Den;
+ a[1] = -2 / Den;
+ a[2] = a[0];
+ b[0] = 1;
+ b[1] = (2 * (k * k - 1)) / Den;
+ b[2] = (1 - Math.Sqrt(2) * k + k * k) / Den;
+ }
+ else if (FiltType == 6) // Band-pass filter
+ {
+ Den = QFactor + k + QFactor * k * k;
+ a[0] = 2 * k / Den;
+ a[1] = 0;
+ a[2] = -a[0];
+ b[0] = 1;
+ b[1] = (2 * QFactor * (k * k - 1)) / Den;
+ b[2] = (QFactor - k + QFactor * k * k) / Den;
+ }
+ else if (FiltType == 8) // 1st order Low-pass filter
+ {
+ Den = 1 + k;
+ a[0] = k / Den;
+ a[1] = a[0];
+ a[2] = 0;
+ b[0] = 1;
+ b[1] = (k - 1) / Den;
+ b[2] = 0;
+ }
+ else if (FiltType == 9) // 1st order High-pass filter
+ {
+ Den = 1 + k;
+ a[0] = -1 / Den;
+ a[1] = 1 / Den;
+ a[2] = 0;
+ b[0] = 1;
+ b[1] = (k - 1) / Den;
+ b[2] = 0;
+ }
+ else if (FiltType == 10) // Bypass
+ {
+ a[0] = 1;
+ a[1] = 0;
+ a[2] = 0;
+ b[0] = 1;
+ b[1] = 0;
+ b[2] = 0;
+ }
+ else if (FiltType == 11) // Bypass
+ {
+ // case 0: 1st order Low-pass filter
+ Den = 1 + 1 / fCoeffA * k;
+ a[0] = 1 / fCoeffA * k / Den;
+ a[1] = a[0];
+ a[2] = 0;
+ b[0] = 1;
+ b[1] = (1 / fCoeffA * k - 1) / Den;
+ b[2] = 0;
+ }
+ else if (FiltType == 12)
+ {
+ // case 1: // Butterworth Low-pass filter
+ Den = 1 + fCoeffA * k + k * k;
+ a[0] = (k * k) / Den;
+ a[1] = (2 * k * k) / Den;
+ a[2] = a[0];
+ b[0] = 1;
+ b[1] = (2 * (k * k - 1)) / Den;
+ b[2] = (1 - fCoeffA * k + k * k) / Den;
+ }
+ else if (FiltType == 13)
+ {
+ // case 2: Bessel Low-pass filter
+ Den = 1 + fCoeffA / fCoeffB * k +
+ 1 / fCoeffB * k * k;
+ a[0] = (1 / fCoeffB * k * k) / Den;
+ a[1] = (2 * 1 / fCoeffB * k * k) / Den;
+ a[2] = a[0];
+ b[0] = 1;
+ b[1] = (2 * (1 / fCoeffB * k * k - 1)) / Den;
+ b[2] = (1 - fCoeffA / fCoeffB * k +
+ 1 / fCoeffB * k * k) / Den;
+ }
+ else if (FiltType == 14)
+ {
+ // case 3: 1st order High-pass filter
+ Den = 1 + fCoeffA * k;
+ a[0] = 1 / Den;
+ a[1] = -1 / Den;
+ a[2] = 0;
+ b[0] = 1;
+ b[1] = (fCoeffA * k - 1) / Den;
+ b[2] = 0;
+ }
+ else if (FiltType == 15)
+ {
+ // case 4: Butterworth High-pass filter
+ Den = 1 + fCoeffA * k + k * k;
+ a[0] = 1 / Den;
+ a[1] = -2 / Den;
+ a[2] = a[0];
+ b[0] = 1;
+ b[1] = (2 * (k * k - 1)) / Den;
+ b[2] = (1 - fCoeffA * k + k * k) / Den;
+ }
+ else if (FiltType == 16)
+ {
+ // case 5: Bessel High-pass filter
+ Den = 1 + fCoeffA * k + fCoeffB * k * k;
+ a[0] = 1 / Den;
+ a[1] = -2 / Den;
+ a[2] = a[0];
+ b[0] = 1;
+ b[1] = (2 * (fCoeffB * k * k - 1)) / Den;
+ b[2] = (1 - fCoeffA * k + fCoeffB * k * k) / Den;
+ }
+ else
+ {
+ if (Gain >= 0)
+ {
+ try
+ {
+ v0 = Math.Pow(10.0, Gain / 20.0);
+ }
+ catch (Exception e)
+ {
+ v0 = 0.0;
+
+ }
+
+ Den = 1 + Math.Sqrt(2.0) * k + k * k;
+ if (FiltType == 2)
+ { // Low frequency shelving with positive gain
+ k = Math.Tan(FFTConstaint.PI * Frequency / FFTConstaint.SAMPLE_RATE);
+ a[0] = (1 + Math.Sqrt(2 * v0) * k + v0 * k * k) / Den;
+ a[1] = 2 * (v0 * k * k - 1) / Den;
+ a[2] = (1 - Math.Sqrt(2 * v0) * k + v0 * k * k) / Den;
+ b[0] = 1;
+ b[1] = 2 * (k * k - 1) / Den;
+ b[2] = (1 - Math.Sqrt(2.0) * k + k * k) / Den;
+ }
+ else if (FiltType == 3)
+ { // High frequency shelving with positive gain
+ k = Math.Tan(FFTConstaint.PI * Frequency / FFTConstaint.SAMPLE_RATE);
+ a[0] = (v0 + Math.Sqrt(2 * v0) * k + k * k) / Den;
+ a[1] = 2 * (k * k - v0) / Den;
+ a[2] = (v0 - Math.Sqrt(2 * v0) * k + k * k) / Den;
+ b[0] = 1;
+ b[1] = 2 * (k * k - 1) / Den;
+ b[2] = (1 - Math.Sqrt(2.0) * k + k * k) / Den;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ try
+ {
+ v0 = Math.Pow(10.0, (-(Gain) / 20.0));
+ }
+ catch (Exception e)
+ {
+ v0 = 0.0;
+ }
+ if (FiltType == 2)
+ { // Low frequency shelving with negative gain
+ k = Math.Tan(FFTConstaint.PI * Frequency / FFTConstaint.SAMPLE_RATE);
+ Den = 1 + Math.Sqrt(2 * v0) * k + v0 * k * k;
+ a[0] = (1 + Math.Sqrt(2.0) * k + k * k) / Den;
+ a[1] = 2 * (k * k - 1) / Den;
+ a[2] = (1 - Math.Sqrt(2.0) * k + k * k) / Den;
+ b[0] = 1;
+ b[1] = 2 * (v0 * k * k - 1) / Den;
+ b[2] = (1 - Math.Sqrt(2 * v0) * k + v0 * k * k) / Den;
+ }
+ else if (FiltType == 3)
+ { // High frequency shelving with negative gain
+ k = Math.Tan(FFTConstaint.PI * Frequency / FFTConstaint.SAMPLE_RATE);
+ Den1 = v0 + Math.Sqrt(2 * v0) * k + k * k;
+ Den2 = 1 + Math.Sqrt(2 / v0) * k + (k * k / v0);
+ a[0] = (1 + Math.Sqrt(2.0) * k + k * k) / Den1;
+ a[1] = 2 * (k * k - 1) / Den1;
+ a[2] = (1 - Math.Sqrt(2.0) * k + k * k) / Den1;
+ b[0] = 1;
+ b[1] = 2 * ((k * k / v0) - 1) / Den2;
+ b[2] = (1 - Math.Sqrt(2 / v0) * k + (k * k / v0)) / Den2;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ ///
+ /// caculateFFT
+ ///
+ /// s
+ ///
+ ///
+ /// 1 is defalut value
+ ///
+ ///
+ public double[] calculateEQ_FFT(double gain, double freq, double qfactor, int type, double fCoeffA, double fCoeffB)
+ {
+ // ************************************
+ // ****define local parameter**********
+ // ************************************
+ int i, j, nb = 3, na = 3;
+ double[] resArray = new double[FFTConstaint.NFFT];
+
+ Point sumb = new Point(0.0, 0.0);
+ Point suma = new Point(0.0, 0.0);
+ Point temp = new Point(0.0, 0.0);
+ double pr;// dTemp;
+ //Array.Clear(PointArray, 0, FFTConstaint.NFFT);
+ double[] ww = new double[FFTConstaint.NFFT];
+ // ------------------------------------------
+ try
+ {
+ PeakShlv(gain, freq, qfactor, type, fCoeffA, fCoeffB);
+ // ------------------------------------------
+ // ************FFT*************************
+
+ for (i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ ww[i] = Math.Pow(10, Math.Log10(FFTConstaint.SAMPLERATE) * i / FFTConstaint.NFFT) * FFTConstaint.PI / FFTConstaint.SAMPLERATE;
+
+ sumb.X = b[0]; // sumb=b(1);
+ sumb.Y = 0;
+ suma.X = a[0]; // suma=a(1);
+ suma.Y = 0;
+
+ for (j = 1; j < nb; j++)
+ {
+ pr = j * ww[i]; // pr=(j-1).*ww(k);
+ temp.X = b[j] * Math.Cos(-pr); // exp(-i*pr)
+ temp.Y = b[j] * Math.Sin(-pr);
+ sumb = addc(sumb, temp); // sumb=sumb+b(j).*exp(-i*pr);
+ }
+ for (j = 1; j < na; j++)
+ {
+ pr = j * ww[i]; // pr=(j-1).*ww(k)
+ temp.X = a[j] * Math.Cos(-pr);
+ temp.Y = a[j] * Math.Sin(-pr); // exp(-i*pr)
+ suma = addc(suma, temp); // suma=suma+a(j).*exp(-i*pr);
+ }
+ // PointArray[i] = -(20.0)*log10(abss(sumb)/abss(suma))-(m_mastergain)*0.0322;
+ if (abss(sumb) / abss(suma) > 0)
+ {
+ resArray[i] = -(20.0) * Math.Log10(abss(sumb) / abss(suma)) - MatsterGain;
+
+ }
+
+ }
+
+
+ }
+ catch (Exception e)
+ {
+ }
+ return resArray;
+
+ }
+
+ private void clearButterWorthAray()
+ {
+
+ for(int i=0;i
+ /// process HLpf with freq //HPLFGlags 0 high pass 1:low pass
+ ///
+ public double[] calculateHLPF_FFT(byte HPLFlags, byte filter, double freq) //HPLFGlags 0 high pass 1:low pass
+ {
+
+ double[] tempArray = new double[FFTConstaint.NFFT];
+ double fCoefA1 = 0.0, fCoefB1 = 0.0;
+ HLPassType iFilterType = 0;
+ const int DefaultFilter = 1;
+ //FFTConstaint.XoverType type;
+ //type=(FFTConstaint.XoverType)Enum.ToObject(typeof(FFTConstaint.XoverType), sfilter);
+ //byte filter =(byte)FFTConstaint.getFilterWithType(type);
+ clearButterWorthAray();
+ // Debug.WriteLine("dispatch with calculateHLPF_FFT with --------", filter);
+
+ switch (filter)
+ {
+ case 0://by pass
+ {
+
+ iFilterType = HLPassType.HLBYPASS;
+ tempArray = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+
+ }
+ break;
+ case 1: //butterworth -6dB/oct
+ {
+ if (HPLFlags > 0) iFilterType = HLPassType.LP6dB; //low pass 11
+ else iFilterType = HLPassType.BESLP12dB; //high pass 14
+
+ fCoefA1 = 0.6;
+ fCoefB1 = 0;
+ tempArray = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+ }
+ break;
+
+ case 2:////butterworth 12
+ case 3:////butterworth 18
+ case 4:////butterworth 24
+ case 5://butterworth 30
+ case 6://butterworth 36
+ case 7://butterworth 42
+ case 8://butterworth 48
+ {
+
+
+ if (FFTConstaint.fButterWorthCoef[filter - 1, 0] == 1)
+ {
+ fCoefA1 = 1;
+ fCoefB1 = 0;
+
+ iFilterType = (HPLFlags > 0 ? HLPassType.LP6dB : HLPassType.BESLP12dB);
+ butterWorthAray[0] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+
+
+ }
+ else
+ {
+ butterWorthAray[0] = calculateHLPF_FFT_Default();
+ }
+
+ for (int i = 1; i < 5; i++)
+ {
+
+ if (FFTConstaint.fButterWorthCoef[filter - 1, i] != 0)
+ {
+
+ fCoefA1 = FFTConstaint.fButterWorthCoef[filter - 1, i];
+ fCoefB1 = 0;
+ iFilterType = (HPLFlags > 0 ? HLPassType.HP6dB : HLPassType.LKLP12dB);
+ butterWorthAray[i] = calculateEQ_FFT(0.0, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+ }
+ }
+ butterWorthAray[5] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, DefaultFilter, fCoefA1, fCoefB1);
+
+ for (int j = 0; j < cENum; j++)
+ {
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ tempArray[i] += butterWorthAray[j][i];
+ }
+
+ }
+
+
+ }
+
+ break;
+
+ case 9: //Bessel --6dB/OCT
+ case 10: //Bessel --12dB/OCT
+ case 11: //Bessel ---18dB/OCT
+ case 12: //Bessel --24dB/OCT
+ case 13: //Bessel --30db/OCT
+ case 14: //Bessel --36B/OCT
+ case 15: //Bessel --42dB/OCT
+ case 16: //Bessel --48B/OCT
+ {
+
+ if (FFTConstaint.fBesselCoef[filter - 9, 0, 0] != 0)
+ {
+
+ fCoefA1 = FFTConstaint.fBesselCoef[filter - 9, 0, 0];
+ fCoefB1 = 0;
+ iFilterType = (HPLFlags > 0 ? HLPassType.LP6dB : HLPassType.BESLP12dB);
+
+ butterWorthAray[0] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+ }
+
+ for (int i = 1; i < 5; i++)
+ {
+ if (FFTConstaint.fBesselCoef[filter - 9, i, 0] != 0)
+ {
+ fCoefA1 = FFTConstaint.fBesselCoef[filter - 9, i, 0];
+ fCoefB1 = FFTConstaint.fBesselCoef[filter - 9, i, 1];
+
+ iFilterType = (HPLFlags > 0 ? HLPassType.BWLP12dB : HLPassType.CHVLP12dB);
+
+ butterWorthAray[i] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+
+ }
+
+ }
+ butterWorthAray[5] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, DefaultFilter, fCoefA1, fCoefB1);
+
+ for (int j = 0; j < cENum; j++)
+ {
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ tempArray[i] += butterWorthAray[j][i];
+ }
+
+ }
+
+ }
+
+ break;
+ case 17: //link/rikey -12dB/oct
+ case 18: //link/Riky -24dB/oct
+ { //three points diejia
+
+ for (int i = 0; i < 2; i++)
+ {
+ if ((filter - 17) == 0)
+ {
+ fCoefA1 = 0.8;
+ fCoefB1 = 0.0;
+ iFilterType = (HPLFlags > 0 ? HLPassType.LP6dB : HLPassType.BESLP12dB);
+ }
+ else
+ {
+ fCoefA1 = FFTConstaint.fButterWorthCoef[filter - 17, 1];
+ Debug.WriteLine("LK24 fcoefa1 is {0}", fCoefA1);
+
+ fCoefB1 = 0;
+ iFilterType = (HPLFlags > 0 ? HLPassType.HP6dB : HLPassType.LKLP12dB);
+ }
+ butterWorthAray[i] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+
+ }
+ for (int i = 2; i < 5; i++)
+ butterWorthAray[i] = calculateHLPF_FFT_Default();
+ butterWorthAray[5] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, DefaultFilter, fCoefA1, fCoefB1);
+
+ for (int j = 0; j < cENum; j++)
+ {
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ tempArray[i] += butterWorthAray[j][i];
+ }
+
+ }
+
+ }
+ break;
+ case 19: //Link/Rikey -36dB/oct
+ case 20: //Link/Rikey -48dB/oct 4point jiejia
+ {
+
+ for (int i = 0; i < 2; i++)
+ {
+ if ((filter - 19) == 0)
+ {
+ fCoefA1 = 1.6180;
+ Debug.WriteLine("Link Rikey 36 fcore fA is {0}", fCoefA1);
+ fCoefB1 = 0;
+ iFilterType = (HPLFlags > 0 ? HLPassType.LP6dB : HLPassType.BESLP12dB);
+
+
+ }
+ else
+ {
+ fCoefA1 = FFTConstaint.fButterWorthCoef[filter - 17, 2];
+ fCoefB1 = 0;
+ Debug.WriteLine("Link Rikey 48 fcore fA is {0}", fCoefA1);
+
+ iFilterType = (HPLFlags > 0 ? HLPassType.HP6dB : HLPassType.LKLP12dB);
+ }
+ butterWorthAray[i] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, (int)iFilterType, fCoefA1, fCoefB1);
+ }
+ //
+ fCoefA1 = FFTConstaint.fButterWorthCoef[filter - 17, 1];
+ fCoefB1 = 0;
+ iFilterType = (HPLFlags > 0 ? HLPassType.HP6dB : HLPassType.LKLP12dB);
+ butterWorthAray[4] = calculateHLPF_FFT_Default();
+ butterWorthAray[3] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, DefaultFilter, fCoefA1, fCoefB1);
+ butterWorthAray[5] = calculateEQ_FFT(DefaultHLGain, freq, DefaultQValue, DefaultFilter, fCoefA1, fCoefB1);
+
+ for (int j = 0; j < cENum; j++)
+ {
+ for (int i = 0; i < FFTConstaint.NFFT; i++)
+ {
+ tempArray[i] += butterWorthAray[j][i];
+ }
+ }
+ }
+ break;
+
+ }
+ return tempArray;
+ }
+
+
+ }
+
+
+
+
+
+}
diff --git a/LibControl/Controls/FinalTables.cs b/LibControl/Controls/FinalTables.cs
new file mode 100644
index 0000000..c375513
--- /dev/null
+++ b/LibControl/Controls/FinalTables.cs
@@ -0,0 +1,643 @@
+
+public class StrValueTables {
+
+ public const int Delay_Const_Range = 170;
+ public const float Delay_ConstI = 0.62f;
+ public const float Delay_ConstII = 3.2808f;
+
+ //
+ public static string[] strFreqTable=
+ { //0..300
+ "19.7Hz", //00
+ "20.1Hz", //01
+ "20.6Hz", //02
+ "21.1Hz", //03
+ "21.6Hz", //04
+ "22.1Hz", //05
+ "22.6Hz", //06
+ "23.1Hz", //07
+ "23.7Hz", //08
+ "24.2Hz", //09
+
+ "24.8Hz", //10
+ "25.4Hz", //11
+ "26.0Hz", //12
+ "26.6Hz", //13
+ "27.2Hz", //14
+ "27.8Hz", //15
+ "28.5Hz", //16
+ "29.2Hz", //17
+ "29.8Hz", //18
+ "30.5Hz", //19
+
+ "31.2Hz", //20
+ "32.0Hz", //21
+ "32.7Hz", //22
+ "33.5Hz", //23
+ "34.3Hz", //24
+ "35.1Hz", //25
+ "35.9Hz", //26
+ "36.7Hz", //27
+ "37.6Hz", //28
+ "38.5Hz", //29
+
+ "39.4Hz", //30
+ "40.3Hz", //31
+ "41.2Hz", //32
+ "42.2Hz", //33
+ "43.2Hz", //34
+ "44.2Hz", //35
+ "45.2Hz", //36
+ "46.3Hz", //37
+ "47.4Hz", //38
+ "48.5Hz", //39
+
+ "49.6Hz", //40
+ "50.8Hz", //41
+ "52.0Hz", //42
+ "53.2Hz", //43
+ "54.4Hz", //44
+ "55.7Hz", //45
+ "57.0Hz", //46
+ "58.3Hz", //47
+ "59.7Hz", //48
+ "61.1Hz", //49
+
+ "62.5Hz", //50
+ "64.0Hz", //51
+ "65.5Hz", //52
+ "67.0Hz", //53
+ "68.6Hz", //54
+ "70.2Hz", //55
+ "71.8Hz", //56
+ "73.5Hz", //57
+ "75.2Hz", //58
+ "76.9Hz", //59
+
+ "78.7Hz", //60
+ "80.6Hz", //61
+ "82.5Hz", //62
+ "84.4Hz", //63
+ "86.4Hz", //64
+ "88.4Hz", //65
+ "90.5Hz", //66
+ "92.6Hz", //67
+ "94.7Hz", //68
+ "96.9Hz", //69
+
+ "99.2Hz", //70
+ "101.5Hz", //71
+ "103.9Hz", //72
+ "106.3Hz", //73
+ "108.8Hz", //74
+ "111.4Hz", //75
+ "114.0Hz", //76
+ "116.6Hz", //77
+ "119.4Hz", //78
+ "122.1Hz", //79
+
+ "125.0Hz", //80
+ "127.9Hz", //81
+ "130.9Hz", //82
+ "134.0Hz", //83
+ "137.1Hz", //84
+ "140.3Hz", //85
+ "143.6Hz", //86
+ "146.9Hz", //87
+ "150.4Hz", //88
+ "153.9Hz", //89
+
+ "157.5Hz", //90
+ "161.2Hz", //91
+ "164.9Hz", //92
+ "168.8Hz", //93
+ "172.7Hz", //94
+ "176.8Hz", //95
+ "180.9Hz", //96
+ "185.1Hz", //97
+ "189.5Hz", //98
+ "193.9Hz", //99
+
+ "198.4Hz", //100
+ "203.1Hz", //101
+ "207.8Hz", //102
+ "212.7Hz", //103
+ "217.6Hz", //104
+ "222.7Hz", //105
+ "227.9Hz", //106
+ "233.3Hz", //107
+ "238.7Hz", //108
+ "244.3Hz", //109
+
+ "250.0Hz", //110
+ "255.8Hz", //111
+ "261.8Hz", //112
+ "267.9Hz", //113
+ "274.2Hz", //114
+ "280.6Hz", //115
+ "287.2Hz", //116
+ "293.9Hz", //117
+ "300.8Hz", //118
+ "307.8Hz", //119
+
+ "315.0Hz", //120
+ "322.3Hz", //121
+ "329.9Hz", //122
+ "337.6Hz", //123
+ "345.5Hz", //124
+ "353.6Hz", //125
+ "361.8Hz", //126
+ "370.3Hz", //127
+ "378.9Hz", //128
+ "387.8Hz", //129
+
+ "396.9Hz", //130
+ "406.1Hz", //131
+ "415.6Hz", //132
+ "425.3Hz", //133
+ "435.3Hz", //134
+ "445.4Hz", //135
+ "455.9Hz", //136
+ "466.5Hz", //137
+ "477.4Hz", //138
+ "488.6Hz", //139
+
+ "500.0Hz", //140
+ "511.7Hz", //141
+ "523.6Hz", //142
+ "535.9Hz", //143
+ "548.4Hz", //144
+ "561.2Hz", //145
+ "574.3Hz", //146
+ "587.8Hz", //147
+ "601.5Hz", //148
+ "615.6Hz", //149
+
+ "630.0Hz", //150
+ "644.7Hz", //151
+ "659.8Hz", //152
+ "675.2Hz", //153
+ "691.0Hz", //154
+ "707.1Hz", //155
+ "723.6Hz", //156
+ "740.5Hz", //157
+ "757.9Hz", //158
+ "775.6Hz", //159
+
+ "793.7Hz", //160
+ "812.3Hz", //161
+ "831.2Hz", //162
+ "850.7Hz", //163
+ "870.6Hz", //164
+ "890.9Hz", //165
+ "911.7Hz", //166
+ "933.0Hz", //167
+ "954.8Hz", //168
+ "977.2Hz", //169
+
+ "1.00KHz", //170
+ "1.03KHz", //171
+ "1.05KHz", //172
+ "1.08KHz", //173
+ "1.10KHz", //174
+ "1.13KHz", //175
+ "1.15KHz", //176
+ "1.18KHz", //177
+ "1.21KHz", //178
+ "1.24KHz", //179
+
+ "1.26KHz", //180
+ "1.29KHz", //181
+ "1.32KHz", //182
+ "1.35KHz", //183
+ "1.39KHz", //184
+ "1.42KHz", //185
+ "1.45KHz", //186
+ "1.49KHz", //187
+ "1.52KHz", //188
+ "1.56KHz", //189
+
+ "1.59KHz", //190
+ "1.63KHz", //191
+ "1.67KHz", //192
+ "1.71KHz", //193
+ "1.75KHz", //194
+ "1.79KHz", //195
+ "1.83KHz", //196
+ "1.87KHz", //197
+ "1.91KHz", //198
+ "1.96KHz", //199
+
+ "2.01KHz", //200
+ "2.05KHz", //201
+ "2.10KHz", //202
+ "2.15KHz", //203
+ "2.20KHz", //204
+ "2.25KHz", //205
+ "2.30KHz", //206
+ "2.36KHz", //207
+ "2.41KHz", //208
+ "2.47KHz", //209
+
+ "2.52KHz", //210
+ "2.58KHz", //211
+ "2.64KHz", //212
+ "2.70KHz", //213
+ "2.77KHz", //214
+ "2.83KHz", //215
+ "2.90KHz", //216
+ "2.97KHz", //217
+ "3.04KHz", //218
+ "3.11KHz", //219
+
+ "3.18KHz", //220
+ "3.25KHz", //221
+ "3.33KHz", //222
+ "3.41KHz", //223
+ "3.49KHz", //224
+ "3.57KHz", //225
+ "3.65KHz", //226
+ "3.74KHz", //227
+ "3.82KHz", //228
+ "3.91KHz", //229
+
+ "4.01KHz", //230
+ "4.10KHz", //231
+ "4.19KHz", //232
+ "4.29KHz", //233
+ "4.39KHz", //234
+ "4.49KHz", //235
+ "4.60KHz", //236
+ "4.71KHz", //237
+ "4.82KHz", //238
+ "4.93KHz", //239
+
+ "5.04KHz", //240
+ "5.16KHz", //241
+ "5.28KHz", //242
+ "5.41KHz", //243
+ "5.53KHz", //244
+ "5.66KHz", //245
+ "5.79KHz", //246
+ "5.93KHz", //247
+ "6.07KHz", //248
+ "6.21KHz", //249
+
+ "6.35KHz", //250
+ "6.50KHz", //251
+ "6.65KHz", //252
+ "6.81KHz", //253
+ "6.97KHz", //254
+ "7.13KHz", //255
+ "7.30KHz", //256
+ "7.47KHz", //257
+ "7.64KHz", //258
+ "7.82KHz", //259
+
+ "8.00KHz", //260
+ "8.19KHz", //261
+ "8.38KHz", //262
+ "8.58KHz", //263
+ "8.78KHz", //264
+ "8.98KHz", //265
+ "9.19KHz", //266
+ "9.41KHz", //267
+ "9.63KHz", //268
+ "9.85KHz", //269
+
+ "10.08KHz", //270
+ "10.32KHz", //271
+ "10.56KHz", //272
+ "10.81KHz", //273
+ "11.06KHz", //274
+ "11.32KHz", //275
+ "11.58KHz", //276
+ "11.85KHz", //277
+ "12.13KHz", //278
+ "12.41KHz", //279
+
+ "12.70KHz", //280
+ "13.00KHz", //281
+ "13.30KHz", //282
+ "13.61KHz", //283
+ "13.93KHz", //284
+ "14.26KHz", //285
+ "14.59KHz", //286
+ "14.93KHz", //287
+ "15.28KHz", //288
+ "15.64KHz", //289
+
+ "16.01KHz", //290
+ "16.38KHz", //291
+ "16.76KHz", //292
+ "17.15KHz", //293
+ "17.55KHz", //294
+ "17.96KHz", //295
+ "18.38KHz", //296
+ "18.81KHz", //297
+ "19.25KHz", //298
+ "19.70KHz", //299
+ "20.16KHz" //300
+ };
+ public static string[] strQFactorTable =
+ { //0..100
+ "0.4", //00
+ "0.42", //01
+ "0.45", //02
+ "0.47", //03
+ "0.5", //04
+ "0.53", //05
+ "0.56", //06
+ "0.59", //07
+ "0.63", //08
+ "0.67", //09
+
+ "0.71", //10
+ "0.75", //11
+ "0.79", //12
+ "0.84", //13
+ "0.89", //14
+ "0.94", //15
+ "1.0", //16
+ "1.06", //17
+ "1.12", //18
+ "1.19", //19
+
+ "1.26", //20
+ "1.3", //21
+ "1.4", //22
+ "1.5", //23
+ "1.6", //24
+ "1.7", //25
+ "1.8", //26
+ "1.9", //27
+ "2.0", //28
+ "2.1", //29
+
+ "2.1", //30
+ "2.4", //31
+ "2.5", //32
+ "2.7", //33
+ "2.8", //34
+ "3.0", //35
+ "3.2", //36
+ "3.4", //37
+ "3.6", //38
+ "3.8", //39
+
+ "4.0", //40
+ "4.2", //41
+ "4.5", //42
+ "4.8", //43
+ "5.0", //44
+ "5.3", //45
+ "5.7", //46
+ "6.0", //47
+ "6.3", //48
+ "6.7", //49
+
+ "7.1", //50
+ "7.6", //51
+ "8.0", //52
+ "8.5", //53
+ "9.0", //54
+ "9.5", //55
+ "10.1", //56
+ "10.7", //57
+ "11.3", //58
+ "12", //59
+
+
+ "12.7", //60
+ "13.5", //61
+ "14", //62
+ "15", //63
+ "16", //64
+ "17", //65
+ "18", //66
+ "19", //67
+ "20", //68
+ "21", //69
+
+ "23", //70
+ "24", //71
+ "25", //72
+ "27", //73
+ "29", //74
+ "30", //75
+ "32", //76
+ "34", //77
+ "36", //78
+ "38", //79
+ "40", //80
+ "43", //81
+ "45", //82
+ "48", //83
+ "51", //84
+ "54", //85
+ "57", //86
+ "60", //87
+ "64", //88
+ "68", //89
+ "72", //90
+ "76", //91
+ "81", //92
+ "85", //93
+ "91", //94
+ "96", //95
+ "102", //96
+ "108", //97
+ "114", //98
+ "121", //99
+ "128" //100
+ };
+ public static double[] QVFactorTable =
+ { //0..100
+ 0.4, //00
+ 0.42, //01
+ 0.45, //02
+ 0.47, //03
+ 0.5, //04
+ 0.53, //05
+ 0.56, //06
+ 0.59, //07
+ 0.63, //08
+ 0.67, //09
+
+ 0.71, //10
+ 0.75, //11
+ 0.79, //12
+ 0.84, //13
+ 0.89, //14
+ 0.94, //15
+ 1.0, //16
+ 1.06, //17
+ 1.12, //18
+ 1.19, //19
+
+ 1.26, //20
+ 1.3, //21
+ 1.4, //22
+ 1.5, //23
+ 1.6, //24
+ 1.7, //25
+ 1.8, //26
+ 1.9, //27
+ 2.0, //28
+ 2.1, //29
+
+ 2.1, //30
+ 2.4, //31
+ 2.5, //32
+ 2.7, //33
+ 2.8, //34
+ 3.0, //35
+ 3.2, //36
+ 3.4, //37
+ 3.6, //38
+ 3.8, //39
+
+ 4.0, //40
+ 4.2, //41
+ 4.5, //42
+ 4.8, //43
+ 5.0, //44
+ 5.3, //45
+ 5.7, //46
+ 6.0, //47
+ 6.3, //48
+ 6.7, //49
+
+ 7.1, //50
+ 7.6, //51
+ 8.0, //52
+ 8.5, //53
+ 9.0, //54
+ 9.5, //55
+ 10.1, //56
+ 10.7, //57
+ 11.3, //58
+ 12, //59
+
+
+ 12.7, //60
+ 13.5, //61
+ 14, //62
+ 15, //63
+ 16, //64
+ 17, //65
+ 18, //66
+ 19, //67
+ 20, //68
+ 21, //69
+
+ 23, //70
+ 24, //71
+ 25, //72
+ 27, //73
+ 29, //74
+ 30, //75
+ 32, //76
+ 34, //77
+ 36, //78
+ 38, //79
+ 40, //80
+ 43, //81
+ 45, //82
+ 48, //83
+ 51, //84
+ 54, //85
+ 57, //86
+ 60, //87
+ 64, //88
+ 68, //89
+ 72, //90
+ 76, //91
+ 81, //92
+ 85, //93
+ 91, //94
+ 96, //95
+ 102, //96
+ 108, //97
+ 114, //98
+ 121, //99
+ 128 //100
+ };
+ public static string[] strGainTable =
+ { //0..48
+ "-18dB", //0
+"-17.5dB",//1
+"-17dB",//2
+"-16.5dB",//3
+"-16dB",//4
+"-15.5dB",//5
+"-15dB",//6
+"-14.5dB",//7
+"-14dB",//8
+"-13.5dB",//9
+"-13dB",//10
+"-12.5dB",//11
+"-12dB",//12
+"-11.5dB",//13
+"-11dB",//14
+"-10.5dB",//15
+"-10dB",//16
+"-9.5dB",//17
+"-9dB",//18
+"-8.5dB",//19
+"-8dB",//20
+"-7.5dB",//21
+"-7dB",//22
+"-6.5dB",//23
+"-6dB",//24
+"-5.5dB",//25
+"-5dB",//26
+"-4.5dB",//27
+"-4dB",//28
+"-3.5dB",//29
+"-3dB",//30
+"-2.5dB",//31
+"-2dB",//32
+"-1.5dB",//33
+"-1dB",//34
+"-0.5dB",//35
+"0dB", //36
+"0.5dB",//37
+"1dB",//38
+"1.5dB",//39
+"2dB",//40
+"2.5dB",//41
+"3dB",//42
+"3.5dB",//43
+"4dB",//44
+"4.5dB",//45
+"5dB",//46
+"5.5dB",//47
+"6dB",//48
+"6.5dB",//49
+"7dB",//50
+"7.5dB",//51
+"8dB",//52
+"8.5dB",//53
+"9dB",//54
+"9.5dB",//55
+"10dB",//56
+"10.5dB",//57
+"11dB",//58
+"11.5dB",//59
+"12dB",//60
+"12.5dB",//61
+"13dB",//62
+"13.5dB",//63
+"14dB",//64
+"14.5dB",//65
+"15dB",//66
+"15.5dB",//67
+"16dB",//68
+"16.5dB",//69
+"17dB",//70
+"17.5dB",//71
+"18dB"//72
+ };
+
+}
\ No newline at end of file
diff --git a/LibControl/Controls/IPControl.cs b/LibControl/Controls/IPControl.cs
new file mode 100644
index 0000000..1efd930
--- /dev/null
+++ b/LibControl/Controls/IPControl.cs
@@ -0,0 +1,314 @@
+namespace Lib.Controls
+{
+ using System;
+ using System.Linq;
+ using System.Text.RegularExpressions;
+ using System.Windows;
+ using System.Windows.Controls;
+ using System.Windows.Input;
+
+ public class IPControl : TextBox
+ {
+ public static string IpRegex =
+ @"([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]|[*])";
+
+ public IPControl()
+ {
+ this.PreviewTextInput += this.TextBoxPreviewTextInput;
+ this.PreviewKeyDown += this.HandleHandledKeyDown;
+ DataObject.AddPastingHandler(this, this.IPControl_Pasting);
+ }
+
+ public void HandleHandledKeyDown(object sender, RoutedEventArgs e)
+ {
+ var ke = e as KeyEventArgs;
+ if (ke != null && ke.Key == Key.Space)
+ {
+ e.Handled = true;
+ }
+ }
+
+ private static bool ValidCharacter(string enteredValue)
+ {
+ Match valRes = Regex.Match(enteredValue, "[0-9.]", RegexOptions.IgnoreCase);
+ if (!valRes.Success)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ private static int CountOfDot(string text)
+ {
+ int dotCount = text.Count(c => c == '.');
+ return dotCount;
+ }
+
+ private string AlterValue(TextCompositionEventArgs e, TextBox text, string val, int insertIndex, bool replace, out bool moveNext, int replaceIndex = 0)
+ {
+ string textVal = text.Text;
+ string oldValue = textVal;
+ if (replace)
+ {
+ textVal = textVal.Remove(replaceIndex, 1);
+ }
+
+ textVal = textVal.Insert(insertIndex, val);
+
+ if (!this.ValidIpFragment(textVal, out moveNext))
+ {
+ return this.Manipulate(e, text, oldValue, val, insertIndex);
+ }
+
+ return textVal;
+ }
+
+ private void Do(TextCompositionEventArgs e, string val, TextBox tx, int ind, int nextIndexOfDot, int indexDiff, int dotCount)
+ {
+ bool moveNext;
+
+ switch (indexDiff)
+ {
+ case 0:
+ int previousIndexOfDot = this.FindPreviousIndexOf(".", tx.Text, ind - 1);
+ int indexDiff2 = Math.Abs(previousIndexOfDot - nextIndexOfDot);
+
+ if (4 > indexDiff2)
+ {
+ this.Do(e, val, tx, ind, nextIndexOfDot, indexDiff2, dotCount);
+ return;
+ }
+ else
+ {
+ this.HandleTextInput(e, ind + 1, val, tx);
+ }
+
+ break;
+ case 4:
+ if (tx.Text.Length <= ind)
+ {
+ if (dotCount >= 3)
+ {
+ e.Handled = true;
+ tx.CaretIndex = ind + 1;
+ return;
+ }
+
+ if (val != ".")
+ {
+ tx.Text = this.AlterValue(e, tx, ".", ind, false, out moveNext);
+ tx.Text = this.AlterValue(e, tx, val, ind + 1, false, out moveNext);
+ }
+ else
+ {
+ tx.Text = this.AlterValue(e, tx, val, ind, false, out moveNext);
+ }
+
+ tx.CaretIndex = ind + 2;
+ }
+ else
+ {
+ string ret1 = this.AlterValue(e, tx, val, ind, true, out moveNext, ind);
+ if (!moveNext)
+ {
+ tx.Text = ret1;
+ tx.CaretIndex = ind + 1;
+ }
+ else
+ {
+ int carInd = tx.CaretIndex;
+ tx.Text = ret1;
+ tx.CaretIndex = carInd + 1;
+ }
+ }
+
+ e.Handled = true;
+
+ break;
+ default:
+ string ret = this.AlterValue(e, tx, val, ind, false, out moveNext);
+
+ e.Handled = true;
+ if (!moveNext)
+ {
+ tx.Text = ret;
+ tx.CaretIndex = ind + 1;
+ }
+ else
+ {
+ int carInd = tx.CaretIndex;
+ tx.Text = ret;
+ tx.CaretIndex = carInd + 1;
+ }
+
+ break;
+ }
+ }
+
+ private int FindNextIndexOf(string p, string text, int ind)
+ {
+ int index = text.IndexOf(p, ind);
+ if (index == -1)
+ {
+ return text.Length;
+ }
+
+ return index;
+ }
+
+ private int FindPreviousIndexOf(string p, string text, int ind)
+ {
+ if (ind < 0)
+ {
+ return ind;
+ }
+
+ return text.LastIndexOf(p, ind);
+ }
+
+ private void HandleExcessDot(TextCompositionEventArgs e, int ind, TextBox textBox)
+ {
+ if (textBox.Text.Count() > ind)
+ {
+ int findNextIndexOf = this.FindNextIndexOf(".", textBox.Text, ind);
+ if (findNextIndexOf != textBox.Text.Count())
+ {
+ int count = findNextIndexOf - ind;
+ textBox.Text = textBox.Text.Remove(ind, count);
+ textBox.CaretIndex = ind + 1;
+ }
+ else
+ {
+ textBox.CaretIndex = findNextIndexOf;
+ }
+ }
+
+ e.Handled = true;
+ }
+
+ private void HandleTextInput(TextCompositionEventArgs e, int ind, string enteredValue, TextBox textBox)
+ {
+ if (!ValidCharacter(enteredValue))
+ {
+ e.Handled = true;
+ textBox.CaretIndex = ind;
+ return;
+ }
+
+ int dotCount = CountOfDot(textBox.Text);
+
+ if (enteredValue == ".")
+ {
+ if (dotCount >= 3)
+ {
+ this.HandleExcessDot(e, ind, textBox);
+ return;
+ }
+ }
+
+ int previousIndexOfDot = this.FindPreviousIndexOf(".", textBox.Text, ind);
+ int nextIndexOfDot = this.FindNextIndexOf(".", textBox.Text, ind);
+ int indexDiff = nextIndexOfDot - previousIndexOfDot;
+ if (4 >= indexDiff)
+ {
+ this.Do(e, enteredValue, textBox, ind, nextIndexOfDot, indexDiff, dotCount);
+ }
+ else
+ {
+ e.Handled = true;
+ }
+ }
+
+ private void IPControl_Pasting(object sender, DataObjectPastingEventArgs e)
+ {
+ var textBox = (TextBox)sender;
+ textBox.Clear();
+ if (e.DataObject.GetDataPresent(typeof(string)))
+ {
+ var text = (string)e.DataObject.GetData(typeof(string));
+
+ bool res = Regex.IsMatch(text, IpRegex);
+ if (!res)
+ {
+ e.CancelCommand();
+ }
+ }
+ else
+ {
+ e.CancelCommand();
+ }
+ }
+
+ private string Manipulate(TextCompositionEventArgs e, TextBox text, string oldValue, string val, int insertIndex)
+ {
+ int previousIndexOfDot = this.FindPreviousIndexOf(".", oldValue, insertIndex);
+ int nextIndexOfDot = this.FindNextIndexOf(".", oldValue, insertIndex);
+ int indexDiff = nextIndexOfDot - previousIndexOfDot;
+
+ int countOfDot = CountOfDot(oldValue);
+
+ if (0 < indexDiff)
+ {
+ if (insertIndex != nextIndexOfDot)
+ {
+ oldValue = oldValue.Remove(previousIndexOfDot + 1, indexDiff - 1);
+ oldValue = oldValue.Insert(previousIndexOfDot + 1, val);
+ text.CaretIndex = previousIndexOfDot + 1;
+ }
+ else
+ {
+ if (countOfDot < 3)
+ {
+ this.HandleTextInput(e, text.CaretIndex, ".", text);
+ this.HandleTextInput(e, text.CaretIndex, val, text);
+ oldValue = text.Text;
+ }
+ }
+ }
+ else
+ {
+ this.HandleTextInput(e, nextIndexOfDot + 1, val, text);
+ text.CaretIndex = text.CaretIndex - 1;
+ oldValue = text.Text;
+ }
+
+ return oldValue;
+ }
+
+ private void TextBoxPreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ var textBox = (TextBox)sender;
+ string enteredValue = e.Text;
+
+ this.HandleTextInput(e, textBox.CaretIndex, enteredValue, textBox);
+ }
+
+ private bool ValidIpFragment(string textVal, out bool moveToNext)
+ {
+ moveToNext = false;
+ string[] arr = textVal.Split('.');
+ int count = 0;
+ foreach (string item in arr)
+ {
+ if (!string.IsNullOrEmpty(item))
+ {
+ int val = int.Parse(item);
+ if (val > 255)
+ {
+ if (count < 3)
+ {
+ moveToNext = true;
+ }
+
+ return false;
+ }
+ }
+
+ count++;
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/LibControl/Controls/Lib.Controls.csproj b/LibControl/Controls/Lib.Controls.csproj
new file mode 100644
index 0000000..8b8a96b
--- /dev/null
+++ b/LibControl/Controls/Lib.Controls.csproj
@@ -0,0 +1,380 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {EEFA1336-44F6-4766-BE16-A81AD1FCC2E5}
+ library
+ Properties
+ Lib.Controls
+ Lib.Controls.MyControls
+ v4.5
+
+
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ 4.0.20901.0
+ bdf601df
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ ..\..\CommLibrary\CommLibrary\bin\Debug\CommLibrary.dll
+
+
+ ..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll
+ True
+
+
+ ..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll
+ True
+
+
+
+
+
+
+
+ ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net45\System.Data.SQLite.dll
+ True
+
+
+ ..\packages\System.Data.SQLite.EF6.1.0.104.0\lib\net45\System.Data.SQLite.EF6.dll
+ True
+
+
+ ..\packages\System.Data.SQLite.Linq.1.0.104.0\lib\net45\System.Data.SQLite.Linq.dll
+ True
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ InputPasDialog.xaml
+
+
+
+
+
+
+
+
+ CTreeViewItem.xaml
+
+
+
+
+
+
+
+
+
+
+
+
+ changeNameDialog.xaml
+
+
+ CLeftTextModule.xaml
+
+
+ CMVIIIModule.xaml
+
+
+
+ CRightTextModule.xaml
+
+
+ CRouterLanModule.xaml
+
+
+ CRVA200Module.xaml
+
+
+ CSwitcherIVModule.xaml
+
+
+ InputHexDialog.xaml
+
+
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ SearchLed.xaml
+
+
+
+
+
+ synchronizeLed.xaml
+
+
+
+
+ AutoMixerInput.xaml
+
+
+ CDelayControl.xaml
+
+
+ CDuckerSourceControl.xaml
+
+
+ CEQControl.xaml
+
+
+ CEQControlII.xaml
+
+
+ CMatrixControl.xaml
+
+
+ CNoiseGateAjustControl.xaml
+
+
+
+ CPYGCheckBox.xaml
+
+
+
+ FBCStatusLeds.xaml
+
+
+ FBCSwitcherControl.xaml
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Module/CLeftTextModule.xaml b/LibControl/Controls/Module/CLeftTextModule.xaml
new file mode 100644
index 0000000..46c1184
--- /dev/null
+++ b/LibControl/Controls/Module/CLeftTextModule.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CLeftTextModule.xaml.cs b/LibControl/Controls/Module/CLeftTextModule.xaml.cs
new file mode 100644
index 0000000..3a54ee9
--- /dev/null
+++ b/LibControl/Controls/Module/CLeftTextModule.xaml.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using CommLibrary;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CTextModule.xaml
+ ///
+ public partial class CLeftTextModule : ComUserMD
+ {
+ public CLeftTextModule()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_TxtLft;
+ }
+
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+ base.loadDevInfo(devf);
+ edLb.Text = devf.noteTxt;
+ }
+
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+
+ }
+
+ public override void setDeviceID(UInt16 mid)
+ {
+ base.setDeviceID(mid);
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ }
+
+ private void edLb_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ devinfo.noteTxt = edLb.Text.Trim();
+ }
+ //delete module
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+
+ }
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/Module/CMVIIIModule.xaml b/LibControl/Controls/Module/CMVIIIModule.xaml
new file mode 100644
index 0000000..ffa7fe1
--- /dev/null
+++ b/LibControl/Controls/Module/CMVIIIModule.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CMVIIIModule.xaml.cs b/LibControl/Controls/Module/CMVIIIModule.xaml.cs
new file mode 100644
index 0000000..edda69b
--- /dev/null
+++ b/LibControl/Controls/Module/CMVIIIModule.xaml.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using CommLibrary;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CMVIIIModule.xaml
+ ///
+ public partial class CMVIIIModule : ComUserMD
+ {
+ public CMVIIIModule()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_MAVIII;//matrix A8
+ devinfo.devProv.pMachineID= AppIDList.AP_Matrix_A8;
+
+
+
+ }
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+
+ base.loadDevInfo(devf);
+ edDevID.Text = devf.devProv.pDeviceID.ToString("X4");
+ if (devf.devProv.strDevName.Length > 16)
+ {
+ //string strTmp=devf.devProv.strDevName;
+ headLb.Text = devf.devProv.strDevName.Substring(0, 16);
+ }
+
+ else
+ headLb.Text = devf.devProv.strDevName;
+ }
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+
+
+ }
+
+ public override void setDeviceID(UInt16 mid)
+ {
+ base.setDeviceID(mid);
+ devinfo.devProv.pDeviceID = mid;
+ edDevID.Text = mid.ToString("X4");
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ devinfo.devProv.strDevName = strName;
+ if (strName.Length > 16)
+ headLb.Text = strName.Substring(0, 16);
+ else
+ headLb.Text = strName;
+
+
+ }
+
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ var inputPDlg = new InputHexDialog();
+ inputPDlg.Background = border.Background as SolidColorBrush;
+ var sres=inputPDlg.ShowDialog();
+ if (sres == true)
+ {
+ edDevID.Text= inputPDlg.devID.ToString("X4");
+ devinfo.devProv.pDeviceID= inputPDlg.devID;
+
+ }
+
+
+ }
+
+ public override void setHeaderStatus(bool status)
+ {
+ base.setHeaderStatus(status);
+ headLb.Background = new SolidColorBrush((status ? activeConHeadColor : unConHeadColor));
+
+ }
+
+ //delete module
+ private void MenuItem_Click_1(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+
+ }
+ }
+}
diff --git a/LibControl/Controls/Module/CMVIIIModule.xaml.cs~RF9ad838.TMP b/LibControl/Controls/Module/CMVIIIModule.xaml.cs~RF9ad838.TMP
new file mode 100644
index 0000000..c240aed
--- /dev/null
+++ b/LibControl/Controls/Module/CMVIIIModule.xaml.cs~RF9ad838.TMP
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using CommLibrary;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CMVIIIModule.xaml
+ ///
+ public partial class CMVIIIModule : ComUserMD
+ {
+ public CMVIIIModule()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_MAVIII;//matrix A8
+ devinfo.devProv.pMachineID= AppIDList.AP_Matrix_A8;
+
+
+
+ }
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+
+ base.loadDevInfo(devf);
+ edDevID.Text = devf.devProv.pDeviceID.ToString("X4");
+ if (devf.devProv.pDeviceName.Length > 8)
+ {
+ string strTmp=devf.devProv.strDevName;
+ edDevName.Text = strTmp.Substring(0, 8);
+ }
+
+ else
+ edDevName.Text = devf.devProv.strDevName;
+ }
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+
+
+ }
+
+ public override void setDeviceID(int mid)
+ {
+ base.setDeviceID(mid);
+ devinfo.devProv.pDeviceID = mid;
+ edDevID.Text = mid.ToString("X4");
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ devinfo.devProv.strDevName = strName;
+ edDevName.Text = strName;
+
+ }
+
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ var inputPDlg = new InputHexDialog();
+ var sres=inputPDlg.ShowDialog();
+ if (sres == true)
+ {
+ edDevID.Text= inputPDlg.devID.ToString("X4");
+ devinfo.devProv.pDeviceID= inputPDlg.devID;
+
+
+ }
+
+
+ }
+
+ public override void setHeaderStatus(bool status)
+ {
+ base.setHeaderStatus(status);
+ headLb.Background = new SolidColorBrush((status ? activeConHeadColor : unConHeadColor));
+
+ }
+
+ //delete module
+ private void MenuItem_Click_1(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+
+ }
+ }
+}
diff --git a/LibControl/Controls/Module/CRVA200Module.xaml b/LibControl/Controls/Module/CRVA200Module.xaml
new file mode 100644
index 0000000..4474dfc
--- /dev/null
+++ b/LibControl/Controls/Module/CRVA200Module.xaml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CRVA200Module.xaml.cs b/LibControl/Controls/Module/CRVA200Module.xaml.cs
new file mode 100644
index 0000000..d55010c
--- /dev/null
+++ b/LibControl/Controls/Module/CRVA200Module.xaml.cs
@@ -0,0 +1,162 @@
+using CommLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CRVC200.xaml
+ ///
+ public partial class CRVC200Module : ComUserMD
+ {
+ public CRVC200Module()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_RVA100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RVA_100;
+ devinfo.strDevName = string.Empty;
+ }
+
+
+ public override void setBotomCap(string strCap)
+ {
+ base.setBotomCap(strCap);
+ botomLb.Text = strCap.Trim();
+ }
+
+ public override void setHeadColor(SolidColorBrush scb)
+ {
+ base.setHeadColor(scb);
+ border.Background = scb;
+ }
+
+ public override void setBodyColor(SolidColorBrush scb)
+ {
+ base.setBodyColor(scb);
+ grid.Background = scb;
+ }
+ public override void setBodyImage(ImageSource imgsrc)
+ {
+ base.setBodyImage(imgsrc);
+ image.Source = imgsrc;
+ }
+ ///
+ /// module RVA set
+ ///
+ ///
+ public override void setRVAModuleType(ModuleRVAS modRva)
+ {
+ base.setRVAModuleType(modRva);
+ switch(modRva)
+ {
+ case ModuleRVAS.MRVA:
+ devinfo.devModuleType = Module_Type.Mod_RVA100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RVA_100;
+ break;
+ case ModuleRVAS.MRVC:
+ devinfo.devModuleType = Module_Type.Mod_RVC100;// RVC1000
+ devinfo.devProv.pMachineID = AppIDList.AP_RVC_100;//
+ break;
+ case ModuleRVAS.MRIO:
+ devinfo.devModuleType = Module_Type.Mod_RIO100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RIO_100;
+ break;
+ case ModuleRVAS.RPM:
+ devinfo.devModuleType = Module_Type.Mod_RPM100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RPM_100;
+ break;
+
+ }
+
+
+ }
+
+
+ ///
+ /// delete module
+ ///
+ ///
+ ///
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+ }
+ //----------
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+ base.loadDevInfo(devf);
+ edDevID.Text = devf.devProv.pDeviceID.ToString("X4");
+ if (devf.devProv.strDevName.Length > 16)
+ {
+
+ rheadLb.Text = devf.devProv.strDevName.Substring(0, 16);
+ }
+ else
+ rheadLb.Text = devf.devProv.strDevName;
+
+
+ }
+
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+ }
+
+ public override void setDeviceID(UInt16 mid)
+ {
+ base.setDeviceID(mid);
+ devinfo.devProv.pDeviceID = mid;
+ edDevID.Text = mid.ToString("X4");
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ devinfo.devProv.strDevName = strName;
+ if (strName.Length > 16)
+ rheadLb.Text = strName.Substring(0, 16);
+ else
+ rheadLb.Text = strName;
+
+ }
+ ///
+ /// change device ID
+ ///
+ ///
+ ///
+ private void changeDevID_Click(object sender, RoutedEventArgs e)
+ {
+ var inputPDlg = new InputHexDialog();
+ inputPDlg.Background = border.Background as SolidColorBrush;
+ var sres = inputPDlg.ShowDialog();
+ if (sres == true)
+ {
+ edDevID.Text = inputPDlg.devID.ToString("X4");
+ devinfo.devProv.pDeviceID = inputPDlg.devID;
+
+ }
+ }
+
+
+ public override void setHeaderStatus(bool status)
+ {
+ base.setHeaderStatus(status);
+ rheadLb.Background = new SolidColorBrush((status ? activeConHeadColor : unConHeadColor));
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/Module/CRVA200Module.xaml.cs~RF1777d43a.TMP b/LibControl/Controls/Module/CRVA200Module.xaml.cs~RF1777d43a.TMP
new file mode 100644
index 0000000..41075a1
--- /dev/null
+++ b/LibControl/Controls/Module/CRVA200Module.xaml.cs~RF1777d43a.TMP
@@ -0,0 +1,143 @@
+using CommLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CRVC200.xaml
+ ///
+ public partial class CRVC200Module : ComUserMD
+ {
+ public CRVC200Module()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_RVA100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RVA_100;
+ devinfo.strDevName = string.Empty;
+ }
+
+
+ public override void setBotomCap(string strCap)
+ {
+ base.setBotomCap(strCap);
+ botomLb.Text = strCap.Trim();
+ }
+
+ ///
+ /// module RVA set
+ ///
+ ///
+ public override void setRVAModuleType(ModuleRVAS modRva)
+ {
+ base.setRVAModuleType(modRva);
+ switch(modRva)
+ {
+ case ModuleRVAS.MRVA:
+ devinfo.devModuleType = Module_Type.Mod_RVA100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RVA_100;
+ break;
+ case ModuleRVAS.MRVC:
+ devinfo.devModuleType = Module_Type.Mod_RVC100;// RVC1000
+ devinfo.devProv.pMachineID = AppIDList.AP_RVC_100;//
+ break;
+ case ModuleRVAS.MRIO:
+ devinfo.devModuleType = Module_Type.Mod_RIO100;
+ devinfo.devProv.pMachineID = AppIDList.AP_RIO_100;
+ break;
+ case ModuleRVAS.RPM:
+
+ break;
+
+ }
+
+
+ }
+
+
+
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ var inputPDlg = new InputHexDialog();
+ var sres = inputPDlg.ShowDialog();
+ if (sres == true)
+ {
+ edDevID.Text = inputPDlg.devID.ToString("X4");
+ devinfo.devProv.pDeviceID = inputPDlg.devID;
+ }
+
+ }
+ //----------
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+ base.loadDevInfo(devf);
+ edDevID.Text = devf.devProv.pDeviceID.ToString("X4");
+ if (devf.devProv.strDevName.Length > 16)
+ {
+
+ rheadLb.Text = devf.devProv.strDevName.Substring(0, 16);
+ }
+ else
+ rheadLb.Text = devf.devProv.strDevName;
+
+
+ }
+
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+ }
+
+ public override void setDeviceID(int mid)
+ {
+ base.setDeviceID(mid);
+ devinfo.devProv.pDeviceID = mid;
+ edDevID.Text = mid.ToString("X4");
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ devinfo.devProv.strDevName = strName;
+ if (strName.Length > 16)
+ rheadLb.Text = strName.Substring(0, 16);
+ else
+ rheadLb.Text = strName;
+
+ }
+
+ private void changeDevID_Click(object sender, RoutedEventArgs e)
+ {
+ var inputPDlg = new InputHexDialog();
+ var sres = inputPDlg.ShowDialog();
+ if (sres == true)
+ {
+ edDevID.Text = inputPDlg.devID.ToString("X4");
+ devinfo.devProv.pDeviceID = inputPDlg.devID;
+
+ }
+ }
+
+
+ public override void setHeaderStatus(bool status)
+ {
+ base.setHeaderStatus(status);
+ rheadLb.Background = new SolidColorBrush((status ? activeConHeadColor : unConHeadColor));
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/Module/CRightTextModule.xaml b/LibControl/Controls/Module/CRightTextModule.xaml
new file mode 100644
index 0000000..6aca237
--- /dev/null
+++ b/LibControl/Controls/Module/CRightTextModule.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CRightTextModule.xaml.cs b/LibControl/Controls/Module/CRightTextModule.xaml.cs
new file mode 100644
index 0000000..0840e23
--- /dev/null
+++ b/LibControl/Controls/Module/CRightTextModule.xaml.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using CommLibrary;
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CRightTextModule.xaml
+ ///
+ public partial class CRightTextModule : ComUserMD
+ {
+ public CRightTextModule()
+ {
+ InitializeComponent();
+
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_TxtRht;//text right
+
+ }
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+ base.loadDevInfo(devf);
+ edLbR.Text = devf.noteTxt;
+ }
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+
+ }
+
+ private void edLbR_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ devinfo.noteTxt = edLbR.Text.Trim();
+ }
+
+ public override void setDeviceID(UInt16 mid)
+ {
+ base.setDeviceID(mid);
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ }
+
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+ }
+
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/Module/CRouterLanModule.xaml b/LibControl/Controls/Module/CRouterLanModule.xaml
new file mode 100644
index 0000000..a32ecc5
--- /dev/null
+++ b/LibControl/Controls/Module/CRouterLanModule.xaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CRouterLanModule.xaml.cs b/LibControl/Controls/Module/CRouterLanModule.xaml.cs
new file mode 100644
index 0000000..b401245
--- /dev/null
+++ b/LibControl/Controls/Module/CRouterLanModule.xaml.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using CommLibrary;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CRouterLanModule.xaml
+ ///
+ public partial class CRouterLanModule : ComUserMD
+ {
+ public CRouterLanModule()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_LAN;//lan router
+ }
+ ///
+ ///
+ ///
+ ///
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+ base.loadDevInfo(devf);
+
+ }
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+
+ }
+ public override void setRouterAddr(string strAddr)
+ {
+ base.setRouterAddr(strAddr);
+ ipLabel.Text = strAddr;
+ }
+
+
+ public override void setHeaderStatus(bool status)
+ {
+ base.setHeaderStatus(status);
+ rheadLb.Background = new SolidColorBrush((status ? activeConHeadColor : unConHeadColor));
+
+ }
+
+ public override void setBodyColor(SolidColorBrush scb)
+ {
+ base.setBodyColor(scb);
+ bgrid.Background = scb;
+ }
+
+ public override void setHeadColor(SolidColorBrush scb)
+ {
+ base.setHeadColor(scb);
+ unConHeadColor = scb.Color;
+ rheadLb.Background = scb;
+ bottomLabel.Background = scb;
+ }
+
+
+ public override void setDeviceID(UInt16 mid)
+ {
+ base.setDeviceID(mid);
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ }
+ ///
+ /// delete module
+ ///
+ ///
+ ///
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+ }
+
+ }
+}
diff --git a/LibControl/Controls/Module/CRouterLanModule.xaml~RF5a49f96.TMP b/LibControl/Controls/Module/CRouterLanModule.xaml~RF5a49f96.TMP
new file mode 100644
index 0000000..27d925a
--- /dev/null
+++ b/LibControl/Controls/Module/CRouterLanModule.xaml~RF5a49f96.TMP
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CRouterLanModule.xaml~RF5ae3de7.TMP b/LibControl/Controls/Module/CRouterLanModule.xaml~RF5ae3de7.TMP
new file mode 100644
index 0000000..a32ecc5
--- /dev/null
+++ b/LibControl/Controls/Module/CRouterLanModule.xaml~RF5ae3de7.TMP
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CSwitcherIVModule.xaml b/LibControl/Controls/Module/CSwitcherIVModule.xaml
new file mode 100644
index 0000000..2d6c74f
--- /dev/null
+++ b/LibControl/Controls/Module/CSwitcherIVModule.xaml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+ D
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CSwitcherIVModule.xaml.cs b/LibControl/Controls/Module/CSwitcherIVModule.xaml.cs
new file mode 100644
index 0000000..5da279b
--- /dev/null
+++ b/LibControl/Controls/Module/CSwitcherIVModule.xaml.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using CommLibrary;
+
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for CSwitcherIVModule.xaml
+ ///
+ public partial class CSwitcherIVModule : ComUserMD
+ {
+ public CSwitcherIVModule()
+ {
+ InitializeComponent();
+ devinfo = new CDeviceInfo();
+ devinfo.devModuleType = Module_Type.Mod_CLIV;//CL-4
+ cbBox.SelectionChanging += cbox_SelectionChanging;
+
+ }
+
+ public override void setHeaderStatus(bool status)
+ {
+ base.setHeaderStatus(status);
+
+ IVheadLb.Background = new SolidColorBrush((status ? activeConHeadColor : unConHeadColor));
+
+ }
+
+ public override void setHeadColor(SolidColorBrush scb)
+ {
+ base.setHeadColor(scb);
+ IVheadLb.Background = scb;
+ unConHeadColor = scb.Color;
+ botomLabel.Background = scb;
+
+ }
+
+ public override void setRouterAddr(string strAddr)
+ {
+ base.setRouterAddr(strAddr);
+ ipLabel.Text = strAddr;
+ }
+
+
+ public override void setBodyColor(SolidColorBrush scb)
+ {
+ base.setBodyColor(scb);
+ bgrid.Background = scb;
+ }
+
+
+ private void cbox_SelectionChanging(object sender, SelectionChangingEventArgs e) //eq type
+ {
+ // e.Cancel = true;
+ var cbx = sender as TComboBox;
+ devinfo.lineIndex = cbx.SelectedIndex;
+ }
+
+ public override void loadDevInfo(CDeviceInfo devf)
+ {
+ base.loadDevInfo(devf);
+ cbBox.SelectedIndex = devf.lineIndex;
+ }
+ public override void saveDeInfo()
+ {
+ base.saveDeInfo();
+ // devinfo.lineIndex = cbBox.SelectedIndex;
+
+ }
+
+
+ public override void setDeviceID(UInt16 mid)
+ {
+ base.setDeviceID(mid);
+ }
+
+ public override void setDeviceName(string strName)
+ {
+ base.setDeviceName(strName);
+ }
+
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ deleteModule(sender);
+ }
+ }
+}
diff --git a/LibControl/Controls/Module/CSwitcherIVModule.xaml~RF5b9b410.TMP b/LibControl/Controls/Module/CSwitcherIVModule.xaml~RF5b9b410.TMP
new file mode 100644
index 0000000..97d52ff
--- /dev/null
+++ b/LibControl/Controls/Module/CSwitcherIVModule.xaml~RF5b9b410.TMP
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+ D
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/CSwitcherIVModule.xaml~RF5bb77cb.TMP b/LibControl/Controls/Module/CSwitcherIVModule.xaml~RF5bb77cb.TMP
new file mode 100644
index 0000000..dbe851c
--- /dev/null
+++ b/LibControl/Controls/Module/CSwitcherIVModule.xaml~RF5bb77cb.TMP
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+ D
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/ComUserMD.cs b/LibControl/Controls/Module/ComUserMD.cs
new file mode 100644
index 0000000..4b7a69b
--- /dev/null
+++ b/LibControl/Controls/Module/ComUserMD.cs
@@ -0,0 +1,270 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Diagnostics;
+using CommLibrary;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixSystemEditor.commom
+ *文件名: ComUserMD
+ *版本号: V1.0.0.0
+ *唯一标识:bdd6a293-d59c-419f-9d70-3f9d3c67e8e9
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:11/17/2016 7:29:31 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:11/17/2016 7:29:31 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ * 对于usercontrol 继承的这种,必须使用不同的name,比如CLeftText
+/************************************************************************************/
+
+
+namespace Lib.Controls
+{
+
+ /*
+ ID type list below:
+ * Left/Right Text devID:0x5000,0x5001
+ * LanRouter:0x5002
+ * cl-IV Switcher:0x5003
+ *
+ * MatrixA8 or later from 0x1000 +
+ *
+ *
+ */
+ public class ComUserMD : UserControl
+ {
+
+
+ #region property define-------------------------------
+
+#if DoduleTypeDefine
+ private const Module_Type DefaultMType = Module_Type.Mod_CLIV;
+ public Module_Type ModuleType
+ {
+ get { return (Module_Type)GetValue(ModuleTypeProperty); }
+ set { SetValue(ModuleTypeProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for ModuleType. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty ModuleTypeProperty =
+ DependencyProperty.Register("ModuleType", typeof(Module_Type), typeof(ComUserMD),
+ new PropertyMetadata(DefaultMType));
+ //---------------------------------
+#endif
+ #endregion
+
+
+
+
+
+ private static Color DefaultUnColor = Color.FromRgb(0xC0, 0xC0, 0xC0);
+
+ public Color unConHeadColor
+ {
+ get { return (Color)GetValue(unConHeadColorProperty); }
+ set { SetValue(unConHeadColorProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for unConHeadColor. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty unConHeadColorProperty =
+ DependencyProperty.Register("unConHeadColor", typeof(Color), typeof(ComUserMD), new PropertyMetadata(DefaultUnColor));
+
+
+ private static SolidColorBrush DefaultHeadColor = new SolidColorBrush(Color.FromRgb(0x25, 0x40, 0x61)); //green color
+ public SolidColorBrush HeadColor
+ {
+ get { return (SolidColorBrush)GetValue(HeadColorProperty); }
+ set { SetValue(HeadColorProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeConHeadColor. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty HeadColorProperty =
+ DependencyProperty.Register("HeadColor", typeof(SolidColorBrush), typeof(CRVC200Module), new PropertyMetadata(DefaultHeadColor));
+
+
+ private static Color DefaultActColor = Color.FromRgb(0, 0xFF, 0); //green color
+ public Color activeConHeadColor
+ {
+ get { return (Color)GetValue(activeConHeadColorProperty); }
+ set { SetValue(activeConHeadColorProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for activeConHeadColor. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty activeConHeadColorProperty =
+ DependencyProperty.Register("activeConHeadColor", typeof(Color), typeof(ComUserMD), new PropertyMetadata(DefaultActColor));
+
+
+
+
+ public CDeviceInfo devinfo;
+
+ public void setDevX(double x)
+ {
+ devinfo.DevPoint.X = x;
+ Canvas.SetLeft(this, x);
+
+ }
+ public void setDevY(double y)
+ {
+ devinfo.DevPoint.Y = y;
+ Canvas.SetTop(this, y);
+
+ }
+ ///
+ ///
+ ///
+ ///
+ public virtual void setDeviceID(UInt16 mid)
+ {
+
+
+ }
+ ///
+ /// ///
+ ///
+ ///
+ public virtual void setDeviceName(string strName)
+ {
+
+
+ }
+
+
+
+ public void setDevPoint(Point pt)
+ {
+ devinfo.DevPoint = pt;
+ Canvas.SetLeft(this, pt.X);
+ Canvas.SetTop(this, pt.Y);
+ }
+
+ #region virutal function
+ public virtual void saveDeInfo()
+ {
+ devinfo.DevPoint.X = Canvas.GetLeft(this);
+ devinfo.DevPoint.Y = Canvas.GetTop(this);
+
+ }
+ public virtual void setRouterAddr(String strAddr)
+ {
+
+ }
+
+ public virtual void setBotomCap(string strCap)
+ {
+
+ }
+
+ public virtual void setHeadColor(SolidColorBrush scb)
+ {
+
+ }
+ public virtual void setBodyColor(SolidColorBrush scb)
+ {
+
+ }
+
+ public virtual void setBodyImage(ImageSource imgsrc)
+ {
+
+ }
+ public virtual void setRVAModuleType(ModuleRVAS modRva)
+ {
+
+ }
+
+ private bool headStatus = false;
+
+ public virtual void setHeaderStatus(bool status)
+ {
+ headStatus = status;
+ }
+
+
+
+ public virtual void loadDevInfo(CDeviceInfo devf) //load dev into it
+ {
+ devinfo.copyDevinfo(devf);
+ setDevX(devinfo.DevPoint.X);
+ setDevY(devinfo.DevPoint.Y);
+ }
+ #endregion
+
+
+ public ComUserMD()
+ {
+ if (devinfo == null)
+ {
+ devinfo = new CDeviceInfo();
+ }
+ devinfo.devProv.pDeviceID = 0x1000;
+ devinfo.devProv.strDevName = "DeviceID";
+
+
+
+ }
+ #region clickEvent below
+
+ public delegate void mouseDoubleClick(Object sender);
+ public event mouseDoubleClick onMouseDoubleClickEvent;
+
+ protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
+ {
+ base.OnMouseDoubleClick(e);
+
+ if (onMouseDoubleClickEvent != null)
+ {
+ onMouseDoubleClickEvent(this);
+ }
+
+ }
+
+
+ #endregion
+
+ public void deleteModule(object sender)
+ {
+ var grid2 = (Grid)ContextMenuService.GetPlacementTarget(
+ LogicalTreeHelper.GetParent(sender as MenuItem));
+ ComUserMD mod;
+ if (Convert.ToInt16(grid2.Tag) == 100)
+ {
+ var aaa = (Border)LogicalTreeHelper.GetParent(grid2);
+ mod = (ComUserMD)LogicalTreeHelper.GetParent(aaa);
+ }
+ else
+ {
+ mod = (ComUserMD)LogicalTreeHelper.GetParent(grid2);
+ }
+ var cvs = (Canvas)LogicalTreeHelper.GetParent(mod);
+ cvs.Children.Remove(mod);
+
+ }
+
+
+
+ }
+}
diff --git a/LibControl/Controls/Module/IOSqliteOperation.cs~RF4a5bd6.TMP b/LibControl/Controls/Module/IOSqliteOperation.cs~RF4a5bd6.TMP
new file mode 100644
index 0000000..c10a479
--- /dev/null
+++ b/LibControl/Controls/Module/IOSqliteOperation.cs~RF4a5bd6.TMP
@@ -0,0 +1,317 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SQLite;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixSystemEditor.commom
+ *文件名: IOSqliteOperation
+ *版本号: V1.0.0.0
+ *唯一标识:3095a0c4-643d-485a-98cb-b4f4303c51bf
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:11/19/2016 2:18:02 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:11/19/2016 2:18:02 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+/*
+ 1:when close table ,first clear the database,then do save all date to datable
+ 2:when load read the data from database
+ */
+namespace MatrixSystemEditor.commom
+{
+ class IOSqliteOperation
+ {
+
+ private string uDataBase = "sysdb.db"; //default is in the app file directory
+ public SQLiteConnection m_dbConnection;
+
+
+ public IOSqliteOperation(string dbName)
+ {
+ uDataBase = dbName;
+ createDataBase();
+ connectToDataBase();
+ // createTables();
+ }
+
+ public IOSqliteOperation()
+ {
+
+ createDataBase();
+ connectToDataBase();
+
+ }
+
+ public bool FileInUse(string strpath)
+ {
+ bool res = false;
+ try
+ {
+ using (FileStream fs = new FileStream(strpath, FileMode.OpenOrCreate))
+ {
+ res = !fs.CanWrite;
+ }
+ return false;
+ }
+ catch (IOException ex)
+ {
+ return true;
+
+ }
+
+ }
+
+ private void createDataBase()
+ {
+ if (File.Exists(uDataBase))
+ {
+ // Debug.WriteLine("database is exist ");
+ if (FileInUse(uDataBase))
+ {
+ // MessageBox.Show("File is in used or has opened,you must close the file firstly!");
+ Environment.Exit(-1);
+ }
+ }
+ else
+ {
+ // Debug.WriteLine("database is not exist....");
+ SQLiteConnection.CreateFile(uDataBase);
+ }
+
+ }
+
+ private void connectToDataBase()
+ {
+ try
+ {
+ string strDBC = string.Format("Data Source={0};Version=3;", uDataBase);
+ m_dbConnection = new SQLiteConnection(strDBC);
+ m_dbConnection.Open();
+ }
+ catch (Exception ec)
+ {
+ // MessageBox.Show("Open dtabase error");
+ Debug.WriteLine("connect to database error...............");
+ }
+ }
+
+ private const string CDeviceTable = "DeviceModTable";
+
+ private void createTable(string msql, string strTable)
+ {
+ //first check if exist
+ //string.Format("create table if not exists {0}(name varchar(20),score int)"
+ string sql = string.Format(msql, strTable);
+ SQLiteCommand comand = new SQLiteCommand(sql, m_dbConnection);
+ comand.ExecuteNonQuery();//insert or create table ,it is the non return type
+
+ }
+
+ private const string ModuleInfoPosTb = "ModuleInfoTable";
+
+ public void renewSaveModuleInfo(List devList)
+ {
+ createModuleInfoTable();
+ saveToDevList(devList);
+ }
+
+ public void createModuleInfoTable() //for save and renew table now
+ {
+ try
+ {
+ //create module position table
+
+ //drop table first
+ string sql = string.Format("drop table if exists {0}", ModuleInfoPosTb);
+ SQLiteCommand comand = new SQLiteCommand(sql, m_dbConnection);
+ comand.ExecuteNonQuery();//insert or create table ,it is the non return type
+ ///execute for create table
+ sql = string.Format("create table if not exists {0}(moduleType int,devName varchar(20),noteTxt varchar(20),machineID int," +
+ "devID int,devPtX float,devPtY float,linindex int )", ModuleInfoPosTb);
+ comand = new SQLiteCommand(sql, m_dbConnection);
+ comand.ExecuteNonQuery();//insert or create table ,it is the non return type
+ }
+ catch (Exception e)
+ {
+
+
+ }
+ }
+
+ // Inserts some values in the highscores table.
+ // As you can see, there is quite some duplicate code here, we'll solve this in part two.
+ public void saveToDevList(List devList)
+ {
+ if (devList == null) return;
+ string sql = "";
+ SQLiteCommand comnd = null;
+ foreach (CDeveInfo dev in devList)
+ {
+
+ sql = string.Format("insert into {0}(moduleType, devName,noteTxt,machineID,devID,devPtX,devPtY,linindex) values (?,?,?,?,?,?,?,?)", ModuleInfoPosTb);
+ comnd = new SQLiteCommand(sql, m_dbConnection);
+ comnd.Parameters.Add("moduleType", System.Data.DbType.Int16);
+ comnd.Parameters["moduleType"].Value = dev.devModuleType;
+
+ comnd.Parameters.Add("devName", System.Data.DbType.String);
+ comnd.Parameters["devName"].Value = dev.DeviceName;
+
+ comnd.Parameters.Add("noteTxt", System.Data.DbType.String);
+ comnd.Parameters["noteTxt"].Value = dev.noteTxt;
+
+ comnd.Parameters.Add("machineID", System.Data.DbType.Int16);
+ comnd.Parameters["machineID"].Value = dev.devProv.pMachineID;
+
+ comnd.Parameters.Add("devID", System.Data.DbType.Int16);
+ comnd.Parameters["devID"].Value = dev.devProv.pDeviceID;
+
+ comnd.Parameters.Add("devPtX", System.Data.DbType.Double);
+ comnd.Parameters["devPtX"].Value = dev.DevPoint.X;
+
+ comnd.Parameters.Add("devPtY", System.Data.DbType.Double);
+ comnd.Parameters["devPtY"].Value = dev.DevPoint.Y;
+
+ comnd.Parameters.Add("linindex", System.Data.DbType.Int16);
+ comnd.Parameters["linindex"].Value = dev.lineIndex;
+
+
+ comnd.ExecuteNonQuery();
+ }
+
+ }
+
+ public void readToDevList(List devList)
+ {
+ if (devList == null) return;
+ devList.Clear(); //renew
+
+ try
+ {
+ string sql = string.Format("select * from {0}", ModuleInfoPosTb);
+ SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
+ SQLiteDataReader reader = command.ExecuteReader();
+ CDeveInfo devi = null;
+ while (reader.Read())
+ {
+ //devicelist
+ devi = new CDeveInfo();
+ devi.devModuleType = (Module_Type)reader["moduleType"];
+ devi.devProv.pMachineID = (int)reader["machineID"];
+ devi.devProv.pDeviceID= (int)reader["devID"];
+
+ devi.DeviceName = reader["devName"].ToString();
+ devi.noteTxt = reader["noteTxt"].ToString();
+
+ devi.DevPoint.X = (double)reader["devPtX"];
+ devi.DevPoint.Y = (double)reader["devPtY"];
+ devi.lineIndex = (int)reader["linindex"];
+ devList.Add(devi);
+ devi.printDevInfo();
+ }
+ }
+ catch (SQLiteException e)
+ {
+
+
+ }
+
+ }
+
+
+
+#if _refcence
+
+ private void refreshTable()
+ {
+ string sql = string.Format("select * from {0} ", CLineTable);
+ SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
+ SQLiteDataReader reader = command.ExecuteReader();
+ int rowNum = 0;
+ /*
+ if (reader.HasRows)
+ {
+ while (reader.Read())
+ {
+ Console.WriteLine("Name = ", reader["Name"]);
+ Console.WriteLine("Address = ", reader["score"]);
+ }
+ }
+ */
+ using (DataTable dt = new DataTable())
+ {
+ dt.Load(reader);
+ rowNum = dt.Rows.Count;
+ }
+ reader.Close();
+
+ Debug.WriteLine("table rows count is {0}", rowNum);
+ if (rowNum == 0) //use insert model
+ {
+ sql = string.Format("INSERT INTO {0}(name,score) VALUES(?,?)", CLineTable);
+ command = new SQLiteCommand(sql, m_dbConnection);
+
+ command.Parameters.Add("name", System.Data.DbType.String);
+ command.Parameters["name"].Value = muserList[0].Name;
+
+ command.Parameters.Add("score", System.Data.DbType.Int16);
+ command.Parameters["score"].Value = muserList[0].Score;
+
+ try
+ {
+ command.ExecuteNonQuery();
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ }
+ else //use modify update model
+ {
+ //modify
+ sql = string.Format("UPDATE {0} set name=?,score=?", CLineTable);
+ command = new SQLiteCommand(sql, m_dbConnection);
+ command.Parameters.Add("name", System.Data.DbType.String);
+ command.Parameters["name"].Value = muserList[0].Name;
+ //
+ command.Parameters.Add("score", System.Data.DbType.Int16);
+ command.Parameters["score"].Value = muserList[0].Score;
+
+ try
+ {
+ command.ExecuteNonQuery();
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+
+ }
+
+
+
+ }
+#endif
+
+ }
+}
diff --git a/LibControl/Controls/Module/InputHexDialog.xaml b/LibControl/Controls/Module/InputHexDialog.xaml
new file mode 100644
index 0000000..f7c427f
--- /dev/null
+++ b/LibControl/Controls/Module/InputHexDialog.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/InputHexDialog.xaml.cs b/LibControl/Controls/Module/InputHexDialog.xaml.cs
new file mode 100644
index 0000000..846f5c0
--- /dev/null
+++ b/LibControl/Controls/Module/InputHexDialog.xaml.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Text.RegularExpressions;
+using System.Diagnostics;
+using System.Globalization;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for InputPasDialog.xaml
+ ///
+ public partial class InputHexDialog : Window
+ {
+
+ public UInt16 devID { get; set; }
+ public InputHexDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void btnOK_Click(object sender, RoutedEventArgs e)
+ {
+ Debug.WriteLine("btn ok is pressed now............");
+ if(edInput.Text.Trim().Length>=4)
+ {
+ this.DialogResult = true;
+ devID = UInt16.Parse(edInput.Text.Trim(), NumberStyles.HexNumber);
+ }
+
+ this.Close();
+ }
+
+
+ private void btnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-fA-F0-9\b]+$");//numeric and backspace
+ e.Handled = regex.IsMatch(e.Text);
+
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ edInput.Focus();
+ }
+
+ private void edInput_KeyDown(object sender, KeyEventArgs e)
+ {
+
+ if(e.Key==Key.Return)
+ {
+ btnOK_Click(sender, e);
+
+ }
+
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+
+ }
+
+
+
+
+ }
+}
diff --git a/LibControl/Controls/Module/LCommand.cs b/LibControl/Controls/Module/LCommand.cs
new file mode 100644
index 0000000..cab9a6d
--- /dev/null
+++ b/LibControl/Controls/Module/LCommand.cs
@@ -0,0 +1,246 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Diagnostics;
+
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:MatrixUpdate
+ *文件名: LCommand
+ *版本号: V1.0.0.0
+ *唯一标识:852961b3-ed58-4d8f-9c96-ad5c5163c1a6
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/1/2016 3:30:35 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/1/2016 3:30:35 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class LCommand
+ {
+ public const byte UTRAL_H0 = 0x01;
+ public const byte UTRAL_H1 = 0x20;
+ public const byte UTRAL_H2 = 0x03;
+ public const byte UTRAL_End = 0x40;
+
+ private int packLen;
+ private int _cmdType;
+ public int packMinLen = 14;
+
+ public int ID_Machine
+ {
+ get;
+ set;
+ }
+ public int Device_ID
+ {
+ get;
+ set;
+ }
+
+ public LCommand(int length, int cmdType)
+ {
+
+ packLen = length;
+ _cmdType = cmdType;
+ }
+
+ ///
+ /// getpackage with added data:aData
+ ///
+ ///
+ ///
+ public byte[] getPackage_withDataArray(byte[] aData)
+ {
+
+ byte[] package = new byte[packLen];
+ Array.Clear(package, 0, packLen);
+ if (aData == null)
+ {
+ Debug.WriteLine("package data added is error......");
+ return package;
+ }
+
+ package[0] = UTRAL_H0;
+ package[1] = UTRAL_H1;
+ package[2] = UTRAL_H2;
+ //
+ package[3] = (byte)(packLen / 256);
+ package[4] = (byte)(packLen % 256);
+
+ package[5] = (byte)(ID_Machine / 256);
+ package[6] = (byte)(ID_Machine % 256);
+
+ package[7] = (byte)(Device_ID / 256);
+ package[8] = (byte)(Device_ID % 256);
+
+ package[9] = (byte)(_cmdType / 256);
+ package[10] = (byte)(_cmdType % 256);
+ //
+ Array.Copy(aData, 0, package, 11, aData.Length);
+
+ package[packLen - 1] = UTRAL_End;
+
+ byte checkSum = package[0];
+ for (int i = 1; i < packLen; i++)
+ {
+ if (i != packLen - 2)
+ checkSum ^= package[i];
+
+ }
+ package[packLen - 2] = checkSum;
+ return package;
+
+ }
+
+ ///
+ /// getpackage with added data:aData,clen is the segment index
+ ///
+ ///
+ ///
+ public byte[] getPackage_withDataArray(byte[] aData, int clen)
+ {
+
+ byte[] package = new byte[packLen];
+ Array.Clear(package, 0, packLen);
+ if (aData == null)
+ {
+ Debug.WriteLine("package data added is error......");
+ return package;
+ }
+ package[0] = UTRAL_H0;
+ package[1] = UTRAL_H1;
+ package[2] = UTRAL_H2;
+ //
+ package[3] = (byte)(packLen / 256);
+ package[4] = (byte)(packLen % 256);
+
+ package[5] = (byte)(ID_Machine / 256);
+ package[6] = (byte)(ID_Machine % 256);
+
+ package[7] = (byte)(Device_ID / 256);
+ package[8] = (byte)(Device_ID % 256);
+
+ package[9] = (byte)(_cmdType / 256);
+ package[10] = (byte)(_cmdType % 256);
+
+ package[11] = (byte)(clen / 100);
+ package[12] = (byte)((clen) % 100);
+ //
+ Array.Copy(aData, 0, package, 13, aData.Length);
+
+ //len-3,len-4 is reserved
+
+ byte checkSum = package[0];
+ for (int i = 1; i < packLen; i++)
+ {
+ checkSum ^= package[i];
+
+ }
+
+ package[packLen - 1] = UTRAL_End;
+ for (int i = 1; i < packLen; i++)
+ {
+ if (i != packLen - 2)
+ checkSum ^= package[i];
+
+ }
+ package[packLen - 2] = checkSum;
+ return package;
+
+ }
+
+ public byte[] getPackage_withoutDataArray(int item)
+ {
+
+ byte[] package = new byte[packLen];
+ Array.Clear(package, 0, packLen);
+
+ package[0] = UTRAL_H0;
+ package[1] = UTRAL_H1;
+ package[2] = UTRAL_H2;
+ //
+ package[3] = (byte)(packLen / 256);
+ package[4] = (byte)(packLen % 256);
+
+ package[5] = (byte)(ID_Machine / 256);
+ package[6] = (byte)(ID_Machine % 256);
+
+ package[7] = (byte)(Device_ID / 256);
+ package[8] = (byte)(Device_ID % 256);
+
+ package[9] = (byte)(_cmdType / 256);
+ package[10] = (byte)(_cmdType % 256);
+ package[11] = (byte)item;
+
+ //
+ byte checkSum = package[0];
+
+ package[packLen - 1] = UTRAL_End;
+
+ for (int i = 1; i < packLen; i++)
+ {
+ if (i != packLen - 2)
+ checkSum ^= package[i];
+
+ }
+ package[packLen - 2] = checkSum;
+ return package;
+
+ }
+
+ public byte[] getPackage_withoutDataArray()
+ {
+
+ byte[] package = new byte[packLen];
+ Array.Clear(package, 0, packLen);
+
+ package[0] = UTRAL_H0;
+ package[1] = UTRAL_H1;
+ package[2] = UTRAL_H2;
+ //
+ package[3] = (byte)(packLen / 256);
+ package[4] = (byte)(packLen % 256);
+
+ package[5] = (byte)(ID_Machine / 256);
+ package[6] = (byte)(ID_Machine % 256);
+
+ package[7] = (byte)(Device_ID / 256);
+ package[8] = (byte)(Device_ID % 256);
+
+ package[9] = (byte)(_cmdType / 256);
+ package[10] = (byte)(_cmdType % 256);
+ //
+ byte checkSum = package[0];
+
+ package[packLen - 1] = UTRAL_End;
+
+ for (int i = 1; i < packLen; i++)
+ {
+ if (i != packLen - 2)
+ checkSum ^= package[i];
+
+ }
+ package[packLen - 2] = checkSum;
+ return package;
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/Module/MessageReceiver.cs b/LibControl/Controls/Module/MessageReceiver.cs
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/LibControl/Controls/Module/MessageReceiver.cs
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/LibControl/Controls/Module/changeNameDialog.xaml b/LibControl/Controls/Module/changeNameDialog.xaml
new file mode 100644
index 0000000..ca81013
--- /dev/null
+++ b/LibControl/Controls/Module/changeNameDialog.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Module/changeNameDialog.xaml.cs b/LibControl/Controls/Module/changeNameDialog.xaml.cs
new file mode 100644
index 0000000..c950ea8
--- /dev/null
+++ b/LibControl/Controls/Module/changeNameDialog.xaml.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Text.RegularExpressions;
+using System.Diagnostics;
+using System.Globalization;
+using CommLibrary;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for InputPasDialog.xaml
+ ///
+ public partial class ChangeNameDialog : Window
+ {
+
+
+
+ public int chindex { get; set; }
+
+ public ChangeNameDialog()
+ {
+ InitializeComponent();
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void btnSave_Click(object sender, RoutedEventArgs e)
+ {
+ if (fedInput.Text.Trim().Length > 0)
+ {
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ }
+ ///
+ /// fetch the input keybord name string
+ ///
+ ///
+ public string getInputName()
+ {
+ return fedInput.Text.Trim();
+ }
+
+ public void setChName(string mstr)
+ {
+ fedInput.Clear();
+ fedInput.Text = mstr.Trim();
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void btnSetDefault_Click(object sender, RoutedEventArgs e)
+ {
+ string str = CUlitity.defaultChName(chindex).Trim();
+ fedInput.Text = str;
+ Debug.WriteLine("set default string is : " + str);
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-zA-Z0-9\b]+$");//numeric and backspace
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ fedInput.Focus();
+ string str = string.Format("channel {0} name will be changed.", chindex + 1);
+ this.Title = str;
+ }
+
+ private void edInput_KeyDown(object sender, KeyEventArgs e)
+ {
+
+ if (e.Key == Key.Return)
+ {
+ btnSave_Click(sender, e);
+
+ }
+
+ }
+
+
+
+ }
+}
diff --git a/LibControl/Controls/Module/changeNameDialog.xaml~RFc0b668e.TMP b/LibControl/Controls/Module/changeNameDialog.xaml~RFc0b668e.TMP
new file mode 100644
index 0000000..ca81013
--- /dev/null
+++ b/LibControl/Controls/Module/changeNameDialog.xaml~RFc0b668e.TMP
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/PainterText.cs b/LibControl/Controls/PainterText.cs
new file mode 100644
index 0000000..8acdc57
--- /dev/null
+++ b/LibControl/Controls/PainterText.cs
@@ -0,0 +1,176 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:DrawDemo
+ *文件名: PainterText
+ *版本号: V1.0.0.0
+ *唯一标识:1ba03d05-ad72-4a31-9dae-b4597892a677
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/28/2016 2:14:48 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/28/2016 2:14:48 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+ public class PainterText : Control
+ {
+
+ public static string[] DrawText ={
+ " 0",
+ " -5",
+ "-10",
+ "-15",
+ "-20",
+ "-25",
+ "-30",
+ "-35",
+ "-40"
+
+ };
+
+ static PainterText()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(PainterText), new FrameworkPropertyMetadata(typeof(PainterText)));
+ }
+
+ public PainterText()
+ {
+ // Color
+
+ }
+ public FormattedText getFormatStr(string str, int fontSize, Brush mbrush)
+ {
+ FormattedText formatText = new FormattedText(str,
+ System.Globalization.CultureInfo.CurrentCulture,
+ System.Windows.FlowDirection.LeftToRight,
+ new Typeface(new FontFamily("Arial").ToString()),
+ fontSize, mbrush);
+
+ return formatText;
+ }
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ base.OnRender(dc);
+ for (int i = 0; i < DrawText.Length; i++)
+ {
+
+ string str = DrawText[i];
+ FormattedText fStr = getFormatStr(str, 8, Brushes.Black);
+ dc.DrawText(fStr, new Point(xoffset, i * fontGap));
+
+ }
+
+ }
+
+
+
+ private static double DefaultXOffset = 1.0;
+ public double xoffset
+ {
+ get { return (double)GetValue(xoffsetProperty); }
+ set { SetValue(xoffsetProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for xoffset. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty xoffsetProperty =
+ DependencyProperty.Register("xoffset", typeof(double), typeof(PainterText),
+ new FrameworkPropertyMetadata(DefaultXOffset, FrameworkPropertyMetadataOptions.None, onTextXoffsetChange
+ ));
+
+
+ private static void onTextXoffsetChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var painter = obj as PainterText;
+ if (painter != null)
+ {
+ painter.xoffset = (double)args.NewValue;
+ painter.redraw();
+ }
+
+ }
+
+
+ private static double DefaultFontGap = 15;
+ public double fontGap
+ {
+ get { return (double)GetValue(fontGapProperty); }
+ set { SetValue(fontGapProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for fontGap. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fontGapProperty =
+ DependencyProperty.Register("fontGap", typeof(double), typeof(PainterText),
+ new FrameworkPropertyMetadata(DefaultFontGap, FrameworkPropertyMetadataOptions.None, onTextGapChange
+ ));
+
+
+ private static void onTextGapChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var painter = obj as PainterText;
+ if (painter != null)
+ {
+ painter.fontGap = (double)args.NewValue;
+ painter.redraw();
+ }
+
+ }
+
+
+ private static int DefaultFontSize = 8;
+ public int fontSizeOfDraw
+ {
+ get { return (int)GetValue(fontSizeOfDrawProperty); }
+ set { SetValue(fontSizeOfDrawProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for fontSizeOfDraw. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty fontSizeOfDrawProperty =
+ DependencyProperty.Register("fontSizeOfDraw", typeof(int), typeof(PainterText),
+ new FrameworkPropertyMetadata(DefaultFontSize, FrameworkPropertyMetadataOptions.None, onFontValueChange
+ ));
+
+
+ private static void onFontValueChange(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var painter = obj as PainterText;
+ if (painter != null)
+ {
+ painter.fontSizeOfDraw = (int)args.NewValue;
+ painter.redraw();
+ }
+
+
+ }
+ //
+ public void redraw()
+ {
+ // Debug.WriteLine("readraw.....");
+ InvalidateVisual();
+ }
+
+
+ }
+}
diff --git a/LibControl/Controls/PointLine.cs b/LibControl/Controls/PointLine.cs
new file mode 100644
index 0000000..821ca63
--- /dev/null
+++ b/LibControl/Controls/PointLine.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Lib.Controls
+{
+ public class PointLine
+ {
+
+ public int LineID { get; set; }
+ public List LinePointAry;
+ public PointLine()
+ {
+ LineID = 0;
+ LinePointAry=new List();
+ }
+
+
+
+ }
+}
diff --git a/LibControl/Controls/Properties/AssemblyInfo.cs b/LibControl/Controls/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..89c767a
--- /dev/null
+++ b/LibControl/Controls/Properties/AssemblyInfo.cs
@@ -0,0 +1,54 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Markup;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lib.Controls")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("lapthorn.net")]
+[assembly: AssemblyProduct("Lib.Controls")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/LibControl/Controls/Properties/Resources.Designer.cs b/LibControl/Controls/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..c3b4eff
--- /dev/null
+++ b/LibControl/Controls/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// 這段程式碼是由工具產生的。
+// 執行階段版本:4.0.30319.42000
+//
+// 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼,
+// 變更將會遺失。
+//
+//------------------------------------------------------------------------------
+
+namespace Lib.Controls.Properties {
+ using System;
+
+
+ ///
+ /// 用於查詢當地語系化字串等的強類型資源類別。
+ ///
+ // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder
+ // 類別透過 ResGen 或 Visual Studio 這類工具。
+ // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen
+ // (利用 /str 選項),或重建您的 VS 專案。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// 傳回這個類別使用的快取的 ResourceManager 執行個體。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lib.Controls.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有
+ /// 使用這個強類型資源類別的資源查閱。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。
+ ///
+ internal static System.Drawing.Bitmap MA8 {
+ get {
+ object obj = ResourceManager.GetObject("MA8", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。
+ ///
+ internal static System.Drawing.Bitmap RIO200 {
+ get {
+ object obj = ResourceManager.GetObject("RIO200", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。
+ ///
+ internal static System.Drawing.Bitmap RPM200 {
+ get {
+ object obj = ResourceManager.GetObject("RPM200", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。
+ ///
+ internal static System.Drawing.Bitmap RVC1000 {
+ get {
+ object obj = ResourceManager.GetObject("RVC1000", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/LibControl/Controls/Properties/Resources.resx b/LibControl/Controls/Properties/Resources.resx
new file mode 100644
index 0000000..2d88531
--- /dev/null
+++ b/LibControl/Controls/Properties/Resources.resx
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Resources\MA8.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\RIO200.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\RPM200.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\RVC1000.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Properties/Settings.Designer.cs b/LibControl/Controls/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..edf7d00
--- /dev/null
+++ b/LibControl/Controls/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18408
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Lib.Controls.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/LibControl/Controls/Properties/Settings.settings b/LibControl/Controls/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/LibControl/Controls/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Resources/AllBrushes.xaml b/LibControl/Controls/Resources/AllBrushes.xaml
new file mode 100644
index 0000000..0c11cd3
--- /dev/null
+++ b/LibControl/Controls/Resources/AllBrushes.xaml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Resources/MA8.PNG b/LibControl/Controls/Resources/MA8.PNG
new file mode 100644
index 0000000..5ac245d
Binary files /dev/null and b/LibControl/Controls/Resources/MA8.PNG differ
diff --git a/LibControl/Controls/Resources/RIO200.PNG b/LibControl/Controls/Resources/RIO200.PNG
new file mode 100644
index 0000000..426573d
Binary files /dev/null and b/LibControl/Controls/Resources/RIO200.PNG differ
diff --git a/LibControl/Controls/Resources/RPM200.PNG b/LibControl/Controls/Resources/RPM200.PNG
new file mode 100644
index 0000000..0e106bc
Binary files /dev/null and b/LibControl/Controls/Resources/RPM200.PNG differ
diff --git a/LibControl/Controls/Resources/RVC1000.PNG b/LibControl/Controls/Resources/RVC1000.PNG
new file mode 100644
index 0000000..42118c4
Binary files /dev/null and b/LibControl/Controls/Resources/RVC1000.PNG differ
diff --git a/LibControl/Controls/Resources/brush.scroll.down.xaml b/LibControl/Controls/Resources/brush.scroll.down.xaml
new file mode 100644
index 0000000..4c0312b
--- /dev/null
+++ b/LibControl/Controls/Resources/brush.scroll.down.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Resources/brush.scroll.up.xaml b/LibControl/Controls/Resources/brush.scroll.up.xaml
new file mode 100644
index 0000000..ecd3e66
--- /dev/null
+++ b/LibControl/Controls/Resources/brush.scroll.up.xaml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Resources/fader_hr.png b/LibControl/Controls/Resources/fader_hr.png
new file mode 100644
index 0000000..7265b17
Binary files /dev/null and b/LibControl/Controls/Resources/fader_hr.png differ
diff --git a/LibControl/Controls/Resources/h_sliderTrack.png b/LibControl/Controls/Resources/h_sliderTrack.png
new file mode 100644
index 0000000..b57c2c3
Binary files /dev/null and b/LibControl/Controls/Resources/h_sliderTrack.png differ
diff --git a/LibControl/Controls/Resources/hbs_sliderPanel.png b/LibControl/Controls/Resources/hbs_sliderPanel.png
new file mode 100644
index 0000000..d0c5710
Binary files /dev/null and b/LibControl/Controls/Resources/hbs_sliderPanel.png differ
diff --git a/LibControl/Controls/Resources/rightDown_img.png b/LibControl/Controls/Resources/rightDown_img.png
new file mode 100644
index 0000000..8aab1d9
Binary files /dev/null and b/LibControl/Controls/Resources/rightDown_img.png differ
diff --git a/LibControl/Controls/Resources/thumb.png b/LibControl/Controls/Resources/thumb.png
new file mode 100644
index 0000000..7e7c91c
Binary files /dev/null and b/LibControl/Controls/Resources/thumb.png differ
diff --git a/LibControl/Controls/SearchLed.xaml b/LibControl/Controls/SearchLed.xaml
new file mode 100644
index 0000000..c50aead
--- /dev/null
+++ b/LibControl/Controls/SearchLed.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/SearchLed.xaml.cs b/LibControl/Controls/SearchLed.xaml.cs
new file mode 100644
index 0000000..0d1a4f1
--- /dev/null
+++ b/LibControl/Controls/SearchLed.xaml.cs
@@ -0,0 +1,163 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for SearchLed.xaml
+ ///
+ ///
+
+ public partial class SearchLed : UserControl
+ {
+ public SearchLed()
+ {
+ InitializeComponent();
+ strLedTitle = srchLb.Text.Trim();
+ initialTimer();
+ }
+
+ private int dotNum = -1;
+
+ public void setLedDotNum(int num)
+ {
+ switch (num)
+ {
+ case 0:
+ dotLb.Text = ".";
+ break;
+ case 1:
+ dotLb.Text = "..";
+ break;
+ case 2:
+ dotLb.Text = "...";
+ break;
+ case 3:
+ dotLb.Text = "....";
+ break;
+ case 4:
+ dotLb.Text = ".....";
+ break;
+ case 5:
+ dotLb.Text = "......";
+ break;
+
+ }
+
+ }
+ public const int eSwitchInterval = 900;
+ private System.Timers.Timer loopTimer;
+
+ private void initialTimer()
+ {
+ loopTimer = new System.Timers.Timer(eSwitchInterval);
+ loopTimer.AutoReset = true;
+ loopTimer.Enabled = true;
+ loopTimer.Elapsed += new System.Timers.ElapsedEventHandler(loopTimer_ElapsedHandle);
+ // loopTimer.Start();
+ stopSearch();
+ }
+ public void setTextColor(Brush texB)
+ {
+ srchLb.Foreground = texB;
+ dotLb.Foreground = texB;
+ }
+
+
+ public void stopSearch()
+ {
+ dotLb.Text = "";
+ srchLb.Text = "";
+ dotNum = -1;
+ loopTimer.Stop();
+ this.Height = 0.01;
+ scanNum = 0;
+ }
+
+ public void startSearch()
+ {
+ this.Height = 50;
+ dotLb.Text = "";
+ loopTimer.Start();
+ dotNum = -1;
+ srchLb.Text = strLedTitle;
+ scanNum = 0;
+ }
+
+
+
+ private const int defaultDotMax = 6;
+
+ private const int DefaultMaxScanNum = 12;
+ private int scanNum = 0;
+
+
+
+
+
+ public int maxDelaySecTimes
+ {
+ get { return (int)GetValue(maxDelaySecTimesProperty); }
+ set { SetValue(maxDelaySecTimesProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for maxDelaySecTimes. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty maxDelaySecTimesProperty =
+ DependencyProperty.Register("maxDelaySecTimes", typeof(int), typeof(SearchLed), new PropertyMetadata(DefaultMaxScanNum));
+
+
+
+
+
+ private void loopTimer_ElapsedHandle(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ scanNum++;
+ dotNum++;
+ if (dotNum >= defaultDotMax)
+ dotNum = -1;
+
+ Task.Factory.StartNew(() =>
+ {
+ BeginInvokeLed(dotNum);
+ });
+
+ // Debug.WriteLine("dotNum is {0}", dotNum);
+ }
+
+ public string strLedTitle;
+ public void setLedTitle(string strT)
+ {
+ srchLb.Text = strT;
+ strLedTitle = strT;
+ }
+
+ public void BeginInvokeLed(int num) //async
+ {
+ Dispatcher.Invoke(() =>
+ {
+ setLedDotNum(num);
+ if (scanNum >= maxDelaySecTimes)
+ {
+ stopSearch();
+ }
+
+ }
+ );
+
+ }
+
+ }
+}
diff --git a/LibControl/Controls/SpinnerControl.cs b/LibControl/Controls/SpinnerControl.cs
new file mode 100644
index 0000000..a52b4ff
--- /dev/null
+++ b/LibControl/Controls/SpinnerControl.cs
@@ -0,0 +1,576 @@
+// Copyright 2012 lapthorn.net.
+//
+// This software is provided "as is" without a warranty of any kind. All
+// express or implied conditions, representations and warranties, including
+// any implied warranty of merchantability, fitness for a particular purpose
+// or non-infringement, are hereby excluded. lapthorn.net and its licensors
+// shall not be liable for any damages suffered by licensee as a result of
+// using the software. In no event will lapthorn.net be liable for any
+// lost revenue, profit or data, or for direct, indirect, special,
+// consequential, incidental or punitive damages, however caused and regardless
+// of the theory of liability, arising out of the use of or inability to use
+// software, even if lapthorn.net has been advised of the possibility of
+// such damages.
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Diagnostics;
+
+public enum EQFragType
+{
+ EQ_QV = 0, EQ_Gain = 1, EQ_Freq = 2,
+ Delay_Ms = 3, Delay_Meter = 4, Delay_Feet = 5,
+ OtherType=6,
+};
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for SpinnerControl.xaml
+ ///
+ public class SpinnerControl : UserControl
+ {
+
+ public delegate void spinValueClickChange(object sender, int cvalue, EQFragType etype, int itg, EventArgs e);
+ public event spinValueClickChange onSpinValueClickChangeEvent;
+
+ #region UpeqType property
+ private const EQFragType DefaultUpDownType = EQFragType.EQ_QV;
+ ///
+ /// This is the Control property that we expose to the user.
+ ///
+ // public EQFragType eqFragType = EQFragType.EQ_QV;
+ [Category("SpinnerControl")]
+ public EQFragType UpeqType
+ {
+
+ get { return (EQFragType)GetValue(UpdownTypeProperty); }
+ set
+ {
+ SetValue(UpdownTypeProperty, value);
+ updateMaxRange(0);
+ }
+
+ }
+ private static readonly DependencyProperty UpdownTypeProperty =
+ DependencyProperty.Register("UpeqType", typeof(EQFragType), typeof(SpinnerControl),
+ new PropertyMetadata(DefaultUpDownType));
+
+ public void updateMaxRange(int mv)
+ {
+
+ switch (UpeqType)
+ {
+ case EQFragType.EQ_QV:
+ Maximum = StrValueTables.strQFactorTable.Length-1;
+ // Debug.WriteLine("qfactor maxmum is : {0}", Maximum);
+ Value = mv;
+ UpdateFormattedValue(mv);
+ break;
+ case EQFragType.EQ_Gain:
+ Maximum = StrValueTables.strGainTable.Length - 1;
+ // Debug.WriteLine("eq Gain maxmum is : {0}", Maximum);
+ Value = mv;
+ UpdateFormattedValue(mv);
+ break;
+ case EQFragType.EQ_Freq:
+ Maximum = StrValueTables.strFreqTable.Length - 1;
+ // Debug.WriteLine("freq maxmum is : {0}", Maximum);
+ Value = mv;
+ UpdateFormattedValue(mv);
+ break;
+ case EQFragType.Delay_Ms://ms
+ case EQFragType.Delay_Meter://meter
+ case EQFragType.Delay_Feet: //feet
+ this.Maximum = StrValueTables.Delay_Const_Range; //170
+ UpdateFormattedValue(Value);
+ break;
+ case EQFragType.OtherType:
+ break;
+ }
+ }
+ #endregion
+
+
+ #region dependecy iTag
+ private const int DefaultiTag = 0;
+
+ public int iTag
+ {
+ get { return (int)GetValue(iTagProperty); }
+ set { SetValue(iTagProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTagProperty =
+ DependencyProperty.Register("iTag", typeof(int), typeof(SpinnerControl), new PropertyMetadata(DefaultiTag));
+
+ #endregion
+
+
+
+
+
+ private const bool DefaultLock = false;
+
+ public bool isLock
+ {
+ get { return (bool)GetValue(isLockProperty); }
+ set { SetValue(isLockProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for isLock. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty isLockProperty =
+ DependencyProperty.Register("isLock", typeof(bool), typeof(SpinnerControl), new PropertyMetadata(DefaultLock));
+
+
+
+ public SpinnerControl()
+ {
+ this.Loaded += control_Loaded;
+ //new FrameworkPropertyMetadata()
+ //new PropertyMetadata(DefaultiTag));
+
+ }
+
+ private void control_Loaded(object sender,RoutedEventArgs e)
+ {
+
+ // Debug.WriteLine("spin user oem control loaded .................................");
+ updateMaxRange(Value);
+
+ }
+
+ static SpinnerControl()
+ {
+ InitializeCommands();
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(SpinnerControl), new FrameworkPropertyMetadata(typeof(SpinnerControl)));
+
+ // Debug.WriteLine("here cxh in static constructor function ......");
+
+ }
+
+ #region FormattedValue property
+
+ ///
+ /// Dependency property identifier for the formatted value with limited
+ /// write access to the underlying read-only dependency property: we
+ /// can only use SetValue on this, not on the property itself.
+ ///
+ private static readonly DependencyPropertyKey FormattedValuePropertyKey =
+ DependencyProperty.RegisterAttachedReadOnly("FormattedValue", typeof(string), typeof(SpinnerControl),
+ new PropertyMetadata(DefaultValue.ToString()));
+
+ ///
+ /// The dependency property for the formatted value.
+ ///
+ private static readonly DependencyProperty FormattedValueProperty = FormattedValuePropertyKey.DependencyProperty;
+
+ ///
+ /// Returns the formatted version of the value, with the specified
+ /// number of DecimalPlaces.
+ ///
+ public string FormattedValue
+ {
+ get
+ {
+ return (string)GetValue(FormattedValueProperty);
+ }
+ }
+
+ ///
+ /// Update the formatted value.
+ ///
+ ///
+ protected void UpdateFormattedValue(int newValue)
+ {
+ // NumberFormatInfo numberFormatInfo = new NumberFormatInfo() { NumberDecimalDigits = DecimalPlaces };
+ // use fixed point, and the built-in NumberFormatInfo
+ // implementation of IFormatProvider
+
+
+ string formattedValue = "";
+ bool isInRange = false;
+
+ //if(UpeqType==EQFragType.EQ_Gain)
+ // Debug.WriteLine("a being in control do update formatted value now......{0} maximum {1} ",newValue,Maximum);
+
+
+ int val = Math.Max(Minimum, Math.Min(Maximum, newValue));
+
+ switch (UpeqType)
+ {
+ case EQFragType.EQ_QV:
+ {
+ formattedValue = StrValueTables.strQFactorTable[val];
+ isInRange = true;
+ // Debug.WriteLine("spincontrol do update value now......{0} itag:{1} --eqtype{2} ", val, iTag, UpeqType);
+ }
+ break;
+ case EQFragType.EQ_Gain:
+ {
+ formattedValue = StrValueTables.strGainTable[val];
+ isInRange = true;
+ }
+ break;
+ case EQFragType.EQ_Freq:
+ {
+ formattedValue = StrValueTables.strFreqTable[val];
+ isInRange = true;
+ }
+
+ break;
+ case EQFragType.Delay_Ms:
+ {
+ formattedValue = string.Format("{0}ms", val);
+ isInRange = true;
+ }
+
+ break;
+ case EQFragType.Delay_Meter:
+ {
+ // formattedValue = val*StrValueTables. save the decimal 1 points end
+ isInRange = true;
+ float tmp = StrValueTables.Delay_ConstI * 340 / 1000;
+ formattedValue = string.Format("{0}mt", Math.Round(tmp * val, 2));
+ }
+
+ break;
+ case EQFragType.Delay_Feet:
+ {
+ float tmp = StrValueTables.Delay_ConstI * 340 / 1000 * StrValueTables.Delay_ConstII;
+ formattedValue = string.Format("{0}ft", Math.Round(tmp*val, 2));
+ isInRange = true;
+ }
+
+ break;
+ case EQFragType.OtherType:
+ //set the text outside to the textblock
+ break;
+
+ }
+
+ // var formattedValue = newValue.ToString("f", numberFormatInfo);
+
+ // Set the value of the FormattedValue property via its property key
+ if (isInRange)
+ SetValue(FormattedValuePropertyKey, formattedValue);
+
+ // Debug.WriteLine("value is : {0} ", Value);
+ }
+ #endregion
+
+ public void setTxt(string str)
+ {
+ SetValue(FormattedValuePropertyKey, str);
+ }
+
+
+ private const string DefaultValueTxt = "";
+ public string valueTxt
+ {
+ get { return (string)GetValue(valueTxtProperty); }
+ set { SetValue(valueTxtProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for valueTxt. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty valueTxtProperty =
+ DependencyProperty.Register("valueTxt", typeof(string), typeof(SpinnerControl),
+ new FrameworkPropertyMetadata(DefaultValueTxt,
+ FrameworkPropertyMetadataOptions.None, OnValueTxtChanged));
+
+ private static void OnValueTxtChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ var spinc = obj as SpinnerControl;
+ if (spinc != null)
+ {
+ var newValue = (string)args.NewValue;
+ // btn.setTxt(newValue);
+ spinc.setTxt(newValue);
+
+ }
+ }
+
+
+ #region Value property
+ ///
+ /// This is the Control property that we expose to the user.
+ ///
+ [Category("SpinnerControl")]
+ public int Value
+ {
+ get { return (int)GetValue(ValueProperty); }
+ set { SetValue(ValueProperty, value); }
+ }
+
+ private static readonly DependencyProperty ValueProperty =
+ DependencyProperty.Register("Value", typeof(int), typeof(SpinnerControl),
+ new FrameworkPropertyMetadata(DefaultValue,
+ FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
+ OnValueChanged,
+ CoerceValue
+ ));
+
+ ///
+ /// If the value changes, update the text box that displays the Value
+ /// property to the consumer.
+ ///
+ ///
+ ///
+ private static void OnValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ SpinnerControl control = obj as SpinnerControl;
+ if (control != null)
+ {
+ var newValue = (int)args.NewValue;
+ var oldValue = (int)args.OldValue;
+
+ control.UpdateFormattedValue(newValue);
+
+
+
+ // Debug.WriteLine("updated new value is :{0} ", newValue);
+
+
+ RoutedPropertyChangedEventArgs e =
+ new RoutedPropertyChangedEventArgs(oldValue, newValue, ValueChangedEvent);
+
+ control.OnValueChanged(e);
+ }
+ }
+
+ ///
+ /// Raise the ValueChanged event. Derived classes can use this.
+ ///
+ ///
+ virtual protected void OnValueChanged(RoutedPropertyChangedEventArgs e)
+ {
+ RaiseEvent(e);
+ }
+
+ private static int LimitValueByBounds(int newValue, SpinnerControl control)
+ {
+ newValue = Math.Max(control.Minimum, Math.Min(control.Maximum, newValue)); //very good
+ // then ensure the number of decimal places is correct.
+
+ // Debug.WriteLine("before newvalue is : {0}", newValue);
+ // newValue = Decimal.Round(newValue, control.DecimalPlaces);
+
+ // Debug.WriteLine("after newvalue is : {0}", newValue);
+ return newValue;
+ }
+
+ private static object CoerceValue(DependencyObject obj, object value)
+ {
+ int newValue = (int)value;
+ SpinnerControl control = obj as SpinnerControl;
+
+ if (control != null)
+ {
+ // ensure that the value stays within the bounds of the minimum and
+ // maximum values that we define.
+ newValue = LimitValueByBounds(newValue, control);
+ }
+
+ return newValue;
+ }
+
+
+ #endregion
+
+
+ #region MinimumValue property
+ ///
+ /// This is the Control property that we expose to the user.
+ ///
+ [Category("SpinnerControl")]
+ public int Minimum
+ {
+ get { return (int)GetValue(MinimumValueProperty); }
+ set { SetValue(MinimumValueProperty, value); }
+ }
+
+ private static readonly DependencyProperty MinimumValueProperty =
+ DependencyProperty.Register("Minimum", typeof(int), typeof(SpinnerControl),
+ new PropertyMetadata(DefaultMinimumValue));
+ #endregion
+
+
+ #region MaximumValue property
+ ///
+ /// This is the Control property that we expose to the user.
+ ///
+ [Category("SpinnerControl")]
+ public int Maximum
+ {
+ get { return (int)GetValue(MaximumValueProperty); }
+ set { SetValue(MaximumValueProperty, value); }
+ }
+
+ private static readonly DependencyProperty MaximumValueProperty =
+ DependencyProperty.Register("Maximum", typeof(int), typeof(SpinnerControl),
+ new PropertyMetadata(DefaultMaximumValue));
+
+ #endregion
+
+
+
+ #region DecimalPlaces property
+ ///
+ /// This is the Control property that we expose to the user.
+ ///
+ [Category("SpinnerControl")]
+ public int DecimalPlaces
+ {
+ get { return (int)GetValue(DecimalPlacesProperty); }
+ set { SetValue(DecimalPlacesProperty, value); }
+ }
+
+ private static readonly DependencyProperty DecimalPlacesProperty =
+ DependencyProperty.Register("DecimalPlaces", typeof(int), typeof(SpinnerControl),
+ new PropertyMetadata(DefaultDecimalPlaces));
+
+ #endregion
+
+
+ #region Change property
+ ///
+ /// This is the Control property that we expose to the user.
+ ///
+ [Category("SpinnerControl")]
+ public int Change
+ {
+ get { return (int)GetValue(ChangeProperty); }
+ set { SetValue(ChangeProperty, value); }
+ }
+
+ private static readonly DependencyProperty ChangeProperty =
+ DependencyProperty.Register("Change", typeof(int), typeof(SpinnerControl),
+ new PropertyMetadata(DefaultChange));
+
+ #endregion
+
+
+ #region Default values
+
+ ///
+ /// Define the min, max and starting value, which we then expose
+ /// as dependency properties.
+ ///
+ private const int DefaultMinimumValue = 0,
+ DefaultMaximumValue = 100,
+ DefaultValue = DefaultMinimumValue,
+ DefaultChange = 1;
+
+ ///
+ /// The default number of decimal places, i.e. 0, and show the
+ /// spinner control as an int initially.
+ ///
+ private const int DefaultDecimalPlaces = 0;
+ #endregion
+
+
+ #region Command Stuff
+ public static RoutedCommand IncreaseCommand { get; set; }
+
+ protected static void OnIncreaseCommand(Object sender, ExecutedRoutedEventArgs e)
+ {
+ SpinnerControl control = sender as SpinnerControl;
+
+ if (control != null)
+ {
+ control.OnIncrease();
+ }
+ }
+
+ protected void OnIncrease()
+ {
+ // see https://connect.microsoft.com/VisualStudio/feedback/details/489775/
+ // for why we do this.
+ Value = LimitValueByBounds(Value + Change, this);
+
+ int val = (int)Math.Max(Minimum, Value);
+ if (onSpinValueClickChangeEvent != null)
+ {
+ onSpinValueClickChangeEvent(this,val, UpeqType, iTag, new EventArgs()); //iTag
+ // Debug.WriteLine("onInCrease ....................");
+
+ }
+
+
+ }
+
+ public static RoutedCommand DecreaseCommand { get; set; }
+
+ protected static void OnDecreaseCommand(Object sender, ExecutedRoutedEventArgs e)
+ {
+ SpinnerControl control = sender as SpinnerControl;
+
+ if (control != null)
+ {
+ control.OnDecrease();
+ }
+ }
+
+ protected void OnDecrease()
+ {
+ // see https://connect.microsoft.com/VisualStudio/feedback/details/489775/
+ // for why we do this.
+ Value = LimitValueByBounds(Value - Change, this);
+ int val = (int)Math.Max(Minimum, Value);
+ if (onSpinValueClickChangeEvent != null)
+ {
+ onSpinValueClickChangeEvent(this,val, UpeqType, iTag, new EventArgs()); //iTag
+ // Debug.WriteLine("onInCrease ....................");
+
+ }
+ }
+
+ ///
+ /// Since we're using RoutedCommands for the up/down buttons, we need to
+ /// register them with the command manager so we can tie the events
+ /// to callbacks in the control.
+ ///
+ private static void InitializeCommands()
+ {
+ // create instances
+ IncreaseCommand = new RoutedCommand("IncreaseCommand", typeof(SpinnerControl));
+ DecreaseCommand = new RoutedCommand("DecreaseCommand", typeof(SpinnerControl));
+
+ // register the command bindings - if the buttons get clicked, call these methods.
+ CommandManager.RegisterClassCommandBinding(typeof(SpinnerControl), new CommandBinding(IncreaseCommand, OnIncreaseCommand));
+ CommandManager.RegisterClassCommandBinding(typeof(SpinnerControl), new CommandBinding(DecreaseCommand, OnDecreaseCommand));
+
+ // lastly bind some inputs: i.e. if the user presses up/down arrow
+ // keys, call the appropriate commands.
+ CommandManager.RegisterClassInputBinding(typeof(SpinnerControl), new InputBinding(IncreaseCommand, new KeyGesture(Key.Up)));
+ CommandManager.RegisterClassInputBinding(typeof(SpinnerControl), new InputBinding(IncreaseCommand, new KeyGesture(Key.Right)));
+ CommandManager.RegisterClassInputBinding(typeof(SpinnerControl), new InputBinding(DecreaseCommand, new KeyGesture(Key.Down)));
+ CommandManager.RegisterClassInputBinding(typeof(SpinnerControl), new InputBinding(DecreaseCommand, new KeyGesture(Key.Left)));
+ }
+ #endregion
+
+
+ #region Events
+
+ ///
+ /// The ValueChangedEvent, raised if the value changes.
+ ///
+ private static readonly RoutedEvent ValueChangedEvent =
+ EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
+ typeof(RoutedPropertyChangedEventHandler), typeof(SpinnerControl));
+
+ ///
+ /// Occurs when the Value property changes.
+ ///
+ public event RoutedPropertyChangedEventHandler ValueChanged
+ {
+ add { AddHandler(ValueChangedEvent, value); }
+ remove { RemoveHandler(ValueChangedEvent, value); }
+ }
+ #endregion
+ }
+}
diff --git a/LibControl/Controls/SprocketControl.cs b/LibControl/Controls/SprocketControl.cs
new file mode 100644
index 0000000..3c271c2
--- /dev/null
+++ b/LibControl/Controls/SprocketControl.cs
@@ -0,0 +1,803 @@
+// -------------------------------------------------------------------------------
+//
+// This file is part of the WPFSpark project: http://wpfspark.codeplex.com/
+//
+// Author: Ratish Philip
+//
+// WPFSpark v1.0
+//
+// -------------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Timers;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace Lib.Controls
+{
+ ///
+ /// Interaction logic for SprocketControl.xaml
+ ///
+ public class SprocketControl : Control
+ {
+ #region Constants
+
+ private const double DEFAULT_INTERVAL = 60;
+ private static readonly Color DEFAULT_TICK_COLOR = Color.FromArgb((byte)255, (byte)58, (byte)58, (byte)58);
+ private const double DEFAULT_TICK_WIDTH = 3;
+ private const int DEFAULT_TICK_COUNT = 12;
+ private const double MINIMUM_INNER_RADIUS = 5;
+ private const double MINIMUM_OUTER_RADIUS = 8;
+ private readonly Size MINIMUM_CONTROL_SIZE = new Size(28, 28);
+ private const double MINIMUM_PEN_WIDTH = 2;
+ private const double DEFAULT_START_ANGLE = 270;
+ private const double INNER_RADIUS_FACTOR = 0.175;
+ private const double OUTER_RADIUS_FACTOR = 0.3125;
+ // The Lower limit of the Alpha value (The spokes will be shown in
+ // alpha values ranging from 255 to m_AlphaLowerLimit)
+ private const double ALPHA_LOWER_LIMIT = 5;
+ private const double DEFAULT_PROGRESS_ALPHA = 10;
+ private const double DEFAULT_PROGRESS = 0.0;
+ #endregion
+
+ #region Enums
+
+ ///
+ /// Defines the Direction of Rotation
+ ///
+ public enum Direction
+ {
+ CLOCKWISE,
+ ANTICLOCKWISE
+ }
+
+ #endregion
+
+ #region Structs
+
+ ///
+ /// Stores the details of each spoke
+ ///
+ struct Spoke
+ {
+ public Point StartPoint;
+ public Point EndPoint;
+
+ public Spoke(Point pt1, Point pt2)
+ {
+ StartPoint = pt1;
+ EndPoint = pt2;
+ }
+ }
+
+ #endregion
+
+ #region Fields
+
+ Point centerPoint = new Point();
+ double innerRadius = 0;
+ double outerRadius = 0;
+ double alphaChange = 0;
+ double angleIncrement = 0;
+ double renderStartAngle = 0;
+ System.Timers.Timer renderTimer = null;
+ List spokes = null;
+
+ #endregion
+
+ #region Dependency Properties
+
+ #region Interval
+
+ ///
+ /// Interval Dependency Property
+ ///
+ public static readonly DependencyProperty IntervalProperty =
+ DependencyProperty.Register("Interval", typeof(double), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(DEFAULT_INTERVAL,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnIntervalChanged)));
+
+ ///
+ /// Gets or sets the Interval property. This dependency property
+ /// indicates duration at which the timer for rotation should fire.
+ ///
+ public double Interval
+ {
+ get { return (double)GetValue(IntervalProperty); }
+ set { SetValue(IntervalProperty, value); }
+ }
+
+ ///
+ /// Handles changes to the Interval property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnIntervalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ double oldInterval = (double)e.OldValue;
+ double newInterval = sprocket.Interval;
+ sprocket.OnIntervalChanged(oldInterval, newInterval);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the Interval property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnIntervalChanged(double oldInterval, double newInterval)
+ {
+ if (renderTimer != null)
+ {
+ bool isEnabled = renderTimer.Enabled;
+ renderTimer.Enabled = false;
+ renderTimer.Interval = newInterval;
+ renderTimer.Enabled = isEnabled;
+ }
+ }
+
+ #endregion
+
+ #region TickColor
+
+ ///
+ /// TickColor Dependency Property
+ ///
+ public static readonly DependencyProperty TickColorProperty =
+ DependencyProperty.Register("TickColor", typeof(Color), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(DEFAULT_TICK_COLOR,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnTickColorChanged)));
+
+ ///
+ /// Gets or sets the TickColor property. This dependency property
+ /// indicates the color of the Spokes in the SprocketControl.
+ ///
+ public Color TickColor
+ {
+ get { return (Color)GetValue(TickColorProperty); }
+ set { SetValue(TickColorProperty, value); }
+ }
+
+ ///
+ /// Handles changes to the TickColor property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnTickColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ Color oldTickColor = (Color)e.OldValue;
+ Color newTickColor = sprocket.TickColor;
+ sprocket.OnTickColorChanged(oldTickColor, newTickColor);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the TickColor property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnTickColorChanged(Color oldTickColor, Color newTickColor)
+ {
+ InvalidateVisual();
+ }
+
+ #endregion
+
+ #region Rotation
+
+ ///
+ /// Rotation Dependency Property
+ ///
+ public static readonly DependencyProperty RotationProperty =
+ DependencyProperty.Register("Rotation", typeof(Direction), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(Direction.CLOCKWISE,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnRotationChanged)));
+
+ ///
+ /// Gets or sets the Rotation property. This dependency property
+ /// indicates the direction of Rotation of the SprocketControl.
+ ///
+ public Direction Rotation
+ {
+ get { return (Direction)GetValue(RotationProperty); }
+ set { SetValue(RotationProperty, value); }
+ }
+
+ ///
+ /// Handles changes to the Rotation property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnRotationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ Direction oldRotation = (Direction)e.OldValue;
+ Direction newRotation = sprocket.Rotation;
+ sprocket.OnRotationChanged(oldRotation, newRotation);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the Rotation property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnRotationChanged(Direction oldRotation, Direction newRotation)
+ {
+ // Recalculate the spoke points
+ CalculateSpokesPoints();
+ }
+
+ #endregion
+
+ #region StartAngle
+
+ ///
+ /// StartAngle Dependency Property
+ ///
+ public static readonly DependencyProperty StartAngleProperty =
+ DependencyProperty.Register("StartAngle", typeof(double), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(DEFAULT_START_ANGLE,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnStartAngleChanged)));
+
+ ///
+ /// Gets or sets the StartAngle property. This dependency property
+ /// indicates the angle at which the first spoke (with max opacity) is drawn.
+ ///
+ public double StartAngle
+ {
+ get { return (double)GetValue(StartAngleProperty); }
+ set { SetValue(StartAngleProperty, value); }
+ }
+
+ ///
+ /// Handles changes to the StartAngle property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnStartAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ double oldStartAngle = (double)e.OldValue;
+ double newStartAngle = sprocket.StartAngle;
+ sprocket.OnStartAngleChanged(oldStartAngle, newStartAngle);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the StartAngle property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnStartAngleChanged(double oldStartAngle, double newStartAngle)
+ {
+ // Recalculate the spoke points
+ CalculateSpokesPoints();
+ }
+
+ #endregion
+
+ #region TickCount
+
+ ///
+ /// TickCount Dependency Property
+ ///
+ public static readonly DependencyProperty TickCountProperty =
+ DependencyProperty.Register("TickCount", typeof(int), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(DEFAULT_TICK_COUNT,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnTickCountChanged),
+ new CoerceValueCallback(CoerceTickCount)));
+
+ ///
+ /// Gets or sets the TickCount property. This dependency property
+ /// indicates the number of spokes of the SprocketControl.
+ ///
+ public int TickCount
+ {
+ get { return (int)GetValue(TickCountProperty); }
+ set { SetValue(TickCountProperty, value); }
+ }
+
+ ///
+ /// Coerces the TickCount value to an acceptable value
+ ///
+ /// SprocketControl
+ /// New Value
+ /// Coerced Value
+ private static object CoerceTickCount(DependencyObject d, object value)
+ {
+ int count = (int)value;
+
+ if (count <= 0)
+ {
+ return DEFAULT_TICK_COUNT;
+ }
+
+ return value;
+ }
+
+ ///
+ /// Handles changes to the TickCount property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnTickCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ int oldTickCount = (int)e.OldValue;
+ int newTickCount = sprocket.TickCount;
+ sprocket.OnTickCountChanged(oldTickCount, newTickCount);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the TickCount property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnTickCountChanged(int oldTickCount, int newTickCount)
+ {
+ // Recalculate the spoke points
+ CalculateSpokesPoints();
+ }
+
+ #endregion
+
+ #region TickStyle
+
+ ///
+ /// TickStyle Dependency Property
+ ///
+ public static readonly DependencyProperty TickStyleProperty =
+ DependencyProperty.Register("TickStyle", typeof(PenLineCap), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(PenLineCap.Round, FrameworkPropertyMetadataOptions.AffectsRender, (new PropertyChangedCallback(OnTickStyleChanged))));
+
+ ///
+ /// Gets or sets the TickStyle property. This dependency property
+ /// indicates the style of the ends of each tick.
+ ///
+ public PenLineCap TickStyle
+ {
+ get { return (PenLineCap)GetValue(TickStyleProperty); }
+ set { SetValue(TickStyleProperty, value); }
+ }
+
+ ///
+ /// Handles changes to the TickStyle property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnTickStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ PenLineCap oldTickStyle = (PenLineCap)e.OldValue;
+ PenLineCap newTickStyle = sprocket.TickStyle;
+ sprocket.OnTickStyleChanged(oldTickStyle, newTickStyle);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the TickStyle property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnTickStyleChanged(PenLineCap oldTickStyle, PenLineCap newTickStyle)
+ {
+ InvalidateVisual();
+ }
+
+ #endregion
+
+ #region IsIndeterminate
+
+ ///
+ /// IsIndeterminate Dependency Property
+ ///
+ public static readonly DependencyProperty IsIndeterminateProperty =
+ DependencyProperty.Register("IsIndeterminate", typeof(bool), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(true,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ (new PropertyChangedCallback(OnIsIndeterminateChanged))));
+
+ ///
+ /// Gets or sets the IsIndeterminate property. This dependency property
+ /// indicates whether the SprocketControl's progress is indeterminate or not.
+ ///
+ public bool IsIndeterminate
+ {
+ get { return (bool)GetValue(IsIndeterminateProperty); }
+ set { SetValue(IsIndeterminateProperty, value); }
+ }
+
+ ///
+ /// Handles changes to the IsIndeterminate property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnIsIndeterminateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl target = (SprocketControl)d;
+ bool oldIsIndeterminate = (bool)e.OldValue;
+ bool newIsIndeterminate = target.IsIndeterminate;
+ target.OnIsIndeterminateChanged(oldIsIndeterminate, newIsIndeterminate);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the IsIndeterminate property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnIsIndeterminateChanged(bool oldIsIndeterminate, bool newIsIndeterminate)
+ {
+ if (oldIsIndeterminate != newIsIndeterminate)
+ {
+ if (newIsIndeterminate)
+ {
+ // Start the renderTimer
+ Start();
+ }
+ else
+ {
+ // Stop the renderTimer
+ Stop();
+ InvalidateVisual();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Progress
+
+ ///
+ /// Progress Dependency Property
+ ///
+ public static readonly DependencyProperty ProgressProperty =
+ DependencyProperty.Register("Progress", typeof(double), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(DEFAULT_PROGRESS,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnProgressChanged),
+ new CoerceValueCallback(CoerceProgress)));
+
+ ///
+ /// Gets or sets the Progress property. This dependency property
+ /// indicates the progress percentage.
+ ///
+ public double Progress
+ {
+ get { return (double)GetValue(ProgressProperty); }
+ set { SetValue(ProgressProperty, value); }
+ }
+
+ ///
+ /// Coerces the Progress value so that it stays in the range 0-100
+ ///
+ /// SprocketControl
+ /// New Value
+ /// Coerced Value
+ private static object CoerceProgress(DependencyObject d, object value)
+ {
+ double progress = (double)value;
+
+ if (progress < 0.0)
+ {
+ return 0.0;
+ }
+ else if (progress > 100.0)
+ {
+ return 100.0;
+ }
+
+ return value;
+ }
+
+ ///
+ /// Handles changes to the Progress property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnProgressChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl sprocket = (SprocketControl)d;
+ double oldProgress = (double)e.OldValue;
+ double newProgress = sprocket.Progress;
+ sprocket.OnProgressChanged(oldProgress, newProgress);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the Progress property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnProgressChanged(double oldProgress, double newProgress)
+ {
+ InvalidateVisual();
+ }
+
+ #endregion
+
+ #region TickWidth
+
+ ///
+ /// TickWidth Dependency Property
+ ///
+ public static readonly DependencyProperty TickWidthProperty =
+ DependencyProperty.Register("TickWidth", typeof(double), typeof(SprocketControl),
+ new FrameworkPropertyMetadata(DEFAULT_TICK_WIDTH,
+ FrameworkPropertyMetadataOptions.AffectsRender,
+ new PropertyChangedCallback(OnTickWidthChanged),
+ new CoerceValueCallback(CoerceTickWidth)));
+
+ ///
+ /// Gets or sets the TickWidth property. This dependency property
+ /// indicates the width of each spoke in the SprocketControl.
+ ///
+ public double TickWidth
+ {
+ get { return (double)GetValue(TickWidthProperty); }
+ set { SetValue(TickWidthProperty, value); }
+ }
+
+ ///
+ /// Coerces the TickWidth value so that it stays above 0.
+ ///
+ /// SprocketControl
+ /// New Value
+ /// Coerced Value
+ private static object CoerceTickWidth(DependencyObject d, object value)
+ {
+ double progress = (double)value;
+
+ if (progress < 0.0)
+ {
+ return DEFAULT_TICK_WIDTH;
+ }
+
+ return value;
+ }
+ ///
+ /// Handles changes to the TickWidth property.
+ ///
+ /// SprocketControl
+ /// DependencyProperty changed event arguments
+ private static void OnTickWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ SprocketControl target = (SprocketControl)d;
+ double oldTickWidth = (double)e.OldValue;
+ double newTickWidth = target.TickWidth;
+ target.OnTickWidthChanged(oldTickWidth, newTickWidth);
+ }
+
+ ///
+ /// Provides derived classes an opportunity to handle changes to the TickWidth property.
+ ///
+ /// Old Value
+ /// New Value
+ protected virtual void OnTickWidthChanged(double oldTickWidth, double newTickWidth)
+ {
+ InvalidateVisual();
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Construction
+
+ ///
+ /// Ctor
+ ///
+ public SprocketControl()
+ {
+ //InitializeComponent();
+
+ renderTimer = new System.Timers.Timer(this.Interval);
+ renderTimer.Elapsed += new ElapsedEventHandler(OnRenderTimerElapsed);
+
+ // Set the minimum size of the SprocketControl
+ this.MinWidth = MINIMUM_CONTROL_SIZE.Width;
+ this.MinWidth = MINIMUM_CONTROL_SIZE.Height;
+
+ // Calculate the spoke points based on the current size
+ CalculateSpokesPoints();
+
+ this.Loaded += (s, e) =>
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (IsIndeterminate)
+ Start();
+ }));
+ };
+ }
+
+ #endregion
+
+ #region Helpers
+
+ ///
+ /// Start the Tick Control rotation
+ ///
+ private void Start()
+ {
+ if ((renderTimer != null) && (!renderTimer.Enabled))
+ {
+ renderTimer.Interval = this.Interval;
+ renderTimer.Enabled = true;
+ }
+ }
+
+ ///
+ /// Stop the Tick Control rotation
+ ///
+ private void Stop()
+ {
+ if (renderTimer != null)
+ {
+ renderTimer.Enabled = false;
+ }
+ }
+
+ ///
+ /// Converts Degrees to Radians
+ ///
+ /// Degrees
+ /// Radians
+ private double ConvertDegreesToRadians(double degrees)
+ {
+ return ((Math.PI / (double)180) * degrees);
+ }
+
+ ///
+ /// Calculate the Spoke Points and store them
+ ///
+ private void CalculateSpokesPoints()
+ {
+ spokes = new List();
+
+ // Calculate the angle between adjacent spokes
+ angleIncrement = (360 / (double)TickCount);
+ // Calculate the change in alpha between adjacent spokes
+ alphaChange = (int)((255 - ALPHA_LOWER_LIMIT) / (double)TickCount);
+
+ // Set the start angle for rendering
+ renderStartAngle = StartAngle;
+
+ // Calculate the location around which the spokes will be drawn
+ double width = (this.Width < this.Height) ? this.Width : this.Height;
+ centerPoint = new Point(this.Width / 2, this.Height / 2);
+ // Calculate the inner and outer radii of the control. The radii should not be less than the
+ // Minimum values
+ innerRadius = (int)(width * INNER_RADIUS_FACTOR);
+ if (innerRadius < MINIMUM_INNER_RADIUS)
+ innerRadius = MINIMUM_INNER_RADIUS;
+ outerRadius = (int)(width * OUTER_RADIUS_FACTOR);
+ if (outerRadius < MINIMUM_OUTER_RADIUS)
+ outerRadius = MINIMUM_OUTER_RADIUS;
+
+ double angle = 0;
+
+ for (int i = 0; i < TickCount; i++)
+ {
+ Point pt1 = new Point(innerRadius * (float)Math.Cos(ConvertDegreesToRadians(angle)), innerRadius * (float)Math.Sin(ConvertDegreesToRadians(angle)));
+ Point pt2 = new Point(outerRadius * (float)Math.Cos(ConvertDegreesToRadians(angle)), outerRadius * (float)Math.Sin(ConvertDegreesToRadians(angle)));
+
+ // Create a spoke based on the points generated
+ Spoke spoke = new Spoke(pt1, pt2);
+ // Add the spoke to the List
+ spokes.Add(spoke);
+
+ // If it is not it Indeterminate state,
+ // ensure that the spokes are drawn in clockwise manner
+ if (!IsIndeterminate)
+ {
+ angle += angleIncrement;
+ }
+ else
+ {
+ if (Rotation == Direction.CLOCKWISE)
+ {
+ angle -= angleIncrement;
+ }
+ else if (Rotation == Direction.ANTICLOCKWISE)
+ {
+ angle += angleIncrement;
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region Overrides
+
+ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
+ {
+ base.OnRenderSizeChanged(sizeInfo);
+
+ // Calculate the spoke points based on the new size
+ CalculateSpokesPoints();
+ }
+
+ protected override void OnRender(DrawingContext dc)
+ {
+ if (spokes == null)
+ return;
+
+ TranslateTransform translate = new TranslateTransform(centerPoint.X, centerPoint.Y);
+ dc.PushTransform(translate);
+ RotateTransform rotate = new RotateTransform(renderStartAngle);
+ dc.PushTransform(rotate);
+
+ byte alpha = (byte)255;
+
+ // Get the number of spokes that can be drawn with zero transparency
+ int progressSpokes = (int)Math.Floor((Progress * TickCount) / 100.0);
+
+ // Render the spokes
+ for (int i = 0; i < TickCount; i++)
+ {
+ if (!IsIndeterminate)
+ {
+ if (progressSpokes > 0)
+ alpha = (byte)(i <= progressSpokes ? 255 : DEFAULT_PROGRESS_ALPHA);
+ else
+ alpha = (byte)DEFAULT_PROGRESS_ALPHA;
+ }
+
+ Pen p = new Pen(new SolidColorBrush(Color.FromArgb(alpha, this.TickColor.R, this.TickColor.G, this.TickColor.B)), TickWidth);
+ p.StartLineCap = p.EndLineCap = TickStyle;
+ dc.DrawLine(p, spokes[i].StartPoint, spokes[i].EndPoint);
+
+ if (IsIndeterminate)
+ {
+ alpha -= (byte)alphaChange;
+ if (alpha < ALPHA_LOWER_LIMIT)
+ alpha = (byte)ALPHA_LOWER_LIMIT;
+ }
+ }
+
+ // Perform a reverse Rotation and Translation to obtain the original Transformation
+ dc.Pop();
+ dc.Pop();
+ }
+
+ #endregion
+
+ #region Event Handlers
+
+ ///
+ /// Handles the Elapsed event of the renderTimer
+ ///
+ /// Sender
+ /// EventArgs
+ void OnRenderTimerElapsed(object sender, ElapsedEventArgs e)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (Rotation == Direction.CLOCKWISE)
+ {
+ renderStartAngle += angleIncrement;
+
+ if (renderStartAngle >= 360)
+ renderStartAngle -= 360;
+ }
+ else if (Rotation == Direction.ANTICLOCKWISE)
+ {
+ renderStartAngle -= angleIncrement;
+
+ if (renderStartAngle <= -360)
+ renderStartAngle += 360;
+ }
+
+ // Force re-rendering of control
+ InvalidateVisual();
+ }));
+ }
+
+ #endregion
+ }
+}
diff --git a/LibControl/Controls/TComboBox.cs b/LibControl/Controls/TComboBox.cs
new file mode 100644
index 0000000..a9b2782
--- /dev/null
+++ b/LibControl/Controls/TComboBox.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Lib.Controls
+{
+ ///
+ /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
+ ///
+ /// Step 1a) Using this custom control in a XAML file that exists in the current project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:ChangeX"
+ ///
+ ///
+ /// Step 1b) Using this custom control in a XAML file that exists in a different project.
+ /// Add this XmlNamespace attribute to the root element of the markup file where it is
+ /// to be used:
+ ///
+ /// xmlns:MyNamespace="clr-namespace:ChangeX;assembly=ChangeX"
+ ///
+ /// You will also need to add a project reference from the project where the XAML file lives
+ /// to this project and Rebuild to avoid compilation errors:
+ ///
+ /// Right click on the target project in the Solution Explorer and
+ /// "Add Reference"->"Projects"->[Browse to and select this project]
+ ///
+ ///
+ /// Step 2)
+ /// Go ahead and use your control in the XAML file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public class SelectionChangingEventArgs : RoutedEventArgs
+ {
+ public bool Cancel { get; set; }
+ }
+
+ public delegate void
+ SelectionChangingEventHandler(Object sender, SelectionChangingEventArgs e);
+
+
+ public class TComboBox : ComboBox
+ {
+ static TComboBox()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(TComboBox), new FrameworkPropertyMetadata(typeof(TComboBox)));
+ }
+
+ public int _index{get;set;}
+ public int _lastIndex { get; set; }
+ public bool _suppress { get; set; }
+
+
+
+ public bool MyProperty { get; set; }
+
+
+
+ public event SelectionChangingEventHandler SelectionChanging;
+ public new event SelectionChangedEventHandler SelectionChanged;
+
+
+
+ public int iTg
+ {
+ get { return (int)GetValue(iTgProperty); }
+ set { SetValue(iTgProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for iTg. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty iTgProperty =
+ DependencyProperty.Register("iTg", typeof(int), typeof(TComboBox), new PropertyMetadata(0));
+
+
+
+
+ public TComboBox()
+ {
+ _index = -1;
+ _lastIndex = 0;
+ _suppress = false;
+ base.SelectionChanged += InternalSelectionChanged;
+ }
+
+ public void setSelectindex(int index)
+ {
+ _suppress = true;
+ this.SelectedIndex = index;
+ _suppress = false;
+ }
+
+ private void InternalSelectionChanged(Object s, SelectionChangedEventArgs e)
+ {
+ var args = new SelectionChangingEventArgs();
+ OnSelectionChanging(args);
+ if (args.Cancel)
+ {
+ return;
+ }
+ OnSelectionChanged(e);
+ }
+
+ public new void OnSelectionChanged(SelectionChangedEventArgs e)
+ {
+ if (_suppress) return;
+
+ // The selection has changed, so _index must be updated
+ _index = SelectedIndex;
+ if (SelectionChanged != null)
+ {
+ SelectionChanged(this, e);
+ }
+ }
+
+ public void OnSelectionChanging(SelectionChangingEventArgs e)
+ {
+ if (_suppress) return;
+
+ // Recall the last SelectedIndex before raising SelectionChanging
+ _lastIndex = (_index >= 0) ? _index : SelectedIndex;
+ if (SelectionChanging == null) return;
+
+ // Invoke user event handler and revert to last
+ // selected index if user cancels the change
+ SelectionChanging(this, e);
+ if (e.Cancel)
+ {
+ _suppress = true;
+ SelectedIndex = _lastIndex;
+ _suppress = false;
+ }
+ }
+ }
+}
diff --git a/LibControl/Controls/Themes/BorderSwitcherStyle.xaml b/LibControl/Controls/Themes/BorderSwitcherStyle.xaml
new file mode 100644
index 0000000..5c89bb6
--- /dev/null
+++ b/LibControl/Controls/Themes/BorderSwitcherStyle.xaml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Themes/Generic.xaml b/LibControl/Controls/Themes/Generic.xaml
new file mode 100644
index 0000000..c52e0eb
--- /dev/null
+++ b/LibControl/Controls/Themes/Generic.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibControl/Controls/Themes/SpinnerControl.Generic.xaml b/LibControl/Controls/Themes/SpinnerControl.Generic.xaml
new file mode 100644
index 0000000..b98c46e
--- /dev/null
+++ b/LibControl/Controls/Themes/SpinnerControl.Generic.xaml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Themes/StandardButonStyle.Generic.xaml b/LibControl/Controls/Themes/StandardButonStyle.Generic.xaml
new file mode 100644
index 0000000..ed1b697
--- /dev/null
+++ b/LibControl/Controls/Themes/StandardButonStyle.Generic.xaml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Themes/StandardButonStyle.Generic_bk.xaml b/LibControl/Controls/Themes/StandardButonStyle.Generic_bk.xaml
new file mode 100644
index 0000000..021e674
--- /dev/null
+++ b/LibControl/Controls/Themes/StandardButonStyle.Generic_bk.xaml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/Themes/TCombBox.xaml b/LibControl/Controls/Themes/TCombBox.xaml
new file mode 100644
index 0000000..34fbc4a
--- /dev/null
+++ b/LibControl/Controls/Themes/TCombBox.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LibControl/Controls/TraverseChildrenControl.cs b/LibControl/Controls/TraverseChildrenControl.cs
new file mode 100644
index 0000000..0849bf5
--- /dev/null
+++ b/LibControl/Controls/TraverseChildrenControl.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+/************************************************************************************
+ * Copyright (c) 2016 All Rights Reserved.
+ * CLR版本: 4.0.30319.18408
+ *机器名称:PC120
+ *公司名称:
+ *命名空间:ALP50SA
+ *文件名: TraverseChildrenControl
+ *版本号: V1.0.0.0
+ *唯一标识:dbe81dc7-ee4f-475f-a49a-994e748ec831
+ *当前的用户域:SEIKAKU
+ *创建人: williamxia
+ *电子邮箱:XXXX@sina.cn
+ *创建时间:9/21/2016 8:50:40 PM
+ *描述:
+ *
+ *=====================================================================
+ *修改标记
+ *修改时间:9/21/2016 8:50:40 PM
+ *修改人: williamxia
+ *版本号: V1.0.0.0
+ *描述:
+ *
+/************************************************************************************/
+
+namespace Lib.Controls
+{
+
+ public class TraverseChildrenControls
+ {
+
+ private List