Example #1
0
        public async void DisplayRoomInfos()
        {
            try
            {
                Hide();
                if (!Client.InRoom)
                {
                    return;
                }

                var roomInfos = await Client.GetRooms();

                var scrollObject = new GameObject();
                scroll = scrollObject.AddComponent <CanvasScroll>();
                Vector3 halfCanvasSize = Vector3.zero;
                foreach (var roomInfo in roomInfos)
                {
                    var instantiatedCanvas = scroll.AddCanvas(roomInfoCanvas.gameObject, $"{roomInfo.OwnerName}'s Room");
                    var canvas             = instantiatedCanvas.GetComponent <RoomInfoCanvas>();
                    canvas.SetParentScroll(scroll);
                    canvas.Initialize(roomInfo);
                    halfCanvasSize = Vector3.Scale(canvas.CanvasSize(), Vector3.right) / 2;
                }

                var halfButtonSize = GetComponent <RectTransform>().rect.width *transform.localScale.x / 2;
                scrollObject.transform.localPosition += new Vector3(halfButtonSize + 3, 0f, 0f) + halfCanvasSize;
                scrollObject.transform.SetParent(transform.root, false);
            }
            catch (Exception e)
            {
                Notification.Notify("ルーム情報を取得できませんでした");
                Debug.LogError(e);
                throw;
            }
        }
Example #2
0
        private void ControlMouseMove(object sender, MouseEventArgs e)
        {
            if (cardDragging)
            {
                if (uc != null)
                {
                    //var element = sender as FrameworkElement;
                    var currentPoint = e.GetPosition(null);
                    var scrollOffset = CanvasScroll.VerticalOffset;

                    var xPos = currentPoint.X - (uc.Width / 2);
                    var yPos = (currentPoint.Y - WINDOW_HEADING_OFFSET) - (uc.Height / 2) + scrollOffset;

                    uc.SetValue(Canvas.LeftProperty, xPos);
                    uc.SetValue(Canvas.TopProperty, yPos);
                }
            }
            else if (canvasDragging)
            {
                var currentPoint = e.GetPosition(null);
                if (startMousePos.Y < currentPoint.Y)
                {
                    CanvasScroll.LineUp();
                }
                else if (startMousePos.Y > currentPoint.Y)
                {
                    CanvasScroll.LineDown();
                }

                startMousePos = currentPoint;
            }
        }
Example #3
0
 public void Hide()
 {
     if (scroll != null)
     {
         DestroyImmediate(scroll.gameObject);
         scroll = null;
     }
 }