コード例 #1
0
        private void RoomFlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (CurrentRoom == null)
            {
                return;
            }
            uint flags = 0;

            for (int i = 0; i < RoomFlagsCheckedListBox.Items.Count; i++)
            {
                if (e.Index == i)
                {
                    if (e.NewValue == CheckState.Checked)
                    {
                        flags += (uint)(1 << i);
                    }
                }
                else
                {
                    if (RoomFlagsCheckedListBox.GetItemChecked(i))
                    {
                        flags += (uint)(1 << i);
                    }
                }
            }
            RoomFlagsTextBox.Text = flags.ToString();
            lock (ProjectForm.ProjectSyncRoot)
            {
                if (CurrentRoom._Data.flags != flags)
                {
                    CurrentRoom._Data.flags = flags;
                    ProjectForm.SetYtypHasChanged(true);
                }
            }
        }
コード例 #2
0
 private void RoomFlagsTextBox_TextChanged(object sender, EventArgs e)
 {
     if (CurrentRoom == null)
     {
         return;
     }
     uint.TryParse(RoomFlagsTextBox.Text, out uint flags);
     for (int i = 0; i < RoomFlagsCheckedListBox.Items.Count; i++)
     {
         var c = ((flags & (1u << i)) > 0);
         RoomFlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked);
     }
     lock (ProjectForm.ProjectSyncRoot)
     {
         if (CurrentRoom._Data.flags != flags)
         {
             CurrentRoom._Data.flags = flags;
             ProjectForm.SetYtypHasChanged(true);
         }
     }
 }