protected override void PluginInitialize() { Console.WriteLine("Initializing Sample Plugin"); timeout_id = GLib.Timeout.Add(5000, OnTimeout); source = new SampleSource(); SourceManager.AddSource(source); }
public void Dispose() { var sm = new SourceManager (); sm.Initialize (); sm.AddSource (new ErrorSource ("Baz")); Assert.IsFalse (sm.Sources.Count == 0); sm.Dispose (); Assert.IsTrue (sm.Sources.Count == 0); }
protected override void InterfaceInitialize() { InstallInterfaceActions(); source = new RadioSource(this); SourceManager.AddSource(source); manager.ReloadStations(false); }
public void AddRemove() { var sm = new SourceManager (); var src = new ErrorSource ("Foo"); sm.AddSource (src, false); Assert.AreEqual (sm.Sources.Count, 1); var src2 = new ErrorSource ("Bar"); sm.AddSource (src2, true); Assert.IsTrue (sm.Sources.Count == 2); Assert.AreEqual (src2, sm.DefaultSource); Assert.AreEqual (src2, sm.ActiveSource); sm.SetActiveSource (src); Assert.AreEqual (src, sm.ActiveSource); sm.RemoveSource (src); Assert.IsTrue (sm.Sources.Count == 1); }
protected override void PluginInitialize() { RegisterConfigurationKey("Username"); RegisterConfigurationKey("Password"); RegisterConfigurationKey("Country"); config = Globals.Configuration; source = new MusicStoreSource(this); SourceManager.AddSource(source); }
protected override void PluginInitialize() { RegisterConfigurationKey("Username"); RegisterConfigurationKey("Password"); gconf = Globals.Configuration; gconf.AddNotify(ConfigurationBase, GConfNotifier); source = new LockerSource(this); SourceManager.AddSource(this.source); }
private static void InitSource() { if (source == null) { PlayerEngineCore.StateChanged += OnPlayerEngineStateChanged; source = new PodcastSource(); SourceManager.AddSource(source); source.Load(); } }
public void AddSource(SourceViewModel sourceViewModel) { try { tbl_Source tblSource = new tbl_Source(); tblSource.SourceDesc = sourceViewModel.sourceDesc; tblSource.daId = sourceViewModel.DAID;//1 tblSource.EntityState = DA.DomainModel.EntityState.Added; SourceManager sourceManager = new SourceManager(); sourceManager.AddSource(tblSource); } catch (Exception) { throw; } }
public void RunDialog() { ResponseType response = (ResponseType)dialog.Run(); //int w = -1, h = -1; //dialog.GetSize (out w, out h); //Console.WriteLine ("w = {0}, h = {1}", w, h); if (response == ResponseType.Ok) { string name = Name; string condition = Condition; string order_by = OrderBy; string limit_number = LimitNumber; ThreadAssist.Spawn(delegate { //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number); if (playlist == null) { playlist = new SmartPlaylist(name, condition, order_by, limit_number); playlist.Source.Commit(); SourceManager.AddSource(playlist.Source); } else { playlist.Name = name; playlist.Condition = condition; playlist.OrderBy = order_by; playlist.LimitNumber = limit_number; playlist.Commit(); } }); } dialog.Destroy(); }
/// <summary> /// /// </summary> /// <param name="n"></param> /// <param name="id"></param> /// <returns></returns> public IOMesh LoadGeometryFromID(Node n, string id, List <IOEnvelope> vertexEnvelopes = null) { // sanitize id = ColladaHelper.SanitizeID(id); // find geometry by id var geom = _collada.Library_Geometries.Geometry.First(e => e.ID == id); // not found if (geom == null) { return(null); } // create new mesh IOMesh mesh = new IOMesh() { Name = n.Name }; // create source manager helper SourceManager srcs = new SourceManager(); if (geom.Mesh.Source != null) { foreach (var src in geom.Mesh.Source) { srcs.AddSource(src); } } // load geomtry meshes if (geom.Mesh.Triangles != null) { foreach (var tri in geom.Mesh.Triangles) { var stride = tri.Input.Max(e => e.Offset) + 1; var poly = new IOPolygon() { PrimitiveType = IOPrimitive.TRIANGLE, MaterialName = tri.Material }; var p = tri.P.GetValues(); for (int i = 0; i < tri.Count * 3; i++) { IOVertex vertex = new IOVertex(); for (int j = 0; j < tri.Input.Length; j++) { var input = tri.Input[j]; var index = p[i * stride + input.Offset]; ProcessInput(input.Semantic, input.source, input.Set, vertex, geom.Mesh.Vertices, index, srcs, vertexEnvelopes); } poly.Indicies.Add(mesh.Vertices.Count); mesh.Vertices.Add(vertex); } mesh.Polygons.Add(poly); } } //TODO: collada trifan //TODO: collada tristrip //TODO: collada linestrip //TODO: collada polylist //TODO: collada polygon return(mesh); }
/// <summary> /// /// </summary> /// <param name="n"></param> /// <param name="id"></param> /// <returns></returns> public IOMesh LoadGeometryControllerFromID(Node n, string id) { // sanitize id = ColladaHelper.SanitizeID(id); // find geometry by id var con = _collada.Library_Controllers.Controller.FirstOrDefault(e => e.ID == id); // not found if (con == null) { return(null); } // load controllers SourceManager srcs = new SourceManager(); foreach (var src in con.Skin.Source) { srcs.AddSource(src); } var v = con.Skin.Vertex_Weights.V.GetValues(); var counts = con.Skin.Vertex_Weights.VCount.GetValues(); var vi = 0; var vertexIndex = 0; List <IOEnvelope> envelopes = new List <IOEnvelope>(); for (int i = 0; i < con.Skin.Vertex_Weights.Count; i++) { var en = new IOEnvelope(); var stride = con.Skin.Vertex_Weights.Input.Length; for (int j = 0; j < counts[i]; j++) { IOBoneWeight bw = new IOBoneWeight(); foreach (var input in con.Skin.Vertex_Weights.Input) { var index = v[vi + input.Offset + j * stride]; switch (input.Semantic) { case Input_Semantic.JOINT: foreach (var jointInput in con.Skin.Joints.Input) { switch (jointInput.Semantic) { case Input_Semantic.JOINT: bw.BoneName = srcs.GetNameValue(jointInput.source, index)[0]; break; case Input_Semantic.INV_BIND_MATRIX: var m = srcs.GetFloatValue(jointInput.source, index); var t = new Matrix4x4( m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]); bw.BindMatrix = t; break; } } break; case Input_Semantic.WEIGHT: bw.Weight = srcs.GetFloatValue(input.source, index)[0]; break; } } en.Weights.Add(bw); } envelopes.Add(en); vi += counts[i] * stride; vertexIndex++; } // load geometry var geom = string.IsNullOrEmpty(con.Skin.sourceid) ? LoadGeometryFromID(n, con.Skin.sID, envelopes) : LoadGeometryFromID(n, con.Skin.sourceid, envelopes); // bind shape if (con.Skin.Bind_Shape_Matrix != null) { var m = con.Skin.Bind_Shape_Matrix.GetValues(); var t = new Matrix4x4( m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]); geom.TransformVertices(t); } return(geom); }
private Task Initialize() { return(ExecuteSafe(async() => { using (await _initializeAsyncLock.LockAsync()) { if (_isInitialized) { return; } var jsonAssets = await _storageService.GetAssetTextFileAsync(ReflectionHelper.GetAttributeOfEnum <DescriptionAttribute, FileKeys>(FileKeys.SourcesConfiguration).Description); var feeds = JsonConvert.DeserializeObject <List <SourceModel> >(jsonAssets); var recovered = false; try { var json = await _storageService.GetRoamingTextFileAsync(ReflectionHelper.GetAttributeOfEnum <DescriptionAttribute, FileKeys>(FileKeys.SourcesUserConfiguration).Description); if (!string.IsNullOrEmpty(json)) { _sourceCacheEntity = JsonConvert.DeserializeObject <SourceCacheEntity>(json); recovered = true; } else { _sourceCacheEntity = new SourceCacheEntity(); } } catch (Exception ex) { LogHelper.Instance.LogException(ex); _sourceCacheEntity = new SourceCacheEntity(); } var feedsToLoad = new List <FeedModel>(); foreach (var source in feeds) { if (!_sourceCacheEntity.IsEnabledDictionary.ContainsKey(source.Guid)) { _sourceCacheEntity.IsEnabledDictionary[source.Guid] = false; recovered = false; } SourceManager.AddSource(source, _sourceCacheEntity.IsEnabledDictionary[source.Guid]); foreach (var feed in source.Feeds) { feed.Source = source; if (!_sourceCacheEntity.IsEnabledDictionary.ContainsKey(feed.Guid)) { _sourceCacheEntity.IsEnabledDictionary[feed.Guid] = false; recovered = false; } SourceManager.AddFeed(feed, source, _sourceCacheEntity.IsEnabledDictionary[feed.Guid]); if (_sourceCacheEntity.IsEnabledDictionary[feed.Guid]) { feedsToLoad.Add(feed); } } } _isInitialized = true; if (!recovered) { await SaveCache(); } var tasks = feedsToLoad.Select(feedModel => LoadArticlesIntoFeed(feedModel, 12)).ToList(); await Task.WhenAll(tasks); } })); }
protected override void PluginInitialize() { source = new RadioSource(this); SourceManager.AddSource(source); LoadMenus(); }