Ejemplo n.º 1
0
        private Pen GetBorderPen(ServiceInfoGroup servInfo)
        {
            if (servInfo != null)
            {
                var isDowloaded = !servInfo.IsEmpty && servInfo.GetItems().Any(item => item.IsDownloaded);
                return(isDowloaded
                           ? new Pen(Color.Green, 5)
                           : new Pen(SystemColors.WindowFrame, 2));
            }

            return(new Pen(SystemColors.WindowFrame, 2));
        }
Ejemplo n.º 2
0
        public static ServiceInfoGroup Create(IEnumerable <ServiceInfo> potentialOverlappedPoints)
        {
            if (potentialOverlappedPoints == null)
            {
                throw new ArgumentNullException("potentialOverlappedPoints");
            }

            var result = new ServiceInfoGroup();

            foreach (var point in potentialOverlappedPoints)
            {
                result.AddOverlappedServiceInfo(point);
            }

            return(result);
        }
Ejemplo n.º 3
0
        private ServiceInfoGroup Identify(IFeatureLayer layer, Extent tolerant)
        {
            Debug.Assert(layer != null);

            var group = new ServiceInfoGroup();

            foreach (var feature in layer.DataSet.Select(tolerant))
            {
                if (feature.DataRow == null)
                {
                    feature.ParentFeatureSet.FillAttributes();
                }
                var pInfo = ClassConvertor.IFeatureToServiceInfo(feature, layer);
                var serviceDescription = _serviceInfoExtractor.GetServiceDesciptionUrl(pInfo.ServiceUrl);
                if (serviceDescription != null)
                {
                    pInfo.ServiceDesciptionUrl = serviceDescription;
                }
                group.AddOverlappedServiceInfo(pInfo);
            }

            return(group);
        }
Ejemplo n.º 4
0
        private void AddInfoIntoContainer(ServiceInfoGroup info, Control container)
        {
            var thisWidth = 0;
            var startX    = CONTROLS_START_X;
            var startY    = CONSTROLS_START_Y;

            var itemForCommonParts = info.GetItems().First();

            // Data Source label
            var lbDataSource = new LinkLabel {
                AutoSize = true, Location = new Point(startX, startY)
            };

            lbDataSource.LinkClicked += lblServiceDesciptionUrl_LinkClicked;
            AddControl(container, lbDataSource);
            lbDataSource.Text = itemForCommonParts.DataSource;
            lbDataSource.Links[0].LinkData = itemForCommonParts.ServiceDesciptionUrl;
            lbDataSource.Links[0].Enabled  = IsValidServiceDesciptionUrl(itemForCommonParts.ServiceDesciptionUrl);
            CalculateContainerSize(lbDataSource, ref thisWidth, ref startY);

            // Site Name label
            startY += 2;
            var lbSiteName = new Label {
                AutoSize = true, Location = new Point(startX, startY)
            };

            AddControl(container, lbSiteName);
            lbSiteName.Text = itemForCommonParts.SiteName;
            CalculateContainerSize(lbSiteName, ref thisWidth, ref startY);

            // Variable labels...
            var sameVarName  = info.GetItems().All(item => itemForCommonParts.VarName == item.VarName);
            var sameType     = info.GetItems().All(item => itemForCommonParts.DataType == item.DataType);
            var showDataType = info.ItemsCount > 1 &&
                               (!sameType || sameVarName);
            const int max_variables_count = 10; // If variables list is too long, limit display to max_variables_count
            var       variablesList       = info.GetItems().ToList();

            for (int i = 0; i < variablesList.Count && i < max_variables_count; i++)
            {
                var item       = variablesList[i];
                var lbVariable = new Label {
                    AutoSize = true, Location = new Point(startX, startY)
                };
                AddControl(container, lbVariable);
                lbVariable.Text = string.Format("{0}{1} - {2}{3}",
                                                item.VarName,
                                                !showDataType ? string.Empty : ", " + item.DataType,
                                                item.ValueCountAsString,
                                                item.IsDownloaded ? string.Empty : " (estimated)");
                CalculateContainerSize(lbVariable, ref thisWidth, ref startY);
            }
            if (variablesList.Count > max_variables_count)
            {
                var lbVariable = new Label {
                    AutoSize = true, Location = new Point(startX, startY)
                };
                AddControl(container, lbVariable);
                lbVariable.Text = string.Format("{0} more available but not shown", variablesList.Count - max_variables_count);
                CalculateContainerSize(lbVariable, ref thisWidth, ref startY);
            }

            // Download data label
            startY += 2;
            var lbDowloadData = new LinkLabel
            {
                AutoSize = true,
                Location = new Point(startX, startY),
                Tag      = info,
            };

            lbDowloadData.LinkClicked += lblDownloadData_LinkClicked;
            AddControl(container, lbDowloadData);
            lbDowloadData.Text = info.GetItems().Any(item => item.IsDownloaded) ? "Download updated data" : "Download data";
            CalculateContainerSize(lbDowloadData, ref thisWidth, ref startY);
            lbDowloadData.Location = new Point(thisWidth - lbDowloadData.Width, lbDowloadData.Location.Y);

            container.Width  = thisWidth + CONTROLS_START_X;
            container.Height = startY + CONSTROLS_START_Y;
        }