public MatrixMustNotExceedSize( MatrixSize maxMatrixSize, MatrixSize matrixSize) { this.maxMatrixSize = maxMatrixSize; this.matrixSize = matrixSize; }
public RobotLocationService() { _currentPosition = new RobotPosition { X = 0, Y = 0, Direction = Direction.N }; _workingMatrixSize = new MatrixSize(); }
public void WritePatternObject(TPdfStream DataStream, TXRefSection XRef) { int MatrixSize; byte[] PatternDef = GetPattern(out MatrixSize); XRef.SetObjectOffset(PatternObjId, DataStream); TIndirectRecord.SaveHeader(DataStream, PatternObjId); TDictionaryRecord.BeginDictionary(DataStream); TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.PatternName)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.PatternTypeName, "1"); TDictionaryRecord.SaveKey(DataStream, TPdfToken.PaintTypeName, "2"); TDictionaryRecord.SaveKey(DataStream, TPdfToken.TilingTypeName, "2"); TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, String.Format(CultureInfo.InvariantCulture, "[0 0 {0} {0}]", MatrixSize)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.XStepName, MatrixSize.ToString(CultureInfo.InvariantCulture)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.YStepName, MatrixSize.ToString(CultureInfo.InvariantCulture)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, PatternDef.Length); TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName)); TDictionaryRecord.BeginDictionary(DataStream); TDictionaryRecord.EndDictionary(DataStream); TDictionaryRecord.EndDictionary(DataStream); TStreamRecord.BeginSave(DataStream); DataStream.Write(PatternDef); TStreamRecord.EndSave(DataStream); TIndirectRecord.SaveTrailer(DataStream); }
/// <summary> /// Calculate penalty value for first rule. /// </summary> internal override int PenaltyCalculate(BitMatrix matrix) { MatrixSize size = matrix.Size; int penaltyValue = 0; penaltyValue = PenaltyCalculation(matrix, true) + PenaltyCalculation(matrix, false); return(penaltyValue); }
public HorizontalMatrixValidator(ICollection <string> matrix) { var matrixSize = new MatrixSize(matrix); var maxMatrixSize = new MatrixSize(MatrixConstants.MATRIX_MAX_HEIGHT, MatrixConstants.MATRIX_MAX_LENGTH); Entity = matrix; Rules = new List <IRule> { new AllMatrixRowsMustHaveSameLength(matrix, matrixSize.Length), new MatrixMustNotExceedSize(maxMatrixSize, matrixSize) }; }
public bool SetupWorkingMatrix(MatrixSize matrixSize) { if (matrixSize == null) { _log.Message(LogLevel.Warn, $"Matrix size setup abort due to {typeof(MatrixSize).Name} value null"); return(false); } _workingMatrixSize = matrixSize; return(true); }
public ActionResult CreateMatrix(MatrixSize matrixSize) { if (matrixSize == null || matrixSize.Range <= 0 || matrixSize.Range > 26) { return(BadRequest("Invalid matrix size. Required size: 0 < matrixSize <= 26")); } if (_gameLifetimeService.GetGameState() == GameState.Finished) { _gameLifetimeService.ClearGame(); } _creationService.CreateMatrix(matrixSize.Range); return(Ok()); }
public override void ApplyTo(TriStateMatrix matrix) { MatrixSize size = GetSizeOfSquareWithSeparators(); MatrixPoint leftTopCorner = new MatrixPoint(0, 0); CopyTo(matrix, new MatrixRectangle(new MatrixPoint(1, 1), size), leftTopCorner, MatrixStatus.NoMask); MatrixPoint rightTopCorner = new MatrixPoint(matrix.Width - Width + 1, 0); CopyTo(matrix, new MatrixRectangle(new MatrixPoint(0, 1), size), rightTopCorner, MatrixStatus.NoMask); MatrixPoint leftBottomCorner = new MatrixPoint(0, matrix.Width - Width + 1); CopyTo(matrix, new MatrixRectangle(new MatrixPoint(1, 0), size), leftBottomCorner, MatrixStatus.NoMask); }
public (bool isSuccess, StateResponse stateResponse) ProcessState(RobotCommand robotCommand, MatrixSize matrixSize = null) { if (robotCommand == null || robotCommand.MoveTo == null) { return(false, null); } bool result = _locationService.SetPosition(robotCommand.MoveTo.X, robotCommand.MoveTo.Y, robotCommand.CurentDirection); return(result, new StateResponse { CurrentPosition = _locationService.GetCurrentRobotPosition() }); }
public BGListView(MatrixSize size) : base(size, new Size(50, 50), 5, 5) { //Test:BGTimer BGSystem.MainTimer.Tick += (s, e) => this.SystemUpdate(); }
private void UpdateGrid(bool withAnimation) { TimeSpan animationTime = new TimeSpan(); List <WidgetSiteControl> sitesToRemove = new List <WidgetSiteControl>(256); int rowCount = _controlData.Source.Bounds.RowCount; int columnCount = _controlData.Source.Bounds.ColumnCount; ResizeRowOrColumn(matrixPanel.RowDefinitions, rowCount); ResizeRowOrColumn(matrixPanel.ColumnDefinitions, columnCount); _controlData.SiteGrid = new Array2D <WidgetSiteControl>(rowCount, columnCount); foreach (var child in matrixPanel.Children) { WidgetSiteControl site = child as WidgetSiteControl; if (site == null) { continue; } if (!_controlData.Source.Bounds.Contains(site.Location)) { if (withAnimation) { MatrixSize siteDistance = _controlData.Source.Bounds.Distance(site.Location); TranslateTransform transform = (TranslateTransform)((TransformGroup)site.RenderTransform).Children[1]; transform.Y = site.HeightWithMargin * siteDistance.RowCount; transform.X = site.WidthWithMargin * siteDistance.ColumnCount; AnimateSiteScaleTransform(site, ref animationTime, 1, 0, new EventHandler((o, e) => { matrixPanel.Children.Remove(site); })); } else { sitesToRemove.Add(site); } } else { MatrixLoc arrayIndex = _controlData.Source.Bounds.ToIndex(site.Location); _controlData.SiteGrid[arrayIndex] = site; site.UpdateGridPosition(); } } foreach (var site in sitesToRemove) { matrixPanel.Children.Remove(site); } foreach (MatrixLoc loc in _controlData.Source.Bounds) { MatrixLoc arrayIndex = _controlData.Source.Bounds.ToIndex(loc); if (_controlData.SiteGrid[arrayIndex] == null) { var site = CreateWidgetSite(loc, withAnimation, ref animationTime); _controlData.SiteGrid[arrayIndex] = site; } _controlData.SiteGrid[arrayIndex].Content = _controlData.Source[loc]; } }
/// <summary> /// Конструктор класса. /// Инициализирует существующую матрицу. /// </summary> public Matrix(string name, T[,] matrix, MatrixSize size) { this.name = name; this.matrix = matrix; this.size = size; }
public Matrix(MatrixSize matrixSize) { Size = matrixSize; matrix = new int[matrixSize.Rows, matrixSize.Columns]; }
public SCP(MatrixSize size) { Matrix = new Matrix <int>(size); Solution = new SCPSolution(); }
/// <inheritdoc/> protected override void DeserializeFromXml( XmlReader reader ) { _containerBounds.Row = XmlConvert.ToInt32( reader.GetAttribute( "firstRow" ) ); _containerBounds.Column = XmlConvert.ToInt32( reader.GetAttribute( "firstColumn" ) ); MatrixSize size = new MatrixSize( XmlConvert.ToInt32( reader.GetAttribute( "rowCount" ) ), XmlConvert.ToInt32( reader.GetAttribute( "columnCount" ) ) ); Resize( size, 0 ); if( !reader.Read() ) return; while( reader.NodeType != XmlNodeType.EndElement ) { if( reader.NodeType == XmlNodeType.Element ) { if( string.Compare( reader.Name, "Children", true ) == 0 ) { reader.Read(); while( reader.NodeType != XmlNodeType.EndElement ) { if( reader.NodeType == XmlNodeType.Element ) { WidgetData widget = WidgetData.Create( reader ); this[ widget.Location ] = widget; } else { reader.Read(); } } reader.ReadEndElement(); } else { reader.Skip(); } } else { reader.Read(); } } }
/// <summary> /// Resizes the container to the specified size /// </summary> /// <param name="newSize">New size to which the container is to be resized</param> /// <param name="justify">Resize justification, which indicates the edge at which widgets are to /// remain in their current positions (i.e. right justification will make the left edge move left/right /// while right edge's location stays constant)</param> public void Resize( MatrixSize newSize, WidgetContainerResizeJustify justify ) { if( newSize.RowCount > 256 || newSize.ColumnCount > 256 ) { throw new ApplicationException( string.Format( "Attemp to allocate too much ({0} x {1})", newSize.RowCount, newSize.ColumnCount ) ); } else if( newSize == this.Bounds.Size ) { return; } Validate(); MatrixSize currentSize = this.Size; MatrixSize originShift = currentSize - newSize; if( !justify.HasFlag( WidgetContainerResizeJustify.Bottom ) ) originShift.RowCount = 0; if( !justify.HasFlag( WidgetContainerResizeJustify.Right ) ) originShift.ColumnCount = 0; MatrixRect newContainerBounds = new MatrixRect( _containerBounds.Location + originShift, newSize ); // Cells in the intersection of original bounding rectangle and the new bounding // rectangle are the ones that will survive the resize operation. Once we identify // the intersection of the two rectangles, we need to iterate through the original // array and copy those cells into the new array MatrixRect existingCellBounds = _containerBounds.Intersect( newContainerBounds ); // normalize existing cell bounding box around 0-based arrays. existingCellBounds.Location = new MatrixLoc( originShift.RowCount > 0 ? originShift.RowCount : 0, originShift.ColumnCount > 0 ? originShift.ColumnCount : 0 ); Array2D< WidgetData > newArray = new Array2D<WidgetData>( newSize ); foreach( var loc in existingCellBounds ) { newArray[ loc - originShift ] = _widgetArray[ loc ]; } _widgetArray = newArray; _containerBounds = newContainerBounds; this.IsDirty = true; Validate(); OnContainerResized(); Validate(); }
internal MatrixRectangle(MatrixPoint location, MatrixSize size) : this() { Location = location; Size = size; }
public override bool Equals(object obj) { MatrixSize core = obj as MatrixSize; return((this.X != core.X) || (this.Y != core.Y) ? false : true); }