Пример #1
0
        private void splitTime(string filePath, StringBuilder sb)
        {
            //Load the data, add the clip ID lines and output in new file
            string[] origFile = getText(filePath);
            string splitTime = textBox2.Text;

            if (origFile == null)//if the source file is bad don't go to next part, the user warning comes in getText
            {
                return;
            }
            int[] timeArray = getTime(splitTime);//get the text time into numbers
            int[] invalidTime = { 0, 0, 0, 0 };
            if (timeArray[0] == invalidTime[0] && timeArray[1] == invalidTime[1] && timeArray[2] == invalidTime[2] && timeArray[3] == invalidTime[3])
            {
                return;
            }
            //Console.WriteLine(timeArray[0] + ":" + timeArray[1] + ":" + timeArray[2] + "." + timeArray[3]);

            //get the clip name
            string clipBaseName = origFile[2].Substring(2, origFile[2].Length - 3);

            //start outputting to a new file while modifying it
            // Set a variable to the My Documents path.
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //StringBuilder sb = new StringBuilder();

            //Start building the file
            int clipCount = 1;
            int segStart = 4;
            int segEnd = origFile.Length - 1;
            sb.AppendLine(origFile[0]);//write in the transcript name through the first segment
            sb.AppendLine();
            sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
            clipCount++;
            sb.AppendLine(origFile[segStart]);

            int runningTime = 0;//keep track of the current time in the ccs(in sec)
            int splitingTime = toSec(timeArray);
            bool hasSplit = false;
            for (int i = segStart + 1; i < segEnd; i++)
            {
                //get the times, find difference, add to running time
                //if running time is more than splitting time then split, otherwise keep going
                //once it is split go till end
                if (!hasSplit)
                {
                    //make substrings of the timestamps, format them, change to sec, and add to running time
                    //Then check to see if that time is greater than the splitting time
                    string segStartTime = origFile[i].Substring(22, 12);
                    string segEndTime = origFile[i].Substring(37, 12);
                    //Console.WriteLine(segStartTime + "-" + segEndTime);
                    int[] checkSegStartTime = getTime(segStartTime);
                    int[] checkSegEndTime = getTime(segEndTime);
                    runningTime += toSec(getTime(segEndTime)) - toSec(getTime(segStartTime));//add the difference in segment start and stop times
                    //Console.WriteLine(toSec(getTime(segEndTime)) + "-" + toSec(getTime(segStartTime)));
                    //Console.WriteLine(runningTime);
                    if (runningTime > splitingTime)
                    {
                        sb.AppendLine();
                        sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
                        clipCount++;
                        hasSplit = true;
                    }
                    sb.AppendLine(origFile[i]);
                }
                else
                {
                    sb.AppendLine(origFile[i]);
                }

            }

            // Write the stream contents to a new file with the file name + "EDIT".
            string fullPath = textBox1.Text;
            string fileName = fullPath.Substring(mydocpath.Length + 1, fullPath.Length - mydocpath.Length - 5);
            using (StreamWriter outfile = new StreamWriter(mydocpath + @"\" + fileName + "EDIT.ccs"))
            {
                outfile.Write(sb.ToString());
            }

            Completed prompt = new Completed();
            prompt.ShowDialog();
        }
Пример #2
0
        private void splitAll(string filePath, StringBuilder sb)
        {
            //Load the data, add the clip ID lines and output in new file
            string[] origFile = getText(filePath);
            if (origFile == null)//if the source file is bad don't go to next part, the user warning comes in getText
            {
                return;
            }

            //get the clip name
            string clipBaseName = origFile[2].Substring(2, origFile[2].Length - 3);

            //start outputting to a new file while modifying it
            // Set a variable to the My Documents path.
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //StringBuilder sb = new StringBuilder();

            //Start building the file
            int clipCount = 1;
            int segStart = 4;
            int segEnd = origFile.Length - 1;
            //sb.AppendLine(origFile[0]);
            //sb.AppendLine();
            for (int i = segStart; i < segEnd; i++)
            {
                sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
                sb.AppendLine(origFile[i]);
                sb.AppendLine();
                clipCount++;
            }

            // Write the stream contents to a new file with the file name + "EDIT".
            string fullPath = textBox1.Text;
            string fileName = fullPath.Substring(mydocpath.Length + 1, fullPath.Length - mydocpath.Length - 5);
            using (StreamWriter outfile = new StreamWriter(mydocpath + @"\" + fileName + "EDIT.ccs"))
            {
                outfile.Write(sb.ToString());
            }

            Completed prompt = new Completed();
            prompt.ShowDialog();
        }
Пример #3
0
        private void splitOrder(string filePath, StringBuilder sb)
        {
            //Load the data, add the clip ID lines and output in new file
            string[] origFile = getText(filePath);
            if (origFile == null)
            {
                return;
            }

            //get the clip name
            string clipBaseName = origFile[2].Substring(2, origFile[2].Length - 3);

            //start outputting to a new file while modifying it
            // Set a variable to the My Documents path.
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //StringBuilder sb = new StringBuilder();

            //Start building the file
            int clipCount = 1;
            int segStart = 4;
            int segEnd = origFile.Length - 1;
            sb.AppendLine(origFile[0]);//write in the transcript name through the first segment
            sb.AppendLine();
            sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
            clipCount++;
            sb.AppendLine(origFile[segStart]);

            for (int i = segStart + 1; i < segEnd; i++)//for every segment after compare its page/line to the one before, if it is less than split it
            {
                int firstPage = Convert.ToInt32(origFile[i - 1].Substring(0, 5));//grab all of the page/line numbers
                int firstLine = Convert.ToInt32(origFile[i - 1].Substring(6, 2));
                int secondPage = Convert.ToInt32(origFile[i].Substring(0, 5));
                int secondLine = Convert.ToInt32(origFile[i].Substring(6, 2));
                if (firstPage > secondPage)//add in a clip id if the first segment is greater than the second segment
                {
                    sb.AppendLine();
                    sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
                    clipCount++;
                }
                else if (firstPage == secondPage)
                {
                    if (firstLine > secondLine)
                    {
                        sb.AppendLine();
                        sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
                        clipCount++;
                    }
                }

                sb.AppendLine(origFile[i]);
            }

            // Write the stream contents to a new file with the file name + "EDIT".
            string fullPath = textBox1.Text;
            string fileName = fullPath.Substring(mydocpath.Length + 1, fullPath.Length - mydocpath.Length - 5);
            using (StreamWriter outfile = new StreamWriter(mydocpath + @"\" + fileName + "EDIT.ccs"))
            {
                outfile.Write(sb.ToString());
            }

            Completed prompt = new Completed();
            prompt.ShowDialog();
        }
Пример #4
0
        private void adjustEnd(string filePath, StringBuilder sb)
        {
            //takes the time from the textbox and the direction from the button then adjust the ending time of every segment
            string[] origFile = getText(filePath);
            if (origFile == null)
            {
                return;
            }
            string changeTime = adjustendText.Text;//get the change time
            Boolean adjustLater = false;//get the direction of the change
            if (adjustendBox.Text == "+")
            {
                adjustLater = true;
            }
            int changeMS = 0;
            try
            {
                changeMS = Int32.Parse(changeTime);
            }
            catch (Exception e)
            {
                Console.WriteLine("Invalid Time Code");
                InvalidTime errormessage = new InvalidTime();
                errormessage.ShowDialog();
                Console.WriteLine(e.Message);
                return;
            }

            //get the clip name
            string clipBaseName = origFile[2].Substring(2, origFile[2].Length - 3);

            //start outputting to a new file while modifying it
            // Set a variable to the My Documents path.
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //StringBuilder sb = new StringBuilder();

            //Start building the file
            int clipCount = 1;
            int segStart = 4;
            int segEnd = origFile.Length - 1;
            sb.AppendLine(origFile[0]);//write in the transcript name through the first segment
            sb.AppendLine();
            sb.AppendLine("C(" + clipBaseName + "-" + clipCount + ")");
            clipCount++;

            for (int i = segStart; i < segEnd; i++)
            {
                //get the start time, adjut it, rewrite that section of the line, and then append the line
                string segEndTime = origFile[i].Substring(37, 12);
                string output = origFile[i];
                string newSegEndTime = segEndTime;
                int[] checkSegEndTime = getTime(segEndTime);
                int currentMS = toMilSec(checkSegEndTime);//get the current time in milliseconds
                int newMS = currentMS;
                if (adjustLater)
                {
                    newMS = currentMS + changeMS;
                    newSegEndTime = milSecToString(newMS);
                    output = origFile[i].Substring(0, 37) + newSegEndTime + origFile[i].Substring(49, 1);
                }
                else
                {
                    newMS = currentMS - changeMS;
                    newSegEndTime = milSecToString(newMS);
                    output = origFile[i].Substring(0, 37) + newSegEndTime + origFile[i].Substring(49, 1);
                }
                sb.AppendLine(output);

            }

            // Write the stream contents to a new file with the file name + "EDIT".
            string fullPath = textBox1.Text;
            string fileName = fullPath.Substring(mydocpath.Length + 1, fullPath.Length - mydocpath.Length - 5);
            using (StreamWriter outfile = new StreamWriter(mydocpath + @"\" + fileName + "EDIT.ccs"))
            {
                outfile.Write(sb.ToString());
            }

            Completed prompt = new Completed();
            prompt.ShowDialog();
        }