示例#1
0
        /// <summary>
        ///     Initializes the graphics.
        /// </summary>
        private void InitializeGraphics()
        {
            DependencyManger.ForTypeUse(() => _renderControl.RenderTargetContainer, DependencyCacheFlags.CacheGlobal);

            _miskResourceManager = DependencyManger.GetResourceManager();
            _miskResourceManager.Add(_whiteStyle);
            _miskResourceManager.Add(_grayStyle);
            _miskResourceManager.Add(_blackStyle);

            RenderTargetContainer renderTargetContainer = _renderControl.RenderTargetContainer;
            DirectXGraphics       graphics = new DirectXGraphics(
                renderTargetContainer.RenderTarget,
                _miskResourceManager,
                _whiteStyle,
                _blackStyle,
                1f);

            renderTargetContainer.RenderTargetChanged += rt => graphics.RenderTarget = rt;

            _directXGraphics = graphics;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="TilingController" /> class.
        /// </summary>
        /// <param name="tiling">The tiling.</param>
        /// <param name="view">The view.</param>
        /// <exception cref="System.ArgumentNullException">
        /// </exception>
        /// <exception cref="System.InvalidOperationException"></exception>
        public TilingController([NotNull] Tiling tiling, [NotNull] IView view)
            : base(view)
        {
            if (tiling == null)
            {
                throw new ArgumentNullException(nameof(tiling));
            }

            _tiling = tiling;

            IResourceManager resourceManager = DependencyManger.GetResourceManager(StyleManager);

            _resourceManager = resourceManager;

            resourceManager.Add(SolidColourStyle.Transparent);
            resourceManager.Add(SolidColourStyle.White);
            resourceManager.Add(SolidColourStyle.Black);
            resourceManager.Add(SolidColourStyle.Gray);
            resourceManager.Add(SolidColourStyle.CornflowerBlue);
            resourceManager.Add(TransparentBlue);

            _tiles = _tiling.GetTiles(view.ViewBounds, Enumerable.Empty <TileBase>());

            _styleManagerChangedHandler = _styleManager_Changed;
            StyleManager.StylesChanged += _styleManagerChangedHandler;

            Tools = new Tool[]
            {
                EditLine  = new EditLineTool(this, _tolerance),
                SplitLine = new SplitLineTool(this, _tolerance)
            };

            view.ViewBoundsChanged += View_ViewBoundsChanged;
        }
        /// <summary>
        ///     Sets the tiling.
        /// </summary>
        /// <param name="tiling">The tiling.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.InvalidOperationException"></exception>
        public void SetTiling([NotNull] Tiling tiling)
        {
            if (tiling == null)
            {
                throw new ArgumentNullException(nameof(tiling));
            }

            if (tiling == _tiling)
            {
                return;
            }

            StyleManager oldStyleManager = StyleManager;

            Debug.Assert(oldStyleManager != null, "oldStyleManager != null");
            oldStyleManager.StylesChanged -= _styleManagerChangedHandler;

            _tiling = tiling;

            StyleManager.StylesChanged += _styleManagerChangedHandler;

            IResourceManager resourceManager    = DependencyManger.GetResourceManager(tiling.StyleManager);
            IResourceManager oldResourceManager = Interlocked.Exchange(ref _resourceManager, resourceManager);

            DependencyManger.ReleaseResourceManager(ref oldResourceManager, oldStyleManager);

            resourceManager.Add(SolidColourStyle.Transparent);
            resourceManager.Add(SolidColourStyle.White);
            resourceManager.Add(SolidColourStyle.Black);
            resourceManager.Add(SolidColourStyle.Gray);
            resourceManager.Add(SolidColourStyle.CornflowerBlue);
            resourceManager.Add(TransparentBlue);

            _tiles = _tiling.GetTiles(View.ViewBounds, Enumerable.Empty <TileBase>());
        }
示例#4
0
        /// <summary>
        ///     Adds the specified key to the manager which creates the resource(s) for the key.
        /// </summary>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <param name="key">The key.</param>
        /// <exception cref="System.NotSupportedException">The type of the key and/or resource is not supported by this manager.</exception>
        /// <exception cref="System.ArgumentNullException"><paramref name="key" /> is null.</exception>
        public void Add <TKey>(TKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            IResourceManager <TKey> rm = this as IResourceManager <TKey>;

            if (rm == null)
            {
                throw new NotSupportedException(Strings.ResourceManager_TypesNotSupported);
            }
            rm.Add(key);
        }
        /// <summary>
        /// Erstellt eine neue Planung.
        /// </summary>
        /// <param name="site">Die zugehörige Arbeitsumgebung.</param>
        private RecordingPlanner(IRecordingPlannerSite site)
        {
            // Remember
            m_site = site;

            // Process all profiles
            foreach (var profileName in site.ProfileNames)
            {
                // Look up the profile
                var profile = ProfileManager.FindProfile(profileName);
                if (profile == null)
                {
                    continue;
                }

                // Create the resource for it
                var profileResource = ProfileScheduleResource.Create(profileName);

                // Remember
                m_resources.Add(profileName, profileResource);

                // See if this is a leaf profile
                if (!string.IsNullOrEmpty(profile.UseSourcesFrom))
                {
                    continue;
                }

                // See if we should process guide updates
                var guideTask = site.CreateProgramGuideTask(profileResource, profile);
                if (guideTask != null)
                {
                    m_tasks.Add(guideTask);
                }

                // See if we should update the source list
                var scanTask = site.CreateSourceScanTask(profileResource, profile);
                if (scanTask != null)
                {
                    m_tasks.Add(scanTask);
                }
            }

            // Make sure we report all errors
            try
            {
                // Create the manager
                m_manager = ResourceManager.Create(site.ScheduleRulesPath, ProfileManager.ProfileNameComparer);
            }
            catch (Exception e)
            {
                // Report
                VCRServer.LogError(Properties.Resources.BadRuleFile, e.Message);

                // Use standard rules
                m_manager = ResourceManager.Create(ProfileManager.ProfileNameComparer);
            }

            // Safe configure it
            try
            {
                // All all resources
                foreach (var resource in m_resources.Values)
                {
                    m_manager.Add(resource);
                }
            }
            catch (Exception e)
            {
                // Cleanup
                Dispose();

                // Report
                VCRServer.Log(e);
            }
        }
        /// <summary>
        /// Erstellt eine neue Planung.
        /// </summary>
        /// <param name="site">Die zugehörige Arbeitsumgebung.</param>
        private RecordingPlanner( IRecordingPlannerSite site )
        {
            // Remember
            m_site = site;

            // Process all profiles
            foreach (var profileName in site.ProfileNames)
            {
                // Look up the profile
                var profile = ProfileManager.FindProfile( profileName );
                if (profile == null)
                    continue;

                // Create the resource for it
                var profileResource = ProfileScheduleResource.Create( profileName );

                // Remember
                m_resources.Add( profileName, profileResource );

                // See if this is a leaf profile
                if (!string.IsNullOrEmpty( profile.UseSourcesFrom ))
                    continue;

                // See if we should process guide updates
                var guideTask = site.CreateProgramGuideTask( profileResource, profile );
                if (guideTask != null)
                    m_tasks.Add( guideTask );

                // See if we should update the source list
                var scanTask = site.CreateSourceScanTask( profileResource, profile );
                if (scanTask != null)
                    m_tasks.Add( scanTask );
            }

            // Make sure we report all errors
            try
            {
                // Create the manager
                m_manager = ResourceManager.Create( site.ScheduleRulesPath, ProfileManager.ProfileNameComparer );
            }
            catch (Exception e)
            {
                // Report
                VCRServer.LogError( Properties.Resources.BadRuleFile, e.Message );

                // Use standard rules
                m_manager = ResourceManager.Create( ProfileManager.ProfileNameComparer );
            }

            // Safe configure it
            try
            {
                // All all resources
                foreach (var resource in m_resources.Values)
                    m_manager.Add( resource );
            }
            catch (Exception e)
            {
                // Cleanup
                Dispose();

                // Report
                VCRServer.Log( e );
            }
        }