Exemplo n.º 1
0
        // ADDS AN ITEM THAT WAS ALREADY CREATED ON THE SERVER, WITH ITS OWN ID
        public void AddItemFromServer(PaletteItemData pid)
        {
            // code from current AddItem function
            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);

            if (pid.Quadrant == quadrants[0].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, assumptionBrush);
                fec.SetValue(Ellipse.FillProperty, assumptionBrush);
            }
            else if (pid.Quadrant == quadrants[1].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, benefitBrush);
                fec.SetValue(Ellipse.FillProperty, benefitBrush);
            }
            else if (pid.Quadrant == quadrants[2].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, questionBrush);
                fec.SetValue(Ellipse.FillProperty, questionBrush);
            }
            else if (pid.Quadrant == quadrants[3].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, riskBrush);
                fec.SetValue(Ellipse.FillProperty, riskBrush);
            }

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

            Canvas.SetLeft(tmbDragThumb, pid.Position.X - (tmbDragThumb.Width / 2));
            Canvas.SetTop(tmbDragThumb, pid.Position.Y - (tmbDragThumb.Width / 2));

            tmbDragThumb.ToolTip = pid.Content;
            mainCanvas.Children.Add(tmbDragThumb);

            // ADD TO DATA LISTS
            //pid.ItemId = Data.Count; // NOT SURE THIS WILL STAY IN SYNC...SEE WHO CALLS THIS FUNCTION
            Data.Add(pid);
            Thumbs.Add(tmbDragThumb);

            UpdateScore(pid);
        }
Exemplo n.º 2
0
        private void MakeThumb(PaletteItemData pid)
        {
            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);

            if (pid.Quadrant == quadrants[0].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, assumptionBrush);
                fec.SetValue(Ellipse.FillProperty, assumptionBrush);
            }
            else if (pid.Quadrant == quadrants[1].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, benefitBrush);
                fec.SetValue(Ellipse.FillProperty, benefitBrush);
            }
            else if (pid.Quadrant == quadrants[2].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, questionBrush);
                fec.SetValue(Ellipse.FillProperty, questionBrush);
            }
            else if (pid.Quadrant == quadrants[3].Name)
            {
                fec.SetValue(Ellipse.StrokeProperty, riskBrush);
                fec.SetValue(Ellipse.FillProperty, riskBrush);
            }


            tmbDragThumb.Tag      = pid.Quadrant;
            template.VisualTree   = fec;
            tmbDragThumb.Template = template;
            tmbDragThumb.ToolTip  = pid.Content;

            Canvas.SetLeft(tmbDragThumb, pid.Position.X - (tmbDragThumb.Width / 2));
            Canvas.SetTop(tmbDragThumb, pid.Position.Y - (tmbDragThumb.Width / 2));

            mainCanvas.Children.Add(tmbDragThumb);

            Thumbs.Add(tmbDragThumb);
        }
Exemplo n.º 3
0
        public void UpdatePaletteItem(PaletteItemData pid)
        {
            foreach (PaletteItemData p in Data)
            {
                if (p.ItemId == pid.ItemId)
                {
                    Data[Data.IndexOf(p)] = pid;

                    // update thumb
                    Thumb th = Thumbs[Data.IndexOf(p)];
                    Canvas.SetLeft(th, p.Position.X - (th.Width / 2));
                    Canvas.SetTop(th, p.Position.Y - (th.Height / 2));
                    th.ToolTip = p.Content;
                    break;
                }
            }
        }
Exemplo n.º 4
0
        private void NewPaletteItemEventHandler(object sender, RoutedEventArgs e)
        {
            PaletteItemData pid = ((PaletteControl)e.OriginalSource).NewestItem;

            string message = String.Format("PI|{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|",
                                           pid.Author,
                                           pid.CapabilityIndex,
                                           pid.Content,
                                           pid.ItemId,
                                           pid.Position.X,
                                           pid.Position.Y,
                                           pid.Quadrant,
                                           pid.Score);

            sessionData.PaletteItemData.Add(pid);

            network.SendMessage(message);
        }
Exemplo n.º 5
0
        private void AddPaletteItem(string author, string capid, string content, string id, string px, string py, string quadrant, string score)
        {
            PaletteItemData pid = new PaletteItemData();

            pid.Author          = author;
            pid.CapabilityIndex = int.Parse(capid);
            pid.Content         = content;
            pid.ItemId          = id;
            pid.Position        = new Point(System.Convert.ToDouble(px), System.Convert.ToDouble(py));
            pid.Quadrant        = quadrant;
            pid.Score           = System.Convert.ToDouble(score);

            sessionData.PaletteItemData.Add(pid);

            string name;

            if (player.IsHost)
            {
                name = hostGameControl.hostPaletteControl.GetSelectedPlayerName();
                //if(name == pid.Author)
                //{
                this.Dispatcher.Invoke(() =>
                {
                    //hostGameControl.hostPaletteControl.paletteControl.AddItemFromServer(pid);
                    hostGameControl.AddPlayerNameToAssessmentControl(pid.Author);
                });
                //}
                if (name == pid.Author)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        hostGameControl.hostPaletteControl.paletteControl.AddItemFromServer(pid);
                    });
                }
            }
            else
            {
                this.Dispatcher.Invoke(() =>
                {
                    playerGameControl.playerPaletteControl.playerPalette.AddItemFromServer(pid);
                });
            }
        }
Exemplo n.º 6
0
        private void UpdateScore(PaletteItemData pd)
        {
            Thumb th = Thumbs[Data.IndexOf(pd)];

            if (pd.Quadrant == quadrants[0].Name)
            {
                pd.Score = Canvas.GetLeft(th);
            }
            else if (pd.Quadrant == quadrants[1].Name)
            {
                pd.Score = Canvas.GetTop(th);
            }
            else if (pd.Quadrant == quadrants[2].Name)
            {
                pd.Score = Canvas.GetRight(th);
            }
            else if (pd.Quadrant == quadrants[3].Name)
            {
                pd.Score = Canvas.GetBottom(th);
            }
        }
Exemplo n.º 7
0
        private void PaletteItemContentUpdateEventHandler(object sender, RoutedEventArgs e)
        {
            PaletteItemData pid = (e.OriginalSource as PaletteControl).NewestItem;

            // update data
            sessionData.PaletteItemData[sessionData.PaletteItemData.IndexOf(pid)].Content = pid.Content;

            string msg;

            if (player.IsHost)
            {
                // if host, send to selected player
                msg = String.Format("IU|1|{0}|{1}|{2}|", pid.Author, pid.ItemId, pid.Content);
                network.SendMessage(msg);
            }
            else
            {
                // if player, send to host - the 1 indicates this is a content update
                msg = String.Format("IU|1|{0}|{1}|{2}|", pid.Author, pid.ItemId, pid.Content);
                network.SendMessage(msg);
            }
        }
Exemplo n.º 8
0
        private void PaletteItemDragCompletedEventHandler(object sender, RoutedEventArgs e)
        {
            PaletteItemData pid = (e.OriginalSource as PaletteControl).NewestItem;

            // update data
            sessionData.PaletteItemData[sessionData.PaletteItemData.IndexOf(pid)].Score    = pid.Score;
            sessionData.PaletteItemData[sessionData.PaletteItemData.IndexOf(pid)].Position = pid.Position;

            string msg;

            if (player.IsHost)
            {
                // if host, send to selected player
                msg = String.Format("IU|0|{0}|{1}|{2}|{3}|{4}|", pid.Author, pid.ItemId, pid.Position.X, pid.Position.Y, pid.Score);
                network.SendMessage(msg);
            }
            else
            {
                // if player, send to host - the 0 indicates this is a position update
                msg = String.Format("IU|0|{0}|{1}|{2}|{3}|{4}|", pid.Author, pid.ItemId, pid.Position.X, pid.Position.Y, pid.Score);
                network.SendMessage(msg);
            }
        }
Exemplo n.º 9
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));
        }
Exemplo n.º 10
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("");
            }
        }