Exemple #1
0
 public MadcaDisplay(PictureBox pBox)
 {
     PictureBox                = pBox;
     editorLaneEnvironment     = new EditorLaneEnvironment(new Size(pBox.Width / 2, pBox.Height));
     previewDisplayEnvironment = new PreviewDisplayEnvironment(new Point(pBox.Width / 2, 0), new Size(pBox.Width / 2, pBox.Height));
     Initialize();
 }
Exemple #2
0
 public MadcaDisplay(
     PictureBox pBox,
     EditorLaneEnvironment laneEnv,
     PreviewDisplayEnvironment previewEnv
     )
 {
     PictureBox                = pBox;
     editorLaneEnvironment     = laneEnv;
     previewDisplayEnvironment = previewEnv;
     Initialize();
 }
Exemple #3
0
        private void SetEventToDragLane()
        {
            Point?offset = null;
            Point?p      = null;
            var   key    = new KeyToken();

            PictureBox.MouseDown += (s, e) =>
            {
                if (KeyTokenHolder.Locked)
                {
                    return;
                }
                if (e.Button == MouseButtons.Middle && EditorLaneEnvironment.GetEditorLaneRegion(e.Location) == EditorLaneRegion.Lane)
                {
                    KeyTokenHolder.Lock(key);
                    offset            = new Point(EditorLaneEnvironment.OffsetXRaw, EditorLaneEnvironment.OffsetY);
                    p                 = e.Location;
                    PictureBox.Cursor = Cursors.Cross;
                }
            };
            PictureBox.MouseMove += (s, e) =>
            {
                if (!KeyTokenHolder.CanUnLock(key))
                {
                    return;
                }
                if (offset != null && p != null)
                {
                    editorLaneEnvironment.OffsetXRaw = offset.Value.X - (e.X - p.Value.X);
                    // NOTE: ある程度マウスが移動したときのみ縦方向の更新を行う(これをやらないと描画が不安定になる)
                    var diffY = offset.Value.Y + (e.Y - p.Value.Y) - EditorLaneEnvironment.OffsetY;
                    if (Math.Abs(diffY) > 10)
                    {
                        editorLaneEnvironment.OffsetY         += diffY;
                        previewDisplayEnvironment.TimingOffset = new TimingPosition(EditorLaneEnvironment.TimingUnitHeight.ToUInt(), EditorLaneEnvironment.OffsetY);
                    }
                }
            };
            PictureBox.MouseUp += (s, e) =>
            {
                if (!KeyTokenHolder.UnLock(key))
                {
                    return;
                }
                offset            = p = null;
                PictureBox.Cursor = Cursors.Default;
            };
        }
Exemple #4
0
        private void Initialize()
        {
            VScrollBar.Height   = PictureBox.Height;
            VScrollBar.Location = new Point(previewDisplayEnvironment.DisplayRegion.X - VScrollBar.Width / 2, PictureBox.Top);
            PictureBox.Controls.Add(VScrollBar);
            VScrollBar.Value = VScrollBar.Maximum - EditorLaneEnvironment.OffsetY;

            editorLaneEnvironment.OffsetYChanged += v =>
            {
                VScrollBar.Value = VScrollBar.Maximum - v;
            };

            VScrollBar.ValueChanged += (s, e) =>
            {
                editorLaneEnvironment.OffsetY          = VScrollBar.Maximum - VScrollBar.Value;
                previewDisplayEnvironment.TimingOffset = new TimingPosition(editorLaneEnvironment.TimingUnitHeight.ToUInt(), editorLaneEnvironment.OffsetY);
                PictureBox.Refresh();
            };

            PictureBox.SizeChanged += (s, e) =>
            {
                var halfSize = new Size(PictureBox.Width / 2, PictureBox.Height);
                editorLaneEnvironment.PanelRegion       = new Rectangle(new Point(), halfSize);
                previewDisplayEnvironment.DisplayRegion = new Rectangle(new Point(halfSize.Width, 0), halfSize);

                VScrollBar.Height   = PictureBox.Height;
                VScrollBar.Location = new Point(previewDisplayEnvironment.DisplayRegion.X - VScrollBar.Width / 2, PictureBox.Top);
            };

            PictureBox.MouseWheel += (s, e) =>
            {
                // NOTE: WHEEL_DELTAは120
                if (EditorLaneEnvironment.GetEditorLaneRegion(e.Location) == EditorLaneRegion.Lane)
                {
                    editorLaneEnvironment.OffsetXRaw -= e.Delta / 120 * (int)editorLaneEnvironment.LaneUnitWidth;
                    return;
                }
                if (EditorLaneEnvironment.PanelRegion.Contains(e.Location))
                {
                    if (Control.ModifierKeys.HasFlag(Keys.Shift))
                    {
                        var prevHeight = editorLaneEnvironment.TimingUnitHeight;
                        editorLaneEnvironment.TimingUnitHeight -= e.Delta / 10;
                        editorLaneEnvironment.OffsetY           = (int)(editorLaneEnvironment.TimingUnitHeight / (double)prevHeight * editorLaneEnvironment.OffsetY);
                        return;
                    }
                    editorLaneEnvironment.OffsetY         += e.Delta;
                    previewDisplayEnvironment.TimingOffset = new TimingPosition(editorLaneEnvironment.TimingUnitHeight.ToUInt(), editorLaneEnvironment.OffsetY);
                    return;
                }
                if (PreviewDisplayEnvironment.DisplayRegion.Contains(e.Location))
                {
                    var den = (e.Delta / 10).ToUInt();
                    if (den != 0)
                    {
                        previewDisplayEnvironment.TimingLength -= new TimingPosition((e.Delta / 10).ToUInt(), e.Delta < 0 ? -1 : 1);
                    }
                }
            };

            SetEventToDragLane();
        }