public static void RemoteActivationViaHttpRequest()
        {
            string strDeviceId;

            CApplicationAPI.GetUniqueDeviceId(out _mySError, out strDeviceId, 0);
            O("GetUniqueDeviceId returns: " + strDeviceId);


            //string productId = "2324";
            //string sdPassword = "******";

            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create("http://www.sygic.com/partners/activate.php");
            string         postData = "type=2&SD_password=6E193DBF&product_ID=2324&device_code=" + strDeviceId + "&description=Skuska";

            byte[] data = Encoding.ASCII.GetBytes(postData.ToCharArray());

            request.Method        = "POST";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

            O(responseString);
        }
        public static void GetUniqueDeviceId()
        {
            string strDeviceId;

            CApplicationAPI.GetUniqueDeviceId(out _mySError, out strDeviceId, 0);
            O("GetUniqueDeviceId returns: " + strDeviceId);
        }
        public static void GetCurrentSpeedLimit(int inMaxTime)
        {
            int nSpeedLimit = 0;
            int ret         = CApplicationAPI.GetCurrentSpeedLimit(out _mySError, out nSpeedLimit, inMaxTime);

            O("GetCurrentSpeedLimit returns: " + ret.ToString() + ", nSpeedLimit= " + nSpeedLimit.ToString());
        }
        public static void GetActualGpsPosition(bool inSatellitesInfo, int inMaxTime)
        {
            SGpsPosition gpos = new SGpsPosition();
            int          ret  = CApplicationAPI.GetActualGpsPosition(out _mySError, out gpos, inSatellitesInfo, inMaxTime);

            O("GetActualGpsPosition returns: " + ret.ToString());
            //O("Altitude: " + gpos.Altitude.ToString());
            O("Course: " + gpos.Course.ToString());
            //O("Date: " + gpos.Date.ToString());
            //O("FromPointOffset: " + gpos.FromPointOffset.ToString());
            O("HDoP: " + gpos.HDoP.ToString());
            O("Latitude: " + gpos.Latitude.ToString());
            O("Longitude: " + gpos.Longitude.ToString());
            //O("MapIso: " + gpos.MapIso.ToString());
            O("RealCourse: " + gpos.RealCourse.ToString());
            O("RoadOffset: " + gpos.RoadOffset.ToString());
            O("Satellites:" + gpos.Satellites.ToString());
            //for (int i = 0; i < gpos.Satellites; i++ )
            //    O(i.ToString() + ". sat: "
            //        + gpos.satellitesInfo[i].Azimuth.ToString() + ", "
            //        + gpos.satellitesInfo[i].Elevation.ToString() + ", "
            //        + gpos.satellitesInfo[i].Quality.ToString() + ", "
            //        + gpos.satellitesInfo[i].SateliteId.ToString() + ", "
            //        + gpos.satellitesInfo[i].UsedForFix.ToString());
            O("Speed: " + gpos.Speed.ToString());
            //O("Time: " + gpos.Time.ToString());
            //O("ToPointOffset: " + gpos.ToPointOffset.ToString());
        }
        public static void ShowMessage(string inMessage, int inButtons, bool inWaitForFeedback, bool inBShowApplication, int inMaxTime)
        {
            int inNUserFeedback = 0;
            int ret             = CApplicationAPI.ShowMessage(out _mySError, inMessage, inButtons, inWaitForFeedback, inBShowApplication, ref inNUserFeedback, inMaxTime);

            O("ShowMessage: " + ret.ToString() + ", nUserFeedback: " + inNUserFeedback);
        }
        public static void TripStart(string inTripName, string inDataMode, int inMaxTime)
        {
            TripBookRecordDataMode tmpDataMode = TripBookRecordDataMode.tbdmNoData;

            switch (inDataMode)
            {
            case "tbdmNoData":
                tmpDataMode = TripBookRecordDataMode.tbdmNoData;
                break;

            case "tbdmFullData":
                tmpDataMode = TripBookRecordDataMode.tbdmFullData;
                break;

            case "tbdmFullNMEA":
                tmpDataMode = TripBookRecordDataMode.tbdmFullNMEA;
                break;

            default:
                break;
            }

            int ret = CApplicationAPI.TripStart(out _mySError, inTripName, (int)tmpDataMode, inMaxTime);

            O("TripStart returns: " + ret.ToString());
        }
        public static string GetCoordinatesFromListOfOffsetIds(string inPath)
        {
            StringBuilder s = new StringBuilder("");

            if (File.Exists(inPath))
            {
                LONGPOSITION lp         = new LONGPOSITION();
                string       tmp        = "";
                string[]     parameters = new string[2];

                StreamReader sr = new StreamReader(inPath);
                while (!sr.EndOfStream)
                {
                    tmp        = sr.ReadLine();
                    parameters = tmp.Split(';');
                    CApplicationAPI.GetCoordinatesFromOffset(
                        out _mySError,
                        parameters[0],
                        int.Parse(parameters[1]),
                        out lp,
                        0);
                    s.AppendLine(lp.lX.ToString() + ";" + lp.lY.ToString());
                }
                sr.Close();
            }
            return(s.ToString());
        }
        public static void DirectGeocoding(int inX, int inY, int inMaxTime)
        {
            LONGPOSITION lp         = new LONGPOSITION(inX, inY);
            string       strAddress = "";
            SRoadInfo    sri        = new SRoadInfo();
            int          ret        = CApplicationAPI.GetLocationInfo(out _mySError, lp, out strAddress, out sri, inMaxTime);

            O("GetLocationInfo returns: " + ret + ", errorcode: " + MySError.nCode.ToString());
            if (ret == 1)
            {
                O("lRoadOffset: " + sri.lRoadOffset.ToString());
                O("OnroadPosition: X:" + sri.OnroadPosition.lX.ToString() + " Y: " + sri.OnroadPosition.lY.ToString());
                O("OffroadDistance:" + sri.dwOffroadDistance);
                O("IsCongestionCharge: " + sri.IsCongestionCharge.ToString());
                O("IsFerry: " + sri.IsFerry.ToString());
                O("IsoCode: " + sri.IsoCode.ToString());
                O("IsPaved: " + sri.IsPaved.ToString());
                O("IsProhibited: " + sri.IsProhibited.ToString());
                O("IsTollRoad: " + sri.IsTollRoad.ToString());
                O("IsTunnel: " + sri.IsTunnel.ToString());
                O("IsUrban: " + sri.IsUrban.ToString());
                O("RoadClass: " + sri.RoadClass.ToString());
                O("SpeedCategory: " + sri.SpeedCategory.ToString());
                O("SpeedRestriction: " + sri.SpeedRestriction.ToString());
                O("strAddress: " + strAddress);
            }

            int ret2 = CApplicationAPI.ShowCoordinatesOnMap(out _mySError, lp, 2, true, 0);

            O("ShowCoordinatesOnMap returns: " + ret2.ToString());
        }
        public static List <int> DetectWrongWaypoints(string inPath) //inPath = name of itinerary (i.e. "default")
        {
            SStopOffPoint[] wp;
            List <int>      ids = new List <int>();

            CApplicationAPI.GetItineraryList(out _mySError, inPath, out wp, 0);

            if (wp != null)
            {
                for (int i = 0; i < wp.Length - 1; i++)
                {
                    SStopOffPoint[] tmpWp = new SStopOffPoint[2];
                    tmpWp[0]            = wp[i];
                    tmpWp[0].nPointType = 3;

                    tmpWp[1]            = wp[i + 1];
                    tmpWp[1].nPointType = 2;

                    CApplicationAPI.AddItinerary(out _mySError, tmpWp, inPath + "-" + i.ToString(), 0);
                    int result = CApplicationAPI.SetRoute(out _mySError, inPath + "-" + i.ToString(), 0, true, 0);
                    if (result != 1)
                    {
                        ids.Add(i + 1);
                    }
                }
            }
            return(ids);
        }
        public static void GetRouteInfo(int inMaxTime)
        {
            SRouteInfo RouteInfo = new SRouteInfo();
            int        ret       = CApplicationAPI.GetRouteInfo(out _mySError, out RouteInfo, inMaxTime);

            ushort years;
            byte   months, days, hours, minutes, seconds;

            RouteInfo.GetEstimatedTimeArival(out years, out months, out days, out hours, out minutes, out seconds);

            O("GetRouteInfo returns: " + ret.ToString());
            O("RouteInfo.BoundaryRectangle(lBottom,lLeft,lRight,lTop): " + RouteInfo.BoundaryRectangle.lBottom.ToString()
              + "," + RouteInfo.BoundaryRectangle.lLeft.ToString()
              + "," + RouteInfo.BoundaryRectangle.lRight.ToString()
              + "," + RouteInfo.BoundaryRectangle.lTop.ToString());
            O("RouteInfo.EstimatedTimeArival: " + RouteInfo.EstimatedTimeArival.ToString()
              + ", " + years.ToString()
              + "-" + months.ToString()
              + "-" + days.ToString()
              + ", " + hours.ToString()
              + ":" + minutes.ToString()
              + ":" + seconds.ToString());
            O("RouteInfo.FerriesLength: " + RouteInfo.FerriesLength.ToString());
            O("RouteInfo.MotorwaysLength: " + RouteInfo.MotorwaysLength.ToString());
            O("RouteInfo.RemainingDistance: " + RouteInfo.RemainingDistance.ToString());
            O("RouteInfo.RemaningTime: " + RouteInfo.RemaningTime.ToString());
            O("RouteInfo.Status: " + RouteInfo.Status.ToString());
            O("RouteInfo.TollRoadsLength: " + RouteInfo.TollRoadsLength.ToString());
            O("RouteInfo.TotalDistance: " + RouteInfo.TotalDistance.ToString());
            O("RouteInfo.TotalTime: " + RouteInfo.TotalTime.ToString());
        }
        public static void HighlightPoi(string inPoiCategory, string inPoiName, string inSound, int inX, int inY, int inMaxTime)
        {
            LONGPOSITION lp  = new LONGPOSITION(inX, inY);
            int          ret = CApplicationAPI.HighlightPoi(out _mySError, inPoiCategory, inPoiName, inSound, lp, inMaxTime);

            O("HighlightPoi returns: " + ret.ToString());
        }
        public static void GetMapVersion(string inStrIso, int inMaxTime)
        {
            string strMapVersion = "";
            int    ret           = CApplicationAPI.GetMapVersion(out _mySError, inStrIso, out strMapVersion, inMaxTime);

            O("GetMapVersion returns: " + ret.ToString());
            O("StrMapVersion: " + strMapVersion);
        }
        public static void GetCoordinatesFromOffset(string inIsoCode, int inRoadOffset, int inMaxTime)
        {
            LONGPOSITION lp  = new LONGPOSITION();
            int          ret = CApplicationAPI.GetCoordinatesFromOffset(out _mySError, inIsoCode, inRoadOffset, out lp, inMaxTime);

            O("GetCoordinatesFromOffset returns: " + ret.ToString());
            O("x=" + lp.lX.ToString() + ", y=" + lp.lY.ToString());
        }
        public static int StartDrive(int inLeft, int inTop, int inWidth, int inHeight, bool inRunInForeground, bool inNoCaption)
        {
            ApplicationAPI.CApplicationAPI.ApplicationHandler AppHnd = new CApplicationAPI.ApplicationHandler(NavHandler);
            int ret = CApplicationAPI.InitApi(_myDrivePath, AppHnd, inLeft, inTop, inWidth, inHeight, inRunInForeground, inNoCaption);

            O("InitApi returns: " + ret.ToString());
            return(ret);
        }
        public static void GetSdkVersion()
        {
            string sdkVersion  = "";
            string buildNumber = "";
            int    ret         = CApplicationAPI.GetSdkVersion(out _mySError, out sdkVersion, out buildNumber, 0);

            O("GetSdkVersion returns: " + ret.ToString() + "; " + sdkVersion + "; " + buildNumber);
        }
        public static void AddBitmapToMap(string inPathToBitmap, int inX, int inY, int inMaxTime)
        {
            SError error;
            int    nBitmapID;

            int ret = CApplicationAPI.AddBitmapToMap(out error, inPathToBitmap, inX, inY, out nBitmapID, inMaxTime);

            O("AddBitmapToMap returns: " + ret.ToString());
        }
        public static void StartNavigation(int inlX, int inlY, int inFlags, bool inbShowApplication, bool inbSearchAddress, int inMaxTime)
        {
            LONGPOSITION lp = new LONGPOSITION(inlX, inlY);
            SWayPoint    wp = new SWayPoint();

            wp.Location = lp;
            int ret = CApplicationAPI.StartNavigation(out _mySError, ref wp, inFlags, inbShowApplication, inbSearchAddress, inMaxTime);

            O("StartNavigation returns: " + ret.ToString() + ", errorcode: " + _mySError.nCode.ToString());
        }
        public static void AutomaticRemoteActivation(string inActivateExePath, string inMlmPath, string inSdPassword)
        {
            string strDeviceID = "";
            int    ret         = CApplicationAPI.GetUniqueDeviceId(out _mySError, out strDeviceID, 0);

            ProcessStartInfo process = new ProcessStartInfo();

            process.FileName  = inActivateExePath;
            process.Arguments = "\"" + inMlmPath + "\" " + inSdPassword;
            Process.Start(process);
        }
        public static void AddPoi(int inX, int inY, string inCategory, string inName, bool inSearch_address, int inMaxTime)
        {
            LONGPOSITION lp;

            lp.lX = inX;
            lp.lY = inY;
            SPoi p   = new SPoi(lp, inCategory, inName, inSearch_address ? 1 : 0);
            int  ret = CApplicationAPI.AddPoi(out _mySError, ref p, inMaxTime);

            O("AddPoi returns: " + ret.ToString());
        }
        //AddPoi with LocationFromAddress
        public static void AddPoi(string inStrAddress, bool inBPostal, bool inBValueMatch, string inCategory, string inName, bool inSearch_address, int inMaxTime)
        {
            LONGPOSITION lp;
            int          ret = CApplicationAPI.LocationFromAddress(out _mySError, out lp, inStrAddress, inBPostal, inBValueMatch, inMaxTime);

            O("LocationFromAddress returns: " + ret.ToString());
            SPoi p = new SPoi(lp, inCategory, inName, inSearch_address ? 1 : 0);

            ret = CApplicationAPI.AddPoi(out _mySError, ref p, inMaxTime);
            O("AddPoi returns: " + ret.ToString());
        }
        public static void GetPoiCategoryList(int inMaxTime)
        {
            SPoiCategory[] pc;
            int            ret = CApplicationAPI.GetPoiCategoryList(out _mySError, out pc, inMaxTime);

            O("GetPoiCategoryList returns: " + ret.ToString() + ", found categories: " + pc.Length);
            for (int i = 0; i < pc.Length; i++)
            {
                O("Category[" + i.ToString() + "]: " + pc[i].Name);
            }
        }
        public static void ShowRectangleOnMap(int inLBottom, int inLLeft, int inLRight, int inLTop, bool inBShowApplication, int inMaxTime)
        {
            LONGRECT r;

            r.lBottom = inLBottom;
            r.lLeft   = inLLeft;
            r.lRight  = inLRight;
            r.lTop    = inLTop;
            int ret = CApplicationAPI.ShowRectangleOnMap(out _mySError, r, inBShowApplication, inMaxTime);

            O("ShowRectangleOnMap returns: " + ret.ToString());
        }
        public static string[] GetPoiCategoryList()
        {
            SPoiCategory[] pc;
            string[]       list;
            int            ret = CApplicationAPI.GetPoiCategoryList(out _mySError, out pc, 0);

            list = new string[pc.Length];
            for (int i = 0; i < pc.Length; i++)
            {
                list[i] = pc[i].Name;
            }
            return(list);
        }
        public static void LocationFromAddress(string inStrAddress, bool inBPostal, bool inBValueMatch, int inMaxTime)
        {
            LONGPOSITION location;
            int          ret = CApplicationAPI.LocationFromAddress(out _mySError, out location, inStrAddress, inBPostal, inBValueMatch, inMaxTime);

            O("LocationFromAddressEx returns: " + ret.ToString());
            if (ret == 1)
            {
                string tmpAddress;
                CApplicationAPI.GetLocationInfo(out _mySError, location, out tmpAddress, inMaxTime);
                O("x=" + location.lX.ToString() + ", y=" + location.lY.ToString() + ", address:" + tmpAddress);
            }
        }
        public static void GetNextInstruction(int inMaxTime)
        {
            SRouteInstruction instr = new SRouteInstruction();
            int ret = CApplicationAPI.GetNextInstruction(out _mySError, out instr, inMaxTime);

            O("GetNextInstruction returns: " + ret);
            O("ExitIndex: " + instr.ExitIndex.ToString());
            O("lDistanceToNextTurn: " + instr.lDistanceToNextTurn.ToString());
            O("lNextTurnX: " + instr.lNextTurnX.ToString());
            O("lNextTurnY: " + instr.lNextTurnY.ToString());
            O("nInstruction: " + instr.nInstruction.ToString());
            O("nRoundaboutExitIndex: " + instr.nRoundaboutExitIndex.ToString());
        }
        public static void FindNearbyPoi(int inListSize, int inCategoryNumber, string inStrCategoryName, int inLX, int inLY, int inMaxTime)
        {
            SPoi[] pois = new SPoi[0];
            int    ret  = CApplicationAPI.FindNearbyPoi(out _mySError, out pois, ref inListSize, inCategoryNumber, inStrCategoryName, inLX, inLY, inMaxTime);

            O("FindNearbyPoi returns: " + ret.ToString());
            if (pois != null)
            {
                for (int i = 0; i < pois.Length; i++)
                {
                    O(" " + i.ToString() + ". " + pois[i].GetName() + ", " + pois[i].GetAddress());
                }
            }
        }
        public static void GetPoiList(string inStrCategory, bool inBSearchAddress, int inMaxTime)
        {
            SPoi[] pois;
            int    ret = CApplicationAPI.GetPoiList(out _mySError, out pois, inStrCategory, inBSearchAddress, inMaxTime);

            O("GetPoiList returns: " + ret.ToString() + "error: " + _mySError.nCode.ToString());
            if (pois != null)
            {
                for (int i = 0; i < pois.Length; i++)
                {
                    O(i.ToString() + ". poi: " + pois[i].GetName() + ", " + pois[i].GetAddress());
                }
            }
        }
        public static void AddEntryToItinerary(string inStrItineraryName, int inLX, int inLY, int inNPointType, string inCaption, int inNIndex, uint inId)
        {
            SStopOffPoint point = new SStopOffPoint();

            point.Location.lX = inLX;
            point.Location.lY = inLY;
            point.nPointType  = inNPointType;
            point.SetCaption(inCaption);
            point.Id = inId;

            int ret = CApplicationAPI.AddEntryToItinerary(out _mySError, inStrItineraryName, ref point, inNIndex, 0);

            O("AddEntryToItinerary returns: " + ret.ToString());
        }
        public static void GetNextInstruction(int inMaxTime, out string[] outArr)
        {
            SRouteInstruction outInstr = new SRouteInstruction();
            int ret = CApplicationAPI.GetNextInstruction(out _mySError, out outInstr, inMaxTime);

            string[] arr = new string[6];
            arr[0] = outInstr.ExitIndex.ToString();
            arr[1] = outInstr.lDistanceToNextTurn.ToString();
            arr[2] = outInstr.lNextTurnX.ToString();
            arr[3] = outInstr.lNextTurnY.ToString();
            arr[4] = outInstr.nInstruction.ToString();
            arr[5] = outInstr.nRoundaboutExitIndex.ToString();
            outArr = arr;
        }
        public static void AddBitmapToMap(string inPathToBitmap, string inAddress, int inMaxTime)
        {
            SError       error;
            int          lX, lY;
            int          nBitmapID;
            LONGPOSITION Position;

            CApplicationAPI.LocationFromAddress(out error, out Position, inAddress, false, inMaxTime);
            lX = Position.lX;
            lY = Position.lY;

            int ret = CApplicationAPI.AddBitmapToMap(out error, inPathToBitmap, lX, lY, out nBitmapID, inMaxTime);

            O("AddBitmapToMap returns: " + ret.ToString());
        }