예제 #1
0
        private void Thumb_MouseDown(object sender, MouseButtonEventArgs e)
        {
            PaletteItemData _data = new PaletteItemData();

            PaletteContentWindow pc = null;

            _data = Data[Thumbs.IndexOf((Thumb)sender)];
            pc    = new PaletteContentWindow();
            pc.contentTextBox.Text  = _data.Content;
            pc.quadrantName.Content = _data.Quadrant.ToUpper();
            pc.submitButton.Content = "UPDATE";

            if (IsReadOnly)
            {
                pc.submitButton.Content      = "CLOSE";
                pc.cancelButton.Visibility   = Visibility.Hidden;
                pc.contentTextBox.IsReadOnly = true;
            }

            if (_data.Quadrant == quadrants[0].Name)
            {
                pc.quadrantName.Background = assumptionBrush;
            }
            else if (_data.Quadrant == quadrants[1].Name)
            {
                pc.quadrantName.Background = benefitBrush;
            }
            else if (_data.Quadrant == quadrants[2].Name)
            {
                pc.quadrantName.Background = questionBrush;
            }
            else if (_data.Quadrant == quadrants[3].Name)
            {
                pc.quadrantName.Background = riskBrush;
            }
            else
            {
                pc.quadrantName.Background = Brushes.Black;
            }

            if (pc != null)
            {
                pc.ShowDialog();
                if (pc.DialogResult.HasValue && pc.DialogResult.Value)
                {
                    if (pc.DialogResult == true)
                    {
                        if (!IsReadOnly)
                        {
                            _data.Content = pc.contentTextBox.Text;
                            Thumbs[Data.IndexOf(_data)].ToolTip = _data.Content;
                        }
                        pc.Close();
                    }
                    else
                    {
                    }
                }
            }

            // Raise event to update data record on pplayer and UPDATE SERVER
            NewestItem = Data[Thumbs.IndexOf(sender as Thumb)];

            // RAISE EVENT TO UPDATE DATA RECORD ON PLAYER AND SEND UPDATE MESSAGE TO HOST WITH NEW POSITION AND SCORE
            RaiseEvent(new RoutedEventArgs(PaletteControl.PaletteItemContentUpdateEvent));
        }
예제 #2
0
        public void AddItem(Polygon poly, MouseButtonEventArgs e)
        {
            if (!IsReadOnly)
            {
                PaletteItemData dt = new PaletteItemData();

                Thumb tmbDragThumb = new Thumb();
                tmbDragThumb.Width  = 15;
                tmbDragThumb.Height = 15;

                tmbDragThumb.DragDelta        += new DragDeltaEventHandler(Thumb_DragDelta);
                tmbDragThumb.DragCompleted    += new DragCompletedEventHandler(Thumb_DragCompleted);
                tmbDragThumb.MouseDoubleClick += new MouseButtonEventHandler(Thumb_MouseDown);

                ControlTemplate template = new ControlTemplate();
                var             fec      = new FrameworkElementFactory(typeof(Ellipse));
                fec.SetValue(Ellipse.FillProperty, Brushes.White);

                switch (poly.Name)
                {
                case "assumptionsPolygon":
                    dt.Quadrant = quadrants[0].Name;
                    fec.SetValue(Ellipse.StrokeProperty, assumptionBrush);
                    fec.SetValue(Ellipse.FillProperty, assumptionBrush);
                    break;

                case "benefitsPolygon":
                    dt.Quadrant = quadrants[1].Name;
                    fec.SetValue(Ellipse.StrokeProperty, benefitBrush);
                    fec.SetValue(Ellipse.FillProperty, benefitBrush);
                    break;

                case "questionsPolygon":
                    dt.Quadrant = quadrants[2].Name;
                    fec.SetValue(Ellipse.StrokeProperty, questionBrush);
                    fec.SetValue(Ellipse.FillProperty, questionBrush);
                    break;

                case "risksPolygon":
                    dt.Quadrant = quadrants[3].Name;
                    fec.SetValue(Ellipse.StrokeProperty, riskBrush);
                    fec.SetValue(Ellipse.FillProperty, riskBrush);
                    break;

                default:
                    break;
                }

                tmbDragThumb.Tag      = dt.Quadrant;
                template.VisualTree   = fec;
                tmbDragThumb.Template = template;

                Canvas.SetLeft(tmbDragThumb, e.GetPosition(mainCanvas).X - (tmbDragThumb.Width / 2));
                Canvas.SetTop(tmbDragThumb, e.GetPosition(mainCanvas).Y - (tmbDragThumb.Width / 2));

                dt.Position = e.GetPosition(mainCanvas);

                // get content
                PaletteContentWindow pc = new PaletteContentWindow();
                pc.quadrantName.Content = dt.Quadrant.ToUpper();
                //pc.Left = dt.WindowLeft;
                //pc.Top = dt.WindowTop;
                if (dt.Quadrant == quadrants[0].Name)
                {
                    pc.quadrantName.Background = assumptionBrush;
                }
                else if (dt.Quadrant == quadrants[1].Name)
                {
                    pc.quadrantName.Background = benefitBrush;
                }
                else if (dt.Quadrant == quadrants[2].Name)
                {
                    pc.quadrantName.Background = questionBrush;
                }
                else if (dt.Quadrant == quadrants[3].Name)
                {
                    pc.quadrantName.Background = riskBrush;
                }
                else
                {
                    pc.quadrantName.Background = Brushes.Black;
                }
                pc.ShowDialog();
                if (pc.DialogResult.HasValue && pc.DialogResult.Value)
                {
                    if (pc.DialogResult == true)
                    {
                        dt.Author            = this.PlayerName;
                        dt.CapabilityIndex   = this.CapabilityIndex;
                        dt.Content           = pc.contentTextBox.Text;
                        dt.ItemId            = GetRandomId(8);
                        tmbDragThumb.ToolTip = dt.Content;
                        mainCanvas.Children.Add(tmbDragThumb);

                        // ADD TO DATA LISTS
                        Data.Add(dt);
                        Thumbs.Add(tmbDragThumb);

                        pc.Close();
                    }
                    else
                    {
                        dt = null;
                    }
                }
                UpdateScore(dt);

                // raise event on MainWindow to send info to host
                NewestItem = new PaletteItemData();
                NewestItem = dt;
                RaiseEvent(new RoutedEventArgs(PaletteControl.NewPaletteItemEvent));


                Console.WriteLine("");
            }
        }