internal static HandleRef getCPtrAndSetReference(symbolSetObj obj, object parent) { if (obj != null) { obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
public void testsymbolSetObj() { mapObj map = new mapObj(mapfile); symbolSetObj symbolset = map.symbolset; symbolset.filename = "filename"; map = null; gc(); assert(symbolset.filename == "filename", "testsymbolSetObj"); }
/// <summary> /// Find symbol by name (without adding) /// </summary> /// <param name="symbolset">The symbolset object</param> /// <param name="key_to_find">the symbol name to search for</param> /// <returns>Symbol found or null</returns> public static symbolObj FindSymbol(symbolSetObj symbolset, string name_to_find) { if (name_to_find != null) { for (int i = 0; i < symbolset.numsymbols; i++) { symbolObj sym = symbolset.getSymbol(i); if (sym.name != null && sym.name.ToLower() == name_to_find.ToLower()) { return(sym); } } } return(null); }
/// <summary> /// Click event handler of the buttonRemoveFont control. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="layer">The selected layer.</param> private void buttonRemoveFont_Click(object sender, EventArgs e) { if (listViewFonts.SelectedItems.Count > 0) { // check whether we have symbol references to this font string fontName = listViewFonts.SelectedItems[0].Text; if (map != null) { symbolSetObj symbolset = map.symbolset; for (int i = 0; i < symbolset.numsymbols; i++) { symbolObj sym = map.symbolset.getSymbol(i); if (String.Compare(sym.font, fontName, true) == 0) { MessageBox.Show("Unable to remove the selected font! The map file contains symbol referring to this font: " + sym.name, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } if (StyleLibrary.Styles != null) { symbolSetObj symbolset = ((mapObj)StyleLibrary.Styles).symbolset; for (int i = 0; i < symbolset.numsymbols; i++) { symbolObj sym = map.symbolset.getSymbol(i); if (String.Compare(sym.font, fontName, true) == 0) { MessageBox.Show("Unable to remove the selected font! The style library contains symbol referring to this font: " + sym.name, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } if (MessageBox.Show("Are you sure you want to delete the selected font?", "MapManager", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } listViewFonts.Items.Remove(listViewFonts.SelectedItems[0]); SetFontsetModified(true); } }
/// <summary> /// Validating event handler of the scintillaControlSymbolset control. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="layer">The selected layer.</param> private void scintillaControlSymbolset_Validating(object sender, CancelEventArgs e) { if (symbolsetChanged) { // validating string fileName = Path.GetTempFileName(); try { File.WriteAllText(fileName, scintillaControlSymbolset.Text); // test whether we can parse the symbolset symbolSetObj s = new symbolSetObj(fileName); // make sure we have all symbol references Hashtable symbolNames = new Hashtable(); for (int i = 0; i < s.numsymbols; i++) { string symbolName = s.getSymbol(i).name; if (symbolName != null && !symbolNames.ContainsKey(symbolName)) { symbolNames.Add(symbolName, symbolName); } } mapObj map = StyleLibrary.Styles; s = map.symbolset; for (int i = 0; i < s.numsymbols; i++) { symbolObj sym = s.getSymbol(i); string symbolName = sym.name; if (symbolName != null && sym.inmapfile == mapscript.MS_TRUE && !symbolNames.ContainsKey(symbolName)) { symbolNames.Add(symbolName, symbolName); } } for (int i = 0; i < map.numlayers; i++) { layerObj layer = map.getLayer(i); for (int j = 0; j < layer.numclasses; j++) { classObj classobj = layer.getClass(j); for (int k = 0; k < classobj.numstyles; k++) { string symbolName = classobj.getStyle(k).symbolname; if (symbolName != null && !symbolNames.ContainsKey(symbolName)) { throw new Exception("Symbol name '" + symbolName + "' is missing from the symbolset file!"); } } } } } catch (Exception ex) { if (MessageBox.Show(ex.Message + "\n\rPress OK to correct the errors or Cancel to ignore the changes!", "MapManager", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { e.Cancel = true; } else { LoadSymbolset(); } return; } finally { if (File.Exists(fileName)) { File.Delete(fileName); } } // validation ok, ask whether to save or not DialogResult res = MessageBox.Show("Do you wish to save the modifications of the symbolset?", "MapManager", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (res == DialogResult.Yes) { SaveSymbolset(); // the symbolset has changed, need to reload view timerRefresh.Enabled = true; } else if (res == DialogResult.No) { LoadSymbolset(); } else if (res == DialogResult.Cancel) { e.Cancel = true; } } }
internal static HandleRef getCPtr(symbolSetObj obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
/// <summary> /// Find symbol by name (without adding) /// </summary> /// <param name="symbolset">The symbolset object</param> /// <param name="key_to_find">the symbol name to search for</param> /// <returns>Symbol found or null</returns> public static symbolObj FindSymbol(symbolSetObj symbolset, string name_to_find) { if (name_to_find != null) { for (int i = 0; i < symbolset.numsymbols; i++) { symbolObj sym = symbolset.getSymbol(i); if (sym.name != null && sym.name.ToLower() == name_to_find.ToLower()) return sym; } } return null; }
/// <summary> /// Validating event handler of the scintillaControlSymbolset control. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="layer">The selected layer.</param> private void scintillaControlSymbolset_Validating(object sender, CancelEventArgs e) { if (symbolsetChanged) { // validating string fileName = Path.GetTempFileName(); try { File.WriteAllText(fileName, scintillaControlSymbolset.Text); // test whether we can parse the symbolset symbolSetObj s = new symbolSetObj(fileName); // make sure we have all symbol references Hashtable symbolNames = new Hashtable(); for (int i = 0; i < s.numsymbols; i++) { string symbolName = s.getSymbol(i).name; if (symbolName != null && !symbolNames.ContainsKey(symbolName)) symbolNames.Add(symbolName, symbolName); } mapObj map = StyleLibrary.Styles; s = map.symbolset; for (int i = 0; i < s.numsymbols; i++) { symbolObj sym = s.getSymbol(i); string symbolName = sym.name; if (symbolName != null && sym.inmapfile == mapscript.MS_TRUE && !symbolNames.ContainsKey(symbolName)) symbolNames.Add(symbolName, symbolName); } for (int i = 0; i < map.numlayers; i++) { layerObj layer = map.getLayer(i); for (int j = 0; j < layer.numclasses; j++) { classObj classobj = layer.getClass(j); for (int k = 0; k < classobj.numstyles; k++) { string symbolName = classobj.getStyle(k).symbolname; if (symbolName != null && !symbolNames.ContainsKey(symbolName)) throw new Exception("Symbol name '" + symbolName + "' is missing from the symbolset file!"); } } } } catch (Exception ex) { if (MessageBox.Show(ex.Message + "\n\rPress OK to correct the errors or Cancel to ignore the changes!", "MapManager", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) e.Cancel = true; else { LoadSymbolset(); } return; } finally { if (File.Exists(fileName)) File.Delete(fileName); } // validation ok, ask whether to save or not DialogResult res = MessageBox.Show("Do you wish to save the modifications of the symbolset?", "MapManager", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (res == DialogResult.Yes) { SaveSymbolset(); // the symbolset has changed, need to reload view timerRefresh.Enabled = true; } else if (res == DialogResult.No) { LoadSymbolset(); } else if (res == DialogResult.Cancel) e.Cancel = true; } }