예제 #1
0
        private void OldMergeSequences()
        {
            mergeTracks         = Properties.Settings.Default.MergeTracks;
            mergeTracksByName   = Properties.Settings.Default.MergeTracksByName;
            duplicateNameAction = Properties.Settings.Default.DuplicateNameAction;
            numberFormat        = Properties.Settings.Default.AddNumberFormat;

            bool matched = false;
            int  t2Idx   = 0;
            int  exIdx   = 0;


            List <Map> groupMap       = new List <Map>();
            List <Map> trackMap       = new List <Map>();
            List <Map> timingMap      = new List <Map>();
            int        newGroupCount  = 0;
            int        newTrackCount  = 0;
            int        newTimingCount = 0;

            /////////////////////
            //  TIMING GRIDS  //
            ///////////////////

            // Make sure existing time grids are in order (they should be, but make sure anyway)
            for (int t = 0; t < seqNew.TimingGrids.Count; t++)
            {
                seqNew.TimingGrids[t].timings.Sort();
            }

            for (int timings2Idx = 0; timings2Idx < seqTwo.TimingGrids.Count; timings2Idx++)
            {
                seqTwo.TimingGrids[timings2Idx].timings.Sort();
                matched = false;
                int matchingExTimingsGridIdx = utils.UNDEFINED;
                for (int exTimingGridsIdx = 0; exTimingGridsIdx < seqNew.TimingGrids.Count; exTimingGridsIdx++)
                {
                    // Compare names
                    if (seqTwo.TimingGrids[timings2Idx].CompareTo(seqNew.TimingGrids[exTimingGridsIdx]) == 0)
                    {
                        // Matching names found
                        matched = true;
                        matchingExTimingsGridIdx = exTimingGridsIdx;
                        exTimingGridsIdx         = seqNew.TimingGrids.Count; // Break out of loop
                    }
                }                                                            // end loop thru new sequence's timing grids
                if (matched)
                {
                    //MergeTimingGrids(timings2Idx, matchingExTimingsGridIdx);
                }
                else
                {
                    // No timing grid with matching name found, so add this one
                    // Create a new timing grid and copy the name and type
                    int newSaveID = seqNew.Members.HighestSaveID + 1;

                    TimingGrid tGrid = seqNew.CreateTimingGrid(seqTwo.TimingGrids[timings2Idx].Name);
                    //tGrid.type = seqTwo.TimingGrids[timings2Idx].type;
                    tGrid.spacing = seqTwo.TimingGrids[timings2Idx].spacing;
                    // Create a new array for timings, and copy them
                    tGrid.CopyTimings(seqTwo.TimingGrids[timings2Idx].timings, false);
                }         // end if matched, or not
            }             // end loop thru 2nd sequence's timing grids

            ///////////////
            //  TRACKS  //
            /////////////

            foreach (Track track2 in seqTwo.Tracks)
            //for (int tracks2Idx = 0; tracks2Idx < seqTwo.Tracks.Count; tracks2Idx++)
            {
                matched = false;
                if (mergeTracks)
                {
                    int matchedExTracksIdx = utils.UNDEFINED;
                    foreach (Track newTrack in seqNew.Tracks)
                    //for (int exTracksIdx = 0; exTracksIdx < seqNew.Tracks.Count; exTracksIdx++)
                    {
                        if (mergeTracksByName)
                        {
                            // Merge by Name
                            if (track2.CompareTo(newTrack) == 0)
                            {
                                matched = true;
                                t2Idx   = track2.Index;
                                exIdx   = newTrack.Index;
                                //exTracksIdx = seqNew.Tracks.Count; // Break out of loop
                                break;
                            }
                        }
                        else
                        {
                            // Merge by Number
                            if (track2.Index == newTrack.Index)
                            {
                                matched = true;
                                t2Idx   = track2.Index;
                                exIdx   = newTrack.Index;
                                //exTracksIdx = seqNew.trackCount; // Break out of loop
                                break;
                            }
                        }
                    }                     // New Sequence Track Loop
                    if (matched)
                    {
                        //MergeTracks(t2Idx, exIdx);

                        newTrackCount++;
                    }
                }



                ///////////////////////
                //  CHANNEL GROUPS  //
                /////////////////////

                foreach (ChannelGroup group2 in seqTwo.ChannelGroups)
                //for (int groups2Idx = 0; groups2Idx < seqTwo.channelGroupCount; groups2Idx++)
                {
                    int matchedExGroupsIdx = utils.UNDEFINED;
                    foreach (ChannelGroup newGroup in seqNew.ChannelGroups)
                    //for (int exGroupsIdx = 0; exGroupsIdx < seqNew.channelGroupCount; exGroupsIdx++)
                    {
                        matched = false;
                        if (group2.CompareTo(newGroup) == 0)
                        {
                            matchedExGroupsIdx = newGroup.Index;
                            //exGroupsIdx = seqNew.channelGroupCount;
                            break;
                        }
                        //Array.Resize(ref groupMap, newGroupCount + 1);
                        Map gm = new Map(group2, newGroup);
                        groupMap.Add(gm);
                        if (matchedExGroupsIdx == utils.UNDEFINED)
                        {
                            ChannelGroup group3 = seqNew.CreateChannelGroup(group2.Name);
                            gm = new Map(group3, newGroup);
                            groupMap.Add(gm);
                        }
                        else
                        {
                        }
                        newGroupCount++;
                    }



                    /////////////////////
                    //  RGB CHANNELS  //
                    ///////////////////



                    ///////////////////////////
                    //  (Regular) CHANNELS  //
                    /////////////////////////
                }
            }
        }
예제 #2
0
        private void MergeTimingGrids(TimingGrid destGrid, TimingGrid sourceGrid)
        {
            int t2Idx = 0;
            int exIdx = 0;

            if (sourceGrid.timings.Count > 0)
            {
                if (destGrid.timings.Count > 0)
                {
                    t2Idx = 0;
                    exIdx = 0;
                    int dir = 0;

                    List <int> t2Timings = sourceGrid.timings;
                    List <int> exTimings = destGrid.timings;

                    while ((t2Idx < t2Timings.Count) && (exIdx < exTimings.Count))
                    {
                        if (t2Idx == exIdx)
                        {
                            // Already there!  Do Nothing!
                            // Increment BOTH indexes
                            exIdx++;
                            t2Idx++;
                        }
                        else
                        {
                            if (t2Idx > exIdx)
                            {
                                // Haven't reached same point yet
                                // Increment new index
                                exIdx++;
                            }
                            else
                            {
                                // t2Idx < exIdx
                                // Didn't exist in new sequence
                                // Add it
                                destGrid.CopyTimings(sourceGrid.timings, true);
                                // Increment BOTH indexes
                                exIdx++;
                                t2Idx++;
                            }             // haven't reached it
                        }                 // Not already there
                    }                     // while indexes are below counts
                }
                else
                {
                    // Unlikely situation here, but nonetheless plausible
                    // Sequence2 and New Sequence have timing grids with the same name
                    // but in the New Sequence the grid is empty, and in Sequence2 it is not
                    // Names match, but are they the same type?  (might be why it's empty)
                    if (sourceGrid.TimingGridType == destGrid.TimingGridType)
                    {
                        // So--- Add all of them
                        //destGrid.itemCount = sourceGrid.itemCount;
                        //Array.Resize(ref seqTwo.TimingGrids[seqNewGridIdx].timings, sourceGrid.itemCount);
                        foreach (int tc in sourceGrid.timings)
                        //for (int t = 0; t < sourceGrid.itemCount; t++)
                        {
                            destGrid.timings.Add(tc);
                            //sourceGrid.timings[t];
                        }
                    }
                    else
                    {
                        //? Not sure what to do here
                        string sMsg = "Help!  This situation was not programmed for!\r\n";
                        sMsg += "Both sequences contain a timing grid named '" + sourceGrid.Name;
                        sMsg += "' but they are not the same type!\r\n";
                        sMsg += "It is highly recommended that you rename one (or both) of the timing grids in one (or both) ";
                        sMsg += "sequences and re-perform this merge.";
                        MessageBox.Show(this, sMsg, "Grid Conflict", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }         // end new timing grid has timings (or not)
            }             // end 2nd timing grid had items
        }
예제 #3
0
        private void MergeSequences()
        {
            mergeTracks         = Properties.Settings.Default.MergeTracks;
            mergeTracksByName   = Properties.Settings.Default.MergeTracksByName;
            duplicateNameAction = Properties.Settings.Default.DuplicateNameAction;
            mergeEffects        = Properties.Settings.Default.MergeEffects;
            numberFormat        = Properties.Settings.Default.AddNumberFormat;

            bool matched = false;
            int  exIdx   = 0;


            List <Map> groupMap       = new List <Map>();
            List <Map> trackMap       = new List <Map>();
            List <Map> timingMap      = new List <Map>();
            int        newGroupCount  = 0;
            int        newTrackCount  = 0;
            int        newTimingCount = 0;
            bool       found          = false;



            /////////////////////
            //  TIMING GRIDS  //
            ///////////////////
            if (mergeGrids)
            {
                for (int g2Idx = 0; g2Idx < seqTwo.TimingGrids.Count; g2Idx++)
                {
                    TimingGrid sourceGrid = seqTwo.TimingGrids[g2Idx];
                    sourceGrid.timings.Sort();
                    TimingGrid destGrid = null;
                    // Grids treated like tracks.  Merge or Append?
                    if (mergeTracks)
                    {
                        found = true;                         // Reset to default
                        // Search for it, do NOT create if not found
                        destGrid = (TimingGrid)seqNew.Members.Find(sourceGrid.Name, MemberType.TimingGrid, false);
                        if (destGrid == null)                         // no match found
                        {
                            found    = false;
                            destGrid = seqNew.CreateTimingGrid(sourceGrid.Name);
                        }
                        else                         // match found!
                        {
                            // Check for conflicting types and warn user
                            if (sourceGrid.TimingGridType == TimingGridType.FixedGrid)
                            {
                                if (destGrid.TimingGridType == TimingGridType.Freeform)
                                {
                                    GridMismatchError(sourceGrid.Name);
                                }
                            }
                            if (sourceGrid.TimingGridType == TimingGridType.Freeform)
                            {
                                if (destGrid.TimingGridType == TimingGridType.FixedGrid)
                                {
                                    GridMismatchError(sourceGrid.Name);
                                }
                            }
                            // What to do if match is found?
                            if (duplicateNameAction == ACTIONkeepBoth)
                            {
                                destGrid = seqNew.CreateTimingGrid(sourceGrid.Name);
                            }
                            if (duplicateNameAction == ACTIONaddNumber)
                            {
                                destGrid = seqNew.CreateTimingGrid(sourceGrid.Name + " (2)");
                            }
                            if (duplicateNameAction == ACTIONuseSecond)
                            {
                                destGrid.timings.Clear();
                            }
                        }
                    }
                    else                     // Append
                    {
                        destGrid = seqNew.CreateTimingGrid(sourceGrid.Name);
                        destGrid.TimingGridType = sourceGrid.TimingGridType;
                    }                     // Enbd if merge or append

                    // if not found, or any action other than keep first
                    if (!found || (duplicateNameAction != ACTIONkeepFirst))
                    {
                        // Copy type, spacing and timings
                        destGrid.TimingGridType = sourceGrid.TimingGridType;
                        destGrid.spacing        = sourceGrid.spacing;
                        if (destGrid.TimingGridType == TimingGridType.Freeform)
                        {
                            destGrid.CopyTimings(sourceGrid.timings, false);
                        }
                    }
                }         // end loop thru 2nd sequence's timing grids
            }             // if Merge Grids

            ///////////////
            //  TRACKS  //
            /////////////

            if (mergeTracks)
            {
                //foreach (Track track2 in seqTwo.Tracks)
                for (int t2Idx = 0; t2Idx < seqTwo.Tracks.Count; t2Idx++)
                {
                    Track sourceTrack = seqTwo.Tracks[t2Idx];
                    Track destTrack   = null;
                    if (mergeTracksByNumber)
                    {
                        // Merge by number or name?
                        // If by number, do we even have that many in the destination?
                        if (t2Idx < seqNew.Tracks.Count)
                        {
                            destTrack = seqNew.Tracks[t2Idx];
                        }
                        else
                        {
                            // Not enough, make one
                            destTrack = seqNew.CreateTrack(sourceTrack.Name);
                        }
                    }
                    if (mergeTracksByName)
                    {
                        found     = true;                     // reset to default
                        destTrack = (Track)seqNew.Members.Find(sourceTrack.Name, MemberType.Track, false);
                        if (destTrack == null)                // no matching name found
                        {
                            found     = false;
                            destTrack = seqNew.CreateTrack(sourceTrack.Name);
                        }
                        else                         // matching name found!
                        {
                        }
                    }
                    if (appendTracks)
                    {
                        destTrack = seqNew.CreateTrack(sourceTrack.Name);
                    }
                    MergeMembers(destTrack.Members, sourceTrack.Members);

                    Console.WriteLine(destTrack.Name);
                }
            }
        }