protected override void OnAttached()
        {
            base.OnAttached();

            m_appliedSample = null;
            m_subscriptions = SeeingSharpApplication.Current.UIMessenger.SubscribeAll(this);
        }
예제 #2
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void Setup(SampleSelectorUI parentUI, SampleBase prefab)
        {
            this.ParentUI      = parentUI;
            this.ExamplePrefab = prefab;

            this._text.text = prefab.DisplayName;
        }
예제 #6
0
    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);
      }
    }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        //private SKImage lastImage;

        public DetailContentsPage(SampleBase showcase)
        {
            InitializeComponent();

            Sample         = showcase;
            BindingContext = this;
        }
예제 #11
0
        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);
        }
예제 #12
0
 public void ExecuteExample(SampleBase example)
 {
     if (this.dynamicContent != null)
     {
         Destroy(this.dynamicContent);
     }
     this.dynamicContent = Instantiate(example, this._dyncamicContentRoot, false).gameObject;
 }
예제 #13
0
        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;
        }
예제 #14
0
        private void OnSampleSelected(SampleBase sample)
        {
            // update the selected sample
            currentSample = sample;
            currentSample?.Init(canvas.SetNeedsDisplay);

            // refresh the canvas
            canvas.SetNeedsDisplay();
        }
예제 #15
0
        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);
        }
예제 #16
0
        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));
        }
예제 #17
0
        public void AddPoint(Vector2 screenPos, GameObject markerPrefab)
        {
            Vector3 pos = SampleBase.GetWorldPos(screenPos);

            if (markerPrefab)
            {
                AddMarker(pos, markerPrefab);
            }

            points.Add(pos);
            UpdateLines();
        }
예제 #18
0
        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);
        }
예제 #19
0
        /// <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);
            }
        }
예제 #20
0
        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);
        }
예제 #21
0
        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;
            }
        }
예제 #22
0
        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);
        }
예제 #23
0
 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;
     }
 }
예제 #24
0
 /// <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;
         }
     }
 }
예제 #25
0
        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);
        }
예제 #26
0
        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);
        }
예제 #27
0
        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();
        }
예제 #28
0
파일: Form1.cs 프로젝트: gramland/SkiaSharp
        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);
        }
예제 #30
0
        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);
        }