One more hook

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

One more hook

Post by wjstarck »

I need a hook near the bottom of method LayoutControls() after line 2440 on FormOpenDental like so:

Code: Select all

ContrAppt2.Height=height;
try {          <------
Plugins.HookAddCode(ContrAppt2, "FormOpenDental.LayoutControls_bottom"); <------
} catch { } <------
ContrChart2.Location=position;
The try-catch seems to be needed because when OD first loads it calls LayoutControls and I don't think the plugins are quite initialized yet so it bombs. What I'm doing is calling ContrAppt.RefreshModuleScreenPeriod() and ContrAppt.RefreshPeriod() here.

Let me know what naming convention you want to use here. And, I only need this in the head (7.9).

Thanks.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
jordansparks
Site Admin
Posts: 5776
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: One more hook

Post by jordansparks »

We can't put a try-catch in that every customer is guaranteed to hit because it will slow down the load time. We need to find some other way of determining whether plugins are loaded yet.
Jordan Sparks, DMD
http://www.opendental.com
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

OK.

How about this:

Code: Select all

public static Assembly AssemblyEHR;
public bool pluginsLoaded; <-------
.
.
.

private void FormOpenDental_Load(object sender, System.EventArgs e) {
.
.
Plugins.LoadAllPlugins(this);//moved up from right after optimizing tooth chart graphics.  New position might cause problems.
pluginsLoaded = true; <------
.
}
Then, move the hook to line 2369:

Code: Select all

		private void FormOpenDental_Resize(object sender,EventArgs e) {
			
			LayoutControls();
			if (pluginsLoaded) {  <------
				Plugins.HookAddCode(ContrAppt2, "FormOpenDental.FormOpenDental_Resize_end"); <------
			} <------
		}
NOTE: It doesn't matter whether any plugins have *actually loaded*, I just need to know that I'm past Plugins.LoadAllPlugins(this) on FormOpenDental, so if you think a different naming convention is appropriate for bool pluginsLoaded let me know.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
jordansparks
Site Admin
Posts: 5776
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: One more hook

Post by jordansparks »

Closer. I'd rather make PluginsAreLoaded a static property in the Plugins class. And it might simply check to see if PluginList is null.
Jordan Sparks, DMD
http://www.opendental.com
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

Sure. That works.

Thanks.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

What did we ever decide for this one? Is there something I still need to do?

Also, did we ever decide what to do with this:

viewtopic.php?f=3&t=3322

?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: One more hook

Post by michael »

The property PluginsAreLoaded has been added to the head.

Simply use if(PluginList.PluginsAreLoaded) {} to enclose any code that requires the Plugins.

Also, your hook has been added as:

Code: Select all

Plugins.HookAddCode(ContrAppt2,"FormOpenDental.LayoutControls_bottom");
at line 2458 of the head.
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

Thanks Michael-

I guess you didn't catch my edit: The hook should be after line 2383 in method FormOpenDental_Resize like so:

Code: Select all

private void FormOpenDental_Resize(object sender,EventArgs e) {
LayoutControls();
Plugins.HookAddCode(ContrAppt2, "FormOpenDental.FormOpenDental_Resize_end") <-----
} 
Thanks again.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: One more hook

Post by michael »

So, right now it looks like

Code: Select all

if(Plugins.PluginsAreLoaded) {
				Plugins.HookAddCode(ContrAppt2,"FormOpenDental.LayoutControls_bottom");
			}
I'm not sure why we are passing ContrAppt2 instead of this. Did we discuss this? I'm proposing changing it to

Code: Select all

if(Plugins.PluginsAreLoaded) {
				Plugins.HookAddCode(this,"FormOpenDental.FormOpenDental_Resize_end");
			}

when we move it to the FormOpenDental_Resize() function. Does that give you what you need?
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

Hi Michael-

I'm accessing method ContrApptA.RefreshModuleData with this; changing ContrAppt2 to 'this' breaks things. So I'd want it to read:

Code: Select all

if(Plugins.PluginsAreLoaded) {
            Plugins.HookAddCode(ContrAppt2,"FormOpenDental.FormOpenDental_Resize_end");
         }
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: One more hook

Post by michael »

You should be able to use the sender (FormOpenDental/this) to access ContrAppt2. Otherwise you may just need the hook inside ContrAppt. We won't use ContrAppt2 as the sender, because its not the sender. Sending ContrAppt2 was a mistake that we will correct when we move the hook.

So, can you confirm you still want me to move it to here, knowing it will have this as a sender?
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

OK, I've reworked my code so that

Code: Select all

private void FormOpenDental_Resize(object sender,EventArgs e) {
LayoutControls();
	if (Plugins.PluginsAreLoaded) {
		Plugins.HookAddCode(this, "FormOpenDental.FormOpenDental_Resize_end");
	}
}
will work just fine.

Thanks.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: One more hook

Post by michael »

Hook has been moved. It is in the new location in 11.05 (beta).
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck »

Nice.

Thanks.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
Post Reply