コード例 #1
0
        public void OutlineClipVideoHover(
            Graphics g,
            VidkaClipVideo vclip,
            ProjectDimensions dimdim,
            int Height,
            TrimDirection trimDirection,
            int trimBracketLength,
            long framesActiveMouseTrim)
        {
            int y1 = dimdim.getY_main1(Height);
            int y2 = dimdim.getY_main2(Height);
            //int yaudio = dimdim.getY_main_half(Height);
            int x1    = dimdim.getScreenX1(vclip);
            int clipW = dimdim.convert_FrameToAbsX(vclip.LengthFrameCalc);             // hacky, I know

            g.DrawRectangle(penHover, x1, y1, clipW, y2 - y1);
            if (trimDirection == TrimDirection.Left)
            {
                drawTrimBracket(g, x1, y1, y2, TrimDirection.Left, trimBracketLength, dimdim.convert_FrameToAbsX(framesActiveMouseTrim), dimdim);
            }
            if (trimDirection == TrimDirection.Right)
            {
                drawTrimBracket(g, x1 + clipW, y1, y2, TrimDirection.Right, trimBracketLength, dimdim.convert_FrameToAbsX(framesActiveMouseTrim), dimdim);
            }
        }
コード例 #2
0
        private void DrawWaveform(
            Graphics g,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            VidkaClipVideo vclip,
            int x1, int y1, int clipw, int cliph,
            double secStart, double secEnd)
        {
            // TODO: tmp!!! please use a cache or something u idiot, dont read the f*****g file on every paint
            string waveFile = projMapping.AddGetWaveFilenameJpg(vclip.FileName);

            if (File.Exists(waveFile))
            {
                Bitmap bmpWave = imgCache.getWaveImg(waveFile);                         //Image ot
                var    xSrc1   = (int)(bmpWave.Width * secStart / vclip.FileLengthSec); //TODO: this
                var    xSrc2   = (int)(bmpWave.Width * secEnd / vclip.FileLengthSec);
                srcRect.X       = xSrc1;
                srcRect.Width   = xSrc2 - xSrc1;
                srcRect.Y       = 0;
                srcRect.Height  = bmpWave.Height;                //TODO: use constant from Ops
                destRect.X      = x1;
                destRect.Y      = y1;
                destRect.Width  = clipw;
                destRect.Height = cliph;
                g.DrawImage(bmpWave, destRect: destRect, srcRect: srcRect, srcUnit: GraphicsUnit.Pixel);
            }
        }
コード例 #3
0
 internal void SetDraggyVideo(VidkaClipVideo clip)
 {
     if (Draggy.VideoClip != clip)
     {
         stateChanged = true;
     }
     Draggy.VideoClip = clip;
 }
コード例 #4
0
 /// <summary>
 /// There can only be one hover b/w video and audio line, so audio will be set to null
 /// </summary>
 public void SetHoverVideo(VidkaClipVideo hover)
 {
     if (CurrentVideoClipHover != hover ||
         CurrentAudioClipHover != null)
     {
         stateChanged = true;
     }
     CurrentVideoClipHover = hover;
     CurrentAudioClipHover = null;
 }
コード例 #5
0
        private void StartPlaybackOfClip(VidkaClipVideo clip, long?frameOffsetCustom = null)
        {
            mutex.CurClipAbsFrameLeft = mutex.Proj.GetVideoClipAbsFramePositionLeft(clip);
            mutex.CurClipStartFrame   = clip.FrameStart;
            var clipSecStart = mutex.Proj.FrameToSec(frameOffsetCustom ?? clip.FrameStart); //hacky, i know
            var clipSecEnd   = mutex.Proj.FrameToSec(clip.FrameEnd);                        //hacky, i know

            mutex.CurStopPositionSec = clipSecEnd;
            editor.SetCurrentVideoClip_ForceRepaint(clip);
            player.PlayVideoClip(clip.FileName, clipSecStart, clipSecEnd);
        }
コード例 #6
0
        public int getScreenX1(VidkaClipVideo vclip)
        {
            long frameTotal = 0;

            foreach (var ccc in proj.ClipsVideo)
            {
                if (ccc == vclip)
                {
                    break;
                }
                frameTotal += ccc.LengthFrameCalc;
            }
            return(convert_Frame2ScreenX(frameTotal));
        }
コード例 #7
0
 /// <summary>
 /// There can only be one selected (active) b/w video and audio line, so audio will be set to null
 /// Needs proj to find absolute frame position (CurrentClipFrameAbsPos)
 /// </summary>
 public void SetActiveVideo(VidkaClipVideo active, VidkaProj proj)
 {
     if (CurrentVideoClip != active ||
         CurrentAudioClip != null)
     {
         stateChanged = true;
         originalTimelineSelectionChanged = true;
         SetOriginalTimelinePlaybackMode(false);
     }
     CurrentVideoClip       = active;
     CurrentAudioClip       = null;
     CurrentClipFrameAbsPos = (active != null)
                         ? (long?)proj.GetVideoClipAbsFramePositionLeft(active)
                         : null;
 }
コード例 #8
0
        /// <param name="secStart">needs to be in seconds to figure out which thumb</param>
        /// <param name="len">needs to be in seconds to figure out which thumb</param>
        private void DrawClipBitmaps(
            Graphics g,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            VidkaClipVideo vclip,
            int x1, int y1, int clipw, int clipvh,
            double secStart, double len)
        {
            string thumbsFile = projMapping.AddGetThumbnailFilename(vclip.FileName);
            //if (!File.Exists(thumbsFile))
            //	return;
            //Image origThumb = System.Drawing.Image.FromFile(thumbsFile, true);
            //var bmpThumb = new Bitmap(origThumb);
            var heightForThumbs = Math.Max(clipvh - 2 * THUMB_MARGIN_Y, ThumbnailTest.ThumbH);
            var thumbPrefWidth  = heightForThumbs * ThumbnailTest.ThumbW / ThumbnailTest.ThumbH;
            var howManyThumbs   = (clipw - THUMB_MARGIN) / (thumbPrefWidth + THUMB_MARGIN);

            if (howManyThumbs == 0)
            {
                howManyThumbs = 1;
            }
            var xCenteringOffset = (clipw - howManyThumbs * (thumbPrefWidth + THUMB_MARGIN)) / 2;

            for (int i = 0; i < howManyThumbs; i++)
            {
                //DrawVideoThumbnail(
                //	g: g,
                //	bmpAll: bmpThumb,
                //	timeSec: secStart + (i + 0.5) * len / howManyThumbs,
                //	xCenter: x1 + xCenteringOffset + i * (thumbPrefWidth + THUMB_MARGIN) + (thumbPrefWidth + THUMB_MARGIN) / 2,
                //	yCenter: y1 + clipvh / 2,
                //	preferredWidth: thumbPrefWidth,
                //	maxWidth: clipw);
                var timeSec    = secStart + (i + 0.5) * len / howManyThumbs;
                var imageIndex = (int)(timeSec / ThumbnailTest.ThumbIntervalSec);
                DrawVideoThumbnail(
                    g: g,
                    filenameAll: thumbsFile,
                    index: imageIndex,
                    xCenter: x1 + xCenteringOffset + i * (thumbPrefWidth + THUMB_MARGIN) + (thumbPrefWidth + THUMB_MARGIN) / 2,
                    yCenter: y1 + clipvh / 2,
                    preferredWidth: thumbPrefWidth,
                    maxWidth: clipw);
            }
            //bmpThumb.Dispose();
            //origThumb.Dispose();
        }
コード例 #9
0
        private void drawVideoClip(Graphics g,
                                   VidkaClipVideo vclip,
                                   long curFrame, int y1, int cliph, int clipvh,
                                   Brush brushClip,
                                   VidkaProj proj,
                                   VidkaFileMapping projMapping,
                                   ProjectDimensions dimdim)
        {
            int x1    = dimdim.convert_Frame2ScreenX(curFrame);
            int x2    = dimdim.convert_Frame2ScreenX(curFrame + vclip.LengthFrameCalc);
            int clipw = x2 - x1;

            // active video clip deserves a special outline, fill white otherwise to hide gray background
            g.FillRectangle(brushClip, x1, y1, clipw, clipvh);
            DrawClipBitmaps(
                g: g,
                proj: proj,
                projMapping: projMapping,
                vclip: vclip,
                x1: x1,
                y1: y1,
                clipw: clipw,
                clipvh: clipvh,
                secStart: proj.FrameToSec(vclip.FrameStart),
                len: proj.FrameToSec(vclip.LengthFrameCalc));
            DrawWaveform(g, proj, projMapping, vclip, x1, y1 + clipvh, clipw, cliph - clipvh,
                         proj.FrameToSec(vclip.FrameStart), proj.FrameToSec(vclip.FrameEnd));
            if (vclip.IsMuted)
            {
                g.FillRectangle(brushHazyMute, x1, y1 + clipvh, x2 - x1, cliph - clipvh);
            }
            // waveform separator
            g.DrawLine(penGray, x1, y1 + clipvh, x2, y1 + clipvh);
            // outline rect
            g.DrawRectangle(penDefault, x1, y1, clipw, cliph);
            // still analyzing...
            if (vclip.IsNotYetAnalyzed)
            {
                g.DrawString("Still analyzing...", fontDefault, brushDefault, x1 + 5, y1 + 5);
            }
        }
コード例 #10
0
        internal void DrawCurrentClipVideo(
            Graphics g,
            VidkaClipVideo vclip,
            ProjectDimensions dimdim,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            int w, int h,
            OutlineClipType type,
            bool isOriginalPlaybackMode,
            TrimDirection trimDirection,
            int trimBracketLength,
            long markerFrame,
            long selectedClipFrameOffset,
            long framesActiveMouseTrim)
        {
            int yMainTop   = dimdim.getY_main1(h);
            int xMain1     = dimdim.getScreenX1(vclip);
            int xMain2     = xMain1 + dimdim.convert_FrameToAbsX(vclip.LengthFrameCalc);    //hacky, I know
            int xMainDelta = dimdim.convert_FrameToAbsX(framesActiveMouseTrim);             //hacky, I know
            int xOrig1     = dimdim.convert_Frame2ScreenX_OriginalTimeline(vclip.FrameStart, vclip.FileLengthFrames, w);
            int xOrig2     = dimdim.convert_Frame2ScreenX_OriginalTimeline(vclip.FrameEnd, vclip.FileLengthFrames, w);
            int xOrigDelta = dimdim.convert_Frame2ScreenX_OriginalTimeline(framesActiveMouseTrim, vclip.FileLengthFrames, w);             // hacky, I know
            int y1         = dimdim.getY_original1(h);
            int y2         = dimdim.getY_original2(h);
            int yaudio     = dimdim.getY_original_half(h);

            // draw entire original clip (0 .. vclip.FileLength)
            g.FillRectangle(brushWhite, 0, y1, w, y2 - y1);
            g.FillRectangle(brushActive, xOrig1, y1, xOrig2 - xOrig1, y2 - y1);
            DrawClipBitmaps(g, proj, projMapping, vclip, 0, y1, w, yaudio - y1, 0, vclip.FileLengthSec ?? 0);
            DrawWaveform(g, proj, projMapping, vclip, 0, yaudio, w, y2 - yaudio, 0, vclip.FileLengthSec ?? 0);
            if (vclip.IsMuted)
            {
                g.FillRectangle(brushHazyMute, xOrig1, yaudio, xOrig2 - xOrig1, y2 - yaudio);
            }
            g.DrawLine(penGray, 0, yaudio, w, yaudio);
            g.DrawRectangle(penDefault, 0, y1, w, y2 - y1);

            //draw clip bounds
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xMain1, yMainTop, xOrig1, y2);
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xMain2, yMainTop, xOrig2, y2);
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xOrig1, y1, xOrig1, y2);
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xOrig2, y1, xOrig2, y2);
            if (type == OutlineClipType.Hover)
            {
                if (trimDirection == TrimDirection.Left)
                {
                    g.DrawLine(penActiveBoundary, xMain1 + xMainDelta, yMainTop, xOrig1 + xOrigDelta, y2);
                    drawTrimBracket(g, xOrig1, y1, y2, TrimDirection.Left, trimBracketLength, xOrigDelta, dimdim);
                }
                if (trimDirection == TrimDirection.Right)
                {
                    g.DrawLine(penActiveBoundary, xMain2 + xMainDelta, yMainTop, xOrig2 + xOrigDelta, y2);
                    drawTrimBracket(g, xOrig2, y1, y2, TrimDirection.Right, trimBracketLength, xOrigDelta, dimdim);
                }
            }

            // draw marker on
            var frameOffset = isOriginalPlaybackMode
                                ? markerFrame
                                : markerFrame - selectedClipFrameOffset + vclip.FrameStart;
            int xMarker = dimdim.convert_Frame2ScreenX_OriginalTimeline(frameOffset, vclip.FileLengthFrames, w);

            g.DrawLine(penMarker, xMarker, y1, xMarker, y2);
        }
コード例 #11
0
        public void DrawProjectVideoTimeline(
            Graphics g,
            int Width,
            int Height,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            ProjectDimensions dimdim,
            VidkaClipVideo currentVideoClip,
            EditorDraggy draggy)
        {
            // draw video events
            long curFrame = 0;

            int y1     = dimdim.getY_main1(Height);
            int y2     = dimdim.getY_main2(Height);
            int yaudio = dimdim.getY_main_half(Height);
            int cliph  = y2 - y1;            // clip height (video and audio)
            int clipvh = yaudio - y1;        // clip (only video) height (just the video part, no audio!)
            int index  = 0;
            int draggyVideoShoveIndex = dimdim.GetVideoClipDraggyShoveIndex(draggy);

            foreach (var vclip in proj.ClipsVideo)
            {
                if (dimdim.isEvenOnTheScreen(curFrame, curFrame + vclip.LengthFrameCalc, Width))
                {
                    if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index)
                    {
                        drawDraggyVideo(g, curFrame, y1, cliph, clipvh, draggy, dimdim);
                        curFrame += draggy.FrameLength;
                    }

                    if (draggy.VideoClip != vclip)
                    {
                        var brush = brushWhite;
                        if (vclip == currentVideoClip && vclip.IsLocked)
                        {
                            brush = brushLockedActiveClip;
                        }
                        else if (vclip == currentVideoClip)
                        {
                            brush = brushActive;
                        }
                        else if (vclip.IsLocked)
                        {
                            brush = brushLockedClip;
                        }
                        drawVideoClip(g, vclip,
                                      curFrame, y1, cliph, clipvh,
                                      brush,
                                      proj, projMapping, dimdim
                                      );
                    }
                }

                index++;
                if (draggy.VideoClip != vclip)
                {
                    curFrame += vclip.LengthFrameCalc;
                }
            }

            if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index)
            {
                drawDraggyVideo(g, curFrame, y1, cliph, clipvh, draggy, dimdim);
            }
        }
コード例 #12
0
ファイル: Utils.cs プロジェクト: exploitativetext/VidkaEditor
        public static void SetFrameMarker_RightOfVClipJustBefore(this ISomeCommonEditorOperations iEditor, VidkaClipVideo vclip, VidkaProj proj)
        {
            long frameMarker       = proj.GetVideoClipAbsFramePositionLeft(vclip);
            var  rightThreshFrames = proj.SecToFrame(Settings.Default.RightTrimMarkerOffsetSeconds);

            // if clip is longer than RightTrimMarkerOffsetSeconds, we can skip to end-RightTrimMarkerOffsetSeconds
            if (vclip.LengthFrameCalc > rightThreshFrames)
            {
                frameMarker += vclip.LengthFrameCalc - rightThreshFrames;
            }
            iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
        }
コード例 #13
0
ファイル: Utils.cs プロジェクト: exploitativetext/VidkaEditor
        public static void SetFrameMarker_LeftOfVClip(this ISomeCommonEditorOperations iEditor, VidkaClipVideo vclip, VidkaProj proj)
        {
            long frameMarker = proj.GetVideoClipAbsFramePositionLeft(vclip);

            iEditor.SetFrameMarker_ShowFrameInPlayer(frameMarker);
        }