示例#1
0
        /// <summary>
        /// Retrieves an instance from script data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static DirectionsChangedEventArgs FromScriptData(IDictionary <string, object> data)
        {
            var    args = new DirectionsChangedEventArgs();
            object value;

            if (data.TryGetValue("distance", out value))
            {
                args.Distance = Distance.FromScriptData(value as IDictionary <string, object>);
            }
            if (data.TryGetValue("duration", out value))
            {
                args.Duration = Duration.FromScriptData(value as IDictionary <string, object>);
            }
            if (data.TryGetValue("end_address", out value))
            {
                args.EndAddress = value as string;
            }
            if (data.TryGetValue("end_location", out value))
            {
                args.EndLocation = LatLng.FromScriptData(value as IDictionary <string, object>);
            }
            if (data.TryGetValue("start_address", out value))
            {
                args.StartAddress = value as string;
            }
            if (data.TryGetValue("start_location", out value))
            {
                args.StartLocation = LatLng.FromScriptData(value as IDictionary <string, object>);
            }

            if (data.TryGetValue("steps", out value))
            {
                object[] items = value as object[];
                if (items != null)
                {
                    var list = new List <DirectionsStep>();
                    for (int i = 0; i < items.Length; i++)
                    {
                        var item = DirectionsStep.FromScriptData(items[i] as IDictionary <string, object>);
                        if (item != null)
                        {
                            list.Add(item);
                        }
                    }
                    args.Steps = list.ToArray();
                }
            }

            return(args);
        }
示例#2
0
        /// <summary>
        /// When implemented by a class, enables a server control to process an evePnt raised when a form is posted to the server.
        /// </summary>
        /// <param name="eventArgument">A <see cref="T:System.String"/> that represents an optional event argument to be passed to the event handler.</param>
        public void RaisePostBackEvent(string eventArgument)
        {
            var     ser  = new JavaScriptSerializer();
            dynamic args = ser.DeserializeObject(eventArgument);

            if (args != null)
            {
                string name = args["name"];
                if (args["route"] != null)
                {
                    var e = DirectionsChangedEventArgs.FromScriptData(args["route"]);
                    switch (name)
                    {
                    case "change":
                        this.OnChanged(e);
                        break;
                    }
                }
            }
        }
示例#3
0
 /// <summary>
 /// Raises the <see cref="E:Changed"/> event.
 /// </summary>
 /// <param name="e">The <see cref="Velyo.Google.Maps.DirectionsChangedEventArgs"/> instance containing the event data.</param>
 protected virtual void OnChanged(DirectionsChangedEventArgs e)
 {
     Changed?.Invoke(this, e);
 }