public CreateSectionThreadingObj(Volume vol, string path, XElement SectionElement) { this.reader = SectionElement; this.volume = vol; this.SectionPath = path; this.DescriptiveString = SectionElement.ToString(); }
// public string[] TransformNames { get { return _Volume.Transforms.Keys.ToArray(); } } public VolumeViewModel(Volume volume, System.ComponentModel.BackgroundWorker workerThread) { _Volume = volume; SectionViewModels = new SortedList<int, SectionViewModel>(_Volume.Sections.Length); foreach (Section s in _Volume.Sections) { SectionViewModel sectionViewModel = new SectionViewModel(volume, s); SectionViewModels.Add(s.Number, sectionViewModel); } }
public VolumeViewModel(string path, string localCachePath, System.ComponentModel.BackgroundWorker workerThread) { _Volume = new Volume(path, localCachePath, workerThread); SectionViewModels = new SortedList<int, SectionViewModel>(_Volume.Sections.Length); foreach (Section s in _Volume.Sections) { SectionViewModel sectionViewModel = new SectionViewModel(this, s); SectionViewModels.Add(s.Number, sectionViewModel); } }
public Section(Volume vol, string path, XElement sectionElement) : this(vol) { this._SectionSubPath = path; //reader.Read(); //XElement sectionElement = XDocument.ReadFrom(reader) as XElement; Debug.Assert(sectionElement != null); if(IO.GetAttributeCaseInsensitive(sectionElement,"name") != null) this.Name = IO.GetAttributeCaseInsensitive(sectionElement, "name").Value; this.Number = System.Convert.ToInt32(IO.GetAttributeCaseInsensitive(sectionElement,"number").Value); if (this.Name == null) this.Name = this.Number.ToString(); foreach (XNode node in sectionElement.Nodes()) { XElement elem = node as XElement; if (elem == null) continue; switch (elem.Name.LocalName.ToLower()) { case "transform": //Load a transform that can be applied to <Pyramids> string Name = IO.GetAttributeCaseInsensitive(elem, "name").Value; string mosaicTransformPath = IO.GetAttributeCaseInsensitive(elem, "path").Value; bool UseForVolume = System.Convert.ToBoolean(IO.GetAttributeCaseInsensitive(elem, "UseForVolume").Value); string TilePrefix = null; if (IO.GetAttributeCaseInsensitive(elem, "FilePrefix") != null) TilePrefix = IO.GetAttributeCaseInsensitive(elem, "FilePrefix").Value; string TilePostfix = IO.GetAttributeCaseInsensitive(elem, "FilePostfix").Value; TilesToSectionMapping mapping = new TilesToSectionMapping(this, Name, this.Path, mosaicTransformPath, TilePrefix, TilePostfix); PyramidTransformNames.Add(Name); WarpedTo.Add(Name, mapping); if (UseForVolume || string.IsNullOrEmpty(DefaultPyramidTransform)) { DefaultPyramidTransform = Name; } break; case "pyramid": //Load an image pyramid whose tiles can be warped using a <transform> Name = IO.GetAttributeCaseInsensitive(elem, "name").Value; // string Pyramidpath = GetAttributeCaseInsensitive(elem,"path").Value; /*PORT: The viewmodel needs to set this if (UI.State.CurrentMode.Length == 0) UI.State.CurrentMode = Pyramidpath; */ Pyramid pyramid = new Pyramid(elem); if(!this.ImagePyramids.ContainsKey(pyramid.Name)) this.ImagePyramids.Add(pyramid.Name, pyramid); if (DefaultPyramid == null || DefaultPyramid.Length == 0) DefaultPyramid = pyramid.Name; else { if (this.ImagePyramids[DefaultPyramid].GetLevels().Count < pyramid.GetLevels().Count) DefaultPyramid = pyramid.Name; } ChannelNames.Add(pyramid.Name); break; case "tileset": //Load a pre-transformed pyramid whose tiles have a fixed size TileGridMapping tilegridmapping = TileGridMapping.CreateFromTilesetElement(elem, this); this.AddTileset(tilegridmapping); DefaultTileset = tilegridmapping.Name; /*PORT: The viewmodel needs to set this if (UI.State.CurrentMode.Length == 0 || UI.State.CurrentMode == "8-bit") UI.State.CurrentMode = mosaicTransformPath; */ break; case "channelinfo": this.ChannelInfoArray = ChannelInfo.FromXML(elem); break; case "notes": if (elem.Value != null) { //string SourceFilename = IO.GetAttributeCaseInsensitive(elem, "SourceFilename").Value; string NotesString = elem.Value; NotesString = NotesString.Trim(); this.Notes = Uri.UnescapeDataString(NotesString); /* if (String.Compare(encodingType, "txt", true) == 0) { this.Notes = Uri.UnescapeDataString(elem.Value); } else { //Convert the string from hex to bytes System.Text.UTF8Encoding encoder = new UTF8Encoding(); this.Notes = encoder.GetString(encoder.GetBytes(NotesString)); } */ } break; } } }
private Section(Volume vol) { this.volume = vol; }
public Section(Volume vol, string path) : this(vol) { this._SectionSubPath = path; string filename = System.IO.Path.GetFileNameWithoutExtension(path); //We expect the first part of the filename to be a section #: int iSectionNumberEnd = 0; for (int i = 0; i < filename.Length; i++) { if (char.IsDigit(filename[i]) == false) break; iSectionNumberEnd = i; } string sectionNumber = filename; if (iSectionNumberEnd + 1 < filename.Length) sectionNumber = filename.Remove(iSectionNumberEnd + 1); try { this.Number = System.Convert.ToInt32(sectionNumber); } catch (Exception e) { throw new ArgumentException("The name of each directory in a volume must start with a number indicating which section the directory contains.\n" + "This directory did not have a section number: " + path, e); /*PORT System.Windows.Forms.MessageBox.Show("The name of each directory in a volume must start with a number indicating which section the directory contains.\n" + "This directory did not have a section number: " + path); */ } LoadLocal(path); }
public SectionViewModelBase(Volume Volume, Section section) { this._VolumeModel = Volume; this.section = section; }
public SectionViewModel(Volume Volume, Section section) : base(Volume, section) { }