readonly bool isGroupDef; // layouts are groupdefs too public Group(XElement xml) : base(xml) { var type = xml.Name.LocalName; switch (type.ToLower(CultureInfo.InvariantCulture)) { case "layout": case "groupdef": isGroupDef = true; DataContextChanged += (s, e) => { InstantiateGroupDef(xml); }; break; case "group": break; default: isGroupDef = true; DataContextChanged += (s, e) => { InstantiateGroupDef(ElementStore.GetGroupDef(type)); }; break; } Content = panel; }
public override void Build() { var sw = new Stopwatch(); sw.Start(); var kvUsageMemoryStream = new MemoryStream(); KvUsage = new KeyValueUsage(kvUsageMemoryStream); var keyValueStoreFile = new MemoryStream(); KvIndex = new KeyValueIndex(Settings.Search.KvIndexCapacity, Settings.Search.PrefixLength); KvStore = new KeyValueStore(KvIndex, KvUsage, keyValueStoreFile); var storeFile = new MemoryStream(); Store = new ElementStore(KvStore, storeFile, ObjectPool); Tree = new RTree <uint>(65); _reader.Read(new ReaderContext { SourceStream = _sourceStream, Builder = this, ReuseEntities = false, SkipTags = false, }); Clear(); Complete(); sw.Stop(); Trace.Debug(CategoryKey, Strings.IndexBuildInMs, sw.ElapsedMilliseconds.ToString()); }
protected override void ProcessXmlProperty(string name, string value) { // TODO handle get switch (name) { case "topleft": topleft.Source = ElementStore.GetBitmap(value); break; case "top": top.Source = ElementStore.GetBitmap(value); break; case "topright": topright.Source = ElementStore.GetBitmap(value); break; case "left": left.Source = ElementStore.GetBitmap(value); break; case "middle": middle.Source = ElementStore.GetBitmap(value); break; case "right": right.Source = ElementStore.GetBitmap(value); break; case "bottomleft": bottomleft.Source = ElementStore.GetBitmap(value); break; case "bottom": bottom.Source = ElementStore.GetBitmap(value); break; case "bottomright": bottomright.Source = ElementStore.GetBitmap(value); break; } base.ProcessXmlProperty(name, value); }
public SkinBootstrapper() { try { var reader = new WinampXmlReader(Path.Combine(root, "skin.xml")); var skin = XDocument.Load(reader); var store = new ElementStore(skin.Elements().First(), root) { Next = environment }; store.Preload(); var containers = skin .Elements() .First() .Elements("container"); var main = containers .Where(c => c.Attribute("id").Value == "main") .First(); Container.FromXml(main, store).Show(); store.System.Run(); } catch (DirectoryNotFoundException) { } }
public TestableIndexBuilder(IndexSettings settings, IObjectPool objectPool, ITrace trace) : base(settings, objectPool, trace) { Store = new ElementStore(new KeyValueStore(new KeyValueIndex(1000, 3), new KeyValueUsage(new MemoryStream()), new MemoryStream()), new MemoryStream(), TestHelper.GetObjectPool()); Tree = new RTree <uint>(); }
protected override void ProcessXmlProperty(string name, string value) { base.ProcessXmlProperty(name, value); switch (name) { case "image": img.Source = ElementStore.GetBitmap(value); break; } }
/// <summary> Creates instance of <see cref="ElementSource" /> from persistent storage. </summary> /// <param name="directory">Already resolved directory which contains all indecies.</param> /// <param name="fileService">File system service.</param> /// <param name="objectPool">ObjectPool.</param> internal ElementSource(string directory, IFileSystemService fileService, IObjectPool objectPool) { // load map data from streams BoundingBox = PersistentIndexBuilder.ReadBoundingBox(fileService.ReadStream(string.Format(MapConsts.HeaderPathFormat, directory))); KvUsage = new KeyValueUsage(fileService.ReadStream(string.Format(MapConsts.KeyValueUsagePathFormat, directory))); KvIndex = KeyValueIndex.Load(fileService.ReadStream(string.Format(MapConsts.KeyValueIndexPathFormat, directory))); KvStore = new KeyValueStore(KvIndex, KvUsage, fileService.ReadStream(string.Format(MapConsts.KeyValueStorePathFormat, directory))); ElementStore = new ElementStore(KvStore, fileService.ReadStream(string.Format(MapConsts.ElementStorePathFormat, directory)), objectPool); SpatialIndexTree = SpatialIndex.Load(fileService.ReadStream(string.Format(MapConsts.SpatialIndexPathFormat, directory))); IsReadOnly = true; }
/// <summary> /// Creates instance of <see cref="ElementSource" /> from streams and /// created spatial index. /// </summary> internal ElementSource(BoundingBox boundingBox, KeyValueUsage keyValueUsage, KeyValueIndex keyValueIndex, KeyValueStore keyValueStore, ElementStore elementStore, ISpatialIndex <uint> spatialIndex) { BoundingBox = boundingBox; KvUsage = keyValueUsage; KvIndex = keyValueIndex; KvStore = keyValueStore; ElementStore = elementStore; SpatialIndexTree = spatialIndex; IsReadOnly = true; }
protected override void ProcessXmlProperty(string name, string value) { if (name == "image") { Content = new Image() { Source = ElementStore.GetBitmap(value), Stretch = Stretch.Fill }; } base.ProcessXmlProperty(name, value); }
public void VisitElementStore(ElementStore node) { node.Array.Accept(this); node.Index.Accept(this); node.Value.Accept(this); if (!node.IsStatementExpression) { _emitter.Emit(OpCodes.Dup); } _emitter.Emit(OpCodes.Stelem_I4); }
protected override void ProcessXmlProperty(string name, string value) { switch (name) { case "left": Grid.SetColumn(FromXml(ElementStore.GetGroupDef(value), ElementStore), 0); break; case "right": Grid.SetColumn(FromXml(ElementStore.GetGroupDef(value), ElementStore), 1); break; } base.ProcessXmlProperty(name, value); }
public void Setup() { var keyValueStream = new MemoryStream(new byte[256]); keyValueStream.WriteByte(4); keyValueStream.WriteByte(7); var kvUsage = new KeyValueUsage(new MemoryStream(1000)); var index = new KeyValueIndex(100, 3); var keyValueStore = new KeyValueStore(index, kvUsage, keyValueStream); var elementStoreStream = new MemoryStream(new byte[10000]); _store = new ElementStore(keyValueStore, elementStoreStream, TestHelper.GetObjectPool()); }
public override void Build() { var sw = new Stopwatch(); sw.Start(); var sourceStream = _fileSystemService.ReadStream(_filePath); var format = _filePath.Split('.').Last(); var reader = GetReader(format); var kvUsageMemoryStream = new MemoryStream(); var kvUsage = new KeyValueUsage(kvUsageMemoryStream); var keyValueStoreFile = _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueStorePathFormat, _outputDirectory)); var index = new KeyValueIndex(Settings.Search.KvIndexCapacity, Settings.Search.PrefixLength); var keyValueStore = new KeyValueStore(index, kvUsage, keyValueStoreFile); var storeFile = _fileSystemService.WriteStream(String.Format(MapConsts.ElementStorePathFormat, _outputDirectory)); Store = new ElementStore(keyValueStore, storeFile, ObjectPool); Tree = new RTree <uint>(65); reader.Read(new ReaderContext { SourceStream = sourceStream, Builder = this, ReuseEntities = false, SkipTags = false, }); Clear(); Complete(); using (var kvFileStream = _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueUsagePathFormat, _outputDirectory))) { var buffer = kvUsageMemoryStream.GetBuffer(); kvFileStream.Write(buffer, 0, (int)kvUsageMemoryStream.Length); } KeyValueIndex.Save(index, _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueIndexPathFormat, _outputDirectory))); SpatialIndex.Save(Tree, _fileSystemService.WriteStream(String.Format(MapConsts.SpatialIndexPathFormat, _outputDirectory))); Store.Dispose(); sw.Stop(); Trace.Debug(CategoryKey, Strings.IndexBuildInMs, sw.ElapsedMilliseconds.ToString()); }
public static Container FromXml(XElement x, ElementStore store) { var result = new Container() { DataContext = new ElementStore(x, store.Root) { Next = store } }; foreach (var a in x.Attributes()) { result.SetXmlProperty(a.Name.LocalName, a.Value); } result.Content = GuiObject.FromXml(x.Element("layout"), store); return(result); }
public void Setup() { var boundingBox = new BoundingBox(new GeoCoordinate(52.0, 13.0), new GeoCoordinate(52.2, 13.2)); var keyValueStream = new MemoryStream(new byte[256]); keyValueStream.WriteByte(4); keyValueStream.WriteByte(7); var kvIndex = new KeyValueIndex(100, 3); var kvUsage = new KeyValueUsage(new MemoryStream(1000)); var kvStore = new KeyValueStore(kvIndex, kvUsage, keyValueStream); var elementStoreStream = new MemoryStream(new byte[10000]); var elementStore = new ElementStore(kvStore, elementStoreStream, TestHelper.GetObjectPool()); var tree = new RTree <uint>(); var node = new Node() { Id = 1, Coordinate = new GeoCoordinate(52.0, 13.0), Tags = new Dictionary <string, string>() { { "key1", "value1" }, { "key2", "value2" } }.ToTags() }; var nodeOffset = elementStore.Insert(node); tree.Insert(nodeOffset, new PointEnvelop(node.Coordinate)); var way = new Way() { Id = 2, Coordinates = new List <GeoCoordinate>() { new GeoCoordinate(52.1, 13.1), new GeoCoordinate(52.2, 13.2) }, Tags = new Dictionary <string, string>() { { "key1", "value1" }, { "key2", "value2" } }.ToTags() }; var wayOffset = elementStore.Insert(way); tree.Insert(wayOffset, new Envelop(way.Coordinates.First(), way.Coordinates.Last())); _source = new ElementSource(boundingBox, kvUsage, kvIndex, kvStore, elementStore, tree); }
protected void InstantiateGroupDef(XElement groupdef) { if (groupdef == null) { return; } foreach (var go in groupdef.Elements().Select(x => FromXml(x, ElementStore))) { panel.Children.Add(go); } foreach (var xscript in groupdef.Elements("script")) { var file = xscript.Attribute("file")?.Value ?? string.Empty; var param = xscript.Attribute("param")?.Value ?? string.Empty; Debug.WriteLine("Loading script " + file); var script = ElementStore.System.LoadScript(ElementStore.FindScript(file), this, param, file); } }
protected override void ProcessXmlProperty(string name, string value) { base.ProcessXmlProperty(name, value); switch (name) { case "id": if (!isGroupDef) { panel.Children.Clear(); InstantiateGroupDef(ElementStore.GetGroupDef(value)); } break; case "instanceid": InstanceId = value; break; } }
public void VisitElementStore(ElementStore node) { var arrayType = InferType(node.Array, _context) as ArrayType; var indexType = InferType(node.Index, _context); var valueType = InferType(node.Value, _context); if (arrayType == null) { throw new TypeInferenceException("Array access expression must have an array type"); } if (indexType != KnownType.Int32) { throw new TypeInferenceException("Array element store index must have only a int32 type"); } if (!arrayType.ContainedType.Equals(valueType)) { throw new TypeInferenceException("Array contained type must be assignable from a value type"); } _type = arrayType; }
protected override void ProcessXmlProperty(string name, string value) { switch (name.ToLower(CultureInfo.InvariantCulture)) { case "image": img.Source = neutral = ElementStore.GetBitmap(value); break; case "hoverimage": hover = ElementStore.GetBitmap(value); break; case "downimage": down = ElementStore.GetBitmap(value); break; default: base.ProcessXmlProperty(name, value); break; } }
public static GuiObject FromXml(XElement xml, ElementStore store) { var type = xml.Name.LocalName; var xui = default(XElement); switch (type.ToLower(CultureInfo.InvariantCulture)) { case "group": case "layout": return(new Group(xml)); case "grid": return(new WGrid(xml)); case "wasabiframe": return(new Frame(xml)); case "button": return(new WButton(xml)); case "layer": return(new Layer(xml)); case "text": return(new WText(xml)); default: if ((xui = store.GetGroupDef(type)) != null) { return(new Group(xml)); } else { return(new ImageTest(xml)); } } }
static SkinBootstrapper() { var env = new[] { @"about\about.xml", @"checkbox\checkbox.xml", @"combobox\combobox.xml", @"dropdownlist\dropdownlist.xml", @"guiobjects.xml", @"historyeditbox\historyeditbox.xml", @"menubutton\menubutton.xml", @"msgbox\msgbox.xml", @"pathpicker\pathpicker.xml", @"popupmenu\popupmenu.xml", @"statusbar\statusbar.xml", @"tabsheet\tabsheet.xml", @"titlebox\titlebox.xml", @"tooltips\tooltips.xml", @"wasabi\wasabi.xml", @"winamp\cover\cover.xml", @"winamp\thinger\thinger.xml" }; foreach (var e in env) { var path = Path.Combine(root2, e); var wxr = new WinampXmlReader(path); var es = new ElementStore( XDocument.Load(wxr).Elements().First(), Path.GetDirectoryName(path)) { Next = environment }; environment = es; } }
public Derived() { ElementStore.Add("Foo"); ElementStore.Add("Bar"); }