コード例 #1
0
        /// <summary>
        /// 近くのセッション選択ボタンを追加する。
        /// </summary>
        /// <param name="sessionName">セッション名</param>
        /// <param name="sessionID">セッションID</param>
        public void AddNearbyButton(string sessionName, string sessionID)
        {
            try
            {
                lock (nearbySessionPanel)
                {
                    // すでに追加されていないか調べる
                    foreach (Control control in nearbySessionPanel.Controls)
                    {
                        if (sessionID == ((SessionButton)control).SessionID)
                        {
                            return;
                        }
                    }

                    // ボタン作成
                    SessionButton sessionButton = new SessionButton();
                    sessionButton.SessionName = sessionName;
                    sessionButton.SessionID   = sessionID;
                    sessionButton.Text        = sessionName;
                    sessionButton.Size        = new Size(nearbySessionPanel.Width - 30, 40);
                    sessionButton.Click      += new EventHandler(SessionButton_Click);
                    AddNearbyButton(sessionButton);
                }
            }
            catch (Exception e)
            {
                PhotoChat.WriteErrorLog(e.ToString());
            }
        }
コード例 #2
0
 /// <summary>
 /// セッションボタン
 /// </summary>
 private void SessionButton_Click(object sender, EventArgs e)
 {
     try
     {
         SessionButton sessionButton = (SessionButton)sender;
         sessionName = sessionButton.SessionName;
         sessionID   = sessionButton.SessionID;
     }
     catch (Exception ex)
     {
         PhotoChat.WriteErrorLog(ex.ToString());
     }
 }
コード例 #3
0
 /// <summary>
 /// 過去のセッション選択エリアにボタンを追加する。
 /// </summary>
 /// <param name="button">追加するボタン</param>
 private void AddPastButton(SessionButton button)
 {
     try
     {
         if (InvokeRequired)
         {
             // 別スレッドからの呼び出しの場合
             Invoke(new Action <SessionButton>(AddPastButton), button);
             return;
         }
         pastSessionPanel.Controls.Add(button);
     }
     catch (Exception e)
     {
         PhotoChat.WriteErrorLog(e.ToString());
     }
 }
コード例 #4
0
    void UpdateSessionButtonList()
    {
        bool oneItemIsSelected = false;

        // update existing buttons and add new ones
        for (int i = 0; i < _sessions.Count; i++)
        {
            if (i == _sessionButtons.Count)
            {
                // create new button!
                SessionButton newButton = Instantiate(_sessionButtonPrefab, _sessionButtonContainer);
                newButton.onClick += OnSessionButtonClick;
                _sessionButtons.Add(newButton);
            }

            _sessionButtons[i].session  = _sessions[i];
            _sessionButtons[i].selected = _selectedSession != null && (_selectedSession.Id == _sessions[i].Id);
            if (_sessionButtons[i].selected)
            {
                oneItemIsSelected = true;
            }
        }

        // remove extra buttons
        for (int r = _sessionButtons.Count - 1; r >= _sessions.Count; r--)
        {
            _sessionButtons[r].DestroyGO();
            _sessionButtons.RemoveLast();
        }

        if (oneItemIsSelected == false)
        {
            // we were focusing a session that does not exist anymore
            _selectedSession = null;
        }
    }
コード例 #5
0
 void OnSessionButtonClick(SessionButton button)
 {
     _selectedSession = button.session;
     UpdateSessionButtonList();
 }