Пример #1
0
        public static IDisposable SubscribeDisposableRender <T>(this IObservableExceptional <T> o, Func <T, IDisposable> fn, IModelDoc2 doc, Action <Exception> errHandler)
        {
            var d = new SerialDisposable();

            var s = o
                    .ObserveOnSolidworksThread()
                    .Subscribe(onNext: v =>
            {
                using (OpenGlRenderer.DeferRedraw(doc))
                {
                    try
                    {
                        d.Disposable = Disposable.Empty;
                        d.Disposable = fn(v) ?? Disposable.Empty;
                    }
                    catch (Exception e)
                    {
                        d.Disposable = Disposable.Empty;
                        errHandler(e);
                    }
                }
            },
                               onError: e =>
            {
                d.Disposable = Disposable.Empty;
                errHandler(e);
            });

            return(new CompositeDisposable(s, d));
        }
Пример #2
0
 public static IDisposable DisplayUndoable
     (this IEnumerable <IRenderer> renderable, IModelDoc2 doc, int layer = 0)
 {
     return(OpenGlRenderer.DeferRedraw
                (doc
                , () => renderable.Select(r => r.DisplayUndoable(doc, layer)).ToCompositeDisposable()
                ));
 }
Пример #3
0
        public bool ConnectToSW(object thisSw, int cookie)
        {
            SwApp = (SldWorks)thisSw;

            Active = this;

            SwApp.SetAddinCallbackInfo2(0, this, cookie);

            CommandManager = SwApp.GetCommandManager(cookie);

            _Bmp = new BitmapHandler();
            AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
            var d0 = Disposable.Create(() => AppDomain.CurrentDomain.AssemblyResolve -= ResolveAssembly);
            var d1 = OpenGlRenderer.Setup((SldWorks)SwApp);
            var d2 = new CompositeDisposable(Setup());

            _Disposable = new CompositeDisposable(_Bmp, d0, d1, d2);

            return(true);
        }
Пример #4
0
 public static IDisposable DisplayUndoable
     (this IRenderable renderable, IModelDoc2 doc, int layer = 0)
 {
     return(OpenGlRenderer.DisplayUndoable(renderable, doc, layer));
 }