private void btn_findPath_Click(object sender, EventArgs e) { if (points.Count != 2) { MessageBox.Show("Please select start point and end point!"); return; } var start = points[0]; var end = points[1]; Stopwatch stopwatch = new Stopwatch(); AutoRoute autoRoute = new AutoRoute((int[, ])readMap.Maze.Clone()); stopwatch.Start(); var tempPoints = autoRoute.FindeWay(start, end); stopwatch.Stop(); if (tempPoints == null || tempPoints.Count == 0) { lbl_info.Text = "Can't find the path!"; return; } lbl_info.Text = $"times:{stopwatch.ElapsedMilliseconds}\r\nDistance:{tempPoints.Count}"; var newBitmap = (Bitmap)readMap.clippingZone.Clone(); pic_map.Image = newBitmap; foreach (var item in tempPoints) { newBitmap.SetPixel(item.X, item.Y, Color.Red); } pic_map.Image = newBitmap; }
public void AddRoute(int id, AutoRoute route) { if (_routeData != null) { _routeData.Add(id, route); } SaveRouteData(); RoutesUpdated?.Invoke(this, new RouteEventArgs { Routes = GetRouteData(), IsFullRefresh = false }); }
public void DeleteRoute(AutoRoute route) { var newRouteData = _routeData.Values.ToList(); newRouteData.Remove(route); newRouteData.Where(r => r.Id > route.Id).ToList().ForEach(r => r.Id--); _routeData = newRouteData.ToDictionary(r => r.Id); SaveRouteData(); RoutesUpdated?.Invoke(this, new RouteEventArgs { Routes = GetRouteData(), IsFullRefresh = false }); }
/// <summary> /// 寻路 /// </summary> /// <param name="position"></param> /// <param name="to"></param> /// <returns></returns> protected ActionResult <List <Point> > FindPath(PositionInfo position, Point to) { ReadMap readMap = new ReadMap(); readMap.mapFile = @"F:\Program Files\ShengquGames\Legend of mir\Map\3.map"; readMap.Load(); MirContext.ReadMap = readMap; AutoRoute autoRoute = new AutoRoute((int[, ])readMap.Maze.Clone()); var tempPoints = autoRoute.FindeWay(to, position.Point); return(new ActionResult <List <Point> >(tempPoints)); //PathGrid pathGrid = new PathGrid(MirContext.ReadMap.Width, MirContext.ReadMap.Height, MirContext.Maze(position.MapInfo)); //return new ActionResult<List<Point>>(pathGrid.FindPath(position.Point, to)); }
public override void Process() { DicomServerConfiguration configuration = GetServerConfiguration(); var remoteAE = ServerDirectory.GetRemoteServerByName(Request.DestinationServerName); if (remoteAE == null) { Proxy.Fail(string.Format("Unknown destination: {0}", Request.DestinationServerName), WorkItemFailureType.Fatal); return; } if (AutoRoute != null && Proxy.Item.Priority != WorkItemPriorityEnum.Stat) { DateTime now = Platform.Time; DateTime scheduledTime = AutoRoute.GetScheduledTime(now, 0); if (now != scheduledTime) { Proxy.Postpone(); Platform.Log(LogLevel.Info, "Rescheduling AutoRoute WorkItem {0} back into the scheduled time window: {1}", Proxy.Item.Oid, Proxy.Item.ProcessTime); return; } } _scu = new ImageViewerStorageScu(configuration.AETitle, remoteAE); LoadImagesToSend(); if (Request.CompressionType != CompressionType.None) { _scu.LoadPreferredSyntaxes(Request); } Progress.TotalImagesToSend = _scu.TotalSubOperations; Progress.FailureSubOperations = 0; Progress.WarningSubOperations = 0; Progress.SuccessSubOperations = 0; Progress.IsCancelable = true; Proxy.UpdateProgress(); _scu.ImageStoreCompleted += OnImageSent; _scu.DoSend(); if (_scu.Canceled) { if (StopPending) { Proxy.Postpone(); } else { Proxy.Cancel(); } } else if (_scu.Failed || _scu.FailureSubOperations > 0) { var settings = new DicomSendSettings(); TimeSpan delay = settings.RetryDelayUnits == RetryDelayTimeUnit.Seconds ? TimeSpan.FromSeconds(settings.RetryDelay) : TimeSpan.FromMinutes(settings.RetryDelay); Proxy.Fail(_scu.FailureDescription, WorkItemFailureType.NonFatal, AutoRoute != null ? AutoRoute.GetScheduledTime(Platform.Time, (int)delay.TotalSeconds) : Platform.Time.Add(delay), settings.RetryCount); } else { Proxy.Complete(); } }
public bool TryGetRoute(int id, out AutoRoute route) { route = GetRoute(id); return(route != null); }