Beispiel #1
0
        private void SafeRelease()
        {
            if (_srlAction != null)
            {
                _srlAction.Dispose();
            }
            _srlAction = null;
            if (_gepAction != null)
            {
                _gepAction.Dispose();
            }
            _gepAction = null;
            if (_rAction != null)
            {
                _rAction.Dispose();
            }
            _rAction = null;
            if (_cAction != null)
            {
                _cAction.Dispose();
            }
            _cAction = null;
            if (_sAction != null)
            {
                _sAction.Dispose();
            }
            _sAction = null;
            if (_spfAction != null)
            {
                _spfAction.Dispose();
            }
            _spfAction = null;

            if (_render != null)
            {
                _render.Dispose();
            }
            _render = null;
            if (_devices != null)
            {
                _devices.Dispose();
            }
            _devices = null;
        }
Beispiel #2
0
        public MainFormContext(Form owner,
                               Control renderArea,
                               TrackBar trackBar,
                               Label timeLabel,
                               Button startStopButton,
                               NumericUpDown speedBox,
                               Button screenshotButton,
                               Button videoCaptureButton,
                               Button showPropsButton)
        {
            _shouldRecreate = false;
            _recreateSavers = false;

            _owner      = owner;
            _renderArea = renderArea;

            _devices = new DxRender.DxDeviceContext(_owner.Handle, _renderArea, false);
            _render  = new DxRender.GeometricDxRenderer(_devices);
            _states  = new States();

            _srlAction = new SimResultsLoadingAction(_states);
            _gepAction = new GuiEventProcessingAction(_devices,
                                                      _states,
                                                      _owner,
                                                      _renderArea,
                                                      trackBar,
                                                      timeLabel,
                                                      startStopButton,
                                                      speedBox,
                                                      screenshotButton,
                                                      videoCaptureButton);
            _rAction   = new RenderAction(_devices, _render, _states);
            _cAction   = new CaptureAction(_devices, _render, _states, SettingsManager.GetRef().CaptureSettings);
            _sAction   = new SelectAction(_devices, _render, _states);
            _spfAction = new SelectionPopupFormAction(_states, _owner, showPropsButton);

            if (!_states.IsInitialized)
            {
                throw new ApplicationException("Internal error - failed to register all state providers");
            }
        }
Beispiel #3
0
        private void SafeRecreate()
        {
            IOnTickActionContext srlActionContext = _srlAction.DisposeAndExportContext();
            IOnTickActionContext gepActionContext = _gepAction.DisposeAndExportContext();
            IOnTickActionContext rActionContext   = _rAction.DisposeAndExportContext();
            IOnTickActionContext cActionContext   = _cAction.DisposeAndExportContext();
            IOnTickActionContext sActionContext   = _sAction.DisposeAndExportContext();
            IOnTickActionContext spfActionContext = _spfAction.DisposeAndExportContext();

            _states.RemoveStateProviders();

            _render.Dispose();
            _devices.Dispose();

            _devices = new Mitosis.DxRender.DxDeviceContext(_owner.Handle, _renderArea, false);
            _render  = new DxRender.GeometricDxRenderer(_devices);

            _srlAction = new SimResultsLoadingAction(_states, srlActionContext);
            _gepAction = new GuiEventProcessingAction(_devices, _states, gepActionContext);
            _rAction   = new RenderAction(_devices, _render, _states, rActionContext);
            if (_recreateSavers)
            {
                cActionContext.Dispose();
                _cAction = new CaptureAction(_devices, _render, _states, SettingsManager.GetRef().CaptureSettings);
            }
            else
            {
                _cAction = new CaptureAction(_devices, _render, _states, cActionContext);
            }

            _sAction   = new SelectAction(_devices, _render, _states, sActionContext);
            _spfAction = new SelectionPopupFormAction(_states, spfActionContext);

            if (!_states.IsInitialized)
            {
                throw new ApplicationException("Internal error - failed to register all state providers");
            }
        }