Esempio n. 1
0
        /// <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;
        }
Esempio n. 2
0
        /// <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;
        }
Esempio n. 3
0
        /// <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>());
        }
        private IEnumerable <TileBase> GetTiles(Rectangle bounds)
        {
            Debug.Assert(Tiling != null, "Tiling != null");

            Tile origTile = Tiling.Tiles[0];

            Debug.Assert(origTile != null, "origTile != null");

            TileInstance tile = new TileInstance(origTile, origTile.Label, origTile.Transform)
            {
                Style = origTile.Style
            };

            return(Tiling.GetTiles(bounds, new TileBase[] { tile }));
        }
Esempio n. 5
0
        /// <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>());
        }