public string Render <T>(string templateText, T value) { var expressContext = GetExpressContext <T>(templateText); return(MapFunction(expressContext.CompiledTemplate, standardLibrary) (value)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //绑定视图元素到界面 this.bottomsStatusBar.DataContext = MapOperate.ViewInfo; this.tbSystemMsg.DataContext = MapOperate.SystemMsg; //指定画布 MapElement.CvGrid = cvGrid; //栅格 MapElement.CvRFID = cvRFID; //标签 MapElement.CvRouteLine = cvLine; //直路线 MapElement.CvForkLine = cvForkLine; //分叉路线 MapElement.CvOperate = cvOperate; //操作层 //画背景栅格,大小为20*20 MapElement.DrawGrid(1024 * 2, 768 * 2); //加载地图 try { string str = SaveMap.Helper.LoadFromFile(@"map.json"); //重载 MapFunction.ReloadMap(str); //记录当前状态 MapOperate.History.AddRecord("加载地图"); } catch { } }
/// <summary> /// Main constructor /// </summary> public frmMain() { // Export extension point Shell = this; // INitialize layout components InitializeComponent(); // Load extensions, if any //theAppManager.LoadExtensions(); // Add map function to map mClickZoomFunction = new DotSpatial.Controls.MapFunctionClickZoom(theMap); theMap.MapFunctions.Add(mClickZoomFunction); // Add additional click-handlers to elements theMap.Layers.LayerSelected += new EventHandler <LayerSelectedEventArgs>(onLayerSelectionChanged); // Set selection properties on datagridview theDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; theDataGridView.SelectionChanged += new EventHandler(onGridViewSelectionChanged); // Default map projection frmMain.MapProjection = KnownCoordinateSystems.Projected.World.WebMercator; // Set map projection theMap.Projection = frmMain.MapProjection; }
private void dft(MapFunction function, Node <T> n, order order = order.preorder) { if (n.value == null) { function(ref n.value); } else { if (order == order.preorder) { function(ref n.value); } if (n.childs[0] != null) { dft(function, n.childs[0], order); } if (order == order.inorder) { function(ref n.value); } if (n.childs[1] != null) { dft(function, n.childs[1], order); } if (order == order.postorder) { function(ref n.value); } } }
public void FunctionActivatedRaised() { var target = new MapFunction(); var flag = false; target.FunctionActivated += (sender, args) => flag = true; target.Activate(); Assert.AreEqual(true, flag); }
public void KeyUpRaised() { var target = new MapFunction(); var flag = false; target.KeyUp += (sender, args) => flag = true; target.DoKeyUp(null); Assert.AreEqual(true, flag); }
public void MouseDoubleClickRaised() { var target = new MapFunction(); var flag = false; target.MouseDoubleClick += (sender, args) => flag = true; target.DoMouseDoubleClick(null); Assert.AreEqual(true, flag); }
public void MouseWheelRaised() { var target = new MapFunction(); var flag = false; target.MouseWheel += (sender, args) => flag = true; target.DoMouseWheel(null); Assert.AreEqual(true, flag); }
public void FunctionDeActivatedRaised() { var target = new MapFunction(); var flag = false; target.FunctionDeactivated += (sender, args) => flag = true; target.Deactivate(); Assert.AreEqual(true, flag); }
public static PointPairList Map(this PointPairList d, MapFunction f) { PointPairList result = new PointPairList(d); for (int i = 0; i < d.Count; ++i) { f(result[i]); } return(result); }
public void Map(MapFunction mapFunction) { for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { values [i, j] = mapFunction(values [i, j]); } } }
//加载地图 private void Btn_LoadMap_Click(object sender, RoutedEventArgs e) { //读取 string str = SaveMap.Helper.LoadFromFile(); //重载 MapFunction.ReloadMap(str); //记录当前状态 MapOperate.History.AddRecord("加载地图"); }
private void Btn_Add_RFID_Click(object sender, RoutedEventArgs e) { //清除选中状态 MapFunction.ClearSelect(); MapOperate.NowType = MapOperate.EnumElementType.RFID; //添加一个RFID MapOperate.NowSelectIndex = MapElement.AddRFIDAndShow(); //进入添加模式 MapOperate.NowMode = MapOperate.EnumMode.AddElement; }
public void MapTestShoulWork() { var list = new List <int>() { 0, 1, 2, 3, 4 }; list = MapFunction.Map(list, x => x * 2); Assert.IsTrue(list.Contains(8)); Assert.IsFalse(list.Contains(10)); }
public void MapTestShoulWorkWithAddZeroValue() { var list = new List <int>() { 0, 0, 0, 0 }; list = MapFunction.Map(list, x => x * 2); Assert.IsTrue(list.Contains(0)); Assert.IsFalse(list.Contains(1)); }
public static MapFunction Read(BinaryReader reader) { MapFunction result = new MapFunction(); result.FunctionId = Utilities.Read7BitEncodedInt(reader); result.ClassId = Utilities.Read7BitEncodedInt(reader); result.IsNative = Utilities.Read7BitEncodedInt(reader) != 0; result.Name = reader.ReadString(); result.Signature = reader.ReadString(); return(result); }
public Matrix map(MapFunction func) { Matrix matrix = new Matrix(rows, cols); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { matrix.data[i][j] = func(data[i][j]); } } return(matrix); }
public void MapTestShoulWorkWhenWeDoNotAddValues() { var list = new List <int>() { }; list = MapFunction.Map(list, x => x * 2); for (int i = 0; i <= 10; i++) { Assert.IsFalse(list.Contains(i)); } }
public static Matrix Map(Matrix a, MapFunction mapFunction) { Matrix b = new Matrix(a.rows, a.columns); for (int i = 0; i < b.rows; i++) { for (int j = 0; j < b.columns; j++) { b.values [i, j] = mapFunction(a.values [i, j]); } } return(b); }
private void Btn_Add_RouteForkLine_Click(object sender, RoutedEventArgs e) { //清除选中状态 MapFunction.ClearSelect(); //选中类型为分叉线 MapOperate.NowType = MapOperate.EnumElementType.RouteForkLine; //添加分叉线 MapOperate.NowSelectIndex = MapElement.AddForkLine(); //显示起点编辑器 MapElement.ForkLineShowStart(MapOperate.NowSelectIndex); //开始第一步 MapOperate.AddStep = 1; //进入添加模式 MapOperate.NowMode = MapOperate.EnumMode.AddElement; }
public void TestReactΔ() { var f = new MapFunction<int, int>(x => x + 1); var numbers = new[] {10, 7, 12, 13, 6}; var value = f[numbers]; Assert.That(f.React(value, numbers.ToList().ToLog(Δ1.Empty)).Δ, Is.EqualTo(Δ1.Empty)); Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(4).ToIns(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(4).ToIns())); Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(4).ToIns(), (key, i) => 13)).Δ, Is.EqualTo(Expressions.Numbers(4).ToIns())); Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(5).ToIns(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(5).ToIns())); Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(5).ToIns(), (key, i) => 7)).Δ, Is.EqualTo(Expressions.Numbers(5).ToIns())); Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(1).ToDel(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(1).ToDel())); Assert.That(f.React(value, numbers.ToList().Mutate(Expressions.Numbers(3).ToDel(), (key, i) => 26)).Δ, Is.EqualTo(Expressions.Numbers(3).ToDel())); }
/// <summary> /// 撤销 /// </summary> public static void Undo() { if (Records.Count == 0) { MapOperate.SystemMsg.WriteLine("还没有记录^-^"); return; } if (History.nowIndex == 0) { MapOperate.SystemMsg.WriteLine("到低了,不能再撤销了^-^"); return; } History.nowIndex--; //重载地图 MapFunction.ReloadMap(Records[History.nowIndex].Data); }
/// <summary> /// 重做【恢复撤销】 /// </summary> public static void Redo() { if (Records.Count == 0) { MapOperate.SystemMsg.WriteLine("还没有记录^-^"); return; } if (History.nowIndex == Records.Count - 1) { MapOperate.SystemMsg.WriteLine("到最后一步了^-^"); return; } History.nowIndex++; //重载地图 MapFunction.ReloadMap(Records[History.nowIndex].Data); }
public void breadth_first_traversal(MapFunction function) { Queue <Node <T> > queue = new Queue <Node <T> >(); Node <T> n; queue.Enqueue(node); do { n = queue.Dequeue(); function(ref n.value); if (n.childs[0] != null) { queue.Enqueue(n.childs[0]); } if (n.childs[1] != null) { queue.Enqueue(n.childs[1]); } } while (queue.Count > 0); }
public void Map_FunReturnsText_ResultTypesAreCorrect() { var function = new MapFunction() .CreateConcreteOrNull( FunnyType.ArrayOf(FunnyType.Text), FunnyType.ArrayOf(FunnyType.Int32), FunnyType.Fun(FunnyType.Text, FunnyType.Int32)); Assert.IsNotNull(function); Assert.Multiple(() => { Assert.AreEqual( expected: FunnyType.ArrayOf(FunnyType.Text), actual: function.ReturnType); CollectionAssert.AreEqual( expected: new[] { FunnyType.ArrayOf(FunnyType.Int32), FunnyType.Fun(FunnyType.Text, FunnyType.Int32) }, actual: function.ArgTypes); }); }
/// <summary> /// Gets a reference to the specified profile function. /// </summary> /// <param name="functionAssemblyName"></param> /// <param name="functionClassName"></param> /// <param name="functionMethodName"></param> /// <param name="columnName"></param> /// <param name="detailedResults"></param> /// <param name="globalSettings"></param> /// <returns></returns> /// <exception cref="TransformManagerException"></exception> public Mapping GetProfileFunction(string functionAssemblyName, string functionClassName, string functionMethodName, string columnName, bool detailedResults, GlobalSettings globalSettings) { try { var functionMethod = Functions.GetFunctionMethod(functionClassName, functionMethodName, functionAssemblyName); var profileObject = Activator.CreateInstance(functionMethod.type); var property = profileObject.GetType().GetProperty("DetailedResults"); if (property != null) { property.SetValue(profileObject, detailedResults); } var parameters = new Parameters() { Inputs = new Parameter[] { new ParameterColumn("value", new TableColumn(columnName)) }, ResultReturnParameters = new List <Parameter>() { new ParameterOutputColumn("value", ETypeCode.String) }, ResultOutputs = new List <Parameter>() { new ParameterOutputColumn("distribution", ETypeCode.Unknown) }, }; var profileFunction = new TransformFunction(profileObject, functionMethodName, null, parameters, globalSettings); var mapFunction = new MapFunction(profileFunction, parameters, EFunctionCaching.NoCache); return(mapFunction); } catch (Exception ex) { throw new TransformManagerException($"Get profile function failed. {ex.Message}.", ex); } }
public TestD(DB db) : base(db, Rand.RandString("testd")) { this.allTestObjsInclude = this.allTestObjs.IncludeDocs <testobject>(); }
public string Render <T>(ExpressContext <T, L> expressContext, T value) { return(MapFunction(expressContext.CompiledTemplate, standardLibrary) (value)); }
public static MapFunction Read(BinaryReader reader) { MapFunction result = new MapFunction(); result.FunctionId = Utilities.Read7BitEncodedInt(reader); result.ClassId = Utilities.Read7BitEncodedInt(reader); result.IsNative = Utilities.Read7BitEncodedInt(reader) != 0; result.Name = reader.ReadString(); result.Signature = reader.ReadString(); return result; }
public ChiTietChuyenDiViewModel(Dieuxe chuyenXe) { ChuyenXeHienTai = chuyenXe; var accessToken = Settings.AccessToken; //Laydulieu(chuyenXe); //ChiTietChuyenDi = new List<ChiTietChuyenDi>() //{ // new ChiTietChuyenDi{ DangKyLichChiTietId = 1, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.838085, 106.634272", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "17/6A Phan Huy Ích, Phường 15, Gò Vấp", SoNguoiDi = 2, TenNguoiDi = "ADC, XB", SdtLienLac = "0123"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 2, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.769082, 106.702199", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "16 Nam Kỳ Khởi Nghĩa, Phường Nguyễn Thái Bình, Quận 1", SoNguoiDi = 1, TenNguoiDi = "C, Taoz", SdtLienLac = "0222"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 3, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.769082, 106.702199", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "16 Nam Kỳ Khởi Nghĩa, Phường Nguyễn Thái Bình, Quận 1", SoNguoiDi = 2, TenNguoiDi = "Bronzen", SdtLienLac = "0333"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 4, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.838781, 106.672548", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "236a Nguyễn Văn Lượng, Phường 6, Gò Vấp", SoNguoiDi = 3, TenNguoiDi = "Pro, E", SdtLienLac = "0444"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 5, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.769082, 106.702199", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "16 Nam Kỳ Khởi Nghĩa, Phường Nguyễn Thái Bình, Quận 1", SoNguoiDi = 1, TenNguoiDi = "Vip, Vippro", SdtLienLac = "0555"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 6, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.835409, 106.635244", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "243 Phan Huy Ích, Phường 12, Gò Vấp", SoNguoiDi = 4, TenNguoiDi = "Adu, Vãi chưởng", SdtLienLac = "0666"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 7, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.787637, 106.686105", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "209-201 Nam Kỳ Khởi Nghĩa, Phường 7, Quận 3", SoNguoiDi = 1, TenNguoiDi = "Hay đấy, Oke", SdtLienLac = "0777"}, // new ChiTietChuyenDi{ DangKyLichChiTietId = 8, ToaDoDi = "10.832282, 106.778043", ToaDoDen = "10.803820, 106.689993", NoiDi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", NoiDen = "24a Phan Đăng Lưu, Phường 6, Bình Thạnh", SoNguoiDi = 2, TenNguoiDi = "Elly, Đại ca đây", SdtLienLac = "0888"} //}; ChiTietChuyenDi = new List <ChiTietChuyenDi>() { new ChiTietChuyenDi { DangKyLichChiTietId = 1, ToaDoDi = "10.833374,106.559539", ToaDoDen = "10.831530,106.570754", NoiDi = "Mẫu Giáo Ngôi Sao Xanh, Liên Ấp 234, Vĩnh Lộc A, Bình Chánh", NoiDen = "5 Quách Điêu, Vĩnh Lộc A, Bình Chánh", SoNguoiDi = 2, TenNguoiDi = "ADC, XB", SdtLienLac = "0123" }, new ChiTietChuyenDi { DangKyLichChiTietId = 2, ToaDoDi = "10.832763,106.561298", ToaDoDen = "10.831994,106.567321", NoiDi = "xã Vĩnh Lộc A, Vĩnh Lộc A, Bình Chánh", NoiDen = "Siêu thị Bách hóa XANH D10/17B Nữ Dân Công, D10/17B Nữ Dân Công, Ấp 4, Xã Vĩnh Lộc A, Bình Chánh", SoNguoiDi = 1, TenNguoiDi = "C, Taoz", SdtLienLac = "02222" }, new ChiTietChuyenDi { DangKyLichChiTietId = 3, ToaDoDi = "10.835956,106.560145", ToaDoDen = "10.832112,106.563696", NoiDi = "xã Vĩnh Lộc A, Vĩnh Lộc A, Bình Chánh", NoiDen = "Nhà Thuốc Bảo Châu, Đ. Dân Công Hoả Tuyến, Vĩnh Lộc A, Bình Chánh", SoNguoiDi = 1, TenNguoiDi = "C, Taoz", SdtLienLac = "0333" } }; //var lichdangky = new List<lich>() { // new lich { sodangky = 0, ngaydangky = "25/03/2020", nhanviendangky = "SK10", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.845966, 106.765224", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "30-38 Dân Chủ, Bình Thọ, Thủ Đức", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" },// // new lich { sodangky = 1, ngaydangky = "25/03/2020", nhanviendangky = "SK06", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.838085, 106.634272", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "17/6A Phan Huy Ích, Phường 15, Gò Vấp", gioden = "08:00", ngayden = "20/03/2020", giove = "15:00", ngayve = "20/03/2020" },/////// 7 // new lich { sodangky = 2, ngaydangky = "18/03/2020", nhanviendangky = "SK06", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.769082, 106.702199", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "16 Nam Kỳ Khởi Nghĩa, Phường Nguyễn Thái Bình, Quận 1", gioden = "08:00", ngayden = "20/03/2020", giove = "15:00", ngayve = "20/03/2020" },/////// 1 // new lich { sodangky = 3, ngaydangky = "15/03/2020", nhanviendangky = "SK05", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.769082, 106.702199", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "16 Nam Kỳ Khởi Nghĩa, Phường Nguyễn Thái Bình, Quận 1", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" },/////// 2 // new lich { sodangky = 4, ngaydangky = "15/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.832282, 106.778043", noiden = "10.868034, 106.780647", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "940 Xa lộ Đại Hàn, Phường Linh Trung, Thủ Đức", gioden = "09:00", ngayden = "20/03/2020", giove = "15:00", ngayve = "20/03/2020" },// // new lich { sodangky = 5, ngaydangky = "16/03/2020", nhanviendangky = "SK07", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.838781, 106.672548", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "236a Nguyễn Văn Lượng, Phường 6, Gò Vấp", gioden = "09:00", ngayden = "20/03/2020", giove = "17:00", ngayve = "20/03/2020" },/////// 6 // new lich { sodangky = 6, ngaydangky = "18/03/2020", nhanviendangky = "SK06", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.769082, 106.702199", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "16 Nam Kỳ Khởi Nghĩa, Phường Nguyễn Thái Bình, Quận 1", gioden = "08:00", ngayden = "20/03/2020", giove = "15:00", ngayve = "20/03/2020" },/////// 3 // new lich { sodangky = 7, ngaydangky = "19/03/2020", nhanviendangky = "SK05", songuoi = 2, noidi = "10.832282, 106.778043", noiden = "10.835409, 106.635244", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "243 Phan Huy Ích, Phường 12, Gò Vấp", gioden = "08:00", ngayden = "20/03/2020", giove = "15:00", ngayve = "20/03/2020" },/////// 8 // new lich { sodangky = 8, ngaydangky = "21/03/2020", nhanviendangky = "SK09", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.884010, 106.586954", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "47 Xuyên Á, Xuân Thới Sơn, Hóc Môn", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" }, // new lich { sodangky = 9, ngaydangky = "24/03/2020", nhanviendangky = "SK07", songuoi = 1, noidi = "10.832282, 106.778043", noiden = "10.787637, 106.686105", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "209-201 Nam Kỳ Khởi Nghĩa, Phường 7, Quận 3", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" },/////// 4 // new lich { sodangky = 10, ngaydangky = "24/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.832282, 106.778043", noiden = "10.803820, 106.689993", diachidi = "48 Đường Tăng Nhơn Phú, Tăng Nhơn Phú B, Quận 9", diachiden = "24a Phan Đăng Lưu, Phường 6, Bình Thạnh", gioden = "09:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" },/////// 5 // new lich { sodangky = 11, ngaydangky = "24/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.803109, 106.737720", noiden = "10.842808, 106.615312", diachidi = "70 Nguyễn Duy Hiệu, Thảo Điền, Quận 2", diachiden = "An Sương 84, Xa lộ Đại Hàn, Đông Hưng Thuận, Hóc Môn", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" }, // new lich { sodangky = 12, ngaydangky = "24/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.886754, 106.759661", noiden = "10.836570, 106.654286", diachidi = "338-350 Nguyễn Tri Phương, An Bình, Dĩ An, Bình Dương", diachiden = "693 Quang Trung, Phường 8, Gò Vấp", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" }, // new lich { sodangky = 13, ngaydangky = "24/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.774183, 106.722131", noiden = "10.813318, 106.578647", diachidi = "232 Đường Mai Chí Thọ, An Lợi Đông, Quận 2", diachiden = "2300 Đường Vĩnh Lộc, Vĩnh Lộc B, Bình Chánh", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" }, // new lich { sodangky = 14, ngaydangky = "24/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.848119, 106.718481", noiden = "10.806229, 106.627437", diachidi = "1/109 QL13, Hiệp Bình Phước, Thủ Đức", diachiden = "34 Lê Trọng Tấn, Sơn Ký, Tân Phú", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" }, // new lich { sodangky = 15, ngaydangky = "24/03/2020", nhanviendangky = "SK08", songuoi = 2, noidi = "10.795682, 106.675471", noiden = "10.832169, 106.621990", diachidi = "163 Nguyễn Văn Trỗi, Phường 11, Phú Nhuận", diachiden = "Chùa Vĩnh Phước, Trường Chinh, Vinh Phuoc Pagoda, Quận 12", gioden = "08:00", ngayden = "20/03/2020", giove = "16:00", ngayve = "20/03/2020" } //}; DiemKeTiep = new Command(DiemKeTiepAction); DsToaDoDiemDung = MapFunction.Decode(chuyenXe.DsDiemDung).ToList(); TrangThaiChuyenXe = chuyenXe.TrangThai; if (TrangThaiChuyenXe == 1) // đã đi lượt đi { DsToaDoDiemDung.Reverse(); } _DanhSachDiemDung = new List <ThongTinDiemDung>(); ListviewDiaChiRowHeight = 64; ChieuCaoListviewDiaChi = DsToaDoDiemDung.Count * ListviewDiaChiRowHeight; for (int i = 0; i < DsToaDoDiemDung.Count; i++) { //Substring(0, input.Length - 1) //var precision = 0; //var doubleLat = DsToaDoDiemDung[i].Latitude; //var doubleLng = DsToaDoDiemDung[i].Longitude; //while (doubleLat * Math.Pow(10, precision) != Math.Round(doubleLat * Math.Pow(10, precision))) // precision++; //string lat = Math.Round(DsToaDoDiemDung[i].Latitude, precision - 1).ToString(); //precision = 0; //while (doubleLng * Math.Pow(10, precision) != Math.Round(doubleLng * Math.Pow(10, precision))) // precision++; //string lng = Math.Round(DsToaDoDiemDung[i].Longitude, precision - 1).ToString(); string lat = DsToaDoDiemDung[i].Latitude.ToString().Substring(0, DsToaDoDiemDung[i].Latitude.ToString().Length - 1); string lng = DsToaDoDiemDung[i].Longitude.ToString().Substring(0, DsToaDoDiemDung[i].Longitude.ToString().Length - 1); _DanhSachDiemDung.Add(new ThongTinDiemDung { DsNguoiDi = new List <NguoiDi>() }); for (int j = 0; j < ChiTietChuyenDi.Count; j++) { var chitietchuyendi = ChiTietChuyenDi[j]; if (chitietchuyendi.ToaDoDi.Contains(lat) && chitietchuyendi.ToaDoDi.Contains(lng)) { if (string.IsNullOrEmpty(_DanhSachDiemDung[i].DiaChi)) { _DanhSachDiemDung[i].DiaChi = chitietchuyendi.NoiDi; _DanhSachDiemDung[i].lat = lat; _DanhSachDiemDung[i].lng = lng; _DanhSachDiemDung[i].DaDiQua = false; } _DanhSachDiemDung[i].DsNguoiDi.Add(new NguoiDi { TenNguoiDi = chitietchuyendi.TenNguoiDi, SoNguoiDi = chitietchuyendi.SoNguoiDi, SdtLienLac = chitietchuyendi.SdtLienLac, LenXe = TrangThaiChuyenXe == 0 ? true : false, XuongXe = TrangThaiChuyenXe == 0 ? false : true }); } if (chitietchuyendi.ToaDoDen.Contains(lat) && chitietchuyendi.ToaDoDen.Contains(lng)) { if (string.IsNullOrEmpty(_DanhSachDiemDung[i].DiaChi)) { _DanhSachDiemDung[i].DiaChi = chitietchuyendi.NoiDen; _DanhSachDiemDung[i].lat = lat; _DanhSachDiemDung[i].lng = lng; _DanhSachDiemDung[i].DaDiQua = false; } _DanhSachDiemDung[i].DsNguoiDi.Add(new NguoiDi { TenNguoiDi = chitietchuyendi.TenNguoiDi, SoNguoiDi = chitietchuyendi.SoNguoiDi, SdtLienLac = chitietchuyendi.SdtLienLac, LenXe = TrangThaiChuyenXe == 0 ? false : true, XuongXe = TrangThaiChuyenXe == 0 ? true : false }); } } } indexToaDoKeTiep = 0; DaDiQuaDiaChiKeTiep = false; DiaChiKeTiep = DanhSachDiemDung[indexToaDoKeTiep].DiaChi; PositionKeTiep.Latitude = DsToaDoDiemDung[indexToaDoKeTiep].Latitude; PositionKeTiep.Longitude = DsToaDoDiemDung[indexToaDoKeTiep].Longitude; TheoDoi(); }
private void drawViewScroll_PreviewKeyDown(object sender, KeyEventArgs e) { //V+F【重置视图】 if (MapOperate.Userkey.Key == Key.V && e.Key == Key.F) { RestView(); } else //Delete【删除】 if (e.Key == Key.Delete) { //编辑单个 if (MapOperate.NowMode == MapOperate.EnumMode.EditElement) { //是否有选中的 if (MapOperate.NowSelectIndex != -1) { switch (MapOperate.NowType) { case MapOperate.EnumElementType.None: break; //选中了RFID case MapOperate.EnumElementType.RFID: MapFunction.RemoveRFID(MapElement.MapObject.RFIDS[MapOperate.NowSelectIndex]); MapOperate.NowSelectIndex = -1; //记录当前状态 MapOperate.History.AddRecord("删除了一个RFID"); break; case MapOperate.EnumElementType.RouteLine: MapFunction.RemoveRouteLine(MapElement.MapObject.Lines[MapOperate.NowSelectIndex]); MapOperate.NowSelectIndex = -1; //记录当前状态 MapOperate.History.AddRecord("删除了一条直线"); break; case MapOperate.EnumElementType.RouteForkLine: MapFunction.RemoveForkLine(MapElement.MapObject.ForkLines[MapOperate.NowSelectIndex]); MapOperate.NowSelectIndex = -1; //记录当前状态 MapOperate.History.AddRecord("删除了一条分叉线"); break; default: break; } } } else //编辑多个 if (MapOperate.NowMode == MapOperate.EnumMode.MultiEdit) { //删除已选中所有元素 //RFID foreach (var item in MapOperate.MultiSelected.RFIDS) { MapFunction.RemoveRFID(item); } //Line foreach (var item in MapOperate.MultiSelected.Lines) { MapFunction.RemoveRouteLine(item); } //ForkLine foreach (var item in MapOperate.MultiSelected.ForkLines) { MapFunction.RemoveForkLine(item); } //清除已选中 MapFunction.ClearAllSelect(MapOperate.MultiSelected); //记录当前状态 MapOperate.History.AddRecord("批量删除"); } } else //Ctrl+C【复制】 if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.C) { //编辑单个 if (MapOperate.NowMode == MapOperate.EnumMode.EditElement) { if (MapOperate.NowSelectIndex != -1) { //清空剪切板 MapFunction.ClearClipBoard(); //将元素复制到剪贴板 switch (MapOperate.NowType) { case MapOperate.EnumElementType.None: break; case MapOperate.EnumElementType.RFID: //列化深度复制 MapElement.RFID rfid = MapFunction.IgkClone.RFID(MapElement.MapObject.RFIDS[MapOperate.NowSelectIndex]); //添加到剪切板 MapOperate.Clipboard.RFIDS.Add(rfid); break; case MapOperate.EnumElementType.RouteLine: //列化深度复制 MapElement.RouteLine routeLine = MapFunction.IgkClone.Line(MapElement.MapObject.Lines[MapOperate.NowSelectIndex]); //添加到剪切板 MapOperate.Clipboard.Lines.Add(routeLine); break; case MapOperate.EnumElementType.RouteForkLine: //列化深度复制 MapElement.RouteForkLine routeForkLine = MapFunction.IgkClone.ForkLine(MapElement.MapObject.ForkLines[MapOperate.NowSelectIndex]); //添加到剪切板 MapOperate.Clipboard.ForkLines.Add(routeForkLine); break; default: break; } } } else //编辑多个 if (MapOperate.NowMode == MapOperate.EnumMode.MultiEdit) { //将元素复制到剪贴板 MapFunction.CopyMultiSelectToClipBoard(); } } else //Ctrl+V【粘贴】 if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.V) { //清除之前的所有选中 MapFunction.ClearSelect(); MapOperate.NowSelectIndex = -1; MapFunction.ClearAllSelect(MapOperate.MultiSelected); /*----将剪切板的元素复制到对应的地图列表----------------------------*/ //RFID MapOperate.PastedObject.RFIDS.Clear(); foreach (var item in MapOperate.Clipboard.RFIDS) { //列化深度复制 MapElement.RFID rfid = MapFunction.IgkClone.RFID(item); //修改编号 rfid.Num = MapElement.MapObject.RFIDS.Last().Num + 1; //更新到文本 rfid.textBlock.Text = rfid.Num.ToString(); //添加到列表 MapElement.MapObject.RFIDS.Add(rfid); //显示 MapElement.ShowRFID(rfid); //设置为选中状态 MapFunction.SetRFIDIsSelected(rfid); //添加到粘贴过程对象 MapOperate.PastedObject.RFIDS.Add(rfid); } //Line MapOperate.PastedObject.Lines.Clear(); foreach (var item in MapOperate.Clipboard.Lines) { //列化深度复制 MapElement.RouteLine line = MapFunction.IgkClone.Line(item); //修改编号 line.Num = MapElement.MapObject.Lines.Last().Num + 1; //更新到文本 line.textBlock.Text = line.Num.ToString(); //添加到列表 MapElement.MapObject.Lines.Add(line); //显示 MapElement.ShowLine(line); //设置为选中状态 MapFunction.SetRouteLineIsSelected(line); //添加到粘贴过程对象 MapOperate.PastedObject.Lines.Add(line); } //ForkLine MapOperate.PastedObject.ForkLines.Clear(); foreach (var item in MapOperate.Clipboard.ForkLines) { //列化深度复制 MapElement.RouteForkLine forkLine = MapFunction.IgkClone.ForkLine(item); //修改编号 forkLine.Num = MapElement.MapObject.ForkLines.Last().Num + 1; //更新到文本 forkLine.textBlock.Text = forkLine.Num.ToString(); //添加到列表 MapElement.MapObject.ForkLines.Add(forkLine); //显示 MapElement.ShowForkLine(forkLine); //设置为选中状态 MapFunction.SetForkLineIsSelected(forkLine); //添加到粘贴过程对象 MapOperate.PastedObject.ForkLines.Add(forkLine); } /*----使所有对象处于光标中心【优化效果】---------------------------*/ //计算所有对象的中心 Point center = MapFunction.GetCenterPoint(MapOperate.PastedObject); //将左键的按下值设置为中心值【移动是根据左键按下的位置计算偏差】 MapOperate.mouseLeftBtnDownToMap = center; //计算左键按下移动偏差 MapOperate.mouseLeftBtnDownMoveDiff.X = MapOperate.NowPoint.X - MapOperate.mouseLeftBtnDownToMap.X; MapOperate.mouseLeftBtnDownMoveDiff.Y = MapOperate.NowPoint.Y - MapOperate.mouseLeftBtnDownToMap.Y; //初始移动【增加粘贴动态效果】 MapFunction.MoveMultiSelected(MapOperate.NowPoint, MapOperate.PastedObject); //进入粘贴模式 MapOperate.NowMode = MapOperate.EnumMode.Paste; } else //Esc【取消】 if (e.Key == Key.Escape) { //粘贴模式 if (MapOperate.NowMode == MapOperate.EnumMode.Paste) { MapFunction.CancelPaste(); //恢复默认 MapOperate.NowMode = MapOperate.EnumMode.EditElement; } } else //Ctrl+Shif+Z【重做】 if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift) && e.Key == Key.Z) { MapOperate.History.Redo(); } else //Ctrl+Z【撤销】 if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.Z) { MapOperate.History.Undo(); } else //Ctrl+X【剪切】 if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.X) { //编辑单个 if (MapOperate.NowMode == MapOperate.EnumMode.EditElement) { if (MapOperate.NowSelectIndex != -1) { //清空剪切板 MapFunction.ClearClipBoard(); //将元素复制到剪贴板 switch (MapOperate.NowType) { case MapOperate.EnumElementType.None: break; case MapOperate.EnumElementType.RFID: //列化深度复制 MapElement.RFID rfid = MapFunction.IgkClone.RFID(MapElement.MapObject.RFIDS[MapOperate.NowSelectIndex]); //添加到剪切板 MapOperate.Clipboard.RFIDS.Add(rfid); //从地图删除 MapFunction.RemoveRFID(MapElement.MapObject.RFIDS[MapOperate.NowSelectIndex]); MapOperate.NowSelectIndex = -1; //记录当前状态 MapOperate.History.AddRecord("剪切掉了一个RFID"); break; case MapOperate.EnumElementType.RouteLine: //列化深度复制 MapElement.RouteLine routeLine = MapFunction.IgkClone.Line(MapElement.MapObject.Lines[MapOperate.NowSelectIndex]); //添加到剪切板 MapOperate.Clipboard.Lines.Add(routeLine); //从地图删除 MapFunction.RemoveRouteLine(MapElement.MapObject.Lines[MapOperate.NowSelectIndex]); MapOperate.NowSelectIndex = -1; //记录当前状态 MapOperate.History.AddRecord("剪切掉了一条直线"); break; case MapOperate.EnumElementType.RouteForkLine: //列化深度复制 MapElement.RouteForkLine routeForkLine = MapFunction.IgkClone.ForkLine(MapElement.MapObject.ForkLines[MapOperate.NowSelectIndex]); //添加到剪切板 MapOperate.Clipboard.ForkLines.Add(routeForkLine); //从地图删除 MapFunction.RemoveForkLine(MapElement.MapObject.ForkLines[MapOperate.NowSelectIndex]); MapOperate.NowSelectIndex = -1; //记录当前状态 MapOperate.History.AddRecord("剪切掉了一条分叉线"); break; default: break; } } } else //编辑多个 if (MapOperate.NowMode == MapOperate.EnumMode.MultiEdit) { //将元素复制到剪贴板 MapFunction.CopyMultiSelectToClipBoard(); //删除已选中所有元素 int num = 0; //RFID foreach (var item in MapOperate.MultiSelected.RFIDS) { MapFunction.RemoveRFID(item); num++; } //Line foreach (var item in MapOperate.MultiSelected.Lines) { MapFunction.RemoveRouteLine(item); num++; } //ForkLine foreach (var item in MapOperate.MultiSelected.ForkLines) { MapFunction.RemoveForkLine(item); num++; } //清除已选中 MapFunction.ClearAllSelect(MapOperate.MultiSelected); //记录当前状态 MapOperate.History.AddRecord(string.Format("剪切了{0}个元件", num)); } } else //Ctrl+S【保存】 if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.S) { //获取字符串地图 string str = SaveMap.Helper.ObjToJson.MapOject(MapElement.MapObject); //保存 SaveMap.Helper.SaveToFile(str, @"map.json"); } //记录当前按键 MapOperate.Userkey.Key = e.Key; MapOperate.Userkey.KeyState = KeyStates.Down; }
/// <summary> /// Create a new parser that maps the result of the current parser to a new value /// </summary> /// <typeparam name="TSource">The type of items in the input data</typeparam> /// <typeparam name="TResult">The result type of <paramref name="self"/></typeparam> /// <typeparam name="TNext">The mapped value type</typeparam> /// <param name="self">The current parser</param> /// <param name="map">A function that maps the value from the current parser to a new value</param> /// <returns>A new <see cref="Parser{TSource, TResult}"/> that executes the current parser and maps the value to a new value</returns> public static Parser <TSource, TNext> Map <TSource, TResult, TNext>(this Parser <TSource, TResult> self, MapFunction <TSource, TResult, TNext> map) { return(TryMap(self, (ParseResult <TResult> res, ReadOnlySpan <TSource> data, out TNext next) => { next = map(res, data); return true; })); }
public Map(MapFunction f, IEnumerable ie) { _f = f; _ie = ie; }
public TrithemiusCalculator SetMapFunction(MapFunction <int> map) { _map = map; return(this); }