Customise colour dropdown
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 510
- Joined: Sat May 16, 2009 1:55 pm
Customise colour dropdown
Within my application I am restricting the colours that the user are able to place annotations using. I like the use of the properties toolbar that appears as all modification features are there, however I would like to customise the colour dropdown to only show certain RGB colours. Is this possible, or alternatively can I replace your standard colour dropdown on the properties bar with my own?
Thanks
Simon
Thanks
Simon
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 510
- Joined: Sat May 16, 2009 1:55 pm
Re: Customise colour dropdown
Is there any update on this?
Thanks
Simon
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Customise colour dropdown
Hello Simon,
Here's how you can get to the Color Picker interface (in this sample the stroke color command):
After that you can for example add custom colors:
Also, do not forget to remove the Custom Command handler when destroying the form.
Cheers,
Alex
Here's how you can get to the Color Picker interface (in this sample the stroke color command):
Code: Select all
class ColorPickerCommandHandler : PDFXEdit.IUIX_CmdHandler
{
public PDFXEdit.IPXV_Inst m_Inst = null;
public PDFXEdit.IUIX_CmdHandler m_OldHandler = null;
public PDFXEdit.IUIX_List m_List;
public ColorPickerCommandHandler(PDFXEdit.IPXV_Inst Inst)
{
m_Inst = Inst;
}
public void OnCreateNewCtl(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdBar pParent, out PDFXEdit.IUIX_Obj pCtl)
{
//Here the list is created
m_OldHandler.OnCreateNewCtl(pCmd, pParent, out pCtl);
}
public void OnGetCtlSizes(PDFXEdit.IUIX_CmdItem pItem, ref PDFXEdit.tagSIZE nSize, ref PDFXEdit.tagSIZE nMinSize, ref PDFXEdit.tagSIZE nMaxSize)
{
m_OldHandler.OnGetCtlSizes(pItem, nSize, nMinSize, nMaxSize);
}
public void OnGetItemState(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, out int nState)
{
m_OldHandler.OnGetItemState(pCmd, pItem, pOwner, out nState);
}
public void OnGetItemSubMenu(PDFXEdit.IUIX_CmdItem pItem, out PDFXEdit.IUIX_CmdMenu pSubMenu)
{
//pSubMenu = null;
pSubMenu = pItem.SubMenu;
}
public void OnNotify(int nCode, PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, uint nNotifyData)
{
//Getting color picker
IUIX_CmdColorBtn cbutton = pItem.Ctl.Impl as IUIX_CmdColorBtn;
//cbutton.ColorPicker;
m_OldHandler.OnNotify(nCode, pCmd, pItem, pOwner, nNotifyData);
}
public void OnDrawItemIcon(PDFXEdit.IUIX_RenderContext pRC, PDFXEdit.IUIX_CmdItem pItem, ref PDFXEdit.tagRECT stIconRect, ref PDFXEdit.tagRECT stClip)
{
m_OldHandler.OnDrawItemIcon(pRC, pItem, stIconRect, stClip);
}
}
private void colorPickerTestToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorPickerCommandHandler ch = new ColorPickerCommandHandler(pdfCtl.Inst);
PDFXEdit.IUIX_Inst iuiInst = (PDFXEdit.IUIX_Inst)pdfCtl.Inst.GetExtension("UIX");
PDFXEdit.IUIX_Cmd cmd = iuiInst.CmdManager.Cmds.Find("cmd.scolor");
ch.m_OldHandler = cmd.Handler;
cmd.Handler = ch;
}
Code: Select all
public void OnNotify(int nCode, PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, uint nNotifyData)
{
//Getting color picker
IUIX_CmdColorBtn cbutton = pItem.Ctl.Impl as IUIX_CmdColorBtn;
IAUX_Inst auxInst = (IAUX_Inst)m_Inst.GetExtension("AUX");
PDFXEdit.IColor color = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
color.SetRGB(1.0f, 0.0f, 0.0f);
cbutton.ColorPicker.AddCustomColor(color);
m_OldHandler.OnNotify(nCode, pCmd, pItem, pOwner, nNotifyData);
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 510
- Joined: Sat May 16, 2009 1:55 pm
Re: Customise colour dropdown
Alex,
I have tried the following code, but I get the below error:
Error registering background colour events: Unable to cast object of type 'ColorPickerCommandHandler' to type 'PDFXEdit.IUIX_CmdHandler'.
On this line:
Full code below:
Obviously doing something wrong here
Thanks
Simon
I have tried the following code, but I get the below error:
Error registering background colour events: Unable to cast object of type 'ColorPickerCommandHandler' to type 'PDFXEdit.IUIX_CmdHandler'.
On this line:
Code: Select all
cmd.Handler = ch
Code: Select all
Public Sub registerBGColourEvent()
Try
Dim ch As ColorPickerCommandHandler = New ColorPickerCommandHandler(Me.docPreview.Inst)
Dim iuiInst As PDFXEdit.IUIX_Inst = CType(Me.docPreview.Inst.GetExtension("UIX"), PDFXEdit.IUIX_Inst)
Dim cmd As PDFXEdit.IUIX_Cmd = iuiInst.CmdManager.Cmds.Find("cmd.scolor")
ch.m_OldHandler = cmd.Handler
cmd.Handler = ch
Catch ex As Exception
Debug.WriteLine("Error registering background colour events: " & ex.Message)
End Try
End Sub
Class ColorPickerCommandHandler
Public m_OldHandler As PDFXEdit.IUIX_CmdHandler = Nothing
Public m_List As PDFXEdit.IUIX_List
Public m_Inst As PDFXEdit.IPXV_Inst = Nothing
Public Sub New(ByVal Inst As PDFXEdit.IPXV_Inst)
m_Inst = Inst
End Sub
Public Sub OnCreateNewCtl(ByVal pCmd As PDFXEdit.IUIX_Cmd, ByVal pParent As PDFXEdit.IUIX_CmdBar, <Out> ByRef pCtl As PDFXEdit.IUIX_Obj)
m_OldHandler.OnCreateNewCtl(pCmd, pParent, pCtl)
End Sub
Public Sub OnGetCtlSizes(ByVal pItem As PDFXEdit.IUIX_CmdItem, ByRef nSize As PDFXEdit.tagSIZE, ByRef nMinSize As PDFXEdit.tagSIZE, ByRef nMaxSize As PDFXEdit.tagSIZE)
m_OldHandler.OnGetCtlSizes(pItem, nSize, nMinSize, nMaxSize)
End Sub
Public Sub OnGetItemState(ByVal pCmd As PDFXEdit.IUIX_Cmd, ByVal pItem As PDFXEdit.IUIX_CmdItem, ByVal pOwner As PDFXEdit.IUIX_Obj, <Out> ByRef nState As Integer)
m_OldHandler.OnGetItemState(pCmd, pItem, pOwner, nState)
End Sub
Public Sub OnGetItemSubMenu(ByVal pItem As PDFXEdit.IUIX_CmdItem, <Out> ByRef pSubMenu As PDFXEdit.IUIX_CmdMenu)
pSubMenu = pItem.SubMenu
End Sub
Public Sub OnNotify(ByVal nCode As Integer, ByVal pCmd As PDFXEdit.IUIX_Cmd, ByVal pItem As PDFXEdit.IUIX_CmdItem, ByVal pOwner As PDFXEdit.IUIX_Obj, ByVal nNotifyData As UInteger)
Dim cbutton As IUIX_CmdColorBtn = TryCast(pItem.Ctl.Impl, IUIX_CmdColorBtn)
m_OldHandler.OnNotify(nCode, pCmd, pItem, pOwner, nNotifyData)
End Sub
Public Sub OnDrawItemIcon(ByVal pRC As PDFXEdit.IUIX_RenderContext, ByVal pItem As PDFXEdit.IUIX_CmdItem, ByRef stIconRect As PDFXEdit.tagRECT, ByRef stClip As PDFXEdit.tagRECT)
m_OldHandler.OnDrawItemIcon(pRC, pItem, stIconRect, stClip)
End Sub
End Class
Private Sub colorPickerTestToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ch As ColorPickerCommandHandler = New ColorPickerCommandHandler(Me.docPreview.Inst)
Dim iuiInst As PDFXEdit.IUIX_Inst = CType(Me.docPreview.Inst.GetExtension("UIX"), PDFXEdit.IUIX_Inst)
Dim cmd As PDFXEdit.IUIX_Cmd = iuiInst.CmdManager.Cmds.Find("cmd.scolor")
ch.m_OldHandler = cmd.Handler
cmd.Handler = ch
End Sub
Public Sub OnNotify(ByVal nCode As Integer, ByVal pCmd As PDFXEdit.IUIX_Cmd, ByVal pItem As PDFXEdit.IUIX_CmdItem, ByVal pOwner As PDFXEdit.IUIX_Obj, ByVal nNotifyData As UInteger)
Dim cbutton As IUIX_CmdColorBtn = TryCast(pItem.Ctl.Impl, IUIX_CmdColorBtn)
Dim auxInst As IAUX_Inst = CType(Me.docPreview.Inst.GetExtension("AUX"), IAUX_Inst)
Dim color As PDFXEdit.IColor = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB)
color.SetRGB(1.0F, 0.0F, 0.0F)
cbutton.ColorPicker.AddCustomColor(color)
myEventBGColourTarget.m_OldHandler.OnNotify(nCode, pCmd, pItem, pOwner, nNotifyData)
End Sub
Thanks
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Customise colour dropdown
Hello Simon,
I'm not a VB expert but obviously you've forgot to inherit your class:
Cheers,
Alex
I'm not a VB expert but obviously you've forgot to inherit your class:
Code: Select all
class ColorPickerCommandHandler : PDFXEdit.IUIX_CmdHandler
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 510
- Joined: Sat May 16, 2009 1:55 pm
Re: Customise colour dropdown
Alex,
I have got this working now and the color is being successfully added to the color picker. However the problem is that I now wish to hide the "Standard Colors" and also the "More Colors" button from the colorPicker. I have added my code below for info purposes:
Thanks
Simon
I have got this working now and the color is being successfully added to the color picker. However the problem is that I now wish to hide the "Standard Colors" and also the "More Colors" button from the colorPicker. I have added my code below for info purposes:
Code: Select all
Public Sub OnNotify(ByVal nCode As Integer, ByVal pCmd As PDFXEdit.IUIX_Cmd, ByVal pItem As PDFXEdit.IUIX_CmdItem, ByVal pOwner As PDFXEdit.IUIX_Obj, ByVal nNotifyData As UInteger)
Dim cbutton As IUIX_CmdColorBtn = TryCast(pItem.Ctl.Impl, IUIX_CmdColorBtn)
Dim auxInst As IAUX_Inst = CType(Me.docPreview.Inst.GetExtension("AUX"), IAUX_Inst)
Dim color As PDFXEdit.IColor = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB)
color.Value = "rgbd(" & activeAnnotColour.R.ToString & "," & activeAnnotColour.G.ToString & "," & activeAnnotColour.B.ToString & ")"
cbutton.ColorPicker.ClearCustomColors()
cbutton.ColorPicker.AddCustomColor(color)
' Add white
color.Value = "rgbd(255,255,255)"
cbutton.ColorPicker.AddCustomColor(color)
myEventBGColourTarget.m_OldHandler.OnNotify(nCode, pCmd, pItem, pOwner, nNotifyData)
End Sub
Thanks
Simon
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Customise colour dropdown
Hello Simon,
If you are initializing the ColorPickerCommandHandler before the first stroke color popup is shown (for example, after the control initialization), then this code should work perfectly for you:
Also, there won't be any need to add any new code to the OnNotify method:
Cheers,
Alex
If you are initializing the ColorPickerCommandHandler before the first stroke color popup is shown (for example, after the control initialization), then this code should work perfectly for you:
Code: Select all
public void OnCreateNewCtl(PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdBar pParent, out PDFXEdit.IUIX_Obj pCtl)
{
m_OldHandler.OnCreateNewCtl(pCmd, pParent, out pCtl);
IntPtr outPtr;
pCtl.QueryImpl(typeof(PDFXEdit.IUIX_CmdColorBtn).GUID, null, out outPtr);
PDFXEdit.IUIX_CmdColorBtn cbutton = (PDFXEdit.IUIX_CmdColorBtn)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
cbutton.ColorPicker.Obj.SetStyle((uint)UIX_ColorPickerStyleFlags.UIX_ColorPickerStyle_NoMoreColors | (uint)UIX_ColorPickerStyleFlags.UIX_ColorPickerStyle_NoStdColors, (uint)UIX_ColorPickerStyleFlags.UIX_ColorPickerStyle_NoMoreColors | (uint)UIX_ColorPickerStyleFlags.UIX_ColorPickerStyle_NoStdColors);
IAUX_Inst auxInst = (IAUX_Inst)m_Inst.GetExtension("AUX");
PDFXEdit.IColor color = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
color.SetRGB(1.0f, 0.0f, 0.0f);
cbutton.ColorPicker.AddCustomColor(color);
color.SetRGB(1.0f, 0.0f, 1.0f);
cbutton.ColorPicker.AddCustomColor(color);
color.SetRGB(1.0f, 1.0f, 1.0f);
cbutton.ColorPicker.AddCustomColor(color);
}
Code: Select all
public void OnNotify(int nCode, PDFXEdit.IUIX_Cmd pCmd, PDFXEdit.IUIX_CmdItem pItem, PDFXEdit.IUIX_Obj pOwner, uint nNotifyData)
{
m_OldHandler.OnNotify(nCode, pCmd, pItem, pOwner, nNotifyData);
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 510
- Joined: Sat May 16, 2009 1:55 pm
Re: Customise colour dropdown
Thanks Alex,
Worked perfectly.
Thanks for your help
Simon
Worked perfectly.
Thanks for your help
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Customise colour dropdown
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ