├── .gitattributes ├── .gitignore ├── GraphicAlgorithm ├── ArbitraryPolygonCut │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── ArbitraryPolygonCut.cs │ ├── ArbitraryPolygonCut.csproj │ ├── ArbitraryPolygonCutTest.cs │ ├── ArrowLine.cs │ ├── CrossLine.cs │ ├── CutFile │ │ ├── C包含S.cut │ │ ├── S包含C.cut │ │ ├── 完全不相交.cut │ │ ├── 完全不相交(同向).cut │ │ ├── 底边重合(图6).cut │ │ ├── 文档示例(S6S7S1特殊).cut │ │ ├── 文档示例(改C1位置).cut │ │ ├── 文档示例.cut │ │ ├── 点在边上重合(图5-右).cut │ │ └── 点在边上(图5-左).cut │ ├── CutModel.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── MyPolygon.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── WindowLog.cs │ └── packages.config ├── Doc │ └── 示意图.vsd └── GraphicAlgorithm.sln ├── HadoopNET ├── HadoopNET.sln ├── HadoopNET │ ├── App.config │ ├── HadoopNET.csproj │ ├── MRLib │ │ ├── MRRunner.exe │ │ ├── Microsoft.Hadoop.Client.dll │ │ ├── Microsoft.Hadoop.CombineDriver.exe │ │ ├── Microsoft.Hadoop.MapDriver.exe │ │ ├── Microsoft.Hadoop.MapReduce.dll │ │ ├── Microsoft.Hadoop.ReduceDriver.exe │ │ └── Microsoft.WindowsAzure.Management.Framework.Threading.dll │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── NetCoreMapper │ ├── NetCoreMapper.csproj │ ├── Program.cs │ └── publish.bat ├── NetCoreReducer │ ├── NetCoreReducer.csproj │ ├── Program.cs │ └── publish.bat ├── NetCreateCluster │ ├── App.config │ ├── DeploymentHelper.cs │ ├── NetCreateCluster.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── packages.config │ ├── parameters.json │ └── template.json ├── NetMapper │ ├── App.config │ ├── NetMapper.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── NetReducer │ ├── App.config │ ├── NetReducer.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs └── SubmitNet │ ├── App.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── SubmitNet.csproj │ └── packages.config ├── PCI ├── PCI.sln └── PCI │ ├── AdvancedClassify.cs │ ├── AdvancedClassifyTest.cs │ ├── App.config │ ├── Crawler.cs │ ├── DecisionNode.cs │ ├── DocClass.cs │ ├── Dorm.cs │ ├── Gp.cs │ ├── GpTest.cs │ ├── IClassifier.cs │ ├── ISimilar.cs │ ├── LIBSVM_COPYRIGHT │ ├── Lib │ └── Python.Runtime.dll │ ├── MatplotlibCS │ ├── annotations.py │ ├── arc.py │ ├── helpers.py │ ├── histogram.py │ ├── hline.py │ ├── line_2d.py │ ├── matplotlib_cs.py │ ├── subplot.py │ ├── task.py │ └── vline.py │ ├── NewsFeatures.cs │ ├── NewsFeaturesTest.cs │ ├── Nmf.cs │ ├── NumPredict.cs │ ├── NumPredictTest.cs │ ├── PCI.csproj │ ├── Properties │ └── AssemblyInfo.cs │ ├── SearchNet.cs │ ├── Searcher.cs │ ├── SocialNetwork.cs │ ├── TestData │ ├── agesonly.csv │ └── matchmaker.csv │ ├── Travel.cs │ ├── TravelForNumPredict.cs │ ├── blogdata.txt │ ├── libsvm.dll │ └── packages.config ├── README.md ├── Win81Demo ├── Win81Demo.Controls.Sample │ ├── App.xaml │ ├── App.xaml.cs │ ├── Assets │ │ ├── Logo.scale-100.png │ │ ├── SmallLogo.scale-100.png │ │ ├── SplashScreen.scale-100.png │ │ └── StoreLogo.scale-100.png │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Package.appxmanifest │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── View │ │ ├── CircleMenuSample.xaml │ │ └── CircleMenuSample.xaml.cs │ ├── ViewModel │ │ ├── CircleMenuSampleViewModel.cs │ │ ├── MainViewModel.cs │ │ └── ViewModelLocator.cs │ ├── Win81Demo.Controls.Sample.csproj │ ├── Win81Demo.Controls.Sample_TemporaryKey.pfx │ └── packages.config ├── Win81Demo.Controls │ ├── CircleMenuControl │ │ ├── CircleMenu.cs │ │ ├── CircleMenu.xaml │ │ ├── CircleMenuItem.cs │ │ └── CircleMenuPanel.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Themes │ │ └── Generic.xaml │ └── Win81Demo.Controls.csproj └── Win81Demo.sln ├── WpfDemo ├── Wpf.Control.Sample │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── Design │ │ └── DesignDataService.cs │ ├── Model │ │ ├── DataItem.cs │ │ ├── DataService.cs │ │ └── IDataService.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── ViewModel │ │ ├── CircleMenuSampleViewModel.cs │ │ ├── FlowSampleViewModel.cs │ │ ├── MainViewModel.cs │ │ └── ViewModelLocator.cs │ ├── Views │ │ ├── CircleMenuSample.xaml │ │ ├── CircleMenuSample.xaml.cs │ │ ├── FlowSample.xaml │ │ ├── FlowSample.xaml.cs │ │ ├── MainWindow.xaml │ │ └── MainWindow.xaml.cs │ ├── Wpf.Control.Sample.csproj │ └── packages.config ├── Wpf.Control │ ├── CircleMenu │ │ ├── CircleMenuControl.cs │ │ ├── CircleMenuControl.xaml │ │ ├── CircleMenuItem.cs │ │ ├── CircleMenuItemsPresenter.cs │ │ └── CircleMenuPanel.cs │ ├── Flow │ │ ├── FlowControl.cs │ │ ├── FlowControl.xaml │ │ ├── FlowControlPanel.cs │ │ ├── FlowItem.cs │ │ ├── FlowNodeControl.cs │ │ ├── FlowNodeControl.xaml │ │ ├── MultiMarginConverter.cs │ │ ├── MultiWidthAnimationConverter.cs │ │ └── TitleMaxWidthConverter.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Themes │ │ └── Generic.xaml │ └── Wpf.Control.csproj └── WpfControlDemo.sln └── XMindFiles └── WPF.xmind /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WpfApplication1 10 | { 11 | /// 12 | /// App.xaml 的交互逻辑 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CrossLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Media; 8 | using System.Windows.Shapes; 9 | 10 | namespace WpfApplication1 11 | { 12 | public class CrossLine : Shape 13 | { 14 | public static readonly DependencyProperty CenterProperty = DependencyProperty.Register( 15 | "Center", typeof(Point), typeof(CrossLine), 16 | new FrameworkPropertyMetadata(default(Point), FrameworkPropertyMetadataOptions.AffectsRender)); 17 | 18 | public Point Center 19 | { 20 | get { return (Point)GetValue(CenterProperty); } 21 | set { SetValue(CenterProperty, value); } 22 | } 23 | 24 | public static readonly DependencyProperty VisibleProperty = DependencyProperty.Register( 25 | "Visible", typeof(bool), typeof(CrossLine), 26 | new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); 27 | 28 | public bool Visible 29 | { 30 | get { return (bool)GetValue(VisibleProperty); } 31 | set { SetValue(VisibleProperty, value); } 32 | } 33 | 34 | public static readonly DependencyProperty CrossRadiusProperty = DependencyProperty.Register( 35 | "CrossRadius", typeof(double), typeof(CrossLine), new PropertyMetadata(3d)); 36 | 37 | public double CrossRadius 38 | { 39 | get { return (double)GetValue(CrossRadiusProperty); } 40 | set { SetValue(CrossRadiusProperty, value); } 41 | } 42 | 43 | private Geometry _polylineGeometry; 44 | 45 | protected override Geometry DefiningGeometry 46 | { 47 | get 48 | { 49 | CompositeGeometry(); 50 | return _polylineGeometry; 51 | } 52 | } 53 | 54 | private void CompositeGeometry() 55 | { 56 | if (!Visible) 57 | { 58 | _polylineGeometry = Geometry.Empty; 59 | return; 60 | } 61 | 62 | PathGeometry polylineGeometry = new PathGeometry(); 63 | 64 | 65 | var topPoint = new Point(Center.X, Center.Y - CrossRadius); 66 | var bottomPoint = new Point(Center.X, Center.Y + CrossRadius); 67 | PathFigure pathFigureV = new PathFigure(); 68 | pathFigureV.StartPoint = topPoint; 69 | pathFigureV.Segments.Add(new LineSegment(bottomPoint, true)); 70 | var leftPoint = new Point(Center.X - CrossRadius, Center.Y); 71 | var rightPoint = new Point(Center.X + CrossRadius, Center.Y); 72 | var pathFigureH = new PathFigure(); 73 | pathFigureH.StartPoint = leftPoint; 74 | pathFigureH.Segments.Add(new LineSegment(rightPoint, true)); 75 | polylineGeometry.Figures.Add(pathFigureV); 76 | polylineGeometry.Figures.Add(pathFigureH); 77 | 78 | // Set FillRule 79 | polylineGeometry.FillRule = FillRule.EvenOdd; 80 | 81 | if (polylineGeometry.Bounds == Rect.Empty) 82 | { 83 | _polylineGeometry = Geometry.Empty; 84 | } 85 | else 86 | { 87 | _polylineGeometry = polylineGeometry; 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/C包含S.cut: -------------------------------------------------------------------------------- 1 | [{"X":281.0,"Y":159.0,"Name":"S1"},{"X":242.0,"Y":366.0,"Name":"S2"},{"X":506.0,"Y":419.0,"Name":"S3"},{"X":569.0,"Y":248.0,"Name":"S4"},{"X":472.0,"Y":155.0,"Name":"S5"}] 2 | [{"X":149.0,"Y":241.0,"Name":"C1"},{"X":282.0,"Y":72.0,"Name":"C2"},{"X":559.0,"Y":111.0,"Name":"C3"},{"X":628.0,"Y":406.0,"Name":"C4"},{"X":418.0,"Y":475.0,"Name":"C5"},{"X":170.0,"Y":407.0,"Name":"C6"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/S包含C.cut: -------------------------------------------------------------------------------- 1 | [{"X":259.0,"Y":113.0,"Name":"S1"},{"X":103.0,"Y":374.0,"Name":"S2"},{"X":548.0,"Y":481.0,"Name":"S3"},{"X":689.0,"Y":107.0,"Name":"S4"}] 2 | [{"X":306.0,"Y":178.0,"Name":"C1"},{"X":255.0,"Y":326.0,"Name":"C2"},{"X":441.0,"Y":387.0,"Name":"C3"},{"X":596.0,"Y":263.0,"Name":"C4"},{"X":565.0,"Y":160.0,"Name":"C5"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/完全不相交.cut: -------------------------------------------------------------------------------- 1 | [{"X":94.0,"Y":162.0,"Name":"S1"},{"X":59.0,"Y":352.0,"Name":"S2"},{"X":223.0,"Y":480.0,"Name":"S3"},{"X":393.0,"Y":321.0,"Name":"S4"}] 2 | [{"X":500.0,"Y":98.0,"Name":"C1"},{"X":689.0,"Y":111.0,"Name":"C2"},{"X":732.0,"Y":283.0,"Name":"C3"},{"X":603.0,"Y":413.0,"Name":"C4"},{"X":390.0,"Y":270.0,"Name":"C5"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/完全不相交(同向).cut: -------------------------------------------------------------------------------- 1 | [{"X":79.0,"Y":176.0,"Name":"S1"},{"X":52.0,"Y":429.0,"Name":"S2"},{"X":282.0,"Y":430.0,"Name":"S3"},{"X":341.0,"Y":240.0,"Name":"S4"},{"X":221.0,"Y":169.0,"Name":"S5"}] 2 | [{"X":456.0,"Y":111.0,"Name":"C1"},{"X":413.0,"Y":320.0,"Name":"C2"},{"X":691.0,"Y":287.0,"Name":"C3"},{"X":680.0,"Y":172.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/底边重合(图6).cut: -------------------------------------------------------------------------------- 1 | [{"X":247.0,"Y":183.0,"Name":"S1"},{"X":129.0,"Y":374.0,"Name":"S2"},{"X":536.0,"Y":374.0,"Name":"S3"},{"X":536.0,"Y":181.0,"Name":"S4"}] 2 | [{"X":128.0,"Y":71.0,"Name":"C1"},{"X":263.0,"Y":374.0,"Name":"C2"},{"X":455.0,"Y":374.0,"Name":"C3"},{"X":295.0,"Y":70.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/文档示例(S6S7S1特殊).cut: -------------------------------------------------------------------------------- 1 | [{"X":70.0,"Y":104.0,"Name":"S1"},{"X":120.0,"Y":487.0,"Name":"S2"},{"X":688.0,"Y":484.0,"Name":"S3"},{"X":625.0,"Y":299.0,"Name":"S4"},{"X":412.0,"Y":455.0,"Name":"S5"},{"X":281.0,"Y":219.0,"Name":"S6"},{"X":227.0,"Y":357.0,"Name":"S7"}] 2 | [{"X":125.0,"Y":256.0,"Name":"C1"},{"X":689.0,"Y":242.0,"Name":"C2"},{"X":710.0,"Y":427.0,"Name":"C3"},{"X":40.0,"Y":371.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/文档示例(改C1位置).cut: -------------------------------------------------------------------------------- 1 | [{"Next":null,"X":126.0,"Y":121.0,"Name":"S1"},{"Next":null,"X":169.0,"Y":434.0,"Name":"S2"},{"Next":null,"X":633.0,"Y":442.0,"Name":"S3"},{"Next":null,"X":575.0,"Y":194.0,"Name":"S4"},{"Next":null,"X":335.0,"Y":391.0,"Name":"S5"}] 2 | [{"Next":null,"X":176.0,"Y":234.0,"Name":"C1"},{"Next":null,"X":622.0,"Y":132.0,"Name":"C2"},{"Next":null,"X":656.0,"Y":362.0,"Name":"C3"},{"Next":null,"X":90.0,"Y":328.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/文档示例.cut: -------------------------------------------------------------------------------- 1 | [{"X":173.0,"Y":106.0,"Name":"S1"},{"X":128.0,"Y":443.0,"Name":"S2"},{"X":663.0,"Y":457.0,"Name":"S3"},{"X":663.0,"Y":232.0,"Name":"S4"},{"X":333.0,"Y":366.0,"Name":"S5"}] 2 | [{"X":81.0,"Y":183.0,"Name":"C1"},{"X":737.0,"Y":179.0,"Name":"C2"},{"X":713.0,"Y":379.0,"Name":"C3"},{"X":59.0,"Y":292.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/点在边上重合(图5-右).cut: -------------------------------------------------------------------------------- 1 | [{"X":180.0,"Y":115.0,"Name":"S1"},{"X":180.0,"Y":293.0,"Name":"S2"},{"X":378.0,"Y":293.0,"Name":"S3"},{"X":357.0,"Y":115.0,"Name":"S4"}] 2 | [{"X":123.0,"Y":115.0,"Name":"C1"},{"X":304.0,"Y":115.0,"Name":"C2"},{"X":304.0,"Y":232.0,"Name":"C3"},{"X":44.0,"Y":232.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutFile/点在边上(图5-左).cut: -------------------------------------------------------------------------------- 1 | [{"X":242.0,"Y":78.0,"Name":"S1"},{"X":242.0,"Y":289.0,"Name":"S2"},{"X":480.0,"Y":289.0,"Name":"S3"},{"X":480.0,"Y":77.0,"Name":"S4"}] 2 | [{"X":162.0,"Y":110.0,"Name":"C1"},{"X":162.0,"Y":247.0,"Name":"C2"},{"X":386.0,"Y":103.0,"Name":"C3"},{"X":388.0,"Y":19.0,"Name":"C4"}] 3 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/CutModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using Newtonsoft.Json; 9 | 10 | namespace WpfApplication1 11 | { 12 | [Serializable] 13 | public abstract class VertexBase 14 | { 15 | public double X { get; set; } 16 | public double Y { get; set; } 17 | 18 | public string Name { get; set; } 19 | 20 | public void SetXY(double x, double y) 21 | { 22 | X = x; 23 | Y = y; 24 | } 25 | 26 | public Point ToPoint() 27 | { 28 | return new Point(X,Y); 29 | } 30 | } 31 | 32 | public class Vertex : VertexBase 33 | { 34 | [DebuggerNonUserCode] 35 | public Vertex(double x, double y) 36 | { 37 | X = x; 38 | Y = y; 39 | } 40 | 41 | [JsonIgnore] 42 | public VertexBase Next { get; set; } 43 | } 44 | 45 | public class Intersection : VertexBase 46 | { 47 | [DebuggerNonUserCode] 48 | public Intersection(double x, double y) 49 | { 50 | X = x; 51 | Y = y; 52 | } 53 | 54 | public CrossInOut CrossDi { get; set; } 55 | public bool Used { get; set; } 56 | public VertexBase NextS { get; set; } 57 | public VertexBase NextC { get; set; } 58 | } 59 | 60 | public class IntersWithIndex : Intersection 61 | { 62 | [DebuggerNonUserCode] 63 | public IntersWithIndex(double x, double y, int idx) 64 | : base(x, y) 65 | { 66 | Idx = idx; 67 | } 68 | 69 | public int Idx { get; set; } 70 | } 71 | 72 | public enum CrossInOut 73 | { 74 | In, Out 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 显示方向 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/MyPolygon.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Media; 8 | using System.Windows.Shapes; 9 | 10 | namespace WpfApplication1 11 | { 12 | [Serializable] 13 | public class MyPolygon 14 | { 15 | public MyPolygon(RenderType type = RenderType.Polyline) 16 | { 17 | _type = type; 18 | } 19 | 20 | public Color StrokeColor { get; set; } 21 | public Color FillColor { get; set; } 22 | public double StrokeThickess { get; set; } 23 | 24 | private readonly RenderType _type; 25 | public bool Filled { get; set; } = false; 26 | public bool ShowArrow { get; set; } 27 | public bool ArrowReverse { get; set; } 28 | 29 | public List PointList = new List(); 30 | private Shape _innerShape; 31 | 32 | private bool showed = false; 33 | 34 | public void Render(Canvas canvas) 35 | { 36 | if (_type == RenderType.Polyline) 37 | { 38 | if (_innerShape == null) 39 | { 40 | _innerShape = new ArrowLine() 41 | { 42 | Stroke = new SolidColorBrush(StrokeColor), 43 | StrokeThickness = StrokeThickess, 44 | Fill = Filled ? new SolidColorBrush(FillColor) : new SolidColorBrush(Colors.Transparent), 45 | }; 46 | } 47 | var polyline = _innerShape as ArrowLine; 48 | polyline.IsDirectionReverse = ArrowReverse; 49 | polyline.ShowArrow = ShowArrow; 50 | polyline.Text = PointList.Select(v => v.Name).ToList(); 51 | polyline.Points.Clear(); 52 | PointList.ForEach(v=>polyline.Points.Add(v.ToPoint())); 53 | polyline.Points.Add(PointList[0].ToPoint()); 54 | } 55 | else if (_type == RenderType.Polygon) 56 | { 57 | if (_innerShape == null) 58 | { 59 | _innerShape = new Polygon() 60 | { 61 | Stroke = new SolidColorBrush(StrokeColor), 62 | StrokeThickness = StrokeThickess, 63 | Fill = Filled ? new SolidColorBrush(FillColor) : new SolidColorBrush(Colors.Transparent) 64 | }; 65 | var polygon = _innerShape as Polygon; 66 | polygon.Points.Clear(); 67 | PointList.ForEach(pv => polygon.Points.Add(new Point(pv.X, pv.Y))); 68 | polygon.Points.Add(PointList[0].ToPoint()); 69 | } 70 | } 71 | 72 | if (!showed) 73 | { 74 | canvas.Children.Add(_innerShape); 75 | showed = true; 76 | } 77 | } 78 | 79 | public void Reset() 80 | { 81 | PointList.Clear(); 82 | showed = false; 83 | ArrowReverse = false; 84 | } 85 | } 86 | 87 | public enum RenderType 88 | { 89 | Polyline, 90 | Polygon 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("WpfApplication1")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WpfApplication1")] 15 | [assembly: AssemblyCopyright("Copyright © 2015")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | //将 ComVisible 设置为 false 将使此程序集中的类型 20 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请 25 | // 中的 .csproj 文件中 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(当资源未在页面 37 | //或应用程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(当资源未在页面 40 | //、应用程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 52 | // 方法是按如下所示使用“*”: : 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ArbitraryPolygonCut.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ArbitraryPolygonCut.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ArbitraryPolygonCut.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/WindowLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WpfApplication1 10 | { 11 | public class WindowLog 12 | { 13 | private static WindowLog _logger; 14 | private static readonly object CreationLock = new object(); 15 | 16 | public static WindowLog Default 17 | { 18 | get 19 | { 20 | 21 | if (_logger == null) 22 | { 23 | lock (CreationLock) 24 | { 25 | if (_logger == null) 26 | _logger = new WindowLog(); 27 | } 28 | } 29 | return _logger; 30 | } 31 | } 32 | 33 | private Action _logComingAction; 34 | private Action _addLabelAction; 35 | private Action _reverseAction; 36 | 37 | public void WhenLogCommon(Action logComingAction) 38 | { 39 | _logComingAction = logComingAction; 40 | } 41 | 42 | public void WhenAddLabel(Action addLabelAction) 43 | { 44 | _addLabelAction = addLabelAction; 45 | } 46 | 47 | public void Log(string log) 48 | { 49 | _logComingAction?.Invoke(log); 50 | Debug.WriteLine(log); 51 | } 52 | 53 | public void Log(string format, params object[] arg) 54 | { 55 | var log = string.Format(format, arg); 56 | Log(log); 57 | } 58 | 59 | public void AddLabel(string content, Point point) 60 | { 61 | _addLabelAction?.Invoke(content,point); 62 | } 63 | 64 | public void WhenReversePolygon(Action reverseActionCommand) 65 | { 66 | _reverseAction = reverseActionCommand; 67 | } 68 | 69 | public void ReversePolygon() 70 | { 71 | _reverseAction?.Invoke(); 72 | } 73 | } 74 | 75 | public class Counter 76 | { 77 | private static Counter _counter; 78 | private static readonly object CreationLock = new object(); 79 | 80 | public static Counter Default 81 | { 82 | get 83 | { 84 | 85 | if (_counter == null) 86 | { 87 | lock (CreationLock) 88 | { 89 | if (_counter == null) 90 | _counter = new Counter(); 91 | } 92 | } 93 | return _counter; 94 | } 95 | } 96 | 97 | public int Val { get; set; } = 1; 98 | 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /GraphicAlgorithm/ArbitraryPolygonCut/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GraphicAlgorithm/Doc/示意图.vsd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/GraphicAlgorithm/Doc/示意图.vsd -------------------------------------------------------------------------------- /GraphicAlgorithm/GraphicAlgorithm.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Doc", "Doc", "{06E260AB-290A-4C0E-984C-CF7B9D4C74D5}" 7 | ProjectSection(SolutionItems) = preProject 8 | Doc\示意图.vsd = Doc\示意图.vsd 9 | EndProjectSection 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArbitraryPolygonCut", "ArbitraryPolygonCut\ArbitraryPolygonCut.csproj", "{2948D2A6-F19E-4DBF-A7F8-EA5BF96DFAEF}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {2948D2A6-F19E-4DBF-A7F8-EA5BF96DFAEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {2948D2A6-F19E-4DBF-A7F8-EA5BF96DFAEF}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {2948D2A6-F19E-4DBF-A7F8-EA5BF96DFAEF}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {2948D2A6-F19E-4DBF-A7F8-EA5BF96DFAEF}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /HadoopNET/HadoopNET.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HadoopNET", "HadoopNET\HadoopNET.csproj", "{023B23D6-41F7-455A-92EF-E954AEE8A9DC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubmitNet", "SubmitNet\SubmitNet.csproj", "{1AE5CC81-4BDA-40D0-ACC7-F191DA9358CA}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetReducer", "NetReducer\NetReducer.csproj", "{9C6BF11A-0159-4FAC-AF2F-09C67A0EEDC9}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMapper", "NetMapper\NetMapper.csproj", "{AF326F52-E4F8-46D2-9D8D-9F5AB3734C9A}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreReducer", "NetCoreReducer\NetCoreReducer.csproj", "{C4CB6499-D014-4529-B1CA-BB56F0E73162}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreMapper", "NetCoreMapper\NetCoreMapper.csproj", "{FB8A5414-4B7E-4180-B047-1866C3BDC093}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCreateCluster", "NetCreateCluster\NetCreateCluster.csproj", "{17FCC3A3-8D4B-40AE-8460-99BF7E771107}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {023B23D6-41F7-455A-92EF-E954AEE8A9DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {023B23D6-41F7-455A-92EF-E954AEE8A9DC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {023B23D6-41F7-455A-92EF-E954AEE8A9DC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {023B23D6-41F7-455A-92EF-E954AEE8A9DC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {1AE5CC81-4BDA-40D0-ACC7-F191DA9358CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {1AE5CC81-4BDA-40D0-ACC7-F191DA9358CA}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {1AE5CC81-4BDA-40D0-ACC7-F191DA9358CA}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {1AE5CC81-4BDA-40D0-ACC7-F191DA9358CA}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {9C6BF11A-0159-4FAC-AF2F-09C67A0EEDC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {9C6BF11A-0159-4FAC-AF2F-09C67A0EEDC9}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {9C6BF11A-0159-4FAC-AF2F-09C67A0EEDC9}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {9C6BF11A-0159-4FAC-AF2F-09C67A0EEDC9}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {AF326F52-E4F8-46D2-9D8D-9F5AB3734C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {AF326F52-E4F8-46D2-9D8D-9F5AB3734C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {AF326F52-E4F8-46D2-9D8D-9F5AB3734C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {AF326F52-E4F8-46D2-9D8D-9F5AB3734C9A}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {C4CB6499-D014-4529-B1CA-BB56F0E73162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {C4CB6499-D014-4529-B1CA-BB56F0E73162}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {C4CB6499-D014-4529-B1CA-BB56F0E73162}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {C4CB6499-D014-4529-B1CA-BB56F0E73162}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {FB8A5414-4B7E-4180-B047-1866C3BDC093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {FB8A5414-4B7E-4180-B047-1866C3BDC093}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {FB8A5414-4B7E-4180-B047-1866C3BDC093}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {FB8A5414-4B7E-4180-B047-1866C3BDC093}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {17FCC3A3-8D4B-40AE-8460-99BF7E771107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {17FCC3A3-8D4B-40AE-8460-99BF7E771107}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {17FCC3A3-8D4B-40AE-8460-99BF7E771107}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {17FCC3A3-8D4B-40AE-8460-99BF7E771107}.Release|Any CPU.Build.0 = Release|Any CPU 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | EndGlobal 59 | -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/HadoopNET.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {023B23D6-41F7-455A-92EF-E954AEE8A9DC} 8 | Exe 9 | Properties 10 | HadoopNET 11 | HadoopNET 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Microsoft.Hadoop.MapReduce.0.12.5807.28193\lib\net40\Microsoft.Hadoop.Client.dll 38 | True 39 | 40 | 41 | ..\packages\Microsoft.Hadoop.MapReduce.0.12.5807.28193\lib\net40\Microsoft.Hadoop.MapReduce.dll 42 | True 43 | 44 | 45 | ..\packages\Microsoft.Hadoop.MapReduce.0.12.5807.28193\lib\net40\Microsoft.Hadoop.WebClient.dll 46 | True 47 | 48 | 49 | ..\packages\Microsoft.Hadoop.MapReduce.0.12.5807.28193\lib\net40\Microsoft.WindowsAzure.Management.Framework.dll 50 | True 51 | 52 | 53 | ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll 54 | True 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Always 76 | 77 | 78 | Always 79 | 80 | 81 | Always 82 | 83 | 84 | Always 85 | 86 | 87 | Always 88 | 89 | 90 | Always 91 | 92 | 93 | Always 94 | 95 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/MRRunner.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/MRRunner.exe -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.Client.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.Client.dll -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.CombineDriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.CombineDriver.exe -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.MapDriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.MapDriver.exe -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.MapReduce.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.MapReduce.dll -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.ReduceDriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/Microsoft.Hadoop.ReduceDriver.exe -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/MRLib/Microsoft.WindowsAzure.Management.Framework.Threading.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/HadoopNET/HadoopNET/MRLib/Microsoft.WindowsAzure.Management.Framework.Threading.dll -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Hadoop.MapReduce; 7 | 8 | namespace HadoopNET 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | 15 | var hadoop = Hadoop.Connect(); 16 | hadoop.MapReduceJob.ExecuteJob(); 17 | } 18 | } 19 | 20 | public class FirstMapper : MapperBase 21 | { 22 | public override void Map(string inputLine, MapperContext context) 23 | { 24 | // 输入 25 | int inputValue = int.Parse(inputLine); 26 | 27 | // 任务 28 | var sqrt = Math.Sqrt(inputValue); 29 | 30 | // 写入输出 31 | context.EmitKeyValue(inputValue.ToString(), sqrt.ToString()); 32 | } 33 | } 34 | 35 | public class FirstJob : HadoopJob 36 | { 37 | public override HadoopJobConfiguration Configure(ExecutorContext context) 38 | { 39 | HadoopJobConfiguration config = new HadoopJobConfiguration(); 40 | config.InputPath = "input/SqrtJob"; 41 | config.OutputFolder = "output/SqrtJob"; 42 | //config 43 | return config; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("HadoopNET")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("HadoopNET")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("023b23d6-41f7-455a-92ef-e954aee8a9dc")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HadoopNET/HadoopNET/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /HadoopNET/NetCoreMapper/NetCoreMapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp1.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HadoopNET/NetCoreMapper/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace NetCoreMapper 8 | { 9 | public class Program 10 | { 11 | public static void Main(string[] args) 12 | { 13 | if (args.Length > 0) 14 | { 15 | Stream stream = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.Read); 16 | Console.SetIn(new StreamReader(stream)); 17 | } 18 | 19 | string line; 20 | while ((line = Console.ReadLine()) != null) 21 | { 22 | Console.WriteLine(line); 23 | } 24 | 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HadoopNET/NetCoreMapper/publish.bat: -------------------------------------------------------------------------------- 1 | dotnet publish --framework netcoreapp1.0 --configuration release --output publish -------------------------------------------------------------------------------- /HadoopNET/NetCoreReducer/NetCoreReducer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp1.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HadoopNET/NetCoreReducer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace NetCoreReducer 8 | { 9 | public class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | ILoggerFactory loggerFactory = new LoggerFactory() 14 | .AddConsole() 15 | .AddDebug(); 16 | ILogger logger = loggerFactory.CreateLogger(); 17 | logger.LogInformation( 18 | "This is a test of the emergency broadcast system."); 19 | 20 | string line; 21 | var count = 0; 22 | 23 | if (args.Length > 0) 24 | { 25 | Console.SetIn(new StreamReader(new FileStream(args[0], FileMode.Open, FileAccess.Read))); 26 | } 27 | 28 | while ((line = Console.ReadLine()) != null) 29 | { 30 | count += line.Count(cr => (cr == ' ' || cr == '\n')); 31 | } 32 | Console.WriteLine(count); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HadoopNET/NetCoreReducer/publish.bat: -------------------------------------------------------------------------------- 1 | dotnet publish --framework netcoreapp1.0 --configuration release --output publish -------------------------------------------------------------------------------- /HadoopNET/NetCreateCluster/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /HadoopNET/NetCreateCluster/DeploymentHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Microsoft.Azure.Management.ResourceManager; 8 | using Microsoft.Azure.Management.ResourceManager.Models; 9 | using Microsoft.Rest.Azure.Authentication; 10 | using Newtonsoft.Json; 11 | using Newtonsoft.Json.Linq; 12 | 13 | namespace NetCreateCluster 14 | { 15 | class DeploymentHelper 16 | { 17 | string subscriptionId = ""; 18 | string clientId = ""; 19 | string clientSecret = ""; 20 | string resourceGroupName = ""; 21 | string deploymentName = "";//这个是部署的名字而不是集群的名字,集群的名字是在模板指定的 22 | string resourceGroupLocation = ""; // 如果是创建新的资源组则需要指定,否则不需要 23 | string pathToTemplateFile = "template.json"; 24 | string pathToParameterFile = "parameters.json"; 25 | string tenantId = ""; 26 | 27 | public async void Run() 28 | { 29 | // Try to obtain the service credentials 30 | var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, clientSecret); 31 | 32 | // Read the template and parameter file contents 33 | JObject templateFileContents = GetJsonFileContents(pathToTemplateFile); 34 | JObject parameterFileContents = GetJsonFileContents(pathToParameterFile); 35 | 36 | // Create the resource manager client 37 | var resourceManagementClient = new ResourceManagementClient(serviceCreds); 38 | resourceManagementClient.SubscriptionId = subscriptionId; 39 | 40 | // Create or check that resource group exists 41 | EnsureResourceGroupExists(resourceManagementClient, resourceGroupName, resourceGroupLocation); 42 | 43 | // Start a deployment 44 | DeployTemplate(resourceManagementClient, resourceGroupName, deploymentName, templateFileContents, parameterFileContents); 45 | } 46 | 47 | /// 48 | /// Reads a JSON file from the specified path 49 | /// 50 | /// The full path to the JSON file 51 | /// The JSON file contents 52 | private JObject GetJsonFileContents(string pathToJson) 53 | { 54 | JObject templatefileContent = new JObject(); 55 | using (StreamReader file = File.OpenText(pathToJson)) 56 | { 57 | using (JsonTextReader reader = new JsonTextReader(file)) 58 | { 59 | templatefileContent = (JObject)JToken.ReadFrom(reader); 60 | return templatefileContent; 61 | } 62 | } 63 | } 64 | 65 | /// 66 | /// Ensures that a resource group with the specified name exists. If it does not, will attempt to create one. 67 | /// 68 | /// The resource manager client. 69 | /// The name of the resource group. 70 | /// The resource group location. Required when creating a new resource group. 71 | private static void EnsureResourceGroupExists(ResourceManagementClient resourceManagementClient, string resourceGroupName, string resourceGroupLocation) 72 | { 73 | if (resourceManagementClient.ResourceGroups.CheckExistence(resourceGroupName) != true) 74 | { 75 | Console.WriteLine(string.Format("Creating resource group '{0}' in location '{1}'", resourceGroupName, resourceGroupLocation)); 76 | var resourceGroup = new ResourceGroup(); 77 | resourceGroup.Location = resourceGroupLocation; 78 | resourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, resourceGroup); 79 | } 80 | else 81 | { 82 | Console.WriteLine(string.Format("Using existing resource group '{0}'", resourceGroupName)); 83 | } 84 | } 85 | 86 | /// 87 | /// Starts a template deployment. 88 | /// 89 | /// The resource manager client. 90 | /// The name of the resource group. 91 | /// The name of the deployment. 92 | /// The template file contents. 93 | /// The parameter file contents. 94 | private static void DeployTemplate(ResourceManagementClient resourceManagementClient, string resourceGroupName, string deploymentName, JObject templateFileContents, JObject parameterFileContents) 95 | { 96 | Console.WriteLine( 97 | $"Starting template deployment '{deploymentName}' in resource group '{resourceGroupName}'"); 98 | var deployment = new Deployment(); 99 | 100 | deployment.Properties = new DeploymentProperties 101 | { 102 | Mode = DeploymentMode.Incremental, 103 | Template = templateFileContents, 104 | Parameters = parameterFileContents["parameters"].ToObject() 105 | }; 106 | 107 | var deploymentResult = resourceManagementClient.Deployments.CreateOrUpdate(resourceGroupName, deploymentName, deployment); 108 | Console.WriteLine($"Deployment status: {deploymentResult.Properties.ProvisioningState}"); 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /HadoopNET/NetCreateCluster/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetCreateCluster 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var helper = new DeploymentHelper(); 10 | helper.Run(); 11 | 12 | Console.ReadLine();//防止退出 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /HadoopNET/NetCreateCluster/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NetCreateCluster")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NetCreateCluster")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("17fcc3a3-8d4b-40ae-8460-99bf7e771107")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HadoopNET/NetCreateCluster/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /HadoopNET/NetCreateCluster/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "clusterName": { 6 | "value": "" 7 | }, 8 | "clusterLoginUserName": { 9 | "value": "admin" 10 | }, 11 | "clusterLoginPassword": { 12 | "value": "" 13 | }, 14 | "location": { 15 | "value": "eastasia" 16 | }, 17 | "clusterWorkerNodeCount": { 18 | "value": 1 19 | }, 20 | "clusterKind": { 21 | "value": "HADOOP" 22 | }, 23 | "clusterVersion": { 24 | "value": "3.5" 25 | }, 26 | "sshUserName": { 27 | "value": "sshuser" 28 | }, 29 | "sshPassword": { 30 | "value": "" 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /HadoopNET/NetMapper/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /HadoopNET/NetMapper/NetMapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AF326F52-E4F8-46D2-9D8D-9F5AB3734C9A} 8 | Exe 9 | Properties 10 | NetMapper 11 | NetMapper 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /HadoopNET/NetMapper/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace NetMapper 5 | { 6 | class Cat 7 | { 8 | static void Main(string[] args) 9 | { 10 | if (args.Length > 0) 11 | { 12 | Console.SetIn(new StreamReader(args[0])); 13 | } 14 | 15 | string line; 16 | while ((line = Console.ReadLine()) != null) 17 | { 18 | Console.WriteLine(line); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HadoopNET/NetMapper/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NetMap")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NetMap")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("af326f52-e4f8-46d2-9d8d-9f5ab3734c9a")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HadoopNET/NetReducer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /HadoopNET/NetReducer/NetReducer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9C6BF11A-0159-4FAC-AF2F-09C67A0EEDC9} 8 | Exe 9 | Properties 10 | NetReducer 11 | NetReducer 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /HadoopNET/NetReducer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace NetReducer 9 | { 10 | class Program 11 | { 12 | private class Wc 13 | { 14 | static void Main(string[] args) 15 | { 16 | string line; 17 | var count = 0; 18 | 19 | if (args.Length > 0) 20 | { 21 | Console.SetIn(new StreamReader(args[0])); 22 | } 23 | 24 | while ((line = Console.ReadLine()) != null) 25 | { 26 | count += line.Count(cr => (cr == ' ' || cr == '\n')); 27 | } 28 | Console.WriteLine(count); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /HadoopNET/NetReducer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NetReducer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NetReducer")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("9c6bf11a-0159-4fac-af2f-09c67a0eedc9")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HadoopNET/SubmitNet/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /HadoopNET/SubmitNet/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Hyak.Common; 9 | using Microsoft.Azure.Management.HDInsight.Job; 10 | using Microsoft.Azure.Management.HDInsight.Job.Models; 11 | 12 | namespace SubmitNet 13 | { 14 | class Program 15 | { 16 | private static HDInsightJobManagementClient _hdiJobManagementClient; 17 | 18 | private const string ExistingClusterUri = "xxx.azurehdinsight.net"; 19 | private const string ExistingClusterUsername = "admin"; 20 | private const string ExistingClusterPassword = ""; 21 | 22 | private const string DefaultStorageAccountName = ""; 23 | private const string DefaultStorageAccountKey = ""; 24 | private const string DefaultStorageContainerName = ""; 25 | 26 | static void Main(string[] args) 27 | { 28 | Console.WriteLine("The application is running ..."); 29 | 30 | var clusterCredentials = new BasicAuthenticationCloudCredentials { Username = ExistingClusterUsername, Password = ExistingClusterPassword }; 31 | _hdiJobManagementClient = new HDInsightJobManagementClient(ExistingClusterUri, clusterCredentials); 32 | 33 | SubmitMRJob(); 34 | 35 | Console.WriteLine("Press ENTER to continue ..."); 36 | Console.ReadLine(); 37 | } 38 | 39 | private static void SubmitMRJob() 40 | { 41 | //var paras = new MapReduceStreamingJobSubmissionParameters 42 | //{ 43 | // Files = new List() { "/example/app/.exe", "/example/apps/wc.exe" }, 44 | // Mapper = "cat.exe", 45 | // Reducer = "wc.exe", 46 | // Input= "/example/data/gutenberg/davinci.txt", 47 | // Output = "/example/data/StreamingOutput/wc.txt" 48 | //}; 49 | 50 | var paras = new MapReduceStreamingJobSubmissionParameters 51 | { 52 | 53 | Files = new List() 54 | { 55 | "/example/coreapp", 56 | }, 57 | Mapper = "dotnet coreapp/NetCoreMapper.dll", 58 | Reducer = "dotnet coreapp/NetCoreReducer.dll", 59 | Input = "/example/data/gutenberg/davinci.txt", 60 | Output = "/example/data/StreamingOutput/wc.txt" 61 | 62 | }; 63 | 64 | Console.WriteLine("Submitting the MR job to the cluster..."); 65 | var jobResponse = _hdiJobManagementClient.JobManagement.SubmitMapReduceStreamingJob(paras); 66 | var jobId = jobResponse.JobSubmissionJsonResponse.Id; 67 | Console.WriteLine("Response status code is " + jobResponse.StatusCode); 68 | Console.WriteLine("JobId is " + jobId); 69 | 70 | Console.WriteLine("Waiting for the job completion ..."); 71 | 72 | // Wait for job completion 73 | var jobDetail = _hdiJobManagementClient.JobManagement.GetJob(jobId).JobDetail; 74 | while (!jobDetail.Status.JobComplete) 75 | { 76 | Thread.Sleep(1000); 77 | jobDetail = _hdiJobManagementClient.JobManagement.GetJob(jobId).JobDetail; 78 | } 79 | 80 | // Get job output 81 | var storageAccess = new AzureStorageAccess(DefaultStorageAccountName, DefaultStorageAccountKey, 82 | DefaultStorageContainerName); 83 | var output = (jobDetail.ExitValue == 0) 84 | ? _hdiJobManagementClient.JobManagement.GetJobOutput(jobId, storageAccess) // fetch stdout output in case of success 85 | : _hdiJobManagementClient.JobManagement.GetJobErrorLogs(jobId, storageAccess); // fetch stderr output in case of failure 86 | 87 | Console.WriteLine("Job output is: "); 88 | 89 | using (var reader = new StreamReader(output, Encoding.UTF8)) 90 | { 91 | string value = reader.ReadToEnd(); 92 | Console.WriteLine(value); 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /HadoopNET/SubmitNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("SubmitNet")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SubmitNet")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("1ae5cc81-4bda-40d0-acc7-f191da9358ca")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /HadoopNET/SubmitNet/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /PCI/PCI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCI", "PCI\PCI.csproj", "{B1857D90-67F1-49DD-A5DB-B30163AB208F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Debug|x64.ActiveCfg = Debug|x64 19 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Debug|x64.Build.0 = Debug|x64 20 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Release|x64.ActiveCfg = Release|x64 23 | {B1857D90-67F1-49DD-A5DB-B30163AB208F}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /PCI/PCI/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /PCI/PCI/Dorm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ConsoleApplication1 8 | { 9 | public class Dorm 10 | { 11 | // 宿舍,每个宿舍有两个隔间 12 | private List _dorms = new List() 13 | { 14 | "Zeus","Athena","Hercules","Bacchus","Pluto" 15 | }; 16 | 17 | // 学生,以及首选和次选 18 | private List>> _prefs = 19 | new List>>() 20 | { 21 | Tuple.Create("Toby",Tuple.Create("Bacchus", "Hercules")), 22 | Tuple.Create("Steve",Tuple.Create("Zeus", "Pluto")), 23 | Tuple.Create("Andrea",Tuple.Create("Athena", "Zeus")), 24 | Tuple.Create("Sarah",Tuple.Create("Zeus", "Pluto")), 25 | Tuple.Create("Dave",Tuple.Create("Athena", "Bacchus")), 26 | Tuple.Create("Jeff",Tuple.Create("Hercules", "Pluto")), 27 | Tuple.Create("Fred",Tuple.Create("Pluto", "Athena")), 28 | Tuple.Create("Suzie",Tuple.Create("Bacchus", "Hercules")), 29 | Tuple.Create("Laura",Tuple.Create("Bacchus", "Hercules")), 30 | Tuple.Create("Neil",Tuple.Create("Hercules", "Athena")) 31 | }; 32 | 33 | //题解范围 34 | public List> Domain => 35 | Enumerable.Repeat(0, _dorms.Count*2) 36 | .Select((v, i) => Tuple.Create(0, _dorms.Count*2 - i - 1)) 37 | .ToList(); 38 | 39 | public void PrintSolution(List vec) 40 | { 41 | var slots = new List(); 42 | // 为每个宿舍见两个槽 43 | for (int i = 0; i < _dorms.Count; i++) 44 | slots.AddRange(new []{i,i}); 45 | // 遍历每一个名学生的安置情况 46 | for (int i = 0; i < vec.Count; i++) 47 | { 48 | var x = vec[i]; 49 | //从剩余槽中选择 50 | var dorm = _dorms[slots[x]]; 51 | //输出学生及其被分配的宿舍 52 | Console.WriteLine($"{_prefs[i].Item1} {dorm}"); 53 | //删除该槽 54 | slots.RemoveAt(x); 55 | } 56 | } 57 | 58 | public float DormCost(List vec) 59 | { 60 | var cost = 0; 61 | // 建立槽序列 62 | var slots=new List() {0,0,1,1,2,2,3,3,4,4}; 63 | // 遍历每一名学生 64 | for (int i = 0; i < vec.Count; i++) 65 | { 66 | var x = vec[i]; 67 | var dorm = _dorms[slots[x]]; 68 | var pref = _prefs[i].Item2; 69 | //首选成本为0,次选成本值为1 70 | //不在选择之列,成本加3 71 | if (pref.Item1 == dorm) cost += 0; 72 | else if (pref.Item2 == dorm) cost += 1; 73 | else cost += 3; 74 | //删除该槽 75 | slots.RemoveAt(x); 76 | } 77 | return cost; 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /PCI/PCI/IClassifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Data.Common; 5 | using System.Linq; 6 | using Dapper; 7 | 8 | namespace ConsoleApplication1 9 | { 10 | public interface IClassifier 11 | { 12 | int CatCount(Cat cat); 13 | List Categories(); 14 | int Fcount(string f, Cat cat); 15 | float Fprob(string f, Cat cat); 16 | void Incc(Cat cat); 17 | void Incf(string f, Cat cat); 18 | int TotalCount(); 19 | void Train(string item, Cat cat); 20 | float WeightedProb(string f, Cat cat, Func prf, float weight = 1, float ap = 0.5F); 21 | } 22 | 23 | public class SqliteClassifier : IClassifier 24 | { 25 | private IDbConnection _connection; 26 | 27 | public SqliteClassifier(Func> getFeatures, string dbname) 28 | { 29 | _getFeatures = getFeatures; 30 | _connection = GetConn(dbname); 31 | SetDb(); 32 | } 33 | 34 | public void SetDb() 35 | { 36 | _connection.Execute("create table if not exists fc(feature, category, count)"); 37 | _connection.Execute("create table if not exists cc(category,count)"); 38 | } 39 | 40 | public IDbConnection GetConn(string dbname) 41 | { 42 | DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite"); 43 | DbConnection cnn = fact.CreateConnection(); 44 | cnn.ConnectionString = $"Data Source={dbname}"; 45 | cnn.Open(); 46 | return cnn; 47 | } 48 | 49 | protected Func> _getFeatures; 50 | 51 | public void Incf(string f, Cat cat) 52 | { 53 | var count = Fcount(f, cat); 54 | _connection.Execute(count == 0 55 | ? $"insert into fc values ('{f}','{cat}', 1)" 56 | : $"update fc set count={count + 1} where feature='{f}' and category='{cat}'"); 57 | } 58 | 59 | public int Fcount(string f, Cat cat) 60 | { 61 | var res = _connection.ExecuteScalar($"select count from fc where feature='{f}' and category='{cat}'"); 62 | return res; 63 | } 64 | 65 | public void Incc(Cat cat) 66 | { 67 | var count = CatCount(cat); 68 | if (count == 0) _connection.Execute($"insert into cc values ('{cat}', 1)"); 69 | else _connection.Execute($"update cc set count={count + 1} where category='{cat}'"); 70 | } 71 | 72 | public int CatCount(Cat cat) 73 | { 74 | var res = _connection.ExecuteScalar($"select count from cc where category='{cat}'"); 75 | return res; 76 | } 77 | 78 | public List Categories() 79 | { 80 | return _connection.Query("select category from cc") 81 | .ToList() 82 | .Select(cs => Enum.Parse(typeof(Cat), cs)) 83 | .Cast() 84 | .ToList(); 85 | } 86 | 87 | public int TotalCount() 88 | { 89 | var res = _connection.ExecuteScalar("select sum(count) from cc"); 90 | return res; 91 | } 92 | 93 | public void Train(string item, Cat cat) 94 | { 95 | var features = _getFeatures(item); 96 | //针对该分类为每个特征增加计数值 97 | foreach (var f in features) 98 | { 99 | Incf(f.Key, cat); 100 | } 101 | 102 | //增加针对该分类的计数值 103 | Incc(cat); 104 | } 105 | 106 | public float Fprob(string f, Cat cat) 107 | { 108 | if (CatCount(cat) == 0) return 0; 109 | // 特征在分类中出现的总次数,除以分类中包含的内容项总数 110 | return Fcount(f, cat) / (float)CatCount(cat); 111 | } 112 | 113 | public float WeightedProb(string f, Cat cat, Func prf, float weight = 1.0f, float ap = 0.5f) 114 | { 115 | // 计算当前概率 116 | var basicprob = prf(f, cat); 117 | 118 | // 特征(即单词)在所有分类中出现的次数 119 | var totals = Categories().Select(c => Fcount(f, c)).Sum(); 120 | 121 | // 计算加权平均 122 | var bp = (weight * ap + totals * basicprob) / (weight + totals); 123 | return bp; 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /PCI/PCI/ISimilar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ConsoleApplication1 8 | { 9 | interface ISimilar 10 | { 11 | double Calc(Dictionary> prefs, string person1, string person2); 12 | } 13 | 14 | public class SimilarDistance : ISimilar 15 | { 16 | public double Calc(Dictionary> prefs, string person1, string person2) 17 | { 18 | //得到双方都评价过的电影列表 19 | var si = prefs[person1].Keys.Intersect(prefs[person2].Keys).ToList(); 20 | if (!si.Any()) return 0; 21 | var sumSquares = si.Sum(s => Math.Pow(prefs[person1][s] - prefs[person2][s], 2)); 22 | return 1 / (1 + Math.Sqrt(sumSquares)); 23 | } 24 | } 25 | 26 | public class SimilarPerson : ISimilar 27 | { 28 | public double Calc(Dictionary> prefs, string person1, string person2) 29 | { 30 | //得到双方都评价过的电影列表 31 | var si = prefs[person1].Keys.Intersect(prefs[person2].Keys).ToList(); 32 | if (!si.Any()) return -1;//没有共同之处,返回-1 (博主注,原文是返回1,感觉是个bug) 33 | //各种打分求和 34 | var sum1 = si.Sum(s => prefs[person1][s]); 35 | var sum2 = si.Sum(s => prefs[person2][s]); 36 | //打分的平方和 37 | var sum1Sq = si.Sum(s => Math.Pow(prefs[person1][s], 2)); 38 | var sum2Sq = si.Sum(s => Math.Pow(prefs[person2][s], 2)); 39 | //打分乘积之和 40 | var pSum = si.Sum(s => prefs[person1][s] * prefs[person2][s]); 41 | //计算皮尔逊评价值 42 | var num = pSum - (sum1 * sum2 / si.Count); 43 | var den = Math.Sqrt((sum1Sq - Math.Pow(sum1, 2) / si.Count) * (sum2Sq - Math.Pow(sum2, 2) / si.Count)); 44 | if (den == 0) return 0; 45 | return num / den; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /PCI/PCI/LIBSVM_COPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2000-2014 Chih-Chung Chang and Chih-Jen Lin 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | 3. Neither name of copyright holders nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /PCI/PCI/Lib/Python.Runtime.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/PCI/PCI/Lib/Python.Runtime.dll -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/annotations.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | from datetime import datetime 3 | from helpers import if_string_convert_to_datetime 4 | 5 | 6 | class Text: 7 | def __init__(self, jsonDict): 8 | self.fontSize = 12 9 | self.color = 'k' 10 | self.alpha = 1 11 | self.__dict__ = jsonDict 12 | self.x = if_string_convert_to_datetime(self.x) 13 | 14 | def plot(self, axes): 15 | plot.text(self.x, 16 | self.y, 17 | self.text, 18 | size=self.fontSize, 19 | alpha=self.alpha, 20 | color=self.color["value"]) 21 | 22 | 23 | class Annotation: 24 | def __init__(self, jsonDict): 25 | self.fontSize = 12 26 | self.color = 'k' 27 | self.alpha = 1 28 | self.__dict__ = jsonDict 29 | self.x = if_string_convert_to_datetime(self.arrow_x) 30 | self.x = if_string_convert_to_datetime(self.text_x) 31 | 32 | def plot(self, axes): 33 | plot.annotate(self.text, 34 | xy=(self.arrow_x, self.arrow_y), 35 | xycoords='data', 36 | xytext=(self.text_x, self.text_y), 37 | textcoords='data', 38 | color=self.color["value"], 39 | size=self.fontSize, 40 | alpha=self.alpha, 41 | arrowprops=dict( 42 | linewidth=self.lineWidth, 43 | color=self.color["value"], 44 | alpha=self.alpha, 45 | arrowstyle=self.arrow_style, 46 | connectionstyle='arc3,rad=0', 47 | ) 48 | ) 49 | -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/arc.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | import matplotlib.patches as patches 3 | 4 | from line_2d import Line2D 5 | 6 | 7 | class Arc(Line2D): 8 | def __init__(self, jsonDict): 9 | self.__dict__ = jsonDict 10 | self.check_if_x_is_time() 11 | 12 | def plot(self, axes): 13 | label = self.name if self.show_legend else "" 14 | a = patches.Arc((self.x, self.y), 15 | self.width, 16 | self.height, 17 | angle=self.angle, 18 | theta1=self.theta1, 19 | theta2=self.theta2, 20 | color=self.color["value"], 21 | linewidth=self.lineWidth, 22 | alpha=self.alpha, 23 | label=label) 24 | axes.add_patch(a) 25 | plot.hold(True) 26 | -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/helpers.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | 4 | def if_string_convert_to_datetime(x): 5 | ''' 6 | Checks if x is a string, then trying to convert it to datetime and return the result. 7 | If x is not a string, just returns the x itself 8 | :param self: 9 | :return: 10 | ''' 11 | 12 | if isinstance(x, list): 13 | X = [] 14 | for _x in x: 15 | X.append(if_string_convert_to_datetime(_x)) 16 | return X 17 | 18 | if isinstance(x, str): 19 | # return datetime.strptime(x[0:19] + x[27:30] + x[31:33], '%Y-%m-%dT%H:%M:%S%z') 20 | # .net yyyy-MM-ddTHH:mm:ss,fff,zzz 21 | return datetime.strptime(x, '%Y-%m-%dT%H:%M:%S,%f') 22 | return x 23 | -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/histogram.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | from matplotlib.ticker import FormatStrFormatter 3 | 4 | 5 | class Histogram: 6 | def __init__(self, jsonDict): 7 | self.__dict__ = jsonDict 8 | 9 | def plot(self, axes): 10 | label = self.name if self.show_legend else "" 11 | counts, bins, patches = plot.hist( 12 | self.y, 13 | self.bins, 14 | color=self.color["value"], 15 | normed=self.normed, 16 | orientation=self.orientation, 17 | range=self.range, 18 | cumulative=self.cumulative, 19 | histtype=self.histtype, 20 | alpha=self.alpha, 21 | label=label) 22 | plot.hold(True) 23 | axes.set_xticks(bins) 24 | # axes.xaxis.set_major_formatter(FormatStrFormatter('%f')) 25 | 26 | -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/hline.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | from line_2d import Line2D 3 | from helpers import if_string_convert_to_datetime 4 | 5 | class Hline(Line2D): 6 | def __init__(self, jsonDict): 7 | self.__dict__ = jsonDict 8 | self.xmin = if_string_convert_to_datetime(self.xmin) 9 | self.xmax = if_string_convert_to_datetime(self.xmax) 10 | 11 | def plot(self, axes): 12 | label = self.name if self.show_legend else "" 13 | plot.hlines(self.y, 14 | self.xmin, 15 | self.xmax, 16 | color=self.color["value"], 17 | lw=self.lineWidth, 18 | linestyle=self.lineStyle, 19 | alpha=self.alpha, 20 | label=label) 21 | plot.hold(True) -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/line_2d.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | from datetime import datetime 3 | import matplotlib.dates as mdates 4 | from helpers import if_string_convert_to_datetime 5 | 6 | class Line2D: 7 | def __init__(self, jsonDict): 8 | self.__dict__ = jsonDict 9 | self.check_if_x_is_time() 10 | 11 | def check_if_x_is_time(self): 12 | if isinstance(self.x, str) or (isinstance(self.x, list) and isinstance(self.x[0], str)): 13 | self.x = if_string_convert_to_datetime(self.x) 14 | 15 | def plot(self, axes): 16 | label = self.name if self.show_legend else "" 17 | markeredgecolor = self.color["value"] if self.markeredgecolor is None else self.markeredgecolor["value"] 18 | markerfacecolor = self.color["value"] if self.markerfacecolor is None else self.markerfacecolor["value"] 19 | plot.plot(self.x, 20 | self.y, 21 | color=self.color["value"], 22 | marker=self.marker, 23 | markeredgecolor=markeredgecolor, 24 | markeredgewidth=self.markeredgewidth, 25 | markerfacecolor=markerfacecolor, 26 | lw=self.lineWidth, 27 | ms=self.markerSize, 28 | ls=self.lineStyle, 29 | markevery=self.markevery, 30 | alpha=self.alpha, 31 | label=label) 32 | plot.hold(True) 33 | -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/subplot.py: -------------------------------------------------------------------------------- 1 | from annotations import Text, Annotation 2 | from arc import Arc 3 | from histogram import Histogram 4 | from hline import Hline 5 | from line_2d import Line2D 6 | from vline import Vline 7 | 8 | 9 | class Subplot: 10 | def __init__(self, jsonDict): 11 | self.index = 1 12 | self.title = "" 13 | self.xtitle = "" 14 | self.ytitle = "" 15 | 16 | self.__dict__ = jsonDict 17 | 18 | self.items = [] 19 | if "__items__" in jsonDict: 20 | for item in jsonDict["__items__"]: 21 | if item["type"] == "Line2D": 22 | self.items.append(Line2D(item)) 23 | elif item["type"] == "Point2D": 24 | self.items.append(Line2D(item)) 25 | elif item["type"] == "Histogram": 26 | self.items.append(Histogram(item)) 27 | elif item["type"] == "Text": 28 | self.items.append(Text(item)) 29 | elif item["type"] == "Annotation": 30 | self.items.append(Annotation(item)) 31 | elif item["type"] == "Hline": 32 | self.items.append(Hline(item)) 33 | elif item["type"] == "Vline": 34 | self.items.append(Vline(item)) 35 | elif item["type"] == "Arc": 36 | self.items.append(Arc(item)) 37 | 38 | if "grid" in jsonDict: 39 | self.grid = Grid(jsonDict["grid"]) 40 | else: 41 | self.grid = Grid() 42 | 43 | 44 | class Grid: 45 | def __init__(self, jsonDict): 46 | self.which = 'both' 47 | self.minor_alfa = 0.4 48 | self.major_alfa = 0.5 49 | self.on = 'on' 50 | self.__dict__ = jsonDict -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/task.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | 3 | from line_2d import Line2D 4 | from subplot import Subplot 5 | 6 | 7 | class Task: 8 | def __init__(self, jsonDict): 9 | # set default values for most important properties 10 | self.dpi = 300 11 | self.w = 1920 12 | self.h = 1080 13 | self.rows = 1 14 | self.columns = 1 15 | 16 | # initialize object from json, received from c# process 17 | self.__dict__ = jsonDict 18 | 19 | self.subplots = [] 20 | if "__subplots__" in jsonDict: 21 | for subplotJson in jsonDict["__subplots__"]: 22 | self.subplots.append(Subplot(subplotJson)) 23 | -------------------------------------------------------------------------------- /PCI/PCI/MatplotlibCS/vline.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plot 2 | 3 | from line_2d import Line2D 4 | 5 | 6 | class Vline(Line2D): 7 | def __init__(self, jsonDict): 8 | self.__dict__ = jsonDict 9 | self.check_if_x_is_time() 10 | 11 | def plot(self, axes): 12 | label = self.name if self.show_legend else "" 13 | plot.vlines(self.x, 14 | self.ymin, 15 | self.ymax, 16 | color=self.color["value"], 17 | lw=self.lineWidth, 18 | linestyle=self.lineStyle, 19 | alpha=self.alpha, 20 | label=label) 21 | plot.hold(True) 22 | -------------------------------------------------------------------------------- /PCI/PCI/NewsFeaturesTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using ConsoleApplication1; 5 | using MathNet.Numerics.LinearAlgebra; 6 | using MathNet.Numerics.LinearAlgebra.Double; 7 | using Newtonsoft.Json; 8 | using PCI.pythonnet; 9 | using Python.Runtime; 10 | using Xunit; 11 | using Xunit.Abstractions; 12 | 13 | namespace PCI 14 | { 15 | public class NewsFeaturesTest 16 | { 17 | private readonly ITestOutputHelper _output; 18 | 19 | public NewsFeaturesTest(ITestOutputHelper output) 20 | { 21 | _output = output; 22 | } 23 | 24 | private void TestOutput(object obj) 25 | { 26 | _output.WriteLine(obj.ToString()); 27 | } 28 | 29 | [Fact] 30 | public void TestMakeMatrix() 31 | { 32 | var newsFeatures = new NewsFeatures(); 33 | (var allW,var artW,var artT) = newsFeatures.GetArticleWords(); 34 | (var wordMatrix,var wordVec) = newsFeatures.MakeMatrix(allW, artW); 35 | // 单词向量的前10个词 36 | TestOutput(JsonConvert.SerializeObject(wordVec.Take(10))); 37 | // 第二篇文章的标题 38 | TestOutput(artT[1]); 39 | // 第二篇文章的在单词矩阵中对应的数据行的前10个值 40 | TestOutput(JsonConvert.SerializeObject(wordMatrix[1].Take(10))); 41 | } 42 | 43 | [Fact] 44 | public void TestMathNet() 45 | { 46 | // 测试矩阵乘法 47 | var m1 = DenseMatrix.OfArray(new[,] { { 1d, 2d, 3d }, { 4d, 5d, 6d } }); 48 | TestOutput(m1); 49 | var m2 = DenseMatrix.OfArray(new[,] { { 1d, 2d }, { 3d, 4d }, { 5d, 6d } }); 50 | TestOutput(m2); 51 | TestOutput((m1 * m2).ToString()); 52 | 53 | //测试生成随机数组 54 | var mb = Matrix.Build; 55 | var rnd = new Random(); 56 | var mr = mb.Dense(2, 3, (i, j) => rnd.NextDouble()); 57 | TestOutput(mr); 58 | 59 | //测试矩阵转一维数组并由数组重构矩阵 60 | var arr = mr.AsColumnMajorArray(); 61 | TestOutput(JsonConvert.SerializeObject(arr)); 62 | 63 | var mback = mb.DenseOfColumnMajor(2, 3, arr); 64 | TestOutput(mback); 65 | 66 | //测试由行列表生成矩阵,并转换 67 | var rowList = new List>() 68 | { 69 | new List(){1, 2,3,4 }, 70 | new List(){5,6,7,8 }, 71 | new List(){9,10,11,12} 72 | }; 73 | var matrixFromRow = mb.DenseOfRows(rowList); 74 | var matrixFromRowToColumnArr = matrixFromRow.AsColumnMajorArray(); 75 | TestOutput(JsonConvert.SerializeObject(matrixFromRowToColumnArr)); 76 | } 77 | 78 | [Fact] 79 | public void TestFactorize() 80 | { 81 | var m1 = DenseMatrix.OfArray(new[,] { { 1d, 2d, 3d }, { 4d, 5d, 6d } }); 82 | var m2 = DenseMatrix.OfArray(new[,] { { 1d, 2d }, { 3d, 4d }, { 5d, 6d } }); 83 | var m12 = m1 * m2; 84 | TestOutput(m12); 85 | 86 | var nmf = new Nmf(o => TestOutput(o.ToString())); 87 | (var w, var h) = nmf.Factorize(m12, 3, 100); 88 | TestOutput(w); 89 | TestOutput(h); 90 | TestOutput(w * h); 91 | } 92 | 93 | [Fact] 94 | public void TestArticleFactorize() 95 | { 96 | var newsFeatures = new NewsFeatures(); 97 | (var allW, var artW, var artT) = newsFeatures.GetArticleWords(); 98 | (var wordMatrix, var wordVec) = newsFeatures.MakeMatrix(allW, artW); 99 | var nmf = new Nmf(o => TestOutput(o.ToString())); 100 | var matrix = DenseMatrix.OfRows(wordMatrix); 101 | (var weights, var feat) = nmf.Factorize(matrix, 20, 50); 102 | TestOutput(weights); 103 | TestOutput(feat); 104 | } 105 | 106 | [Fact] 107 | public void TestShowFeatures() 108 | { 109 | var newsFeatures = new NewsFeatures(); 110 | (var allW, var artW, var artT) = newsFeatures.GetArticleWords(); 111 | (var wordMatrix, var wordVec) = newsFeatures.MakeMatrix(allW, artW); 112 | var nmf = new Nmf(o => TestOutput(o.ToString())); 113 | var matrix = DenseMatrix.OfRows(wordMatrix); 114 | (var weights, var feat) = nmf.Factorize(matrix, 20, 50); 115 | newsFeatures.ShowFeatures(weights, feat, artT, wordVec); 116 | } 117 | 118 | [Fact] 119 | public void TestShowArticles() 120 | { 121 | var newsFeatures = new NewsFeatures(); 122 | (var allW, var artW, var artT) = newsFeatures.GetArticleWords(); 123 | (var wordMatrix, var wordVec) = newsFeatures.MakeMatrix(allW, artW); 124 | var nmf = new Nmf(o => TestOutput(o.ToString())); 125 | var matrix = DenseMatrix.OfRows(wordMatrix); 126 | (var weights, var feat) = nmf.Factorize(matrix, 20, 50); 127 | (var topPatterns, var patternNames) = newsFeatures.ShowFeatures(weights, feat, artT, wordVec); 128 | newsFeatures.ShowArticles(artT, topPatterns, patternNames); 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /PCI/PCI/Nmf.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using MathNet.Numerics.LinearAlgebra; 8 | using MathNet.Numerics.LinearAlgebra.Double; 9 | 10 | namespace PCI 11 | { 12 | public class Nmf 13 | { 14 | private readonly Action _outputWriter; 15 | 16 | public Nmf(Action outputAction) 17 | { 18 | _outputWriter = outputAction; 19 | } 20 | 21 | private double DifCost(DenseMatrix a, Matrix b) 22 | { 23 | var dif = 0d; 24 | // 遍历矩阵中的每一行和每一列 25 | for (int i = 0; i < a.RowCount; i++) 26 | { 27 | for (int j = 0; j < a.ColumnCount; j++) 28 | { 29 | //将差值相加 30 | dif += Math.Pow(a[i, j] - b[i, j], 2); 31 | } 32 | } 33 | return dif; 34 | } 35 | 36 | 37 | public (Matrix, Matrix) Factorize(DenseMatrix v, int pc = 10, int iter = 50) 38 | { 39 | var ic = v.RowCount; 40 | var fc = v.ColumnCount; 41 | 42 | //以随机值初始化权重矩阵和特征矩阵 43 | var mb = Matrix.Build; 44 | var rndGen = new Random(DateTime.Now.Second); 45 | var w = mb.Dense(ic,pc, (i, j) => rndGen.NextDouble()); 46 | var h = mb.Dense(pc,fc, (i, j)=> rndGen.NextDouble()); 47 | 48 | // 最多执行iter次操作 49 | for (int i = 0; i < iter; i++) 50 | { 51 | var wh = w * h; 52 | // 计算当前查值 53 | var cost = DifCost(v, wh); 54 | if (i % 10 == 0) 55 | _outputWriter(cost); 56 | //如果矩阵已分解彻底,终止循环 57 | if (cost == 0) 58 | break; 59 | //更新特征矩阵 60 | var hn = w.Transpose() * v; 61 | var hd = w.Transpose() * w * h; 62 | h = DenseMatrix.OfColumnMajor(pc, fc, 63 | h.AsColumnMajorArray().Multiple(hn.AsColumnMajorArray()).Divide(hd.AsColumnMajorArray())); 64 | 65 | //更新权重矩阵 66 | var wn = v * h.Transpose(); 67 | var wd = w * h * h.Transpose(); 68 | w = DenseMatrix.OfColumnMajor(ic, pc, 69 | w.AsColumnMajorArray().Multiple(wn.AsColumnMajorArray()).Divide(wd.AsColumnMajorArray())); 70 | } 71 | return (w, h); 72 | } 73 | 74 | } 75 | 76 | public static class DoubleArrayExt 77 | { 78 | public static double[] Multiple(this double[] left, double[] right) 79 | { 80 | return left.Select((l, i) => l * right[i]).ToArray(); 81 | } 82 | 83 | public static double[] Divide(this double[] left, double[] right) 84 | { 85 | return left.Select((l, i) => l / (right[i]==0?double.MinValue:right[i])).ToArray(); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /PCI/PCI/NumPredictTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ConsoleApplication1 8 | { 9 | class NumPredictTest 10 | { 11 | //var numPredict = new NumPredict(); 12 | //var data = numPredict.WineSet3(); 13 | //var prob = numPredict.ProbGuess(data, new[] { 99d, 20 }, 40, 80); 14 | //Console.WriteLine(prob); 15 | //prob = numPredict.ProbGuess(data, new[] { 99d, 20 }, 80, 120); 16 | //Console.WriteLine(prob); 17 | //prob = numPredict.ProbGuess(data, new[] { 99d, 20 }, 120, 1000); 18 | //Console.WriteLine(prob); 19 | //prob = numPredict.ProbGuess(data, new[] { 99d, 20 }, 30, 120); 20 | //Console.WriteLine(prob); 21 | 22 | //var imager = new CoordinateHelper(); 23 | //imager.DrawCoordinate("-Math.PI", "Math.PI", "Math.Sin(x)"); 24 | 25 | //var numPredict = new NumPredict(); 26 | //var axes = numPredict.BuildAxes(); 27 | //numPredict.Draw(axes); 28 | 29 | //var numPredict = new NumPredict(); 30 | //var data = numPredict.WineSet3(); 31 | //numPredict.CumulativeGraph(data, new []{1d,1},120); 32 | 33 | 34 | //var numPredict = new NumPredict(); 35 | //var data = numPredict.WineSet3(); 36 | //numPredict.ProbabilityGraph(data, new[] { 1d, 1 }, 120); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PCI/PCI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("ConsoleApplication1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConsoleApplication1")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("b1857d90-67f1-49dd-a5db-b30163ab208f")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /PCI/PCI/libsvm.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/PCI/PCI/libsvm.dll -------------------------------------------------------------------------------- /PCI/PCI/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | blog_sample_codes 2 | ================= 3 | 4 | code sample for my blog at cnblogs.com -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Windows.ApplicationModel; 4 | using Windows.ApplicationModel.Activation; 5 | using Windows.Globalization; 6 | using Windows.UI.Xaml; 7 | using Windows.UI.Xaml.Controls; 8 | using Windows.UI.Xaml.Navigation; 9 | using GalaSoft.MvvmLight.Views; 10 | 11 | // “空白应用程序”模板在 http://go.microsoft.com/fwlink/?LinkId=234227 上有介绍 12 | 13 | namespace Win81Demo.Controls.Sample 14 | { 15 | /// 16 | /// 提供特定于应用程序的行为,以补充默认的应用程序类。 17 | /// 18 | sealed partial class App : Application 19 | { 20 | /// 21 | /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行, 22 | /// 已执行,逻辑上等同于 main() 或 WinMain()。 23 | /// 24 | public App() 25 | { 26 | this.InitializeComponent(); 27 | this.Suspending += OnSuspending; 28 | } 29 | 30 | /// 31 | /// 在应用程序由最终用户正常启动时进行调用。 32 | /// 将在启动应用程序以打开特定文件等情况下使用。 33 | /// 34 | /// 有关启动请求和过程的详细信息。 35 | protected override void OnLaunched(LaunchActivatedEventArgs e) 36 | { 37 | 38 | #if DEBUG 39 | if (Debugger.IsAttached) 40 | { 41 | this.DebugSettings.EnableFrameRateCounter = true; 42 | } 43 | #endif 44 | 45 | Frame rootFrame = Window.Current.Content as Frame; 46 | 47 | // 不要在窗口已包含内容时重复应用程序初始化, 48 | // 只需确保窗口处于活动状态 49 | if (rootFrame == null) 50 | { 51 | // 创建要充当导航上下文的框架,并导航到第一页 52 | rootFrame = new Frame(); 53 | //设置默认语言 54 | rootFrame.Language = ApplicationLanguages.Languages[0]; 55 | 56 | rootFrame.NavigationFailed += OnNavigationFailed; 57 | 58 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 59 | { 60 | //TODO: 从之前挂起的应用程序加载状态 61 | } 62 | 63 | // 将框架放在当前窗口中 64 | Window.Current.Content = rootFrame; 65 | } 66 | 67 | if (rootFrame.Content == null) 68 | { 69 | // 当导航堆栈尚未还原时,导航到第一页, 70 | // 并通过将所需信息作为导航参数传入来配置 71 | // 参数 72 | rootFrame.Navigate(typeof(MainPage), e.Arguments); 73 | } 74 | // 确保当前窗口处于活动状态 75 | Window.Current.Activate(); 76 | } 77 | 78 | /// 79 | ///导航到特定页失败时调用 80 | /// 81 | ///导航失败的框架 82 | ///有关导航失败的详细信息 83 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 84 | { 85 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName); 86 | } 87 | 88 | /// 89 | /// 在将要挂起应用程序执行时调用。 在不知道应用程序 90 | /// 无需知道应用程序会被终止还是会恢复, 91 | /// 并让内存内容保持不变。 92 | /// 93 | /// 挂起的请求的源。 94 | /// 有关挂起请求的详细信息。 95 | private void OnSuspending(object sender, SuspendingEventArgs e) 96 | { 97 | var deferral = e.SuspendingOperation.GetDeferral(); 98 | //TODO: 保存应用程序状态并停止任何后台活动 99 | deferral.Complete(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Assets/Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/Win81Demo/Win81Demo.Controls.Sample/Assets/Logo.scale-100.png -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Assets/SmallLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/Win81Demo/Win81Demo.Controls.Sample/Assets/SmallLogo.scale-100.png -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/Win81Demo/Win81Demo.Controls.Sample/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/Win81Demo/Win81Demo.Controls.Sample/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上有介绍 17 | 18 | namespace Win81Demo.Controls.Sample 19 | { 20 | /// 21 | /// 可用于自身或导航至 Frame 内部的空白页。 22 | /// 23 | public sealed partial class MainPage : Page 24 | { 25 | public MainPage() 26 | { 27 | this.InitializeComponent(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | Win81Demo.Controls.Sample 10 | Kun 11 | Assets\StoreLogo.png 12 | 13 | 14 | 15 | 6.3.0 16 | 6.3.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("Win81Demo.Controls.Sample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Win81Demo.Controls.Sample")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 程序集的版本信息由下列四个值组成: 18 | // 19 | // 主版本 20 | // 次版本 21 | // 生成号 22 | // 修订号 23 | // 24 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 25 | // 方法是按如下所示使用“*”: : 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/View/CircleMenuSample.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 16 | 17 | 18 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/View/CircleMenuSample.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上有介绍 17 | 18 | namespace Win81Demo.Controls.Sample.View 19 | { 20 | /// 21 | /// 可用于自身或导航至 Frame 内部的空白页。 22 | /// 23 | public sealed partial class CircleMenuSample : Page 24 | { 25 | public CircleMenuSample() 26 | { 27 | this.InitializeComponent(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/ViewModel/CircleMenuSampleViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Windows.UI.Xaml; 8 | using GalaSoft.MvvmLight; 9 | using GalaSoft.MvvmLight.Command; 10 | using GalaSoft.MvvmLight.Views; 11 | using Win81Demo.Controls.CircleMenuControl; 12 | 13 | namespace Win81Demo.Controls.Sample.ViewModel 14 | { 15 | public class CircleMenuSampleViewModel : ViewModelBase 16 | { 17 | private readonly IDialogService _dialogService; 18 | 19 | public CircleMenuSampleViewModel(IDialogService dialogService) 20 | { 21 | _dialogService = dialogService; 22 | 23 | SubMenuItems = new ObservableCollection( 24 | new List() 25 | { 26 | new CircleMenuItem() {Id = 1, Title = "一"}, 27 | new CircleMenuItem() {Id = 2, Title = "城"}, 28 | new CircleMenuItem() {Id = 3, Title = "山"}, 29 | new CircleMenuItem() {Id = 4, Title = "色"}, 30 | new CircleMenuItem() {Id = 5, Title = "半"}, 31 | new CircleMenuItem() {Id = 6, Title = "城"}, 32 | new CircleMenuItem() {Id = 7, Title = "湖"}, 33 | }); 34 | } 35 | 36 | private ObservableCollection _subMenuItems; 37 | 38 | public ObservableCollection SubMenuItems 39 | { 40 | 41 | get 42 | { 43 | if (_subMenuItems == null) _subMenuItems = new ObservableCollection(); 44 | return _subMenuItems; 45 | } 46 | 47 | set { Set(() => SubMenuItems, ref _subMenuItems, value); } 48 | 49 | } 50 | 51 | public Action SubMenuClickCommand 52 | { 53 | get 54 | { 55 | return subMenuId => 56 | { 57 | _dialogService.ShowMessage(subMenuId.ToString(), "子菜单编号"); 58 | }; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/ViewModel/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml; 3 | using Windows.UI.Xaml.Controls; 4 | using GalaSoft.MvvmLight; 5 | using GalaSoft.MvvmLight.Command; 6 | using GalaSoft.MvvmLight.Views; 7 | 8 | namespace Win81Demo.Controls.Sample.ViewModel 9 | { 10 | /// 11 | /// This class contains properties that the main View can data bind to. 12 | /// 13 | /// Use the mvvminpc snippet to add bindable properties to this ViewModel. 14 | /// 15 | /// 16 | /// You can also use Blend to data bind with the tool's support. 17 | /// 18 | /// 19 | /// See http://www.galasoft.ch/mvvm 20 | /// 21 | /// 22 | public class MainViewModel : ViewModelBase 23 | { 24 | 25 | private readonly INavigationService _navigationService; 26 | /// 27 | /// Initializes a new instance of the MainViewModel class. 28 | /// 29 | public MainViewModel(INavigationService navigationService) 30 | { 31 | _navigationService = navigationService; 32 | } 33 | 34 | private RelayCommand _sampleClickCommand; 35 | 36 | 37 | public RelayCommand SampleClickCommand 38 | { 39 | get 40 | { 41 | return _sampleClickCommand 42 | ?? (_sampleClickCommand = new RelayCommand( 43 | p => 44 | { 45 | var destPage = string.Empty; 46 | switch (Convert.ToInt32(p)) 47 | { 48 | case 1: 49 | destPage = "CircleMenu"; 50 | break; 51 | } 52 | 53 | _navigationService.NavigateTo(destPage); 54 | 55 | })); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/ViewModel/ViewModelLocator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | In App.xaml: 3 | 4 | 6 | 7 | 8 | In the View: 9 | DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}" 10 | 11 | You can also use Blend to do all this with the tool's support. 12 | See http://www.galasoft.ch/mvvm 13 | */ 14 | 15 | using GalaSoft.MvvmLight; 16 | using GalaSoft.MvvmLight.Ioc; 17 | using GalaSoft.MvvmLight.Views; 18 | using Microsoft.Practices.ServiceLocation; 19 | using Win81Demo.Controls.Sample.View; 20 | 21 | namespace Win81Demo.Controls.Sample.ViewModel 22 | { 23 | /// 24 | /// This class contains static references to all the view models in the 25 | /// application and provides an entry point for the bindings. 26 | /// 27 | public class ViewModelLocator 28 | { 29 | /// 30 | /// Initializes a new instance of the ViewModelLocator class. 31 | /// 32 | public ViewModelLocator() 33 | { 34 | ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); 35 | 36 | SimpleIoc.Default.Register(CreateNavigationService); 37 | SimpleIoc.Default.Register(); 38 | SimpleIoc.Default.Register(); 39 | SimpleIoc.Default.Register(); 40 | } 41 | 42 | private INavigationService CreateNavigationService() 43 | { 44 | var navigationService = new NavigationService(); 45 | navigationService.Configure("CircleMenu", typeof(CircleMenuSample)); 46 | 47 | return navigationService; 48 | } 49 | 50 | public MainViewModel Main { get { return ServiceLocator.Current.GetInstance(); } } 51 | public CircleMenuSampleViewModel CircleMenuSampleVm { get { return ServiceLocator.Current.GetInstance(); } } 52 | 53 | public static void Cleanup() 54 | { 55 | // TODO Clear the ViewModels 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/Win81Demo.Controls.Sample_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/Win81Demo/Win81Demo.Controls.Sample/Win81Demo.Controls.Sample_TemporaryKey.pfx -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls/CircleMenuControl/CircleMenu.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 75 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls/CircleMenuControl/CircleMenuItem.cs: -------------------------------------------------------------------------------- 1 | namespace Win81Demo.Controls.CircleMenuControl 2 | { 3 | public class CircleMenuItem 4 | { 5 | public CircleMenuItem() 6 | { 7 | } 8 | 9 | public CircleMenuItem(int id, string title) 10 | { 11 | Id = id; 12 | Title = title; 13 | 14 | } 15 | 16 | public int Id { get; set; } 17 | 18 | public string Title { get; set; } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("Win81Demo.Controls")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Win81Demo.Controls")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 程序集的版本信息由下列四个值组成: 18 | // 19 | // 主版本 20 | // 次版本 21 | // 生成号 22 | // 修订号 23 | // 24 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 25 | // 方法是按如下所示使用“*”: : 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.Controls/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Win81Demo/Win81Demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win81Demo.Controls.Sample", "Win81Demo.Controls.Sample\Win81Demo.Controls.Sample.csproj", "{8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win81Demo.Controls", "Win81Demo.Controls\Win81Demo.Controls.csproj", "{AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|ARM = Debug|ARM 14 | Debug|x64 = Debug|x64 15 | Debug|x86 = Debug|x86 16 | Release|Any CPU = Release|Any CPU 17 | Release|ARM = Release|ARM 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 25 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|ARM.ActiveCfg = Debug|ARM 26 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|ARM.Build.0 = Debug|ARM 27 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|ARM.Deploy.0 = Debug|ARM 28 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|x64.ActiveCfg = Debug|x64 29 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|x64.Build.0 = Debug|x64 30 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|x64.Deploy.0 = Debug|x64 31 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|x86.ActiveCfg = Debug|x86 32 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|x86.Build.0 = Debug|x86 33 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Debug|x86.Deploy.0 = Debug|x86 34 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|Any CPU.Deploy.0 = Release|Any CPU 37 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|ARM.ActiveCfg = Release|ARM 38 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|ARM.Build.0 = Release|ARM 39 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|ARM.Deploy.0 = Release|ARM 40 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|x64.ActiveCfg = Release|x64 41 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|x64.Build.0 = Release|x64 42 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|x64.Deploy.0 = Release|x64 43 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|x86.ActiveCfg = Release|x86 44 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|x86.Build.0 = Release|x86 45 | {8CB0315D-7B68-4A3D-B005-3B9A7CFC5126}.Release|x86.Deploy.0 = Release|x86 46 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|ARM.ActiveCfg = Debug|ARM 49 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|ARM.Build.0 = Debug|ARM 50 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|x64.ActiveCfg = Debug|x64 51 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|x64.Build.0 = Debug|x64 52 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|x86.ActiveCfg = Debug|x86 53 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Debug|x86.Build.0 = Debug|x86 54 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|Any CPU.Build.0 = Release|Any CPU 56 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|ARM.ActiveCfg = Release|ARM 57 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|ARM.Build.0 = Release|ARM 58 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|x64.ActiveCfg = Release|x64 59 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|x64.Build.0 = Release|x64 60 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|x86.ActiveCfg = Release|x86 61 | {AEF1BD3C-0B3A-45F4-9A06-940CC0F5E66E}.Release|x86.Build.0 = Release|x86 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | EndGlobal 67 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/App.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace Wpf.Control.Sample 10 | { 11 | /// 12 | /// App.xaml 的交互逻辑 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Design/DesignDataService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Wpf.Control.Sample.Model; 3 | 4 | namespace Wpf.Control.Sample.Design 5 | { 6 | public class DesignDataService : IDataService 7 | { 8 | public void GetData(Action callback) 9 | { 10 | // Use this to create design time data 11 | 12 | var item = new DataItem("Welcome to MVVM Light [design]"); 13 | callback(item, null); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Model/DataItem.cs: -------------------------------------------------------------------------------- 1 | namespace Wpf.Control.Sample.Model 2 | { 3 | public class DataItem 4 | { 5 | public DataItem(string title) 6 | { 7 | Title = title; 8 | } 9 | 10 | public string Title 11 | { 12 | get; 13 | private set; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Model/DataService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Wpf.Control.Sample.Model 4 | { 5 | public class DataService : IDataService 6 | { 7 | public void GetData(Action callback) 8 | { 9 | // Use this to connect to the actual data service 10 | 11 | var item = new DataItem("Welcome to MVVM Light"); 12 | callback(item, null); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Model/IDataService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Wpf.Control.Sample.Model 4 | { 5 | public interface IDataService 6 | { 7 | void GetData(Action callback); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的常规信息通过以下 8 | // 特性集控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("Wpf.Control.Sample")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Wpf.Control.Sample")] 15 | [assembly: AssemblyCopyright("Copyright © hystar 2015")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // 将 ComVisible 设置为 false 使此程序集中的类型 20 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 21 | // 则将该类型上的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请在 25 | // 中的 .csproj 文件中 26 | //设置 CultureYouAreCodingWith。 例如,如果您在源文件中 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(在页面或应用程序资源词典中 37 | // 未找到某个资源的情况下使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(在页面、应用程序或任何主题特定资源词典中 40 | // 未找到某个资源的情况下使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下面四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 52 | // 方法是按如下所示使用“*”: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Wpf.Control.Sample.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Wpf.Control.Sample.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Wpf.Control.Sample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/ViewModel/CircleMenuSampleViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Windows; 4 | using GalaSoft.MvvmLight; 5 | using GalaSoft.MvvmLight.CommandWpf; 6 | using Wpf.Control.Flow; 7 | using Wpf.Control.Sample.Model; 8 | using Wpf.Control.CircleMenu; 9 | 10 | namespace Wpf.Control.Sample.ViewModel 11 | { 12 | /// 13 | /// This class contains properties that a View can data bind to. 14 | /// 15 | /// See http://www.galasoft.ch/mvvm 16 | /// 17 | /// 18 | public class CircleMenuSampleViewModel : ViewModelBase 19 | { 20 | private readonly IDataService _dataService; 21 | 22 | /// 23 | /// Initializes a new instance of the CircleMenuSampleViewModel class. 24 | /// 25 | public CircleMenuSampleViewModel(IDataService dataService) 26 | { 27 | _dataService = dataService; 28 | _dataService.GetData( 29 | (item, error) => 30 | { 31 | if (error != null) 32 | { 33 | // Report error here 34 | return; 35 | } 36 | 37 | SubMenuItems = new ObservableCollection( 38 | new List() 39 | { 40 | new CircleMenuItem() {Id = 1, Title = "衣"}, 41 | new CircleMenuItem() {Id = 2, Title = "带"}, 42 | new CircleMenuItem() {Id = 3, Title = "渐"}, 43 | new CircleMenuItem() {Id = 4, Title = "宽"}, 44 | new CircleMenuItem() {Id = 5, Title = "终"}, 45 | new CircleMenuItem() {Id = 6, Title = "不"}, 46 | new CircleMenuItem() {Id = 7, Title = "悔"}, 47 | new CircleMenuItem() {Id = 8, Title = "为"}, 48 | new CircleMenuItem() {Id = 9, Title = "伊"}, 49 | new CircleMenuItem() {Id = 10, Title = "消"}, 50 | new CircleMenuItem() {Id = 11, Title = "得"}, 51 | new CircleMenuItem() {Id = 12, Title = "人"}, 52 | new CircleMenuItem() {Id = 13, Title = "憔"}, 53 | new CircleMenuItem() {Id = 14, Title = "悴"} 54 | }); 55 | }); 56 | 57 | } 58 | 59 | private ObservableCollection _subMenuItems; 60 | 61 | public ObservableCollection SubMenuItems 62 | { 63 | get { return _subMenuItems; } 64 | set { Set(() => SubMenuItems, ref _subMenuItems, value); } 65 | } 66 | 67 | private RelayCommand _nodeClickCommand; 68 | 69 | public RelayCommand NodeClickCommand 70 | { 71 | get 72 | { 73 | return _nodeClickCommand 74 | ?? (_nodeClickCommand = new RelayCommand( 75 | p => 76 | { 77 | var dataItem = ((FrameworkElement)p.OriginalSource).DataContext; 78 | MessageBox.Show(((CircleMenuItem)dataItem).Id.ToString()); 79 | 80 | var circleCtrl = (CircleMenuControl)p.Source; 81 | var suc = VisualStateManager.GoToState(circleCtrl, CircleMenuControl.VisualStateCollapsed, false); 82 | var bb = 1; 83 | })); 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/ViewModel/FlowSampleViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Windows; 4 | using GalaSoft.MvvmLight; 5 | using GalaSoft.MvvmLight.Command; 6 | using Wpf.Control.Flow; 7 | using Wpf.Control.Sample.Model; 8 | 9 | namespace Wpf.Control.Sample.ViewModel 10 | { 11 | public class FlowSampleViewModel : ViewModelBase 12 | { 13 | private readonly IDataService _dataService; 14 | 15 | public FlowSampleViewModel(IDataService dataService) 16 | { 17 | _dataService = dataService; 18 | _dataService.GetData( 19 | (item, error) => 20 | { 21 | if (error != null) 22 | { 23 | // Report error here 24 | return; 25 | } 26 | 27 | Nodes = new ObservableCollection( 28 | 29 | new List() 30 | { 31 | new FlowItem() {Id = 1, OffsetRate = 0, Title = "接到报修"}, 32 | new FlowItem() {Id = 2, OffsetRate = 0.5, Title = "派工完成"}, 33 | new FlowItem() {Id = 3, OffsetRate = 0.75, Title = "维修完成"}, 34 | new FlowItem() {Id = 3, OffsetRate = 1, Title = "客户确认(我是特别长的标题)"}, 35 | } 36 | ); 37 | }); 38 | } 39 | 40 | private ObservableCollection _nodes; 41 | 42 | public ObservableCollection Nodes 43 | { 44 | get { return _nodes; } 45 | set { Set(() => Nodes, ref _nodes, value); } 46 | } 47 | 48 | private RelayCommand _nodeClickCommand; 49 | 50 | /// 51 | /// Gets the NodeClickCommand. 52 | /// 53 | public RelayCommand NodeClickCommand 54 | { 55 | get 56 | { 57 | return _nodeClickCommand 58 | ?? (_nodeClickCommand = new RelayCommand( 59 | p => 60 | { 61 | var aa = p; 62 | MessageBox.Show(((FlowNodeControl)aa.OriginalSource).NodeTitle); 63 | })); 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/ViewModel/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using GalaSoft.MvvmLight; 5 | using GalaSoft.MvvmLight.Command; 6 | 7 | namespace Wpf.Control.Sample.ViewModel 8 | { 9 | public class MainViewModel : ViewModelBase 10 | { 11 | 12 | /// 13 | /// Initializes a new instance of the MainViewModel class. 14 | /// 15 | public MainViewModel() 16 | { 17 | 18 | } 19 | 20 | private RelayCommand _sampleClickCommand; 21 | 22 | 23 | public RelayCommand SampleClickCommand 24 | { 25 | get 26 | { 27 | return _sampleClickCommand 28 | ?? (_sampleClickCommand = new RelayCommand( 29 | p => 30 | { 31 | var destPage = string.Empty; 32 | switch (Convert.ToInt32(p)) 33 | { 34 | case 1: 35 | destPage = "Views/FlowSample.xaml"; 36 | break; 37 | case 2: 38 | destPage = "Views/CircleMenuSample.xaml"; 39 | break; 40 | } 41 | 42 | var frame = ((Frame)((FrameworkElement)Application.Current.MainWindow.Content).FindName("SampleContainer")); 43 | frame.Navigate(new Uri(destPage, UriKind.Relative)); 44 | 45 | })); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/ViewModel/ViewModelLocator.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using GalaSoft.MvvmLight.Ioc; 3 | using Microsoft.Practices.ServiceLocation; 4 | using Wpf.Control.Sample.Design; 5 | using Wpf.Control.Sample.Model; 6 | 7 | namespace Wpf.Control.Sample.ViewModel 8 | { 9 | /// 10 | /// This class contains static references to all the view models in the 11 | /// application and provides an entry point for the bindings. 12 | /// 13 | /// See http://www.galasoft.ch/mvvm 14 | /// 15 | /// 16 | public class ViewModelLocator 17 | { 18 | static ViewModelLocator() 19 | { 20 | ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); 21 | 22 | if (ViewModelBase.IsInDesignModeStatic) 23 | { 24 | SimpleIoc.Default.Register(); 25 | } 26 | else 27 | { 28 | SimpleIoc.Default.Register(); 29 | } 30 | 31 | SimpleIoc.Default.Register(); 32 | SimpleIoc.Default.Register(); 33 | SimpleIoc.Default.Register(); 34 | } 35 | 36 | public MainViewModel Main { get { return ServiceLocator.Current.GetInstance(); } } 37 | public FlowSampleViewModel FlowSampleVm { get{return ServiceLocator.Current.GetInstance();} } 38 | public CircleMenuSampleViewModel CircleMenuSampleVm { get { return ServiceLocator.Current.GetInstance();}} 39 | 40 | /// 41 | /// Cleans up all the resources. 42 | /// 43 | public static void Cleanup() 44 | { 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Views/CircleMenuSample.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Views/CircleMenuSample.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Wpf.Control.Sample.Views 17 | { 18 | /// 19 | /// CircleMenuSample.xaml 的交互逻辑 20 | /// 21 | public partial class CircleMenuSample : Page 22 | { 23 | public CircleMenuSample() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Views/FlowSample.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Views/FlowSample.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Wpf.Control.Sample.Views 17 | { 18 | /// 19 | /// FlowNodeSample.xaml 的交互逻辑 20 | /// 21 | public partial class FlowSample : Page 22 | { 23 | public FlowSample() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Views/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/Views/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Wpf.Control.Sample.Views 4 | { 5 | /// 6 | /// MainWindow.xaml 的交互逻辑 7 | /// 8 | public partial class MainWindow : Window 9 | { 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/CircleMenu/CircleMenuControl.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Controls.Primitives; 4 | using System.Windows.Media; 5 | using Wpf.Control.Flow; 6 | 7 | namespace Wpf.Control.CircleMenu 8 | { 9 | [TemplatePart(Name = PartCenterBtn)] 10 | [TemplatePart(Name = PartContainer)] 11 | [TemplatePart(Name = PartPanelPresenter)] 12 | [TemplateVisualState(GroupName = "CommonStates", Name = VisualStateInitial)] 13 | [TemplateVisualState(GroupName = "CommonStates", Name = VisualStateExpanded)] 14 | [TemplateVisualState(GroupName = "CommonStates", Name = VisualStateCollapsed)] 15 | public class CircleMenuControl : ItemsControl 16 | { 17 | private const string PartCenterBtn = "PART_CenterBtn"; 18 | private const string PartContainer = "PART_Container"; 19 | private const string PartPanelPresenter = "PART_PanelPresenter"; 20 | public const string VisualStateInitial = "Initial"; 21 | public const string VisualStateExpanded = "Expanded"; 22 | public const string VisualStateCollapsed = "Collapsed"; 23 | 24 | static CircleMenuControl() 25 | { 26 | DefaultStyleKeyProperty.OverrideMetadata(typeof(CircleMenuControl), new FrameworkPropertyMetadata(typeof(CircleMenuControl))); 27 | } 28 | 29 | #region dependency property 30 | 31 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( 32 | "Angle", typeof(double), typeof(CircleMenuControl), new PropertyMetadata(360d)); 33 | 34 | public double Angle 35 | { 36 | get { return (double)GetValue(AngleProperty); } 37 | set { SetValue(AngleProperty, value); } 38 | } 39 | 40 | #endregion 41 | 42 | private Border _centerBtn; 43 | private Grid _container; 44 | private CircleMenuPanel _circleMenuPanel; 45 | private CircleMenuItemsPresenter _circleMenuItemsPresenter; 46 | 47 | public override void OnApplyTemplate() 48 | { 49 | if (_centerBtn != null) 50 | { 51 | _centerBtn.MouseLeftButtonUp -= centerBtn_Click; 52 | } 53 | 54 | base.OnApplyTemplate(); 55 | 56 | _centerBtn = GetTemplateChild(PartCenterBtn) as Border; 57 | _container = GetTemplateChild(PartContainer) as Grid; 58 | _circleMenuItemsPresenter = GetTemplateChild(PartPanelPresenter) as CircleMenuItemsPresenter; 59 | 60 | if (_centerBtn != null) 61 | { 62 | _centerBtn.MouseLeftButtonUp += centerBtn_Click; 63 | } 64 | } 65 | 66 | private void centerBtn_Click(object sender, RoutedEventArgs e) 67 | { 68 | //第一个参数是所在元素的父元素,本控件中为Grid的父级,即控件本身 69 | switch (_circleMenuItemsPresenter.Status) 70 | { 71 | case CircleMenuStatus.Expanded: 72 | VisualStateManager.GoToState(this, VisualStateCollapsed, false); 73 | break; 74 | case CircleMenuStatus.Initial: 75 | case CircleMenuStatus.Collapsed: 76 | VisualStateManager.GoToState(this, VisualStateExpanded, false); 77 | break; 78 | } 79 | 80 | //如果只是在控件内部更改Panel状态可以直接设置ItemPresenter的Status 81 | //使用VisualStateManager是为了可以在外部通过更改状态更新面板 82 | } 83 | 84 | #region route event 85 | 86 | //route event 87 | 88 | //inner menu click 89 | public static readonly RoutedEvent SubMenuClickEvent = 90 | ButtonBase.ClickEvent.AddOwner(typeof (CircleMenuControl)); 91 | 92 | public event RoutedEventHandler SubMenuClick 93 | { 94 | add { AddHandler(ButtonBase.ClickEvent, value, false); } 95 | remove { RemoveHandler(ButtonBase.ClickEvent, value); } 96 | } 97 | 98 | #endregion 99 | 100 | } 101 | 102 | public enum CircleMenuStatus : byte 103 | { 104 | Initial, 105 | Expanded, 106 | Collapsed, 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/CircleMenu/CircleMenuItem.cs: -------------------------------------------------------------------------------- 1 | namespace Wpf.Control.CircleMenu 2 | { 3 | public class CircleMenuItem 4 | { 5 | public CircleMenuItem() 6 | { 7 | } 8 | 9 | public CircleMenuItem(int id, string title,double offsetRate) 10 | { 11 | Id = id; 12 | Title = title; 13 | } 14 | 15 | public int Id { get; set; } 16 | 17 | public string Title { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/CircleMenu/CircleMenuItemsPresenter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | 9 | namespace Wpf.Control.CircleMenu 10 | { 11 | public class CircleMenuItemsPresenter:ItemsPresenter 12 | { 13 | public static readonly DependencyProperty StatusProperty = DependencyProperty.Register( 14 | "Status", typeof (CircleMenuStatus), typeof (CircleMenuItemsPresenter), new PropertyMetadata(default(CircleMenuStatus))); 15 | 16 | public CircleMenuStatus Status 17 | { 18 | get { return (CircleMenuStatus) GetValue(StatusProperty); } 19 | set { SetValue(StatusProperty, value); } 20 | } 21 | 22 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( 23 | "Angle", typeof(Double), typeof(CircleMenuItemsPresenter), new PropertyMetadata(360d)); 24 | 25 | public double Angle 26 | { 27 | get { return (Double)GetValue(AngleProperty); } 28 | set { SetValue(AngleProperty, value); } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/FlowControl.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Wpf.Control.Flow 5 | { 6 | public class FlowControl : ItemsControl 7 | { 8 | 9 | static FlowControl() 10 | { 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(FlowControl), new FrameworkPropertyMetadata(typeof(FlowControl))); 12 | } 13 | 14 | #region dependency property 15 | 16 | private const double NodeWidthDefault = 30; 17 | 18 | public static readonly DependencyProperty NodeWidthProperty = DependencyProperty.Register( 19 | "NodeWidth", typeof(double), typeof(FlowControl), 20 | new PropertyMetadata(NodeWidthDefault)); 21 | 22 | public double NodeWidth 23 | { 24 | get { return (double)GetValue(NodeWidthProperty); } 25 | set 26 | { 27 | SetValue(NodeWidthProperty, value); 28 | } 29 | } 30 | 31 | private const double BarHeightDefault = 10; 32 | 33 | public static readonly DependencyProperty BarHeightProperty = DependencyProperty.Register( 34 | "BarHeight", typeof(double), typeof(FlowControl), new PropertyMetadata(BarHeightDefault)); 35 | 36 | public double BarHeight 37 | { 38 | get { return (double)GetValue(BarHeightProperty); } 39 | set { SetValue(BarHeightProperty, value); } 40 | } 41 | 42 | public static readonly DependencyProperty BarMarginLeftProperty = DependencyProperty.Register( 43 | "BarMarginLeft", typeof(double), typeof(FlowControl), new PropertyMetadata(0.0)); 44 | 45 | public double BarMarginLeft 46 | { 47 | get { return (double)GetValue(BarMarginLeftProperty); } 48 | set { SetValue(BarMarginLeftProperty, value); } 49 | } 50 | 51 | public static readonly DependencyProperty BarMarginTopProperty = DependencyProperty.Register( 52 | "BarMarginTop", typeof(double), typeof(FlowControl), new PropertyMetadata(default(double))); 53 | 54 | private double BarMarginTop 55 | { 56 | get { return (double)GetValue(BarMarginTopProperty); } 57 | set { SetValue(BarMarginTopProperty, value); } 58 | } 59 | 60 | public static readonly DependencyProperty ShadowWidthProperty = DependencyProperty.Register( 61 | "ShadowWidth", typeof(double), typeof(FlowControl), new PropertyMetadata(default(double))); 62 | 63 | private double ShadowWidth 64 | { 65 | get { return (double)GetValue(ShadowWidthProperty); } 66 | set { SetValue(ShadowWidthProperty, value); } 67 | } 68 | 69 | public static readonly DependencyProperty AnimationDurationProperty = DependencyProperty.Register( 70 | "AnimationDuration", typeof(Duration), typeof(FlowControl), new PropertyMetadata(default(Duration))); 71 | 72 | public Duration AnimationDuration 73 | { 74 | get { return (Duration)GetValue(AnimationDurationProperty); } 75 | set { SetValue(AnimationDurationProperty, value); } 76 | } 77 | 78 | #endregion 79 | 80 | protected override Size MeasureOverride(Size constraint) 81 | { 82 | SetValue(BarMarginLeftProperty, NodeWidth / 2); 83 | SetValue(BarMarginTopProperty, (NodeWidth - BarHeight) / 2); 84 | SetValue(ShadowWidthProperty, constraint.Width - BarMarginLeft * 2); 85 | 86 | return base.MeasureOverride(new Size(constraint.Width, NodeWidth * 3)); 87 | } 88 | 89 | protected override Size ArrangeOverride(Size arrangeBounds) 90 | { 91 | return base.ArrangeOverride(arrangeBounds); 92 | } 93 | 94 | #region override itemscontrol 95 | 96 | //不使用路由事件时,可以这样传递事件 97 | //protected override void PrepareContainerForItemOverride(DependencyObject element, object item) 98 | //{ 99 | // var node = element as FlowNodeControl; 100 | // if (node !=null && FlowNodeSelected != null) 101 | // node.NodeSelected += FlowNodeSelected; 102 | 103 | // base.PrepareContainerForItemOverride(element, item); 104 | //} 105 | 106 | //protected override void ClearContainerForItemOverride(DependencyObject element, object item) 107 | //{ 108 | // var node = element as FlowNodeControl; 109 | // if (node != null && FlowNodeSelected != null) 110 | // node.NodeSelected -= FlowNodeSelected; 111 | 112 | // base.ClearContainerForItemOverride(element, item); 113 | //} 114 | 115 | #endregion 116 | 117 | #region route event 118 | 119 | //route event 120 | public static readonly RoutedEvent NodeSelectedEvent = 121 | FlowNodeControl.NodeSelectedEvent.AddOwner(typeof(FlowControl)); 122 | 123 | public event RoutedEventHandler NodeSelected 124 | { 125 | add { AddHandler(FlowNodeControl.NodeSelectedEvent, value, false); } 126 | remove { RemoveHandler(FlowNodeControl.NodeSelectedEvent, value); } 127 | } 128 | 129 | #endregion 130 | 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/FlowControl.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 0 9 | 0:0:1.5 10 | 11 | 61 | 62 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/FlowControlPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Media; 5 | using System.Windows.Media.Animation; 6 | 7 | namespace Wpf.Control.Flow 8 | { 9 | public class FlowControlPanel : Panel 10 | { 11 | public static readonly DependencyProperty AnimationDurationProperty = DependencyProperty.Register( 12 | "AnimationDuration", typeof (Duration), typeof (FlowControlPanel), new PropertyMetadata(default(Duration))); 13 | 14 | public Duration AnimationDuration 15 | { 16 | get { return (Duration) GetValue(AnimationDurationProperty); } 17 | set { SetValue(AnimationDurationProperty, value); } 18 | } 19 | 20 | protected override Size MeasureOverride(Size availableSize) 21 | { 22 | var s = base.MeasureOverride(availableSize); 23 | foreach (UIElement element in this.Children) 24 | { 25 | element.Measure(availableSize); 26 | } 27 | return availableSize; 28 | } 29 | protected override Size ArrangeOverride(Size finalSize) 30 | { 31 | const double y = 0; 32 | double margin = 0; 33 | 34 | foreach (UIElement child in Children) 35 | { 36 | var newMargin = child.DesiredSize.Width / 2; 37 | if (newMargin > margin) 38 | { 39 | margin = newMargin; 40 | } 41 | } 42 | 43 | //double lastX = 0; todo 44 | foreach (ContentPresenter element in Children) 45 | { 46 | var node = element.Content as FlowItem; 47 | var x = Convert.ToDouble(node.OffsetRate) * (finalSize.Width - margin * 2); 48 | element.Arrange(new Rect(0, y, element.DesiredSize.Width, element.DesiredSize.Height)); 49 | 50 | //来自http://www.mgenware.com/blog/?p=326 51 | var transform = element.RenderTransform as TranslateTransform; 52 | if (transform == null) 53 | element.RenderTransform = transform = new TranslateTransform(); 54 | 55 | transform.BeginAnimation(TranslateTransform.XProperty, new DoubleAnimation(0, x, AnimationDuration)); 56 | 57 | } 58 | return finalSize; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/FlowItem.cs: -------------------------------------------------------------------------------- 1 | namespace Wpf.Control.Flow 2 | { 3 | public class FlowItem 4 | { 5 | public FlowItem() 6 | { 7 | } 8 | 9 | public FlowItem(int id, string title,double offsetRate) 10 | { 11 | Id = id; 12 | Title = title; 13 | OffsetRate = offsetRate; 14 | } 15 | 16 | public int Id { get; set; } 17 | 18 | public string Title { get; set; } 19 | 20 | public double OffsetRate { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/FlowNodeControl.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Wpf.Control.Flow 5 | { 6 | [TemplatePart(Name = "PART_NodeRadioButton", Type = typeof(RadioButton))] 7 | public class FlowNodeControl : System.Windows.Controls.Control 8 | { 9 | static FlowNodeControl() 10 | { 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(FlowNodeControl), new FrameworkPropertyMetadata(typeof(FlowNodeControl))); 12 | } 13 | 14 | #region Dependency Property 15 | 16 | public static readonly DependencyProperty OffsetRateProperty = DependencyProperty.Register( 17 | "OffsetRate", typeof(double), typeof(FlowNodeControl), new PropertyMetadata(default(double))); 18 | 19 | public double OffsetRate 20 | { 21 | get { return (double)GetValue(OffsetRateProperty); } 22 | set { SetValue(OffsetRateProperty, value); } 23 | } 24 | 25 | public static readonly DependencyProperty NodeTitleProperty = DependencyProperty.Register( 26 | "NodeTitle", typeof(string), typeof(FlowNodeControl), new PropertyMetadata(string.Empty)); 27 | 28 | public string NodeTitle 29 | { 30 | get { return (string)GetValue(NodeTitleProperty); } 31 | set { SetValue(NodeTitleProperty, value); } 32 | } 33 | 34 | //用于向上通知哪个Node被点击 35 | public static readonly DependencyProperty IdProperty = DependencyProperty.Register( 36 | "Id", typeof(int), typeof(FlowNodeControl), new PropertyMetadata(default(int))); 37 | 38 | public int Id 39 | { 40 | get { return (int)GetValue(IdProperty); } 41 | set { SetValue(IdProperty, value); } 42 | } 43 | 44 | private const double NodeWidthDefault = 30; 45 | public static readonly DependencyProperty NodeWidthProperty = DependencyProperty.Register( 46 | "NodeWidth", typeof(double), typeof(FlowNodeControl), new PropertyMetadata(NodeWidthDefault)); 47 | 48 | public double NodeWidth 49 | { 50 | get { return (double)GetValue(NodeWidthProperty); } 51 | set { SetValue(NodeWidthProperty, value); } 52 | } 53 | 54 | #endregion 55 | 56 | private RadioButton nodeRadioButton; 57 | 58 | public override void OnApplyTemplate() 59 | { 60 | if (nodeRadioButton != null) 61 | { 62 | nodeRadioButton.Click -= nodeRadioButton_Click; 63 | } 64 | 65 | base.OnApplyTemplate(); 66 | 67 | nodeRadioButton = GetTemplateChild("PART_NodeRadioButton") as RadioButton; 68 | 69 | if (nodeRadioButton != null) 70 | { 71 | nodeRadioButton.Click += nodeRadioButton_Click; 72 | } 73 | } 74 | 75 | void nodeRadioButton_Click(object sender, RoutedEventArgs e) 76 | { 77 | RaiseEvent(new RoutedEventArgs(NodeSelectedEvent,this)); 78 | } 79 | 80 | //route event 81 | public static readonly RoutedEvent NodeSelectedEvent = EventManager.RegisterRoutedEvent( 82 | "NodeSelected", RoutingStrategy.Bubble, 83 | typeof(RoutedEventHandler), 84 | typeof(FlowNodeControl)); 85 | 86 | public event RoutedEventHandler NodeSelected 87 | { 88 | add { AddHandler(NodeSelectedEvent, value); } 89 | remove { RemoveHandler(NodeSelectedEvent, value); } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/MultiMarginConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Data; 4 | 5 | namespace Wpf.Control.Flow 6 | { 7 | //http://stackoverflow.com/questions/6249518/binding-only-part-of-the-margin-property-of-wpf-control 8 | public class MultiThicknessConverter : IMultiValueConverter 9 | { 10 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) 11 | { 12 | return new Thickness(System.Convert.ToDouble(values[0]), 13 | System.Convert.ToDouble(values[1]), 14 | System.Convert.ToDouble(values[2]), 15 | System.Convert.ToDouble(values[3])); 16 | } 17 | 18 | public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture) 19 | { 20 | return null; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/MultiWidthAnimationConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Wpf.Control.Flow 6 | { 7 | // stackoverflow.com/questions/2186933/wpf-animation-binding-to-the-to-attribute-of-storyboard-animation 8 | public class MultiWidthAnimationConverter : IMultiValueConverter 9 | { 10 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | double result = 1.0; 13 | for (int i = 0; i < values.Length; i++) 14 | { 15 | if (values[i] is double) 16 | result *= (double)values[i]; 17 | } 18 | 19 | return result; 20 | } 21 | 22 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 23 | { 24 | throw new Exception("Not implemented"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Flow/TitleMaxWidthConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Wpf.Control.Flow 6 | { 7 | public class TitleMaxWidthConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | return System.Convert.ToDouble(value) * 1.9; 12 | } 13 | 14 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Windows; 5 | 6 | // 有关程序集的常规信息通过以下 7 | // 特性集控制。更改这些特性值可修改 8 | // 与程序集关联的信息。 9 | [assembly: AssemblyTitle("Wpf.Control")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Wpf.Control")] 14 | [assembly: AssemblyCopyright("Copyright © hystar 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 将 ComVisible 设置为 false 使此程序集中的类型 19 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 20 | 21 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 22 | 23 | [assembly: ComVisible(false)] 24 | 25 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 26 | [assembly: Guid("65046fab-b1c4-4fd2-afe0-dbc87278f33c")] 27 | 28 | 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /WpfDemo/Wpf.Control/Wpf.Control.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {806808A4-8106-4F8D-8E87-973E0158CCC7} 8 | Library 9 | Properties 10 | Wpf.Control 11 | Wpf.Control 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | MSBuild:Compile 67 | Designer 68 | 69 | 70 | MSBuild:Compile 71 | Designer 72 | 73 | 74 | MSBuild:Compile 75 | Designer 76 | 77 | 78 | MSBuild:Compile 79 | Designer 80 | 81 | 82 | 83 | 90 | -------------------------------------------------------------------------------- /WpfDemo/WpfControlDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wpf.Control", "Wpf.Control\Wpf.Control.csproj", "{806808A4-8106-4F8D-8E87-973E0158CCC7}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wpf.Control.Sample", "Wpf.Control.Sample\Wpf.Control.Sample.csproj", "{72D2E667-CF6E-470A-A880-FB5412E662A5}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {806808A4-8106-4F8D-8E87-973E0158CCC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {806808A4-8106-4F8D-8E87-973E0158CCC7}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {806808A4-8106-4F8D-8E87-973E0158CCC7}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {806808A4-8106-4F8D-8E87-973E0158CCC7}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {72D2E667-CF6E-470A-A880-FB5412E662A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {72D2E667-CF6E-470A-A880-FB5412E662A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {72D2E667-CF6E-470A-A880-FB5412E662A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {72D2E667-CF6E-470A-A880-FB5412E662A5}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /XMindFiles/WPF.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsxqw2004/blog_sample_codes/7937834056439af865bd302dceaf4f949a5c9d06/XMindFiles/WPF.xmind --------------------------------------------------------------------------------