コード例 #1
0
        /// <summary>
        /// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
        /// </summary>
        /// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
        /// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
        /// <returns>
        /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
        /// </returns>
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            XElement getNode = _node.Element(binder.Name);

            if (getNode != null)
            {
                result = new DynamicXMLNode(getNode);
                return(true);
            }

            result = null;
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Opens the specified file name.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="map">The map.</param>
        /// <param name="layer">The layer.</param>
        public static void Open(string fileName, IMap map, Layer layer)
        {
            Contract.Requires(!string.IsNullOrEmpty(fileName), "fileName is null or empty.");
            Contract.Requires(map != null, "map is null.");
            Contract.Requires(layer != null, "featureLayer is null.");

            string lblFile = Path.ChangeExtension(fileName, "lbl");

            if (File.Exists(lblFile) && layer is IFeatureLayer)
            {
                try
                {
                    dynamic parser = DynamicXMLNode.Load(lblFile);
                    DeserializeLabels(parser.Labels, map, layer as IFeatureLayer);
                }
                catch (RuntimeBinderException ex)
                {
                    Trace.WriteLine(ex.Message);
                }
            }

            string mwsrFile = Path.ChangeExtension(fileName, "mwsr");

            if (File.Exists(mwsrFile))
            {
                try
                {
                    dynamic parser = DynamicXMLNode.Load(mwsrFile);
                    DeserializeLayer(parser.Layer, map, layer);
                }
                catch (RuntimeBinderException ex)
                {
                    Trace.WriteLine(ex.Message);
                }
            }

            string mwleg = Path.ChangeExtension(fileName, "mwleg");

            if (File.Exists(mwleg) && layer is MapImageLayer)
            {
                try
                {
                    dynamic parser = DynamicXMLNode.Load(mwleg);
                    DeserializeLegend(parser.GridColoringScheme, map, layer);
                }
                catch (RuntimeBinderException ex)
                {
                    Trace.WriteLine(ex.Message);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Opens the MW4 style project file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        public void OpenFile(string fileName)
        {
            dynamic parser = DynamicXMLNode.Load(fileName);

            switch ((string)parser["type"])
            {
            case "projectfile":
                new ProjectFileVer1Deserializer(_map).Deserialize(parser);
                break;

            case "projectfile.2":
                new ProjectFileVer2Deserializer(_map).Deserialize(parser);
                break;

            default:
                throw new Exception("Unknown project file format");
            }
        }
コード例 #4
0
        /// <summary>
        /// Opens the MW4 style project file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        public void OpenFile(string fileName)
        {
            dynamic parser = DynamicXMLNode.Load(fileName);

            _map.MapFrame.ProjectionString = parser["ProjectProjection"];

            if (!Convert.ToBoolean(parser["ViewBackColor_UseDefault"]))
            {
                var mapControl = _map as Control;
                if (mapControl != null)
                {
                    mapControl.BackColor = LegacyDeserializer.GetColor(parser["ViewBackColor"]);
                }

                _map.Invalidate();
            }

            _map.MapFrame.ViewExtents.MaxX = Convert.ToDouble(parser.Extents["xMax"]);
            _map.MapFrame.ViewExtents.MaxY = Convert.ToDouble(parser.Extents["yMax"]);
            _map.MapFrame.ViewExtents.MinX = Convert.ToDouble(parser.Extents["xMin"]);
            _map.MapFrame.ViewExtents.MinY = Convert.ToDouble(parser.Extents["yMin"]);

            DeserializeGroups(parser.Groups.Elements());
        }
コード例 #5
0
 /// <summary>
 /// Provides the implementation for operations that get member values. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as getting a value for a property.
 /// </summary>
 /// <param name="binder">Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
 /// <param name="result">The result of the get operation. For example, if the method is called for a property, you can assign the property value to <paramref name="result"/>.</param>
 /// <returns>
 /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
 /// </returns>
 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     XElement getNode = node.Element(binder.Name);
     if (getNode != null)
     {
         result = new DynamicXMLNode(getNode);
         return true;
     }
     else
     {
         result = null;
         return false;
     }
 }