I'm currently developing an IDE and Im working on Code-Folding codes now .
I'm thinking to use a TreeView as for it has a collapse and expand property but i dunno/not sure how can I implement it on RichTextBox .
Even an Initial Code showing if interaction within RichTextBox and TreeView will be much appreciated .
like:
{
}
then RichTextBox will have a line indicating till where to collapse .
Thanks a lot in advance!
It doesn't seem feasible to include a TreeView inside a RichTextBox. From my experience, building something atop the RTB is quite problematic and doesn't render the desired result without having quite a lot of quirks.
I suggest taking a look at the Fast-Colored-TextBox:
http://www.codeproject.com/Articles/161871/Fast-Colored-TextBox-for-syntax-highlighting
Or possibly building a similar control from scratch (if you too suffer from NIH) instead of attempting to extend the RTB.
If you really need your own code editor you should really think about taking Avalon Edit. It is able to rebuilt an Visual Studio Editor. So it has all you feature you need (and more).
I know it is a WPF component and not winforms. But it is quite easy to host a WPF control within winforms. So better take this route, cause trying to interweave a tree view with a rich text box will never match exactly what you like (just think about finding out the pixel size of a textline if you are using different fonts or how to determine line wrapping).
Related
I'm creating a simple WYSIWYG editor for HTML in C#, and I want to implement a simple group of controls to view and manipulate the various properties of HTML form elements. I envision the properties panel to look like the one in Visual Studio:
Such that when the user clicks on an HTML element they've added they can change the text, class, id, etc. of the element. The problem is, I can't find how to make a panel that looks like this using C#. Obviously I know how to implement the dropdown list and the buttons, but the main body that actually contains the properties is like a slick version of a tree-view that I don't even know where to begin coding.
I'm not looking for someone to code this whole thing for me, but it would be great if somebody could point me to a form control that looks like the tree-view. I have tried googling around for answers but haven't had any luck. I have also tried looking at the open source project Sharp Develop which uses a similar control, but I've had considerable trouble wading through the hundreds of files of code to find the specific part of the GUI I'm focused on.
Any help on this would be greatly appreciated. Sorry if I was a tad bit vauge above, I guess what I'm really looking for is a nice form control or set of controls in C# to mimick the main body of the properties window. I've tried to be as thorough as possible, but if you have any questions leave a comment and I'll try to improve my question.
The body of that panel contains a PropertyGrid control, which you can use yourself. It's not in the Toolbox by default but you can add it.
This is a broad question, I am aware. However, I have been trying to make a modification in a C# source code to enable a ToolboxControl UI control's right hand border to respond to a mouse drag. In other words make the control size bigger by grabbing the right hand boarder and dragging it to the right. I Have not been successful. So I am thinking if I incorporate a XAML file and create the ToolboxControl in XAML, maybe I would have more control in manipulating the ToolBoxControl.
I dont know how to break up a pure C# WPF code into C# and XAML.
In a nutshell, The problem I am dealing currently is that there is already C# code developed by other developers to perform certain function. I am using the existing C# code but I believe if I move some of the UI functionality from the C# into a XAML file, I would have a better handle on adding some of the needed UI features to the original program.
So you see my problem is I am not starting from scratch. I need to use an existing C# code and break away some UI functionality of it nd put it in a new xaml file. Do you have any ideas about any place that that has been done?
I am looking for any repsonse that leads me to a conversation thread or a sample. In other words I dont know where to start from. any useful guidance is apprecaited and would be marked as an answer.
Check out this article.
At its simplest, you will need to add an invisible (or not) drag handle to the right hand border of your control, then adjust the control size during the drag events raised by that drag handle.
Here is another article showing a similar concept expanded to an entire diagramming system, which includes the resize behavior you mentioned.
You may be able to define a style for what you are trying to accomplish. I wouldn't worry too much about breaking apart the C# from the XAML as that is a nice to have but not nec
I have an idea for a personal project. And I know one way of accomplishing it in Windows Forms (which I no longer wish to use). Basically I could (in WinForms) just draw everything onto the screen (Form) and then when I need to switch views/states of the application, just redraw the new stuff in the old stuff's place.
But how can we have different states in WPF? Is there a "right" or "proper" way of doing this? Is something like this covered somewhere in the docs?
I'd like to do my own searching, but I have no idea what exactly to look for, and current attempts at finding the right information, so far have yielded no helpful (or even relevant) results.
Any help at all will be greatly appreciated. I am new to WPF, but have been making a lot of progress this past week!
Thank you!
P.S.:
I just thouhght of something. If the solution was to draw what is needed for one screen, and when it is time to display the next screen, just dispose of/hide everything and create/display the new stuff, then how would we get around this? Because we can't/shouldn't change XAML markup at runtime, can/should we? :/
Not sure how you drawn your views/states in WinForms (direct painting on a Graphics object?).
The closest to what you're describing is the VisualStateManager. You can use it to statically define several visual states inside a single XAML and transit between them (using a smooth animation if you want).
If what you've done was show different Forms with Show/ShowDialog(), then the equivalent would be to use different Windows and Show/Hide them.
If you just cleared/added Controls to your form, then you can do just the same in WPF. Most Controls in WPF have a Content or Children property instead of Control.Controls in Forms.
I don't know if I understand what you really want. But here are my thoughts:
You can use several Windows and Show/Hide them accordingly
You can use the Frame/Page functionality in WP (MSDN)
if you really need to you could load your XAML and remove the topmost content in your Window and replace it with the loaded content
You could use the VisualStateGroup functionality to change the appearance of your current window
I think you will be happy with the second solution
I am writing a small editor, based on a WPF (c#) TextBox. For some functionality the method getRectFromCharacterIndex(), which is only implemented in the TextBox-class is necessary. Furthermore I've got to do some syntax-highlighting in my program. Normally this is easy to handle in a TextBlock or a RichTextBox. Unfortunately these two Controls don't include Methods like the one mentioned above. Has anyone an idea, how to format and/or color single Characters in a normal TextBox with a small workaround?
Thank you very much for your answers!
I did the same effort in the past and I decided to move to this: http://wiki.sharpdevelop.net/AvalonEdit.ashx almost all the work you need is done here.
I hope I am able to illustrate the problem using a lot of images. First of all, I was no real fan of XAML (Silverlight issues, crashes in Preview, and so on...)
Now, with VS2010 the situation has become better. There are still a lot of things I like better in code, but I also want a preview in my VS.
So, take a look at the following control: It is really simple, a todo details list. The first screenshot shows the code of the control, pretty straighforward:
CodebasedControl http://img28.imageshack.us/img28/2263/invoicea49.png
There is no XAML, so obviously no preview. Of course, I could encapsulate it in another control, like shown in the next screenshot:
CodebasedControl http://img11.imageshack.us/img11/9515/invoicea48.png
But, in that case I have an additional file I do not want or need.
So I had the idea to move the init stuff inside the contructor of a XAML control. For simplicity, I used simple elements. But they do not show up in the preview...
CodebasedControl http://img99.imageshack.us/img99/5547/invoicea47.png
CodebasedControl http://img512.imageshack.us/img512/9625/invoicea46.png
Finally, I know I could use the controls in other parts of my app when creating UIs. But I am using layout manager, PRISM and a lot of other stuff, so I just want an easy preview of some specific control I created (without having to have a XAML wrapper file for each control)
Thanks for help, and sorry for the post structure, but I though with images it is better to understand...
Chris
Ok,
I found a way. Basically I am tricking VS by changing the XAML, but keeping the code-behind linked to the file. It the same like the wrapper solution, but without having a dedicated extra class or file. I am using the "xaml-infront" file for preview.
This solution only works with pure code controls, I have to do more research for mixed controls (at least I think so.. but it is enough for me for now).
Please be aware, the code behind is NOT partial anymore. It could be placed anywhere else, what I am doing here is basically only related to file-names and visual studio "readability"..
See screenshots for explanation:
alt text http://img15.imageshack.us/img15/5456/invoicea50.png
Some space for easier reading
alt text http://img186.imageshack.us/img186/1545/invoicea51.png