Пример #1
0
    public void testGetLayerObjByNameDestroy()
    {
        mapObj   map       = new mapObj(mapfile);
        layerObj newLayer  = map.getLayerByName("POLYGON");
        layerObj reference = map.getLayerByName("POLYGON");

        assert(newLayer.refcount == 3, "testGetLayerObjByNameDestroy precondition");
        //newLayer.Dispose(); // force the destruction needed for Mono on Windows
        newLayer = null;
        gc();
        assert(reference.refcount == 2, "testGetLayerObjByNameDestroy");
    }
Пример #2
0
    public void testGetLayerObjByName()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj newLayer = map.getLayerByName("POLYGON");

        map = null;
        gc();
        assertNotNull(newLayer.map, "testGetLayerObjByName");
        assert(newLayer.refcount == 2, "testGetLayerObjByName refcount");
    }
Пример #3
0
	public void testGetLayerObjByNameDestroy() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayerByName("POLYGON");
		layerObj reference=map.getLayerByName("POLYGON");
		
		assert(newLayer.refcount == 3, "testGetLayerObjByNameDestroy precondition");
		//newLayer.Dispose(); // force the destruction needed for Mono on Windows
		newLayer=null;
		gc();
		assert(reference.refcount == 2, "testGetLayerObjByNameDestroy");
	}
Пример #4
0
	public void testGetLayerObjByName() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayerByName("POLYGON");
		
		map=null;
		gc();
		assertNotNull(newLayer.map, "testGetLayerObjByName");
		assert(newLayer.refcount == 2, "testGetLayerObjByName refcount");
	}
Пример #5
0
        private void UpdateStyleList()
        {
            string selectedName = style.symbolname;

            if (listView.SelectedItems.Count > 0)
            {
                selectedName = listView.SelectedItems[0].Text;
            }

            // populate the style listview
            listView.Items.Clear();
            imageList.Images.Clear();

            ListViewItem selected = null;

            if (comboBoxCategory.Text != "")
            {
                // Create "no symbol" entry
                styleObj nosymbolstyle = new styleObj(null);
                MapUtils.SetDefaultColor(layer.type, nosymbolstyle);
                ListViewItem nosymbolitem = AddListItem(nosymbolstyle, layer, "Default");
                if (selectedName == null)
                {
                    selected = nosymbolitem;
                }

                if (comboBoxCategory.Text == "Inline Symbols")
                {
                    for (int i = 0; i < map.symbolset.numsymbols; i++)
                    {
                        symbolObj symbol = map.symbolset.getSymbol(i);
                        if (symbol.inmapfile == mapscript.MS_TRUE &&
                            !StyleLibrary.HasSymbol(symbol.name))
                        {
                            styleObj libstyle = new styleObj(null);
                            //if (symbol.type == (int)MS_SYMBOL_TYPE.MS_SYMBOL_PATTERNMAP)
                            //    MapUtils.SetDefaultColor(MS_LAYER_TYPE.MS_LAYER_LINE, libstyle);
                            //else
                            MapUtils.SetDefaultColor(layer.type, libstyle);
                            libstyle.setSymbolByName(map, symbol.name);
                            libstyle.size = 8;
                            MS_LAYER_TYPE type = layer.type;
                            try
                            {
                                //STEPH: change layer passed to the list view to be consistent with the other symbol categories
                                //so that it uses a point layer to display the style in the list
                                layer.type = MS_LAYER_TYPE.MS_LAYER_POINT;
                                ListViewItem item = AddListItem(libstyle, layer, symbol.name);
                                if (selectedName == item.Text)
                                {
                                    selected = item;
                                }
                            }
                            finally
                            {
                                layer.type = type;
                            }
                        }
                    }
                }
                else
                {
                    // collect all fonts specified in the fontset file
                    Hashtable fonts = new Hashtable();
                    string    key   = null;
                    while ((key = map.fontset.fonts.nextKey(key)) != null)
                    {
                        fonts.Add(key, key);
                    }

                    mapObj   styles     = StyleLibrary.Styles;
                    layerObj stylelayer = styles.getLayerByName(comboBoxCategory.Text);
                    for (int i = 0; i < stylelayer.numclasses; i++)
                    {
                        classObj classobj    = stylelayer.getClass(i);
                        int      symbolIndex = classobj.getStyle(0).symbol;
                        if (symbolIndex >= 0)
                        {
                            string font = styles.symbolset.getSymbol(symbolIndex).font;
                            if (font != null && !fonts.ContainsKey(font))
                            {
                                continue; // this font cannot be found in fontset
                            }
                        }

                        ListViewItem item = AddListItem(classobj.getStyle(0), stylelayer, classobj.name);
                        if (selectedName == item.Text)
                        {
                            selected = item;
                        }
                    }
                }
            }

            if (selected != null)
            {
                selected.Selected = true;
                selected.EnsureVisible();
            }
        }
Пример #6
0
        /// <summary>
        /// Update the enabled state of the controls according to the layer type
        /// </summary>
        private void UpdateEnabledState()
        {
            textBoxAngle.Enabled   = true;
            textBoxWidth.Enabled   = true;
            textBoxGap.Enabled     = true;
            textBoxPattern.Enabled = true;
            textBoxSize.Enabled    = true;

            if (layer != null && layer.symbolscaledenom >= 0)
            {
                textBoxMinSize.Enabled  = true;
                textBoxMaxSize.Enabled  = true;
                textBoxMinWidth.Enabled = true;
                textBoxMaxWidth.Enabled = true;
            }
            else
            {
                textBoxMinSize.Enabled  = false;
                textBoxMaxSize.Enabled  = false;
                textBoxMinWidth.Enabled = false;
                textBoxMaxWidth.Enabled = false;
            }

            MS_LAYER_TYPE categoryType;

            //check the style category selected
            if (comboBoxCategory.Text != "")
            {
                if (comboBoxCategory.Text == "Inline Symbols")
                {
                    categoryType = MS_LAYER_TYPE.MS_LAYER_POINT;
                }
                else
                {
                    mapObj styles = StyleLibrary.Styles;
                    categoryType = styles.getLayerByName(comboBoxCategory.Text).type;
                }
                //disable rellevant control according to the category ticket #4982
                if (categoryType == MS_LAYER_TYPE.MS_LAYER_POINT)
                {
                    textBoxPattern.Enabled = false;
                }
                else if (categoryType == MS_LAYER_TYPE.MS_LAYER_LINE)
                {
                    if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0].Text != "Default")
                    {
                        textBoxPattern.Enabled = false;
                        textBoxGap.Enabled     = false;
                    }
                }
                else if (categoryType == MS_LAYER_TYPE.MS_LAYER_POLYGON)
                {
                    if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0].Text != "Default")
                    {
                        textBoxPattern.Enabled = false;
                        textBoxGap.Enabled     = false;
                        textBoxSize.Enabled    = false;
                        textBoxAngle.Enabled   = false;
                        textBoxWidth.Enabled   = false;
                    }
                }
            }

            if (isLabelStyle)
            {
                textBoxMinZoom.Enabled    = false;
                textBoxMaxZoom.Enabled    = false;
                checkBoxAutoAngle.Enabled = false;
                buttonMinScale.Enabled    = false;
                buttonMaxScale.Enabled    = false;
            }
        }