Ejemplo n.º 1
0
        private void CreateLabelModifierElement(XmlDocument _doc, LabelSource source, XmlElement lyrElement, string uniqueID)
        {
            LabelModifiers mods = source.Modifiers;

            foreach (LabelModifier lm in mods)
            {
                XmlElement element = _doc.CreateElement("branch");
                element.SetAttribute("branchtype", "", "leaf");
                element.SetAttribute("title", null, lm.Name);
                element.SetAttribute("alias", "", lm.Alias);
                element.SetAttribute("code", "", "nonselectable");
                element.SetAttribute("type", "", "LabelMod");
                element.SetAttribute("img", null, "lcmodifier.bmp");
                element.SetAttribute("uniqueid", "", uniqueID);
                if (lm.Enabled)
                {
                    element.SetAttribute("visible", "true");
                }
                else
                {
                    element.SetAttribute("visible", "false");
                }
                lyrElement.AppendChild(element);
            }
        }
Ejemplo n.º 2
0
 public PrinterOptions(LabelSource labelSource, string labelName, bool generateImageOnly, bool showDiagnostic)
 {
     LabelSource       = labelSource;
     LabelName         = labelName;
     GenerateImageOnly = generateImageOnly;
     ShowDiagnostic    = showDiagnostic;
 }
Ejemplo n.º 3
0
        // Create a LabelLayer and add it into the Group Layer collection with index 0.
        private LabelLayer CreateLabelLayer(Map myMap, MapInfo.Data.Table table, string caption)
        {
            LabelLayer ll = new LabelLayer("Label Layer for bound data", SampleConstants.NewLabelLayerAlias);
            // Insert this LabelLayer into the GroupLayer
            GroupLayer gLyr = GetTheGroupLayer();

            gLyr.Insert(0, ll);

            LabelSource ls = new LabelSource(table);

            ls.DefaultLabelProperties.Caption = caption;
            ll.Sources.Append(ls);
            return(ll);
        }
Ejemplo n.º 4
0
        private string GetSourceName(LabelSource labelSource)
        {
            switch (labelSource)
            {
            case LabelSource.Default:
                return("Automatically Select");

            case LabelSource.Left:
                return("Left Roll");

            case LabelSource.Right:
                return("Right Roll");
            }
            throw new InvalidOperationException($"Unknown label source: {labelSource.ToString()}");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加标注图层
        /// <param name="tableName">标注的表名</param>
        /// <param name="columnName">标注的列名</param>
        /// </summary>
        public static bool ShowLabelLayer(Map oMap, string tableName, string columnName)
        {
            if (oMap == null)
            {
                return(false);
            }

            //新建标注图层
            LabelLayer labellayer = new LabelLayer();

            oMap.Layers.Add(labellayer);

            //指定要标注的数据表
            LabelSource labelSource = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable(tableName));

            labellayer.Sources.Append(labelSource);

            //指定要标准字段所在的列
            labelSource.DefaultLabelProperties.Caption = columnName;
            //labelSource.DefaultLabelProperties.Visibility.Enabled = true;
            //labelSource.DefaultLabelProperties.Visibility.VisibleRangeEnabled = true;
            //labelSource.DefaultLabelProperties.Visibility.VisibleRange = new VisibleRange(0.01, 10, MapInfo.Geometry.DistanceUnit.Mile);
            //labelSource.DefaultLabelProperties.Visibility.AllowDuplicates = true;
            //labelSource.DefaultLabelProperties.Visibility.AllowOverlap = true;
            //labelSource.DefaultLabelProperties.Visibility.AllowOutOfView = true;
            //labelSource.Maximum = 50;
            //labelSource.DefaultLabelProperties.Layout.UseRelativeOrientation = true;
            //labelSource.DefaultLabelProperties.Layout.RelativeOrientation = MapInfo.Text.RelativeOrientation.FollowPath;
            //labelSource.DefaultLabelProperties.Layout.Angle = 33.0;
            //labelSource.DefaultLabelProperties.Priority.Major = "index";
            labelSource.DefaultLabelProperties.Layout.Offset    = 7;
            labelSource.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.BottomCenter;
            //Font font = new Font("黑体", 10);
            //font.ForeColor = System.Drawing.Color.DarkBlue;
            //labelSource.DefaultLabelProperties.Style.Font = font;
            return(true);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> LabelOrder(
            OrderViewModel viewModel,
            LabelSource labelSource,
            LabelObjectType labelObjectType,
            LabelState labelStatus,
            LabelReasonCodes labelReasonCode)
        {
            var order = await GetOrder(viewModel.OrderNumber);

            if (order == null)
            {
                return(BadRequest("No such order found for this user."));
            }

            #region Fraud Protection Service
            string labelObjectId;
            switch (labelObjectType)
            {
            case LabelObjectType.Purchase:
                labelObjectId = order.RiskPurchase.PurchaseId;
                break;

            case LabelObjectType.Account:
                labelObjectId = order.RiskPurchase.User.UserId;
                break;

            case LabelObjectType.Email:
                labelObjectId = order.RiskPurchase.User.Email;
                break;

            case LabelObjectType.PI:
                labelObjectId = order.RiskPurchase.PaymentInstrumentList[0].MerchantPaymentInstrumentId;
                break;

            default:
                throw new InvalidOperationException("Label object type not supported: " + labelObjectType);
            }

            var label = new Label
            {
                LabelObjectType  = labelObjectType.ToString(),
                LabelObjectId    = labelObjectId,
                LabelSource      = labelSource.ToString(),
                LabelReasonCodes = labelReasonCode.ToString(),
                LabelState       = labelStatus.ToString(),
                EventTimeStamp   = DateTimeOffset.Now,
                Processor        = "Fraud Protection sample site",
            };

            if (labelObjectType == LabelObjectType.Purchase)
            {
                label.Amount   = order.Total;
                label.Currency = order.RiskPurchase?.Currency;
            }

            var correlationId = _fraudProtectionService.NewCorrelationId;
            var response      = await _fraudProtectionService.PostLabel(label, correlationId);

            var fraudProtectionIO = new FraudProtectionIOModel(correlationId, label, response, "Label");
            TempData.Put(FraudProtectionIOModel.TempDataKey, fraudProtectionIO);
            #endregion

            return(View("LabelDone"));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// ���þݵ��ע�ļ�
 /// </summary>
 private void LabelLayer()
 {
     LabelLayer layer = new LabelLayer("LabelLayer" + strTempMapPointTable, "LabelLayer" + strTempMapPointTable);
     mapControl1.Map.Layers.Add(layer);
     LabelSource source = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable(strTempMapPointTable));
     source.DefaultLabelProperties.Caption = "Caption";        //��ע�õ����Ǹ��ֶ�����
     source.DefaultLabelProperties.Layout.Offset = 5;
     layer.Sources.Append(source);
 }
Ejemplo n.º 8
0
 public PrinterOptions(LabelSource labelSource, string labelName, bool generateImageOnly)
 {
     LabelSource       = labelSource;
     LabelName         = labelName;
     GenerateImageOnly = generateImageOnly;
 }
Ejemplo n.º 9
0
 public PrinterOptions(LabelSource labelSource)
 {
     LabelSource = labelSource;
 }
Ejemplo n.º 10
0
        //初始化地图,更换地图
        private void InitMap(MapFile mapFile)
        {
            currentMap = mapFile;
            if (preMap == mapFile.File)
            {
                return;
            }
            mapControl.Map.Clear();
            mapControl.Map.Load(MapInfo.Mapping.MapLoader.CreateFromFile(mapFile.File));
            mapControlOver.Map.Load(MapInfo.Mapping.MapLoader.CreateFromFile(mapFile.File));
            initZoom = mapControl.Map.Zoom;

            initCenter = mapControl.Map.Bounds.Center();
            ClearDistanceLayer();
            preMap = mapFile.File;

            comboBoxLayers.Items.Clear();
            listBoxLayerPlace.Items.Clear();
            for (int i = 1; i < mapControl.Map.Layers.Count; i++)
            {
                if (mapControl.Map.Layers[i].Name != "Watching" && mapControl.Map.Layers[i].Name != "Place" &&
                    mapControl.Map.Layers[i].Name != "HisPos" && mapControl.Map.Layers[i].Name != "HisLine" &&
                    mapControl.Map.Layers[i].Name != "HisAlarm" && mapControl.Map.Layers[i].Name != "Alarm" &&
                    mapControl.Map.Layers[i].Name != "DisLine" && mapControl.Map.Layers[i].Name != "Temp" &&
                    mapControl.Map.Layers[i].Name != "HisPlayPos" && mapControl.Map.Layers[i].Name != "HisPlayLine" &&
                    mapControl.Map.Layers[i].Name != "Watching_L" && mapControl.Map.Layers[i].Name != "Place_L" &&
                    mapControl.Map.Layers[i].Name != "HisPos_L" && mapControl.Map.Layers[i].Name != "HisAlarm_L" &&
                    mapControl.Map.Layers[i].Name != "Alarm_L" && mapControl.Map.Layers[i].Name != "HisPlayPos_L" &&
                    mapControl.Map.Layers[i].Name != "Administrative")
                {
                    comboBoxLayers.Items.Add(mapControl.Map.Layers[i].Name);
                }
            }
            if (comboBoxLayers.Items.Count > 0)
            {
                comboBoxLayers.SelectedIndex = 0;
            }

            if (tableWatching == null)
            {
                //监控点图层
                TableInfo ti = TableInfoFactory.CreateTemp("Watching");
                ti.Columns.Add(ColumnFactory.CreateStringColumn("ID", 10));
                ti.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableWatching = Session.Current.Catalog.CreateTable(ti);
                TextStyle ts = new TextStyle();
                ts.Font.Size       = 8;
                ts.Font.FontWeight = FontWeight.Bold;
                ts.Font.ForeColor  = Color.Green;
                labLayWatching     = new LabelLayer("Watching_L", "Watching_L");
                LabelSource source = new LabelSource(tableWatching);
                source.DefaultLabelProperties.Caption                 = "Label";
                source.DefaultLabelProperties.Style                   = ts;
                source.DefaultLabelProperties.CalloutLine.Use         = false;
                source.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source.DefaultLabelProperties.Layout.Offset           = 10;
                source.DefaultLabelProperties.Visibility.AllowOverlap = true;
                //labLayWatching = (LabelLayer)mapControl.Map.Layers["Watching_L"];
                labLayWatching.Sources.Append(source);
                //自定义标注点图层
                TableInfo ti2 = TableInfoFactory.CreateTemp("Place");
                ti2.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tablePlace = Session.Current.Catalog.CreateTable(ti2);
                TextStyle ts2 = new TextStyle();
                ts2.Font.Size       = 8;
                ts2.Font.FontWeight = FontWeight.Bold;
                ts2.Font.ForeColor  = Color.Blue;
                labLayPlace         = new LabelLayer("Place_L", "Place_L");
                LabelSource source2 = new LabelSource(tablePlace);
                source2.DefaultLabelProperties.Caption                 = "Label";
                source2.DefaultLabelProperties.Style                   = ts2;
                source2.DefaultLabelProperties.CalloutLine.Use         = false;
                source2.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source2.DefaultLabelProperties.Layout.Offset           = 10;
                source2.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayPlace = (LabelLayer)mapControl.Map.Layers["Place_L"];
                labLayPlace.Sources.Append(source2);
                //历史轨迹点图层
                TableInfo ti3 = TableInfoFactory.CreateTemp("HisPos");
                ti3.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableHisPos = Session.Current.Catalog.CreateTable(ti3);
                TextStyle ts3 = new TextStyle();
                ts3.Font.Size       = 8;
                ts3.Font.FontWeight = FontWeight.Bold;
                ts3.Font.ForeColor  = Color.Navy;
                labLayHisPos        = new LabelLayer("HisPos_L", "HisPos_L");
                LabelSource source3 = new LabelSource(tableHisPos);
                source3.DefaultLabelProperties.Caption                 = "Label";
                source3.DefaultLabelProperties.Style                   = ts3;
                source3.DefaultLabelProperties.CalloutLine.Use         = false;
                source3.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source3.DefaultLabelProperties.Layout.Offset           = 10;
                source3.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayHisPos = (LabelLayer)mapControl.Map.Layers["HisPos_L"];
                labLayHisPos.Sources.Append(source3);
                //历史轨迹线图层
                TableInfo ti4 = TableInfoFactory.CreateTemp("HisLine");
                tableHisLine = Session.Current.Catalog.CreateTable(ti4);
                //历史报警点图层
                TableInfo ti5 = TableInfoFactory.CreateTemp("HisAlarm");
                ti5.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableHisAlarm = Session.Current.Catalog.CreateTable(ti5);
                TextStyle ts5 = new TextStyle();
                ts5.Font.Size       = 8;
                ts5.Font.FontWeight = FontWeight.Bold;
                ts5.Font.ForeColor  = Color.Red;
                labLayHisAlarm      = new LabelLayer("HisAlarm_L", "HisAlarm_L");
                LabelSource source5 = new LabelSource(tableHisAlarm);
                source5.DefaultLabelProperties.Caption                 = "Label";
                source5.DefaultLabelProperties.Style                   = ts5;
                source5.DefaultLabelProperties.CalloutLine.Use         = false;
                source5.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source5.DefaultLabelProperties.Layout.Offset           = 10;
                source5.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayHisAlarm = (LabelLayer)mapControl.Map.Layers["HisAlarm_L"];
                labLayHisAlarm.Sources.Append(source5);
                //报警点图层
                TableInfo ti6 = TableInfoFactory.CreateTemp("Alarm");
                ti6.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableAlarm = Session.Current.Catalog.CreateTable(ti6);
                TextStyle ts6 = new TextStyle();
                ts6.Font.Size       = 8;
                ts6.Font.FontWeight = FontWeight.Bold;
                ts6.Font.ForeColor  = Color.Red;
                labLayAlarm         = new LabelLayer("Alarm_L", "Alarm_L");
                LabelSource source6 = new LabelSource(tableAlarm);
                source6.DefaultLabelProperties.Caption                 = "Label";
                source6.DefaultLabelProperties.Style                   = ts6;
                source6.DefaultLabelProperties.CalloutLine.Use         = false;
                source6.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source6.DefaultLabelProperties.Layout.Offset           = 10;
                source6.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayAlarm = (LabelLayer)mapControl.Map.Layers["Alarm_L"];
                labLayAlarm.Sources.Append(source6);
                //测距线图层
                TableInfo ti7 = TableInfoFactory.CreateTemp("DisLine");
                tableDisLine = Session.Current.Catalog.CreateTable(ti7);
                //临时图层
                TableInfo ti8 = TableInfoFactory.CreateTemp("Temp");
                tableTemp = Session.Current.Catalog.CreateTable(ti8);
                //轨迹回放点图层
                TableInfo ti9 = TableInfoFactory.CreateTemp("HisPlayPos");
                ti9.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableHisPlay = Session.Current.Catalog.CreateTable(ti9);
                TextStyle ts9 = new TextStyle();
                ts9.Font.Size       = 8;
                ts9.Font.FontWeight = FontWeight.Bold;
                ts9.Font.ForeColor  = Color.Black;
                labLayHisPlayPos    = new LabelLayer("HisPlayPos_L", "HisPlayPos_L");
                LabelSource source9 = new LabelSource(tableHisPlay);
                source9.DefaultLabelProperties.Caption                 = "Label";
                source9.DefaultLabelProperties.Style                   = ts9;
                source9.DefaultLabelProperties.CalloutLine.Use         = false;
                source9.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source9.DefaultLabelProperties.Layout.Offset           = 10;
                source9.DefaultLabelProperties.Visibility.AllowOverlap = false;
                labLayHisPlayPos.Sources.Append(source9);
                //轨迹回放线图层
                TableInfo ti10 = TableInfoFactory.CreateTemp("HisPlayLine");
                tableHisPlayLine = Session.Current.Catalog.CreateTable(ti10);
            }

            FeatureLayer lyr = new FeatureLayer(tableWatching);

            mapControl.Map.Layers.Insert(0, lyr);
            FeatureLayer lyr2 = new FeatureLayer(tablePlace);

            mapControl.Map.Layers.Insert(0, lyr2);

            FeatureLayer lyr3 = new FeatureLayer(tableHisPos);

            mapControl.Map.Layers.Insert(0, lyr3);
            FeatureLayer lyr4 = new FeatureLayer(tableHisLine);

            mapControl.Map.Layers.Insert(0, lyr4);

            FeatureLayer lyr5 = new FeatureLayer(tableHisAlarm);

            mapControl.Map.Layers.Insert(0, lyr5);

            FeatureLayer lyr6 = new FeatureLayer(tableAlarm);

            mapControl.Map.Layers.Insert(0, lyr6);
            FeatureLayer lyr7 = new FeatureLayer(tableDisLine);

            mapControl.Map.Layers.Insert(0, lyr7);

            FeatureLayer lyr8 = new FeatureLayer(tableTemp);

            mapControl.Map.Layers.Insert(0, lyr8);

            FeatureLayer lyr9 = new FeatureLayer(tableHisPlay);

            mapControl.Map.Layers.Insert(0, lyr9);
            FeatureLayer lyr10 = new FeatureLayer(tableHisPlayLine);

            mapControl.Map.Layers.Insert(0, lyr10);

            //标注图层
            mapControl.Map.Layers.Add(labLayWatching);
            mapControl.Map.Layers.Add(labLayPlace);
            mapControl.Map.Layers.Add(labLayHisPos);
            mapControl.Map.Layers.Add(labLayHisAlarm);
            mapControl.Map.Layers.Add(labLayAlarm);
            mapControl.Map.Layers.Add(labLayHisPlayPos);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Find a LabelSource in the map which uses the
        /// specified table, and return it, or return null
        /// if no suitable LabelSource exists.
        /// </summary>
        /// <param name="map">The Map object to search</param>
        /// <param name="sourceTable">
        /// A table which may or may not be labeled currently</param>
        /// <param name="currentLabelSource">
        /// If null is passed, we will return the first LabelSource we find
        /// that uses the specified table; if currentLabelSource is not
        /// null, we will search for the next LabelSource that uses
        /// the same table.
        /// </param>
        /// <param name="wrapAround">true if you want a "find next" search
        /// to wrap around to the beginning of the layer tree, if necessary,
        /// to find the next LabelSource; false if you do not the search to wrap.
        /// </param>
        /// <returns>A LabelSource object (which may be identical to
        /// the currentLabelSource param, e.g. if the currentLabelSource
        /// param represents the only LabelSource in the map); or null if
        /// the map does not contain any LabelSource based on the specified table.
        /// </returns>
        private LabelSource LocateNextLabelSource(
            Map map, Table sourceTable, LabelSource currentLabelSource, bool wrapAround)
        {
            // Get a collection of all LabelLayers in the map
            FilterByLayerType labelLayerFilter =
                new FilterByLayerType(LayerType.Label);

            MapLayerEnumerator mapLayerEnum =
                map.Layers.GetMapLayerEnumerator(
                    labelLayerFilter, MapLayerEnumeratorOptions.Recurse);

            _firstLabelLayer = null;
            LabelSource matchingLabelSource       = null;
            LabelSource firstMatchingLabelSource  = null;
            bool        bPassedCurrentLabelSource = false;

            // Given the set of all LabelLayers in the layer tree,
            // search each LabelLayer to try to find a LabelSource
            // child node that is based on the specified table
            // (the sourceTable param).
            // OR: If a non-null currentLabelSource param
            // was passed in, then it represents an existing
            // LabelSource, and our job is to find the NEXT
            // LabelSource that uses the same table.
            foreach (LabelLayer ll in mapLayerEnum)
            {
                if (_firstLabelLayer == null)
                {
                    // Make a note of the first LabelLayer we find;
                    // later, if we decide to create a new LabelSource,
                    // it will go into this first LabelLayer.
                    _firstLabelLayer = ll;
                }

                // Look through this LabelLayer's collection of LabelSources
                foreach (LabelSource lblSource in ll.Sources)
                {
                    if (lblSource.Table == sourceTable)
                    {
                        // This LabelSource uses the correct table
                        if (firstMatchingLabelSource == null)
                        {
                            // We found our first match, so make a note of it,
                            // even though it may not be ideal (i.e. it may not
                            // be the "next" LabelSource that was requested).
                            firstMatchingLabelSource = lblSource;
                        }

                        // Now determine whether this match is an ideal match.
                        // We may have been passed a LabelSource, and asked
                        // to find the "next" LabelSource.  So we may need
                        // to skip over the current LabelSource if it's
                        // the same as the LabelSource that was passed in.
                        if (currentLabelSource != null &&
                            !bPassedCurrentLabelSource)
                        {
                            // We WERE asked to find the "next" LabelSource,
                            // which means that our first task is to find
                            // the LabelSource that the user right-clicked.
                            // But according to the flag, we have not yet
                            // looped past the currently-selected LabelSource.
                            // So we will continue the loop instead of
                            // assigning  matchingLabelSource.
                            if (lblSource == currentLabelSource)
                            {
                                // We were asked to find the next LabelSource,
                                // and this LabelSource is the same one that
                                // was passed in.  In this case, just set the
                                // flag, so that the next match will be used.
                                bPassedCurrentLabelSource = true;
                            }
                            continue;
                        }

                        // We found a LabelSource that is a perfect match.
                        matchingLabelSource = lblSource;
                        break;
                    }
                }                 // This ends the "for each LabelSource in this LabelLayer" loop

                if (matchingLabelSource != null)
                {
                    // We found an ideal match, so we can skip searching
                    // the other LabelLayers.  Break the outer foreach loop:
                    break;
                }
            }             // This ends the "for each LabelLayer" loop

            if (matchingLabelSource == null)
            {
                // We end up here if we did not find an ideal match; for
                // example, if we were asked to find the "next" node, and
                // we did not find a next matching node, but we did find a
                // previous matching node, we end up here.
                // At this point, since we did not find a perfect match,
                // we will consider a less-than-perfect match.
                if (wrapAround)
                {
                    // Wrapping is On, meaning that when we search for
                    // the next LabelSource, we should wrap around to the top of
                    // the layer list, if necessary
                    matchingLabelSource = firstMatchingLabelSource;
                }
                else
                {
                    // Wrap is Off, meaning: if we did not find a Next LabelSource,
                    // return the LabelSource that was originally specified,
                    // which will tell the caller, "there IS no Next LabelSource."
                    matchingLabelSource = currentLabelSource;
                }
            }
            return(matchingLabelSource);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Find a LabelSource node in the layer tree which uses the
        /// specified table, and select that node.  If there are no
        /// LabelSources that use the specified table, ask the user
        /// whether a LabelSource should be added to the map.
        /// </summary>
        /// <param name="sourceTable">
        /// A table which may or may not be labeled currently</param>
        /// <param name="currentLabelSource">
        /// If null is passed, we will select the first LabelSource we find
        /// that uses the specified table; if currentLabelSource is not
        /// null, we will search for the next LabelSource that uses
        /// the same table.
        /// </param>
        private void SelectNextLabelSource(
            Table sourceTable, LabelSource currentLabelSource)
        {
            LabelSource matchingLabelSource =
                LocateNextLabelSource(_lc.Map, sourceTable, currentLabelSource, true);

            if (matchingLabelSource != null)
            {
                // There is at least one LabelSource found that uses
                // the specified table.
                if (_lc.ContextMenuTargetObject == matchingLabelSource)
                {
                    // The user right-clicked on a LabelSource in the tree,
                    // and the only LabelSource that we found is the
                    // same one the user right-clicked.  So we failed
                    // to find a Next LabelSource.
                    MapInfo.Windows.MessageBox.Show(
                        "There are no more label sources based on the table:\n\n"
                        + sourceTable.TableInfo.Description);
                }
                else
                {
                    // We found an appropriate match; select its tree node.
                    _lc.SelectedObject = matchingLabelSource;
                }
            }
            else
            {
                // There are NO LabelSource nodes that use the specified table.
                // The user must have right-clicked a FeatureLayer node
                // and then clicked Find Labels, but we could not find any.
                // Ask the user if we should create a new LabelSource.
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      dr      = MessageBox.Show(
                    null,
                    "There are no labels for the selected layer: \n\n"
                    + sourceTable.TableInfo.Description + "\n\n"
                    + "Do you want to create a new label source?",
                    "No Labels Found", buttons);

                if (dr == DialogResult.Yes)
                {
                    if (_firstLabelLayer == null)
                    {
                        // There are NO LabelLayers in the map; build one.
                        _firstLabelLayer = new LabelLayer("Label Layer");
                        _lc.Map.Layers.Insert(0, _firstLabelLayer);
                    }
                    LabelSource newSource = new LabelSource(sourceTable);
                    if (sourceTable.TableInfo.TableType == TableType.Wms ||
                        sourceTable.TableInfo.TableType == TableType.Grid ||
                        sourceTable.TableInfo.TableType == TableType.Raster)
                    {
                        // For a Raster Image layer, just label with the layer name.
                        newSource.DefaultLabelProperties.Caption =
                            "'" + sourceTable.TableInfo.Description + "'";
                    }

                    _firstLabelLayer.Sources.Append(newSource);

                    if (!_lc.UpdateWhenCollectionChanges)
                    {
                        // The LayerControl is currently configured to NOT update
                        // automatically when a new node is added to the tree;
                        // so we will force the LayerTree to regenerate, so that
                        // the new LabelSource node appears.
                        Map map = _lc.Map;
                        _lc.Map = null;
                        _lc.Map = map;
                    }

                    _lc.SelectedObject = newSource;
                }
            }
        }
Ejemplo n.º 13
0
        // Create a LabelLayer and add it into the Group Layer collection with index 0.
        private LabelLayer CreateLabelLayer(Map myMap, MapInfo.Data.Table table, string caption)
        {
            LabelLayer ll = new LabelLayer("Label Layer for bound data", SampleConstants.NewLabelLayerAlias);
            // Insert this LabelLayer into the GroupLayer
            GroupLayer gLyr = GetTheGroupLayer();
            gLyr.Insert(0, ll);

            LabelSource ls = new LabelSource(table);
            ls.DefaultLabelProperties.Caption = caption;
            ll.Sources.Append(ls);
            return ll;
        }
Ejemplo n.º 14
0
 private void CreateLabelModifierElement(XmlDocument _doc, LabelSource source, XmlElement lyrElement, string uniqueID)
 {
     LabelModifiers mods = source.Modifiers;
     foreach (LabelModifier lm in mods) {
         XmlElement element = _doc.CreateElement("branch");
         element.SetAttribute("branchtype", "", "leaf");
         element.SetAttribute("title", null, lm.Name);
         element.SetAttribute("alias", "", lm.Alias);
         element.SetAttribute("code", "", "nonselectable");
         element.SetAttribute("type", "", "LabelMod");
         element.SetAttribute("img", null,  "lcmodifier.bmp");
         element.SetAttribute("uniqueid", "", uniqueID);
         if (lm.Enabled) {
             element.SetAttribute("visible", "true");
         } else {
             element.SetAttribute("visible", "false");
         }
         lyrElement.AppendChild(element);
     }
 }