示例#1
0
        public void UpdatePaths(Models.Path thepath)
        {
            string strurl = "https://lornestar.firebaseio.com/.json";

            Hashtable hstemp = new Hashtable();

            hstemp.Add("percentage", Math.Round(thepath.marketdifference.percentage, 2));
            hstemp.Add("feeBTC", thepath.marketdifference.staticfeeBTC);
            hstemp.Add("feeLTC", thepath.marketdifference.staticfeeLTC);
            hstemp.Add("feeUSD", thepath.marketdifference.staticfeeUSD);
            hstemp.Add("time", thepath.marketdifference.time);

            Hashtable hstemp2 = new Hashtable();

            hstemp2.Add("pathkey", thepath.pathkey);
            hstemp2.Add("name", thepath.label);
            hstemp2.Add("marketdifference", hstemp);
            hstemp2.Add("lastupdated", DateTime.UtcNow.ToString("hh:mm:ss"));

            Hashtable hstemp3 = new Hashtable();

            hstemp3.Add(thepath.pathkey, hstemp2);

            Web_Request(strurl, hstemp3, 0);
        }
 public static void SafePath(Models.Path collectionOfPoints, string directory = "", string fileName = "CollectionOfPoints.txt")  //When skip Directory as parameter, the default empty string will use current EXE working directory.
 {
     try
     {
         using (var writer = new StreamWriter((directory + fileName), false, Encoding.UTF8)) //if safeToFilePath is null, ArgumentNullException
         {
             foreach (var currentPoint in collectionOfPoints)                                //if collectionOfPoints is null, NullReferenceException
             {
                 writer.WriteLine(currentPoint.ToString());
             }
         }
     }
     catch (ArgumentNullException)
     {
         Console.WriteLine("SafeToFilePath is NULL!");
     }
     catch (NullReferenceException)
     {
         Console.WriteLine("CollectionOfPoints is NULL!");
     }
     catch (Exception)
     {
         Console.WriteLine("The file can't be created!");
     }
 }
示例#3
0
        private void SearchPathTree(Models.Path tree, HashSet <Guid> ImageIdList, string keyword)
        {
            if (tree == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(tree.segment) && tree.segment.ToLower().Contains(keyword))
            {
                var allrouteids = GetAllSubRouteId(tree);

                foreach (var item in allrouteids)
                {
                    var route = SiteDb.Routes.Get(item);
                    if (route != null && route.DestinationConstType == ConstObjectType.Image)
                    {
                        ImageIdList.Add(route.objectId);
                    }
                }
                return;
            }

            foreach (var item in tree.Children)
            {
                SearchPathTree(item.Value, ImageIdList, keyword);
            }
        }
示例#4
0
 public void ReplacePath(int index, Models.Path path)
 {
     path_list.ElementAt(index).id        = path.id;
     path_list.ElementAt(index).name      = path.name;
     path_list.ElementAt(index).type      = path.type;
     path_list.ElementAt(index).waypoints = path.waypoints;
     path_list.ElementAt(index).selected  = path.selected;
     path_list.ElementAt(index).visible   = path.visible;
 }
示例#5
0
 public void AddPathId(int id, Models.Path path)
 {
     path.internal_id = id;
     if (id > _internal_id)
     {
         _internal_id = id;
     }
     path_list.AddLast(path);
 }
示例#6
0
        public static Path Create(Models.Path path, IEnumerable <PublicTransportOperator> publicTransportOperators)
        {
            if (path == null)
            {
                return(null);
            }

            return(new Path(path.TripId, path.StartDate, path.EndDate, path.LocationText, path.DestinationText, new Coordinate(path.StartLatitude, path.StartLongitude), new Coordinate(path.EndLatitude, path.EndLongitude), path.IsPinned, path.JsonObject, path.Order, publicTransportOperators));
        }
示例#7
0
        public void UpdatePaths(Models.Path thepath)
        {
            string strurl = "https://lornestar.firebaseio.com/arbitrage/.json";

            Hashtable hstemp = new Hashtable();

            hstemp.Add(thepath.pathkey, Getpathhstable(thepath));

            Web_Request(strurl, hstemp, 0);
        }
示例#8
0
 void UpdatePath()
 {
     Models.Path Path = TaxiDbContext.Instance.Paths.Find(BizObject.Id);
     Path.IsDeleted   = false;
     Path.Origin      = BizObject.Origin;
     Path.Destination = BizObject.Destination;
     Path.Cost        = BizObject.Cost;
     TaxiDbContext.Instance.SaveChanges();
     BizObject = null;
     MessageBoxRTL.Info(".مسیر با موفقیت ویرایش شد", string.Empty);
     UpdateGrid();
 }
示例#9
0
        public frmPaths()
        {
            btnPaths.ChangeMenuItemImage(Properties.Resources.Paths_out);

            InitializeComponent();

            UpdateGrid();

            BizObject = new Models.Path();

            gridPaths.CellClick += gridPaths_CellClick;
        }
        public static Models.Path LoadPath(string directory = "", string fileName = "CollectionOfPoints.txt") //When skip Directory as parameter, the default empty string will use current EXE working directory.
        {                                                                                                     //Method can read Point3D in format "X = 1, Y = 2, Z = 3" or "X:1 Y:2 Z:3". There is no limit how many Point3D can be read as collection (Models.Path). Every Point3D need to be in NEW line!
            Models.Path collectionOfPoints = new Models.Path();
            try
            {
                using (var reader = new StreamReader((directory + fileName), Encoding.UTF8))
                {
                    string currentLine;

                    while ((currentLine = reader.ReadLine()) != null)
                    {
                        string[] splitText = currentLine.Split(new string[] {
                            "X = ", ",", " ", "Y = ", "Z = ",
                            "X:", "X: ", "Y:", "Y: ", "Z:", "Z: "
                        },
                                                               StringSplitOptions.RemoveEmptyEntries)
                                             .ToArray();

                        double[] XYZ_points = new double[3];
                        for (int index = 0; index <= splitText.Length - 1; index++)
                        {
                            XYZ_points[index] = double.Parse(splitText[index]);  //if more than three doubles, IndexOutOfRangeException
                        }

                        Point3D currentPoint = new Point3D(XYZ_points[0], XYZ_points[1], XYZ_points[2]);
                        collectionOfPoints.AddPoint(currentPoint);
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File was not found!");
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("Wrong directory path!");
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("More than three numbers/points are detected!");
            }
            catch (FormatException)
            {
                Console.WriteLine("Not correct numeric value!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("The file can't be accessed, parsed or do not exist! " + ex.Message);
            }

            return(collectionOfPoints);
        }
示例#11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int cost = 0;

            int.TryParse(txtCost.Text.PersianToEnglish(), out cost);
            if (BizObject != null && !BizObject.IsDeleted)
            {
                BizObject.Cost = cost;
            }
            if (BizObject != null && Validation.Validate(BizObject))
            {
                try
                {
                    if (BizObject.Id != 0)
                    {
                        UpdatePath();
                    }
                    else if (BizObject.Id == 0)
                    {
                        var CheckExistingPath = TaxiDbContext.Instance.Paths
                                                .SingleOrDefault(p => p.Origin == BizObject.Origin && p.Destination == BizObject.Destination);
                        if (CheckExistingPath != null)
                        {
                            DialogResult dr = MessageBoxRTL.Ask("این مسیر قبلا ثبت شده است. آیا تمایل به ویرایش آن دارید؟", string.Empty);
                            if (dr == DialogResult.OK)
                            {
                                BizObject      = null;
                                BizObject      = CheckExistingPath;
                                BizObject.Cost = cost;
                                UpdatePath();
                                return;
                            }
                            else
                            {
                                return;
                            }
                        }
                        BizObject.Cost = cost;
                        TaxiDbContext.Instance.Paths.Add(BizObject);
                        TaxiDbContext.Instance.SaveChanges();
                        MessageBoxRTL.Info(".مسیر با موفقیت افزوده شد", string.Empty);
                        UpdateGrid();
                    }
                    BizObject = null;
                }
                catch
                {
                    MessageBoxRTL.Error("ذخیره سازی مسیر با خطا روبرو شد.", string.Empty);
                }
            }
        }
示例#12
0
        private void EditBizObject()
        {
            BizObject = null;
            int id;

            int.TryParse(gridPaths.SelectedCells.First().RowInfo.Cells["Id"].Value.ToString(), out id);
            UpdateGrid();
            Models.Path PathToEdit = TaxiDbContext.Instance.Paths.Find(id);
            if (PathToEdit != null)
            {
                //BizObject = (Models.Driver)DriverToEdit.Clone();
                BizObject    = (Models.Path)PathToEdit.Clone();
                txtCost.Text = BizObject.Cost.ToString();
            }
        }
        public static Models.Path LoadPath(string filePath)
        {
            var path = new Models.Path();
            using (var sr = new StreamReader(filePath))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    Point3D point = Point3D.Parse(line);
                    path.AddPoint(point);
                }
            }

            return path;
        }
示例#14
0
        public void Add_Empty_Path(Waypoint_Path_Gen wpg, GMAP gmap, string name, string type)
        {
            _wpg  = wpg;
            _gmap = gmap;
            int id = wpg.PathCount();

            Models.Path new_path = new Models.Path();
            new_path.id        = id;
            new_path.name      = name;
            new_path.type      = type;
            new_path.selected  = false;
            new_path.visible   = true;
            new_path.waypoints = null;
            _wpg.AddPath(new_path);
            //Update_GMapTree();
            _gmap.Add_gMapPath(new_path, true);
        }
示例#15
0
        private HashSet <Guid> GetAllSubRouteId(Models.Path tree)
        {
            HashSet <Guid> result = new HashSet <Guid>();

            if (tree.RouteId != default(Guid))
            {
                result.Add(tree.RouteId);
            }
            foreach (var item in tree.Children)
            {
                var subset = GetAllSubRouteId(item.Value);
                foreach (var set in subset)
                {
                    result.Add(set);
                }
            }
            return(result);
        }
示例#16
0
        public void ReversePathWP(int i)
        {
            // Build new wp list
            Models.Path            path   = path_list.ElementAt(i);
            LinkedList <WayPoints> wplist = path.waypoints;
            LinkedList <WayPoints> wpnew  = new LinkedList <WayPoints>();
            int count = wplist.Count;
            int index = count - 1;

            while (index >= 0)
            {
                WayPoints wp     = wplist.ElementAt(index);
                WayPoints wp_new = new WayPoints();
                wp_new = wp;
                wpnew.AddLast(wp_new);
                index--;
            }
            // Build New Path Element
            Models.Path newpath = new Models.Path();
            newpath.name      = path.name;
            newpath.type      = path.type;
            newpath.selected  = path.selected;
            newpath.visible   = path.visible;
            newpath.waypoints = wpnew;
            // Now insert new before the old and delete the old
            LinkedListNode <Models.Path> node = path_list.First;
            LinkedListNode <Models.Path> next_node;

            count = 0;
            while (node != null)
            {
                next_node = node.Next;
                if (count == i)
                {
                    path_list.AddBefore(node, newpath);
                    next_node = node.Next;
                    path_list.Remove(path);
                }
                count++;
                node = next_node;
            }
        }
示例#17
0
        protected Hashtable Getpathhstable(Models.Path thepath)
        {
            Hashtable hstemp = new Hashtable();

            hstemp.Add("percentage", Math.Round(thepath.marketdifference.percentage, 2));
            hstemp.Add("feeBTC", thepath.marketdifference.staticfeeBTC);
            hstemp.Add("feeLTC", thepath.marketdifference.staticfeeLTC);
            hstemp.Add("feeUSD", thepath.marketdifference.staticfeeUSD);
            hstemp.Add("time", thepath.marketdifference.time);

            Hashtable hstemp2 = new Hashtable();

            hstemp2.Add("pathkey", thepath.pathkey);
            hstemp2.Add("name", thepath.label);
            hstemp2.Add("marketdifference", hstemp);
            hstemp2.Add("lastupdated", DateTime.UtcNow.ToString("hh:mm:ss"));
            hstemp2.Add("volume", string.Format("{0:n0}", thepath.volume));

            return(hstemp2);
        }
示例#18
0
        void DeleteBizObject()
        {
            Models.Path  PathToRemove = TaxiDbContext.Instance.Paths.Find(gridPaths.CurrentRow.Cells["Id"].Value);
            DialogResult dr           = MessageBoxRTL.Ask("آیا از حذف مسیر اطمینان دارید؟", string.Empty);

            if (dr == DialogResult.OK)
            {
                try
                {
                    //TaxiDbContext.Instance.Paths.Remove(PathToRemove);
                    PathToRemove.IsDeleted = true;
                    TaxiDbContext.Instance.SaveChanges();
                    MessageBoxRTL.Info(".مسیر با موفقیت حذف شد", string.Empty);
                    UpdateGrid();
                }
                catch
                {
                    MessageBoxRTL.Error("حذف مسیر با خطا روبرو شد", string.Empty);
                }
            }
            BizObject = null;
        }
示例#19
0
        public void ReadXml_Path(string file_name)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(file_name);

            string dialog_text = "XMLReadPath\n\n";


            // Get Paths

            XmlNodeList pathlist   = xmlDoc.DocumentElement.SelectNodes("/WPG/Path");
            int         path_count = pathlist.Count;

            dialog_text = dialog_text + "Path Count : " + path_count + "\n";

            ClearPath();

            foreach (XmlNode path_node in pathlist)
            {
                Models.Path path = new Models.Path();

                path.name        = path_node.SelectSingleNode("Name").InnerText;
                path.type        = path_node.SelectSingleNode("Type").InnerText;
                path.internal_id = Convert.ToInt16(path_node.SelectSingleNode("InternalId").InnerText);

                if (path.type == "Circular")
                {
                    CircularGUI gui      = new CircularGUI();
                    XmlNodeList GUI_node = path_node.SelectNodes("./GUI");
                    foreach (XmlNode node in GUI_node)
                    {
                        gui.CW          = Convert.ToBoolean(node.SelectSingleNode("CW").InnerText);
                        gui.name        = node.SelectSingleNode("Name").InnerText;
                        gui.lat         = Convert.ToDouble(node.SelectSingleNode("Lat").InnerText);
                        gui.lon         = Convert.ToDouble(node.SelectSingleNode("Lon").InnerText);
                        gui.altitude    = Convert.ToDouble(node.SelectSingleNode("Altitude").InnerText);
                        gui.radius      = Convert.ToDouble(node.SelectSingleNode("Radius").InnerText);
                        gui.numpoints   = Convert.ToInt16(node.SelectSingleNode("NumPoints").InnerText);
                        gui.fullcirc    = Convert.ToBoolean(node.SelectSingleNode("FullCircle").InnerText);
                        gui.start_angle = Convert.ToDouble(node.SelectSingleNode("StartAngle").InnerText);
                        gui.circ_span   = Convert.ToDouble(node.SelectSingleNode("CircleSpan").InnerText);
                        gui.startend    = Convert.ToBoolean(node.SelectSingleNode("StartEnd").InnerText);
                        gui.poimode     = Convert.ToBoolean(node.SelectSingleNode("POIMode").InnerText);
                        gui.poiname     = node.SelectSingleNode("POIName").InnerText;
                    }
                    path.circgui = gui;
                }

                if (path.type == "Helical")
                {
                    HelicalGUI  gui      = new HelicalGUI();
                    XmlNodeList GUI_node = path_node.SelectNodes("./GUI");
                    foreach (XmlNode node in GUI_node)
                    {
                        gui.CW          = Convert.ToBoolean(node.SelectSingleNode("CW").InnerText);
                        gui.name        = node.SelectSingleNode("Name").InnerText;
                        gui.lat         = Convert.ToDouble(node.SelectSingleNode("Lat").InnerText);
                        gui.lon         = Convert.ToDouble(node.SelectSingleNode("Lon").InnerText);
                        gui.start_alt   = Convert.ToDouble(node.SelectSingleNode("StartAltitude").InnerText);
                        gui.end_alt     = Convert.ToDouble(node.SelectSingleNode("EndAltitude").InnerText);
                        gui.start_rad   = Convert.ToDouble(node.SelectSingleNode("StartRadius").InnerText);
                        gui.end_rad     = Convert.ToDouble(node.SelectSingleNode("EndRadius").InnerText);
                        gui.start_angle = Convert.ToDouble(node.SelectSingleNode("StartAngle").InnerText);
                        gui.helix_span  = Convert.ToDouble(node.SelectSingleNode("HelixSpan").InnerText);
                        gui.num_points  = Convert.ToInt16(node.SelectSingleNode("NumPoints").InnerText);
                        gui.startend    = Convert.ToBoolean(node.SelectSingleNode("StartEnd").InnerText);
                        gui.poimode     = Convert.ToBoolean(node.SelectSingleNode("POIMode").InnerText);
                        gui.poiname     = node.SelectSingleNode("POIName").InnerText;
                    }
                    path.helixgui = gui;
                }

                if (path.type == "Rectangular")
                {
                    RectanglarGUI gui      = new RectanglarGUI();
                    XmlNodeList   GUI_node = path_node.SelectNodes("./GUI");
                    foreach (XmlNode node in GUI_node)
                    {
                        gui.name     = node.SelectSingleNode("Name").InnerText;
                        gui.video    = Convert.ToBoolean(node.SelectSingleNode("Video").InnerText);
                        gui.startend = Convert.ToBoolean(node.SelectSingleNode("StartEnd").InnerText);
                        gui.altitude = Convert.ToDouble(node.SelectSingleNode("Altitude").InnerText);
                        gui.heading  = Convert.ToDouble(node.SelectSingleNode("Heading").InnerText);
                        gui.length   = Convert.ToDouble(node.SelectSingleNode("Length").InnerText);
                        gui.width    = Convert.ToDouble(node.SelectSingleNode("Width").InnerText);
                        gui.single   = Convert.ToBoolean(node.SelectSingleNode("SinglePath").InnerText);
                        gui.poimode  = Convert.ToBoolean(node.SelectSingleNode("POIMode").InnerText);
                        gui.poiname  = node.SelectSingleNode("POIName").InnerText;
                    }
                    path.rectanglegui = gui;
                }

                if (path.type == "Polygon")
                {
                    PolygonGridGUI gui      = new PolygonGridGUI();
                    XmlNodeList    GUI_node = path_node.SelectNodes("./GUI");
                    foreach (XmlNode node in GUI_node)
                    {
                        gui.name             = node.SelectSingleNode("Name").InnerText;
                        gui.video            = Convert.ToBoolean(node.SelectSingleNode("Video").InnerText);
                        gui.startend         = Convert.ToBoolean(node.SelectSingleNode("StartEnd").InnerText);
                        gui.altitude         = Convert.ToDouble(node.SelectSingleNode("Altitude").InnerText);
                        gui.heading          = Convert.ToDouble(node.SelectSingleNode("Heading").InnerText);
                        gui.polyname         = node.SelectSingleNode("PolyName").InnerText;
                        gui.poly_internal_id = Convert.ToInt16(node.SelectSingleNode("Poly_IntID").InnerText);
                    }
                    path.polygridgui = gui;
                }

                path.selected = false;
                path.visible  = false;
                LinkedList <WayPoints> way_list = new LinkedList <WayPoints>();

                XmlNodeList way_nodes = path_node.SelectNodes("./Waypoint");
                int         way_count = way_nodes.Count;

                dialog_text = dialog_text + "Path : " + path.name + "Type : " + path.type + "\n";
                dialog_text = dialog_text + "Waypoint Count : " + Convert.ToString(way_count) + "\n";
                //MessageBox.Show(dialog_text, "xxx");
                way_count = 0;
                foreach (XmlNode wp_node in way_nodes)
                {
                    WayPoints waypoint = new WayPoints();
                    waypoint.lat         = Convert.ToDouble(wp_node.SelectSingleNode("Lat").InnerText);
                    waypoint.lon         = Convert.ToDouble(wp_node.SelectSingleNode("Lon").InnerText);
                    waypoint.alt         = Convert.ToDouble(wp_node.SelectSingleNode("Alt").InnerText);
                    waypoint.head        = Convert.ToDouble(wp_node.SelectSingleNode("Heading").InnerText);
                    waypoint.curvesize   = Convert.ToDouble(wp_node.SelectSingleNode("CurveSize").InnerText);
                    waypoint.rotationdir = Convert.ToDouble(wp_node.SelectSingleNode("RotationDir").InnerText);
                    waypoint.gimblemode  = Convert.ToInt16(wp_node.SelectSingleNode("GimbleMode").InnerText);
                    waypoint.gimblepitch = Convert.ToDouble(wp_node.SelectSingleNode("GimblePitch").InnerText);

                    XmlNodeList action_nodes = wp_node.SelectNodes("./Action");
                    int         action_count = action_nodes.Count;
                    dialog_text = dialog_text + "Waypoint : " + Convert.ToString(way_count) + "\n";
                    dialog_text = dialog_text + "Action Count : " + Convert.ToString(action_count) + "\n";

                    int[,] actions_arr = new int[100, 2];
                    int i = 0;
                    int act_type, act_param;
                    foreach (XmlNode act_node in action_nodes)
                    {
                        act_type          = Convert.ToInt16(act_node.SelectSingleNode("Type").InnerText);
                        act_param         = Convert.ToInt16(act_node.SelectSingleNode("Param").InnerText);
                        dialog_text       = dialog_text + "Action Count : " + Convert.ToString(i);
                        dialog_text       = dialog_text + ", Action Type : " + Convert.ToString(act_type);
                        dialog_text       = dialog_text + ", Action Param : " + Convert.ToString(act_param) + "\n";
                        actions_arr[i, 0] = act_type;
                        actions_arr[i, 1] = act_param;
                        i++;
                    }
                    waypoint.actions = actions_arr;

                    way_list.AddLast(waypoint);
                    way_count++;
                }
                //MessageBox.Show(dialog_text, "xxx");
                path.waypoints = way_list;
                AddPathId(path.internal_id, path);
                path_count++;
            }
        }
示例#20
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     BizObject = null;
 }
示例#21
0
 private static Path Convert(Models.Path path)
 {
     return(new Path(path.Id, path.From, path.To, Convert(path.Type)));
 }
示例#22
0
        //
        //
        // Path Mathods
        //
        //

        public void AddPath(Models.Path path)
        {
            path.internal_id = next_internal_id();
            path_list.AddLast(path);
        }
示例#23
0
 public void DeletePath(Models.Path path)
 {
     path_list.Remove(path);
 }