Page 1 of 1

Hook Request

Posted: Sun Sep 15, 2013 7:35 pm
by drtech
_____________________________________________________________________
object[] parameters = {retVal};
if (Plugins.HookMethod(null, "OpenDental.PatientL.GetMainTitleMidInsert", parameters))
{
retVal = (string)parameters[0];
}
_____________________________________________________________________

need this placed right after line 79 in OpenDental.PatientL please.



*********************************************************************************************************************

Second Hook
_____________________________________________________________________
Plugins.HookAddCode(this, "FormSplash.FormSplash_Load_end");
_____________________________________________________________________

obviously placed after line 29 of FormSplash.FormSplash_Load.

Thanks!

Re: Hook Request

Posted: Mon Sep 16, 2013 11:45 am
by jsalmon
I've created a task in our system so that this Hook Request doesn't get missed. It might take us a little longer than usual to add this hook due to our programming resources being stretched pretty thin atm. Should be added by next week I'd imagine.

Re: Hook Request

Posted: Tue Sep 17, 2013 5:58 am
by drtech
I just figured out that the last request may not work? It compiles, but then it seems the number of plugins is still null for the program. I assume this is because it has not yet loaded the plugin info? Initially I was thinking I just had something improperly passed...

Would be nice to be able to use an embedded image in my plugin rather than have to copy and keep track of a *.jpg and a *.dll for a plugin to modify the splash screen.

Re: Hook Request

Posted: Wed Sep 18, 2013 8:44 am
by drtech
So, unless you can make it work, I don't think my second request above will work. I see that plugins don't load until later and that is because the database is not yet connected, and all of that is supposed to run while the splash screen is showing, so I guess the *.jpg method you have implemented is the best workaround. If there is some other way to load an embedded image that I am not thinking of, let me know.

If you can still get the other hook entered, I would appreciate it. Thanks

Re: Hook Request

Posted: Wed Sep 18, 2013 8:57 am
by jsalmon
The original splash is just an embedded resource. The *.jpg method is the only way I'm aware of changing it other than going through a big headache of manipulating the resource.

I've got a programmer with the other hook on his TODO list.

Re: Hook Request

Posted: Wed Sep 18, 2013 11:43 am
by drtech
I actually have a modification I figured out that will allow me to hook the splash after the database is found. Currently the program reloads the splash screen after the database connection is established, so in that second time around, I can hook into it and then achieve the desired effect for my plugin. I will post that code shortly.

Re: Hook Request

Posted: Wed Sep 18, 2013 11:45 am
by allends
This is Jordan. We are trying to add it, but it doesn't follow any of the patterns on our hooks page. Notice how HookMethods always replace an entire method, so they contain a "return". But you seem to have more of a HookAddCode. The pattern needs to look more like the example:

Code: Select all

object[] parameters={myInt,myStr};
Plugins.HookAddCode(this,"FormClaim.GetClaims_beginning", parameters);        
myInt=(int)parameters[0];
myStr=(string)parameters[1];
It also needs to be tested by you before we add it. We don't want to add it, only to have to revise it again later.

Re: Hook Request

Posted: Wed Sep 18, 2013 1:32 pm
by drtech
Sorry, I didn't realize I left it as a "AddMethod" and not "addcode" after my testing. Yes, it was tested and works fine, but I revised it below to follow the patterns since I had combined examples by mistake. I just want to add a string(plugin name) to the retVal so it shows in the title bar. If you have a better way of doing it, then by all means replace it or give me an idea of what you think would be better. This works great and is simpler:

Code: Select all

object[] parameters = {retVal};
Plugins.HookAddCode(null, "OpenDental.PatientL.GetMainTitleMidInsert", parameters);
retVal = (string)parameters[0];                 

added at line 80 of OpenDental.PatientL


for the splash screen, I will continue to work on it...

Re: Hook Request

Posted: Wed Sep 18, 2013 3:31 pm
by drtech
***************************
For the splash screen this modification will make it work on the second showing after the database info is loaded. The user gets the normal splash initially and then my plugin additions will popup. Not what I initially hoped for, but works pretty well actually since a plugin is an add-on anyway and visually represents that to the user.

Code: Select all

If (Plugins.PluginsAreLoaded) Plugins.HookAddCode(this, "FormSplash.FormSplash_Load_end");

to line 30 of OpenDental.FormSplash.cs


The to make it work, the Plugins need to loaded just a bit earlier. If you move

Code: Select all

                Plugins.LoadAllPlugins(this);
 
in FormOpenDental.FormOpenDental_load from line 1662 (before loading the splash screen for the second time) up to 1627, it works great.

All is tested and working.

Re: Hook Request

Posted: Thu Sep 19, 2013 7:07 am
by allends
I will work on adding this today.

Re: Hook Request

Posted: Sun Sep 22, 2013 7:09 pm
by drtech
Thanks.

I have another request. In order to add a setup menu item for my plugin, I need menuItemSettings to be made public rather than private.

change line 66 in FormOpenDental.cs

FROM
***************
private System.Windows.Forms.MenuItem menuItemSettings;
***************

TO
***************
public System.Windows.Forms.MenuItem menuItemSettings;
***************

The hook is already present for me to use, just need this protection level changed. Thanks!

Re: Hook Request

Posted: Tue Oct 01, 2013 3:22 pm
by drtech
Any idea when these recent hooks from a few of us developers will be processed? Thanks.

Re: Hook Request

Posted: Tue Oct 01, 2013 3:46 pm
by wjstarck
drtech wrote:Thanks.

I have another request. In order to add a setup menu item for my plugin, I need menuItemSettings to be made public rather than private.

change line 66 in FormOpenDental.cs

FROM
***************
private System.Windows.Forms.MenuItem menuItemSettings;
***************

TO
***************
public System.Windows.Forms.MenuItem menuItemSettings;
***************

The hook is already present for me to use, just need this protection level changed. Thanks!
David-

Sorry to butt in :oops: , but do you just want to add a custom menuItem somewhere? PM me, you can do that without OD staff having to change the access modifier for that control

Re: Hook Request

Posted: Wed Oct 02, 2013 2:33 pm
by allends
drtech wrote:***************************
The to make it work, the Plugins need to loaded just a bit earlier. If you move

Code: Select all

                Plugins.LoadAllPlugins(this);
 
in FormOpenDental.FormOpenDental_load from line 1662 (before loading the splash screen for the second time) up to 1627, it works great.

All is tested and working.
For this change could you give me the code around it so I can get this in the correct place. Currently if I place it on the line it will not compile.

Re: Hook Request

Posted: Wed Oct 02, 2013 4:41 pm
by drtech
if(!formChooseDb.TryToConnect()) {
formChooseDb.ShowDialog();
if(formChooseDb.DialogResult==DialogResult.Cancel) {
Application.Exit();
return;
}
}
}
else {
formChooseDb.ShowDialog();
if(formChooseDb.DialogResult==DialogResult.Cancel) {
Application.Exit();
return;
}
}
Cursor=Cursors.WaitCursor;
Plugins.LoadAllPlugins(this);//moved again for splash screen plugins-->moved up from right after optimizing tooth chart graphics. New position might cause problems.
Splash = new FormSplash();
if(CommandLineArgs.Length==0) {
Splash.Show();
}
if(!PrefsStartup()){//looks for the AtoZ folder here, but would like to eventually move that down to after login
Cursor=Cursors.Default;
Splash.Dispose();
Application.Exit();
return;
}
__________________________________________________________________________________---
this is the new position and compiles and runs fine if you place it here. Thanks, David.

Re: Hook Request

Posted: Thu Oct 03, 2013 8:10 am
by allends
DrTech,

Were you able to access the private control through our public Controls property?

http://www.opendental.com/manual/plugins.html

1. To access the private controls on an existing form from outside the form, look through the public Controls property as shown in the posted example.

Changing the privacy setting on a control to public is generally not good practice, but you should still be able to access it this way.

Re: Hook Request

Posted: Thu Oct 03, 2013 11:21 am
by allends
drtech wrote:***************************
For the splash screen this modification will make it work on the second showing after the database info is loaded. The user gets the normal splash initially and then my plugin additions will popup. Not what I initially hoped for, but works pretty well actually since a plugin is an add-on anyway and visually represents that to the user.

Code: Select all

If (Plugins.PluginsAreLoaded) Plugins.HookAddCode(this, "FormSplash.FormSplash_Load_end");

to line 30 of OpenDental.FormSplash.cs


The to make it work, the Plugins need to loaded just a bit earlier. If you move

Code: Select all

                Plugins.LoadAllPlugins(this);
 
in FormOpenDental.FormOpenDental_load from line 1662 (before loading the splash screen for the second time) up to 1627, it works great.

All is tested and working.
Due to moving Plugins.LoadAllPlugins I am not going to backport this to the beta, but it will exist in the head.

Re: Hook Request

Posted: Thu Oct 03, 2013 11:52 am
by allends
drtech wrote:Sorry, I didn't realize I left it as a "AddMethod" and not "addcode" after my testing. Yes, it was tested and works fine, but I revised it below to follow the patterns since I had combined examples by mistake. I just want to add a string(plugin name) to the retVal so it shows in the title bar. If you have a better way of doing it, then by all means replace it or give me an idea of what you think would be better. This works great and is simpler:

Code: Select all

object[] parameters = {retVal};
Plugins.HookAddCode(null, "OpenDental.PatientL.GetMainTitleMidInsert", parameters);
retVal = (string)parameters[0];                 

added at line 80 of OpenDental.PatientL


for the splash screen, I will continue to work on it...
This has been backported to the beta.

Re: Hook Request

Posted: Fri Oct 04, 2013 8:19 pm
by drtech
Thanks for the other additions
DrTech,

Were you able to access the private control through our public Controls property?

http://www.opendental.com/manual/plugins.html

1. To access the private controls on an existing form from outside the form, look through the public Controls property as shown in the posted example.

Changing the privacy setting on a control to public is generally not good practice, but you should still be able to access it this way.
No, I have added other controls to the forms and manipulated lots of other controls, but I can't seem to access menus through the "Controls" property.

Here is what I am doing, but this only works if the menu itself is public. I can't use "menuItemSettings.MenuItems.Add" or seem to add a menu item using the standard "Controls.Add"

Code: Select all

        public static void OpenDental_Load_end(OpenDental.FormOpenDental sender)
        {
            formModuleSetupP = new FormModuleSetupP();
            MenuItem mnu = new MenuItem();
            mnu.Text = "Plugin Customized Setup";
            mnu.Name = "PluginSetup";
            mnu.Index = 0;
            mnu.Click += formModuleSetupP.aGoldPluginOptionsToolStripMenuItem1_Click;
            sender.menuItemSettings.MenuItems.Add(0, mnu);
   

        

        }
wjstarck sent me an alternate method of adding a menu item, but I have not yet have time to try it out.....