internal static void BaglantiCumleleriAta()
        {
            string baglantiCumlesiDosyaYolu = Path.Combine(Application.StartupPath, "System.dat");

            string sifreliCumle = string.Empty;

            if (File.Exists(baglantiCumlesiDosyaYolu))
            {
                sifreliCumle = File.ReadAllText(baglantiCumlesiDosyaYolu);
            }

            string baglantiCumleleri = string.Empty;

            if (!string.IsNullOrEmpty(sifreliCumle))
            {
                UniqueValue sifreleme = new UniqueValue();
                baglantiCumleleri = sifreleme.EnDeCrypt(sifreliCumle);
            }
            string[] baglantiCumleleriArray = baglantiCumleleri.Split(new string[] { "^#^" }, StringSplitOptions.None);

            if (baglantiCumleleriArray.Length > 0 && !string.IsNullOrWhiteSpace(baglantiCumleleriArray[0]))
            {
                SqlHelper.DinamikConnStr = baglantiCumleleriArray[0];
            }
        }
Example #2
0
 /// <summary>
 /// 返回从源类型到目标类型的用户定义的显式转换方法。
 /// 该转换方法的参数与源类型和目标类型并不一定完全相同,但保证存在标准显式转换。
 /// </summary>
 /// <param name="sourceType">要获取用户定义的转换方法的源类型。</param>
 /// <param name="targetType">要获取用户定义的转换方法的目标类型。</param>
 /// <returns>如果存在从源类型到目标类型的用户定义的显式转换方法,则返回该方法;
 /// 否则返回 <c>null</c>。</returns>
 public static ConversionMethod GetExplicitConversion(Type sourceType, Type targetType)
 {
     Type exactSource = null, exactTarget = null;
     UniqueValue<ConversionMethod> method = new UniqueValue<ConversionMethod>();
     Conversion conv = GetTypeConversions(sourceType.GetNonNullableType());
     for (int i = conv.ConvertToIndex; i < conv.Methods.Length; i++)
     {
         ConversionMethod m = conv.Methods[i];
         if (targetType.IsStandardExplicitFrom(m.TargetType))
         {
             GetBestConversion(m, ref exactSource, ref exactTarget, method);
         }
     }
     conv = GetTypeConversions(targetType.GetNonNullableType());
     for (int i = Conversion.ConvertFromIndex; i < conv.ConvertToIndex; i++)
     {
         ConversionMethod m = conv.Methods[i];
         if (m.SourceType.IsStandardExplicitFrom(sourceType))
         {
             GetBestConversion(m, ref exactSource, ref exactTarget, method);
         }
     }
     if (method.IsUnique)
     {
         return method.Value;
     }
     return null;
 }
Example #3
0
        private static void FindMinMax(UniqueValue[] p_uniqueValues, out UniqueValue p_minVal, out UniqueValue p_maxVal)
        {
            p_minVal = null;
            p_maxVal = null;

            if (p_uniqueValues.Length != 0)
            {
                p_minVal = p_uniqueValues[0];
                p_maxVal = p_uniqueValues[0];
            }

            for (int index = 1; index < p_uniqueValues.Length; index++)
            {
                var uniqueValue = p_uniqueValues[index];

                if (uniqueValue.Value < p_minVal.Value)
                {
                    p_minVal = uniqueValue;
                }

                if (uniqueValue.Value > p_maxVal.Value)
                {
                    p_maxVal = uniqueValue;
                }
            }
        }
        private async void Initialize()
        {
            try
            {
                _progressBar.Visibility = Android.Views.ViewStates.Visible;
                _status.Text = "Loading Utility Network...";

                // Create a map.
                _myMapView.Map = new Map(new Basemap(new Uri("https://www.arcgis.com/home/item.html?id=1970c1995b8f44749f4b9b6e81b5ba45")))
                {
                    InitialViewpoint = _startingViewpoint
                };

                // Add the layer with electric distribution lines.
                FeatureLayer lineLayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115"));
                UniqueValue mediumVoltageValue = new UniqueValue("N/A", "Medium Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3), 5);
                UniqueValue lowVoltageValue = new UniqueValue("N/A", "Low Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.DarkCyan, 3), 3);
                lineLayer.Renderer = new UniqueValueRenderer(new List<string>() { "ASSETGROUP" }, new List<UniqueValue>() { mediumVoltageValue, lowVoltageValue }, "", new SimpleLineSymbol());
                _myMapView.Map.OperationalLayers.Add(lineLayer);

                // Add the layer with electric devices.
                FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100"));
                _myMapView.Map.OperationalLayers.Add(electricDevicelayer);

                // Set the selection color for features in the map view.
                _myMapView.SelectionProperties = new SelectionProperties(System.Drawing.Color.Yellow);

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), _myMapView.Map);

                // Get the utility tier used for traces in this network. For this data set, the "Medium Voltage Radial" tier from the "ElectricDistribution" domain network is used.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork("ElectricDistribution");
                _mediumVoltageTier = domainNetwork.GetTier("Medium Voltage Radial");

                // More complex datasets may require using utility trace configurations from different tiers. The following LINQ expression gets all tiers present in the utility network.
                //IEnumerable<UtilityTier> tiers = _utilityNetwork.Definition.DomainNetworks.Select(domain => domain.Tiers).SelectMany(tier => tier);

                // Create symbols for starting locations and barriers.
                _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LightGreen, 25d);
                _barrierPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.OrangeRed, 25d);

                // Create a graphics overlay.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                _myMapView.GraphicsOverlays.Add(graphicsOverlay);

                // Set the instruction text.
                _status.Text = "Tap on the network lines or points to add a utility element.";
            }
            catch (Exception ex)
            {
                _status.Text = "Loading Utility Network failed...";
                CreateDialog(ex.Message, title: ex.GetType().Name);
            }
            finally
            {
                _progressBar.Visibility = Android.Views.ViewStates.Invisible;
            }
        }
        internal static void BaglantiCumleleriKaydet()
        {
            string veri = SqlHelper.DinamikConnStr;

            string baglantiCumlesiDosyaYolu = Path.Combine(Application.StartupPath, "System.dat");

            UniqueValue sifreleme    = new UniqueValue();
            string      sifreliCumle = sifreleme.EnDeCrypt(veri);

            File.WriteAllText(baglantiCumlesiDosyaYolu, sifreliCumle);
        }
Example #6
0
 public override string ToString()
 {
     if (Empty)
     {
         return("Empty");
     }
     if (IsUnique)
     {
         return(UniqueValue.ToString(CultureInfo.InvariantCulture));
     }
     return(string.Format("[{0}, {1}]", Lower, Upper));
 }
Example #7
0
        public UniqueValue[] GetHistagrammValues(UniqueValue[] p_uniqueValues)
        {
            UniqueValue[] resultedValues;
            if (p_uniqueValues.Length == ChartSize)
            {
                resultedValues = p_uniqueValues;
            }
            else
            {
                resultedValues = new UniqueValue[ChartSize];
                UniqueValue minValue;
                UniqueValue maxValue;
                FindMinMax(p_uniqueValues, out minValue, out maxValue);

                var step = maxValue.Value / ((double)ChartSize - 1);

                for (int i = 0; i < resultedValues.Length; i++)
                {
                    var resultedValue = resultedValues[i] = new UniqueValue();
                    resultedValue.Count = 0;
                    resultedValue.Value = i * step;
                }
                resultedValues[0].Value = minValue.Value;
                resultedValues[resultedValues.Length - 1].Value = maxValue.Value;


                for (int i = 0; i < p_uniqueValues.Length; i++)
                {
                    var uniqueValue = p_uniqueValues[i];
                    var index       = FindIndex(step, uniqueValue.Value);

                    var resultedValue = resultedValues[index];

                    resultedValue.Count += uniqueValue.Count;
                }
            }

            double summ = 0.0;

            for (int i = 0; i < resultedValues.Length; i++)
            {
                summ += resultedValues[i].Count;
            }

            for (int i = 0; i < resultedValues.Length; i++)
            {
                var resultedValue = resultedValues[i];
                resultedValue.Count = 100 * (double)resultedValue.Count / summ;
            }

            return(resultedValues);
        }
Example #8
0
 /// <summary>
 /// 沿着指定 <see cref="Type"/> 的继承链向上查找,直到找到当前泛型类型定义的封闭构造类型。
 /// </summary>
 /// <param name="definition">要获取封闭构造类型的泛型类型定义。</param>
 /// <param name="type">要查找继承链的类型。</param>
 /// <returns>如果当前的泛型类型定义是 <paramref name="type"/> 继承链中类型的泛型定义,
 /// 或者是 <paramref name="type"/> 实现的接口的泛型定义,
 /// 或者 <paramref name="type"/> 是泛型类型参数且当前泛型类型定义是 <paramref name="type"/> 的约束之一,
 /// 则为相应的封闭构造类型。否则为 <c>null</c>。</returns>
 /// <exception cref="ArgumentNullException"><paramref name="definition"/> 为 <c>null</c>。</exception>
 /// <exception cref="ArgumentNullException"><paramref name="type"/> 为 <c>null</c>。</exception>
 /// <remarks>如果一个类将同一个接口实现了多次,那么该接口对应的封闭构造类型就不是唯一的。</remarks>
 /// <example>
 /// 下面是 <see cref="UniqueCloseDefinitionFrom"/> 方法的简单示例:
 /// <code>
 /// Console.WriteLine(typeof(IEnumerable&lt;&gt;).UniqueCloseDefinitionFrom(typeof(List&lt;int&gt;)));
 /// // 输出:System.Collections.Generic.IEnumerable`1[System.Int32]
 /// </code>
 /// </example>
 public static Type UniqueCloseDefinitionFrom(this Type definition, Type type)
 {
     if (definition == null)
     {
         throw CommonExceptions.ArgumentNull("definition");
     }
     if (type == null)
     {
         throw CommonExceptions.ArgumentNull("type");
     }
     Contract.EndContractBlock();
     if (!definition.IsGenericTypeDefinition)
     {
         return(null);
     }
     if (definition.IsInterface == type.IsInterface)
     {
         // 沿继承链向上查找。
         while (type != null)
         {
             if (type.IsGenericType)
             {
                 if (definition == type.GetGenericTypeDefinition())
                 {
                     return(type);
                 }
             }
             type = type.BaseType;
         }
         return(null);
     }
     if (definition.IsInterface)
     {
         // 查找实现的接口。
         Type[]             interfaces = type.GetInterfaces();
         UniqueValue <Type> unique     = new UniqueValue <Type>();
         for (int i = 0; i < interfaces.Length && !unique.IsAmbig; i++)
         {
             if (interfaces[i].IsGenericType && definition == interfaces[i].GetGenericTypeDefinition())
             {
                 unique.Value = interfaces[i];
             }
         }
         if (unique.IsUnique)
         {
             return(unique.Value);
         }
     }
     return(null);
 }
Example #9
0
        /// <summary>
        /// 沿着指定 <see cref="Type"/> 的继承链向上查找,直到找到当前泛型类型定义的封闭构造类型。
        /// </summary>
        /// <param name="definition">要获取封闭构造类型的泛型类型定义。</param>
        /// <param name="type">要查找继承链的类型。</param>
        /// <returns>如果当前的泛型类型定义是 <paramref name="type"/> 继承链中类型的泛型定义,
        /// 或者是 <paramref name="type"/> 实现的接口的泛型定义,
        /// 或者 <paramref name="type"/> 是泛型类型参数且当前泛型类型定义是 <paramref name="type"/> 的约束之一,
        /// 则为相应的封闭构造类型。否则为 <c>null</c>。</returns>
        /// <exception cref="ArgumentNullException"><paramref name="definition"/> 为 <c>null</c>。</exception>
        /// <exception cref="ArgumentNullException"><paramref name="type"/> 为 <c>null</c>。</exception>
        /// <remarks>如果一个类将同一个接口实现了多次,那么该接口对应的封闭构造类型就不是唯一的。</remarks>
        /// <example>
        /// 下面是 <see cref="UniqueCloseDefinitionFrom"/> 方法的简单示例:
        /// <code>
        /// Console.WriteLine(typeof(IEnumerable&lt;&gt;).UniqueCloseDefinitionFrom(typeof(List&lt;int&gt;)));
        /// // 输出:System.Collections.Generic.IEnumerable`1[System.Int32]
        /// </code>
        /// </example>
        public static Type UniqueCloseDefinitionFrom(this Type definition, Type type)
        {
            CommonExceptions.CheckArgumentNull(definition, nameof(definition));
            CommonExceptions.CheckArgumentNull(type, nameof(type));
            Contract.EndContractBlock();
            if (!definition.IsGenericTypeDefinition)
            {
                return(null);
            }
            if (!definition.IsInterface && !type.IsInterface)
            {
                // 沿继承链向上查找。
                while (type != null)
                {
                    if (type.IsGenericType && definition == type.GetGenericTypeDefinition())
                    {
                        return(type);
                    }
                    type = type.BaseType;
                }
                return(null);
            }
            if (!definition.IsInterface)
            {
                return(null);
            }
            if (type.IsGenericType && definition == type.GetGenericTypeDefinition())
            {
                return(type);
            }
            // 查找实现的接口。
            var interfaces = type.GetInterfaces();
            var unique     = new UniqueValue <Type>();

            for (var i = 0; i < interfaces.Length && !unique.IsAmbig; i++)
            {
                if (interfaces[i].IsGenericType && definition == interfaces[i].GetGenericTypeDefinition())
                {
                    unique.Value = interfaces[i];
                }
            }
            return(unique.ValueOrDefault);
        }
        private async void Initialize()
        {
            try
            {
                // Create the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl));

                // Create the map.
                MyMapView.Map = new Map(Basemap.CreateTopographicVector());

                // Get all of the edges and junctions in the network.
                IEnumerable <UtilityNetworkSource> edges     = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge);
                IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction);

                // Add all edges that are not subnet lines to the map.
                foreach (UtilityNetworkSource source in edges)
                {
                    if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Add all junctions to the map.
                foreach (UtilityNetworkSource source in junctions)
                {
                    if (source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Create a graphics overlay for associations.
                _associationsOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(_associationsOverlay);

                // Symbols for the associations.
                Symbol attachmentSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d);
                Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d);

                // Create a renderer for the associations.
                var attachmentValue   = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString());
                var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString());
                _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> {
                    "AssociationType"
                }, new List <UniqueValue> {
                    attachmentValue, connectivityValue
                }, string.Empty, null);

                // Populate the legend in the UI.
                Dictionary <UtilityAssociationType, System.Windows.Media.ImageSource> legend;
                legend = new Dictionary <UtilityAssociationType, System.Windows.Media.ImageSource>();

                RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Attachment] = await attachmentSwatch?.ToImageSourceAsync();

                RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Connectivity] = await connectSwatch?.ToImageSourceAsync();

                AssociationLegend.ItemsSource = legend;

                // Set the starting viewpoint.
                await MyMapView.SetViewpointAsync(InitialViewpoint);

                // Add the associations in the starting viewpoint.
                AddAssociations();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private async void Initialize()
        {
            // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations.
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) =>
            {
                try
                {
                    // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample.
                    string sampleServer7User = "******";
                    string sampleServer7Pass = "******";

                    return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            });

            try
            {
                // Create the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl));

                // Create the map.
                MyMapView.Map = new Map(BasemapStyle.ArcGISTopographic);

                // Get all of the edges and junctions in the network.
                IEnumerable <UtilityNetworkSource> edges     = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge);
                IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction);

                // Add all edges that are not subnet lines to the map.
                foreach (UtilityNetworkSource source in edges)
                {
                    if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Add all junctions to the map.
                foreach (UtilityNetworkSource source in junctions)
                {
                    if (source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Create a graphics overlay for associations.
                _associationsOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(_associationsOverlay);

                // Symbols for the associations.
                Symbol attachmentSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d);
                Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d);

                // Create a renderer for the associations.
                var attachmentValue   = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString());
                var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString());
                _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> {
                    "AssociationType"
                }, new List <UniqueValue> {
                    attachmentValue, connectivityValue
                }, string.Empty, null);

                // Populate the legend in the UI.
                Dictionary <UtilityAssociationType, System.Windows.Media.ImageSource> legend;
                legend = new Dictionary <UtilityAssociationType, System.Windows.Media.ImageSource>();

                RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Attachment] = await attachmentSwatch?.ToImageSourceAsync();

                RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Connectivity] = await connectSwatch?.ToImageSourceAsync();

                AssociationLegend.ItemsSource = legend;

                // Set the starting viewpoint.
                await MyMapView.SetViewpointAsync(InitialViewpoint);

                // Add the associations in the starting viewpoint.
                AddAssociations();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #12
0
 /// <summary>
 /// 确定当前的开放泛型类型的实例是否可以从指定 <see cref="System.Type"/> 的实例唯一分配,
 /// 并返回唯一相应的封闭泛型类型。
 /// </summary>
 /// <param name="type">要判断的开放泛型类型。</param>
 /// <param name="fromType">要与当前类型进行比较的类型。</param>
 /// <param name="closedType">如果可以唯一分配到开放泛型类型,则返回相应的封闭泛型类型;
 /// 否则返回 <c>null</c>。</param>
 /// <returns>如果当前的开放泛型类型可以从 <paramref name="fromType"/> 的实例唯一分配,
 /// 则为 <c>true</c>;否则为 <c>false</c>。</returns>
 /// <example>
 /// 下面是 <see cref="UniqueOpenGenericIsAssignableFrom(Type,Type,out Type)"/> 方法的简单示例:
 /// <code>
 /// Type type;
 /// Console.WriteLine(typeof(IEnumerable&lt;&gt;).UniqueOpenGenericIsAssignableFrom(
 ///		typeof(List&gt;int&gt;), out type));
 /// Console.WriteLine(type);
 /// Console.WriteLine(typeof(IEnumerable&lt;&gt;).UniqueOpenGenericIsAssignableFrom(
 ///		typeof(TestClass)));
 /// class TestClass : IEnumerable&lt;int&gt;, IEnumerable&lt;long&gt; { }
 /// // 示例输出:
 /// // True
 /// // System.Collections.Generic.IEnumerable`1[System.Int32]
 /// // False
 /// </code>
 /// </example>
 /// <remarks>
 /// <para>如果一个类将一个泛型接口实现了多次,则不满足唯一实现,会返回 <c>false</c>。
 /// 仅当实现了一次时,才会返回 <c>true</c>,以及相应的封闭泛型类型。</para>
 /// <para>关于判断是否可以分配到开放泛型类型的算法可以参考我的博客文章 
 /// <see href="http://www.cnblogs.com/cyjb/archive/p/TypeAssignableFrom.html">
 /// 《C# 判断类型间能否隐式或强制类型转换,以及开放泛型类型转换》</see>。</para></remarks>
 /// <seealso href="http://www.cnblogs.com/cyjb/archive/p/TypeAssignableFrom.html">
 /// 《C# 判断类型间能否隐式或强制类型转换,以及开放泛型类型转换》</seealso>
 /// <overloads>
 /// <summary>
 /// 确定当前的开放泛型类型的实例是否可以从指定 <see cref="System.Type"/> 的实例唯一分配。
 /// </summary>
 /// </overloads>
 public static bool UniqueOpenGenericIsAssignableFrom(this Type type, Type fromType, out Type closedType)
 {
     if (type != null && fromType != null && type.IsGenericTypeDefinition)
     {
         if (type.IsInterface == fromType.IsInterface)
         {
             if (type.InInheritanceChain(fromType, out closedType))
             {
                 return true;
             }
         }
         if (type.IsInterface)
         {
             // 查找唯一实现的接口。
             Type[] interfaces = fromType.GetInterfaces();
             UniqueValue<Type> unique = new UniqueValue<Type>();
             for (int i = 0; i < interfaces.Length; i++)
             {
                 if (type.InInheritanceChain(interfaces[i], out closedType))
                 {
                     unique.Value = closedType;
                     if (unique.IsAmbig)
                     {
                         return false;
                     }
                 }
             }
             if (unique.IsUnique)
             {
                 closedType = unique.Value;
                 return true;
             }
         }
     }
     closedType = null;
     return false;
 }
Example #13
0
 /// <summary>
 /// 固定当前界限集所限定的类型参数。
 /// </summary>
 /// <returns>如果成功固定当前界限集的的类型参数,则为类型参数;
 /// 如果固定失败,则为 <c>null</c>。</returns>
 public Type FixTypeArg()
 {
     Type result = null;
     if (exactBound == null)
     {
         List<Type> list = new List<Type>(new HashSet<Type>(lowerBounds.Concat(upperBounds))
             .Where(type => this.CanFixed(type)));
         if (list.Count == 0)
         {
             // 没有找到合适的推断结果。
             return null;
         }
         else if (list.Count == 1)
         {
             // 找到唯一的推断结果。
             result = list[0];
         }
         else
         {
             // 进一步进行推断。
             UniqueValue<Type> uType = new UniqueValue<Type>();
             int cnt = list.Count;
             for (int j = 0; j < cnt; j++)
             {
                 int k = 0;
                 for (; k < cnt; k++)
                 {
                     if (k == j) { continue; }
                     if (!list[j].IsImplicitFrom(list[k]))
                     {
                         break;
                     }
                 }
                 if (k == cnt) { uType.Value = list[j]; }
             }
             if (uType.IsUnique)
             {
                 result = uType.Value;
             }
             else
             {
                 // 推断失败。
                 return null;
             }
         }
     }
     else
     {
         result = exactBound;
     }
     // 判断引用类型约束。
     if (ReferenceType && result.IsValueType)
     {
         return null;
     }
     return result;
 }
Example #14
0
        private async void Initialize()
        {
            try
            {
                _activityIndicator.StartAnimating();
                _statusLabel.Text = "Loading Utility Network...";

                // Create a map.
                _myMapView.Map = new Map(Basemap.CreateStreetsNightVector())
                {
                    InitialViewpoint = _startingViewpoint
                };

                // Add the layer with electric distribution lines.
                FeatureLayer lineLayer          = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115"));
                UniqueValue  mediumVoltageValue = new UniqueValue("N/A", "Medium Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3), 5);
                UniqueValue  lowVoltageValue    = new UniqueValue("N/A", "Low Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.DarkCyan, 3), 3);
                lineLayer.Renderer = new UniqueValueRenderer(new List <string>()
                {
                    "ASSETGROUP"
                }, new List <UniqueValue>()
                {
                    mediumVoltageValue, lowVoltageValue
                }, "", new SimpleLineSymbol());
                _myMapView.Map.OperationalLayers.Add(lineLayer);

                // Add the layer with electric devices.
                FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100"));
                _myMapView.Map.OperationalLayers.Add(electricDevicelayer);

                // Set the selection color for features in the map view.
                _myMapView.SelectionProperties = new SelectionProperties(System.Drawing.Color.Yellow);

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), _myMapView.Map);

                // Get the utility tier used for traces in this network. For this data set, the "Medium Voltage Radial" tier from the "ElectricDistribution" domain network is used.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork("ElectricDistribution");
                _mediumVoltageTier = domainNetwork.GetTier("Medium Voltage Radial");

                // More complex datasets may require using utility trace configurations from different tiers. The following LINQ expression gets all tiers present in the utility network.
                //IEnumerable<UtilityTier> tiers = _utilityNetwork.Definition.DomainNetworks.Select(domain => domain.Tiers).SelectMany(tier => tier);

                // Create symbols for starting locations and barriers.
                _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LightGreen, 25d);
                _barrierPointSymbol  = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.OrangeRed, 25d);

                // Create a graphics overlay.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                _myMapView.GraphicsOverlays.Add(graphicsOverlay);

                // Set the instruction text.
                _statusLabel.Text = "Click on the network lines or points to add a utility element.";
            }
            catch (Exception ex)
            {
                _statusLabel.Text = "Loading Utility Network failed...";
                new UIAlertView("Error", ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show();
            }
            finally
            {
                _activityIndicator.StopAnimating();
            }
        }
        private async void Initialize()
        {
            try
            {
                IsBusy.Visibility = Visibility.Visible;
                Status.Text       = "Loading Utility Network...";

                // Setup Map with Feature Layer(s) that contain Utility Network.
                MyMapView.Map = new Map(Basemap.CreateStreetsNightVector())
                {
                    InitialViewpoint = _startingViewpoint
                };

                // Add the layer with electric distribution lines.
                FeatureLayer lineLayer          = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115"));
                UniqueValue  mediumVoltageValue = new UniqueValue("N/A", "Medium Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3), 5);
                UniqueValue  lowVoltageValue    = new UniqueValue("N/A", "Low Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.DarkCyan, 3), 3);
                lineLayer.Renderer = new UniqueValueRenderer(new List <string>()
                {
                    "ASSETGROUP"
                }, new List <UniqueValue>()
                {
                    mediumVoltageValue, lowVoltageValue
                }, "", new SimpleLineSymbol());
                MyMapView.Map.OperationalLayers.Add(lineLayer);

                // Add the layer with electric devices.
                FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100"));
                MyMapView.Map.OperationalLayers.Add(electricDevicelayer);

                // Set the selection color for features in the map view.
                MyMapView.SelectionProperties = new SelectionProperties(System.Drawing.Color.Yellow);

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), MyMapView.Map);

                // Update the trace configuration UI.
                TraceTypes.ItemsSource   = Enum.GetValues(typeof(UtilityTraceType));
                TraceTypes.SelectedIndex = 0;

                // Get the utility tier used for traces in this network. For this data set, the "Medium Voltage Radial" tier from the "ElectricDistribution" domain network is used.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork("ElectricDistribution");
                _mediumVoltageTier = domainNetwork.GetTier("Medium Voltage Radial");

                // More complex datasets may require using utility trace configurations from different tiers. The following LINQ expression gets all tiers present in the utility network.
                //IEnumerable<UtilityTier> tiers = _utilityNetwork.Definition.DomainNetworks.Select(domain => domain.Tiers).SelectMany(tier => tier);

                // Create symbols for starting locations and barriers.
                _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LightGreen, 25d);
                _barrierPointSymbol  = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.OrangeRed, 25d);

                // Create a graphics overlay.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(graphicsOverlay);

                // Set the instruction text.
                Status.Text = "Click on the network lines or points to add a utility element.";
            }
            catch (Exception ex)
            {
                Status.Text = "Loading Utility Network failed...";
                MessageBox.Show(ex.Message, ex.Message.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                MainUI.IsEnabled  = true;
                IsBusy.Visibility = Visibility.Hidden;
            }
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Identifier" /> class.
 /// </summary>
 public Identifier()
 {
     this._id = new UniqueValue();
 }
Example #17
0
 /// <summary>
 /// 沿着指定 <see cref="Type"/> 的继承链向上查找,直到找到当前泛型类型定义的封闭构造类型。
 /// </summary>
 /// <param name="definition">要获取封闭构造类型的泛型类型定义。</param>
 /// <param name="type">要查找继承链的类型。</param>
 /// <returns>如果当前的泛型类型定义是 <paramref name="type"/> 继承链中类型的泛型定义,
 /// 或者是 <paramref name="type"/> 实现的接口的泛型定义,
 /// 或者 <paramref name="type"/> 是泛型类型参数且当前泛型类型定义是 <paramref name="type"/> 的约束之一,
 /// 则为相应的封闭构造类型。否则为 <c>null</c>。</returns>
 /// <exception cref="ArgumentNullException"><paramref name="definition"/> 为 <c>null</c>。</exception>
 /// <exception cref="ArgumentNullException"><paramref name="type"/> 为 <c>null</c>。</exception>
 /// <remarks>如果一个类将同一个接口实现了多次,那么该接口对应的封闭构造类型就不是唯一的。</remarks>
 /// <example>
 /// 下面是 <see cref="UniqueCloseDefinitionFrom"/> 方法的简单示例:
 /// <code>
 /// Console.WriteLine(typeof(IEnumerable&lt;&gt;).UniqueCloseDefinitionFrom(typeof(List&lt;int&gt;)));
 /// // 输出:System.Collections.Generic.IEnumerable`1[System.Int32]
 /// </code>
 /// </example>
 public static Type UniqueCloseDefinitionFrom(this Type definition, Type type)
 {
     CommonExceptions.CheckArgumentNull(definition, "definition");
     CommonExceptions.CheckArgumentNull(type, "type");
     Contract.EndContractBlock();
     if (!definition.IsGenericTypeDefinition)
     {
         return null;
     }
     if (!definition.IsInterface && !type.IsInterface)
     {
         // 沿继承链向上查找。
         while (type != null)
         {
             if (type.IsGenericType && definition == type.GetGenericTypeDefinition())
             {
                 return type;
             }
             type = type.BaseType;
         }
         return null;
     }
     if (!definition.IsInterface)
     {
         return null;
     }
     if (type.IsGenericType && definition == type.GetGenericTypeDefinition())
     {
         return type;
     }
     // 查找实现的接口。
     Type[] interfaces = type.GetInterfaces();
     UniqueValue<Type> unique = new UniqueValue<Type>();
     for (int i = 0; i < interfaces.Length && !unique.IsAmbig; i++)
     {
         if (interfaces[i].IsGenericType && definition == interfaces[i].GetGenericTypeDefinition())
         {
             unique.Value = interfaces[i];
         }
     }
     return unique.ValueOrDefault;
 }
Example #18
0
        private async void Initialize()
        {
            // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations.
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) =>
            {
                try
                {
                    // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample.
                    string sampleServer7User = "******";
                    string sampleServer7Pass = "******";

                    return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            });

            try
            {
                _activityIndicator.StartAnimating();
                _statusLabel.Text = "Loading Utility Network...";

                // Create a map.
                _myMapView.Map = new Map(BasemapStyle.ArcGISStreetsNight)
                {
                    InitialViewpoint = _startingViewpoint
                };

                // Add the layer with electric distribution lines.
                FeatureLayer lineLayer          = new FeatureLayer(new Uri($"{FeatureServiceUrl}/3"));
                UniqueValue  mediumVoltageValue = new UniqueValue("N/A", "Medium Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3), 5);
                UniqueValue  lowVoltageValue    = new UniqueValue("N/A", "Low Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.DarkCyan, 3), 3);
                lineLayer.Renderer = new UniqueValueRenderer(new List <string>()
                {
                    "ASSETGROUP"
                }, new List <UniqueValue>()
                {
                    mediumVoltageValue, lowVoltageValue
                }, "", new SimpleLineSymbol());
                _myMapView.Map.OperationalLayers.Add(lineLayer);

                // Add the layer with electric devices.
                FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/0"));
                _myMapView.Map.OperationalLayers.Add(electricDevicelayer);

                // Set the selection color for features in the map view.
                _myMapView.SelectionProperties = new SelectionProperties(System.Drawing.Color.Yellow);

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), _myMapView.Map);

                // Get the utility tier used for traces in this network. For this data set, the "Medium Voltage Radial" tier from the "ElectricDistribution" domain network is used.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork("ElectricDistribution");
                _mediumVoltageTier = domainNetwork.GetTier("Medium Voltage Radial");

                // More complex datasets may require using utility trace configurations from different tiers. The following LINQ expression gets all tiers present in the utility network.
                //IEnumerable<UtilityTier> tiers = _utilityNetwork.Definition.DomainNetworks.Select(domain => domain.Tiers).SelectMany(tier => tier);

                // Create symbols for starting locations and barriers.
                _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LightGreen, 25d);
                _barrierPointSymbol  = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.OrangeRed, 25d);

                // Create a graphics overlay.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                _myMapView.GraphicsOverlays.Add(graphicsOverlay);

                // Set the instruction text.
                _statusLabel.Text = "Click on the network lines or points to add a utility element.";
            }
            catch (Exception ex)
            {
                _statusLabel.Text = "Loading Utility Network failed...";
                new UIAlertView("Error", ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show();
            }
            finally
            {
                _activityIndicator.StopAnimating();
            }
        }
        private async void RenderSymbols(Dictionary <string, object> info, bool initialize = false)
        {
            FeatureCollectionTable dTable;
            FeatureCollectionTable uTable;

            DictionaryRenderer  dRend;
            UniqueValueRenderer uRend;

            string[] codes = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(info["codes"].ToString());
            int      page  = int.Parse(info["page"].ToString());

            if (initialize)
            {
                // Create the default symbol
                SimpleMarkerSymbol sms = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 12)
                {
                    Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Black, 1)
                };

                // Create the Dictionary and Unique Value renderers
                dRend = new DictionaryRenderer(DictionarySymbolStyle.OpenAsync("mil2525c_b2", StylePath).Result);
                uRend = new UniqueValueRenderer(new[] { FieldName }, null, "MilSymbol", sms);

                // Create the fields for the Feature Collection table
                Field[] fields = { new Field(FieldType.Text, FieldName, FieldName, 15) };

                // Create the Feature Collection Tables
                dTable = new FeatureCollectionTable(fields, GeometryType.Point, SpatialReferences.WebMercator)
                {
                    Renderer = dRend
                };
                uTable = new FeatureCollectionTable(fields, GeometryType.Point, SpatialReferences.WebMercator)
                {
                    Renderer = uRend
                };

                // Add the tables to the feature collection
                FeatureCollection collection = new FeatureCollection(new[] { dTable, uTable });

                // Add the collection to the map
                MyMapView.Map.OperationalLayers.Add(new FeatureCollectionLayer(collection));
            }
            else
            {
                // Get the feature collection from the map
                FeatureCollection collection = (MyMapView.Map.OperationalLayers.First() as FeatureCollectionLayer).FeatureCollection;

                // Get the tables from the collection
                dTable = collection.Tables.First();
                uTable = collection.Tables.Last();

                // Clear the records from the table and overlay
                QueryParameters query = new QueryParameters {
                    WhereClause = "1=1"
                };
                await dTable.DeleteFeaturesAsync(dTable.QueryFeaturesAsync(query).Result);

                await uTable.DeleteFeaturesAsync(uTable.QueryFeaturesAsync(query).Result);

                MyMapView.GraphicsOverlays.First().Graphics.Clear();

                // Clear the symbols from the unique value renderer
                (uTable.Renderer as UniqueValueRenderer)?.UniqueValues.Clear();
            }

            // Show the Page #
            MapPoint   titleLocation = new MapPoint(AOI.GetCenter().X, AOI.Extent.YMax + 25);
            TextSymbol titleBar      = new TextSymbol
            {
                Text                = string.Format("Page: {0}", page),
                Color               = Colors.Black,
                BackgroundColor     = Colors.DodgerBlue,
                FontWeight          = Esri.ArcGISRuntime.Symbology.FontWeight.Bold,
                Size                = 50,
                HorizontalAlignment = Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center,
                VerticalAlignment   = Esri.ArcGISRuntime.Symbology.VerticalAlignment.Bottom,
                OutlineColor        = Colors.Black,
                OutlineWidth        = 2
            };

            MyMapView.GraphicsOverlays.First().Graphics.Add(new Graphic(titleLocation, titleBar));

            int rows = codes.Length / Columns;

            double rowMargin = (AOI.XMax - AOI.XMin) / (Columns - 1);
            double colMargin = (AOI.YMax - AOI.YMin) / rows;

            int count = 0;

            for (double x = AOI.XMin; x < AOI.XMax; x += rowMargin)
            {
                if (count >= codes.Length)
                {
                    break;
                }

                for (double y = AOI.YMax; y > AOI.YMin; y -= colMargin)
                {
                    if (count >= codes.Length)
                    {
                        break;
                    }

                    string code = codes[count];

                    if (code.Length != 15)
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("Possible invalid code: {0}", code));
                    }
                    else
                    {
                        // Create features with the sidc code
                        Feature dFeature = dTable.CreateFeature(new Dictionary <string, object> {
                            { FieldName, code }
                        }, new MapPoint(x, y, SpatialReferences.WebMercator));
                        Feature uFeature = uTable.CreateFeature(new Dictionary <string, object> {
                            { FieldName, code }
                        }, new MapPoint(x + (rowMargin * 0.5), y, SpatialReferences.WebMercator));

                        // Create a label to display the code
                        TextSymbol label = new TextSymbol
                        {
                            Text            = code,
                            FontWeight      = Esri.ArcGISRuntime.Symbology.FontWeight.Bold,
                            Color           = Colors.DarkGoldenrod,
                            BackgroundColor = Colors.Black,
                            FontFamily      = "Consolas",
                            Size            = 16
                        };

                        MapPoint labelPoint = new MapPoint(x + (rowMargin * 0.25), y - (colMargin * 0.25), SpatialReferences.WebMercator);
                        MyMapView.GraphicsOverlays.First().Graphics.Add(new Graphic(labelPoint, label));

                        // Add the feature to the table
                        await dTable.AddFeatureAsync(dFeature);

                        await uTable.AddFeatureAsync(uFeature);

                        // Triple the size of the Unique Value symbol
                        MultilayerPointSymbol symbol = (MultilayerPointSymbol)(dTable.Renderer as DictionaryRenderer).GetSymbol(dFeature);
                        symbol.Size *= 3;

                        // Add the military symbol to the unique value renderer
                        UniqueValue uval = new UniqueValue(code, code, symbol, code);
                        (uTable.Renderer as UniqueValueRenderer).UniqueValues.Add(uval);
                    }

                    count++;

                    System.Diagnostics.Debug.WriteLine(string.Format(@"Processed feature {0} for {1}...", count, codes.Length));
                }
            }
        }
Example #20
0
            /// <summary>
            /// 固定当前界限集所限定的类型参数。
            /// </summary>
            /// <returns>如果成功固定当前界限集的的类型参数,则为类型参数;
            /// 如果固定失败,则为 <c>null</c>。</returns>
            public Type FixTypeArg()
            {
                Type result = null;

                if (exactBound == null)
                {
                    List <Type> list = new List <Type>(new HashSet <Type>(lowerBounds.Concat(upperBounds))
                                                       .Where(type => this.CanFixed(type)));
                    if (list.Count == 0)
                    {
                        // 没有找到合适的推断结果。
                        return(null);
                    }
                    else if (list.Count == 1)
                    {
                        // 找到唯一的推断结果。
                        result = list[0];
                    }
                    else
                    {
                        // 进一步进行推断。
                        UniqueValue <Type> uType = new UniqueValue <Type>();
                        int cnt = list.Count;
                        for (int j = 0; j < cnt; j++)
                        {
                            int k = 0;
                            for (; k < cnt; k++)
                            {
                                if (k == j)
                                {
                                    continue;
                                }
                                if (!list[j].IsImplicitFrom(list[k]))
                                {
                                    break;
                                }
                            }
                            if (k == cnt)
                            {
                                uType.Value = list[j];
                            }
                        }
                        if (uType.IsUnique)
                        {
                            result = uType.Value;
                        }
                        else
                        {
                            // 推断失败。
                            return(null);
                        }
                    }
                }
                else
                {
                    result = exactBound;
                }
                // 判断引用类型约束。
                if (ReferenceType && result.IsValueType)
                {
                    return(null);
                }
                return(result);
            }
Example #21
0
        // 레이어 심볼 Renderer 구성 초기화 - shape버전 레이어구성시에만 사용함
        public void InitUniqueValueRenderer()
        {
            uniqueValueRenderer = new UniqueValueRenderer();

            // 1.Point 마커 스타일링 - 속성값에따른 이미지 선별매핑
            //스탠드파이프
            SimpleLineSymbol SA003Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.SkyBlue, 1);
            UniqueValue      SA003Value  = new UniqueValue("SA003", "SA003", SA003Symbol, "SA003");
            //상수맨홀
            var SA100Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA100"), UriKind.Relative);
            PictureMarkerSymbol SA100Symbol = new PictureMarkerSymbol(SA100Uri);
            UniqueValue         SA100Value  = new UniqueValue("SA100", "SA100", SA100Symbol, "SA100"); //string description, string label, Symbol symbol, object value
            //취수장
            var SA112Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA112"), UriKind.Relative);
            PictureMarkerSymbol SA112Symbol = new PictureMarkerSymbol(SA112Uri);
            UniqueValue         SA112Value  = new UniqueValue("SA112", "SA112", SA112Symbol, "SA112"); //string description, string label, Symbol symbol, object value
            //배수지
            var SA114Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA114"), UriKind.Relative);
            PictureMarkerSymbol SA114Symbol = new PictureMarkerSymbol(SA114Uri);
            UniqueValue         SA114Value  = new UniqueValue("SA114", "SA114", SA114Symbol, "SA114"); //string description, string label, Symbol symbol, object value
            //수원지
            var SA110Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA110"), UriKind.Relative);
            PictureMarkerSymbol SA110Symbol = new PictureMarkerSymbol(SA110Uri);
            UniqueValue         SA110Value  = new UniqueValue("SA110", "SA110", SA110Symbol, "SA110"); //string description, string label, Symbol symbol, object value

            //유량계
            //BitmapImage bi = new BitmapImage();
            //bi.BeginInit();
            //bi.UriSource = new Uri(BizUtil.GetDataFolder("style_img", "SA117"), UriKind.Relative);
            //bi.EndInit();
            //byte[] data;
            //JpegBitmapEncoder encoder = new JpegBitmapEncoder();
            //encoder.Frames.Add(BitmapFrame.Create(bi));
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    encoder.Save(ms);
            //    data = ms.ToArray();
            //}
            //FileStream fs = new FileStream(BizUtil.GetDataFolder("style_img", "SA117"), FileMode.Open);
            //var SA117Uri = await RuntimeImage.FromStreamAsync(fs);


            //RuntimeImage SA117Uri;
            //using (FileStream fs = new FileStream(BizUtil.GetDataFolder("style_img", "SA117"), FileMode.Open, FileAccess.Read))
            //{
            //    SA117Uri = await RuntimeImage.FromStreamAsync(fs);
            //    //fs.Flush();
            //    //fs.Dispose();
            //    //fs.Close();
            //}
            var SA117Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA117"), UriKind.Relative);
            PictureMarkerSymbol SA117Symbol = new PictureMarkerSymbol(SA117Uri);;
            UniqueValue         SA117Value  = new UniqueValue("SA117", "SA117", SA117Symbol, "SA117"); //string description, string label, Symbol symbol, object value



            //급수탑
            var SA118Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA118"), UriKind.Relative);
            PictureMarkerSymbol SA118Symbol = new PictureMarkerSymbol(SA118Uri);
            UniqueValue         SA118Value  = new UniqueValue("SA118", "SA118", SA118Symbol, "SA118"); //string description, string label, Symbol symbol, object value
            //소화전
            var SA119Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA119"), UriKind.Relative);
            PictureMarkerSymbol SA119Symbol = new PictureMarkerSymbol(SA119Uri);
            UniqueValue         SA119Value  = new UniqueValue("SA119", "SA119", SA119Symbol, "SA119");
            //저수조
            var SA120Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA120"), UriKind.Relative);
            PictureMarkerSymbol SA120Symbol = new PictureMarkerSymbol(SA120Uri);
            UniqueValue         SA120Value  = new UniqueValue("SA120", "SA120", SA120Symbol, "SA120");
            //수압계
            var SA121Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA121"), UriKind.Relative);
            PictureMarkerSymbol SA121Symbol = new PictureMarkerSymbol(SA121Uri);
            UniqueValue         SA121Value  = new UniqueValue("SA121", "SA121", SA121Symbol, "SA121"); //string description, string label, Symbol symbol, object value
            //급수전계량기
            var SA122Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA122"), UriKind.Relative);
            PictureMarkerSymbol SA122Symbol = new PictureMarkerSymbol(SA122Uri);
            UniqueValue         SA122Value  = new UniqueValue("SA122", "SA122", SA122Symbol, "SA122"); //string description, string label, Symbol symbol, object value

            /* 변류시설 그룹 */
            //제수변
            var SA200Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA200"), UriKind.Relative);
            PictureMarkerSymbol SA200Symbol = new PictureMarkerSymbol(SA200Uri);
            UniqueValue         SA200Value  = new UniqueValue("SA200", "SA200", SA200Symbol, "SA200"); //string description, string label, Symbol symbol, object value
            //역지변
            var SA201Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA201"), UriKind.Relative);
            PictureMarkerSymbol SA201Symbol = new PictureMarkerSymbol(SA201Uri);
            UniqueValue         SA201Value  = new UniqueValue("SA201", "SA201", SA201Symbol, "SA201"); //string description, string label, Symbol symbol, object value
            //이토변
            var SA202Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA202"), UriKind.Relative);
            PictureMarkerSymbol SA202Symbol = new PictureMarkerSymbol(SA202Uri);
            UniqueValue         SA202Value  = new UniqueValue("SA202", "SA202", SA202Symbol, "SA202"); //string description, string label, Symbol symbol, object value
            //배기변
            var SA203Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA203"), UriKind.Relative);
            PictureMarkerSymbol SA203Symbol = new PictureMarkerSymbol(SA203Uri);
            UniqueValue         SA203Value  = new UniqueValue("SA203", "SA203", SA203Symbol, "SA203"); //string description, string label, Symbol symbol, object value
            //감압변
            var SA204Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA204"), UriKind.Relative);
            PictureMarkerSymbol SA204Symbol = new PictureMarkerSymbol(SA204Uri);
            UniqueValue         SA204Value  = new UniqueValue("SA204", "SA204", SA204Symbol, "SA204"); //string description, string label, Symbol symbol, object value
            //안전변
            var SA205Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA205"), UriKind.Relative);
            PictureMarkerSymbol SA205Symbol = new PictureMarkerSymbol(SA205Uri);
            UniqueValue         SA205Value  = new UniqueValue("SA205", "SA205", SA205Symbol, "SA205"); //string description, string label, Symbol symbol, object value
            //소화전제수변
            var SA206Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA206"), UriKind.Relative);
            PictureMarkerSymbol SA206Symbol = new PictureMarkerSymbol(SA206Uri);
            UniqueValue         SA206Value  = new UniqueValue("SA206", "SA206", SA206Symbol, "SA206"); //string description, string label, Symbol symbol, object value

            //누수지점
            var SA300Uri = new Uri(BizUtil.GetDataFolder("style_img", "SA300"), UriKind.Relative);
            PictureMarkerSymbol SA300Symbol = new PictureMarkerSymbol(SA300Uri);
            UniqueValue         SA300Value  = new UniqueValue("SA300", "SA300", SA300Symbol, "SA300"); //string description, string label, Symbol symbol, object value

            uniqueValueRenderer.FieldNames.Add("FTR_CDE");

            uniqueValueRenderer.UniqueValues.Add(SA003Value);
            uniqueValueRenderer.UniqueValues.Add(SA100Value);
            uniqueValueRenderer.UniqueValues.Add(SA110Value);
            uniqueValueRenderer.UniqueValues.Add(SA112Value);
            uniqueValueRenderer.UniqueValues.Add(SA114Value);
            uniqueValueRenderer.UniqueValues.Add(SA117Value);
            uniqueValueRenderer.UniqueValues.Add(SA118Value);
            uniqueValueRenderer.UniqueValues.Add(SA119Value);
            uniqueValueRenderer.UniqueValues.Add(SA120Value);
            uniqueValueRenderer.UniqueValues.Add(SA121Value);
            uniqueValueRenderer.UniqueValues.Add(SA122Value);

            uniqueValueRenderer.UniqueValues.Add(SA200Value);
            uniqueValueRenderer.UniqueValues.Add(SA201Value);
            uniqueValueRenderer.UniqueValues.Add(SA202Value);
            uniqueValueRenderer.UniqueValues.Add(SA203Value);
            uniqueValueRenderer.UniqueValues.Add(SA204Value);
            uniqueValueRenderer.UniqueValues.Add(SA205Value);
            uniqueValueRenderer.UniqueValues.Add(SA206Value);

            uniqueValueRenderer.UniqueValues.Add(SA300Value);


            /*
             */
            // 2.Line 스타일링 - 속성값에따른 라인컬러 선별매핑
            //상수관로
            SimpleLineSymbol SA001Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 2);
            UniqueValue      SA001Value  = new UniqueValue("SA001", "SA001", SA001Symbol, "SA001");
            //급수관로
            SimpleLineSymbol SA002Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.SkyBlue, 2);
            UniqueValue      SA002Value  = new UniqueValue("SA002", "SA002", SA002Symbol, "SA002");

            uniqueValueRenderer.UniqueValues.Add(SA001Value);
            uniqueValueRenderer.UniqueValues.Add(SA002Value);



            // 3.Polygon 스타일링 - 속성값에따른 라인&내부컬러 선별매핑
            //정수장
            SimpleFillSymbol SA113Symbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.Blue, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.SkyBlue, 1));
            UniqueValue      SA113Value  = new UniqueValue("SA113", "SA113", SA113Symbol, "SA113");


            //울산행정구역
            SimpleLineSymbol EA035Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.Red, 2);
            UniqueValue      EA035Value  = new UniqueValue("EA035", "EA035", EA035Symbol, "EA035");


            uniqueValueRenderer.UniqueValues.Add(SA113Value);
            uniqueValueRenderer.UniqueValues.Add(EA035Value);
        }
        private async void Initialize()
        {
            try
            {
                // Create the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl));

                // Create the map.
                _myMapView.Map = new Map(Basemap.CreateTopographicVector());

                // Get all of the edges and junctions in the network.
                IEnumerable <UtilityNetworkSource> edges     = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge);
                IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction);

                // Add all edges that are not subnet lines to the map.
                foreach (UtilityNetworkSource source in edges)
                {
                    if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null)
                    {
                        _myMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Add all junctions to the map.
                foreach (UtilityNetworkSource source in junctions)
                {
                    if (source.FeatureTable != null)
                    {
                        _myMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Create a graphics overlay for associations.
                _associationsOverlay = new GraphicsOverlay();
                _myMapView.GraphicsOverlays.Add(_associationsOverlay);

                // Symbols for the associations.
                Symbol attachmentSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d);
                Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d);

                // Create a renderer for the associations.
                var attachmentValue   = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString());
                var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString());
                _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> {
                    "AssociationType"
                }, new List <UniqueValue> {
                    attachmentValue, connectivityValue
                }, string.Empty, null);

                // Populate the legend in the UI.
                RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync();

                Android.Graphics.Bitmap attachmentBitmap = await attachmentSwatch?.ToImageSourceAsync();

                _attachmentImageView.SetImageBitmap(attachmentBitmap);

                RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync();

                Android.Graphics.Bitmap connectivityBitmap = await connectSwatch?.ToImageSourceAsync();

                _connectivityImageView.SetImageBitmap(connectivityBitmap);

                // Set the starting viewpoint.
                await _myMapView.SetViewpointAsync(InitialViewpoint);

                // Add the associations in the starting viewpoint.
                AddAssociations();
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.Message).SetTitle(ex.GetType().Name).Show();
            }
        }
Example #23
0
        /// <summary>
        /// 根据给定的用户定义转换获取最合适的转换。
        /// </summary>
        /// <param name="method">要测试的用户定义转换。</param>
        /// <param name="exactSource">当前最合适的源类型。</param>
        /// <param name="exactTarget">当前最合适的目标类型。</param>
        /// <param name="uniqueMethod">最合适的转换。</param>
        private static void GetBestConversion(ConversionMethod method, ref Type exactSource, ref Type exactTarget,
			UniqueValue<ConversionMethod> uniqueMethod)
        {
            if (exactSource != method.SourceType)
            {
                if (exactSource != null && method.SourceType.IsAssignableFrom(exactSource))
                {
                    return;
                }
                else
                {
                    exactSource = method.SourceType;
                    uniqueMethod.Reset();
                }
            }
            if (exactTarget != method.TargetType)
            {
                if (exactTarget != null && exactTarget.IsAssignableFrom(method.TargetType))
                {
                    return;
                }
                else
                {
                    exactTarget = method.TargetType;
                    uniqueMethod.Reset();
                }
            }
            uniqueMethod.Value = method;
        }