Example #1
0
        private void UnloadSettingsInternal(string targetAlias, KStudioClipSource clipSource)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            Guid identifier = GetFileId(targetAlias, clipSource);

            lock (this.fileSettings)
            {
                XDocument xml;
                if (this.fileSettings.TryGetValue(identifier, out xml))
                {
                    string fileName = GetFileName(targetAlias, identifier);
                    try
                    {
                        xml.Save(fileName);
                    }
                    catch (Exception)
                    {
                        // TODO_LOG
                    }

                    this.fileSettings.Remove(identifier);
                }
            }
        }
        public TimelineInOutPointsCollection(string targetAlias, KStudioClipSource clipSource)
            : base(targetAlias, clipSource)
        {
            DebugHelper.AssertUIThread();

            this.OnLoad();
        }
        public void UnloadSettings(string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrEmpty(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            UnloadSettingsInternal(targetAlias, clipSource);
        }
Example #4
0
        public void UnloadSettings(string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrEmpty(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            UnloadSettingsInternal(targetAlias, clipSource);
        }
        public PlaybackFileSettings(IFileSettingsService fileSettingsService, string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrWhiteSpace(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            this.Initialize(fileSettingsService, targetAlias, clipSource);
        }
Example #6
0
        public TimelinePausePointsCollection(string targetAlias, KStudioClipSource clipSource, TimelineMarkersCollection markers)
            : base(targetAlias, clipSource)
        {
            DebugHelper.AssertUIThread();

            this.markers = markers;

            this.OnLoad();
        }
Example #7
0
        public XElement GetSettings(string targetAlias, KStudioClipSource clipSource, string settingsKey)
        {
            if (String.IsNullOrEmpty(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            this.LoadSettingsInternal(targetAlias, clipSource);

            return(GetSettingsInternal(targetAlias, clipSource, settingsKey));
        }
        public XElement GetSettings(string targetAlias, KStudioClipSource clipSource, string settingsKey)
        {
            if (String.IsNullOrEmpty(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            this.LoadSettingsInternal(targetAlias, clipSource);

            return GetSettingsInternal(targetAlias, clipSource, settingsKey);
        }
Example #9
0
        private static Guid GetFileId(string targetAlias, KStudioClipSource clipSource)
        {
            Debug.Assert(clipSource != null);

            Guid value = clipSource.Id;

            if (value == Guid.Empty)
            {
                KStudioEventFile file = clipSource as KStudioEventFile;
                if (file == null)
                {
                    throw new ArgumentOutOfRangeException("clipSource", "not a KStudioEventFile");
                }
                else
                {
                    // File did not have a real identifier (legacy file), so create one that is "reasonable"

                    string fileNameUpper = file.FilePath.ToUpperInvariant();
                    int    fullPathHash  = fileNameUpper.GetHashCode();
                    fileNameUpper = Path.GetFileName(fileNameUpper.Reverse());
                    int fileNameHash = fileNameUpper.GetHashCode();

                    if (targetAlias == null)
                    {
                        value = new Guid((UInt32)fullPathHash,
                                         (UInt16)fileNameHash,
                                         (UInt16)(((UInt32)fileNameHash) >> 16),
                                         0, 0, 0, 0, 0, 0, 0, 0);
                    }
                    else
                    {
                        string targetAliasUpper = targetAlias.ToUpperInvariant();
                        UInt32 targetAliasHash1 = (UInt32)targetAliasUpper.GetHashCode();
                        targetAliasUpper = targetAliasUpper.Reverse();
                        UInt32 targetAliasHash2 = (UInt32)targetAliasUpper.GetHashCode();

                        value = new Guid((UInt32)fullPathHash,
                                         (UInt16)fileNameHash,
                                         (UInt16)(((UInt32)fileNameHash) >> 16),
                                         (byte)targetAliasHash1,
                                         (byte)(targetAliasHash1 >> 8),
                                         (byte)(targetAliasHash1 >> 16),
                                         (byte)(targetAliasHash1 >> 24),
                                         (byte)targetAliasHash2,
                                         (byte)(targetAliasHash2 >> 8),
                                         (byte)(targetAliasHash2 >> 16),
                                         (byte)(targetAliasHash2 >> 24));
                    }
                }
            }

            return(value);
        }
        protected TimelinePointsCollection(string targetAlias, KStudioClipSource clipSource)
        {
            DebugHelper.AssertUIThread();

            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            this.targetAlias = targetAlias;
            this.clipSource  = clipSource;
            this.points      = new ObservableCollection <T>();
        }
Example #11
0
        private void LoadSettingsInternal(string targetAlias, KStudioClipSource clipSource)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            Guid identifier = GetFileId(targetAlias, clipSource);

            lock (this.fileSettings)
            {
                XDocument xml;

                if (!this.fileSettings.TryGetValue(identifier, out xml))
                {
                    string fileName = GetFileName(targetAlias, identifier);
                    if (File.Exists(fileName))
                    {
                        try
                        {
                            xml = XDocument.Load(fileName);
                        }
                        catch (Exception)
                        {
                            // TODO_LOG
                        }
                    }

                    if (xml == null)
                    {
                        xml = new XDocument();
                    }

                    if (xml.Root == null)
                    {
                        XElement fileElement = new XElement("file");
                        if (targetAlias != null)
                        {
                            fileElement.Add(new XAttribute("targetAlias", targetAlias));
                        }
                        fileElement.Add(new XAttribute("id", identifier.ToString()));
                        xml.Add(fileElement);
                    }

                    this.fileSettings[identifier] = xml;
                }
            }
        }
        private void LoadSettingsInternal(string targetAlias, KStudioClipSource clipSource)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            Guid identifier = GetFileId(targetAlias, clipSource);

            lock (this.fileSettings)
            {
                XDocument xml;

                if (!this.fileSettings.TryGetValue(identifier, out xml))
                {
                    string fileName = GetFileName(targetAlias, identifier);
                    if (File.Exists(fileName))
                    {
                        try
                        {
                            xml = XDocument.Load(fileName);
                        }
                        catch (Exception)
                        {
                            // TODO_LOG
                        }
                    }

                    if (xml == null)
                    {
                        xml = new XDocument();
                    }

                    if (xml.Root == null)
                    {
                        XElement fileElement = new XElement("file");
                        if (targetAlias != null)
                        {
                            fileElement.Add(new XAttribute("targetAlias", targetAlias));
                        }
                        fileElement.Add(new XAttribute("id", identifier.ToString()));
                        xml.Add(fileElement);
                    }

                    this.fileSettings[identifier] = xml;
                }
            }
        }
        private void Initialize(IFileSettingsService fileSettingsService, string targetAlias, KStudioClipSource clipSource)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            this.fileSettingsService = fileSettingsService;
            this.targetAlias = targetAlias;
            this.clipSource = clipSource;

            if (this.fileSettingsService != null)
            {
                if (targetAlias == null)
                {
                    this.fileSettingsService.LoadSettings(this.clipSource);
                }
                else
                {
                    this.fileSettingsService.LoadSettings(this.targetAlias, this.clipSource);
                }
            }
        }
Example #14
0
        private XElement GetSettingsInternal(string targetAlias, KStudioClipSource clipSource, string settingsKey)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            if (String.IsNullOrEmpty(settingsKey))
            {
                throw new ArgumentNullException("settingsKey");
            }

            Guid identifier = GetFileId(targetAlias, clipSource);

            XElement value = null;

            lock (this.fileSettings)
            {
                XDocument xml;
                if (!this.fileSettings.TryGetValue(identifier, out xml))
                {
                    throw new InvalidOperationException("settings not loaded");
                }

                Debug.Assert(xml.Root != null);

                value = xml.Root.Element(settingsKey);
                if (value == null)
                {
                    value = new XElement(settingsKey);
                    xml.Root.Add(value);
                }
            }

            return(value);
        }
        private XElement GetSettingsInternal(string targetAlias, KStudioClipSource clipSource, string settingsKey)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            if (String.IsNullOrEmpty(settingsKey))
            {
                throw new ArgumentNullException("settingsKey");
            }

            Guid identifier = GetFileId(targetAlias, clipSource);

            XElement value = null;

            lock (this.fileSettings)
            {
                XDocument xml;
                if (!this.fileSettings.TryGetValue(identifier, out xml))
                {
                    throw new InvalidOperationException("settings not loaded");
                }

                Debug.Assert(xml.Root != null);

                value = xml.Root.Element(settingsKey);
                if (value == null)
                {
                    value = new XElement(settingsKey);
                    xml.Root.Add(value);
                }
            }

            return value;
        }
 public PlaybackFileSettings(IFileSettingsService fileSettingsService, KStudioClipSource clipSource)
 {
     this.Initialize(fileSettingsService, null, clipSource);
 }
Example #17
0
        public PlaybackFileSettings(IFileSettingsService fileSettingsService, string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrWhiteSpace(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            this.Initialize(fileSettingsService, targetAlias, clipSource);
        }
Example #18
0
        private void Initialize(IFileSettingsService fileSettingsService, string targetAlias, KStudioClipSource clipSource)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            this.fileSettingsService = fileSettingsService;
            this.targetAlias         = targetAlias;
            this.clipSource          = clipSource;

            if (this.fileSettingsService != null)
            {
                if (targetAlias == null)
                {
                    this.fileSettingsService.LoadSettings(this.clipSource);
                }
                else
                {
                    this.fileSettingsService.LoadSettings(this.targetAlias, this.clipSource);
                }
            }
        }
Example #19
0
 public void UnloadSettings(KStudioClipSource clipSource)
 {
     this.UnloadSettingsInternal(null, clipSource);
 }
Example #20
0
 public PlaybackFileSettings(IFileSettingsService fileSettingsService, KStudioClipSource clipSource)
 {
     this.Initialize(fileSettingsService, null, clipSource);
 }
Example #21
0
        public XElement GetSettings(KStudioClipSource clipSource, string settingsKey)
        {
            this.LoadSettingsInternal(null, clipSource);

            return(this.GetSettingsInternal(null, clipSource, settingsKey));
        }
        private void UnloadSettingsInternal(string targetAlias, KStudioClipSource clipSource)
        {
            if (clipSource == null)
            {
                throw new ArgumentNullException("clipSource");
            }

            Guid identifier = GetFileId(targetAlias, clipSource);

            lock (this.fileSettings)
            {
                XDocument xml;
                if (this.fileSettings.TryGetValue(identifier, out xml))
                {
                    string fileName = GetFileName(targetAlias, identifier);
                    try
                    {
                        xml.Save(fileName);
                    }
                    catch (Exception)
                    {
                        // TODO_LOG
                    }

                    this.fileSettings.Remove(identifier);
                }
            }
        }
        public XElement GetSettings(KStudioClipSource clipSource, string settingsKey)
        {
            this.LoadSettingsInternal(null, clipSource);

            return this.GetSettingsInternal(null, clipSource, settingsKey);
        }
 public void UnloadSettings(KStudioClipSource clipSource)
 {
     this.UnloadSettingsInternal(null, clipSource);
 }
        private static Guid GetFileId(string targetAlias, KStudioClipSource clipSource)
        {
            Debug.Assert(clipSource != null);

            Guid value = clipSource.Id;

            if (value == Guid.Empty)
            {
                KStudioEventFile file = clipSource as KStudioEventFile;
                if (file == null)
                {
                    throw new ArgumentOutOfRangeException("clipSource",  "not a KStudioEventFile");
                }
                else
                {
                    // File did not have a real identifier (legacy file), so create one that is "reasonable"

                    string fileNameUpper = file.FilePath.ToUpperInvariant();
                    int fullPathHash = fileNameUpper.GetHashCode();
                    fileNameUpper = Path.GetFileName(fileNameUpper.Reverse());
                    int fileNameHash = fileNameUpper.GetHashCode();

                    if (targetAlias == null)
                    {
                        value = new Guid((UInt32)fullPathHash,
                            (UInt16)fileNameHash,
                            (UInt16)(((UInt32)fileNameHash) >> 16),
                            0, 0, 0, 0, 0, 0, 0, 0);
                    }
                    else
                    {
                        string targetAliasUpper = targetAlias.ToUpperInvariant();
                        UInt32 targetAliasHash1 = (UInt32)targetAliasUpper.GetHashCode();
                        targetAliasUpper= targetAliasUpper.Reverse();
                        UInt32 targetAliasHash2 = (UInt32)targetAliasUpper.GetHashCode();

                        value = new Guid((UInt32)fullPathHash,
                            (UInt16)fileNameHash,
                            (UInt16)(((UInt32)fileNameHash) >> 16),
                            (byte)targetAliasHash1,
                            (byte)(targetAliasHash1 >> 8),
                            (byte)(targetAliasHash1 >> 16),
                            (byte)(targetAliasHash1 >> 24),
                            (byte)targetAliasHash2,
                            (byte)(targetAliasHash2 >> 8),
                            (byte)(targetAliasHash2 >> 16),
                            (byte)(targetAliasHash2 >> 24));
                    }
                }
            }

            return value;
        }