private void btnChAddOne_Click(object sender, EventArgs e) { var chNum = _contextProfile.FullChannels.Count; var ch = new Channel(string.Format("Channel {0}", chNum + 1), Color.White, chNum); _contextProfile.AddChannelObject(ch); _contextProfile.Freeze(); _internalUpdate = true; AddRow(_contextProfile.FullChannels[chNum], chNum + 1); _internalUpdate = false; _contextProfile.IsDirty = true; SelectLastRow(); }
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); }