Exemplo n.º 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;
			}
		}
Exemplo n.º 2
0
		public QuestionDate(QuestionBase question, Panel panel)
			: base(question, panel)
		{
			if (question.Hidden)
				return;

			StackPanel responsePanel = base.ResponsePanel;

			responsePanel.Children.Add(m_DatePicker);
			m_DatePicker.ApplyStyle(panel, "SurveyDatePicker");
			m_DatePicker.Tag = question.Name;
			m_DatePicker.Width = question.Cols * 8 + 12;
			m_DatePicker.Height = question.Rows * 12 + 12;
			m_DatePicker.Text = question.ResponseDefault;
			m_DatePicker.HorizontalAlignment = HorizontalAlignment.Left;
		}
Exemplo n.º 3
0
		public QuestionPassword(QuestionBase question, Panel panel)
			: base(question, panel)
		{
			if (question.Hidden)
				return;

			StackPanel responsePanel = base.ResponsePanel;

			responsePanel.Children.Add(m_PasswordBox);
			m_PasswordBox.ApplyStyle(panel, "SurveyPasswordBox");
			m_PasswordBox.Tag = question.Name;
			m_PasswordBox.Width = question.Cols * 8 + 12;
			m_PasswordBox.Height = question.Rows * 12 + 12;
			m_PasswordBox.Password = question.ResponseDefault;
			m_PasswordBox.MaxLength = question.MaxChars;
			m_PasswordBox.HorizontalAlignment = HorizontalAlignment.Left;
		}
Exemplo n.º 4
0
		public QuestionChooseOne(QuestionBase question, Panel panel)
			: base(question, panel)
		{
			if (question.Hidden)
				return;

			StackPanel responsePanel = base.ResponsePanel;

			ComboBox comboBox = null;
			if (question.List)
			{
				comboBox = new ComboBox();
				responsePanel.Children.Add(comboBox);
				comboBox.ApplyStyle(panel, "SurveyComboBox");
			}

			foreach (string text in question.ResponseList)
			{
				if (question.List)
				{
					ComboBoxItem item = new ComboBoxItem();
					comboBox.Items.Add(item);
					item.ApplyStyle(panel, "SurveyComboBoxItem");
					item.Content = text;
					if (text.EqualsIgnoreCase(question.ResponseDefault))
						item.IsSelected = true;
				}
				else
				{
					RadioButton button = new RadioButton();
					responsePanel.Children.Add(button);
					button.ApplyStyle(panel, "SurveyRadioButton");
					button.Content = text;
					if (text.EqualsIgnoreCase(question.ResponseDefault))
						button.IsChecked = true;
				}
			}
		}
Exemplo n.º 5
0
		public QuestionChooseAny(QuestionBase question, Panel panel)
			: base(question, panel)
		{
			if (question.Hidden)
				return;

			StackPanel responsePanel = base.ResponsePanel;

			ListBox listBox = null;
			if (question.List)
			{
				listBox = new ListBox();
				responsePanel.Children.Add(listBox);
				listBox.ApplyStyle(panel, "SurveyListBox");
			}

			foreach (string text in question.ResponseList)
			{
				if (question.List)
				{
					ListBoxItem item = new ListBoxItem();
					listBox.Items.Add(item);
					item.ApplyStyle(panel, "SurveyListBoxItem");
					item.Content = text;
					if (text.EqualsIgnoreCase(question.ResponseDefault))
						item.IsSelected = true;
				}
				else
				{
					CheckBox checkBox = new CheckBox();
					responsePanel.Children.Add(checkBox);
					checkBox.ApplyStyle(panel, "SurveyCheckBox");
					checkBox.Content = text;
					if (text.EqualsIgnoreCase(question.ResponseDefault))
						checkBox.IsChecked = true;
				}
			}
		}
Exemplo n.º 6
0
		private static void CreateControl(QuestionBase question, StackPanel panel)
		{
			if (question.Hidden)
				return;

			QuestionControl control;
			switch (question.Type)
			{
				case "text":
					control = new QuestionText(question, panel);
					break;
				case "password":
					control = new QuestionPassword(question, panel);
					break;
				case "date":
					control = new QuestionDate(question, panel);
					break;
				case "yesno":
					control = new QuestionYesNo(question, panel);
					break;
				case "state":
					control = new QuestionState(question, panel);
					break;
				case "chooseone":
					control = new QuestionChooseOne(question, panel);
					break;
				case "chooseany":
					control = new QuestionChooseAny(question, panel);
					break;
				case "noresponse":
					control = new QuestionControl(question, panel);
					break;
				default:
					control = new QuestionControl(question, panel);
					break;
			}
		}
Exemplo n.º 7
0
		public QuestionText(QuestionBase question, Panel panel)
			: base(question, panel)
		{
			if (question.Hidden)
				return;

			StackPanel responsePanel = base.ResponsePanel;

			bool bMultiLine = (question.Rows > 1);

			m_textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
			responsePanel.Children.Add(m_textBox);
			m_textBox.ApplyStyle(panel, "SurveyTextBox");
			m_textBox.Tag = question.Name;
			m_textBox.Text = " "; // To force the control to have assigned height
//j			if (question.Required)
//j				m_textBox.Watermark = "<Required>";
			m_textBox.AcceptsReturn = bMultiLine;
			m_textBox.TextWrapping = (bMultiLine ? TextWrapping.Wrap : TextWrapping.NoWrap);
			m_textBox.Width = question.Cols * 8 + 12;
			m_textBox.Height = question.Rows * 12 + 12;
			m_textBox.Text = question.ResponseDefault;
			m_textBox.MaxLength = question.MaxChars;
			m_textBox.HorizontalAlignment = HorizontalAlignment.Left;
#if NOTUSED
			if (base.Question.Required)
			{
				RequiredFieldValidator child = new RequiredFieldValidator();
				child.ControlToValidate = m_textBox.Tag;
				child.EnableClientScript = false;
				child.Text = base.Question.RequiredText;
				responsePanel.Children.Add(child);
				responsePanel.Children.Add(new LiteralControl("<br>"));
			}
#endif
		}
Exemplo n.º 8
0
		private bool LoadResponse(QuestionBase question)
		{
			const string nodeName = "Response";
			if (!MatchingElementStart(nodeName))
				return false;

			// Process any attributes

			// Process any children
			if (m_xmlReader.IsEmptyElement)
				return true;

			question.ResponseList.Add(ReadInnerXml());
			return true;
		}
Exemplo n.º 9
0
		private bool LoadResponses(QuestionBase question)
		{
			const string nodeName = "Responses";
			if (!MatchingElementStart(nodeName))
				return false;

			// Process any attributes

			// Process any children
			if (m_xmlReader.IsEmptyElement)
				return true;

			while (ReadNode())
			{
				if (MatchingElementEnd(nodeName))
					break;

				if (LoadResponse(question))
					continue;
			}

			return true;
		}
Exemplo n.º 10
0
		private bool LoadStatement(QuestionBase question)
		{
			const string nodeName = "Statement";
			if (!MatchingElementStart(nodeName))
				return false;

			// Process any attributes

			// Process any children
			if (m_xmlReader.IsEmptyElement)
				return true;

			question.Statement = ReadInnerXml();
			return true;
		}
Exemplo n.º 11
0
		private bool LoadQuestion(GroupBase group)
		{
			const string nodeName = "Question";
			if (!MatchingElementStart(nodeName))
				return false;

			// Process any attributes
			QuestionBase question = new QuestionBase(m_xmlReader);
			group.QuestionList.Add(question);

			// Process any children
			if (m_xmlReader.IsEmptyElement)
				return true;

			while (ReadNode())
			{
				if (MatchingElementEnd(nodeName))
					break;

				if (LoadStatement(question))
					continue;

				if (LoadResponses(question))
					continue;
			}

			return true;
		}
Exemplo n.º 12
0
		public QuestionState(QuestionBase question, Panel panel)
			: base(question.SetResponses(m_Responses), panel)
		{
		}