コード例 #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);
                }
            }
        }
コード例 #2
0
        public TimelineInOutPointsCollection(string targetAlias, KStudioClipSource clipSource)
            : base(targetAlias, clipSource)
        {
            DebugHelper.AssertUIThread();

            this.OnLoad();
        }
コード例 #3
0
        public void UnloadSettings(string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrEmpty(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

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

            UnloadSettingsInternal(targetAlias, clipSource);
        }
コード例 #5
0
        public PlaybackFileSettings(IFileSettingsService fileSettingsService, string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrWhiteSpace(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

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

            this.markers = markers;

            this.OnLoad();
        }
コード例 #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));
        }
コード例 #8
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);
        }
コード例 #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);
        }
コード例 #10
0
        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>();
        }
コード例 #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;
                }
            }
        }
コード例 #12
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;
                }
            }
        }
コード例 #13
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);
                }
            }
        }
コード例 #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);
        }
コード例 #15
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;
        }
コード例 #16
0
 public PlaybackFileSettings(IFileSettingsService fileSettingsService, KStudioClipSource clipSource)
 {
     this.Initialize(fileSettingsService, null, clipSource);
 }
コード例 #17
0
        public PlaybackFileSettings(IFileSettingsService fileSettingsService, string targetAlias, KStudioClipSource clipSource)
        {
            if (String.IsNullOrWhiteSpace(targetAlias))
            {
                throw new ArgumentNullException("targetAlias");
            }

            this.Initialize(fileSettingsService, targetAlias, clipSource);
        }
コード例 #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);
                }
            }
        }
コード例 #19
0
 public void UnloadSettings(KStudioClipSource clipSource)
 {
     this.UnloadSettingsInternal(null, clipSource);
 }
コード例 #20
0
 public PlaybackFileSettings(IFileSettingsService fileSettingsService, KStudioClipSource clipSource)
 {
     this.Initialize(fileSettingsService, null, clipSource);
 }
コード例 #21
0
        public XElement GetSettings(KStudioClipSource clipSource, string settingsKey)
        {
            this.LoadSettingsInternal(null, clipSource);

            return(this.GetSettingsInternal(null, clipSource, settingsKey));
        }
コード例 #22
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);
                }
            }
        }
コード例 #23
0
        public XElement GetSettings(KStudioClipSource clipSource, string settingsKey)
        {
            this.LoadSettingsInternal(null, clipSource);

            return this.GetSettingsInternal(null, clipSource, settingsKey);
        }
コード例 #24
0
 public void UnloadSettings(KStudioClipSource clipSource)
 {
     this.UnloadSettingsInternal(null, clipSource);
 }
コード例 #25
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;
        }