/// <summary> /// Channel info can be specified in an XML file, this reads that information /// </summary> /// <param name="elem"></param> /// <returns></returns> public static ChannelInfo[] FromXML(XElement elemChannelInfo) { if (elemChannelInfo == null) return new ChannelInfo[0]; List<ChannelInfo> channels = new List<ChannelInfo>(); foreach (XNode node in elemChannelInfo.Nodes()) { XElement elem = node as XElement; if (elem == null) continue; switch (elem.Name.LocalName) { case "Channel": bool CreateChannel = true; string Section = "Selected"; if (Utils.IO.GetAttributeCaseInsensitive(elem,"Section") != null) Section = IO.GetAttributeCaseInsensitive(elem,"Section").Value; int? SectionNumber = new int?(); ChannelInfo.SectionInfo refSectionInfo = SectionInfo.FIXED; switch (Section.ToLower()) { case "selected": refSectionInfo = SectionInfo.SELECTED; break; case "above": refSectionInfo = SectionInfo.ABOVE; break; case "below": refSectionInfo = SectionInfo.BELOW; break; default: try { SectionNumber = new int?(System.Convert.ToInt32(Section)); refSectionInfo = SectionInfo.FIXED; } catch (FormatException ) { Trace.WriteLine("Cannot format Section attribute of ChannelInfo: " + elem.ToString(), "VolumeModel"); CreateChannel = false; } break; } string Channel = ""; if (IO.GetAttributeCaseInsensitive(elem, "Channel") != null) { Channel = IO.GetAttributeCaseInsensitive(elem, "Channel").Value; if (Channel == "Selected") Channel = ""; } string Color = "#FFFFFF"; if (IO.GetAttributeCaseInsensitive(elem, "Color") != null) Color = IO.GetAttributeCaseInsensitive(elem, "Color").Value; //Convert the color to a valid value Geometry.Graphics.Color ChannelColor; System.Drawing.Color FromNameColor = System.Drawing.Color.FromName(Color); //If the color is unknown we have all zeros in the color if (FromNameColor.A == 0 && FromNameColor.B == 0 && FromNameColor.G == 0 && FromNameColor.R == 0) { int ColorValue = 0; try { if (Color.StartsWith("#")) { Color = Color.Substring(1); ColorValue = Int32.Parse(Color, System.Globalization.NumberStyles.HexNumber); } else if (Color.StartsWith("0x")) { Color = Color.Substring(2); ColorValue = Int32.Parse(Color, System.Globalization.NumberStyles.HexNumber); } else { ColorValue = Int32.Parse(Color, System.Globalization.NumberStyles.Integer); } } catch (FormatException ) { Trace.WriteLine("Cannot format Color attribute of ChannelInfo: " + elem.ToString(), "VolumeModel"); CreateChannel = false; } ChannelColor = new Geometry.Graphics.Color((Byte)(ColorValue >> 16), (Byte)(ColorValue >> 8), (Byte)(ColorValue), (Byte)(255 - (ColorValue >> 24))); } else { ChannelColor = new Geometry.Graphics.Color(FromNameColor.R, FromNameColor.G, FromNameColor.B, FromNameColor.A); } if (CreateChannel) { ChannelInfo newChannel = new ChannelInfo(); newChannel.ChannelName = Channel; newChannel.Color = ChannelColor; newChannel.SectionSource = refSectionInfo; newChannel.FixedSectionNumber = SectionNumber; channels.Add(newChannel); } break; } } return channels.ToArray(); }
public object Clone() { ChannelInfo clone = new ChannelInfo(); clone.ChannelName = this.ChannelName; clone.Color = this.Color; clone.FixedSectionNumber = this.FixedSectionNumber; clone.SectionSource = this.SectionSource; return clone; }
/// <summary> /// /// </summary> /// <param name="path">The host and path to the volume, no filenames</param> /// <param name="localCachePath">LocaL cache path corresponding to the path</param> /// <param name="workerThread">optional worker thread to report progress</param> public Volume(string path, string localCachePath, XDocument VolumeXML, System.ComponentModel.BackgroundWorker workerThread) { //Load the default settings from user preferences //ChannelInfo DefaultChannel = new ChannelInfo(); DefaultChannels = new ChannelInfo[0]; this._Host = path; this.LocalCachePath = localCachePath; Initialize(VolumeXML, workerThread); }
internal ChannelPickerControl(ChannelInfo info) : this() { this.Info = info; }
internal SetupChannelsForm(ChannelInfo[] Channels, string[] ChannelNames) { InitializeComponent(); ChannelControl.SetChannelData(Channels, ChannelNames); }