protected override void OnAttached() { base.OnAttached(); m_appliedSample = null; m_subscriptions = SeeingSharpApplication.Current.UIMessenger.SubscribeAll(this); }
public void OneReplacedWithOtherDescendant() { var @base = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "b" } }; var changed = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant2 { Id = 2, Value = "b" } }; var expected = DiffFactory.Create <SampleBase[]>().Ordered() .Changed(1, inner => inner.Value() .Replaced(new SampleDescendant1 { Id = 2, Value = "b" }, new SampleDescendant2 { Id = 2, Value = "b" }) ) .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void SetSample(SampleBase newSample) { // clean up the old sample if (sample != null) { sample.RefreshRequested -= OnRefreshRequested; sample.Destroy(); } sample = newSample; // set the title var title = sample?.Title ?? "SkiaSharp for MacOS"; Title = title; var window = View?.Window; if (window != null) { window.Title = title; } // prepare the sample if (sample != null) { sample.RefreshRequested += OnRefreshRequested; sample.Init(); } // refresh the view OnRefreshRequested(null, null); }
public void OneChangedProperty() { var diff = DiffFactory.Create <SampleBase[]>().Ordered() .Changed(1, inner => inner.Value() .ChangedType <SampleDescendant1>(inner2 => inner2.Class() .Replaced(x => x.Value, "b", "c") ) ) .MakeDiff(); var obj = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "b" } }; var changed = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "c" } }; var ret = Merger.Instance.Partial.ApplyPatch(obj, diff); CollectionAssert.AreEqual(changed, ret); }
public void Setup(SampleSelectorUI parentUI, SampleBase prefab) { this.ParentUI = parentUI; this.ExamplePrefab = prefab; this._text.text = prefab.DisplayName; }
static void CreateExportPlan(GameObject go, SampleBase sample, ExportFunction exportFunc, ExportContext context, string pathSuffix = null, object data = null, bool insertFirst = true) { // This is an exportable object. Transform expRoot = context.exportRoot; string path = UnityTypeConverter.GetPath(go.transform, expRoot); if (!string.IsNullOrEmpty(pathSuffix)) { path += pathSuffix; } if (!context.plans.ContainsKey(go)) { context.plans.Add(go, new ExportPlan()); } var exp = new Exporter { exportFunc = exportFunc, sample = sample, path = path, data = data }; if (insertFirst) { context.plans[go].exporters.Insert(0, exp); } else { context.plans[go].exporters.Add(exp); } // Include the parent xform hierarchy. // Note that the parent hierarchy is memoised, so despite looking expensive, the time // complexity is linear. Transform xf = go.transform.parent; if (xf != context.exportRoot && !context.plans.ContainsKey(xf.gameObject)) { // Since all GameObjects have a Transform, export all un-exported parents as transform. CreateExportPlan(xf.gameObject, CreateSample<XformSample>(context), XformExporter.ExportXform, context); CreateExportPlan(xf.gameObject, CreateSample<XformSample>(context), NativeExporter.ExportObject, context, insertFirst: false); } }
public void OneChangedProperty() { var @base = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "b" } }; var changed = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "c" } }; var expected = DiffFactory.Create <SampleBase[]>().Ordered() .Changed(1, inner => inner.Value() .ChangedType <SampleDescendant1>(inner2 => inner2.Class() .Replaced(x => x.Value, "b", "c") ) ) .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void OneAdded() { var diff = DiffFactory.Create <SampleBase[]>().Ordered() .Added(1, new SampleDescendant1 { Id = 2, Value = "b" }) .MakeDiff(); var obj = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" } }; var changed = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "b" } }; var ret = Merger.Instance.Partial.ApplyPatch(obj, diff); CollectionAssert.AreEqual(changed, ret); }
public void OneAdded() { var @base = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" } }; var changed = new SampleBase[] { new SampleDescendant1 { Id = 1, Value = "a" }, new SampleDescendant1 { Id = 2, Value = "b" } }; var expected = DiffFactory.Create <SampleBase[]>().Ordered() .Added(1, new SampleDescendant1 { Id = 2, Value = "b" }) .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
//private SKImage lastImage; public DetailContentsPage(SampleBase showcase) { InitializeComponent(); Sample = showcase; BindingContext = this; }
public void SetSample(SampleBase newSample) { sample = newSample; // set the title var title = sample?.Title ?? "SkiaSharp for MacOS"; Title = title; var window = View?.Window; if (window != null) { window.Title = title; } // prepare the sample sample?.Init(() => { // refresh the view canvas.SetNeedsDisplayInRect(canvas.Bounds); glview.SetNeedsDisplayInRect(glview.Bounds); }); // refresh the view canvas.SetNeedsDisplayInRect(canvas.Bounds); glview.SetNeedsDisplayInRect(glview.Bounds); }
public void ExecuteExample(SampleBase example) { if (this.dynamicContent != null) { Destroy(this.dynamicContent); } this.dynamicContent = Instantiate(example, this._dyncamicContentRoot, false).gameObject; }
public void Setup(SampleSelectorUI parentUI, SampleBase example) { this._parentUI = parentUI; this._example = example; this._header.text = this._example.name; this._description.text = this._example.Description; }
private void OnSampleSelected(SampleBase sample) { // update the selected sample currentSample = sample; currentSample?.Init(canvas.SetNeedsDisplay); // refresh the canvas canvas.SetNeedsDisplay(); }
public void ChangedType() { SampleBase @base = new SampleDescendant1(); SampleBase left = new SampleDescendant1(); SampleBase right = new SampleDescendant2(); SampleBase ret = Merger.Instance.Merge(@base, left, right); Assert.IsInstanceOf <SampleDescendant2>(ret); }
public void TestGetFieldValue() { SampleBase sampleObj = new SampleBase(); Assert.AreEqual(sampleObj.MyString, ReflectionUtil.GetFieldValue(sampleObj, "MyString")); Assert.AreEqual(sampleObj.MyInt, ReflectionUtil.GetFieldValue(sampleObj, "MyInt")); Assert.AreEqual(sampleObj.MyFloat, ReflectionUtil.GetFieldValue(sampleObj, "MyFloat")); Assert.AreEqual(sampleObj.MyList, ReflectionUtil.GetFieldValue(sampleObj, "MyList")); Assert.AreEqual(sampleObj.MyList[2], ReflectionUtil.GetFieldValue(sampleObj, "MyList", 2)); }
public void AddPoint(Vector2 screenPos, GameObject markerPrefab) { Vector3 pos = SampleBase.GetWorldPos(screenPos); if (markerPrefab) { AddMarker(pos, markerPrefab); } points.Add(pos); UpdateLines(); }
public void ChangedTypeWithConflict() { SampleBase @base = new SampleDescendant1(); SampleBase left = new SampleDescendant1 { Value = "a" }; SampleBase right = new SampleDescendant2(); SampleBase ret = Merger.Instance.Merge(@base, left, right); Assert.IsInstanceOf <SampleDescendant1>(ret); Assert.AreEqual("a", ((SampleDescendant1)ret).Value); }
/// <summary> /// Attaches the specified associated object. /// </summary> /// <param name="associatedObject">The associated object.</param> public void Attach(DependencyObject associatedObject) { m_associatedObject = associatedObject; m_appliedSample = null; m_subscriptions = SeeingSharpApplication.Current.UIMessenger.SubscribeAll(this); SwapChainPanel renderElement = m_associatedObject as SwapChainPanel; if (renderElement != null) { m_painter.Attach(renderElement); } }
public static SampleBase GetSampleBase() { SampleBase sampleBase = new SampleBase(); sampleBase.TextValue = Guid.NewGuid().ToString(); sampleBase.NumberValue = TestCaseUtils._rnd.Next(); int num = TestCaseUtils._rnd.Next(); int num2 = TestCaseUtils._rnd.Next(); int num3 = TestCaseUtils._rnd.Next(); sampleBase.VectorValue = new Vector3((float)num, (float)num2, (float)num3); return(sampleBase); }
void InitExportableObjects(GameObject go) { SampleBase sample = null; ExportFunction exportFunc = null; if (go.GetComponent <MeshFilter>() != null && go.GetComponent <MeshRenderer>() != null) { sample = new MeshSample(); exportFunc = ExportMesh; foreach (var mat in go.GetComponent <MeshRenderer>().materials) { if (!m_materialMap.ContainsKey(mat)) { string usdPath = "/World/Materials/" + pxr.UsdCs.TfMakeValidIdentifier(mat.name); m_materialMap.Add(mat, usdPath); } } } else if (go.GetComponent <Camera>()) { sample = new CameraSample(); exportFunc = ExportCamera; } else { return; } // This is an exportable object. string path = Unity.UnityTypeConverter.GetPath(go.transform); m_primMap.Add(go, new ExportPlan { path = path, sample = sample, exportFunc = exportFunc }); Debug.Log(path + " " + sample.GetType().Name); // Include the parent xform hierarchy. // Note that the parent hierarchy is memoised, so despite looking expensive, the time // complexity is linear. Transform xf = go.transform.parent; while (xf) { if (!InitExportableParents(xf.gameObject)) { break; } xf = xf.parent; } }
public static SampleBase GetSampleBase() { var sb = new SampleBase(); sb.TextValue = Guid.NewGuid().ToString(); sb.NumberValue = _rnd.Next(); var x = _rnd.Next(); var y = _rnd.Next(); var z = _rnd.Next(); sb.VectorValue = new Vector3((float)x, (float)y, (float)z); return(sb); }
public void DictionaryObjectKeySerialization() { this.LogStart("Dictionary (Object As Key)"); try { Dictionary <SampleBase, int> dictionary = new Dictionary <SampleBase, int>(); for (int i = 0; i < 4; i++) { dictionary.Add(TestCaseUtils.GetSampleBase(), i); } string text = JsonConvert.SerializeObject(dictionary); this.LogSerialized(text); this._text.set_text(text); Dictionary <SampleBase, int> dictionary2 = JsonConvert.DeserializeObject <Dictionary <SampleBase, int> >(text); List <SampleBase> list = new List <SampleBase>(); List <SampleBase> list2 = new List <SampleBase>(); using (Dictionary <SampleBase, int> .KeyCollection.Enumerator enumerator = dictionary.get_Keys().GetEnumerator()) { while (enumerator.MoveNext()) { SampleBase current = enumerator.get_Current(); list.Add(current); } } using (Dictionary <SampleBase, int> .KeyCollection.Enumerator enumerator2 = dictionary2.get_Keys().GetEnumerator()) { while (enumerator2.MoveNext()) { SampleBase current2 = enumerator2.get_Current(); list2.Add(current2); } } this.LogResult(list.get_Item(1).TextValue, list2.get_Item(1).TextValue); if (list.get_Item(1).TextValue != list2.get_Item(1).TextValue) { this.DisplayFail("Dictionary (Object As Key)", "Incorrect Deserialized Result"); } else { this.DisplaySuccess("Dictionary (Object As Key)"); } } catch (Exception ex) { this.DisplayFail("Dictionary (Object As Key)", ex.get_Message()); throw; } }
/// <summary> /// Dispose pattern. /// </summary> /// <param name="disposing"> /// True if being called from Dispose, false if from the finalizer. /// </param> protected virtual void Dispose(bool disposing) { if (disposing) { if (SampleFraction != null) { SampleFraction.Dispose(); SampleFraction = null; } if (SampleBase != null) { SampleBase.Dispose(); SampleBase = null; } } }
public void TestIgnoredDifferent() { var @base = new SampleBase { Value = "one", Value2 = "three" }; var changed = new SampleBase { Value = "two", Value2 = "three" }; var expected = DiffFactory.Create <SampleBase>().Class() .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void TestProcessedDifferent() { var @base = new SampleBase { Value = "one", Value2 = "three" }; var changed = new SampleBase { Value = "one", Value2 = "four" }; var expected = DiffFactory.Create <SampleBase>().Class() .Replaced(x => x.Value2, "three", "four") .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
private void SetSample(SampleBase newSample) { sample = newSample; // set the title Title = sample?.Title ?? "SkiaSharp for WPF"; // prepare the sample sample?.Init(() => { // refresh the view canvas.InvalidateVisual(); glhost.Child?.Invalidate(); }); // refresh the view canvas.InvalidateVisual(); glhost.Child?.Invalidate(); }
private void SetSample(SampleBase newSample) { sample = newSample; // set the title Text = sample?.Title ?? "SkiaSharp for Windows"; // prepare the sample sample?.Init(() => { // refresh the view canvas.Invalidate(); glview.Invalidate(); }); // refresh the view canvas.Invalidate(); glview.Invalidate(); }
private TreeNode CreateTreeNode(SampleBase sample, int level) { TreeNode node = new TreeNode(sample.Title); node.Tag = sample; SampleGroup sg = sample as SampleGroup; if (sg != null) { foreach (SampleBase sb in sg.Children) { node.Nodes.Add(CreateTreeNode(sb, level + 1)); } node.ImageKey = node.SelectedImageKey = "BookClosed"; } else { node.ImageKey = node.SelectedImageKey = "Item"; } return(node); }
private void OnSampleSelected(SampleBase sample) { // clean up the old sample if (currentSample != null) { currentSample.RefreshRequested -= OnRefreshRequested; currentSample.Destroy(); } // update the selected sample currentSample = sample; // prepare the sample if (sample != null) { sample.RefreshRequested += OnRefreshRequested; sample.Init(); } // refresh the view OnRefreshRequested(null, null); }