示例#1
0
        void AddWiew()
        {
            try
            {
                // Invoke from main thread
                Action AddDele = AddWiew;
                if (ui.InvokeRequired)
                {
                    ui.Invoke(AddDele, new object[] { });
                    return;
                }

                var view = new WaveView();
                view.Top    = 0;
                view.Left   = 0;
                view.Height = ui.TabControlWaves.Height - 30;
                view.Width  = ui.TabControlWaves.ClientSize.Width - 8;
                view.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);                 // Resize waveView with the window
                view.ZoomX  = 0.1;
                Double.TryParse(ui.textBoxZoomX.Text, out view.ZoomX);

                var page = new TabPage("");
                ui.TabControlWaves.TabPages.Add(page);
                page.Controls.Add(view);
                ui.Views.Add(view);
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to add new view to the GUI\n" + e.Message);
            }
        }
示例#2
0
        public BounceView()
        {
            ballView = new BallView();
            waveView = new WaveView();

            ballView.Hidden = true;

            AddSubview(ballView);
            AddSubview(waveView);

            waveView.didEndPull = () =>
            {
                Helpers.CreateScheduledTimer(0.2, () =>
                {
                    ballView.Hidden = false;
                    ballView.StartAnimation();
                });
            };

            BallSize = 28f;
            BallMovementTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut);
            BallMoveUpDuration = 0.2;
            BallMoveUpDistance = 32f * 1.5f;
            BallViewHeight = 100f;
            WaveBounceDuration = 0.8;
            BallColor = UIColor.White;
            WaveColor = UIColor.White;
        }
示例#3
0
        /// <summary>
        /// Calculate the points of a match that are used to draw the GUI connection lines.
        /// </summary>
        /// <param name="match"></param>
        /// <param name="waveViewMappings"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns>true if the match is visible and should be drawn, else false</returns>
        private bool CalculatePoints(Match match, Dictionary <AudioTrack, WaveView> waveViewMappings, out Point p1, out Point p2)
        {
            WaveView waveView1  = waveViewMappings[match.Track1];
            long     timestamp1 = waveView1.AudioTrack.Offset.Ticks + match.Track1Time.Ticks;

            p1 = waveView1.TranslatePoint(new Point(waveView1.VirtualToPhysicalIntervalOffset(timestamp1), 0), this);

            WaveView waveView2  = waveViewMappings[match.Track2];
            long     timestamp2 = waveView2.AudioTrack.Offset.Ticks + match.Track2Time.Ticks;

            p2 = waveView2.TranslatePoint(new Point(waveView2.VirtualToPhysicalIntervalOffset(timestamp2), 0), this);

            if (p1.Y < p2.Y)
            {
                p1.Y += waveView1.ActualHeight;
            }
            else
            {
                p2.Y += waveView2.ActualHeight;
            }

            // make p1 always the left point, p2 the right point
            if (p1.X > p2.X)
            {
                CommonUtil.Swap <Point>(ref p1, ref p2);
            }

            // find out if a match is invisible and can be skipped
            double bx1 = 0;           // x-coord of left drawing boundary
            double bx2 = ActualWidth; // x-coord of right drawing boundary

            if ((p1.X >= bx1 && p1.X <= bx2) ||
                (p2.X >= bx1 && p2.X <= bx2) ||
                (p1.X < bx1 && p2.X > bx2) ||
                (p2.X < bx1 && p1.X > bx2))
            {
                // calculate bounded line drawing coordinates to avoid that lines with very long lengths need to be rendered
                // drawing of lines with lengths > 100000 is very very slow or makes the application even stop
                double k = (p2.Y - p1.Y) / (p2.X - p1.X); // line gradient
                // the following only works for cases realiably where p1 is always the left point
                if (p1.X < bx1)
                {
                    double delta = Math.Abs(p1.X - bx1);
                    p1.X += delta;
                    p1.Y += k * delta;
                }
                if (p2.X > bx2)
                {
                    double delta = Math.Abs(p2.X - bx2);
                    p2.X -= delta;
                    p2.Y -= k * delta;
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
示例#4
0
 public WaveFormTouchListener(WaveformViewExtended waveformView, FrameLayout fragmentContainer, WaveView element) :
     this()
 {
     mWaveformView          = waveformView;
     _fragmentContainer     = fragmentContainer;
     _element               = element;
     seekableBackgroundView = new AView(Application.Context);
     seekableBackgroundView.SetBackgroundColor(Android.Graphics.Color.ParseColor("#85000000"));
 }
示例#5
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (multiTrackListBox.ItemsSource == null || !multiTrackListBox.ItemsSource.GetEnumerator().MoveNext())
            {
                return;
            }

            // NOTE the dictionary needs to be built every time because the ListBox.items.CollectionChanged event is inaccessible (protected)
            Dictionary <AudioTrack, WaveView> waveViewMappings = new Dictionary <AudioTrack, WaveView>();

            foreach (AudioTrack audioTrack in multiTrackListBox.ItemsSource)
            {
                ListBoxItem      item = (ListBoxItem)multiTrackListBox.ItemContainerGenerator.ContainerFromItem(audioTrack);
                ContentPresenter itemContentPresenter = UIUtil.FindVisualChild <ContentPresenter>(item);
                DataTemplate     itemDataTemplate     = itemContentPresenter.ContentTemplate;
                WaveView         waveView             = (WaveView)itemDataTemplate.FindName("waveView", itemContentPresenter);
                waveViewMappings.Add(audioTrack, waveView);
            }

            Point p1, p2;

            foreach (Match match in Matches)
            {
                WaveView waveView1 = waveViewMappings[match.Track1];
                WaveView waveView2 = waveViewMappings[match.Track2];
                if (!CalculatePoints(match, waveViewMappings, out p1, out p2))
                {
                    continue;
                }

                if (waveView1 != waveView2)
                {
                    Color c = colors[(int)(match.Similarity * (colors.Length - 1))];
                    drawingContext.DrawLine(new Pen(new SolidColorBrush(c), 3)
                    {
                        DashStyle    = DashStyles.Solid,
                        EndLineCap   = PenLineCap.Triangle,
                        StartLineCap = PenLineCap.Triangle
                    }, p1, p2);
                }

                // draw selected match
                if (selectedMatches.Contains(match))
                {
                    DrawTriangle(drawingContext, Brushes.Red, p1, p1.Y > p2.Y ? 6 : -6); // top triangle
                    DrawTriangle(drawingContext, Brushes.Red, p2, p1.Y > p2.Y ? -6 : 6); // bottom triangle
                }
            }
        }
        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// The contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.DoubleBuffered = true;

            this.SuspendLayout();
            // 
            // WaveView
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "WaveView";

            _waveformView = new WaveView();
            _horScaleBar = new HorizontalScaleBar();
            _verScaleBar = new VerticalScaleBar();

            this.Controls.AddRange(new System.Windows.Forms.Control[] { _waveformView, _horScaleBar, _verScaleBar });

            this.Size = new System.Drawing.Size(554, 231);
            this.ResumeLayout(false);

        }
示例#7
0
 // Use this for initialization
 void Start()
 {
     wave = new WaveView();
 }
示例#8
0
        void AddWiew()
        {
            try
            {
                // Invoke from main thread
                Action AddDele = AddWiew;
                if (ui.InvokeRequired)
                {
                    ui.Invoke(AddDele, new object[] { });
                    return;
                }

                var view = new WaveView();
                view.Top = 0;
                view.Left = 0;
                view.Height = ui.TabControlWaves.Height - 30;
                view.Width = ui.TabControlWaves.ClientSize.Width - 8;
                view.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); // Resize waveView with the window
                view.ZoomX = 0.1;
                Double.TryParse(ui.textBoxZoomX.Text, out view.ZoomX);

                var page = new TabPage("");
                ui.TabControlWaves.TabPages.Add(page);
                page.Controls.Add(view);
                ui.Views.Add(view);
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to add new view to the GUI\n" + e.Message);
            }
        }