コード例 #1
0
        public void CreateReadOnly()
        {
            DecisionBox b = new DecisionBox();

            DisplayPage          = b;
            b.x_description.Text = Data.Description;
            if (Answer != null)
            {
                Answered();
            }
            else
            {
                for (int i = 0; i < Data.Posibilities.Count; i++)
                {
                    DecisionPossibilities s = Data.Posibilities[i];
                    Button  bt = new Button();
                    Outcome o  = Outcomes.Find(x => x.Id == s.Id);
                    // this must be valid. Solved while loading
                    System.Diagnostics.Debug.Assert(o != null);
                    bt.Content     = s.Action;
                    bt.DataContext = s;
                    bt.Click      += Bt_Click;
                    b.x_decisions.Children.Add(bt);
                }
            }
        }
コード例 #2
0
        private void x_add_decision_Click(object sender, RoutedEventArgs e)
        {
            DecisionData          d = (DataContext as DecisionCreator).Data;
            DecisionPossibilities p = new DecisionPossibilities();

            d.Posibilities.Add(p);
            AddDecision(p);
        }
コード例 #3
0
        private void AddDecision(DecisionPossibilities p)
        {
            int            t = x_decisions.Children.Count - 1;
            SingleDecision d = new SingleDecision();

            x_decisions.Children.Insert(t, d);
            x_remove_decision.IsEnabled = true;
            DecisionCreator dc = DataContext as DecisionCreator;

            InitCrossroad(d, dc, p);
        }
コード例 #4
0
        private void InitCrossroad(SingleDecision sd, DecisionCreator dc, DecisionPossibilities p)
        {
            DecisionData d = dc.Data;

            sd.DataContext                   = p;
            sd.x_crossroad.ItemsSource       = dc.Outcomes;
            sd.x_crossroad.DisplayMemberPath = "Name";
            int selected = dc.Outcomes.FindIndex(x => p.Id == x.Id);

            if (selected < 0)
            {
                return;
            }
            sd.x_crossroad.SelectedItem = dc.Outcomes[selected];
        }
コード例 #5
0
        private void Bt_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (onAnswer != null)
            {
                DecisionPossibilities a = b.DataContext as DecisionPossibilities;
                Answer             = new PostAnswerData();
                Answer.id          = a.Id;
                Answer.Reaction    = a.Reaction;
                Answer.ActionTaken = a.Action;
                onAnswer(a.Id);
            }
            Answered();
        }