Esempio n. 1
0
 private void chk_Bfb_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (this.pnl_Phoneme.Tag == null || this.pnl_Phoneme.Tag.GetType() != typeof(List <long>))
         {
             return;
         }
         if ((int)chk_Bfb.Tag != CurrentIndex)
         {
             return;
         }
         if (ListValue[CurrentIndex].AtomLength == 0)
         {
             chk_Bfb.Checked = false;
             return;
         }
         List <long> TickArray = (List <long>) this.pnl_Phoneme.Tag;
         if (ListValue[CurrentIndex].LengthIsPercent != chk_Bfb.Checked)
         {
             if (chk_Bfb.Checked)
             {
                 try
                 {
                     long tot = 0;
                     for (int i = 0; i < TickArray.Count; i++)
                     {
                         tot = tot + TickArray[CurrentIndex];
                     }
                     ListValue[CurrentIndex].AtomLength      = (long)Math.Round(((double)TickArray[CurrentIndex] / (double)tot) * 100);
                     ListValue[CurrentIndex].LengthIsPercent = true;
                 }
                 catch {; }
             }
             else
             {
                 try
                 {
                     ListValue[CurrentIndex].AtomLength      = TickArray[CurrentIndex];
                     ListValue[CurrentIndex].LengthIsPercent = false;
                 }
                 catch {; }
             }
         }
         AtomPropertyGrid.Refresh();
     }
     catch {; }
 }
Esempio n. 2
0
        private void ctl_pa_Start_Scroll(object sender, EventArgs e)
        {
            if (this.pnl_Phoneme.Tag == null || this.pnl_Phoneme.Tag.GetType() != typeof(List <long>))
            {
                return;
            }
            List <long> TickArray  = (List <long>) this.pnl_Phoneme.Tag;
            long        st1        = getStartTick(CurrentIndex - 1);
            long        Tl1        = ctl_pa_Start.Value - st1;
            long        tEnd       = pmodel.Length;
            long        st2        = getStartTick(CurrentIndex + 1);
            long        MaxNoteLen = pmodel.Length / TickArray.Count;

            if (CurrentIndex + 1 < ListValue.Count)
            {
                tEnd = st2;
            }
            long Tl2         = tEnd - ctl_pa_Start.Value;
            long MinTickNote = 10;

            if (MinTickNote > MaxNoteLen)
            {
                MinTickNote = MaxNoteLen;
            }
            try
            {
                if (ListValue[CurrentIndex - 1].AtomLength > 0 && Tl1 < MinTickNote)
                {
                    //前置音符过短
                    long MinValue = MinTickNote + st1;
                    ctl_pa_Start.Value = (int)MinValue;
                    ctl_pa_Start_Scroll(null, null);
                    return;
                }
                if (ListValue[CurrentIndex].AtomLength > 0 || (!isSingleAuto && ListValue[CurrentIndex - 1].AtomLength == 0))
                {
                    if (Tl2 < MinTickNote)
                    {
                        //后置音符过短
                        long MinValue = tEnd - MinTickNote;
                        ctl_pa_Start.Value = (int)MinValue;
                        ctl_pa_Start_Scroll(null, null);
                        return;
                    }
                }
            }
            catch {; }

            if (ListValue[CurrentIndex - 1].AtomLength > 0)
            {
                if (ListValue[CurrentIndex - 1].LengthIsPercent)
                {
                    double bfb = (double)Tl1 / (double)pmodel.Length;
                    bfb = bfb * 100;
                    ListValue[CurrentIndex - 1].AtomLength = (long)Math.Round(bfb);
                }
                else
                {
                    ListValue[CurrentIndex - 1].AtomLength = Tl1;
                }
                this.pnl_Phoneme.Controls[CurrentIndex - 1].BackColor = Color.FromArgb(0, 192, 192);
            }
            if (ListValue[CurrentIndex].AtomLength > 0 || (!isSingleAuto && ListValue[CurrentIndex - 1].AtomLength == 0))
            {
                if (ListValue[CurrentIndex].LengthIsPercent)
                {
                    double bfb = (double)Tl2 / (double)pmodel.Length;
                    bfb = bfb * 100;
                    ListValue[CurrentIndex].AtomLength = (long)Math.Round(bfb);
                }
                else
                {
                    ListValue[CurrentIndex].AtomLength = Tl2;
                }
                this.pnl_Phoneme.Controls[CurrentIndex].BackColor = Color.Teal;
            }
            ReCalcListValue();
            ResizeShown();
            AtomPropertyGrid.Refresh();
        }