Exemplo n.º 1
0
        public override void SaveProfile(Profile profile)
        {
            var profileXml = Xml.CreateXmlDocument("Profile");

            BaseSaveProfile(profileXml, profile, FormatChannel);
            Group.SaveToXml(profileXml.DocumentElement, profile.Groups);

            profileXml.Save(profile.FileName);
            profile.IsDirty = false;
        }
Exemplo n.º 2
0
        public override void SaveProfile(Profile profile)
        {
            var profileXml = Xml.CreateXmlDocument("Profile");

            BaseSaveProfile(profileXml, profile, FormatChannel);
            var profileNode = Xml.GetNodeAlways(profileXml, "Profile");
            BaseSaveSortOrders(profileNode, profile);
            BaseSaveNativeData(profile.FileName, profile.Groups);

            profileXml.Save(profile.FileName);
            profile.IsDirty = false;
        }
Exemplo n.º 3
0
 public SequenceProgram(EventSequence sequence)
 {
     _profile = null;
     UseSequencePluginData = false;
     TreatAsLocal = false;
     _key = Host.GetUniqueKey();
     _mask = null;
     FileName = sequence.FileName;
     ConstructUsing();
     SetupData = sequence.PlugInData;
     EventSequences.Add(new EventSequenceStub(sequence));
 }
Exemplo n.º 4
0
        protected static Profile BaseOpenProfile(string fileName, IFileIOHandler ioHandler)
        {
            var p = new Profile {FileIOHandler = ioHandler};

            var document = new XmlDocument();
            document.Load(fileName);
            XmlNode documentElement = document.DocumentElement;
            p.FileName = fileName;
            p.ClearChannels();
            if (documentElement != null) {
                var channelObjectsNode = documentElement.SelectNodes("ChannelObjects/*");
                if (channelObjectsNode != null) {
                    foreach (XmlNode channelObject in channelObjectsNode) {
                        p.AddChannelObject(new Channel(channelObject), false);
                    }
                }

                var outputNodes = documentElement.SelectSingleNode("Outputs");
                if (outputNodes != null) {
                    foreach (var outputChannel in outputNodes.InnerText.Split(',').Where(outputChannel => outputChannel.Length > 0)) {
                        p.AddChannelOutput(Convert.ToInt32(outputChannel));
                    }
                }
            }
            p.PlugInData.LoadFromXml(documentElement);
            p.Groups = Group.LoadFromXml(documentElement) ?? new Dictionary<string, GroupData>();
            p.IsDirty = Group.LoadFromFile(documentElement, p.Groups);
            if (documentElement != null) {
                var disabledChannelsNode = documentElement.SelectSingleNode("DisabledChannels");
                if (disabledChannelsNode != null) {
                    foreach (
                        var disabledChannel in disabledChannelsNode.InnerText.Split(',').Where(disabledChannel => disabledChannel != string.Empty)) {
                        p.Channels[Convert.ToInt32(disabledChannel)].Enabled = false;
                    }
                }
            }

            p.Freeze();

            return p;
        }
Exemplo n.º 5
0
 public EventSequence()
 {
     _fullChannels = new List<Channel>();
     Channels = new List<Channel>();
     PlugInData = new SetupData();
     Extensions = new SequenceExtensions();
     EventValues = null;
     _eventPeriod = 100;
     MinimumLevel = 0;
     MaximumLevel = 255;
     Audio = null;
     TotalEventPeriods = 0;
     WindowWidth = 0;
     WindowHeight = 0;
     ChannelWidth = 0;
     EngineType = EngineType.Standard;
     _profile = null;
     TreatAsLocal = false;
     AudioDeviceIndex = -1;
     AudioDeviceVolume = 0;
     Key = Host.GetUniqueKey();
 }
Exemplo n.º 6
0
 public abstract void SaveProfile(Profile profile);
Exemplo n.º 7
0
        protected static void BaseSaveSortOrders(XmlNode profileNode, Profile profile)
        {
            var sortOrders = Xml.GetEmptyNodeAlways(profileNode, "SortOrders");
            Xml.SetAttribute(sortOrders, "lastSort", "-1"); // always default to none since we don't track this anywhere.

            var ownerDoc = profileNode.OwnerDocument;

            if (ownerDoc == null) {
                throw new ArgumentNullException("profileNode", "Somehow your profile node is a lost child!  Sorry I have to exit.");
            }

            foreach (var g in profile.Groups.Where(g => g.Value.IsSortOrder)) {
                var groupValue = g.Value;

                var cso = ownerDoc.CreateElement("SortOrder");
                var originalName = groupValue.Name.Replace(" (Sort Order)", "").Trim();
                Xml.SetAttribute(cso, "name", originalName);
                cso.InnerText = groupValue.GroupChannels;

                sortOrders.AppendChild(cso);
            }
        }
Exemplo n.º 8
0
        protected static void BaseSaveProfile(XmlDocument doc, Profile profileObject, FormatChannelDelegate fc)
        {
            profileObject.Freeze(); // fix VIX-53
            XmlNode profileDoc = doc.DocumentElement;

            var channelObjectsNode = Xml.GetEmptyNodeAlways(profileDoc, "ChannelObjects");
            foreach (var channel in profileObject.Channels) {
                channelObjectsNode.AppendChild(fc(doc, channel));
            }

            var outputs = string.Join(",", (from c in profileObject.Channels select c.OutputChannel.ToString()).ToArray());
            Xml.GetEmptyNodeAlways(profileDoc, "Outputs").InnerText = outputs;

            if (profileDoc != null) {
                profileDoc.AppendChild(doc.ImportNode(profileObject.PlugInData.RootNode, true));
            }

            var disabledChannels = string.Join(",",
                (from c in profileObject.Channels where !c.Enabled select profileObject.Channels.FindIndex(i => i == c).ToString()).ToArray());
            Xml.SetValue(profileDoc, "DisabledChannels", disabledChannels);
        }
Exemplo n.º 9
0
 private void DetachFromProfile()
 {
     FileIOHandler.LoadEmbeddedData(FileName, this);
     _fullChannels.Clear();
     _fullChannels.AddRange(_profile.FullChannels);
     _profile = null;
     UpdateEventValueArray();
 }
Exemplo n.º 10
0
 public void ReloadProfile()
 {
     if (_profile == null) {
         return;
     }
     _profile = FileIOHandler.OpenProfile(_profile.FileName);
     LoadFromProfile();
 }
Exemplo n.º 11
0
 public void AttachToProfile(Profile profile)
 {
     _profile = profile;
     _profile.Freeze();
     LoadFromProfile();
 }
Exemplo n.º 12
0
 public void SaveProfile(Profile profile)
 {
     throw new NotSupportedException("Format does not support profiles.");
 }
Exemplo n.º 13
0
 private void Initialize(Profile profile)
 {
     if (Mode == EngineMode.Synchronous) {
         throw new Exception("Only an asynchronous engine instance can be initialized with a profile.");
     }
     profile.Freeze();
     InitializeForAsynchronous(profile);
 }
Exemplo n.º 14
0
 private void SetProfile(Profile profile)
 {
     _sequence.Profile = profile;
     _sequence.Groups = profile.Groups;
     UpdateGroups();
     ReactToProfileAssignment();
     IsDirty = true;
 }
Exemplo n.º 15
0
        private Profile GetContextProfile(string fileName = null)
        {
            var context = new Profile();
            if (null != fileName) {
                context.FileName = fileName;
            }
            context.InheritChannelsFrom(_sequence);
            context.InheritPlugInDataFrom(_sequence);
            context.Groups = _sequence.Groups;
            context.FileIOHandler = _sequence.FileIOHandler;

            return context;
        }