Drawing Toolbar Example

May 21, 2014 at 6:08 PM
Hello again!

Here's the drawing toolbar example I was talking about a bit. Please let me know what you think, if I'm doing anything wrong, or if you know of any improvements I can make to it =). I might add a few more features depending on if I get some more free time.

https://github.com/Slxe/OxyPlot-Drawing-Toolbar
May 26, 2014 at 2:40 PM
Soooo.... Any feedback at all? >_>
May 26, 2014 at 7:49 PM
It's cool, keep it up!
Coordinator
May 26, 2014 at 7:58 PM
Sorry for the slow response, I have too many projects going on and too little spare time. Thanks for reminding!

I have cloned your repository and had a look at the code. It is a really nice demo, and I hope we can include this in the 'official' demos later. But I have some comments after a first quick look:
  • the architecture should be changed to use a PlotController - this can make the annotation creation/editing reusable on all platforms!
  • use some ui pattern (mvc, mvp, mvvm?) to separate all the logic from the views
  • Convert.ToDouble is missing culture, it throws exceptions all the time on my machine. I got around by setting System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; in the Program.Main.
For code that should be pulled into the OxyPlot project, see the contribution guidelines.

Please continue on this demo! I can do more code reviews later, but expect response to vary from 2min to weeks... :-)
May 26, 2014 at 8:23 PM
Hey! Thanks for the reply. I'm still a bit ... nervous or uncertain of my code in C# since I've only really been using it for a few months now (since I started my current job), and I've got a lot more experience with Java and Python, so any tips on the code greatly help. I'll definitely look into what you've suggested and let you know when I've updated it.

As far as coding style goes I use ReSharper myself, but I'll look into what StyleCop suggests just so it matches up to the requirements. Wasn't really sold on regions yet either, so I'll just remove them as per the guidelines. lol I come from Python which has the PEP8 Coding Guidelines and the "pythonic" way of coding, so I try and approach new languages looking for language specific idioms (if that's even the right way to word that? O_o), so any tips at all are always welcome.
Coordinator
Jun 6, 2014 at 8:25 PM
I have added https://oxyplot.codeplex.com/workitem/10218
I can probably help setting up a little "skeleton example" using a PlotController, but I have a few other tasks to finish first...
Jun 6, 2014 at 9:34 PM
I've been reading the source a bit when I've had free time trying to think of a good way to put it together myself, but had other things require my attention at work so I haven't really put a lot of time into it yet sadly.

They've actually asked me to make a generic custom control at work that will let them add axes and series through the designers properties browser, as well as include the annotation toolbar and a custom legend (it lists all axes and series in the plotmodel with visibility checkboxes and colour buttons for the series pic), so I'll probably end up taking some time to rework it into a proper mvc pattern for that and submit it afterwards. I'm just reading up on proper implementation of a custom control, properties and such in winforms (although it's kinda hard finding a good post on the subject after 2005ish, was hoping to find one with C# 4/5 features). It'll hopefully be pretty generic (although winforms based) so I'd be happy to submit it if It'd be useful.
Jun 11, 2014 at 6:10 PM
Scratch the idea of allowing the devs to add series and axes through the designer, after talking to the devs that'll be using the control and thinking about it, figured it'd be best to just have methods to handle it.

Been looking myself, but you wouldn't happen to have any good resources on pattern implementation for custom user controls in C#? Or I guess if it's even needed/recommended for user controls? Just going off a book a co worker let my borrow and various msdn posts.
Coordinator
Jun 11, 2014 at 9:02 PM
Mark Heath is announcing a Pluralsight course about winforms best practices - this sounds interesting:
http://mark-dot-net.blogspot.no/2014/06/is-windows-forms-dead-yet.html
Jun 11, 2014 at 9:28 PM
Sounds promising, thanks for the link.
Jun 13, 2014 at 5:07 PM
Edited Jun 13, 2014 at 5:07 PM
All right, I've moved the annotation drawing events out of the toolbar into their own custom MouseManipulators and now throw those into the PlotController as commands. Let me know when you get some free time how it turned out please =). Next is moving some of the other toolbar actions into the PlotController as well, and commenting everything.
Coordinator
Jun 14, 2014 at 7:48 AM
Sounds good, I will have a look at your github repo.