示例#1
0
        /// <summary>
        /// Fires when the value of the SelectedIndexProperty dependency property changes
        /// </summary>
        /// <param name="d">Dependency object containing the property that changed</param>
        /// <param name="e">Arguments passed to the change event</param>
        private static void OnSelectedIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MediaItemDialog mid = d as MediaItemDialog;

            if (mid.SelectedIndex != -1)
            {
                MediaItem selectedMediaItem = mid.MediaItems[mid.SelectedIndex];

                Boolean modified = false;

                //refresh the size of the parts
                foreach (MediaItemPart part in selectedMediaItem.Parts)
                {
                    FileInfo fi = new FileInfo(part.Location.Value);

                    if (fi.Exists)
                    {
                        if (part.Size != fi.Length)
                        {
                            part.Size = fi.Length;
                            modified = true;
                        }
                    }
                }

                if (modified)
                    mid.OnSavedMediaItem(selectedMediaItem);

                mid.SelectedMediaItem = selectedMediaItem.Clone() as MediaItem;
            }
        }
示例#2
0
        /// <summary>
        /// Saves the selected media item to the database
        /// </summary>
        /// <returns>True if the media item is saved successfully, false if not</returns>
        private Boolean UpdateSelectedMediaItem()
        {
            try
            {
                if (IntelligentString.IsNullOrEmpty(SelectedMediaItem.Name))
                {
                    GeneralMethods.MessageBoxApplicationError("Please give the " + SelectedMediaItem.Type.ToString().ToLower() + " a name");
                    return false;
                }

                if (mipParts.MediaItem.Parts.Count == 0)
                {
                    GeneralMethods.MessageBoxApplicationError("A " + SelectedMediaItem.Type.ToString().ToLower() + " must have at least 1 part");
                    return false;
                }

                MediaItem selectedMediaItem = MediaItems[SelectedIndex];
                CopyPropertiesFromClone(selectedMediaItem);
                selectedMediaItem.Parts = new MediaItemPartCollection(mipParts.MediaItem.Parts);

                OnSavedMediaItem(selectedMediaItem);

                SelectedMediaItem = selectedMediaItem.Clone() as MediaItem;

                return true;
            }
            catch (System.Exception e)
            {
                GeneralMethods.MessageBoxException(e, "Could not save video: ");
                return false;
            }
        }