Beispiel #1
0
        private void RC3_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Song song = Global.Instance.Song;

            if (song == null)
            {
                return;
            }

            if ((CurrOver != null) && (CurrOver.HasProperties))
            {
                endselection();
                endhover();
                prvover = null;

                CurrOver.ShowDialog(Global.Instance.Song);

                //  show propr dialog
                //var dlg = CurrOver.PropertyWindow();
                ////dlg.FormBorderStyle = FormBorderStyle.None;
                //dlg.MaximizeBox = false;
                //dlg.MinimizeBox = false;
                //dlg.StartPosition = FormStartPosition.CenterScreen;

                //dlg.ShowDialog();
            }
        }
Beispiel #2
0
        protected virtual VizCmd CmdCopy(VizCmd vizCmd)
        {
            //Viz viz = (Viz)JsonConvert.DeserializeObject((string)(vizCmd.obj), typeof(Lyric));
            Viz viz = vizCmd.viz;

            viz.ResetPoints(Global.Instance.Song);
            Global.Instance.Song.Vizs.Add(viz);
            vizCmd.cmd = Cmd.Delete;
            return(vizCmd);
        }
Beispiel #3
0
        private void CntxtMenu_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            CntxtMenuItem     cmi  = (CntxtMenuItem)tsmi.Tag;
            Viz viz = (Viz)tsmi.Owner.Tag;

            var does = cmi.Handler(viz, CntxtMenuMouseLocation);

            if (does != null)
            {
                if (does.Any(c => c.cmd == Cmd.Insert))
                {
                    Global.Instance.Song.Selected.Clear();
                }
                var undoes = new List <VizCmd>();
                foreach (VizCmd cmd in does)
                {
                    if (cmd != null)
                    {
                        VizCmd chain;
                        if (cmd.viz != null)
                        {
                            if ((chain = cmd.viz.XeqCmd(cmd)) != null)
                            {
                                undoes.Add(chain);
                            }
                        }
                        else if (cmd.obj is Dictionary <string, object> )
                        {
                            Dictionary <string, object> dict = cmd.obj as Dictionary <string, object>;
                            object obj;
                            if ((dict != null) && (dict.TryGetValue("type", out obj)) && (obj is Type))
                            {
                                Type typ = obj as Type;
                                if (typ == typeof(Lyric))
                                {
                                    Lyric lyr = Global.Instance.Song.CreateLyric((string)dict["text"], (TimeMark)dict["tm"]);
                                    cmd.cmd = Cmd.Delete;
                                    cmd.viz = lyr;
                                    undoes.Add(cmd);
                                }
                            }
                        }
                    }
                }
                if (undoes.Count > 0)
                {
                    Global.Instance.Song.Remember(undoes);
                    //Recalculate(true);
                }
            }
        }
Beispiel #4
0
 public IEnumerable <VizCmd> cmCopy(Viz viz = null)
 {
     copied.Clear();
     if (selected.Count == 0)
     {
         copied.Add(viz);
     }
     else
     {
         copied.AddRange(selected);
     }
     return(null);
 }
Beispiel #5
0
 public IEnumerable <VizCmd> cmDelete(Viz viz = null)
 {
     if (selected.Count == 0)
     {
         return(new List <VizCmd>()
         {
             new VizCmd(viz, Cmd.Delete)
         });
     }
     else
     {
         return(selected.Select(v => new VizCmd(v, Cmd.Delete)).ToList());
     }
 }
Beispiel #6
0
 public IEnumerable <VizCmd> cmDuplicate(Viz viz = null)
 {
     if (selected.Count == 0)
     {
         return(new List <VizCmd>()
         {
             new VizCmd(viz.Clone(), Cmd.Insert)
         });
     }
     else
     {
         return(selected.Select(v => new VizCmd(v.Clone(), Cmd.Insert)).ToList());
     }
 }
Beispiel #7
0
        private void endhover()
        {
            switch (hoverMode)
            {
            case HoverMode.Prehover:         // pre
                hovertimer.Stop();
                //toolStripStatusLabel3.Text = "stop timer";
                hoverMode = HoverMode.Off;
                break;

            case HoverMode.Active:
                toolTip1.Hide(this);
                //toolStripStatusLabel3.Text = "end hover";
                hoverMode = HoverMode.Off;
                break;
            }
            prvover = null;
        }
Beispiel #8
0
        private static IEnumerable <VizCmd> cmPaste(Viz viz, System.Drawing.Point MouseLocation)
        {
            Song song    = Global.Instance.Song;
            Viz  frst    = song.Copied[0];
            int  newBeat = song.Beat(MouseLocation.X + Global.Lft);
            int  oldBeat = song.Beat(frst.StartPoint.X);
            int  offset  = newBeat - oldBeat;

            List <VizCmd> cmds = new List <VizCmd>(song.Copied.Count);

            foreach (var src in song.Copied)
            {
                Lyric dst     = (Lyric)src.Clone();
                int   beat    = song.Beat(dst.StartPoint.X);
                float newTime = dst.StartPoint.X + (Global.Instance.Song.TimePoints.Keys[beat + offset] - Global.Instance.Song.TimePoints.Keys[beat]);
                dst.timemark = Global.Instance.Song.NormalizedTimeMark((int)newTime);
                cmds.Add(new VizCmd(dst, Cmd.Insert));
            }
            return(cmds);
        }
Beispiel #9
0
 public void Select(Viz viz, bool ShiftKey)
 {
     if (viz.IsSelectable)
     {
         if (ShiftKey ||
             (!viz.IsMultiSelectable) ||
             ((Selected.Count > 0) && (viz.GetType() != Selected[0].GetType())))
         {
             Selected.Clear();
         }
         if (Selected.Contains(viz))
         {
             Selected.Remove(viz);
         }
         else
         {
             Selected.Add(viz);
         }
     }
     else
     {
         Selected.Clear();
     }
 }
Beispiel #10
0
 public VizCmd(Viz viz, Cmd cmd, object obj = null)
 {
     this.viz = viz;
     this.cmd = cmd;
     this.obj = obj;
 }
Beispiel #11
0
        private static IEnumerable <VizCmd> cmInsert(Viz viz, System.Drawing.Point MouseLocation)
        {
            TimeMark tm = Global.Instance.Song.NormalizedTimeMark(Global.Lft + MouseLocation.X);

            return(Lyric.AddDialog("", tm));
        }
Beispiel #12
0
        private void RC3_MouseMove(object sender, MouseEventArgs e)
        {
            if (hovertimer == null)
            {
                hovertimer                     = new System.Timers.Timer(1000);
                hovertimer.AutoReset           = false;
                hovertimer.Enabled             = false;
                hovertimer.SynchronizingObject = this;
                hovertimer.Elapsed            += beginhover;
            }

            var song = Global.Instance.Song;

            if (song != null)
            {
                if (song.DragMode == DragMode.Predrag)
                {
                    if (!((Math.Abs(e.X - hoverpos.X) < Global.HoverDragSensitivity) && (Math.Abs(e.Y - hoverpos.Y) < Global.HoverDragSensitivity)))
                    {
                        song.DragMode = DragMode.Active;

                        if (!dragShift)
                        {
                            song.Selected.Clear();
                        }

                        dragCount = song.Selected.Count;

                        if ((CurrOver != null) && (CurrOver.IsSelectable))
                        {
                            if ((!song.Selected.Contains(CurrOver)) &&
                                ((song.Selected.Count == 0) ||
                                 ((CurrOver.IsMultiSelectable)
                                  //&& (song.Selected.Count > 0)
                                  && (CurrOver.GetType() == song.Selected[0].GetType()))))
                            {
                                song.Selected.Add(CurrOver);
                            }
                        }
                    }
                }
                if (song.DragMode == DragMode.Active)
                {
                    song.DragEnd = e.Location;
                    var dragBox = song.DragBox;
                    foreach (Viz viz in song.Vizs)
                    {
                        if (dragBox.Contains(viz.Rectangle))
                        {
                            if (!song.Selected.Contains(viz) && ((song.Selected.Count == 0) || (viz.GetType() == song.Selected[0].GetType())))
                            {
                                song.Selected.Add(viz);
                            }
                        }
                        else
                        {
                            if (song.Selected.IndexOf(viz) >= dragCount)
                            {
                                song.Selected.Remove(viz);
                            }
                        }
                    }
                }



                // toolStripStatusLabel2.Text = e.Location.ToString();

                int x = e.X;
                int y = e.Y;
                //int x1 = x + hScrollBar1.Value;
                int x1 = x + prioroffset;

                if (song != null && song.Vizs != null)
                {
                    var over = Enumerable.Reverse(song.Vizs).Where(s => s.StartPoint.X <= x1 && x1 <= s.EndPoint.X && s.StartPoint.Y <= y && y <= s.EndPoint.Y).FirstOrDefault();

                    if (over != CurrOver)
                    {
                        CurrOver = over;

                        //if (dragging)
                        //{
                        //	if ((dragOver != null) && dragOver.IsSelectable)
                        //	{
                        //		dragOver = CurrOver;
                        //		if ((!CurrOver.IsMultiSelectable) || (CurrOver.GetType() != song.Selected[0].GetType()))
                        //		{
                        //			song.Selected.Clear();
                        //		}
                        //		if (song.Selected.Contains(CurrOver))
                        //			song.Selected.Remove(CurrOver);
                        //		else
                        //			song.Selected.Add(CurrOver);
                        //	}
                        //}
                    }

                    if (over != null)
                    {
                        //over = x1 / 100 * 100;

                        if (prvover != over)
                        {
                            if (prvover != null)
                            {
                                //toolStripStatusLabel1.Text = "Leave:" + prvover.ToString();
                                endhover();
                            }
                        }
                        else
                        {
                            if (hoverMode == HoverMode.Prehover)
                            {
                                if ((Math.Abs(e.X - hoverpos.X) < Global.HoverDragSensitivity) && (Math.Abs(e.Y - hoverpos.Y) < Global.HoverDragSensitivity))
                                {
                                    return;
                                }

                                endhover();
                            }
                        }

                        //toolStripStatusLabel1.Text = "Over:" + over.ToString() + ":" + hoverstat.ToString();
                        if (hoverMode == HoverMode.Off)
                        {
                            if (over.HasToolTip)
                            {
                                //toolStripStatusLabel3.Text = "pre hover";
                                prvover   = over;
                                hoverMode = HoverMode.Prehover;
                                hoverpos  = e.Location;
                                hovertimer.Start();
                            }
                        }
                    }
                    else        // not/no longer over
                    {
                        if (prvover == null)
                        {
                            return;
                        }

                        endhover();

                        //toolStripStatusLabel3.Text = "leave:" + prvover.ToString();
                    }
                }
            }
        }
Beispiel #13
0
 private static IEnumerable <VizCmd> cmExit(Viz viz, System.Drawing.Point MouseLocation)
 {
     return(null);
 }
Beispiel #14
0
 private static IEnumerable <VizCmd> cmInsert(Viz viz, System.Drawing.Point MouseLocation) => null;
Beispiel #15
0
 private static IEnumerable <VizCmd> cmDelete(Viz viz, System.Drawing.Point MouseLocation) => Global.Instance.Song.cmDelete(viz);
Beispiel #16
0
 public PropDialogData(Func <PropDialogItem[]> GetPropDialogItems, Viz Viz, Action <Viz> Handler)
 {
     this.GetPropDialogItems = GetPropDialogItems;
     this.Viz     = Viz;
     this.Handler = Handler;
 }