Exemple #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="type">The spread mechanics to use for source values.</param>
        /// <param name="position">The position on a map that the source is located at.</param>
        /// <param name="radius">
        /// The maximum radius of the source -- this is the maximum distance the source values will
        /// emanate, provided the area is completely unobstructed.
        /// </param>
        /// <param name="distanceCalc">
        /// The distance calculation used to determine what shape the radius has (or a type
        /// implicitly convertible to <see cref="SadRogue.Primitives.Distance" />, such as <see cref="SadRogue.Primitives.Radius" />).
        /// </param>
        /// <param name="intensity">The starting intensity value of the source. Defaults to 1.0.</param>
#pragma warning disable CS8618 // Uninitialized non-nullable variable for light and nearLight is incorrect, as the Radius setter initializes them.
        public SenseSource(SourceType type, Point position, double radius, Distance distanceCalc,
                           double intensity = 1.0)
#pragma warning restore CS8618
        {
            if (radius <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(radius), "SenseMap radius cannot be 0");
            }

            if (intensity < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(intensity),
                                                      "SenseSource intensity cannot be less than 0.0.");
            }

            Type         = type;
            Position     = position;
            Radius       = radius; // Arrays are initialized by this setter
            DistanceCalc = distanceCalc;

            _resMap = null;
            Enabled = true;

            IsAngleRestricted = false;
            Intensity         = intensity;

            // Stores max of 8 neighbors
            _neighbors = new List <Point>(8);
        }
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.grid = view as IGridView;
            this.grid.ContextItemsNeeded += GetContextItems;
            this.model             = model as Model;
            this.explorerPresenter = explorerPresenter;

            // if the model is Testable, run the test method.
            ITestable testModel = model as ITestable;

            if (testModel != null)
            {
                testModel.Test(false, true);
                this.grid.ReadOnly = true;
            }

            this.grid.NumericFormat   = "G6";
            grid.CanGrow              = false;
            this.childrenWithSameType = this.GetChildModelsWithSameType(this.model);
            this.FindAllPropertiesForChildren();
            if (this.grid.DataSource == null)
            {
                this.PopulateGrid(this.model);
            }
            else
            {
                this.FormatTestGrid();
            }

            this.grid.CellsChanged += this.OnCellValueChanged;
            this.grid.ButtonClick  += this.OnFileBrowseClick;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
        private void Panel_ChildrenChanged(object sender, ChildrenChangedEventArgs e)
        {
            IGridView child = e.Child as IGridView;

            if (child != null)
            {
                if (e.ChangeOperation == ItemsChangeOperation.Inserted)
                {
                    child.Initialize(this, this.template.MasterViewInfo);
                    if (this.currentView == null)
                    {
                        IRowView rowView = child as IRowView;
                        if (rowView != null)
                        {
                            this.currentView = rowView;
                        }
                    }
                }
                if (e.ChangeOperation == ItemsChangeOperation.Removed)
                {
                    child.Detach();
                    if (child == this.CurrentView)
                    {
                        this.CurrentView = (IRowView)null;
                    }
                }
            }
            if (e.ChangeOperation != ItemsChangeOperation.Cleared)
            {
                return;
            }
            this.CurrentView = (IRowView)null;
        }
        private static bool GridViewCompare <T>(IGridView <T> view1, IGridView <T> view2)
        {
            if (ReferenceEquals(view1, view2))
            {
                return(true);
            }

            if (view1.Width != view2.Width || view1.Height != view2.Height)
            {
                return(false);
            }

            foreach (var pos in view1.Positions())
            {
                var val1 = view1[pos];
                var val2 = view2[pos];
                if (ReferenceEquals(val1, val2))
                {
                    continue;
                }

                if (val1 is null || val2 is null)
                {
                    return(false);
                }

                if (!val1.Equals(val2))
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Allows stringifying the contents of a grid view. Takes characters to surround the grid view printout, and
        /// each row, the method used to get the string representation of each element (defaulting to the ToString
        /// function of type T), and separation characters for each element and row.
        /// </summary>
        /// <typeparam name="T" />
        /// <param name="gridView" />
        /// <param name="begin">Character(s) that should precede the IGridView printout.</param>
        /// <param name="beginRow">Character(s) that should precede each row.</param>
        /// <param name="elementStringifier">
        /// Function to use to get the string representation of each value. null uses the ToString
        /// function of type T.
        /// </param>
        /// <param name="rowSeparator">Character(s) to separate each row from the next.</param>
        /// <param name="elementSeparator">Character(s) to separate each element from the next.</param>
        /// <param name="endRow">Character(s) that should follow each row.</param>
        /// <param name="end">Character(s) that should follow the IGridView printout.</param>
        /// <returns>A string representation of the values in the grid view.</returns>
        public static string ExtendToString <T>(this IGridView <T> gridView, string begin = "", string beginRow = "",
                                                Func <T, string>?elementStringifier       = null,
                                                string rowSeparator = "\n", string elementSeparator = " ",
                                                string endRow       = "", string end = "")
        {
            elementStringifier ??= obj => obj?.ToString() ?? "null";

            var result = new StringBuilder(begin);

            for (var y = 0; y < gridView.Height; y++)
            {
                result.Append(beginRow);
                for (var x = 0; x < gridView.Width; x++)
                {
                    result.Append(elementStringifier(gridView[x, y]));
                    if (x != gridView.Width - 1)
                    {
                        result.Append(elementSeparator);
                    }
                }

                result.Append(endRow);
                if (y != gridView.Height - 1)
                {
                    result.Append(rowSeparator);
                }
            }

            result.Append(end);

            return(result.ToString());
        }
Exemple #6
0
        /// <summary>
        /// Constructor. Initialises the widget and will show a world
        /// map with no markers until <see cref="ShowMap" /> is called.
        /// </summary>
        /// <param name="owner">Owner view.</param>
        public MapView(ViewBase owner) : base(owner)
        {
            GeometryServiceProvider.Instance = new NtsGeometryServices();

            image = new Gtk.Image();
            var container = new Gtk.EventBox();

            container.Add(image);

            VPaned box = new VPaned();

            Grid = new GridView(this);
            box.Pack1(((ViewBase)Grid).MainWidget, true, false);
            box.Pack2(container, true, true);

            container.AddEvents(
                (int)Gdk.EventMask.ButtonPressMask
                | (int)Gdk.EventMask.ButtonReleaseMask
                | (int)Gdk.EventMask.ScrollMask);
            container.ButtonPressEvent   += OnButtonPress;
            container.ButtonReleaseEvent += OnButtonRelease;
            image.SizeAllocated          += OnSizeAllocated;
            image.ExposeEvent            += OnImageExposed;
            container.Destroyed          += OnMainWidgetDestroyed;
            container.ScrollEvent        += OnMouseScroll;

            mainWidget = box;
            mainWidget.ShowAll();
        }
Exemple #7
0
        /// <summary>
        /// Initializes the grid.
        /// </summary>
        private void InitializeGrid()
        {
            IGrid <ICell> grid = Container.Resolve <IGrid <ICell> >(
                new ParameterOverride("totalRows", totalRows),
                new ParameterOverride("totalColumns", totalColumns),
                new ParameterOverride("initialActiveCells", initialActiveCells));


            IStateGenerator stateGenerator = Container.Resolve <IStateGenerator>(new ParameterOverride("currentState", grid));

            IGridView gridView = Container.Resolve <IGridView>(new ParameterOverride("stateGenerator", stateGenerator));

            gridView.Render();

            Console.Write("Press <enter> to see next state or 'exit' to quit : ");
            string result = Console.ReadLine();

            while (string.Compare(result, "exit", StringComparison.OrdinalIgnoreCase) != 0)
            {
                gridView.RenderNextState();

                Console.Write("Press <enter> to see next state or 'exit' to quit : ");
                result = Console.ReadLine();
            }
        }
Exemple #8
0
        // Private constructor that does work of others
#pragma warning disable CS8618 // _heuristic is initialized via Heuristic so ignore erroneous warning
        private AStar(IGridView <bool> walkabilityView, Distance distanceMeasurement,
                      Func <Point, Point, double>?heuristic = null, IGridView <double>?weights = null,
                      double minimumWeight = 1.0)
#pragma warning restore CS8618
        {
            Weights = weights;

            WalkabilityView        = walkabilityView;
            DistanceMeasurement    = distanceMeasurement;
            MinimumWeight          = minimumWeight;
            _cachedMinWeight       = minimumWeight;
            MaxEuclideanMultiplier = MinimumWeight / Point.EuclideanDistanceMagnitude(new Point(0, 0),
                                                                                      new Point(WalkabilityView.Width, WalkabilityView.Height));

            Heuristic = heuristic !; // Handles null and exposes as non-nullable since it will never allow null

            var maxSize = walkabilityView.Width * walkabilityView.Height;

            _nodes        = new AStarNode?[maxSize];
            _closed       = new BitArray(maxSize);
            _cachedWidth  = walkabilityView.Width;
            _cachedHeight = walkabilityView.Height;

            _openNodes = new FastPriorityQueue <AStarNode>(maxSize);
        }
Exemple #9
0
        private static Point FindEmptySquare(IGridView <bool> map, IEnhancedRandom rng)
        {
            // Try random positions first
            // TODO: Port to retries option
            for (var i = 0; i < 100; i++)
            {
                var location = rng.RandomPosition(map, false);

                if (IsPointConsideredEmpty(map, location))
                {
                    return(location);
                }
            }

            // Start looping through every single one
            for (var i = 0; i < map.Width * map.Height; i++)
            {
                var location = Point.FromIndex(i, map.Width);

                if (IsPointConsideredEmpty(map, location))
                {
                    return(location);
                }
            }

            return(Point.None);
        }
        /// <summary>
        /// Gets the direction of the neighbor with the minimum goal-map value from the given position.
        /// </summary>
        /// <param name="goalMap" />
        /// <param name="position">The position to get the minimum value for.</param>
        /// <param name="adjacencyRule">The adjacency rule to use to determine neighbors.</param>
        /// <returns>
        /// The direction that has the minimum value in the goal-map, or <see cref="SadRogue.Primitives.Direction.None" /> if the
        /// neighbors are all obstacles.
        /// </returns>
        public static Direction GetDirectionOfMinValue(this IGridView <double?> goalMap, Point position,
                                                       AdjacencyRule adjacencyRule)
        {
            var min    = goalMap[position].HasValue ? goalMap[position] !.Value : double.MaxValue;
            var minDir = Direction.None;

            for (int i = 0; i < adjacencyRule.DirectionsOfNeighborsCache.Length; i++)
            {
                var newPosition = position + adjacencyRule.DirectionsOfNeighborsCache[i];

                if (!goalMap.Contains(newPosition) || !goalMap[newPosition].HasValue)
                {
                    continue;
                }

                // <= to prefer movement over non movement; known to be not null thanks to above continue
                if (goalMap[newPosition] !.Value <= min)
                {
                    min    = goalMap[newPosition] !.Value; // Again known to be not null thanks to above continue
                    minDir = adjacencyRule.DirectionsOfNeighborsCache[i];
                }
            }

            return(minDir); // Direction.None if all obstacles
        }
Exemple #11
0
 /// <summary>
 /// Constructor. Takes a single goal map and assigns it a weight of 1.0.
 /// </summary>
 /// <param name="map">The goal map.</param>
 public WeightedGoalMap(IGridView <double?> map)
 {
     Weights = new List <GoalMapWeightPair> {
         new GoalMapWeightPair(map, 1)
     };
     Width  = map.Width;
     Height = map.Height;
 }
Exemple #12
0
 /// <summary>
 /// Attach the model to the view.
 /// </summary>
 /// <param name="model">The model to connect to</param>
 /// <param name="view">The view to connect to</param>
 /// <param name="parentPresenter">The parent explorer presenter</param>
 public virtual void Attach(object model, object view, ExplorerPresenter parentPresenter)
 {
     grid              = view as IGridView;
     grid.CopyCells   += CopyCells;
     grid.PasteCells  += PasteCells;
     grid.DeleteCells += DeleteCells;
     presenter         = parentPresenter;
 }
 public GridColumn(PropertyInfo property, IGridView grid)
 {
     Grid           = grid;
     Metadata       = ModelMetadata.FromStringExpression(property.Name, new ViewDataDictionary <T>());
     this.Title     = Metadata.DisplayName ?? Metadata.PropertyName;
     this.DataField = Metadata.PropertyName;
     this.DataType  = Metadata.ModelType;
 }
 public GridColumn(Expression <Func <T, F> > expression, IGridView grid)
 {
     Grid           = grid;
     Metadata       = ModelMetadata.FromLambdaExpression(expression, new ViewDataDictionary <T>());
     this.Title     = Metadata.DisplayName ?? Metadata.PropertyName;
     this.DataField = Metadata.PropertyName;
     this.DataType  = Metadata.ModelType;
 }
Exemple #15
0
        /// <summary>Display a view on the right hand panel in view.</summary>
        public void ShowRightHandView()
        {
            if (this.treeview.SelectedNode != string.Empty)
            {
                string[] path = this.treeview.SelectedNode.Split('.');

                string root        = "";
                string category    = "";
                string subcategory = "";

                //zero based but path[0] is always empty.
                //(because SelectedNode path always starts with a ".")
                //true root ie. name of model is always path[1]
                switch (path.Length)
                {
                case 1:
                    root        = "";
                    category    = "";
                    subcategory = "";
                    break;

                case 2:
                    root        = path[1];
                    category    = "";
                    subcategory = "";
                    break;

                case 3:
                    root        = path[1];
                    category    = path[2];
                    subcategory = "";
                    break;

                case 4:
                    root        = path[1];
                    category    = path[2];
                    subcategory = path[3];
                    break;
                }

                this.tablePresenter.CategoryFilter    = category;
                this.tablePresenter.SubcategoryFilter = subcategory;
            }
            else
            {
                //this will show all the properties in the model
                //there will be no filtering on Category and Subcategory.
                this.tablePresenter.CategoryFilter    = "";
                this.tablePresenter.SubcategoryFilter = "";
            }

            //create a new grid view to be added as a RightHandView
            //nb. the grid view is owned by the tree view not by this presenter.
            this.gridview = new GridView(this.treeview as ViewBase);
            this.treeview.AddRightHandView(this.gridview);
            this.tablePresenter.Attach(this.model, this.gridview, this.explorerPresenter);
        }
Exemple #16
0
 private static bool IsPointMapEdge(IGridView <bool> map, Point location, bool onlyEdgeTest = false)
 {
     if (onlyEdgeTest)
     {
         return(location.X == 0 || location.X == map.Width - 1 || location.Y == 0 ||
                location.Y == map.Height - 1);
     }
     return(location.X <= 0 || location.X >= map.Width - 1 || location.Y <= 0 || location.Y >= map.Height - 1);
 }
        /// <summary>
        /// Constructor. Takes an existing grid view to create a view from and a getter function
        /// taking only a value of type T1.
        /// </summary>
        /// <remarks>
        /// If a position is also needed to perform the translation, an overload is provided taking a
        /// corresponding function.
        /// </remarks>
        /// <param name="baseGrid">Your underlying grid data.</param>
        /// <param name="getter">The TranslateGet implementation.</param>
        public LambdaTranslationGridView(IGridView <T1> baseGrid, Func <T1, T2> getter)
            : base(baseGrid)
        {
            if (getter == null)
            {
                throw new ArgumentNullException(nameof(getter));
            }

            _getter = (c, t1) => getter(t1);
        }
Exemple #18
0
        public virtual int GetActualHeight(IGridView gridView)
        {
            GridTableElement gridTableElement = gridView as GridTableElement;

            if (gridTableElement != null)
            {
                return((int)gridTableElement.RowScroller.ElementProvider.GetElementSize(this).Height);
            }
            return(this.Height);
        }
 /// <summary>
 /// Iterates through each position in the grid view.
 /// </summary>
 /// <typeparam name="T" />
 /// <param name="gridView" />
 /// <returns>All positions in the IGridView.</returns>
 public static IEnumerable <Point> Positions <T>(this IGridView <T> gridView)
 {
     for (var y = 0; y < gridView.Height; y++)
     {
         for (var x = 0; x < gridView.Width; x++)
         {
             yield return(new Point(x, y));
         }
     }
 }
Exemple #20
0
        public void IndexerAccessGridViewTest()
        {
            var grid = new ArrayView <bool>(_width, _height);
            ISettableGridView <bool> setGridView = grid;
            IGridView <bool>         gridView    = grid;

            bool[] array = grid;

            // Set last entry via indexer syntax (via the ArrayView, to prove implicit implementations
            // work at all levels)
            grid[^ 1] = true;
Exemple #21
0
		public void Setup()
		{
			Application.Instance.Invoke(() =>
			{
				grid = new GridView();
				handler = (IGridView)grid.Handler;
				model = GridViewUtils.CreateModel();
				grid.DataStore = model;
				grid.SelectionChanged += (s, e) => selectionChangedCount++;
			});
		}
Exemple #22
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.grid              = view as IGridView;
            this.model             = model as Model;
            this.explorerPresenter = explorerPresenter;

            this.FindAllProperties();
            this.PopulateGrid(this.model);
            this.grid.CellsChanged += this.OnCellValueChanged;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
Exemple #23
0
 public void Setup()
 {
     Application.Instance.Invoke(() =>
     {
         grid                   = new GridView();
         handler                = (IGridView)grid.Handler;
         model                  = GridViewUtils.CreateModel();
         grid.DataStore         = model;
         grid.SelectionChanged += (s, e) => selectionChangedCount++;
     });
 }
Exemple #24
0
        /// <summary>
        /// Constructor. Takes a base map and a distance measurement to use for calculation.
        /// </summary>
        /// <param name="baseMap">
        /// A map view that represents the map as an
        /// <see cref="SadRogue.Primitives.GridViews.IGridView{T}" /> of <see cref="GoalState"/>.  Must not change
        /// width/height after the goal map has been constructed.
        /// </param>
        /// <param name="distanceMeasurement">
        /// The distance measurement (and implicitly the <see cref="SadRogue.Primitives.AdjacencyRule" />) to use for calculation.
        /// </param>
        public GoalMap(IGridView <GoalState> baseMap, Distance distanceMeasurement)
        {
            BaseMap             = baseMap ?? throw new ArgumentNullException(nameof(baseMap));
            DistanceMeasurement = distanceMeasurement;

            _closedSet = new BitArray(baseMap.Width * baseMap.Height);
            _openEdges = new Queue <Point>();

            _goalMap = new ArrayView <double?>(baseMap.Width, baseMap.Height);
            Update();
        }
Exemple #25
0
        /// <summary>
        /// Constructor. Takes the resistance map to use for calculations.
        /// </summary>
        /// <param name="resMap">The resistance map to use for calculations.</param>
        public SenseMap(IGridView <double> resMap)
        {
            _resMap     = resMap;
            _senseMap   = new double[resMap.Width, resMap.Height];
            _lastWidth  = resMap.Width;
            _lastHeight = resMap.Height;

            _senseSources = new List <SenseSource>();

            _previousSenseMap = new HashSet <Point>();
            _currentSenseMap  = new HashSet <Point>();
        }
Exemple #26
0
        /// <summary>Constructor</summary>
        public DualGridView(ViewBase owner) : base(owner)
        {
            Grid1 = new GridView(owner);
            Grid2 = new GridView(owner);

            VPaned panel = new VPaned();

            mainWidget = panel;
            panel.Pack1((Grid1 as GridView).MainWidget, true, true);
            panel.Pack2((Grid2 as GridView).MainWidget, true, true);
            mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Exemple #27
0
        /// <summary>Constructor</summary>
        public PropertyAndGridView(ViewBase owner) : base(owner)
        {
            PropertiesView = new PropertyView(owner);
            Grid2          = new GridView(owner);

            VPaned panel = new VPaned();

            mainWidget = panel;
            panel.Pack1((PropertiesView as ViewBase).MainWidget, true, false);
            panel.Pack2((Grid2 as ViewBase).MainWidget, true, false);
            mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Exemple #28
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.grid              = view as IGridView;
            this.tableModel        = model as IModelAsTable;
            this.explorerPresenter = explorerPresenter;

            // populate the grid
            this.grid.DataSource = tableModel.GetTable();
            grid.RowCount        = 100;
            //this.grid.ResizeControls();

            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
Exemple #29
0
 public void ReloadData()
 {
     mainPanel.Controls.Clear();
     _gridView                 = new GridControlView();
     _gridView.IsSelect        = toolSelected.Checked;
     _gridView.IsPanTo         = toolPanTo.Checked;
     _gridView.IsZoomTo        = toolZoomTo.Checked;
     _gridView.Dock            = DockStyle.Fill;
     _gridView.Map             = _context.FocusMap;
     _gridView.Grid.DataSource = ConvertToExpandoObjectList(_featureItems);
     _gridView.BestFitColumns();
     mainPanel.Controls.Add(_gridView as Control);
 }
Exemple #30
0
        private static bool IsPointWallsExceptSource(IGridView <bool> map, Point location, Direction sourceDirection)
        {
            // exclude the outside of the map
            var mapInner = map.Bounds().Expand(-1, -1);

            if (!mapInner.Contains(location))
            {
                // Shortcut out if this location is part of the map edge.
                return(false);
            }

            // Get map indexes for all surrounding locations
            var index = AdjacencyRule.EightWay.DirectionsOfNeighborsClockwise().ToArray();

            Direction[] skipped;

            if (sourceDirection == Direction.Right)
            {
                skipped = new[] { sourceDirection, Direction.UpRight, Direction.DownRight }
            }
            ;
            else if (sourceDirection == Direction.Left)
            {
                skipped = new[] { sourceDirection, Direction.UpLeft, Direction.DownLeft }
            }
            ;
            else if (sourceDirection == Direction.Up)
            {
                skipped = new[] { sourceDirection, Direction.UpRight, Direction.UpLeft }
            }
            ;
            else
            {
                skipped = new[] { sourceDirection, Direction.DownRight, Direction.DownLeft }
            };

            foreach (var direction in index)
            {
                if (skipped[0] == direction || skipped[1] == direction || skipped[2] == direction)
                {
                    continue;
                }

                if (!map.Bounds().Contains(location + direction) || map[location + direction])
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #31
0
        public GridModel(IGridView gridView, IGeneratorsHost generatorsHost, bool shouldExecuteSyncroniously)
        {
            this.executeOperationsSyncroniously = shouldExecuteSyncroniously;
            this.TrackPropertyChanged           = true;

            this.GroupFactory = new DataGroupFactory();

            this.GeneratorsHost = generatorsHost;
            this.GridView       = gridView;
            this.View           = gridView;

            this.rowLayout    = new CompactLayout(new GroupHierarchyAdapter(), DefaultRowHeight);
            this.columnLayout = new CompactLayout(new GroupHierarchyAdapter(), DefaultColumnWidth);

            this.columns = new DataGridColumnCollection(this);

            this.RowPool    = new RowModelPool(this, new RowModelGenerator(generatorsHost.RowItemGenerator), this.rowLayout);
            this.ColumnPool = new ColumnHeaderPool(this, new ColumnModelGenerator(generatorsHost.ColumnItemGenerator), this.columnLayout);

            this.CellsController            = new CellsController <GridCellModel>(this, new CellModelGenerator(generatorsHost.CellItemGenerator));
            this.CellsController.ColumnPool = this.ColumnPool;
            this.CellsController.RowPool    = this.RowPool;

            this.EditRowPool = new EditRowPool(this.GeneratorsHost.EditRowItemGenerator, this);

            this.CellEditorsController            = new CellEditorsController(this, new CellEditorModelGenerator(generatorsHost.CellEditorItemGenerator));
            this.CellEditorsController.ColumnPool = this.ColumnPool;
            this.CellEditorsController.RowPool    = this.EditRowPool;

            // TODO: Consider providing it in the constructor or as a property of IGridView interface.
            this.DecorationsController = new DecorationsController(gridView.LineDecorationsPresenter);
            this.selectionPresenter    = new SelectionRegionController(gridView.SelectionDecorationsPresenter);

            this.FrozenDecorationsController = new DecorationsController(gridView.FrozenLineDecorationsPresenter);
            this.FrozenSelectionPresenter    = new SelectionRegionController(gridView.FrozenSelectionDecorationsPresenter);

            this.sortDescriptors = new SortDescriptorCollection(this);
            this.sortDescriptors.CollectionChanged += this.OnSortDescriptorsCollectionChanged;

            this.groupDescriptors = new GroupDescriptorCollection(this);
            this.groupDescriptors.CollectionChanged += this.OnGroupDescriptorsCollectionChanged;

            this.filterDescriptors = new FilterDescriptorCollection(this);
            this.filterDescriptors.CollectionChanged += this.OnFilterDescriptorsCollectionChanged;

            this.aggregateDescriptors = new AggregateDescriptorCollection(this);
            this.aggregateDescriptors.CollectionChanged += this.OnAggregateDescriptorsCollectionChanged;

            this.VerticalBufferScale = 1;
        }
Exemple #32
0
		/// <summary>
		/// Create a grid and register view data
		/// </summary>
		public void CreateGrid (int locationX, int locationY, IGridView view)
		{
			Logger.I ("Creating the " + Width + "x" + Height + " grid...");

			// Calculate border size
			// TODO This sucks
			BorderWidth = 4;
			int borderStartX = GridLocation.X + (BorderWidth / 2);
			int borderStartY = GridLocation.Y + (BorderWidth / 2);
			BorderStartLocation = new Point (borderStartX, borderStartY);
			GridLocation = BorderStartLocation;

			// Create the grid
			Cells = new Cell[Width][];

			for (int x=0; x<Width; x++) {

				Cells [x] = new Cell[Height];

				for (int y=0; y<Height; y++) {

					Cell c = new Cell ();
					c.X = x;
					c.Y = y;
					Cells [x] [y] = c;

					c.Rect = new Rectangle (
						GridLocation.X + c.X * CellSize, 
						GridLocation.Y + c.Y * CellSize, 
						CellSize, CellSize);
				}
			}

			// Initialize the view
			if (view == null) {
				throw new ArgumentException ();
			}

			this.View = view;
		}
Exemple #33
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            // if the model is Testable, run the test method.
            ITestable testModel = model as ITestable;
            if (testModel != null)
                testModel.Test(false, true);

            string[] split;
            this.grid = view as IGridView;
            this.model = model as Model;
            this.explorerPresenter = explorerPresenter;

            this.FindAllProperties(this.model);
            if (this.grid.DataSource == null)
            {
                this.PopulateGrid(this.model);
            }
            else
            {
                this.grid.ResizeControls();
                FormatTestGrid();
            }

            this.grid.CellsChanged += this.OnCellValueChanged;
            this.grid.ButtonClick += OnFileBrowseClick;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
            if (model != null)
            {
                split = this.model.GetType().ToString().Split('.');
                this.grid.ModelName = split[split.Length - 1];
                this.grid.LoadImage();
            }
        }
Exemple #34
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            string[] split;
            this.grid = view as IGridView;
            this.model = model as Model;
            this.explorerPresenter = explorerPresenter;

            this.FindAllProperties();
            this.PopulateGrid(this.model);
            this.grid.CellsChanged += this.OnCellValueChanged;
            this.grid.ButtonClick += OnFileBrowseClick;
            this.grid.ResizeControls();
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
            if (model != null)
            {
                split = this.model.GetType().ToString().Split('.');
                this.grid.ModelName = split[split.Length - 1];
                this.grid.LoadImage();
            }
        }