Under review

Drawing Toolbar Example

Oystein Bjorke 6 years ago updated by anonymous 6 years ago 2
This discussion was imported from CodePlex

Slxe wrote at 2014-05-21 19:08:

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.


Slxe wrote at 2014-05-26 15:40:

Soooo.... Any feedback at all? >_>

everytimer wrote at 2014-05-26 20:49:

It's cool, keep it up!

objo wrote at 2014-05-26 20:58:

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... :-)

Slxe wrote at 2014-05-26 21:23:

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.

objo wrote at 2014-06-06 21:25:

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...

Slxe wrote at 2014-06-06 22:34:

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.

Slxe wrote at 2014-06-11 19:10:

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.

objo wrote at 2014-06-11 22:02:

Mark Heath is announcing a Pluralsight course about winforms best practices - this sounds interesting:

Slxe wrote at 2014-06-11 22:28:

Sounds promising, thanks for the link.

Slxe wrote at 2014-06-13 18:07:

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.

objo wrote at 2014-06-14 08:48:

Sounds good, I will have a look at your github repo.
I've updated the repo to the latest build, https://github.com/Slxe/OxyPlotDrawingToolbar, and changed the name (don't know what I was thinking putting hyphens in there). The biggest change is moving most of the functionality to custom MouseManipulators, take a look and let me know what you think! =D
Under review
that sounds great! I will have a look at it as soon as I get a chance! sorry it is taking such a long time, I have too many things on my todo list :)