/* * 0 通道ID BYTE >0 1 拍摄命令 WORD 0 表示停止拍摄;0xFFFF 表示录像;其它表示拍 照张数 3 拍照间隔/录像时间 WORD 秒,0 表示按最小间隔拍照或一直录像 5 保存标志 BYTE 1:保存; 0:实时上传 6 分辨率a BYTE 0x01:320*240; 0x02:640*480; 0x03:800*600; 0x04:1024*768; 0x05:176*144;[Qcif]; 0x06:352*288;[Cif]; 0x07:704*288;[HALF D1]; 0x08:704*576;[D1]; 7 图像/视频质量 BYTE 1-10,1 代表质量损失最小,10 表示压缩比最大 8 亮度 BYTE 0-255 9 对比度 BYTE 0-127 10 饱和度 BYTE 0-127 11 色度 BYTE 0-255 * * */ /// <summary> /// 中心抓拍图片 /// </summary> /// <param name="ordinal"></param> /// <param name="size"></param> /// <param name="quality"></param> /// <param name="count"></param> /// <returns></returns> public override byte[] Capture(uint ordinal, SizeType size, QualityType quality, byte count) { var mes = Message.Create(0x8801, this.terminalid + "", 0, null); var ms = new MemoryStream(); BitWriter bw = new BitWriter(ms); bw.Write((byte)1);//通道一 bw.Write((UInt16)count);//拍一张 bw.Write((UInt16)0);//拍照间隔 bw.Write((byte)0);//0实时上传 1保存 byte pixel = 0x01; switch (size) //分辨率 图片大小 { case SizeType.Big: pixel = 0x04; break; // case SizeType.Normal: pixel = 0x08; break; // case SizeType.Small: pixel = 0x01; break; // } bw.Write(pixel);//分辨率 byte level = 1; switch (quality) //图片质量 { case QualityType.Height: level = 1; break; case QualityType.Normal: level = 5; break; case QualityType.Low: level = 10; break; } bw.Write(level);//图片质量 bw.Write((byte)127);//亮度 bw.Write((byte)64);//对比度 bw.Write((byte)64);//饱和度 bw.Write((byte)127);//色度 mes.BodyBytes = ms.ToArray(); return mes.ToBytes(); }
public void SplitFileBySizeOfFiles( string inputFile, int chunkSize, SizeType sizeType = SizeType.Bytes) { int fileSize = (sizeType == SizeType.Bytes ? chunkSize : GetFileSize(chunkSize, sizeType)); using (var fileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read)) { int i = 0; while (fileStream.Position < fileStream.Length) { using (var outputFile = new FileStream(PreparePathFileName(inputFile, i), FileMode.Create, FileAccess.Write)) { int remaining = fileSize, bytesRead; byte[] buffer = new byte[fileSize]; while (remaining > 0 && (bytesRead = fileStream.Read(buffer, 0, Math.Min(remaining, fileSize))) > 0) { outputFile.Write(buffer, 0, bytesRead); remaining -= bytesRead; } i++; } } } }
public TextLayer(Image image, double x, double y, string text, int border, bool antialias, double size, SizeType sizeType, string fontname) : base(gimp_text_fontname(image.ID, -1, x, y, text, border, antialias, size, sizeType, fontname)) { }
public RowStyle (SizeType sizeType, float height) { if (height < 0) throw new ArgumentOutOfRangeException("height"); base.SizeType = sizeType; this.height = height; }
public ColumnStyle (SizeType sizeType, float width) { if (width < 0) throw new ArgumentOutOfRangeException ("height"); base.SizeType = sizeType; this.width = width; }
public void DeleteFile(AttachmentBE attachment, SizeType size) { if (!attachment.IsHeadRevision()) { throw new DreamInternalErrorException(DekiResources.CAN_ONLY_DELETE_HEAD_REVISION); } for (int i = 1; i <= attachment.Content.Revision; i++) { string filename = FilePath(attachment, size); try { File.Delete(filename); } catch { } } }
public void DeleteFile(ResourceBE attachment, SizeType size) { if (!attachment.IsHeadRevision()) { throw new StorageNonHeadRevisionDeleteFatalException(); } for (int i = 1; i <= attachment.Content.Revision; i++) { string filename = FilePath(attachment, size); try { File.Delete(filename); } catch { } } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override bool ShouldUpdateMesh() { bool shouldUpdate = ( base.ShouldUpdateMesh() || InnerSizeType != vPrevInnerType ); vPrevInnerType = InnerSizeType; return shouldUpdate; }
/// <summary> /// Creates an offscreen texture with the specified size which /// can be used for render to texture. /// </summary> public RenderToTexture(SizeType setSizeType) { sizeType = setSizeType; CalcSize(); texFilename = "RenderToTexture instance " + RenderToTextureGlobalInstanceId++; Create(); BaseGame.AddRemRenderToTexture(this); }
public PowerDoritoPickup(ContentManager Content, GameUnit centerX, GameUnit centerY, SizeType size) : base(CollisionType.BouncingCollision) { kinematicsX = new Kinematics(centerX - Units.HalfTile, (Game1.Random.Next(0, 11) - 5) * 0.025f); kinematicsY = new Kinematics(centerY - Units.HalfTile, (Game1.Random.Next(0, 11) - 5) * 0.025f); sprite = new AnimatedSprite(Content, SpriteName, Units.TileToPixel(SourceX), Units.TileToPixel(SourceYs[(int)size]), Units.TileToPixel(SourceWidth), Units.TileToPixel(SourceHeight), Fps, NumFrames); this.size = size; timer = new Timer(LifeTime, true); }
/*--------------------------------------------------------------------------------------------*/ protected float GetDimensionProgress(SizeType pType) { HoverIndicator ind = GetComponent<HoverIndicator>(); switch ( pType ) { case SizeType.Min: return 0; case SizeType.Selection: return ind.SelectionProgress; case SizeType.Highlight: return ind.HighlightProgress; case SizeType.Max: return 1; } throw new Exception("Unexpected type: "+pType); }
//--- Methods --- public StreamInfo GetFile(ResourceBE attachment, SizeType size, bool allowFileLink) { MimeType mime; switch (size) { case SizeType.THUMB: case SizeType.WEBVIEW: mime = AttachmentPreviewBL.ResolvePreviewMime(attachment.MimeType); break; default: mime = attachment.MimeType; break; } return GetFileInternal(FilePath(attachment, size), mime); }
/** * Copy constructor */ public Box(Box b) { this.marginTop = b.marginTop; this.marginTypeTop = b.marginTypeTop; this.marginRight = b.marginRight; this.marginTypeRight = b.marginTypeRight; this.marginLeft = b.marginLeft; this.marginTypeLeft = b.marginTypeLeft; this.marginBottom = b.marginBottom; this.marginTypeBottom = b.marginTypeBottom; this.width = b.width; this.height = b.height; this.widthType = b.widthType; this.heightType = b.heightType; }
private int GetFileSize( int chunkSize, SizeType sizeType) { switch (sizeType) { case SizeType.KBytes: return chunkSize * 1024; case SizeType.MBytes: return chunkSize * 1024 * 1024; case SizeType.GBytes: return chunkSize * 1024 * 1024 * 1024; default: return chunkSize; } }
public static float BytesToLargest( int bytes, out SizeType type ) { if ( ( bytes / Size_MB ) > 1 ) { type = SizeType.MB; return (float)Math.Round( bytes / Size_MB, 2 ); } if ( ( bytes / Size_KB ) > 1 ) { type = SizeType.KB; return (float)Math.Round( bytes / Size_KB, 2 ); } type = SizeType.Bytes; return ( float )Math.Round( ( double )bytes, 2 ); }
public static RedirectResult Redirect(this ImgAzyobuziContext context, string uri, SizeType size) { foreach (var r in context.Resolvers) { var match = r.Pattern.Match(uri); if (match.Success) { var images = r.GetImages(context, match); string location; if (size == SizeType.Video) { var v = images.FirstOrDefault(i => i.Video != null); if (v == null) throw new ImgAzyobuziException(Errors.IsNotVideo); location = v.Video; } else { var i = images.First(); switch (size) { case SizeType.Full: location = i.Full; break; case SizeType.Large: location = i.Large; break; case SizeType.Thumb: location = i.Thumb; break; default: throw new ArgumentException(); } } return new RedirectResult(location, r.ServiceId, r.GetId(match)); } } throw new ImgAzyobuziException(Errors.UriNotSupported); }
// Constructors public RowStyle(SizeType sizeType, float height) { }
/** * Set the width of the box */ public Box SetWidth(float width) { this.width = width; this.widthType = SizeType.PERCENTAGE; return this; }
private void Start() { _asteroidSize = GetComponent <AsteroidSettingsComponent>().Size; }
public void TableLayoutStyle_ConverterConvertTo_InvalidSizeType_ThrowsNotSupportedException(SizeType sizeType) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(TableLayoutStyle)); Assert.Throws <NotSupportedException>(() => converter.ConvertTo(new SubTableLayoutStyle { SizeType = sizeType }, typeof(InstanceDescriptor))); }
public void TableLayoutStyle_SizeType_SetWithOwnerWithHandle_GetReturnsExpected(SizeType value, int expectedLayoutCallCount) { using var control = new TableLayoutPanel(); var style = new ColumnStyle(); control.LayoutSettings.RowStyles.Add(style); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; int layoutCallCount = 0; control.Layout += (sender, e) => { Assert.Same(control, sender); Assert.Same(control, e.AffectedControl); Assert.Equal("Style", e.AffectedProperty); layoutCallCount++; }; style.SizeType = value; Assert.Equal(value, style.SizeType); Assert.Equal(expectedLayoutCallCount, layoutCallCount); Assert.True(control.IsHandleCreated); Assert.Equal(expectedLayoutCallCount * 2, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); // Set same. style.SizeType = value; Assert.Equal(value, style.SizeType); Assert.Equal(expectedLayoutCallCount, layoutCallCount); Assert.True(control.IsHandleCreated); Assert.Equal(expectedLayoutCallCount * 2, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public FixedColumnHeader(string colName, string headerText, int width, SizeType sizeMode) : this(width, sizeMode) { this.Name = colName; this.Text = headerText; }
public Weapon(string name, WeaponBaseType weaponBaseType, WeaponSubType weaponSubType, WeaponProficiencyType weaponProficiencyType, WeaponEffortType weaponEffortType, int[] mediumDamageRoll, WeaponAttackType weaponAttackType, int criticalMinRoll, int criticalMultiplier, WeaponDamageType[] weaponDamageTypes, int range, SizeType sizeType, double cost, double weight, string description) : base(name, cost, weight, description, slotType: SlotType.Weapon) { WeaponBaseType = weaponBaseType; WeaponSubType = weaponSubType; WeaponProficiencyType = weaponProficiencyType; WeaponEffortType = weaponEffortType; MediumDamageRoll = mediumDamageRoll; WeaponAttackType = weaponAttackType; CriticalMinRoll = criticalMinRoll; CriticalMultiplier = criticalMultiplier; WeaponDamageTypes = weaponDamageTypes; Range = range; SetSize(sizeType); // standard attack CombatActions.Add(CombatAction.CreateWeaponAttack(null, this, false)); // full attack CombatActions.Add(CombatAction.CreateWeaponAttack(null, this, true)); }
/// <include file='doc\TableLayoutSettings.uex' path='docs/doc[@for="ColumnStyle.ColumnStyle2"]/*' /> public ColumnStyle(SizeType sizeType, float width) { this.SizeType = sizeType; this.Width = width; }
/// <include file='doc\TableLayoutSettings.uex' path='docs/doc[@for="RowStyle.RowStyle1"]/*' /> public RowStyle(SizeType sizeType) { this.SizeType = sizeType; }
//--- Class Methods --- public static StreamInfo RetrievePreview(ResourceBE attachment, uint height, uint width, RatioType ratio, SizeType size, FormatType format) { string filename; return(RetrievePreview(attachment, height, width, ratio, size, format, out filename)); }
/// <include file='doc\TableLayoutSettings.uex' path='docs/doc[@for="ColumnStyle.ColumnStyle1"]/*' /> public ColumnStyle(SizeType sizeType) { this.SizeType = sizeType; }
public object[] ToOutput() { object[] data = new object[18]; data[0] = Articul; data[1] = Category; data[2] = Name; data[3] = Color; data[4] = SizeType.ToString(); int i = 5; if (SizeType == Globals.RabSizeTypes.Regular) { for (int j = 0; j < ListOfSKU.Count; i++, j++) { if (ListOfSKU[j].Quantity > 0) { data[i] = ListOfSKU[j].Quantity; } else { data[i] = ""; } } data[i++] = ""; data[i++] = ""; data[i++] = ""; } if (SizeType == Globals.RabSizeTypes.One) { for (int j = 0; j < ListOfSKU.Count; i++, j++) { data[i] = ""; } if (ListOfSKU[0].Quantity > 0) { data[i++] = ListOfSKU[0].Quantity; } else { data[i++] = ""; } data[i++] = ""; data[i++] = ""; } if (SizeType == Globals.RabSizeTypes.LeftRight) { for (int j = 0; j < ListOfSKU.Count + 1; i++, j++) { data[i] = ""; } if (ListOfSKU[0].Quantity > 0) { data[i++] = ListOfSKU[0].Quantity; } else { data[i++] = ""; } if (ListOfSKU[1].Quantity > 0) { data[i++] = ListOfSKU[1].Quantity; } else { data[i++] = ""; } } data[i++] = Sum(); data[i++] = Price; data[i++] = ExPrice; data[i++] = Sum() * Price; return(data); }
public SendSizeAttribute(SizeType sizeType) : this(sizeType, 0) { }
public void SetSize(SizeType sizeType) { DamageRoll = sizeType == SizeType.Medium ? MediumDamageRoll : WeaponDamageSizeConversion(sizeType, MediumDamageRoll); SizeType = sizeType; }
/// <summary> /// Create render to texture, using no HDR here. /// </summary> /// <param name="setSizeType">Set size type</param> public RenderToTexture(SizeType setSizeType) : this(setSizeType, false) { }
/// <include file='doc\TableLayoutSettings.uex' path='docs/doc[@for="RowStyle.RowStyle2"]/*' /> public RowStyle(SizeType sizeType, float height) { this.SizeType = sizeType; this.Height = height; }
public FixedColumnHeader Add(string key, string text, int width, SizeType sizeMode, HorizontalAlignment align) { FixedColumnHeader ch = new FixedColumnHeader(); ch.Text = text; ch.Width = width; ch.SizeType = sizeMode; ch.TextAlign = align; Add(ch); return ch; }
public override bool Equals(object obj) { SizeType otherObj = (SizeType)obj; return(otherObj.InternalValue.Equals(this.InternalValue)); }
public SizeDomain(SizeType sizeType, string name) : base(sizeType, name) { }
public LengthedSocket(SizeType sizeHeaderLen, Boolean countSize = true) : this(new Socket(SocketType.Stream, ProtocolType.Tcp), sizeHeaderLen, countSize) { }
public SizeEntity(SizeType sizeType, string name) : this(sizeType, name, null) { }
protected abstract String GetBGPath(SizeType type);
static public string ToString(SizeType item) { return(item.GetDefinitionString()); }
public void DeleteFile(ResourceBE attachment, SizeType size) { CheckDisposed(); DeleteFileInternal(BuildS3Filename(attachment, size)); }
public void SetSize(SizeType size) { this.Size = size; }
public SizeEntity(SizeType sizeType, string name, IEnumerable <SizeGroupCompositeEntity>?sizeGroupComposites) : base(sizeType, name) { Id = GetIdHashCode(sizeType, name); SizeGroupComposites = sizeGroupComposites?.ToList(); }
public Box SetWidth(string pixels) { float width = 0; string[] widthPx = Regex.Split(pixels, @"\D+"); if (widthPx.Length > 0) { float.TryParse(widthPx[0], out width); this.widthType = SizeType.PIXEL; this.width = width; } return this; }
//--------------------------------------------------------------------- //-----Edited by BRM----- //-----To pass fireSizeType public static List <Site> SizeFireCostSurface(Event fireEvent, SizeType fireSizeType, bool buildUp) //---------- { Site initiationSite = PlugIn.ModelCore.Landscape.GetSite(fireEvent.StartLocation); if (!initiationSite.IsActive) { throw new ApplicationException("fire initiation site is not active."); } // Inflate the area or duration to give a cushion for determining optimal path: double AdjMaxFireParameter = fireEvent.MaxFireParameter * 2.0; List <Site> newFireList = new List <Site>(); SiteVars.TravelTime[initiationSite] = 0.0; SiteVars.MinNeighborTravelTime[initiationSite] = 0.0; SiteVars.Event[initiationSite] = fireEvent; //Assign data to the initiation site: double initiationTravelTime = CalculateTravelTime(initiationSite, initiationSite, fireEvent, buildUp); SiteVars.TravelTime[initiationSite] = initiationTravelTime; SiteVars.Event[initiationSite] = fireEvent; //Create a list of neighboring sites to which the fire will spread: List <WeightedSite> sitesToConsider = new List <WeightedSite>(0); sitesToConsider.Add(new WeightedSite(initiationSite, initiationTravelTime)); double totalArea = 0.0; double cellArea = (PlugIn.ModelCore.CellLength * PlugIn.ModelCore.CellLength) / 10000; //convert to ha double cnt = 1; double oldcnt = cnt; while (sitesToConsider.Count > 0) { // Sort, but not every time. Also, only sort if the fire is growing. if (oldcnt < cnt && (sitesToConsider.Count < 10 || (sitesToConsider.Count < 15 && cnt % 5 == 0) || (sitesToConsider.Count < 100 && cnt % 20 == 0) || cnt % 40 == 0)) { sitesToConsider.Sort(new WeightComparer()); } oldcnt = cnt; WeightedSite fastest = sitesToConsider[0]; sitesToConsider.Remove(fastest); Site srcSite = fastest.Site; if (!srcSite.IsActive) { throw new ApplicationException(" the selected source site is not active."); } newFireList.Add(srcSite); //Next, add site's neighbors to the list of //sites to consider. The neighbors cannot be part of //any other Fire event in the current timestep, and //cannot already be in the list. List <WeightedSite> destinations = Get8WeightedNeighbors(srcSite, fireEvent, buildUp); if (destinations.Count > 0) { foreach (WeightedSite weighted in destinations) { Site destSite = weighted.Site; int fuelIndex = (int)SiteVars.CFSFuelType[destSite]; if (Event.FuelTypeParms[fuelIndex].BaseFuel == BaseFuelType.Open && fireEvent.FireSeason.PercentCuring == 0) { continue; } if (sitesToConsider.Contains(weighted)) { continue; } else { //Complex Cost Surface (Scheller's algorithm) SiteVars.CostTime[destSite] = weighted.Weight; if (srcSite == initiationSite) // One of the 8 first neighbors { SiteVars.TravelTime[destSite] = (SiteVars.CostTime[destSite] * (CellDistanceBetweenSites(destSite, srcSite) / 2)) + SiteVars.TravelTime[srcSite]; } else { SiteVars.TravelTime[destSite] = (SiteVars.CostTime[destSite] / 2 + SiteVars.CostTime[srcSite] / 2) * CellDistanceBetweenSites(destSite, srcSite) + SiteVars.TravelTime[srcSite]; } SiteVars.MinNeighborTravelTime[destSite] = SiteVars.TravelTime[srcSite]; // Replace Ellipse business with a simple check for SIZE or DURATION if ((fireSizeType == SizeType.size_based && totalArea <= AdjMaxFireParameter) || (fireSizeType == SizeType.duration_based && SiteVars.TravelTime[destSite] <= AdjMaxFireParameter)) { //sitesToConsider.Enqueue(destSite); weighted.Weight = SiteVars.TravelTime[destSite]; sitesToConsider.Add(weighted); SiteVars.Event[destSite] = fireEvent; totalArea += cellArea; cnt++; } } } } } //Finally, check neighbor travel 2000 times to optimize the shortest travel //distance. bool finished = false; int count = 0; while (!finished) { count++; //PlugIn.ModelCore.UI.WriteLine(" Re-Calculating optimal travel time: {0} times.", count); finished = true; // Loop through list and check each for a new, shorter travel time. foreach (Site destSite in newFireList) //Fire destination { Site srcSite = CalculateMinNeighbor(destSite, fireEvent); // Where is the fire coming from? if (srcSite != null && destSite.IsActive && srcSite.IsActive) { double oldTravelTime = SiteVars.TravelTime[destSite]; double newCostTime = CalculateTravelTime(destSite, srcSite, fireEvent, buildUp); double newTravelTime = ((newCostTime / 2 + SiteVars.CostTime[srcSite] / 2) * CellDistanceBetweenSites(destSite, srcSite)) + SiteVars.TravelTime[srcSite]; if (newTravelTime < oldTravelTime) { SiteVars.CostTime[destSite] = newCostTime; SiteVars.TravelTime[destSite] = newTravelTime; //PlugIn.ModelCore.UI.WriteLine(" OldTT = {0:0.00}, NewTT = {1:0.00}, OldMinNeighborTT = {2:0.00}, MinNeighborTT = {3:0.00}.", //oldTravelTime, SiteVars.TravelTime[destSite], SiteVars.MinNeighborTravelTime[destSite] = SiteVars.TravelTime[srcSite]; if ((oldTravelTime - newTravelTime) > 0.5) { finished = false; } } } } if (count > 2000) { finished = true; } } return(newFireList); }
public RowStyle(SizeType sizeType) { }
private static bool ElipseDistanceBetweenSites(Site igSite, Site burnSite, double C, double A, double fireDirection, double ellipseArea, SizeType fireSizeType) { bool lessThan = false; //In the landscape, 'higher' rows have lower numbers, the inverse of what you //would expect if the ignition site is located at (0,0). double dYburn = ((double)igSite.Location.Row - (double)burnSite.Location.Row); double dXburn = ((double)burnSite.Location.Column - (double)igSite.Location.Column); C = C / (double)PlugIn.ModelCore.CellLength; A = A / (double)PlugIn.ModelCore.CellLength; double sumDist = (Math.Sqrt((A * A) + (C * C))) * 2; // Equals B * 2 (the length of the major axis) //Assume that ignition site (F0) is at location 0,0. double LengthA = Math.Sqrt((dXburn * dXburn) + (dYburn * dYburn)); //Where is second focal site? double dYf1 = C * 2 * Math.Cos((fireDirection) * Math.PI / 180); double dXf1 = C * 2 * Math.Sin((fireDirection) * Math.PI / 180); double dXburn_f1 = dXburn - dXf1; double dYburn_f1 = dYburn - dYf1; double LengthB = Math.Sqrt((dXburn_f1 * dXburn_f1) + (dYburn_f1 * dYburn_f1)); double radius = Math.Sqrt((ellipseArea / Math.PI)) / (double)PlugIn.ModelCore.CellLength; if (fireSizeType == SizeType.duration_based) { radius *= 1.0; // RMS: Was 1.5. Trying to limit the size of ellipses //sumDist *= 2; } else { //radius *= 1.5; sumDist *= 1.0; //5; } //if((LengthA + LengthB >= sumDist ) || (LengthA >= radius)) // lessThan = false; if ((LengthA + LengthB <= sumDist) || (LengthA <= radius)) { lessThan = true; } //PlugIn.ModelCore.UI.WriteLine("LengthA={0:0.0}, LengthB={1:0.0}, C={2:0.0}, D={3:0.0}.", LengthA, LengthB, C,D); //PlugIn.ModelCore.UI.WriteLine("dXf1={0:0.0}, dYf1={1:0.0}, dXburn={2:0.0}, dYburn={3:0.0}.", dXf1, dYf1,dXburn,dYburn); //return true; return(lessThan); }
/// <summary> /// Creates an offscreen texture with the specified size which /// can be used for render to texture. /// </summary> public RenderToTexture(SizeType setSizeType, bool setUseHdrRenderTarget) { sizeType = setSizeType; useHdrRenderTarget = setUseHdrRenderTarget; CalcSize(); texFilename = "RenderToTexture instance " + RenderToTextureGlobalInstanceId++; Create(); AddRemRenderToTexture(this); }
private void ParseStyles(TableLayoutSettings settings, XmlNodeList controlXmlFragments, bool columns) { foreach (XmlNode styleXmlNode in controlXmlFragments) { string styleString = GetAttributeValue(styleXmlNode, "Styles"); Type sizeTypeType = typeof(SizeType); // styleString will consist of N Column/Row styles serialized in the following format // (Percent | Absolute | AutoSize), (24 | 24.4 | 24,4) // Two examples: // Percent,23.3,Percent,46.7,Percent,30 // Percent,23,3,Percent,46,7,Percent,30 // Note we get either . or , based on the culture the TableLayoutSettings were serialized in if (!string.IsNullOrEmpty(styleString)) { int currentIndex = 0; int nextIndex; while (currentIndex < styleString.Length) { // ---- SizeType Parsing ----------------- nextIndex = currentIndex; while (Char.IsLetter(styleString[nextIndex])) { nextIndex++; } SizeType type = (SizeType)Enum.Parse(sizeTypeType, styleString.Substring(currentIndex, nextIndex - currentIndex), true); // ----- Float Parsing -------------- // Find the next Digit (start of the float) while (!char.IsDigit(styleString[nextIndex])) { nextIndex++; } // Append digits left of the decimal delimiter(s) StringBuilder floatStringBuilder = new StringBuilder(); while ((nextIndex < styleString.Length) && (char.IsDigit(styleString[nextIndex]))) { floatStringBuilder.Append(styleString[nextIndex]); nextIndex++; } // Append culture invariant delimiter floatStringBuilder.Append('.'); // Append digits right of the decimal delimiter(s) while ((nextIndex < styleString.Length) && (!char.IsLetter(styleString[nextIndex]))) { if (char.IsDigit(styleString[nextIndex])) { floatStringBuilder.Append(styleString[nextIndex]); } nextIndex++; } string floatString = floatStringBuilder.ToString(); float width; if (!float.TryParse(floatString, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out width)) { Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Failed to parse float for style: {0}", floatString)); width = 0F; } // Add new Column/Row Style if (columns) { settings.ColumnStyles.Add(new ColumnStyle(type, width)); } else { settings.RowStyles.Add(new RowStyle(type, width)); } // Go to the next Column/Row Style currentIndex = nextIndex; } } } }
public FixedColumnHeader Add(string key, string text, int width, SizeType sizeMode) { return Add(key, text, width, sizeMode, HorizontalAlignment.Left); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiRichView)); string defaultFont = file["Font"] as string; int defaultFontSize = DefinitionResolver.Get <int>(Controller, Binding, file["FontSize"], 0); int defaultFontSpacing = DefinitionResolver.Get <int>(Controller, Binding, file["FontSpacing"], int.MaxValue); for (int idx = 0; idx < (int)FontType.Count; ++idx) { FontType type = (FontType)idx; string font = string.Format("{0}.Font", type); string spacing = string.Format("{0}.FontSpacing", type); string resize = string.Format("{0}.FontResize", type); string fontName = file[font] as string; int fontSpacing = DefinitionResolver.Get <int>(Controller, Binding, file[spacing], defaultFontSpacing == int.MaxValue ? 0 : defaultFontSpacing); int fontResize = DefinitionResolver.Get <int>(Controller, Binding, file[resize], 0); if (fontName == null) { fontName = defaultFont; } FontFace fontObj = FontManager.Instance.FindFont(fontName); if (defaultFont == null) { defaultFont = fontName; } if (defaultFontSpacing == int.MaxValue) { defaultFontSpacing = fontSpacing; } _fonts[idx] = new FontInfo() { Font = fontObj, FontSpacing = (float)fontSpacing / 1000.0f, FontResize = fontResize }; } for (int idx = 0; idx < (int)SizeType.Count; ++idx) { SizeType type = (SizeType)idx; string size = string.Format("{0}.FontSize", type); int fontSize = DefinitionResolver.Get <int>(Controller, Binding, file[size], defaultFontSize); if (defaultFontSize == 0) { defaultFontSize = fontSize; } _sizes[idx] = fontSize; } _bulletText = DefinitionResolver.GetString(Controller, Binding, file["BulletText"]) ?? "* "; //_bulletText = _bulletText.Replace(" ", ((char)0xa0).ToString()); _horizontalRulerHeight = DefinitionResolver.Get <Length>(Controller, Binding, file["HorizontalRulerHeight"], new Length(0, 0, 1)); _indentSize = DefinitionResolver.Get <Length>(Controller, Binding, file["Indent"], Length.Zero); _paragraphSpacing = DefinitionResolver.Get <Length>(Controller, Binding, file["ParagraphSpacing"], Length.Zero); _imageNotLoaded = DefinitionResolver.Get <Texture2D>(Controller, Binding, file["ImageNotLoaded"], AdvancedDrawBatch.OnePixelWhiteTexture); _lineHeight = (float)DefinitionResolver.Get <int>(Controller, Binding, file["LineHeight"], 100) / 100.0f; _justify = DefinitionResolver.Get <bool>(Controller, Binding, file["Justify"], false); _linkResolver = DefinitionResolver.Get <ILinkResolver>(Controller, Binding, file["LinkResolver"], this); _baseLineCorrection = DefinitionResolver.Get <bool>(Controller, Binding, file["EnableBaseLineCorrection"], false); Type processorType = file["Processor"] as Type; if (processorType != null) { _richProcessor = Activator.CreateInstance(processorType) as IRichProcessor; } Text = DefinitionResolver.GetString(Controller, Binding, file["Text"]); _colorNormal = DefinitionResolver.GetColorWrapper(Controller, Binding, file["TextColor"]) ?? UiLabel.DefaultTextColor; _colorClickable = DefinitionResolver.GetColorWrapper(Controller, Binding, file["LinkColor"]) ?? UiLabel.DefaultTextColor; _colorClickableActive = DefinitionResolver.GetColorWrapper(Controller, Binding, file["ActiveLinkColor"]) ?? _colorClickable; _colorRuler = DefinitionResolver.GetColorWrapper(Controller, Binding, file["HorizontalRulerColor"]) ?? UiLabel.DefaultTextColor; HorizontalContentAlignment horzAlign = DefinitionResolver.Get <HorizontalContentAlignment>(Controller, Binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Left); VerticalContentAlignment vertAlign = DefinitionResolver.Get <VerticalContentAlignment>(Controller, Binding, file["VerticalContentAlignment"], VerticalContentAlignment.Top); _textAlign = UiHelper.TextAlignFromContentAlignment(horzAlign, vertAlign); _clickMargin = DefinitionResolver.Get <Length>(Controller, Binding, file["ClickMargin"], Length.Zero); RegisterDelegate("UrlClick", file["UrlClick"]); EnabledGestures = (GestureType.Down | GestureType.Up | GestureType.Move | GestureType.Tap); return(true); }
public FixedColumnHeader(int width, SizeType sizeMode) { this._type = sizeMode; this._size = width; }
public void EmployeesLoad_EmptyRows_Sizes_A2Case() { var navigation = Substitute.For <INavigationManager>(); var interactive = Substitute.For <IInteractiveMessage>(); var progressStep = Substitute.For <IProgressBarDisplayable>(); var progressInterceptor = Substitute.For <ProgressInterceptor>(); var dataParser = new DataParserEmployee(new PersonNames(), new SizeService(), new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated)); var setting = new SettingsMatchEmployeesViewModel(); var model = new ImportModelEmployee(dataParser, setting); using (var employeesLoad = new ExcelImportViewModel(model, UnitOfWorkFactory, navigation, interactive, progressInterceptor)) { var uow = employeesLoad.UoW; var heightType = new SizeType { Name = "РостТип", Position = 1, UseInEmployee = true, CategorySizeType = CategorySizeType.Height }; uow.Save(heightType); var sizeType = new SizeType { Name = "РазмерТип", Position = 2, CategorySizeType = CategorySizeType.Size, UseInEmployee = true }; uow.Save(sizeType); var shoesType = new SizeType { Name = "ОбувьТип", Position = 3, CategorySizeType = CategorySizeType.Size, UseInEmployee = true }; uow.Save(shoesType); var height = new Size { Name = "170-176", SizeType = heightType, UseInEmployee = true }; uow.Save(height); var size = new Size { Name = "48-50", SizeType = sizeType, UseInEmployee = true }; uow.Save(size); var shoes = new Size { Name = "38", SizeType = shoesType, UseInEmployee = true }; uow.Save(shoes); uow.Commit(); employeesLoad.ProgressStep = progressStep; employeesLoad.FileName = "Samples/Excel/empty_first_row_a2.xls"; Assert.That(employeesLoad.Sheets.Count, Is.GreaterThan(0)); employeesLoad.SelectedSheet = employeesLoad.Sheets.First(); Assert.That(employeesLoad.SensitiveSecondStepButton, Is.True, "Кнопка второго шага должна быть доступна"); employeesLoad.SecondStep(); Assert.That(employeesLoad.SensitiveThirdStepButton, Is.True, "Кнопка третьего шага должна быть доступна"); employeesLoad.ThirdStep(); Assert.That(employeesLoad.SensitiveSaveButton, Is.True, "Кнопка сохранить должна быть доступна"); employeesLoad.Save(); uow.Commit(); var employees = uow.GetAll <EmployeeCard>().ToList(); Assert.That(employees.Count, Is.EqualTo(5)); var nikolay = employees.First(x => x.FirstName == "Николай"); Assert.That(nikolay.Sizes.FirstOrDefault(x => x.SizeType == heightType)?.Size?.Id, Is.EqualTo(height.Id)); Assert.That(nikolay.Sizes.FirstOrDefault(x => x.SizeType == sizeType)?.Size?.Id, Is.EqualTo(size.Id)); Assert.That(nikolay.Sizes.FirstOrDefault(x => x.SizeType == shoesType)?.Size?.Id, Is.EqualTo(shoes.Id)); //Проверяем что должности не задублировались var posts = uow.GetAll <Post>(); Assert.That(posts.Count, Is.EqualTo(3)); } }
public RowStyle (SizeType sizeType) { this.height = 0; base.SizeType = sizeType; }
public ColumnStyle(SizeType sizeType) { SizeType = sizeType; }
private LengthedSocket(Socket s, SizeType sizeHeaderLen, Boolean countSize = true) { _socket = s; _sizeHeaderLen = sizeHeaderLen; _countSize = countSize; }
public static StreamInfo RetrievePreview(ResourceBE attachment, uint height, uint width, RatioType ratio, SizeType size, FormatType format, out string filename) { if (!AttachmentBL.Instance.IsAllowedForImageMagickPreview(attachment)) { throw new AttachmentPreviewFailedWithMimeTypeNotImplementedException(attachment.MimeType); } if (format != FormatType.UNDEFINED && size != SizeType.UNDEFINED && size != SizeType.ORIGINAL && size != SizeType.CUSTOM) { throw new AttachmentPreviewFormatConversionWithSizeNotImplementedException(); } // check that attachment has a width and height defined AttachmentBL.Instance.IdentifyUnknownImages(new ResourceBE[] { attachment }); #region check validity of size, width, and height parameters // NOTE (steveb): following table describes the possible state-transitions; note that the resulting graph must acyclic to avoid infinite loops. // BESTFIT // -> THUMB // -> WEBVIEW // -> ORIGINAL // UNDEFINED // -> CUSTOM // -> ORIGINAL // THUMB // -> ORIGINAL // WEBVIEW // -> ORIGINAL // CUSTOM // -> ORIGINAL // ORIGINAL again: switch (size) { case SizeType.BESTFIT: if (width == 0 && height == 0) { // no dimensions specified, use original size = SizeType.ORIGINAL; goto again; } if (width <= DekiContext.Current.Instance.ImageThumbPixels && height <= DekiContext.Current.Instance.ImageThumbPixels) { // thumbnail is big enough size = SizeType.THUMB; goto again; } else if (width <= DekiContext.Current.Instance.ImageWebviewPixels && height <= DekiContext.Current.Instance.ImageWebviewPixels) { // webview is big enough size = SizeType.WEBVIEW; goto again; } else { // use original size = SizeType.ORIGINAL; goto again; } case SizeType.CUSTOM: if (height == 0 && width == 0) { // no dimensions specified, use original size = SizeType.ORIGINAL; goto again; } if ((attachment.MetaXml.ImageWidth <= width && attachment.MetaXml.ImageHeight <= height) && (attachment.MetaXml.ImageWidth >= 0 && attachment.MetaXml.ImageHeight >= 0)) { // requested dimensions are larger than original, use original (we don't scale up!) size = SizeType.ORIGINAL; goto again; } break; case SizeType.ORIGINAL: width = 0; height = 0; break; case SizeType.UNDEFINED: if (height != 0 || width != 0) { size = SizeType.CUSTOM; goto again; } else { size = SizeType.ORIGINAL; goto again; } case SizeType.THUMB: width = DekiContext.Current.Instance.ImageThumbPixels; height = DekiContext.Current.Instance.ImageThumbPixels; if ((attachment.MetaXml.ImageWidth <= width && attachment.MetaXml.ImageHeight <= height) && (attachment.MetaXml.ImageWidth >= 0 && attachment.MetaXml.ImageHeight >= 0)) { size = SizeType.ORIGINAL; goto again; } break; case SizeType.WEBVIEW: width = DekiContext.Current.Instance.ImageWebviewPixels; height = DekiContext.Current.Instance.ImageWebviewPixels; if ((attachment.MetaXml.ImageWidth <= width && attachment.MetaXml.ImageHeight <= height) && (attachment.MetaXml.ImageWidth >= 0 && attachment.MetaXml.ImageHeight >= 0)) { size = SizeType.ORIGINAL; goto again; } break; } #endregion // Asking to convert to the same format as original if (format != FormatType.UNDEFINED && format == ResolvePreviewFormat(attachment.MimeType)) { format = FormatType.UNDEFINED; } //Determine if the result is capable of being cached bool cachable = ( format == FormatType.UNDEFINED && //No format conversion ratio != RatioType.VARIABLE && //must be a fixed aspect ratio or not provided (size == SizeType.THUMB || size == SizeType.WEBVIEW) //must be one of the known cached thumb sizes. ); // load image StreamInfo result = null; try { if (size == SizeType.ORIGINAL && format == FormatType.UNDEFINED) { result = DekiContext.Current.Instance.Storage.GetFile(attachment, SizeType.ORIGINAL, false); } else { bool cached = false; //The type of image is based on uploaded file's mimetype if (format == FormatType.UNDEFINED) { format = ResolvePreviewFormat(attachment.MimeType); } // check if image can be taken from the cache if (cachable) { result = GetCachedThumb(attachment, size); cached = (result != null); } // load image if we haven't yet if (result == null) { result = DekiContext.Current.Instance.Storage.GetFile(attachment, SizeType.ORIGINAL, false); if (result != null) { result = BuildThumb(attachment, result, format, ratio, width, height); } } // store result if possible and needed if (cachable && !cached && (result != null)) { SaveCachedThumb(attachment, size, result); result = GetCachedThumb(attachment, size); } } if (result == null) { ThrowOnBadPreviewImage(); } // full filename for response content-disposition header switch (size) { case SizeType.CUSTOM: filename = string.Format("{0}_({1}x{2}){3}", attachment.Name, width == 0 ? "" : width.ToString(), height == 0 ? "" : height.ToString(), attachment.FilenameExtension == string.Empty ? string.Empty : "." + attachment.FilenameExtension); break; case SizeType.ORIGINAL: filename = attachment.Name; break; case SizeType.BESTFIT: case SizeType.THUMB: case SizeType.UNDEFINED: case SizeType.WEBVIEW: default: filename = string.Format("{0}_({1}){2}", attachment.Name, size.ToString().ToLowerInvariant(), attachment.FilenameExtension == string.Empty ? string.Empty : "." + attachment.FilenameExtension); break; } if (format != FormatType.UNDEFINED) { filename = Path.ChangeExtension(filename, format.ToString().ToLowerInvariant()); } return(result); } catch { if (result != null) { result.Close(); } throw; } }
public void PutFile(ResourceBE attachment, SizeType size, StreamInfo file) { CheckDisposed(); PutFileInternal(BuildS3Filename(attachment, size), attachment.Name, file); }
public SizeInfo(long size, SizeType type) { Size = size; Type = type; }
private string BuildS3Filename(ResourceBE attachment, SizeType size) { // Legacy pre-Lyons S3 paths are based on fileid. If the fileid is present in the resource then use it otherwise base on resourceid. var id = (attachment.MetaXml.FileId == null) ? string.Format("r{0}", attachment.ResourceId) : attachment.MetaXml.FileId.ToString(); switch(size) { case SizeType.THUMB: case SizeType.WEBVIEW: return string.Format("{0}/{1}/{2}/{3}", _prefix, id, attachment.Content.Revision - 1, size.ToString().ToLowerInvariant()); default: return string.Format("{0}/{1}/{2}", _prefix, id, attachment.Content.Revision - 1); } }
} // RenderToTexture(setSizeType, setUseHdrRenderTarget) /// <summary> /// Create render to texture, using no HDR here. /// </summary> /// <param name="setSizeType">Set size type</param> public RenderToTexture(SizeType setSizeType) : this(setSizeType, false) { } // RenderToTexture(setSizeType)