示例#1
0
        public int CreateSegmentSuitabilityBitfield(PsaiProject parentProject)
        {
            int bitfield = 0;

            if (this.IsAutomaticBridgeSegment || this.IsBridgeSnippetToAnyGroup(parentProject))
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.bridge);
            }

            if (this.IsUsableAtStart)
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.start);
            }

            if (this.IsUsableInMiddle)
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.middle);
            }

            if (this.IsUsableAtEnd)
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.end);
            }

            return(bitfield);
        }
示例#2
0
        internal psai.net.Soundtrack CreatePsaiDotNetVersion(PsaiProject parentProject)
        {
            psai.net.Soundtrack netSoundtrack = new psai.net.Soundtrack();

            foreach (Theme theme in Themes)
                netSoundtrack.m_themes.Add(theme.Id, theme.CreatePsaiDotNetVersion());

            foreach (Segment segment in Segments)
                netSoundtrack.m_snippets.Add(segment.Id, segment.CreatePsaiDotNetVersion(parentProject));

            return netSoundtrack;
        }
示例#3
0
        internal ProtoBuf_PsaiCoreSoundtrack CreateProtoBuf(PsaiProject parentProject)
        {
            ProtoBuf_PsaiCoreSoundtrack pbSoundtrack = new ProtoBuf_PsaiCoreSoundtrack();

            pbSoundtrack.audioformat = AudioFormat;

            foreach (Theme theme in Themes)
                pbSoundtrack.themes.Add(theme.CreateProtoBuf());

            foreach (Segment segment in Segments)
                pbSoundtrack.snippets.Add(segment.CreateProtoBuf(parentProject));

            return pbSoundtrack;
        }
示例#4
0
        // This method will create the HashSet of compatibleSnippets based on the ManuallyBlocked / ManuallyLinked entities.
        // The CompatibleSnippets HashSet is only needed for import, or to build the .pcb file.
        public void BuildCompatibleSegmentsSet(PsaiProject project)
        {
            HashSet <Segment> allSegments = project.GetSegmentsOfAllThemes();

            CompatibleSnippetsIds.Clear();
            foreach (Segment targetSegment in allSegments)
            {
                bool compatible                       = false;
                CompatibilityReason reason            = CompatibilityReason.not_set;
                CompatibilityType   compatibilityType = this.GetCompatibilityType(targetSegment, out reason);

                switch (compatibilityType)
                {
                /*
                 * case CompatibilityType.allowed_always:
                 *  compatible = true;
                 *  break;
                 */

                case CompatibilityType.allowed_implicitly:
                    compatible = true;
                    break;

                case CompatibilityType.allowed_manually:
                    compatible = true;
                    break;

                default:
                    compatible = false;
                    break;
                }

                if (compatible)
                {
                    float compatibility;
                    if (targetSegment.Group == this.Group)
                    {
                        compatibility = COMPATIBILITY_PERCENTAGE_SAME_GROUP;
                    }
                    else
                    {
                        compatibility = COMPATIBILITY_PERCENTAGE_OTHER_GROUP;
                    }

                    this.AddCompatibleSnippet(targetSegment, compatibility);
                }
            }
        }
示例#5
0
        internal psai.net.Soundtrack CreatePsaiDotNetVersion(PsaiProject parentProject)
        {
            psai.net.Soundtrack netSoundtrack = new psai.net.Soundtrack();

            foreach (Theme theme in Themes)
            {
                netSoundtrack.m_themes.Add(theme.Id, theme.CreatePsaiDotNetVersion());
            }

            foreach (Segment segment in Segments)
            {
                netSoundtrack.m_snippets.Add(segment.Id, segment.CreatePsaiDotNetVersion(parentProject));
            }

            return(netSoundtrack);
        }
示例#6
0
        internal ProtoBuf_PsaiCoreSoundtrack CreateProtoBuf(PsaiProject parentProject)
        {
            ProtoBuf_PsaiCoreSoundtrack pbSoundtrack = new ProtoBuf_PsaiCoreSoundtrack();

            pbSoundtrack.audioformat = AudioFormat;

            foreach (Theme theme in Themes)
            {
                pbSoundtrack.themes.Add(theme.CreateProtoBuf());
            }

            foreach (Segment segment in Segments)
            {
                pbSoundtrack.snippets.Add(segment.CreateProtoBuf(parentProject));
            }

            return(pbSoundtrack);
        }
示例#7
0
        public static PsaiProject LoadProjectFromStream(Stream stream)
        {
            PsaiProject project = null;

            try
            {
                TextReader    reader     = new StreamReader(stream);
                XmlSerializer serializer = new XmlSerializer(typeof(PsaiProject));
                project = (PsaiProject)serializer.Deserialize(reader);
                reader.Close();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

            project.ReconstructReferencesAfterXmlDeserialization();
            return(project);
        }
示例#8
0
        public psai.net.Segment CreatePsaiDotNetVersion(PsaiProject parentProject)
        {
            psai.net.Segment netSegment = new psai.net.Segment();


            netSegment.audioData           = this.AudioData.CreatePsaiDotNetVersion();
            netSegment.Id                  = this.Id;
            netSegment.Intensity           = this.Intensity;
            netSegment.SnippetTypeBitfield = this.CreateSegmentSuitabilityBitfield(parentProject);
            netSegment.ThemeId             = this.ThemeId;
            netSegment.Name                = this.Name;

            for (int i = 0; i < this.CompatibleSnippetsIds.Count; i++)
            {
                int snippetId = this.CompatibleSnippetsIds.Keys.ElementAt(i);
                netSegment.Followers.Add(new Follower(snippetId, CompatibleSnippetsIds[snippetId]));
            }

            return(netSegment);
        }
示例#9
0
        public ProtoBuf_Snippet CreateProtoBuf(PsaiProject parentProject)
        {
            ProtoBuf_Snippet pbSnippet = new ProtoBuf_Snippet();

            pbSnippet.audio_data   = this.AudioData.CreateProtoBuf();
            pbSnippet.id           = this.Id;
            pbSnippet.intensity    = this.Intensity;
            pbSnippet.snippet_type = this.CreateSegmentSuitabilityBitfield(parentProject);
            pbSnippet.theme_id     = this.ThemeId;
            pbSnippet.name         = this.Name;

            for (int i = 0; i < this.CompatibleSnippetsIds.Count; i++)
            {
                int snippetId = this.CompatibleSnippetsIds.Keys.ElementAt(i);
                pbSnippet.follower_id.Add(snippetId);
                pbSnippet.follower_compatibility.Add(this.CompatibleSnippetsIds[snippetId]);
            }

            return(pbSnippet);
        }
 void OnClose()
 {
     this._project = null;
 }
 private void HandleEvent_ProjectLoaded(object sender, System.EventArgs e)
 {
     _project = null;
 }
示例#12
0
 public bool IsManualBridgeSnippetForAnyGroup(PsaiProject project)
 {
     List<Group> groups = null;
     return project.CheckIfSnippetIsManualBridgeSnippetToAnyGroup(this, false, out groups);
 }
示例#13
0
        public bool IsManualBridgeSnippetForAnyGroup(PsaiProject project)
        {
            List <Group> groups = null;

            return(project.CheckIfSnippetIsManualBridgeSnippetToAnyGroup(this, false, out groups));
        }
 public CommandAddSegments(PsaiProject psaiProject, string[] filenames, Group parentGroup)
 {
     _psaiProject = psaiProject;
     _filenames = filenames;
     _parentGroup = parentGroup;
 }
示例#15
0
 public override int GetIndexPositionWithinParentEntity(PsaiProject parentProject)
 {
     return parentProject.Themes.IndexOf(this);
 }
示例#16
0
 internal CommandDeleteSegment(PsaiProject project, Segment segmentToDelete)
 {
     _psaiProject     = project;
     _entityToDelete  = segmentToDelete;
     _segmentToDelete = segmentToDelete;
 }
示例#17
0
 internal CommandDeleteTheme(PsaiProject psaiProject, Theme themeToDelete)
 {
     _psaiProject    = psaiProject;
     _entityToDelete = themeToDelete;
     _themeToDelete  = themeToDelete;
 }
示例#18
0
 internal CommandDeleteGroup(PsaiProject project, Group groupToDelete)
 {
     _psaiProject    = project;
     _entityToDelete = groupToDelete;
     _groupToDelete  = groupToDelete;
 }
示例#19
0
        /*
         * public void ToggleSnippetTypeFlag(SegmentSuitability snippetType)
         * {
         *
         #if DEBUG
         *      Console.WriteLine("ToggleSnippetTypeFlag() " + snippetType);
         *      Console.WriteLine("before: start=" + IsUsableAtStart + "  middle=" + IsUsableInMiddle + "  end=" + IsUsableAtEnd);
         #endif
         *
         *  if (this.IsUsableAs(snippetType))
         *  {
         *      // remove the flag
         *      this.ClearSnippetTypeFlag(snippetType);
         *  }
         *  else
         *  {
         *       //set the flag
         *      this.SetSnippetTypeFlag(snippetType);
         *  }
         *
         #if DEBUG
         *      Console.WriteLine("after: start=" + IsUsableAtStart + "  middle=" + IsUsableInMiddle + "  end=" + IsUsableAtEnd);
         #endif
         * }
         */

        public bool IsBridgeSnippetToAnyGroup(PsaiProject project)
        {
            List <Group> groups = null;

            return(this.IsAutomaticBridgeSegment || project.CheckIfSnippetIsManualBridgeSnippetToAnyGroup(this, false, out groups));
        }
示例#20
0
 public abstract int GetIndexPositionWithinParentEntity(PsaiProject parentProject);
示例#21
0
        // This method will create the HashSet of compatibleSnippets based on the ManuallyBlocked / ManuallyLinked entities.
        // The CompatibleSnippets HashSet is only needed for import, or to build the .pcb file.
        public void BuildCompatibleSegmentsSet(PsaiProject project)
        {
            HashSet<Segment> allSegments = project.GetSegmentsOfAllThemes();

            CompatibleSnippetsIds.Clear();
            foreach (Segment targetSegment in allSegments)
            {
                bool compatible = false;
                CompatibilityReason reason = CompatibilityReason.not_set;
                CompatibilityType compatibilityType = this.GetCompatibilityType(targetSegment, out reason);

                switch (compatibilityType)
                {
                    /*
                    case CompatibilityType.allowed_always:
                        compatible = true;
                        break;
                    */

                    case CompatibilityType.allowed_implicitly:
                        compatible = true;
                        break;

                    case CompatibilityType.allowed_manually:
                        compatible = true;
                        break;

                    default:
                        compatible = false;
                        break;
                }

                if (compatible)
                {
                    float compatibility;
                    if (targetSegment.Group == this.Group)
                        compatibility = COMPATIBILITY_PERCENTAGE_SAME_GROUP;
                    else
                        compatibility = COMPATIBILITY_PERCENTAGE_OTHER_GROUP;

                    this.AddCompatibleSnippet(targetSegment, compatibility);
                }
            }
        }
        private int _targetIndex = 0; // the index position (within the Group / Theme / Project)

        #endregion Fields

        #region Constructors

        public CommandAddPsaiEntity(PsaiProject psaiProject, PsaiMusicEntity entityToAdd, int targetIndex)
        {
            _psaiProject = psaiProject;
            _entityToAdd = entityToAdd;
            _targetIndex = targetIndex;
        }
示例#23
0
        public psai.net.Segment CreatePsaiDotNetVersion(PsaiProject parentProject)
        {
            psai.net.Segment netSegment = new psai.net.Segment();

            netSegment.audioData = this.AudioData.CreatePsaiDotNetVersion();
            netSegment.Id = this.Id;
            netSegment.Intensity = this.Intensity;
            netSegment.SnippetTypeBitfield = this.CreateSegmentSuitabilityBitfield(parentProject);
            netSegment.ThemeId = this.ThemeId;
            netSegment.Name = this.Name;

            for (int i = 0; i < this.CompatibleSnippetsIds.Count; i++)
            {
                int snippetId = this.CompatibleSnippetsIds.Keys.ElementAt(i);
                netSegment.Followers.Add(new Follower(snippetId, CompatibleSnippetsIds[snippetId]));
            }

            return netSegment;
        }
示例#24
0
        // iterates through all entities and assigns a unique running id to each one.
        // Used to compare cloned items.

        /*
         * public void AssignUniqueInteralIdForAllEntities()
         * {
         *  int internalId = 0;
         *
         *  foreach (Theme theme in this.Themes)
         *  {
         *      theme.InternalId = internalId;
         *      internalId++;
         *
         *      foreach (Group group in theme.Groups)
         *      {
         *          group.InternalId = internalId;
         *          internalId++;
         *
         *          List<Snippet> groupSnippets = group.Snippets;
         *          foreach (Snippet snippet in groupSnippets)
         *          {
         *              snippet.InternalId = internalId;
         *              internalId++;
         *          }
         *      }
         *  }
         * }
         */

        /*
         * public PsaiMusicEntity GetPsaiMusicEntityByInternalId(int internalId)
         * {
         *  foreach (Theme theme in this.Themes)
         *  {
         *
         *      if (theme.InternalId == internalId)
         *          return theme;
         *
         *      foreach (Group group in theme.Groups)
         *      {
         *          if (group.InternalId == internalId)
         *              return group;
         *
         *          List<Snippet> groupSnippets = group.Snippets;
         *          foreach (Snippet snippet in groupSnippets)
         *          {
         *              if (snippet.InternalId == internalId)
         *                  return snippet;
         *          }
         *      }
         *  }
         *
         *  return null;
         * }
         */


        public object Clone()
        {
            PsaiProject clone = new PsaiProject();

            clone.Properties = (ProjectProperties)this.Properties.Clone();

            //AssignUniqueInteralIdForAllEntities();

            // now we copy all the entities from the tmpTheme to this instance,
            // since the GUI holds a reference to 'this' model.
            clone.Themes.Clear();
            foreach (Theme theme in this.Themes)
            {
                Theme themeClone = (Theme)theme.Clone();
                clone.AddPsaiMusicEntity(themeClone);
            }

            // now that we are sure that each theme with group exists, add the manually blocked and linked
            // entities

            HashSet <Segment> allSnippetsSource = this.GetSegmentsOfAllThemes();
            HashSet <Segment> allSnippetsTarget = clone.GetSegmentsOfAllThemes();

            // create Dictionary that maps all source- to all target themes
            Dictionary <Theme, Theme> themeMap = new Dictionary <Theme, Theme>();

            List <Theme> .Enumerator enumThemeSource = this.Themes.GetEnumerator();
            List <Theme> .Enumerator enumThemeTarget = clone.Themes.GetEnumerator();
            while (enumThemeSource.MoveNext())
            {
                enumThemeTarget.MoveNext();
                themeMap.Add(enumThemeSource.Current, enumThemeTarget.Current);
            }

            // create a Dictionary that maps all source- to  all target snippets
            Dictionary <Segment, Segment> snippetMap = new Dictionary <Segment, Segment>();

            HashSet <Segment> .Enumerator enumSnippetsSource = allSnippetsSource.GetEnumerator();
            HashSet <Segment> .Enumerator enumSnippetsTarget = allSnippetsTarget.GetEnumerator();
            while (enumSnippetsSource.MoveNext())
            {
                enumSnippetsTarget.MoveNext();
                snippetMap.Add(enumSnippetsSource.Current, enumSnippetsTarget.Current);
            }

            Dictionary <Group, Group> groupMap = new Dictionary <Group, Group>();

            foreach (Theme sourceTheme in themeMap.Keys)
            {
                Theme targetTheme = themeMap[sourceTheme];

                // add manually blocked themes
                foreach (Theme manuallyBlockedTheme in sourceTheme.ManuallyBlockedTargetThemes)
                {
                    if (themeMap.Keys.Contains(manuallyBlockedTheme))
                    {
                        targetTheme.ManuallyBlockedTargetThemes.Add(themeMap[manuallyBlockedTheme]);
                    }
                }

                // fill groupMap
                for (int groupIndex = 0; groupIndex < sourceTheme.Groups.Count; groupIndex++)
                {
                    Group sourceGroup = sourceTheme.Groups[groupIndex];
                    Group targetGroup = targetTheme.Groups[groupIndex];

                    groupMap.Add(sourceGroup, targetGroup);
                }
            }


            // update manually linked and blocked group lists of all groups
            foreach (Group group in groupMap.Keys)
            {
                foreach (Group manuallyLinkedGroup in group.ManuallyLinkedGroups)
                {
                    // deleted groups will not appear in the groupMap, therefore we need to test. // TODO: deleting them before saving would be cleaner
                    if (groupMap.Keys.Contains(manuallyLinkedGroup))
                    {
                        groupMap[group].ManuallyLinkedGroups.Add(groupMap[manuallyLinkedGroup]);
                    }
                }
                foreach (Group manuallyBlockedGroup in group.ManuallyBlockedGroups)
                {
                    if (groupMap.Keys.Contains(manuallyBlockedGroup))
                    {
                        groupMap[group].ManuallyBlockedGroups.Add(groupMap[manuallyBlockedGroup]);
                    }
                }

                foreach (Segment bridgeSnippet in group.ManualBridgeSnippetsOfTargetGroups)
                {
                    if (snippetMap.Keys.Contains(bridgeSnippet))
                    {
                        Segment           cloneBridgeSnippet  = snippetMap[bridgeSnippet];
                        Group             cloneGroup          = groupMap[group];
                        HashSet <Segment> cloneBridgeSnippets = cloneGroup.ManualBridgeSnippetsOfTargetGroups;

                        cloneBridgeSnippets.Add(cloneBridgeSnippet);
                    }
                }
            }

            //
            foreach (Segment snippet in allSnippetsSource)
            {
                foreach (Segment blockedSnippet in snippet.ManuallyBlockedSnippets)
                {
                    // deleted snippets will not appear in the snippetMap, so we need to test   // TODO: deleting them before saving would be cleaner
                    if (snippetMap.Keys.Contains(blockedSnippet))
                    {
                        snippetMap[snippet].ManuallyBlockedSnippets.Add(snippetMap[blockedSnippet]);
                    }
                }

                foreach (Segment linkedSnippet in snippet.ManuallyLinkedSnippets)
                {
                    if (snippetMap.Keys.Contains(linkedSnippet))
                    {
                        snippetMap[snippet].ManuallyLinkedSnippets.Add(snippetMap[linkedSnippet]);
                    }
                }
            }

            return(clone);
        }
示例#25
0
 public override int GetIndexPositionWithinParentEntity(PsaiProject parentProject)
 {
     return this.Group.Segments.IndexOf(this);
 }
示例#26
0
        // iterates through all entities and assigns a unique running id to each one.
        // Used to compare cloned items.
        /*
        public void AssignUniqueInteralIdForAllEntities()
        {
            int internalId = 0;

            foreach (Theme theme in this.Themes)
            {
                theme.InternalId = internalId;
                internalId++;

                foreach (Group group in theme.Groups)
                {
                    group.InternalId = internalId;
                    internalId++;

                    List<Snippet> groupSnippets = group.Snippets;
                    foreach (Snippet snippet in groupSnippets)
                    {
                        snippet.InternalId = internalId;
                        internalId++;
                    }
                }
            }
        }
        */
        /*
        public PsaiMusicEntity GetPsaiMusicEntityByInternalId(int internalId)
        {
            foreach (Theme theme in this.Themes)
            {

                if (theme.InternalId == internalId)
                    return theme;

                foreach (Group group in theme.Groups)
                {
                    if (group.InternalId == internalId)
                        return group;

                    List<Snippet> groupSnippets = group.Snippets;
                    foreach (Snippet snippet in groupSnippets)
                    {
                        if (snippet.InternalId == internalId)
                            return snippet;
                    }
                }
            }

            return null;
        }
        */
        public object Clone()
        {
            PsaiProject clone = new PsaiProject();
            clone.Properties = (ProjectProperties)this.Properties.Clone();

            //AssignUniqueInteralIdForAllEntities();

            // now we copy all the entities from the tmpTheme to this instance,
            // since the GUI holds a reference to 'this' model.
            clone.Themes.Clear();
            foreach (Theme theme in this.Themes)
            {
                Theme themeClone = (Theme)theme.Clone();
                clone.AddPsaiMusicEntity(themeClone);
            }

            // now that we are sure that each theme with group exists, add the manually blocked and linked
            // entities

            HashSet<Segment> allSnippetsSource = this.GetSegmentsOfAllThemes();
            HashSet<Segment> allSnippetsTarget = clone.GetSegmentsOfAllThemes();

            // create Dictionary that maps all source- to all target themes
            Dictionary<Theme, Theme> themeMap = new Dictionary<Theme, Theme>();
            List<Theme>.Enumerator enumThemeSource = this.Themes.GetEnumerator();
            List<Theme>.Enumerator enumThemeTarget = clone.Themes.GetEnumerator();
            while (enumThemeSource.MoveNext())
            {
                enumThemeTarget.MoveNext();
                themeMap.Add(enumThemeSource.Current, enumThemeTarget.Current);
            }

            // create a Dictionary that maps all source- to  all target snippets
            Dictionary<Segment, Segment> snippetMap = new Dictionary<Segment, Segment>();
            HashSet<Segment>.Enumerator enumSnippetsSource = allSnippetsSource.GetEnumerator();
            HashSet<Segment>.Enumerator enumSnippetsTarget = allSnippetsTarget.GetEnumerator();
            while (enumSnippetsSource.MoveNext())
            {
                enumSnippetsTarget.MoveNext();
                snippetMap.Add(enumSnippetsSource.Current, enumSnippetsTarget.Current);
            }

            Dictionary<Group, Group> groupMap = new Dictionary<Group, Group>();

            foreach (Theme sourceTheme in themeMap.Keys)
            {
                Theme targetTheme = themeMap[sourceTheme];

                // add manually blocked themes
                foreach (Theme manuallyBlockedTheme in sourceTheme.ManuallyBlockedTargetThemes)
                {
                    if (themeMap.Keys.Contains(manuallyBlockedTheme))
                        targetTheme.ManuallyBlockedTargetThemes.Add(themeMap[manuallyBlockedTheme]);
                }

                // fill groupMap
                for (int groupIndex = 0; groupIndex < sourceTheme.Groups.Count; groupIndex++)
                {
                    Group sourceGroup = sourceTheme.Groups[groupIndex];
                    Group targetGroup = targetTheme.Groups[groupIndex];

                    groupMap.Add(sourceGroup, targetGroup);
                }
            }

            // update manually linked and blocked group lists of all groups
            foreach (Group group in groupMap.Keys)
            {
                foreach (Group manuallyLinkedGroup in group.ManuallyLinkedGroups)
                {
                    // deleted groups will not appear in the groupMap, therefore we need to test. // TODO: deleting them before saving would be cleaner
                    if (groupMap.Keys.Contains(manuallyLinkedGroup))
                    {
                        groupMap[group].ManuallyLinkedGroups.Add(groupMap[manuallyLinkedGroup]);
                    }
                }
                foreach (Group manuallyBlockedGroup in group.ManuallyBlockedGroups)
                {
                    if (groupMap.Keys.Contains(manuallyBlockedGroup))
                    {
                        groupMap[group].ManuallyBlockedGroups.Add(groupMap[manuallyBlockedGroup]);
                    }
                }

                foreach (Segment bridgeSnippet in group.ManualBridgeSnippetsOfTargetGroups)
                {
                    if (snippetMap.Keys.Contains(bridgeSnippet))
                    {
                        Segment cloneBridgeSnippet = snippetMap[bridgeSnippet];
                        Group cloneGroup = groupMap[group];
                        HashSet<Segment> cloneBridgeSnippets = cloneGroup.ManualBridgeSnippetsOfTargetGroups;

                        cloneBridgeSnippets.Add(cloneBridgeSnippet);
                    }
                }
            }

            //
            foreach (Segment snippet in allSnippetsSource)
            {
                foreach (Segment blockedSnippet in snippet.ManuallyBlockedSnippets)
                {
                    // deleted snippets will not appear in the snippetMap, so we need to test   // TODO: deleting them before saving would be cleaner
                    if (snippetMap.Keys.Contains(blockedSnippet))
                        snippetMap[snippet].ManuallyBlockedSnippets.Add(snippetMap[blockedSnippet]);
                }

                foreach (Segment linkedSnippet in snippet.ManuallyLinkedSnippets)
                {
                    if (snippetMap.Keys.Contains(linkedSnippet))
                        snippetMap[snippet].ManuallyLinkedSnippets.Add(snippetMap[linkedSnippet]);
                }
            }

            return clone;
        }
示例#27
0
 public override int GetIndexPositionWithinParentEntity(PsaiProject parentProject)
 {
     return(this.Group.Segments.IndexOf(this));
 }
示例#28
0
 public override int GetIndexPositionWithinParentEntity(PsaiProject parentProject)
 {
     return(parentProject.Themes.IndexOf(this));
 }
示例#29
0
        private int _targetIndex = 0; // the index position (within the Group / Theme / Project)

        public CommandAddPsaiEntity(PsaiProject psaiProject, PsaiMusicEntity entityToAdd, int targetIndex)
        {
            _psaiProject = psaiProject;
            _entityToAdd = entityToAdd;
            _targetIndex = targetIndex;
        }
示例#30
0
        public ProtoBuf_Snippet CreateProtoBuf(PsaiProject parentProject)
        {
            ProtoBuf_Snippet pbSnippet = new ProtoBuf_Snippet();

            pbSnippet.audio_data = this.AudioData.CreateProtoBuf();
            pbSnippet.id = this.Id;
            pbSnippet.intensity = this.Intensity;
            pbSnippet.snippet_type = this.CreateSegmentSuitabilityBitfield(parentProject);
            pbSnippet.theme_id = this.ThemeId;
            pbSnippet.name = this.Name;

            for (int i = 0; i < this.CompatibleSnippetsIds.Count; i++)
            {
                int snippetId = this.CompatibleSnippetsIds.Keys.ElementAt(i);
                pbSnippet.follower_id.Add(snippetId);
                pbSnippet.follower_compatibility.Add(this.CompatibleSnippetsIds[snippetId]);
            }

            return pbSnippet;
        }
 internal CommandDeleteSegment(PsaiProject project, Segment segmentToDelete)
 {
     _psaiProject = project;
     _entityToDelete = segmentToDelete;
     _segmentToDelete = segmentToDelete;
 }
示例#32
0
        public int CreateSegmentSuitabilityBitfield(PsaiProject parentProject)
        {
            int bitfield = 0;

            if (this.IsAutomaticBridgeSegment || this.IsBridgeSnippetToAnyGroup(parentProject))
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.bridge);
            }

            if (this.IsUsableAtStart)
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.start);
            }

            if (this.IsUsableInMiddle)
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.middle);
            }

            if (this.IsUsableAtEnd)
            {
                SetSegmentSuitabilityFlag(ref bitfield, SegmentSuitability.end);
            }

            return bitfield;
        }
 internal CommandDeleteGroup(PsaiProject project, Group groupToDelete)
 {
     _psaiProject = project;
     _entityToDelete = groupToDelete;
     _groupToDelete = groupToDelete;
 }
示例#34
0
        /*
        public void ToggleSnippetTypeFlag(SegmentSuitability snippetType)
        {

            #if DEBUG
                Console.WriteLine("ToggleSnippetTypeFlag() " + snippetType);
                Console.WriteLine("before: start=" + IsUsableAtStart + "  middle=" + IsUsableInMiddle + "  end=" + IsUsableAtEnd);
            #endif

            if (this.IsUsableAs(snippetType))
            {
                // remove the flag
                this.ClearSnippetTypeFlag(snippetType);
            }
            else
            {
                 //set the flag
                this.SetSnippetTypeFlag(snippetType);
            }

            #if DEBUG
                Console.WriteLine("after: start=" + IsUsableAtStart + "  middle=" + IsUsableInMiddle + "  end=" + IsUsableAtEnd);
            #endif
        }
        */
        public bool IsBridgeSnippetToAnyGroup(PsaiProject project)
        {
            List<Group> groups = null;
            return (this.IsAutomaticBridgeSegment || project.CheckIfSnippetIsManualBridgeSnippetToAnyGroup(this, false, out groups));
        }
 internal CommandDeleteTheme(PsaiProject psaiProject, Theme themeToDelete)
 {
     _psaiProject = psaiProject;
     _entityToDelete = themeToDelete;
     _themeToDelete = themeToDelete;
 }
示例#36
0
 public CommandAddSegments(PsaiProject psaiProject, string[] filenames, Group parentGroup)
 {
     _psaiProject = psaiProject;
     _filenames   = filenames;
     _parentGroup = parentGroup;
 }
示例#37
0
 public abstract int GetIndexPositionWithinParentEntity(PsaiProject parentProject);