private void m_dataGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == ActorName.Index)
            {
                if (m_dataGrid.Rows[e.RowIndex].IsNewRow)
                {
                    return;
                }

                VoiceActor.VoiceActor editedActor = e.RowIndex < m_actorInformationViewModel.Actors.Count
                                        ? m_actorInformationViewModel.Actors[e.RowIndex]
                                        : null;
                Debug.Assert(editedActor != null);

                if (!string.IsNullOrWhiteSpace(e.FormattedValue.ToString()) &&
                    m_actorInformationViewModel.IsDuplicateActorName(editedActor, e.FormattedValue.ToString()))
                {
                    e.Cancel = true;
                    if (!m_inEndEdit)
                    {
                        MessageBox.Show(LocalizationManager.GetString("DialogBoxes.VoiceActorInformation.DuplicateName", "Actor Name must be unique."));
                    }
                }
            }
        }
        private void m_dataGrid_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
        {
            VoiceActor.VoiceActor actor = m_actorInformationViewModel.Actors[e.RowIndex];

            if (e.Value == null)
            {
                return;
            }

            if (e.ColumnIndex == ActorName.Index)
            {
                actor.Name = (string)e.Value;
            }
            else if (e.ColumnIndex == ActorGender.Index)
            {
                actor.Gender = (ActorGender)e.Value;
            }
            else if (e.ColumnIndex == ActorAge.Index)
            {
                actor.Age = (ActorAge)e.Value;
            }
            else if (e.ColumnIndex == ActorStatus.Index)
            {
                actor.Status = (bool)e.Value;
            }
            else if (e.ColumnIndex == ActorQuality.Index)
            {
                actor.VoiceQuality = (VoiceQuality)e.Value;
            }
            else if (e.ColumnIndex == Cameo.Index)
            {
                actor.IsCameo = (bool)e.Value;
            }
        }
        public AddCharactersToGroupViewModel(IReadOnlyDictionary <string, CharacterDetail> characterDetailDictionary,
                                             Dictionary <string, int> keyStrokesByCharacterId,
                                             ISet <string> existingCharactersInGroup,
                                             VoiceActor.VoiceActor cameoActor = null)
        {
            m_characterDetailDictionary = characterDetailDictionary;
            m_keyStrokesByCharacterId   = keyStrokesByCharacterId;
            var charactersNotInGroup = m_keyStrokesByCharacterId.Where(kvp => !existingCharactersInGroup.Contains(kvp.Key));

            if (cameoActor != null)
            {
                m_availableCharacters = new List <CharacterDetail>();
                m_cameoActor          = cameoActor;
                foreach (var kvp in charactersNotInGroup)
                {
                    if ((kvp.Value / Program.kKeyStrokesPerHour) < Program.kCameoCharacterEstimatedHoursLimit)
                    {
                        var detail = m_characterDetailDictionary[kvp.Key];
                        if (cameoActor.Matches(detail))
                        {
                            m_availableCharacters.Add(detail);
                        }
                    }
                }
            }
            else
            {
                m_availableCharacters = new List <CharacterDetail>(charactersNotInGroup.Select(k => m_characterDetailDictionary[k.Key]));
            }

            // TODO: Sort list
        }
        public void CreateNewActorAndAssignToGroup(string voiceActorName, CharacterGroup group)
        {
            var actor = new VoiceActor.VoiceActor {
                Id = 99, Name = voiceActorName
            };

            m_project.VoiceActorList.AllActors.Add(actor);
            AssignActorToGroup(actor.Id, group);
        }
        public VoiceActor.VoiceActor AddNewActor()
        {
            var actor = new VoiceActor.VoiceActor {
                Id = m_currentId++
            };

            Actors.Add(actor);
            return(actor);
        }
        public VoiceActorAddedUndoAction(Project project, int affectedActor)
        {
            m_addedActorInformation = project.VoiceActorList.GetVoiceActorById(affectedActor);
            if (m_addedActorInformation == null)
            {
                throw new ArgumentException("Affected actor must be in the project", "affectedActor");
            }

            m_project = project;
            m_addedActorInformation = m_addedActorInformation.MakeCopy();
        }
Exemplo n.º 7
0
 private object[] GetDataTableRow(VoiceActor.VoiceActor actor, string category)
 {
     return(new object[]
     {
         actor.Id,
         category,
         null,
         actor.Name,
         GetUiStringForActorGender(actor.Gender),
         GetUiStringForActorAge(actor.Age),
         actor.IsCameo ? LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.Cameo", "Cameo") : ""
     });
 }
Exemplo n.º 8
0
        private void m_dataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (m_actorInformationViewModel == null || e.RowIndex < 0 || e.RowIndex >= m_actorInformationViewModel.Actors.Count)
            {
                return;
            }

            VoiceActor.VoiceActor actor = m_actorInformationViewModel.Actors[e.RowIndex];
            if (actor.IsInactive)
            {
                e.CellStyle.ForeColor = Color.Gray;
            }
        }
        public VoiceActorDeletedUndoAction(Project project, VoiceActor.VoiceActor deletedActor, CharacterGroup assignedGroup = null)
        {
            if (deletedActor == null)
            {
                throw new ArgumentNullException("deletedActor");
            }

            m_project      = project;
            m_deletedActor = deletedActor;
            if (assignedGroup != null)
            {
                m_characterIdsOfAssignedGroup = new List <string>(assignedGroup.CharacterIds);
            }
        }
        public void SetInactive(VoiceActor.VoiceActor actor, bool inactive)
        {
            if (actor.IsInactive == inactive)
            {
                return;
            }

            if (inactive && IsActorAssigned(actor))
            {
                m_project.CharacterGroupList.RemoveVoiceActor(actor.Id);
                m_project.SaveCharacterGroupData();
            }
            actor.IsInactive = inactive;
            SaveVoiceActorInformation();
        }
Exemplo n.º 11
0
        public VoiceActorEditUndoAction(Project project, VoiceActor.VoiceActor previousActorInformation)
        {
            if (previousActorInformation == null)
            {
                throw new ArgumentNullException("previousActorInformation");
            }

            m_project = project;
            var currentActor = m_project.VoiceActorList.GetVoiceActorById(previousActorInformation.Id);

            if (currentActor == null)
            {
                throw new ArgumentException("The edited actor is not in the project.", "previousActorInformation");
            }
            m_affectedActorInformation = currentActor.MakeCopy();
            m_previousActorInformation = previousActorInformation;
        }
Exemplo n.º 12
0
        public void SetGroupIdLabel()
        {
            if (GroupIdLabel != Label.None)
            {
                return;
            }

            if (AssignedToCameoActor)
            {
                GroupIdLabel     = Label.Other;
                GroupIdOtherText = VoiceActor.Name;
                return;
            }

            if (CharacterIds.All(c => CharacterVerseData.IsCharacterOfType(c, CharacterVerseData.StandardCharacter.Narrator)))
            {
                GroupIdLabel = Label.Narrator;
            }
            else if (IsVoiceActorAssigned)
            {
                VoiceActor.VoiceActor actor = VoiceActor;
                if (actor.Age == ActorAge.Child)
                {
                    GroupIdLabel = Label.Child;
                }
                else if (actor.Gender == ActorGender.Male)
                {
                    GroupIdLabel = Label.Male;
                }
                else
                {
                    GroupIdLabel = Label.Female;
                }
            }
            else
            {
                if (ContainsOnlyCharactersWithAge(CharacterAge.Child))
                {
                    GroupIdLabel = Label.Child;
                }
                else if (ContainsCharacterWithGender(CharacterGender.Male))
                {
                    GroupIdLabel = Label.Male;
                }
                else if (ContainsCharacterWithGender(CharacterGender.Female))
                {
                    GroupIdLabel = Label.Female;
                }
                else if (ContainsCharacterWithGender(CharacterGender.PreferMale))
                {
                    GroupIdLabel = Label.Male;
                }
                else if (ContainsCharacterWithGender(CharacterGender.PreferFemale))
                {
                    GroupIdLabel = Label.Female;
                }
                else
                {
                    GroupIdLabel = Label.Male;
                }
            }
        }
 public bool IsDuplicateActorName(VoiceActor.VoiceActor editedVoiceActor, string newActorName)
 {
     return(Actors.Where(a => a != editedVoiceActor).Any(actor => actor.Name == newActorName));
 }
 public bool IsActorAssigned(VoiceActor.VoiceActor actor)
 {
     return(m_project.CharacterGroupList.HasVoiceActorAssigned(actor.Id));
 }