Detecting outlining sections within EnvDTE.Document - c#

I've written an extension to comb through code files line by line to detect certain patterns. The problem I'm seeing is that lines within collapsed sections are skipped when using TextSelection.LineDown() or similar.
I'm aware that TextSelection.OutlineSection() exists to create such sections, but is there a way to detect, and possibly expand or collapse them?

In your scenario you don't have to use TextSelection, since that is related to...text selection. To traverse the lines of a code file, given an EnvDTE.TextDocument, you have the TextDocument.StartPoint property to get a EnvDTE.TextPoint and then you create an EnvDTE.EditPoint with TextPoint.CreateEditPoint(). With an EnvDTE.EditPoint you can GetText(...), MoveToXXX(...) etc. EditPoints are not affected by collapsed text.

Related

MigraDoc page break on sub-sections

I am using MigraDoc which might generate a document like the following example:
However I want to be able to 'bind' a given number of paragraphs/tables (or anything else) together so that if a page break is detected anywhere during any of the items, the whole block is moved onto the next page - for example (where highlighted text is all 'bound' together somehow):
Hope the question makes sense...?! I’m not sure where to start with this but have a definitive requirement for it!
Paragraphs have a KeepTogether property that prevents pagebreaks within the paragraph.
Paragraphs have a KeepWithNext property that prevents pagebreaks between this paragraph and the next one. A typical use case are head lines that make no sense at the bottom of the page.
For tables, see here:
https://stackoverflow.com/a/1327228/162529

hbox/vbox and number of cells/items in monodeleop

I've been experimenting with a development platform and have been comparing glade using GTK3 to monodevelop using GTK2 with the integrated builder.
However, I can't find how to increase or decrease the number of cells in a HBOX / VBOX other than inserting after or before the current cell. The default option is 3 and for a couple of boxes, I only want two, yet I can't find a way to remove just one cell. Everything I'm trying is removing all the cells of that box.
The "General" properties of "Box Attribuites" in glade includes "number of items":
All the property options under monodevelop (there's nothing similar):
Although I have provided an answer below, if someone can point out an easier way to use the GUI to modify the number of cells, I'll gladly accept your answer
I tried to delete it from the GUI initially however my selection must have been off.
If you try to delete a panel/cell from the properties area, you lose the whole panel. Don't do it there:
If you make sure JUST the undesired cell is highlighted as in this example, then right click and select delete, that cell only will be removed:

Replacing Microsoft Word Content Control Dynamically At Runtime

I want to be able to bind content control fields to each others' values. Basically if you change a field at the top, all others in the document also update to that. I'm replacing hundreds of individual variables, each with 100 duplicates. There is a better way than the 'Find and Replace Tool'.
Here is a sample document directly from Microsoft's site that shows exactly what I would like to be able to do:
https://omextemplates.content.office.net/support/templates/en-us/tf03444179.dotx
When the '' value is changed, all others in the document update.
I've already looked at plenty of solutions like: c# word interop find and replace everything
But they do not dynamically respond during run-time. In other words you have to go in and change which string you want to replace for each value.
Been looking for a while now, thanks in advance if anyone else can figure this out.

how to automatically extract strings from project and add them to resx file in wpf

I have a very large wpf project and after two years of development i requested to make it bilingual, is there any way to automatically extract strings in labels and grid headers in xaml files so i can translate them instead of manually extract them?
I don't know if there is any existing tool to help, but you can implement it yourself, I faced such a problem when I was converting a large solution of above 100 C++ projects from ansi to unicode strings, I implemented a simple tool with one window containing 2 rich edit boxes, one for the original text with replaces colored, and other for the replacement, for manipulating the resex files have a look at Working with .resx Files Programmatically, Don't forget that regular expression is your friend to accomplish this tool.
You can automate this process by finding all Label controls in WPG root Grid element (e.g. mainGrid) and extracting their content using the following C# code snippet:
IEnumerable<Label> _collection = mainGrid.Children.OfType<Label>();
foreach(Label _control in _collection)
{
string _text = _control.Content.ToString();
// add you code here
}
The results can be placed in Resource file (for example, CSV) with your translation added. Other solution (more sophisticated) pertains to the creation of multilingual XML file, or the local multilingual database with all label contents added to the first field, translation added to the next fields, etc.
Hope this may help.

Integrating Visio exported XAML into Silverlight application

It is possible to export Microsoft Visio drawings as a Website containing Silverlight content. This is described on this blog-post.
The output of such an export are the following:
xaml_1.xaml (contains the structure of the control)
data.xml (contains all text content such as labels, etc)
several java-script files
*.htm pages with a Silverlight container
other files such as *.css and images
I would like to integrate the exported XAML code into another existing Silverlight application. I found this blog-post telling me how to load XAML code dynamically during runtime.
What I would like to know is how to "merge" the XAML-file and the data.xml and how I can get a reference to the items of the XAML code, in order to change certain texts...
In the associated xaml js file (eg xaml_1.js) there's a handleMouseUp function that reads the shape ID from the (XAML) 'name' string and then calls OnShapeClick in frameset.js. This method, which is common to all of the js-based Save as web output types, then calls other methods to populate the details table or retrieve hyperlinks found in data.xml. If you have a look at the FindShapeXML function in frameset.js you'll see that it gets the appropriate data based on the page and shape IDs (note that shape IDs are unique to a page as per Visio itself).
In terms of creating data-bound or dynamic shape text, one workaround for the glyphs issue that #slfan highlights is prevent the text from being output. For example, prior to running Save As Web in Visio, you could loop through all of the shapes and set their HideText ShapeSheet cell to true. This will prevent all of the glyphs xaml being generated and you'll still have access to the text string in data.xml. I guess you wouldn't then benefit from the correct font scaling, but it depends on your scenario. If it was really important to get the scale right then you could parse the RenderTransform attribute (which is described in attribute syntax rather than property element syntax) of the glyph elements.
Glyphs are there (I'm guessing) because it mirrors how Visio works in the application ie in Visio you can select individual characters within a shape's text and apply different fonts and formatting, but if you don't need that, I'd be tempted to ditch the glyphs collection and just use a TextBlock as #slfan suggests.
I think you have to tweak the generated XAML a little bit. Unfortunately Visio generates glyphs for every single character. If you want to change the text at runtime, you will have to remove this glyphs and add the required controls (e.g. TextBlock) yourself.
You can load the XAML into Silverlight with XamlReader.Load. A good description you find here: http://blogs.silverlight.net/blogs/msnow/archive/2008/10/09/silverlight-tip-of-the-day-60-how-to-load-a-control-straight-from-xaml.aspx.
All JavaScript and HTML files you can ignore, the XML-file you need to identify your controls. The ID's in the XML refer to the corresponding elements in the XAML-file.

Categories

Resources