Jump to content
How to Install Plugins ×

Clock plugin


xod

Recommended Posts

I asked that because when the handles overlap it is hard to read the hour. Perhaps an outline?

 

EDIT: One more thing : Increase the font size.  If I use it on a very large canvas, the font size 40 is not large enough.

Edited by Eli
Link to comment
Share on other sites

The 'Century Gothic' font is provided by MS Office. People who don't have Office installed will not be able to use this plugin.

Spoiler

C:\Program Files\paint.net\Effects\Clock.dll, version 1.0.6223.26977

Name: Clock
Type: ClockEffect.ClockEffectPlugin
Version: 1.0.6223.26977
Author: Copyright © xod
Copyright: Render the clock.
Website: http://www.getpaint.net/redirect/plugins.html
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Font 'Century Gothic' cannot be found.
   at System.Drawing.FontFamily.CreateFontFamily(String name, FontCollection fontCollection)
   at ClockEffect.ClockEffectPlugin..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at PaintDotNet.Menus.EffectMenuBase.AddEffectsToMenu() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 602

 

 

You'll want to use an alternative default font, or have a fallback font for when 'Century Gothic' fails.

  • Upvote 1

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

@Eli:

Font size increased to 100. Download the new version.

 

@toe_head:

For me, on Win10,  when the plugin starts, it automatically chooses the first font in the list of installed fonts -  one that starts with the letter A (Arial in most cases).

Edited by xod
Link to comment
Share on other sites

Doesn't work for me.

 

Spoiler

C:\Program Files\Paint.NET4\Effects\Clock.dll, Version 1.0.6223.29215

Name: Clock
Typ: ClockEffect.ClockEffectPlugin
Version: 1.0.6223.29215
Autor: Copyright © xod
Copyright: Render the clock.
Webseite: http://www.getpaint.net/redirect/plugins.html
System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.ArgumentException: Die Schriftart Century Gothic kann nicht gefunden werden.
   bei System.Drawing.FontFamily.CreateFontFamily(String name, FontCollection fontCollection)
   bei ClockEffect.ClockEffectPlugin..ctor()
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   bei System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   bei PaintDotNet.Menus.EffectMenuBase.AddEffectsToMenu() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:Zeile 602.
 


I don't have that font. A standard like Arial would be better.

Edited by IRON67
Link to comment
Share on other sites

2 hours ago, xod said:

... when the plugin starts, it automatically chooses the first font in the list of installed fonts -  one that starts with the letter A (Arial in most cases).

Yes, but you have the FontFamily value initialized as 'Century Gothic', so that is what's used in the Render until the UI loads (the time span here is just a few milliseconds).

Once the UI has loaded, the EffectToken updates (which includes the new value for the FontFamily... usually 'Arial'), and the Render is restarted.

 

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

I like this xod! Well done.

Link to comment
Share on other sites

Thanks Again Xod,

 

I enhanced the results with some shadows and bevels. I also changed the colors of the handles by selecting each one separately and using color adjustments. :) 

xod-clock-longer-handles-02-5160a78.png

Spoiler

I like the longer handles but some people may prefer short ones as the ones on your first post. Maybe you can add a "shorter indicators" option to keep them. As you see, having different colors for the handles is also very nice and more readable. Maybe using a GUI with tabs could make it possible ( It is easy to say for me but I know that it could mean a great effort)

xod-clock-longer-handles-03-5160ae7.png

 

  • Upvote 6
Link to comment
Share on other sites

1 hour ago, dipstick said:

The updated version still doesn't work for me.

That's a different issue from before. @xod, to fix this one properly, you'd have to migrate from CodeLab to Visual Studio.

 

 

Currently, all installed fonts on the system are being made available to the plugin UI.  The code looks like this:

FontFamily[] Amount4FontFamilies = new InstalledFontCollection().Families;
props.Add(new StaticListChoiceProperty(PropertyNames.Amount4, Amount4FontFamilies, 0, false));

You need to filter out the incompatible fonts. Something like this:

FontFamily[] intstalledFontFamilies = new InstalledFontCollection().Families;
List<FontFamily> usableFonts = new List<FontFamily>();
foreach (FontFamily font in intstalledFontFamilies)
{
    if (font.IsStyleAvailable(FontStyle.Regular))
        usableFonts.Add(font);
}
FontFamily[] Amount4FontFamilies = usableFonts.ToArray();
props.Add(new StaticListChoiceProperty(PropertyNames.Amount4, Amount4FontFamilies, 0, false));

 

  • Upvote 2

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

Dear Xod!  <3

 

:trophy:   Thank you so much for the plugin and for your effort.  :cake:  :coffee:

 

15-01-2017.png

Edited by Seerose
  • Upvote 5

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.png

Link to comment
Share on other sites

Thanks to all who have appreciated my work.
I am convinced that someone else could do the work much better because I'm just a beginner in C #.
If someone wants to make another plugin is my guest and I will remove my plugin.
I do not know how to port the code to Visual Studio.
I have not found any detailed explanation about this except one of EER from VS2010.
I think it would be useful to make a post for explaining in detail with screenshots for those who don't know english very well.

  • Upvote 1
Link to comment
Share on other sites

14 minutes ago, xod said:

Thanks to all who have appreciated my work.
I am convinced that someone else could do the work much better because I'm just a beginner in C #.
If someone wants to make another plugin is my guest and I will remove my plugin.
I do not know how to port the code to Visual Studio.
I have not found any detailed explanation about this except one of EER from VS2010.
I think it would be useful to make a post for explaining in detail with screenshots for those who don't know english very well.

 

Don't worry about it. If I wanted to make a clock, I would likely make it by hand manually anyway. Most people would probably be able to use your plugin the way it is anyway.....

69unju0.gif

Link to comment
Share on other sites

@BoltBait, I have some question:
Because it's a Class Library file and not an exe file the code can not be run in VS. Correct?

But if I make the GUI and the code in VS how to transform the exe file to dll file that can be run in paint.net?
What should I do besides adding references to PDN and transform Windows Form App to Class Library?

 

@sashwilko

Change the Font color (white) to another one.

 

I added an option for digital clock. You must install the font found in the zip archive.

Spoiler

vUzpJxE.png

 

 

 

 

Edited by xod
  • Upvote 1
Link to comment
Share on other sites

11 minutes ago, xod said:

Because it's a Class Library file and not an exe file the code can not be run in VS. Correct?

 

That's right.  You'll need to compile, then copy the dll file into the proper paint.net directory in order to test.

 

11 minutes ago, xod said:

But if I make the GUI and the code in VS how to transform the exe file to dll file that can be run in paint.net?

 

Just follow the instructions in the tutorial I posted above and the output of VS will be DLL and not EXE.

 

11 minutes ago, xod said:

What should I do besides adding references to PDN and transform Windows Form App to Class Library?

 

All the instructions are given in the tutorial for moving a CodeLab script to a VS project.

 

Those instructions will NOT change your project into something that can use a custom UI--it will still be using IndirectUI.

  • Upvote 1
Link to comment
Share on other sites

@xod Sounds like you're moving to a WinForms UI. If you want I can send you a link to my updated user guide for the VS template. That should help you get started.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...