One more hook

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

One more hook

Post by wjstarck » Tue Apr 05, 2011 12:03 pm

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: 5755
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: One more hook

Post by jordansparks » Fri Apr 08, 2011 5:25 am

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: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Fri Apr 08, 2011 6:32 am

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: 5755
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: One more hook

Post by jordansparks » Sun Apr 10, 2011 10:54 am

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: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Sun Apr 10, 2011 12:03 pm

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: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Tue Apr 26, 2011 3:54 am

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 » Thu Apr 28, 2011 9:24 am

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: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Thu Apr 28, 2011 11:54 am

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 » Wed Jul 13, 2011 1:06 pm

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: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Thu Jul 14, 2011 3:44 am

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 » Thu Jul 14, 2011 6:12 am

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: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Thu Jul 14, 2011 10:09 am

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 » Tue Jul 19, 2011 6:32 am

Hook has been moved. It is in the new location in 11.05 (beta).

User avatar
wjstarck
Posts: 941
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: One more hook

Post by wjstarck » Tue Jul 19, 2011 6:44 am

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