/// <summary> /// Изменить статус интерьвью /// </summary> public override void dbUpdateState(int id, InterviewState state) { using (var conn = new SqlConnection(SqlConnStrings.crmConnString)) { var cmd = new SqlCommand(SqlCommands.UpdateInterviewState, conn); cmd.Parameters.AddWithValue("@id", ID); cmd.Parameters.AddWithValue("@state", state); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } }
public void Update(GameEngine gameEngine, GameTime gameTime) { if (IsTransitioning) { return; } MouseState = Mouse.GetState(); if (PrevMouseState.LeftButton == ButtonState.Pressed && MouseState.LeftButton == ButtonState.Released) { MouseClicked(gameTime, MouseState.X, MouseState.Y); } switch (GState) { case InterviewState.Contradiction: gameEngine.Push(new NotebookManager(true, ref IdContradict), true, true); IsTransitioning = true; break; case InterviewState.Exiting: gameEngine.Pop(true, true); IsTransitioning = true; break; case InterviewState.TopicChoice: foreach (Button TopicButton in TopicButtons) { TopicButton.Update(); } break; case InterviewState.PlayText: ContradictButton?.Update(); EventScript.Update(gameTime); if (EventScript.IsFinished()) { GState = (!IsContradicted) ? InterviewState.TopicChoice : InterviewState.Exiting; EventScript = null; MainCharacter.TestimonyIds.Add(TestimonyId); } break; default: break; } PrevMouseState = MouseState; }
private void MouseClicked(GameTime gameTime, int x, int y) { Rectangle mouseClickRect = new Rectangle(x, y, 10, 10); switch (GState) { case InterviewState.TopicChoice: foreach (Button Button in TopicButtons) { if (mouseClickRect.Intersects(Button.Rect) && Button.Text == "Bye!") { GState = InterviewState.Exiting; } else if (mouseClickRect.Intersects(Button.Rect)) { GState = InterviewState.PlayText; SelectedTopic = TestimonyList.Topics[Button.Text]; List <Testimony> Testimony = (from testimony in TestimonyList.Testimonies where testimony.TopicTag == SelectedTopic && testimony.CharacterKey == CharacterKey && (testimony.IsInitial || MainCharacter.TestimonyIds.Contains(testimony.Id)) select testimony).ToList(); string Text = "%ost/gumshoe\nCan I talk to you about something? @lphoenix #talking\nI don't have any information. @redgeworth #disgusted\nOk no problem. @lphoenix #talking\n+n: 100"; TestimonyId = -1; if (Testimony.Count > 0 && !Testimony[0].SpokenText.Equals(string.Empty)) { Text = Testimony[0].SpokenText; TestimonyId = Testimony[0].Id; } EventScript = new EventScript(MainCharacter, Content, Text); } } break; case InterviewState.PlayText: if (mouseClickRect.Intersects(ContradictButton.Rect)) { GState = InterviewState.Contradiction; } break; default: break; } }
private void HandleResponse() { /*===========================*/ /* Get the current UI state. */ /*===========================*/ String evalStr = "(find-fact ((?f UI-state)) TRUE)"; FactAddressValue fv = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0]; /*========================================*/ /* Determine the Next/Prev button states. */ /*========================================*/ if (fv["state"].ToString().Equals("conclusion")) { interviewState = InterviewState.CONCLUSION; //nextButton.Tag = "Restart"; //nextButton.Text = "Restart"; nextButton.Visible = false; prevButton.Visible = true; choicesPanel.Visible = false; } else if (fv["state"].ToString().Equals("greeting")) { interviewState = InterviewState.GREETING; nextButton.Visible = false; //nextButton.Tag = "Next"; //nextButton.Text = "Next >"; prevButton.Visible = false; choicesPanel.Visible = false; } else { interviewState = InterviewState.INTERVIEW; nextButton.Visible = true; nextButton.Tag = "Next"; nextButton.Text = "Next >"; prevButton.Visible = false; choicesPanel.Visible = true; if (priorAnswers.Count < 1) { prevButton.Visible = false; } } /*=====================*/ /* Set up the choices. */ /*=====================*/ choicesPanel.Controls.Clear(); MultifieldValue damf = (MultifieldValue)fv["display-answers"]; MultifieldValue vamf = (MultifieldValue)fv["valid-answers"]; String selected = fv["response"].ToString(); RadioButton firstButton = null; for (int i = 0; i < damf.Count; i++) { LexemeValue da = (LexemeValue)damf[i]; LexemeValue va = (LexemeValue)vamf[i]; RadioButton rButton; String buttonName, buttonText, buttonAnswer; buttonName = da.Value; buttonText = buttonName.Substring(0, 1).ToUpperInvariant() + buttonName.Substring(1); buttonAnswer = va.Value; rButton = new RadioButton(); rButton.Text = buttonText; if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) || ((lastAnswer == null) && buttonAnswer.Equals(selected))) { rButton.Checked = true; } else { rButton.Checked = false; } rButton.Tag = buttonAnswer; rButton.Visible = true; rButton.AutoSize = true; choicesPanel.Controls.Add(rButton); if (firstButton == null) { firstButton = rButton; } } if ((GetCheckedChoiceButton() == null) && (firstButton != null)) { firstButton.Checked = true; } /*====================================*/ /* Set the label to the display text. */ /*====================================*/ relationAsserted = ((LexemeValue)fv["relation-asserted"]).Value; /*====================================*/ /* Set the label to the display text. */ /*====================================*/ String messageString = ((StringValue)fv["display"]).Value; messageLabel.Text = messageString; }
/// <summary> /// Изменить статус интерьвью /// </summary> public abstract void dbUpdateState(int id, InterviewState state);
public void Reset(GameEngine gameEngine, MainCharacter mainCharacter, ContentManager content) { if (IsTransitioning) { if (TestimonyId > -1 && TestimonyId == IdContradict[0]) { Testimony NextTestimony = (from testimony in TestimonyList.Testimonies where testimony.PrevId == TestimonyId select testimony).ToList()[0]; string Text = NextTestimony.SpokenText; EventScript = new EventScript(MainCharacter, Content, Text); TestimonyId = NextTestimony.Id; IsContradicted = true; } else if (IdContradict[0] > -1) { Console.WriteLine("hello"); string Text = "%ost/gumshoe\nExcuse me, what are you suggesting?? @redgeworth #disgusted\n+n: 100"; EventScript = new EventScript(MainCharacter, Content, Text); IdContradict[0] = -1; } GState = InterviewState.PlayText; Background = new Background(Content, "castle"); IsTransitioning = false; return; } else { GState = InterviewState.TopicChoice; } content.Unload(); // Common to all Modes Background = new Background(content, "castle"); MainCharacter = mainCharacter; Content = content; IsTransitioning = false; Arial = Content.Load <SpriteFont>("Fonts/Arial"); // Load Testimonies String path = Path.Combine(Content.RootDirectory, "testimonies.txt"); String TestimonyJSON = File.ReadAllText(path); TestimonyList = JsonSerializer.Deserialize <TestimonyList>(TestimonyJSON); ContradictButton = new ClickableTexture(Content.Load <Texture2D>("notebook_icon"), new Vector2(Game1.GetWindowSize().X - 100, 20)); TopicButtons = new List <Button>(); Vector2 TopicPos = new Vector2(500, 450); HashSet <string> TopicTags = (from testimony in TestimonyList.Testimonies where testimony.IsInitial || (MainCharacter.TestimonyIds.Contains(testimony.Id) && testimony.CharacterKey == CharacterKey) select testimony.TopicTag).ToHashSet(); Dictionary <string, string> Topics = (from topic in TestimonyList.Topics where TopicTags.Contains(topic.Value) select topic).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); foreach (string Topic in Topics.Keys) { TopicButtons.Add(new Button(Topic, Arial, TopicPos)); TopicPos.Y += 75; } TopicButtons.Add(new Button("Bye!", Arial, TopicPos)); }
private void HandleResponse() { /*===========================*/ /* Get the current UI state. */ /*===========================*/ String evalStr = "(find-fact ((?f UI-state)) TRUE)"; FactAddressValue fv = (FactAddressValue) ((MultifieldValue) clips.Eval(evalStr))[0]; /*========================================*/ /* Determine the Next/Prev button states. */ /*========================================*/ if (fv.GetFactSlot("state").ToString().Equals("conclusion")) { interviewState = InterviewState.CONCLUSION; nextButton.Tag = "Restart"; nextButton.Text = "Restart"; prevButton.Visible = true; choicesPanel.Visible = false; } else if (fv.GetFactSlot("state").ToString().Equals("greeting")) { interviewState = InterviewState.GREETING; nextButton.Tag = "Next"; nextButton.Text = "Next >"; prevButton.Visible = false; choicesPanel.Visible = false; } else { interviewState = InterviewState.INTERVIEW; nextButton.Tag = "Next"; nextButton.Text = "Next >"; prevButton.Visible = true; choicesPanel.Visible = true; } /*=====================*/ /* Set up the choices. */ /*=====================*/ choicesPanel.Controls.Clear(); MultifieldValue damf = (MultifieldValue) fv.GetFactSlot("display-answers"); MultifieldValue vamf = (MultifieldValue) fv.GetFactSlot("valid-answers"); String selected = fv.GetFactSlot("response").ToString(); RadioButton firstButton = null; for (int i = 0; i < damf.Count; i++) { LexemeValue da = (LexemeValue) damf[i]; LexemeValue va = (LexemeValue) vamf[i]; RadioButton rButton; String buttonName, buttonText, buttonAnswer; buttonName = da.GetLexemeValue(); buttonText = buttonName.Substring(0,1).ToUpperInvariant() + buttonName.Substring(1); buttonAnswer = va.GetLexemeValue(); rButton = new RadioButton(); rButton.Text = buttonText; if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) || ((lastAnswer == null) && buttonAnswer.Equals(selected))) { rButton.Checked = true; } else { rButton.Checked = false; } rButton.Tag = buttonAnswer; rButton.Visible = true; rButton.AutoSize = true; choicesPanel.Controls.Add(rButton); if (firstButton == null) { firstButton = rButton; } } if ((GetCheckedChoiceButton() == null) && (firstButton != null)) { firstButton.Checked = true; } /*====================================*/ /* Set the label to the display text. */ /*====================================*/ relationAsserted = ((LexemeValue) fv.GetFactSlot("relation-asserted")).GetLexemeValue(); /*====================================*/ /* Set the label to the display text. */ /*====================================*/ String messageString = ((StringValue) fv.GetFactSlot("display")).GetStringValue(); int preferredWidth = ComputeLabelWidth(messageString); messageLabel.Text = messageString; messageLabel.Size = new Size(preferredWidth,messageLabel.Height); }
internal void UpdateState(int id, InterviewState stateid) { domainCaster.GetAInterview(this).dbUpdateState(id, stateid); }
private void HandleResponse() { /*===========================*/ /* Get the current UI state. */ /*===========================*/ string evalStr = "(find-fact ((?f UI-state)) TRUE)"; FactAddressValue fv = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0]; /*========================================*/ /* Determine the Next/Prev button states. */ /*========================================*/ if (fv["state"].ToString().Equals("conclusion")) { interviewState = InterviewState.CONCLUSION; nextButton.Tag = "Restart"; nextButton.Content = "Restart"; prevButton.Visibility = Visibility.Hidden; scrollViewer.Visibility = Visibility.Visible; choicesPanel.Visibility = Visibility.Hidden; leftPanel.Visibility = Visibility.Hidden; rightPanel.Visibility = Visibility.Hidden; } else if (fv["state"].ToString().Equals("greeting")) { interviewState = InterviewState.GREETING; nextButton.Tag = "Next"; nextButton.Content = "Next >"; prevButton.Visibility = Visibility.Hidden; scrollViewer.Visibility = Visibility.Hidden; choicesPanel.Visibility = Visibility.Hidden; leftPanel.Visibility = Visibility.Hidden; rightPanel.Visibility = Visibility.Hidden; } else { interviewState = InterviewState.INTERVIEW; nextButton.Tag = "Next"; nextButton.Content = "Next >"; prevButton.Visibility = Visibility.Visible; scrollViewer.Visibility = Visibility.Hidden; choicesPanel.Visibility = Visibility.Visible; leftPanel.Visibility = Visibility.Visible; rightPanel.Visibility = Visibility.Visible; } leftLabel.Visibility = Visibility.Hidden; rightLabel.Visibility = Visibility.Hidden; // Show different image according to job group string currentPath = System.Environment.CurrentDirectory; string[] temp = currentPath.Split("\\".ToCharArray()); currentPath = ""; for (int i = 0; i < temp.Length - 2; i++) { currentPath += temp[i]; currentPath += "\\"; } /*=====================*/ /* Set up the choices. */ /*=====================*/ resultsPanel.Children.Clear(); choicesPanel.Children.Clear(); leftPanel.Children.Clear(); rightPanel.Children.Clear(); /*===========================*/ /* Set up the panel context. */ /*===========================*/ if (fv["state"].ToString().Equals("conclusion")) { MultifieldValue drmf = (MultifieldValue)fv["display-results"]; Label linkLabel = null; Run linkText = null; Hyperlink link = null; // Read excel for link of Job & Course & Prodiver List <string> jobNameList = new List <string>(); List <string> jobLinkList = new List <string>(); List <string> courseNameList = new List <string>(); List <string> courseLinkList = new List <string>(); List <string> providerNameList = new List <string>(); List <string> providerLinkList = new List <string>(); DataTable dt = new DataTable(); dt = LoadExcel(currentPath + "\\doc\\LinkData.xlsx", "Job"); for (int i = 0; i < dt.Rows.Count; i++) { jobNameList.Add(dt.Rows[i][0].ToString()); jobLinkList.Add(dt.Rows[i][1].ToString()); } dt = LoadExcel(currentPath + "\\doc\\LinkData.xlsx", "Course"); for (int i = 0; i < dt.Rows.Count; i++) { courseNameList.Add(dt.Rows[i][0].ToString()); courseLinkList.Add(dt.Rows[i][1].ToString()); } dt = LoadExcel(currentPath + "\\doc\\LinkData.xlsx", "Provider"); for (int i = 0; i < dt.Rows.Count; i++) { providerNameList.Add(dt.Rows[i][0].ToString()); providerLinkList.Add(dt.Rows[i][1].ToString()); } for (int i = 0; i < drmf.Count; i++) { LexemeValue dr = (LexemeValue)drmf[i]; string resultValue = dr.Value; string[] resultValues = resultValue.Split(';'); // Job StackPanel jPanel = new StackPanel(); jPanel.HorizontalAlignment = HorizontalAlignment.Left; jPanel.VerticalAlignment = VerticalAlignment.Center; jPanel.Orientation = Orientation.Horizontal; jPanel.Height = 40; Ellipse jEllipse = new Ellipse(); jEllipse.Width = 20; jEllipse.Height = 20; SolidColorBrush jSolidColorBrush = new SolidColorBrush(); jSolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255); jEllipse.Fill = jSolidColorBrush; jPanel.Children.Add(jEllipse); linkLabel = new Label(); linkText = new Run(" " + resultValues[0].ToString()); link = new Hyperlink(linkText); link.NavigateUri = new Uri(jobLinkList[jobNameList.IndexOf(resultValues[0].ToString())]); link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }); link.MouseEnter += new MouseEventHandler(OnLinkMouseEnter); link.MouseLeave += new MouseEventHandler(OnLinkMouseLeave); link.Foreground = System.Windows.Media.Brushes.White; link.TextDecorations = null; linkLabel.Content = link; linkLabel.FontSize = 22; linkLabel.Foreground = System.Windows.Media.Brushes.White; jPanel.Children.Add(linkLabel); resultsPanel.Children.Add(jPanel); // Course1 StackPanel c1Panel = new StackPanel(); c1Panel.HorizontalAlignment = HorizontalAlignment.Left; c1Panel.VerticalAlignment = VerticalAlignment.Center; c1Panel.Orientation = Orientation.Horizontal; c1Panel.Height = 30; c1Panel.SetValue(Canvas.LeftProperty, 20d); Label c1Label = new Label(); c1Label.Content = " "; c1Panel.Children.Add(c1Label); Ellipse c1Ellipse = new Ellipse(); c1Ellipse.Width = 15; c1Ellipse.Height = 15; SolidColorBrush c1SolidColorBrush = new SolidColorBrush(); c1SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255); c1Ellipse.Fill = c1SolidColorBrush; c1Panel.Children.Add(c1Ellipse); linkLabel = new Label(); linkText = new Run(resultValues[1].ToString()); link = new Hyperlink(linkText); link.NavigateUri = new Uri(courseLinkList[courseNameList.IndexOf(resultValues[1].ToString())]); link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }); link.MouseEnter += new MouseEventHandler(OnLinkMouseEnter); link.MouseLeave += new MouseEventHandler(OnLinkMouseLeave); link.Foreground = System.Windows.Media.Brushes.White; link.TextDecorations = null; linkLabel.Content = link; linkLabel.FontSize = 18; linkLabel.Foreground = System.Windows.Media.Brushes.White; c1Panel.Children.Add(linkLabel); resultsPanel.Children.Add(c1Panel); // Provider1 StackPanel p1Panel = new StackPanel(); p1Panel.HorizontalAlignment = HorizontalAlignment.Left; p1Panel.VerticalAlignment = VerticalAlignment.Center; p1Panel.Orientation = Orientation.Horizontal; p1Panel.Height = 30; p1Panel.SetValue(Canvas.LeftProperty, 40d); Label p1Label = new Label(); p1Label.Content = " "; p1Panel.Children.Add(p1Label); Ellipse p1Ellipse = new Ellipse(); p1Ellipse.Width = 10; p1Ellipse.Height = 10; SolidColorBrush p1SolidColorBrush = new SolidColorBrush(); p1SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255); p1Ellipse.Fill = p1SolidColorBrush; p1Panel.Children.Add(p1Ellipse); linkLabel = new Label(); linkText = new Run(resultValues[3].ToString()); link = new Hyperlink(linkText); link.NavigateUri = new Uri(providerLinkList[providerNameList.IndexOf(resultValues[3].ToString())]); link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }); link.MouseEnter += new MouseEventHandler(OnLinkMouseEnter); link.MouseLeave += new MouseEventHandler(OnLinkMouseLeave); link.Foreground = System.Windows.Media.Brushes.White; link.TextDecorations = null; linkLabel.Content = link; linkLabel.FontSize = 14; linkLabel.Foreground = System.Windows.Media.Brushes.White; p1Panel.Children.Add(linkLabel); resultsPanel.Children.Add(p1Panel); // Course2 StackPanel c2Panel = new StackPanel(); c2Panel.HorizontalAlignment = HorizontalAlignment.Left; c2Panel.VerticalAlignment = VerticalAlignment.Center; c2Panel.Orientation = Orientation.Horizontal; c2Panel.Height = 30; c2Panel.SetValue(Canvas.LeftProperty, 20d); Label c2Label = new Label(); c2Label.Content = " "; c2Panel.Children.Add(c2Label); Ellipse c2Ellipse = new Ellipse(); c2Ellipse.Width = 15; c2Ellipse.Height = 15; SolidColorBrush c2SolidColorBrush = new SolidColorBrush(); c2SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255); c2Ellipse.Fill = c2SolidColorBrush; c2Panel.Children.Add(c2Ellipse); linkLabel = new Label(); linkText = new Run(resultValues[2].ToString()); link = new Hyperlink(linkText); link.NavigateUri = new Uri(courseLinkList[courseNameList.IndexOf(resultValues[2].ToString())]); link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }); link.MouseEnter += new MouseEventHandler(OnLinkMouseEnter); link.MouseLeave += new MouseEventHandler(OnLinkMouseLeave); link.Foreground = System.Windows.Media.Brushes.White; link.TextDecorations = null; linkLabel.Content = link; linkLabel.FontSize = 18; linkLabel.Foreground = System.Windows.Media.Brushes.White; c2Panel.Children.Add(linkLabel); resultsPanel.Children.Add(c2Panel); // Provider2 StackPanel p2Panel = new StackPanel(); p2Panel.HorizontalAlignment = HorizontalAlignment.Left; p2Panel.VerticalAlignment = VerticalAlignment.Center; p2Panel.Orientation = Orientation.Horizontal; p2Panel.Height = 30; p2Panel.SetValue(Canvas.LeftProperty, 40d); Label p2Label = new Label(); p2Label.Content = " "; p2Panel.Children.Add(p2Label); Ellipse p2Ellipse = new Ellipse(); p2Ellipse.Width = 10; p2Ellipse.Height = 10; SolidColorBrush p2SolidColorBrush = new SolidColorBrush(); p2SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255); p2Ellipse.Fill = p2SolidColorBrush; p2Panel.Children.Add(p2Ellipse); linkLabel = new Label(); linkText = new Run(resultValues[4].ToString()); link = new Hyperlink(linkText); link.NavigateUri = new Uri(providerLinkList[providerNameList.IndexOf(resultValues[4].ToString())]); link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }); link.MouseEnter += new MouseEventHandler(OnLinkMouseEnter); link.MouseLeave += new MouseEventHandler(OnLinkMouseLeave); link.Foreground = System.Windows.Media.Brushes.White; link.TextDecorations = null; linkLabel.Content = link; linkLabel.FontSize = 14; linkLabel.Foreground = System.Windows.Media.Brushes.White; p2Panel.Children.Add(linkLabel); resultsPanel.Children.Add(p2Panel); } scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scrollViewer.SetValue(Canvas.HeightProperty, 450d); resultsPanel.VerticalAlignment = VerticalAlignment.Top; Uri uri = null; if (jobGroup != null) { uri = new Uri(currentPath + "\\image\\" + jobGroup + ".png", UriKind.RelativeOrAbsolute); } else { uri = new Uri(currentPath + "\\image\\Path.png", UriKind.RelativeOrAbsolute); } BitmapImage bitmap = new BitmapImage(uri); pathImage.Source = bitmap; // Change window background if (jobGroup != null) { string color = ""; switch (jobGroup) { case "JobGroupsBA": color = "#FF20C2D7"; break; case "JobGroupsCC": color = "#FF0886B7"; break; case "JobGroupsDDM": color = "#FF27BBD5"; break; case "JobGroupsINS": color = "#FF007386"; break; case "JobGroupsISM": color = "#FF059DCC"; break; case "JobGroupsITM": color = "#FF008CAD"; break; case "JobGroupsSSD": color = "#FF00AB9B"; break; } prevButton.Background = nextButton.Background = this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color)); } else { this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF75B2B3")); } // Hidden progressBar progressPanel.Visibility = Visibility.Hidden; } else { MultifieldValue damf = (MultifieldValue)fv["display-answers"]; MultifieldValue vamf = (MultifieldValue)fv["valid-answers"]; string selected = fv["response"].ToString(); Button firstButton = null; RadioButton firstRadioButton = null; Uri uri = null; BitmapImage bitmap = null; for (int i = 0; i < damf.Count; i++) { LexemeValue da = (LexemeValue)damf[i]; LexemeValue va = (LexemeValue)vamf[i]; RadioButton rButton; Button button; string buttonName, buttonText, buttonAnswer; buttonName = da.Value; buttonText = buttonName.Substring(0, 1).ToUpperInvariant() + buttonName.Substring(1); buttonAnswer = va.Value; // Character if (fv["relation-asserted"].ToString().Equals("mind-types") || fv["relation-asserted"].ToString().Equals("see-things") || fv["relation-asserted"].ToString().Equals("judge-things") || fv["relation-asserted"].ToString().Equals("act-towards-changes")) { button = new Button(); // Button with image uri = new Uri(currentPath + "\\image\\" + buttonAnswer + ".png", UriKind.RelativeOrAbsolute); bitmap = new BitmapImage(uri); Image cellImage = new Image(); cellImage.Source = bitmap; button = new Button(); button.Content = cellImage; button.Tag = buttonAnswer; button.Width = 150; button.Height = 150; button.IsDefault = false; button.Click += OnClickButton; button.Visibility = Visibility.Visible; button.Margin = new Thickness(5); if (leftPanel.Children.Count == 0) { leftPanel.Children.Add(button); leftLabel.Content = buttonText; leftLabel.Visibility = Visibility.Visible; } else { rightPanel.Children.Add(button); rightLabel.Content = buttonText; rightLabel.Visibility = Visibility.Visible; } button.SetValue(Canvas.LeftProperty, 10d); button.SetValue(Canvas.TopProperty, 10d); button.SetValue(Canvas.BackgroundProperty, null); if (firstButton == null) { firstButton = button; } } else { rButton = new RadioButton(); rButton.Content = buttonText; if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) || ((lastAnswer == null) && buttonAnswer.Equals(selected))) { rButton.IsChecked = true; } else { rButton.IsChecked = false; } rButton.Tag = buttonAnswer; rButton.Visibility = Visibility.Visible; rButton.Margin = new Thickness(5); choicesPanel.Children.Add(rButton); if (firstRadioButton == null) { firstRadioButton = rButton; } } } if ((GetCheckedChoiceButton() == null) && (firstButton != null)) { firstButton.IsDefault = true; } if ((GetCheckedChoiceButton() == null) && (firstRadioButton != null)) { firstRadioButton.IsChecked = true; } relationAsserted = ((LexemeValue)fv["relation-asserted"]).Value; competency = fv["competency"].ToString(); // Change background when click Prev if (fv["state"].ToString().Equals("greeting")) { uri = new Uri(currentPath + "\\image\\Login.png", UriKind.RelativeOrAbsolute); } else { uri = new Uri(currentPath + "\\image\\Path.png", UriKind.RelativeOrAbsolute); } bitmap = new BitmapImage(uri); pathImage.Source = bitmap; prevButton.Background = nextButton.Background = this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF75B2B3")); // Update progressBar progressBar.Value = variableAsserts.Count * 100 / 13; } /*====================================*/ /* Set the label to the display text. */ /*====================================*/ string messageString = ((StringValue)fv["display"]).Value; double theWidth = ComputeTextBoxWidth(messageString); messageTextBox.Width = theWidth; messageTextBox.MinWidth = theWidth; messageTextBox.Text = messageString; }
private void HandleResponse() { /*===========================*/ /* Get the current UI state. */ /*===========================*/ String evalStr = "(find-fact ((?f UI-state)) TRUE)"; FactAddressValue fv = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0]; /*========================================*/ /* Determine the Next/Prev button states. */ /*========================================*/ if (fv.GetFactSlot("state").ToString().Equals("conclusion")) { interviewState = InterviewState.CONCLUSION; nextButton.Tag = "Restart"; nextButton.Content = "Restart"; prevButton.Visibility = Visibility.Visible; choicesPanel.Visibility = Visibility.Collapsed; } else if (fv.GetFactSlot("state").ToString().Equals("greeting")) { interviewState = InterviewState.GREETING; nextButton.Tag = "Next"; nextButton.Content = "Next >"; prevButton.Visibility = Visibility.Collapsed; choicesPanel.Visibility = Visibility.Collapsed; } else { interviewState = InterviewState.INTERVIEW; nextButton.Tag = "Next"; nextButton.Content = "Next >"; prevButton.Visibility = Visibility.Visible; choicesPanel.Visibility = Visibility.Visible; } /*=====================*/ /* Set up the choices. */ /*=====================*/ choicesPanel.Children.Clear(); MultifieldValue damf = (MultifieldValue)fv.GetFactSlot("display-answers"); MultifieldValue vamf = (MultifieldValue)fv.GetFactSlot("valid-answers"); String selected = fv.GetFactSlot("response").ToString(); RadioButton firstButton = null; for (int i = 0; i < damf.Count; i++) { LexemeValue da = (LexemeValue)damf[i]; LexemeValue va = (LexemeValue)vamf[i]; RadioButton rButton; String buttonName, buttonText, buttonAnswer; buttonName = da.GetLexemeValue(); buttonText = buttonName.Substring(0, 1).ToUpperInvariant() + buttonName.Substring(1); buttonAnswer = va.GetLexemeValue(); rButton = new RadioButton(); rButton.Content = buttonText; if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) || ((lastAnswer == null) && buttonAnswer.Equals(selected))) { rButton.IsChecked = true; } else { rButton.IsChecked = false; } rButton.Tag = buttonAnswer; rButton.Visibility = Visibility.Visible; rButton.Margin = new Thickness(5); choicesPanel.Children.Add(rButton); if (firstButton == null) { firstButton = rButton; } } if ((GetCheckedChoiceButton() == null) && (firstButton != null)) { firstButton.IsChecked = true; } /*====================================*/ /* Set the label to the display text. */ /*====================================*/ relationAsserted = ((LexemeValue)fv.GetFactSlot("relation-asserted")).GetLexemeValue(); /*====================================*/ /* Set the label to the display text. */ /*====================================*/ String messageString = ((StringValue)fv.GetFactSlot("display")).GetStringValue(); double theWidth = ComputeTextBoxWidth(messageString); messageTextBox.Width = theWidth; messageTextBox.MinWidth = theWidth; messageTextBox.Text = messageString; }