[gme-users] Decorator mouse events and draw functions
Kevin Smyth
kevin.m.smyth at gmail.com
Wed Feb 14 15:42:23 CST 2018
Hi Cinthya,
Sorry, I should've told you to cast to IMgaElementDecorator or
MgaDecoratorCommon. Then, you should call boxDecorator.InitializeEx
You can find .pdb debugging symbols and source code for GME and its
BoxDecorator here:
http://repo.isis.vanderbilt.edu/GME/old/
Kevin
On Wed, Feb 14, 2018 at 2:01 PM, Cinthya Lopez <Cinthya_K_Lopez at raytheon.com
> wrote:
> Hi Kevin,
>
>
>
> I have tried the approach you suggested, but when I try to run my
> decorator, I get an error in the GME console saying:
>
>
>
> “Cannot create decorator” and “Couldn’t initialize decorator: Exception
> from HRESULTS: 0x80737003”
>
>
>
> I implemented a BoxDecoratorWrapper class which initializes a
> “IMgaDecorator boxDecorator” class member in the constructor as you
> mentioned in your reply. I call the boxDecorator.Initialize() function
> after with the passed in parameters from my decorator InitializeEx()
> function.
>
>
>
> MyDecorator::InitializeEx(MgaProject p, MgaMetaPart meta, MgaFCO obj,
> IMgaCommonDecoratorEvents eventSink, ulong parentWnd)
>
> {
>
> boxDecoratorWrapper = new BoxDecoratorWrapper(project, meta, obj);
>
> }
>
>
>
> BoxDecoratorWrapper::BoxDecoratorWrapper(MgaProject p, MgaMetaPart meta,
> MgaFCO obj)
>
> {
>
> boxDecorator = (IMgaDecorator)Activator.CreateInstance(Type.
> GetTypeFromProgID(“MGA.BoxDecorator”));
>
> boxDecorator.Initialize(p, meta, obj);
>
> }
>
>
>
> Then I delegate all function implementations available in the
> IMgaDecorator interface to the boxDecorator.
>
>
>
> Am I doing something wrong here? It looks like a few functions in
> MyDecorator are being called before the exception occurs…
>
>
>
> InitializeEx(..) -> called 3 times
>
> GetFeatures() -> called once
>
> GetPorts() -> called once
>
> SetLocation() -> called twice
>
>
>
> Thanks,
>
> Cinthya
>
>
>
> *From:* gme-users [mailto:gme-users-bounces at list.isis.vanderbilt.edu] *On
> Behalf Of *Kevin Smyth
> *Sent:* Monday, February 12, 2018 3:34 PM
> *To:* A list for GME users to share thoughts and discuss bugs and fixes. <
> gme-users at list.isis.vanderbilt.edu>
> *Subject:* [External] Re: [gme-users] Decorator mouse events and draw
> functions
>
>
>
> Hi Cinthya,
>
>
>
> I'd follow the "delegation pattern" for Draw, GetPreferredSize et al
>
>
>
> The default decorator in GME is the "box decorator" which you can create
> in C# like:
>
> var delegate = (IMgaDecorator)Activator.CreateInstance(Type.
> GetTypeFromProgID("MGA.BoxDecorator"));
>
>
>
> Be sure to call Initialize
>
>
>
> Kevin
>
>
>
> On Mon, Feb 12, 2018 at 1:58 PM, Cinthya Lopez <
> Cinthya_K_Lopez at raytheon.com> wrote:
>
> Hi,
>
>
>
> I am trying to implement a Decorator. I used the SampleDecorator.cs file
> that comes with GME install. I was able to run the decorator and catch the
> MouseLeftButtonDoubleClick event, which is the event I am interested in.
> This sample decorator is doing some drawing functionality that is currently
> overwriting the icon/appearance I had set for my Atom in my metamodel. The
> only thing I am interested in doing with the Decorator at this point is to
> catch the mouse event, but the MgaElementDecorator interface seems to
> require the implementation of certain functions such as Draw,
> GetPreferredSize, SetLocation, GetLocation. My question is, is there a way
> to have the decorator take a default implementation for these functions?
> Basically I don’t want the decorator to chance anything about the
> appearance of my Atom, I just want to be able to catch the mouse event and
> perform some functionality from there.
>
>
>
> Thanks,
>
> Cinthya
>
>
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users
>
>
>
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20180214/a426a001/attachment.html>
More information about the gme-users
mailing list