MapInfo Pro Developers User Group

Welcome to the MapInfo Pro Developers community!  We are a group dedicated to the discussion and understanding of MapBasic and .Net MapInfoPro AddIn development. Bring your questions and ideas here. This group includes several members of the Pro development team from around the world.

Please feel free to start a discussion in the discussion tab or join in a conversation.

Product Information  Ideas Portal  MapInfo Community Downloads

Discussions

Members

Resources

Events

 View Only
  • 1.  Implementing legacy style picker controls in .NET?

    Posted 07-13-2024 14:54

    We are converting some of our MapBasic forms using .NET. 

    Is there a way to replicate the standard MapInfo PenPicker and BrushPicker controls in the .NET form world?



    ------------------------------
    Jay Russell
    Lead Systems Analyst
    CENTERPOINT ENERGY RESOURCES
    Houston TX
    ------------------------------


  • 2.  RE: Implementing legacy style picker controls in .NET?

    Posted 07-13-2024 15:17
    Edited by Peter Møller 05-27-2025 02:20

    I did like this, hope this helps

    private void butSetSymStart_Click(object sender, EventArgs e)
            {
                miSymbol sym = new miSymbol();
                sym.setSymbolStyle(rwNet.P2PStartSym);
                _application.RunMapBasicCommand("run menu command " + dotNetMap.mapinfo.M_FORMAT_PICK_SYMBOL);
                sym.setSymbolPropertiesFromCurrent();
                rwNet.P2PStartSym = sym.makeSymbolCommand;
            }

    Note M_FORMAT_PICK_SYMBOL = 503   I had setup as defines.

    I had create a class

    namespace dotNetMap
    {
        public interface ImiSymbol
        {
            Int32 Symbol
            {
                get;
                set;
            }
    
            Int32 Colour
            {
                get;
                set;
            }
    
            Int32 Size
            {
                get;
                set;
            }
    
            Int32 shapeFromCurrent
            {
                get;
            }
    
            Int32 sizeFromCurrent
            {
                get;
            }
    
            Int32 colourFromCurrent
            {
                get;
            }
    
            string makeSymbolCommand
            {
                get;
                set;
            }
        }
    
        public class miSymbol : mapinfo, ImiSymbol
        {
            internal Int32 m_Shape = 0;
            internal Int32 m_Colour = 0;
            internal Int32 m_Size = 0;
    
            internal string m_MakeSymbolCommand = string.Empty;
    
            public string makeSymbolCommand
            {
                set
                {
                    m_MakeSymbolCommand = value;
                }
                get
                {
                    return m_MakeSymbolCommand;
                }
            }
    
            public Int32 Symbol
            {
                get
                {
                    return m_Shape;
                }
                set
                {
                    m_Shape = value;
                }
            }
    
            public Int32 Colour
            {
                get
                {
                    return m_Colour;
                }
                set
                {
                    m_Colour = value;
                }
            }
    
            public Int32 Size
            {
                get
                {
                    return m_Size;
                }
                set
                {
                    m_Size = value;
                }
            }
    
            public Int32 shapeFromCurrent
            {
                get
                {
                    string command = string.Format(@"StyleAttr(CurrentSymbol(),{0})", SYMBOL_CODE);
                    Int32 shape = Convert.ToInt32(Eval(command));
                    return shape;
                }
            }
    
            public Int32 sizeFromCurrent
            {
                get
                {
                    string command = string.Format(@"StyleAttr(CurrentSymbol(),{0})", SYMBOL_POINTSIZE);
                    Int32 size = Convert.ToInt32(Eval(command));
                    return size;
                }
            }
    
            public Int32 colourFromCurrent
            {
                get
                {
                    string command = string.Format(@"StyleAttr(CurrentSymbol(),{0})", SYMBOL_COLOR);
                    Int32 colour = Convert.ToInt32(Eval(command));
                    return colour;
                }
            }
    
            public void setSymbolPropertiesFromCurrent()
            {
                m_Shape = shapeFromCurrent;
                m_Size = sizeFromCurrent;
                m_Colour = colourFromCurrent;
    
                m_MakeSymbolCommand = string.Format("makesymbol({0},{1},{2})", m_Shape, m_Colour, m_Size);
    
                //setSymbolStyle();
            }
    
            public void setSymbolStyle()
            {
                string command = string.Format("Set style symbol makesymbol({0},{1},{2})", m_Shape, m_Colour, m_Size);
                Do(command);
            }
    
            public void setSymbolStyle(Int32 symbol, Int32 colour, Int32 size)
            {
                m_Shape = symbol;
                m_Colour = colour;
                m_Size = size;
    
                setSymbolStyle();
            }
    
            public void setSymbolStyle(string makeSymbol)
            {
                m_MakeSymbolCommand = makeSymbol;
                setSymbolStyleFromCommand();
            }
    
            public void setSymbolStyleFromCommand()
            {
                Do("Set style symbol " + m_MakeSymbolCommand);
            }
        }
    }