Exemplo n.º 1
0
        private void Set()
        {
            if (m_currentTitle == null)
            {
                return;
            }

            m_currentTitle.DateModifiedUtc = GeneralPersistense.GetTimestamp();
            m_currentTitle.TitleName       = TbxTitleName.Text;
            m_currentTitle.Kind            = CbxKind.GetSelectedKey <TitleKind>();
            m_currentTitle.Year            = TbxReleaseYear.Text.To <int>(0);
            m_currentTitle.Description     = TbxDescription.Text;
            m_currentTitle.ImdbId          = TbxImdbId.Text;
            m_currentTitle.Season          = TbxSeason.Text.To <int>(0);
            m_currentTitle.Disk            = TbxDisk.Text.To <int>(0);
            m_currentTitle.EpisodeOrTrack  = TbxEpisode.Text.To <int>(0);

            GeneralPersistense.Upsert(m_currentTitle);
            SetControlsFromDirtyState(false);


            //HACK: TVTitles.Sort doesn't work
            if (!m_currentTitle.ParentTitleId.HasValue)
            {
                var roots = new List <Title>(TVTitles.Roots.Cast <Title>());
                roots.Sort();
                TVTitles.Roots = roots;
                TVTitles.EnsureModelVisible(m_currentTitle);
            }
        }
Exemplo n.º 2
0
        private void BtnNew_Click(object sender, EventArgs e)
        {
            TitleKind kind;

            switch (GetResourceKind())
            {
            case ResourceKind.Audio: kind = TitleKind.AlbumArtist; break;

            case ResourceKind.Video: kind = TitleKind.Title; break;

            default: return;
            }

            Title newTitle = null;

            foreach (Title item in TVTitles.Objects)
            {
                if (item.Id < 1)
                {
                    //Unsaved new item already there
                    newTitle = item;
                }
            }
            if (newTitle == null)
            {
                newTitle = new Title()
                {
                    TitleName = "New", Kind = kind, DateAddedUtc = GeneralPersistense.GetTimestamp()
                };
                TVTitles.AddObject(newTitle);
            }
            TVTitles.SelectedObject = newTitle;
            DisplayTitleInfo(newTitle);
            TVTitles.EnsureModelVisible(newTitle);
            TbxTitleName.Focus();
        }