Ejemplo n.º 1
0
        public void DrawControl(TimeSpan span)
        {
            Binding binding;

            timer.Interval = span;
            timer.Tick    += new EventHandler(timer_Tick);

            ControlThumb   controlThumbAnswer;
            ControlThumb   controlThumbQuestion;
            ContentControl contentControl;

            canvas.Children.Clear();
            foreach (var v in topicDragItemList)
            {
                binding        = new Binding();
                binding.Source = v;
                binding.Path   = new PropertyPath("Text");

                contentControl = new ContentControl()
                {
                    Tag = v.Id, Style = FindResource("textControl") as Style
                };
                contentControl.SetBinding(ContentControl.ContentProperty, binding);

                contentControl.PreviewMouseUp += new MouseButtonEventHandler(contentControl_PreviewMouseUp);
                canvas.Children.Add(contentControl);
            }

            foreach (var v in topicDragItemAnswerList)
            {
                controlThumbAnswer = new ControlThumb()
                {
                    IsEdit = this.IsEdit, Style = FindResource("thumbAnswer") as Style, Tag = "Answer"
                };
                controlThumbQuestion = new ControlThumb()
                {
                    IsEdit = this.IsEdit, Style = FindResource("thumbQuestion") as Style, Tag = "Question"
                };

                controlThumbAnswer.DragCompleted   += new DragCompletedEventHandler(controlThumb_DragCompleted);
                controlThumbQuestion.DragCompleted += new DragCompletedEventHandler(controlThumb_DragCompleted);

                controlThumbAnswer.DragDelta   += new DragDeltaEventHandler(ControlThumb_DragDelta);
                controlThumbQuestion.DragDelta += new DragDeltaEventHandler(ControlThumb_DragDelta);

                controlThumbAnswer.Id = v.AnswerId;

                Canvas.SetLeft(controlThumbAnswer, v.AnswerPoint.X);
                Canvas.SetTop(controlThumbAnswer, v.AnswerPoint.Y);

                controlThumbQuestion.Id = v.QuestionId;

                if (IsEdit == true)
                {
                    controlThumbAnswer.ContentId = v.Id;
                }

                Canvas.SetLeft(controlThumbQuestion, v.QuestionPoint.X);
                Canvas.SetTop(controlThumbQuestion, v.QuestionPoint.Y);

                canvas.Children.Add(controlThumbAnswer);
                canvas.Children.Add(controlThumbQuestion);
            }

            timer.Start();
        }
Ejemplo n.º 2
0
        public void DrawControl(TimeSpan span)
        {
            Binding binding;

            timer.Interval = span;
            timer.Tick    += new EventHandler(timer_Tick);

            ControlThumb   controlThumbAnswer;
            ControlThumb   controlThumbQuestion;
            ContentControl contentControl;

            canvas.Children.Clear();
            foreach (var v in topicDragItemList)
            {
                binding        = new Binding();
                binding.Source = v;
                binding.Path   = new PropertyPath("Text");

                contentControl = new ContentControl()
                {
                    Tag = v.Id, Style = FindResource("textControl") as Style
                };
                contentControl.Foreground = ItemForeground;
                contentControl.Background = ItemBackground;
                contentControl.SetBinding(ContentControl.ContentProperty, binding);

                contentControl.PreviewMouseUp += new MouseButtonEventHandler(contentControl_PreviewMouseUp);
                canvas.Children.Add(contentControl);
            }

            int i = 0;

            foreach (var v in topicDragItemAnswerList)
            {
                controlThumbAnswer = new ControlThumb()
                {
                    IsEdit = this.IsEdit, Style = FindResource("thumbAnswer") as Style, Tag = "Answer"
                };
                controlThumbQuestion = new ControlThumb()
                {
                    IsEdit = this.IsEdit, Style = FindResource("thumbQuestion") as Style, Tag = "Question"
                };

                controlThumbAnswer.DragCompleted   += new DragCompletedEventHandler(controlThumb_DragCompleted);
                controlThumbQuestion.DragCompleted += new DragCompletedEventHandler(controlThumb_DragCompleted);

                controlThumbAnswer.DragDelta   += new DragDeltaEventHandler(ControlThumb_DragDelta);
                controlThumbQuestion.DragDelta += new DragDeltaEventHandler(ControlThumb_DragDelta);
                var modelitem = topicDragItemList.FirstOrDefault(p => p.Id == v.Id);
                binding        = new Binding();
                binding.Source = modelitem;
                binding.Path   = new PropertyPath("Text");
                controlThumbAnswer.SetBinding(ControlThumb.TextProperty, binding);

                controlThumbAnswer.Id = v.AnswerId;
                //controlThumbAnswer.Content.CVisibility = Visibility.Collapsed;
                Canvas.SetLeft(controlThumbAnswer, v.AnswerPoint.X);
                Canvas.SetTop(controlThumbAnswer, v.AnswerPoint.Y);
                Binding bdsource = new Binding();
                bdsource.Source = Isvisibility;
                controlThumbAnswer.SetBinding(ControlThumb.TextVisibilityProperty, bdsource);


                controlThumbQuestion.Id = v.QuestionId;

                if (IsEdit == true)
                {
                    controlThumbAnswer.ContentId = v.Id;
                }


                Canvas.SetLeft(controlThumbQuestion, v.QuestionPoint.X);
                Canvas.SetTop(controlThumbQuestion, v.QuestionPoint.Y);

                canvas.Children.Add(controlThumbAnswer);
                canvas.Children.Add(controlThumbQuestion);
                i++;
            }

            timer.Start();
        }