Пример #1
0
 public CollectionBase(Exchange exchange, Func <TValue, TKey> key_from)
 {
     Exchange = exchange;
     Updated  = new ConditionVariable <DateTimeOffset>(DateTimeOffset.MinValue);
     m_data   = new BindingDict <TKey, TValue> {
         KeyFrom = key_from
     };
     m_data.CollectionChanged += (s, a) => CollectionChanged?.Invoke(this, a);
     m_data.ListChanging      += (s, a) => ListChanging?.Invoke(this, a);
 }
Пример #2
0
        // Notes:
        //  - This class provides the functionality for a measurement tool.
        //  - UI frameworks need to provide binding wrappers.
        //
        // General usage:
        //  - User clicks on 'Start' or 'End' toggle button.
        //  - MouseMove over the scene moves a hotspot around.
        //  - When a mouse click is detected, the Hit point for start/end is updated,
        //    and the toggle button returns to unchecked.
        //  - If the check button is unchecked, the Hit point is not set
        //  - User can still pan/rotate the scene with mouse drag operations

        public Measurement(View3d.Window window)
        {
            ReferenceFrame = EReferenceFrame.WorldSpace;
            Flags          = View3d.EHitTestFlags.Verts | View3d.EHitTestFlags.Edges | View3d.EHitTestFlags.Faces;
            SnapDistance   = 0.1;
            BegSpotColour  = Colour32.Aqua;
            EndSpotColour  = Colour32.Salmon;
            ContextIds     = new Guid[1] {
                Guid.NewGuid()
            };
            IncludeCount = 0;
            ExcludeCount = 1;
            Results      = new BindingDict <EQuantity, Result>(Enum <EQuantity> .Values.ToDictionary(x => x, x => new Result(x, "---")));
            m_hit0       = new Hit();
            m_hit1       = new Hit();

            Window = window;
        }
Пример #3
0
        [Test] public void BindingDictionary()
        {
            var stats = new Stats();

            var a0 = new BindingDict <int, double>();

            a0.ListChanging += (s, a) =>
            {
                if (a.ChangeType == ListChg.ItemAdded)
                {
                    ++stats.Adds;
                }
            };

            for (int i = 0; i != 5; ++i)
            {
                a0.Add(i, i * 1.1);
            }

            Assert.Equal(stats.Adds, 5);
        }