Is it an easy way to implement html like ancher in silverlight? - silverlight

I want to implment a navigate panel with buttons to control the scrollbar position of a scroll viewer. The button effect will like an ancher in html page. If click one button then the content will scroll to relative position in the scroll viewer. Is it an easy way to implement this?
--------------------------------------------
|Button0 | Button 0 relative content | |
|Button1 | ... | |
|Button2 | ... |-|
|--------- ... |||
| ||| <--the scrollbar
| ... |-|
| Button 1 relative content | |
| ... | |
| ... | |
| Button 2 relative content | |
---------------------------------------------
Thanks in advance!

It's a bit tricky because there is no build in utility function for this (as far as I know).
At the moment I can think of two feasible solutions:
First Solution: Calculate the scroll positions for your Content via UIElement.TransformToVisual Method
Something like this (not tested, not done any brainwork):
private void GotoContent3()
{
var generaltransform = m_content3.TransformToVisual( m_scrollviewer);
Point offset = generaltransform.Transform( new Point( 0, 0 ) );
m_scrollviewer.ScrollToVerticalOffset( offset.Y );
}
Second Solution (not recommended): Use a ListBox to display your Content and call ListBox.ScrollIntoView Method

Related

Floating area at report header in Crystal Reports

I want to generate a Crystal report with 2 requirements
The first page (report header) contains a sidebar on the right side which will print the company informations.
A text which can potentially span a lot of pages should start at the first page.
Here is an example of the result I want to achieve:
-------------------------------------------------
| | |
| HeaderArea | Logo |
| | |
| | Info |
| | Info |
| | Info |
| | Info |
| | Info |
| | Info |
| | Info |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | Info |
| Text Text Text Text Text Text | Info |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | Info |
-------------------------------------------------
-------------------------------------------------
| | Logo |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
-------------------------------------------------
When I place a parameter-field for the text-content in the report header section something like this will happen on the second page instead:
-------------------------------------------------
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| Text Text Text Text Text Text | |
| | Logo |
The parameter-field will resize the report header section so that the page-break is not detected correctly.
I already tryed putting the parameter in the detail-section: Now the pagebrak is ok but my text does not start left to the side-bar but "waits" until this is printed and startes below the report header.
What can I do to achieve a sidebar area in report header with Crystal?
Edit:
Here is my current report designer including the recommendation of #Siva:
And here are the current results:
See how the page header is pushed away on second page?

Boilerplate generator

I'm looking for something similar to yeoman generator for creating boilerplate. But for creating boilerplate inside a existing project. I want to automate a creation of a new view on a large project, which includes the name of the view, and it would create a directories and a javascript for the view, a template, a style for the template, and then declare stuff on some specific file.
e.g. generate MyView
would create something like this
|-app
| '--views
| '-- MyView/MyView.js
| '--templates
| '-- MyView/MyView.html
| '-- MyView/MyView.less
|
| '--styles.less <- #include templates/MyView.less
| '--loader.js <- my_view : views/MyView.js

Saving a RichTextBox to a RTF File

For a project I am working on I am trying to save the contents of a WPF RichTextBox to a RTF file as the title states. I have it working for the most part. However, the file does not preserve newlines. When I save the file ( as you will see below ) it will save everything to one line in the RTF. You can see how it is saved below.
private void butSaveHistory_Click( object sender, RoutedEventArgs e ) {
Microsoft.Win32.SaveFileDialog myDlg = new Microsoft.Win32.SaveFileDialog();
myDlg.DefaultExt = "*.rtf";
myDlg.Filter = "RTF Files|*.rtf";
Nullable<bool> myResult = myDlg.ShowDialog();
if ( myResult == true ) {
/*using ( FileStream myStream = new FileStream( myDlg.FileName, FileMode.OpenOrCreate, FileAccess.Write ) ) {
TextRange myRange = new TextRange( rtbTraffic.Document.ContentStart, rtbTraffic.Document.ContentEnd );
myRange.Save( myStream, DataFormats.Rtf );
myStream.Close();
}*/
rtbTraffic.SelectAll();
rtbTraffic.Selection.Save( new FileStream( myDlg.FileName, FileMode.OpenOrCreate, FileAccess.Write ), DataFormats.Rtf );
}
}
AS you can see I tried two different ways. ( One is commented out ) Neither of these work, they both just save everything to one line when everything in the RichTextBox is on multiple lines.
So how can I get the file to save to multiple lines? Any tips or suggestions would be greatly appreciated.
Note: When saving to a .txt file it saves correctly to multiple lines. However, I cannot save to .txt because the colors and fonts of the RichTextBox need to be preserved.
Edit: This is a sample of what the RichTextBox looks like.
After saving the file it looks like this when i open the RTF in word.
This is what I want it to output.
Edit 2: Adding RTF code
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}{\f3\fcharset0 Arial;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red0\green0\blue255;\red255\green0\blue0;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\b\cf0 \cf0\ql{\f3 {\b0\cf2\highlight1\ltrch 09:10:48 | Thing | STATUS Tube_Heat_Consumer,TUBE_HEAT,3.14209:11:47 | Thing | STATUS Tube_Heat_Consumer,TUBE_HEAT,2.718}{\b0\cf3\highlight1\ltrch 09:58:49 | Thing | STOP STOP}{\b0\cf2\highlight1\ltrch 09:58:49 | Thing | STOP STOP}{\b0\highlight1\ltrch 09:58:57 | Thing | DeRegistration Successful}{\b0\cf4\highlight1\ltrch 09:58:58 | Thing | DeRegistration Failed ( Application is not currently registered ) | 81270401}{\b0\highlight1\ltrch 09:58:58 | Thing | Registration Successful}\li0\ri0\sa0\sb0\fi0\ql\par}
}
} Thing | DeRegistration Failed ( Application is not currently registered ) | 81270401}{\b0\highlight1\ltrch 08:55:21 | Thing | Registration Successful08:55:22 | Thing | DeRegistration Successful08:55:22 | Thing | Registration Successful}{\b0\cf2\highlight1\ltrch 08:55:22 | Thing | Registration Failed ( Application Thing already registered ) | 8127040008:55:22 | Thing | Registration Failed ( Application Thing already registered ) | 81270400}{\b0\highlight1\ltrch 08:55:23 | Thing | DeRegistration Successful08:55:23 | Thing | Registration Successful08:55:24 | Thing | DeRegistration Successful08:55:24 | Thing | Registration Successful08:55:25 | Thing | DeRegistration Successful}\li0\ri0\sa0\sb0\fi0\ql\par}
}
}
From the looks of it it is not encoding \par or \lines correctly.
It will be more simple to answer if you put some example of rtf code you try to save, the result you have and what you want.
I'm not sure of what you want to be in multiple line. The rtf in a more easiest "reading" format for human? Where one line in richtextbox is on one line in rtf format like this:
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1036\fs18\f2\cf0 \cf0\ql
{\f2 {\ltrch aaaaa}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch bbbb}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch }\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch cccc}\li0\ri0\sa0\sb0\fi0\ql\par}
}
}
in richtextbox I see this
aaaa
bbbb
cccc
I'm not sure of the interest to do that, because newline is encode by \par for end of paragraphs and \line for new line in the current paragraph then when you open the rtf file with a program (MS Word for example) newlines are respected.
And I obtain the same with this:
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1036\fs18\f2\cf0 \cf0\ql {\f2 {\ltrch aaaaa}\li0\ri0\sa0\sb0\fi0\ql\par}{\f2 {\ltrch bbbb}\li0\ri0\sa0\sb0\fi0\ql\par}{\f2 {\ltrch }\li0\ri0\sa0\sb0\fi0\ql\par}{\f2 {\ltrch cccc}\li0\ri0\sa0\sb0\fi0\ql\par}}}
Don't add the rtf code directly, use Wpf Paragraph and so on.
When you add your new line to RichTextBox use
YourParagraph.Inlines.Add(new LineBreak());
instead of \r\n or something like this.
As you can see in this post, if you add text as plaintext programaticaly to the RichTextBox control, you may have to add this unicode line separator \u2028. And it will normaly converted to \line in the Rtf saved file.
And I recommend you to use the method with TextRange.

Copying ng-grid data as TSV

I'd like to copy the text in ng-grid as Tab Separated Values [TSV] but right now
it has 1 item per row. For example:
| A | B | C |
| D | E | F |
becomes
A
B
C
D
E
F
rather than
A B C
D E F
Best if this worked for Ctrl-C as well as Right-Click | Copy.
Any Angular or jQuery plugins which do this or code recommendations/samples?
Currently planning to override oncontextmenu for right-clicks, but will not be able to access $scope unless there is a way to handle right clicks using ng-click.

How to display the replies count of the each user comments with show/hide option in node view page in Drupal 7?

Now, I am having comments section like this in node view page.
Comment 1
comment 11
comment 12
Comment 2
Comment 3
comment 31
comment 32
comment 33
But, I would to show this with show/hide option for replied comments with replies count. like below
Comment 1
show/hide 2 replies
------------------
| comment 11 |
| comment 12 |
------------------
Comment 2
Comment 3
show/hide 3 replies
---------------
| comment 31 |
| comment 32 |
| comment 33 |
---------------
You can access the count of comments in your Template with
<?php print $comment_count; ?>
And for Show and Hide, whats about the simple .hide() and .show() jQuery Functions?

Resources