Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        static void _OnPresentationChanged(Layer layer)
        {
            if (!_DrawerCache.TryGetValue(layer, out var drawer))
            {
                return;
            }

            var newDisplayMode     = (int)(layer.PresentationMode == PresentationMode.Wireframe ? AIS_DisplayMode.AIS_WireFrame : AIS_DisplayMode.AIS_Shaded);
            var displayModeChanged = drawer.Drawer.DisplayMode() != newDisplayMode;

            _UpdateAttributesForLayer(layer, ref drawer);

            var workspaceController = InteractiveContext.Current?.WorkspaceController;

            if (workspaceController == null)
            {
                return;
            }

            foreach (var visualShape in workspaceController.VisualShapes.GetVisualShapes(entity => entity.GetLayer() == layer))
            {
                var aisShape = visualShape._AisShape;
                if (aisShape == null)
                {
                    continue;
                }

                if (displayModeChanged)
                {
                    workspaceController.Workspace.AisContext.SetDisplayMode(aisShape, newDisplayMode, false);
                }

                workspaceController.Workspace.AisContext.RecomputePrsOnly(aisShape, false, true);
            }
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        public static SketchEditorSettings GetOrCreate(Sketch sketch)
        {
            if (_Settings.TryGetValue(sketch, out var settings))
            {
                return(settings);
            }

            settings = new SketchEditorSettings();
            _Settings.SetValue(sketch, settings);
            return(settings);
        }
        public void WeakTableKeyIsNull()
        {
            var table = new WeakTable <BaseObject, string>();

            Assert.IsFalse(table.HasValue(null));
            Assert.IsNull(table.GetValue(null));
            Assert.IsFalse(table.TryGetValue(null, out _));

            table.SetValue(null, "obj0");
            string s;

            Assert.IsTrue(table.TryGetValue(null, out s));
            Assert.AreEqual("obj0", s);
        }
        public void WeakTableNoValue()
        {
            var table = new WeakTable <BaseObject, string>();
            var obj1  = new BaseObject();

            Assert.IsFalse(table.HasValue(obj1));
            Assert.IsNull(table.GetValue(obj1));
            Assert.IsFalse(table.TryGetValue(obj1, out _));
        }
        public void WeakTableStorage()
        {
            var table = new WeakTable <BaseObject, string>();
            var obj1  = new BaseObject();

            table.SetValue(obj1, "obj1");
            Assert.IsTrue(table.HasValue(obj1));
            Assert.AreEqual("obj1", table.GetValue(obj1));

            string s;

            Assert.IsTrue(table.TryGetValue(obj1, out s));
            Assert.AreEqual("obj1", s);
        }
Ejemplo n.º 6
0
 public static void OnInput(Loop loop, Action <string> action)
 {
     lock (actions)
     {
         Action <string> value;
         if (actions.TryGetValue(loop, out value))
         {
             value += action;
         }
         else
         {
             value = action;
         }
         actions[loop] = value;
     }
 }