예제 #1
0
 private void TimeFlagsTextBox_TextChanged(object sender, EventArgs e)
 {
     if (populatingui)
     {
         return;
     }
     if (CurrentArchetype == null)
     {
         return;
     }
     if (CurrentArchetype is TimeArchetype TimeArchetype)
     {
         uint flags = 0;
         uint.TryParse(TimeFlagsTextBox.Text, out flags);
         populatingui = true;
         for (int i = 0; i < TimeFlagsCheckedListBox.Items.Count; i++)
         {
             var c = ((flags & (1u << i)) > 0);
             TimeFlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked);
         }
         populatingui = false;
         lock (ProjectForm.ProjectSyncRoot)
         {
             if (TimeArchetype.TimeFlags != flags)
             {
                 TimeArchetype.SetTimeFlags(flags);
                 ProjectForm.SetYtypHasChanged(true);
             }
         }
     }
 }
예제 #2
0
 private void TimeFlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (populatingui)
     {
         return;
     }
     if (CurrentArchetype == null)
     {
         return;
     }
     if (CurrentArchetype is TimeArchetype TimeArchetype)
     {
         uint flags = 0;
         for (int i = 0; i < TimeFlagsCheckedListBox.Items.Count; i++)
         {
             if (e.Index == i)
             {
                 if (e.NewValue == CheckState.Checked)
                 {
                     flags += (uint)(1 << i);
                 }
             }
             else
             {
                 if (TimeFlagsCheckedListBox.GetItemChecked(i))
                 {
                     flags += (uint)(1 << i);
                 }
             }
         }
         populatingui          = true;
         TimeFlagsTextBox.Text = flags.ToString();
         populatingui          = false;
         lock (ProjectForm.ProjectSyncRoot)
         {
             if (TimeArchetype.TimeFlags != flags)
             {
                 TimeArchetype.SetTimeFlags(flags);
                 ProjectForm.SetYtypHasChanged(true);
             }
         }
     }
 }