// Use this for initialization void Start() { Vector3[] startPoss = new Vector3[2]; //For one or two drones, start positions are defined //to help reduce response times (hueristic) if (numOfDrone == 1) { startPoss [0] = new Vector3(0, 21, 0); startPoss [1] = new Vector3(0, 21, 0); } if (numOfDrone == 2) { startPoss [0] = new Vector3(75, 21, 75); startPoss [1] = new Vector3(-75, 21, -75); } //Initialize all the required drones droneArray = new Zephyr[numOfDrone]; for (int x = 0; x < numOfDrone; x++) { Zephyr newDrone = Instantiate(dronePrefab, startPoss[x], new Quaternion(0, 0, 0, 0)); droneArray [x] = newDrone; } }
internal ExcelColor(ExcelStyles styles, Zephyr.Utils.EPPlus.XmlHelper.ChangedEventHandler ChangedEvent, int worksheetID, string address, eStyleClass cls, StyleBase parent) : base(styles, ChangedEvent, worksheetID, address) { _parent = parent; _cls = cls; }
public static HSSFEvaluationWorkbook Create(Zephyr.Utils.NPOI.SS.UserModel.IWorkbook book) { if (book == null) { return null; } return new HSSFEvaluationWorkbook((HSSFWorkbook)book); }
static void Main(string[] args) { IDetector zeph = new Zephyr(); zeph.OnData += zeph_OnData; zeph.ConnectDevice("COM5"); Console.Read(); }
private static void Add(Hashtable m, OperationPtg ptgKey, Zephyr.Utils.NPOI.SS.Formula.Functions.Function instance) { // make sure ptg has single private constructor because map lookups assume singleton keys ConstructorInfo[] cc = ptgKey.GetType().GetConstructors(); if (cc.Length > 1 || (cc.Length > 0 && !cc[0].IsPrivate)) { throw new Exception("Failed to verify instance (" + ptgKey.GetType().Name + ") is a singleton."); } m[ptgKey] = instance; }
//[Obsolete] //public static void SetBorderLeft(Zephyr.Utils.NPOI.SS.UserModel.CellBorderType border, Region region, HSSFSheet sheet, // HSSFWorkbook workbook) //{ // SetBorderLeft(border, toCRA(region), sheet, workbook); //} /// <summary> /// Sets the left border for a region of cells by manipulating the cell style /// of the individual cells on the left /// </summary> /// <param name="border">The new border</param> /// <param name="region">The region that should have the border</param> /// <param name="sheet">The sheet that the region is on.</param> /// <param name="workbook">The workbook that the region is on.</param> public static void SetBorderLeft(Zephyr.Utils.NPOI.SS.UserModel.BorderStyle border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { int rowStart = region.FirstRow; int rowEnd = region.LastRow; int column = region.FirstColumn; CellPropertySetter cps = new CellPropertySetter(workbook, HSSFCellUtil.BORDER_LEFT, (int)border); for (int i = rowStart; i <= rowEnd; i++) { cps.SetProperty(HSSFCellUtil.GetRow(i, sheet), column); } }
public WorkItem(int size, Zephyr.Utils.Ionic.Zlib.CompressionLevel compressLevel, CompressionStrategy strategy, int ix) { this.buffer= new byte[size]; // alloc 5 bytes overhead for every block (margin of safety= 2) int n = size + ((size / 32768)+1) * 5 * 2; this.compressed = new byte[n]; this.compressor = new ZlibCodec(); this.compressor.InitializeDeflate(compressLevel, false); this.compressor.OutputBuffer = this.compressed; this.compressor.InputBuffer = this.buffer; this.index = ix; }
internal ExcelStyle(ExcelStyles styles, Zephyr.Utils.EPPlus.XmlHelper.ChangedEventHandler ChangedEvent, int positionID, string Address, int xfsId) : base(styles, ChangedEvent, positionID, Address) { Index = xfsId; ExcelXfs xfs; if (positionID > -1) { xfs = _styles.CellXfs[xfsId]; } else { xfs = _styles.CellStyleXfs[xfsId]; } Styles = styles; PositionID = positionID; Numberformat = new ExcelNumberFormat(styles, ChangedEvent, PositionID, Address, xfs.NumberFormatId); Font = new ExcelFont(styles, ChangedEvent, PositionID, Address, xfs.FontId); Fill = new ExcelFill(styles, ChangedEvent, PositionID, Address, xfs.FillId); Border = new Border(styles, ChangedEvent, PositionID, Address, xfs.BorderId); }
// Update is called once per frame void Update() { /* * This is a hueristic strategy in which each unscanned * fire is assigned to the nearest drone that is free */ float sDistance = float.MaxValue; Zephyr closestDrone = null; Fire closestFire = null; for (int j = 0; j < fireArray.Count; j++) { if (!fireArray [j].targetted && !fireArray [j].scanned) { for (int i = 0; i < droneArray.Length; i++) { if (!droneArray [i].busy) { float d = Vector3.Distance(droneArray [i].transform.position, fireArray [j].transform.position); if (d < sDistance) { sDistance = d; closestDrone = droneArray [i]; closestFire = fireArray [j]; } } } } } if (closestDrone != null && closestFire != null) { closestDrone.setFire(closestFire); closestDrone.busy = true; closestFire.targetted = true; } }
/// <summary> /// Calculates the height of a client anchor in points. /// </summary> /// <param name="sheet">the sheet the anchor will be attached to</param> /// <returns>the shape height.</returns> public float GetAnchorHeightInPoints(Zephyr.Utils.NPOI.SS.UserModel.ISheet sheet) { int y1 = Dy1; int y2 = Dy2; int row1 = Math.Min(Row1, Row2); int row2 = Math.Max(Row1, Row2); float points = 0; if (row1 == row2) { points = ((y2 - y1) / 256.0f) * GetRowHeightInPoints(sheet, row2); } else { points += ((256.0f - y1) / 256.0f) * GetRowHeightInPoints(sheet, row1); for (int i = row1 + 1; i < row2; i++) { points += GetRowHeightInPoints(sheet, i); } points += (y2 / 256.0f) * GetRowHeightInPoints(sheet, row2); } return points; }
/// <summary> /// Sets the bottom border of region. /// </summary> /// <param name="region">The region.</param> /// <param name="borderType">Type of the border.</param> /// <param name="color">The color.</param> public void SetBorderBottomOfRegion(CellRangeAddress region, Zephyr.Utils.NPOI.SS.UserModel.BorderStyle borderType, short color) { HSSFRegionUtil.SetBottomBorderColor(color, region, this, _workbook); HSSFRegionUtil.SetBorderBottom(borderType, region, this, _workbook); }
private static bool ContainsCell(Zephyr.Utils.NPOI.SS.Util.CellRangeAddress cr, int rowIx, int colIx) { if (cr.FirstRow <= rowIx && cr.LastRow >= rowIx && cr.FirstColumn <= colIx && cr.LastColumn >= colIx) { return true; } return false; }
/// <summary> /// Creates a cell, gives it a value, and applies a style if provided /// </summary> /// <param name="row">the row to Create the cell in</param> /// <param name="column">the column index to Create the cell in</param> /// <param name="value">The value of the cell</param> /// <param name="style">If the style is not null, then Set</param> /// <returns>A new HSSFCell</returns> public static Zephyr.Utils.NPOI.SS.UserModel.ICell CreateCell(Zephyr.Utils.NPOI.SS.UserModel.IRow row, int column, String value, HSSFCellStyle style) { Zephyr.Utils.NPOI.SS.UserModel.ICell cell = GetCell(row, column); cell.SetCellValue(new HSSFRichTextString(value)); if (style != null) { cell.CellStyle = (style); } return cell; }
/// <summary> /// Sets the enclosed border of region. /// </summary> /// <param name="region">The region.</param> /// <param name="borderType">Type of the border.</param> /// <param name="color">The color.</param> public void SetEnclosedBorderOfRegion(CellRangeAddress region, Zephyr.Utils.NPOI.SS.UserModel.BorderStyle borderType, short color) { HSSFRegionUtil.SetRightBorderColor(color, region, this, _workbook); HSSFRegionUtil.SetBorderRight(borderType, region, this, _workbook); HSSFRegionUtil.SetLeftBorderColor(color, region, this, _workbook); HSSFRegionUtil.SetBorderLeft(borderType, region, this, _workbook); HSSFRegionUtil.SetTopBorderColor(color, region, this, _workbook); HSSFRegionUtil.SetBorderTop(borderType, region, this, _workbook); HSSFRegionUtil.SetBottomBorderColor(color, region, this, _workbook); HSSFRegionUtil.SetBorderBottom(borderType, region, this, _workbook); }
/// <summary> /// Sets the format properties of the given style based on the given map. /// </summary> /// <param name="style">The cell style</param> /// <param name="workbook">The parent workbook.</param> /// <param name="properties">The map of format properties (String -> Object).</param> private static void SetFormatProperties( Zephyr.Utils.NPOI.SS.UserModel.ICellStyle style, HSSFWorkbook workbook, Hashtable properties) { style.Alignment = (Zephyr.Utils.NPOI.SS.UserModel.HorizontalAlignment)GetShort(properties, ALIGNMENT); style.BorderBottom = (Zephyr.Utils.NPOI.SS.UserModel.BorderStyle)GetShort(properties, BORDER_BOTTOM); style.BorderLeft = (Zephyr.Utils.NPOI.SS.UserModel.BorderStyle)GetShort(properties, BORDER_LEFT); style.BorderRight = (Zephyr.Utils.NPOI.SS.UserModel.BorderStyle)GetShort(properties, BORDER_RIGHT); style.BorderTop = (Zephyr.Utils.NPOI.SS.UserModel.BorderStyle)GetShort(properties, BORDER_TOP); style.BottomBorderColor = (GetShort(properties, BOTTOM_BORDER_COLOR)); style.DataFormat = (GetShort(properties, DATA_FORMAT)); style.FillBackgroundColor = (GetShort(properties, FILL_BACKGROUND_COLOR)); style.FillForegroundColor = (GetShort(properties, FILL_FOREGROUND_COLOR)); style.FillPattern = (Zephyr.Utils.NPOI.SS.UserModel.FillPatternType)GetShort(properties, FILL_PATTERN); style.SetFont(workbook.GetFontAt(GetShort(properties, FONT))); style.IsHidden = (GetBoolean(properties, HIDDEN)); style.Indention = (GetShort(properties, INDENTION)); style.LeftBorderColor = (GetShort(properties, LEFT_BORDER_COLOR)); style.IsLocked = (GetBoolean(properties, LOCKED)); style.RightBorderColor = (GetShort(properties, RIGHT_BORDER_COLOR)); style.Rotation = (GetShort(properties, ROTATION)); style.TopBorderColor = (GetShort(properties, TOP_BORDER_COLOR)); style.VerticalAlignment = (Zephyr.Utils.NPOI.SS.UserModel.VerticalAlignment)GetShort(properties, VERTICAL_ALIGNMENT); style.WrapText = (GetBoolean(properties, WRAP_TEXT)); }
internal ExcelFill(ExcelStyles styles, Zephyr.Utils.EPPlus.XmlHelper.ChangedEventHandler ChangedEvent, int PositionID, string address, int index) : base(styles, ChangedEvent, PositionID, address) { Index = index; }
public int AddMergedRegion(Zephyr.Utils.NPOI.SS.Util.Region region) { return _sheet.AddMergedRegion(region.RowFrom, region.ColumnFrom, region.RowTo, region.ColumnTo); }
/// <summary> /// Sets the size of the margin in inches. /// </summary> /// <param name="margin">which margin to get.</param> /// <param name="size">the size of the margin</param> public void SetMargin(Zephyr.Utils.NPOI.SS.UserModel.MarginType margin, double size) { _sheet.PageSettings.SetMargin(margin, size); }
//[Obsolete] //public static void SetBorderTop(Zephyr.Utils.NPOI.SS.UserModel.CellBorderType border, Region region, HSSFSheet sheet, // HSSFWorkbook workbook) //{ // SetBorderTop(border, toCRA(region), sheet, workbook); //} /// <summary> /// Sets the borderBottom attribute of the HSSFRegionUtil object /// </summary> /// <param name="border">The new border</param> /// <param name="region">The region that should have the border</param> /// <param name="sheet">The sheet that the region is on.</param> /// <param name="workbook">The workbook that the region is on.</param> public static void SetBorderTop(Zephyr.Utils.NPOI.SS.UserModel.BorderStyle border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { int colStart = region.FirstColumn; int colEnd = region.LastColumn; int rowIndex = region.FirstRow; CellPropertySetter cps = new CellPropertySetter(workbook, HSSFCellUtil.BORDER_TOP, (int)border); Zephyr.Utils.NPOI.SS.UserModel.IRow row = HSSFCellUtil.GetRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.SetProperty(row, i); } }
/** * This method attempt to find an already existing HSSFCellStyle that matches * what you want the style to be. If it does not find the style, then it * Creates a new one. If it does Create a new one, then it applies the * propertyName and propertyValue to the style. This is necessary because * Excel has an upper limit on the number of Styles that it supports. * *@param workbook The workbook that is being worked with. *@param propertyName The name of the property that is to be * changed. *@param propertyValue The value of the property that is to be * changed. *@param cell The cell that needs it's style changes *@exception NestableException Thrown if an error happens. */ public static void SetCellStyleProperty(Zephyr.Utils.NPOI.SS.UserModel.ICell cell, HSSFWorkbook workbook, String propertyName, Object propertyValue) { Zephyr.Utils.NPOI.SS.UserModel.ICellStyle originalStyle = cell.CellStyle; Zephyr.Utils.NPOI.SS.UserModel.ICellStyle newStyle = null; Hashtable values = GetFormatProperties(originalStyle); values[propertyName] = propertyValue; // index seems like what index the cellstyle is in the list of styles for a workbook. // not good to compare on! short numberCellStyles = workbook.NumCellStyles; for (short i = 0; i < numberCellStyles; i++) { Zephyr.Utils.NPOI.SS.UserModel.ICellStyle wbStyle = workbook.GetCellStyleAt(i); Hashtable wbStyleMap = GetFormatProperties(wbStyle); if (wbStyleMap.Equals(values)) { newStyle = wbStyle; break; } } if (newStyle == null) { newStyle = workbook.CreateCellStyle(); SetFormatProperties(newStyle, workbook, values); } cell.CellStyle = (newStyle); }
/// <summary> /// Adds a picture to the workbook. /// </summary> /// <param name="pictureData">The bytes of the picture</param> /// <param name="format">The format of the picture. One of /// PictureType.</param> /// <returns>the index to this picture (1 based).</returns> public int AddPicture(byte[] pictureData, Zephyr.Utils.NPOI.SS.UserModel.PictureType format) { InitDrawings(); byte[] uid; using (MD5 md5 = MD5.Create()) { uid = md5.ComputeHash(pictureData); } EscherBitmapBlip blipRecord = new EscherBitmapBlip(); blipRecord.RecordId = (short)(EscherBitmapBlip.RECORD_ID_START + format); switch (format) { case Zephyr.Utils.NPOI.SS.UserModel.PictureType.EMF: blipRecord.Options = HSSFPictureData.MSOBI_EMF; break; case Zephyr.Utils.NPOI.SS.UserModel.PictureType.WMF: blipRecord.Options = HSSFPictureData.MSOBI_WMF; break; case Zephyr.Utils.NPOI.SS.UserModel.PictureType.PICT: blipRecord.Options = HSSFPictureData.MSOBI_PICT; break; case Zephyr.Utils.NPOI.SS.UserModel.PictureType.PNG: blipRecord.Options = HSSFPictureData.MSOBI_PNG; break; case Zephyr.Utils.NPOI.SS.UserModel.PictureType.JPEG: blipRecord.Options = HSSFPictureData.MSOBI_JPEG; break; case Zephyr.Utils.NPOI.SS.UserModel.PictureType.DIB: blipRecord.Options = HSSFPictureData.MSOBI_DIB; break; } blipRecord.UID = uid; blipRecord.Marker = (byte)0xFF; blipRecord.PictureData = pictureData; EscherBSERecord r = new EscherBSERecord(); r.RecordId = EscherBSERecord.RECORD_ID; r.Options = (short)(0x0002 | ((int)format << 4)); r.BlipTypeMacOS = (byte)format; r.BlipTypeWin32 = (byte)format; r.UID = uid; r.Tag = (short)0xFF; r.Size = pictureData.Length + 25; r.Ref = 1; r.Offset = 0; r.BlipRecord = blipRecord; return workbook.AddBSERecord(r); }
public override void Serialize(Zephyr.Utils.NPOI.Util.ILittleEndianOutput out1) { }
public override void Serialize(Zephyr.Utils.NPOI.Util.ILittleEndianOutput out1) { out1.WriteShort(field_1_cEntries); }
/// <summary> /// Creates a split pane. Any existing freezepane or split pane is overwritten. /// </summary> /// <param name="xSplitPos">Horizonatal position of split (in 1/20th of a point).</param> /// <param name="ySplitPos">Vertical position of split (in 1/20th of a point).</param> /// <param name="leftmostColumn">Left column visible in right pane.</param> /// <param name="topRow">Top row visible in bottom pane.</param> /// <param name="activePane">Active pane. One of: PANE_LOWER_RIGHT,PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT</param> public void CreateSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, Zephyr.Utils.NPOI.SS.UserModel.PanePosition activePane) //this would have the same parameter sequence as the internal method and matches the content of the description above, // if this signature changed do it in ISheet, too. // public void CreateSplitPane(int xSplitPos, int ySplitPos, int topRow, int leftmostColumn, Zephyr.Utils.NPOI.SS.UserModel.PanePosition activePane) { Sheet.CreateSplitPane(xSplitPos, ySplitPos, topRow, leftmostColumn, activePane); }
/// <summary> /// Create a cell, and give it a value. /// </summary> /// <param name="row">the row to Create the cell in</param> /// <param name="column">the column index to Create the cell in</param> /// <param name="value">The value of the cell</param> /// <returns>A new HSSFCell.</returns> public static Zephyr.Utils.NPOI.SS.UserModel.ICell CreateCell(Zephyr.Utils.NPOI.SS.UserModel.IRow row, int column, String value) { return CreateCell(row, column, value, null); }
/// <summary> /// Gets the size of the margin in inches. /// </summary> /// <param name="margin">which margin to get.</param> /// <returns>the size of the margin</returns> public double GetMargin(Zephyr.Utils.NPOI.SS.UserModel.MarginType margin) { return _sheet.PageSettings.GetMargin(margin); }
/// <summary> /// Get a specific cell from a row. If the cell doesn't exist, /// </summary> /// <param name="row">The row that the cell is part of</param> /// <param name="column">The column index that the cell is in.</param> /// <returns>The cell indicated by the column.</returns> public static Zephyr.Utils.NPOI.SS.UserModel.ICell GetCell(Zephyr.Utils.NPOI.SS.UserModel.IRow row, int column) { Zephyr.Utils.NPOI.SS.UserModel.ICell cell = row.GetCell(column); if (cell == null) { cell = row.CreateCell(column); } return cell; }
/// <summary> /// Sets the default column style for a given column. POI will only apply this style to new cells Added to the _sheet. /// </summary> /// <param name="column">the column index</param> /// <param name="style">the style to set</param> public void SetDefaultColumnStyle(int column, Zephyr.Utils.NPOI.SS.UserModel.ICellStyle style) { _sheet.SetDefaultColumnStyle(column, style.Index); }
/// <summary> /// Returns a map containing the format properties of the given cell style. /// </summary> /// <param name="style">cell style</param> /// <returns>map of format properties (String -> Object)</returns> private static Hashtable GetFormatProperties(Zephyr.Utils.NPOI.SS.UserModel.ICellStyle style) { Hashtable properties = new Hashtable(); PutShort(properties, ALIGNMENT, (short)style.Alignment); PutShort(properties, BORDER_BOTTOM, (short)style.BorderBottom); PutShort(properties, BORDER_LEFT, (short)style.BorderLeft); PutShort(properties, BORDER_RIGHT, (short)style.BorderRight); PutShort(properties, BORDER_TOP, (short)style.BorderTop); PutShort(properties, BOTTOM_BORDER_COLOR, style.BottomBorderColor); PutShort(properties, DATA_FORMAT, style.DataFormat); PutShort(properties, FILL_BACKGROUND_COLOR, style.FillBackgroundColor); PutShort(properties, FILL_FOREGROUND_COLOR, style.FillForegroundColor); PutShort(properties, FILL_PATTERN, (short)style.FillPattern); PutShort(properties, FONT, style.FontIndex); PutBoolean(properties, HIDDEN, style.IsHidden); PutShort(properties, INDENTION, style.Indention); PutShort(properties, LEFT_BORDER_COLOR, style.LeftBorderColor); PutBoolean(properties, LOCKED, style.IsLocked); PutShort(properties, RIGHT_BORDER_COLOR, style.RightBorderColor); PutShort(properties, ROTATION, style.Rotation); PutShort(properties, TOP_BORDER_COLOR, style.TopBorderColor); PutShort(properties, VERTICAL_ALIGNMENT, (short)style.VerticalAlignment); PutBoolean(properties, WRAP_TEXT, style.WrapText); return properties; }
/// <summary> /// adds a merged region of cells (hence those cells form one) /// </summary> /// <param name="region">region (rowfrom/colfrom-rowto/colto) to merge</param> /// <returns>index of this region</returns> public int AddMergedRegion(Zephyr.Utils.NPOI.SS.Util.CellRangeAddress region) { region.Validate(SpreadsheetVersion.EXCEL97); // throw IllegalStateException if the argument CellRangeAddress intersects with // a multi-cell array formula defined in this sheet ValidateArrayFormulas(region); return _sheet.AddMergedRegion(region.FirstRow, region.FirstColumn, region.LastRow, region.LastColumn); }
public HSSFEvaluationCell(Zephyr.Utils.NPOI.SS.UserModel.ICell cell, IEvaluationSheet evalSheet) { _cell = cell; _evalSheet = evalSheet; }
public void SetProperty(Zephyr.Utils.NPOI.SS.UserModel.IRow row, int column) { Zephyr.Utils.NPOI.SS.UserModel.ICell cell = HSSFCellUtil.GetCell(row, column); HSSFCellUtil.SetCellStyleProperty(cell, _workbook, _propertyName, _propertyValue); }
public HSSFEvaluationCell(Zephyr.Utils.NPOI.SS.UserModel.ICell cell) { _cell = cell; _evalSheet = new HSSFEvaluationSheet((HSSFSheet)cell.Sheet); }