MapInfo Pro Developers User Group

 View Only
  • 1.  Using custom icons from a .NET Assembly

    Employee
    Posted 12-20-2017 13:23
      |   view attached

    I got asked how to use custom icons/images from a .NET assembly and I thought that was basically a walk in the park, but it seems to be a bit more tricky than I had expected.

    As you can see in this thread below, Toby has tried creating his own assembly.

    Now I have also tried doing the same but for some reason we are not able to make it work.

    Here's the assembly setup in Visual Studio:

    See Attachment

    If I refer wrongly to the DLL, I get an error saying that the assembly can't be found. If I fix this, the tools loads nicely but instead of seeing my icon on the control, it only shows the caption assigned to the control.

    Here's is how I try to assign the assembly to the control:

    Call SetRbnBtnCtrlLargeIcon(mtsBtn, New_Uri("pack://addinorigin:,,," + ApplicationDirectory$() + "ImageResource.dll;component/Images/First32x32.png", 0))

    What might I be doing wrong? It's probably something very trivial that I have overlooked.

    The following link is no longer available. To access this information, copy the title found in the url into the search tool on the top nav bar, or try searching for key words in the post. https://li360.pitneybowes.com/s/question/0D58000003kDVHPCA4/can-i-also-use-my-own-custom-iconsimages-for-the-controls



  • 2.  RE: Using custom icons from a .NET Assembly

    Employee
    Posted 12-22-2017 03:13

    Hello Peter,

    Based on your assembly setup snapshot. Please make these changes.

    1.) Change the First32X32.png file "Copy to output Directory" properties in visual studio to "Do Not Copy".

    2.) Change the pack uri path to "pack://addinorigin:,,," + ApplicationDirectory$() + "ImageResource.dll;component/Resources/First32x32.png" in MB code.

    This is because the image is in Resources folder. If you don't want to change the MB code than you can change the folder name "Resources" in assembly to "Images".

     

    If this does not work, Please send me the image assembly project.

    Thanks

    Anshul