コード例 #1
0
 void SetOriginalButtonColor()
 {
     try
     {
         List <FrameworkElement> lstElement;
         FreePlayPage            page = (FreePlayPage)PageController.GetViewModel().CurrentPage;
         Panel pianoRoll             = (Panel)page.pianoRoll.Content;
         UIElementCollection element = pianoRoll.Children;
         lstElement = element.Cast <FrameworkElement>().ToList();
         Dictionary <string, string> _notesByKeys = PageController.GetPianoRollModel()._notesByKeys;
         List <string> pressedNotes = new List <string>();
         var           lstControl   = lstElement.OfType <Button>();
         foreach (var control in lstControl)
         {
             if (control.Tag.ToString() == _notesByKeys.FirstOrDefault(x => x.Value == NOTES[CurrentNote]).Key)
             {
                 if (NOTES[CurrentNote].Contains("#"))
                 {
                     control.SetResourceReference(Button.StyleProperty, "BlackPianoKeyStyle");
                 }
                 else
                 {
                     control.SetResourceReference(Button.StyleProperty, "WhitePianoKeyStyle");
                 }
             }
         }
     }
     catch (Exception) { IsPlaying = false; }
 }
コード例 #2
0
 //получение PianoRollModel из FreePlayPage
 public static PianoRollModel GetPianoRollModel()
 {
     try
     {
         FreePlayPage       page           = (FreePlayPage)PageController.GetViewModel().CurrentPage;
         PianoRollViewModel pianoViewModel = (PianoRollViewModel)page.pianoRoll.DataContext;
         PianoRollModel     pianoModel     = pianoViewModel._model;
         return(pianoModel);
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); return(new PianoRollModel()); }
 }