Example #1
0
		public QuestionControl(QuestionBase question, Panel panel)
		{
			m_question = question;
			if (m_question.Hidden)
				return;

			// Initialize the statement panel
			panel.Children.Add(m_StatementPanel);
			m_StatementPanel.Orientation = Orientation.Horizontal;

			int nIndent = question.Indent;
			if (nIndent > 0 || m_question.Image.Length != 0)
			{
				if (m_question.Image.Length != 0)
				{
					BitmapImage bm = new BitmapImage(); 
					bm.UriSource = UriHelper.UriAppRelative(m_question.Image);

					Image image = new Image(); 
					m_StatementPanel.Children.Add(image);
					image.ApplyStyle(panel, "SurveyImage");
					image.Source = bm;
					image.Stretch = Stretch.None;
					image.VerticalAlignment = VerticalAlignment.Top;
					image.HorizontalAlignment = HorizontalAlignment.Center;
					if (Double.IsNaN(image.Width))
						image.Width = 0;
					if (nIndent < image.Width)
						nIndent = (int)image.Width;
					if (nIndent != 0 && image.Width < nIndent)
						image.Width = nIndent;
				}
				else
				{
					StackPanel spacerPanel = new StackPanel();
					m_StatementPanel.Children.Add(spacerPanel);
					spacerPanel.Width = nIndent;
				}
			}

			RichTextBlock textBlock = new RichTextBlock();
			m_StatementPanel.Children.Add(textBlock);
			textBlock.MaxWidth = 700;
			textBlock.TextWrapping = TextWrapping.Wrap;
			textBlock.ApplyStyle(panel, "SurveyStatement");
			textBlock.SetHtml(m_question.Statement);

			// Initialize the response panel
			panel.Children.Add(m_ResponsePanel);
			m_ResponsePanel.Tag = question.Name;
			m_ResponsePanel.Orientation = question.ResponseLayoutDirection;
			m_ResponsePanel.HorizontalAlignment = HorizontalAlignment.Left;
			
			if (nIndent > 0)
			{
				StackPanel spacerPanel = new StackPanel();
				m_ResponsePanel.Children.Add(spacerPanel);
				spacerPanel.Width = nIndent;
			}
		}
Example #2
0
        private void OnPrintClick(object sender, RoutedEventArgs e)
        {
            MenuItem item = FindMenuItem("print");

            if (item == null || !item.IsEnabled)
            {
                return;
            }

            RichTextBlock richTextBlock = new RichTextBlock();

            TextBox textBox = GetOwnerAs <TextBox>();

            if (textBox != null)
            {
                string    text      = textBox.SelectedText;
                Paragraph paragraph = new Paragraph();
                paragraph.Inlines.Add(new Run()
                {
                    Text = text
                });
                richTextBlock.Blocks.Add(paragraph);
            }

            RichTextBox richTextBox = GetOwnerAs <RichTextBox>();

            if (richTextBox != null)
            {
                richTextBlock.Xaml = richTextBox.Selection.Xaml;
            }

            PrintDocument document = new PrintDocument();

            document.PrintPage += delegate(object s, PrintPageEventArgs args)
            {
                args.PageVisual = richTextBlock;
            };

            // call the Print() with a proper name which will be visible in the Print Queue
            document.Print(UriHelper.UriSite().ToString());
        }