public void LoadRecording(Recording rec)
 {
     Keyframes.Clear();
     FocusedTray = new FocusContainer(this);
     foreach (var kf in rec.Keyframes)
     {
         var tray = InfoTray.BuildNew(kf, FocusedTray);
         Keyframes.Add(tray);
     }
 }
Exemple #2
0
        //private MouseAction[] actions;
        //private int currentAction;

        public KeyframeModel(InfoTray ui)
        {
            this.ui = ui;
            //Console.WriteLine("@@@@@@@@@@@@@@@@@"+ui);
            //actions = (MouseAction[])Enum.GetValues(typeof(MouseAction));
            //var ca = data.GetMouseAction();
            //for(int i = 0; i < actions.Length; i++)
            //{
            //    if(actions[i] == ca)
            //    {
            //        currentAction = i;
            //        break;
            //    }
            //}
        }
        private void Util_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string UP   = btnUp.Name;
            string DN   = btnDn.Name;
            string ADDM = btnAddM.Name;
            string ADDK = btnAddK.Name;
            string DEL  = btnDel.Name;
            string DIS  = btnDis.Name;

            var tray = model.FocusedTray.Focused;
            var kf   = tray?.GetKeyframe();

            //var mNode = tray.Model;
            //var node = tray.Model.DataNode;
            Focus();

            var s = ((Button)sender).Name;

            if (s.Equals(UP))
            {
                const int os = -2;
                if (!data.KeyframeOffsetExists(kf, os + 1))
                {
                    return;
                }

                var p = data.GetLinkedWithOffset(kf, os);
                data.ShiftKeyframe(kf, p);

                var i = model.Keyframes.IndexOf(tray);
                model.Keyframes.Remove(tray);
                model.Keyframes.Insert(i - 1, tray);
            }
            else if (s.Equals(DN))
            {
                const int os = 1;
                if (!data.KeyframeOffsetExists(kf, os))
                {
                    return;
                }

                var p = data.GetLinkedWithOffset(kf, os);
                data.ShiftKeyframe(kf, p);

                var i = model.Keyframes.IndexOf(tray);
                model.Keyframes.Remove(tray);
                model.Keyframes.Insert(i + 1, tray);
            }
            else if (s.Equals(ADDM) || s.Equals(ADDK))
            {
                Recording.Keyframe nk;
                if (s.Equals(ADDM))
                {
                    nk = data.MakeDefaultM(kf);
                }
                else
                {
                    nk = data.MakeDefaultK(kf);
                }
                var i = tray != null?model.Keyframes.IndexOf(tray) + 1 : model.Keyframes.Count;

                var nt = InfoTray.BuildNew(nk, model.FocusedTray);

                model.Keyframes.Insert(i, nt);
                nt.SetAsFocusedTray();

                //Console.WriteLine(model.Keyframes.Count);
            }
            else if (s.Equals(DEL))
            {
                var c = model.Keyframes.Count;
                if (c > 1)
                {
                    var i = model.Keyframes.IndexOf(tray);
                    if (c == 2)
                    {
                        i = i == 0 ? 1 : 0;
                    }
                    else
                    {
                        i = i == 0 ? 1 : i == c - 1 ? c - 2 : i + 1;
                    }

                    var t = model.Keyframes.ElementAt(i);
                    t.SetAsFocusedTray();
                }
                else
                {
                    traysLostFocusDelegate();
                }

                data.DeleteKeyframe(kf);
                model.Keyframes.Remove(tray);
            }
            else if (s.Equals(DIS))
            {
                data.Distribute(MainWindow.SettingsModel.GetSpeed());
            }
        }