Drawing app - the easiest design - wpf

Well, I'm a newbie. I'd like to write an app in WPF. The main purpouse will be in drawing predefined elements/objects. Input from user is mostly realized by text boxes - numbers. But I'd like to add some kind of user input into drawing itself too + zooming and moving. Next functionality will be in saving the draw for later loading and another editing (printing maybe, but it's far far away).
I can imagine something like this:
due to some user interaction I'd prefere to use of InkCanvas
i want to define my own elements/objects with some properties. But where it will be define? Some external file maybe?
the save file will be composed of XAML code only
I will study this more lately, but I want to know if my thoughts are in the right way.
Are these points correct, or completely bullshit? :)
Thanks, and sorry for English...

I don't know if this is exactly what are you looking for, but here a little list of advice to help you on reaching your goal:
First of all, if you are crating an application, you should see this before. It explain the Model-View-ViewModel pattern, which is essential when you are creating something on WPF. This can help you abount your 2nd point.
Regarding your save file, i don't know exactly what you have in mind, but it depends on what do you want to save exactly. If you want, InkCanvas have the option to export directly the work in a bitmap . If you need to store some setting, depending on your need you can work with Settings or Resources
InkCanvas seems the appropriate tool for your need. Of course you will have to build your app around this control

Related

Implement a point highlighting a line of text in CustomTaskPanes

I have asked a question about CustomTaskPanes. It seems that we can implement lots of things inside a pane.
I think it is totally feasible to have a pane to display a program (in VBA or in other languages) or a text, my question is if it is possible to implement a point that allow users to highlight a line of text. It looks like a "breakpoint", but does not necessarily work exactly like a breakpoint for debugging. The implementation of this kind of point does not seem straightforward to me. Does anyone know if there is any technique inside CustomTaskPanes to do so?
PS: I made an image to illustrate the point, let's assume the pane is inside the excel editor and is a CustomTaskPane.

Converting multiple (and different) windows into tabs

Fairly new to WPF.
I'm tasked with converting our application with about ten different windows into a single-window, multi-tabbed application. I'd like your input on the most effective way of doing this.
I suppose I could do this the most-straightforward way -- copying and pasting a ton of code into the main XAML file. I imagine I'd end up with a gigantic file though, and would like to avoid that.
I should mention that the contents of each tab will be substantially different from each other.
There must be some element of WPF that enables this that I just haven't been able to find. Really appreciate any input.
In XAML there are user controls which you can use. That way, you could use one user-control per tab-content and let the main window only contain the tabview and tabitems and some minor logic code.
To achieve that, you can simply copy-paste most of your current window-code in one user control per window. The code base could remain almost the same (if there are no interactions between the windows at least).
There are quite many resources out there containing further details on user controls like this code-project article (a bit old, but the majority of its contents will still apply) or that MSDN one.

Is the winform 'size' property localizable in any way?

I'm in the process of writing a set of documents to help other developers in our office localize various components of a large application. I'm using a tool called Globalizer.NET to do the donkey work and it's very good as it even lets you localize the size and position properties of controls to allow for the likely changes in length of text strings once translated. However, it occurred to me that in some cases I might need to re-size the entire form a bit, but Globalizer doesn't let you do this, and I cannot see any other way of doing this. I have even tried manually adding an entry in the language specific resource file for the form size but it doesn't make any difference.
Ultimately, once it has become a little more established, we'd consider moving to WPF which I understand makes this easier, but for now we can't for a number of reasons.
Is there any way at all to localize this property of a winform? I am beginning to suspect not, but figured I'd ask in case someone else has come up with a workaround.
Don't worry - about a moment after posting this I had a bit of a Homer moment and realised I was trying to use the wrong property - ClientSize is a perfectly localizable property!
Thanks for reading.
Steve

Silverlight - Highlight List<> of words/prhases within TextBox

I am new to Silverlight and have a requirement to highlight (or change font color) all words and phrases wtihin a TextBox that match a list of words/phrases. At first I though this would be easy, but the more I look into it, the more confused I get.
My goal is to write something reusable so I can also apply the logic to a RadGridView later. I've seen a few examples of stuff close to what I need, but it's beyond my Silverlight level at this point.
I want to write this myself to get a better understanding of how some of the Silverlight internals work. Can someone point me in the right direction of where to start on something like this? Should this be implemented in a control? Should I use a behavior? I'm using Silverlight 4.
Once I know where to start, I am sure I can get this done - with some help from you guys of course ;-)
Thanks,
-Scott
How about using the RadRichTextBox (I assume you have a licence for it as you mentionned the RadGridView)?
There's also a good sample project on Telerik forum that is doing exactly what you want to do.

How do you switch between "pages" of a Silverlight application?

I am currently loading the default file, page.xaml, but in that page, I am loading the content from another xaml file. With each "page" change, I just load the content from a different xaml file, and on and on.
Example: this.Content = new StartPage();
I'm running into some syntax issues, however, because of the way I am changing my content, and was wondering if there is a definitive answer on how to accomplish this?
For example, when trying to capture user's keystrokes, I would normally do:
this.Keydown += new KeyEventHandler(this_KeyDown);
but that event handler doesn't even fire in my situation. So, I'm looking for a new approach to my content-switching approach before revisiting the keystroke problem.
Have you looked at using Silverlight 3. It has a new Page Navigation functionality.Silverlight 3 Navigation
As far as content switching goes, I've always done what you propose in the question. Normally I create a MainPage.xaml which has has the frame of the application (usually a Grid for me). One of the cells in the Grid is considered the content area of the app. When the user takes an action that I would consider to be navigation, I create a new instance of a Page, which for me is a file like MyUserControl.xaml, and then add it to the appropriate content cell in the Grid. MainPage stays around for the life of the application and assists with navigation.
If you want something fancier, and want to take advantage of browser based back/forward buttons, you could look into the SL3 navigation like Correl suggested.
A Big problem with what your're doing is that journalization doesnt take place automatically when you swap out framework elements by creating them and plugging them in the codebehind. This means that you lose the back and forward functionality of the browser. You can manually journalize stuff when you swap out pages, but this is simply a hack to get your navigation approach working.
Take a look at Prism at www.compositewpf.codeplex.com/, specifically the MVVM method of GUI design, it'll save you alot of time later on. And remember, you dont need to go hardcore when you look at MVVM, u could always cut out alot of "dynamic" functionality if you're a one man band
Also swap to silverlight 3 and use the navigation application. If you cant, take a look at helix 0.3, it'll provide a more asp oriented approach to navigation. the link provides a really really good starting point, its a three part article, i suggest you read all three and download the sample application and understand it.
A book could have been written on your question, this has to suffice for now.

Resources