コード例 #1
0
        private void addTrackButton_Click(object sender, EventArgs e)
        {
            ModelsData.Model.Track newTrack    = new ModelsData.Model.Track();
            ManageTrackForm        manageTrack = new ManageTrackForm(newTrack, ManageTrackForm.CallType.Add, -1);

            manageTrack.ShowDialog();
            if (manageTrack.DialogResult == DialogResult.OK)
            {
                model.trackList.Add(manageTrack.track);
                GenerateModel();
            }
        }
コード例 #2
0
        private void EditTrack()
        {
            Logger.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name);

            if (tracksDataGridView.SelectedRows.Count == 1)
            {
                string editTrackJson                   = Newtonsoft.Json.JsonConvert.SerializeObject(model.trackList[tracksDataGridView.SelectedRows[0].Index]);
                ModelsData.Model.Track editTrack       = Newtonsoft.Json.JsonConvert.DeserializeObject <ModelsData.Model.Track>(editTrackJson);
                ManageTrackForm        manageTrackEdit = new ManageTrackForm(editTrack, ManageTrackForm.CallType.Edit, tracksDataGridView.SelectedRows[0].Index);
                manageTrackEdit.ShowDialog();
                if (manageTrackEdit.DialogResult == DialogResult.OK)
                {
                    model.trackList[tracksDataGridView.SelectedRows[0].Index] = manageTrackEdit.track;
                    GenerateModel();
                }
            }
        }
コード例 #3
0
        private void copyTrackButton_Click(object sender, EventArgs e)
        {
            Logger.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name);

            if (tracksDataGridView.SelectedRows.Count == 1)
            {
                string copyTrackJson                   = Newtonsoft.Json.JsonConvert.SerializeObject(model.trackList[tracksDataGridView.SelectedRows[0].Index]);
                ModelsData.Model.Track copyTrack       = Newtonsoft.Json.JsonConvert.DeserializeObject <ModelsData.Model.Track>(copyTrackJson);
                ManageTrackForm        manageTrackCopy = new ManageTrackForm(copyTrack, ManageTrackForm.CallType.Copy, -1);
                manageTrackCopy.ShowDialog();
                if (manageTrackCopy.DialogResult == DialogResult.OK)
                {
                    model.trackList.Add(manageTrackCopy.track);
                    GenerateModel();
                }
            }
        }
コード例 #4
0
        public bool CheckTrack(ManageTrackForm manageTrackForm)
        {
            Logger.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name);

            ModelsData.Model.Track   track    = manageTrackForm.track;
            ManageTrackForm.CallType callType = manageTrackForm.callType;
            int     currentTrackIndex         = manageTrackForm.currentTrackIndex;
            Boolean result = true;

            errorList = "";
            int errorIndex = 0;

            #region type
            if (String.IsNullOrEmpty(track.type))
            {
                errorIndex += 1;
                AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.SelectTrackType);
                result = false;
            }
            #endregion
            #region original file number and position

            // the checks for the maximum file number available to insert/edit is removed. when generating the model, all originalFileNumber are fixed filling the holes

            for (int i = 0; i < ManageModelForm.model.trackList.Count; i++)
            {
                // if originalFileNumber and position already in tracklist, error
                if (track.originalFileNumber == ManageModelForm.model.trackList[i].originalFileNumber &&
                    track.originalFileTrackPosition == ManageModelForm.model.trackList[i].originalFileTrackPosition &&
                    i != currentTrackIndex)
                {
                    errorIndex += 1;
                    AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.OriginalFileNumberPositionAlreadyInTrackList);

                    result = false;
                    break;
                }
            }
            // if originalFileNumber is > 0 (external) we need at least suffix or extension
            if (track.originalFileNumber > 0)
            {
                if (String.IsNullOrEmpty(track.originalFileSuffix) && String.IsNullOrEmpty(track.originalFileExtension))
                {
                    errorIndex += 1;
                    AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.SpecifySuffixOrExtension);

                    result = false;
                }
            }
            #endregion
            #region language
            if (String.IsNullOrEmpty(track.language))
            {
                errorIndex += 1;
                AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.InsertLanguageCode);

                result = false;
            }
            #endregion
            #region originalFileSuffix
            if (!String.IsNullOrEmpty(track.originalFileSuffix) && track.originalFileNumber == 0)
            {
                errorIndex += 1;
                AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.SuffixNotRequired);
                result = false;
            }
            #endregion
            #region originalFileExtension
            if (!String.IsNullOrEmpty(track.originalFileExtension) && track.originalFileNumber == 0)
            {
                errorIndex += 1;
                AddError(Properties.Resources.ErrorLabel + " n." + errorIndex + ": " + Properties.Resources.ExtensionNotRequired);
                result = false;
            }
            #endregion
            return(result);
        }