/// <summary> /// Edit Function /// </summary> public void EditFunction() { try { SizeSP spSize = new SizeSP(); SizeInfo infoSize = new SizeInfo(); infoSize.Size = txtSize.Text.Trim(); infoSize.Narration = txtNarration.Text.Trim(); infoSize.Extra1 = String.Empty; infoSize.Extra2 = String.Empty; infoSize.SizeId = decSizeId; if (spSize.SizeNameCheckExistence(txtSize.Text.Trim().ToString(), decSizeId) == false) { if (spSize.SizeEditing(infoSize)) { Messages.UpdatedMessage(); GridFill(); Clear(); } } else { Messages.InformationMessage("Size already exist"); txtSize.Focus(); } } catch (Exception ex) { MessageBox.Show("SZ3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Update values in Size Table and return the status /// </summary> /// <param name="infoSize"></param> /// <returns></returns> public bool SizeEditing(SizeInfo infoSize) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("SizeEditing", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@sizeId", SqlDbType.Decimal).Value = infoSize.SizeId; sqlcmd.Parameters.Add("@size", SqlDbType.VarChar).Value = infoSize.Size; sqlcmd.Parameters.Add("@narration", SqlDbType.VarChar).Value = infoSize.Narration; int ineffectedrow = sqlcmd.ExecuteNonQuery(); if (ineffectedrow > 0) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isEdit); }
/// <summary> /// Grid cell double click for update or delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSize_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { if (dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value != null && dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value.ToString() != string.Empty) { decSizeId = Convert.ToDecimal(dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value.ToString()); if (decSizeId != 1) { SizeSP spSize = new SizeSP(); SizeInfo infoSize = new SizeInfo(); infoSize = spSize.SizeViewing(decSizeId); txtSize.Text = infoSize.Size; txtNarration.Text = infoSize.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; txtSize.Focus(); } else { Messages.InformationMessage(" NA Size canot update or delete"); Clear(); } } } } catch (Exception ex) { MessageBox.Show("SZ12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { SizeSP spSize = new SizeSP(); SizeInfo infoSize = new SizeInfo(); infoSize.Size = txtSize.Text.Trim(); infoSize.Narration = txtNarration.Text.Trim(); infoSize.Extra1 = String.Empty; infoSize.Extra2 = String.Empty; if (spSize.SizeNameCheckExistence(txtSize.Text.Trim().ToString(), 0) == false) { decIdentity = spSize.SizeAdding(infoSize); if (decIdentity > 0) { Messages.SavedMessage(); GridFill(); Clear(); } } else { Messages.InformationMessage(" Size already exist"); txtSize.Focus(); } } catch (Exception ex) { MessageBox.Show("SZ2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to Size Table and return the Curresponding row's Id /// </summary> /// <param name="infoSize"></param> /// <returns></returns> public decimal SizeAdding(SizeInfo infoSize) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("SizeAdding", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@size", SqlDbType.VarChar).Value = infoSize.Size; sqlcmd.Parameters.Add("@narration", SqlDbType.VarChar).Value = infoSize.Narration; sqlcmd.Parameters.Add("@extra1", SqlDbType.VarChar).Value = infoSize.Extra1; sqlcmd.Parameters.Add("@extra2", SqlDbType.VarChar).Value = infoSize.Extra2; decimal deceffectedrow = Convert.ToDecimal(sqlcmd.ExecuteScalar()); if (deceffectedrow > 0) { return(deceffectedrow); } else { return(0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(0); } finally { sqlcon.Close(); } }
/// <summary> /// Checks if it is possible to hide the information inside the image. /// </summary> /// <param name="imageBitSize">The size of the image that everyone will see, in bits.</param> /// <param name="messageBitSize">The size of the message that will be hidden, in bits.</param> /// <param name="sizeInfo">How much of the image will take to hold the message size information.</param> public static void CheckMinimumSize(int imageBitSize, int messageBitSize, SizeInfo sizeInfo, bool skipAlpha) { int minimumImageSize; if (skipAlpha) { minimumImageSize = ((imageBitSize / 4) * 3) - (int)sizeInfo; } else { minimumImageSize = imageBitSize - (int)sizeInfo; } if (minimumImageSize <= 0) { //The image isn't big enough to hold the size information. throw new Exception("The image is too small to hold the message size for decryption."); } if (messageBitSize / 2 > minimumImageSize / 8) { //The message is bigger than the image size. throw new Exception("The message is bigger than the image."); } }
/* Nightmarish implementation to be redone when Vendor ID is really useful * private static String findVendorID(byte[] Data, int Size) * { * String VendorID; * String result = ""; * * // Search for vendor ID * if ( (Data.Length - Size - 8) < 0 ) Size = Data.Length - 8; * for (int i=0; i <= Size; i++) * { * VendorID = Utils.Latin1Encoding.GetString(Data, Data.Length - i - 8, 4); * if (VENDOR_ID_LAME == VendorID) * { * result = VendorID + Utils.Latin1Encoding.GetString(Data, Data.Length - i - 4, 4); * break; * } * else if (VENDOR_ID_GOGO_NEW == VendorID) * { * result = VendorID; * break; * } * } * return result; * } */ /* Unused for now * * private String getVersion() * { * // Get MPEG version name * return MPEG_VERSION[HeaderFrame.VersionID]; * } * * private String getLayer() * { * // Get MPEG layer name * return MPEG_LAYER[HeaderFrame.LayerID]; * } * * private String getChannelMode() * { * // Get channel mode name * return MPEG_CM_MODE[HeaderFrame.ModeID]; * } * * private String getEmphasis() * { * // Get emphasis name * return MPEG_EMPHASIS[HeaderFrame.EmphasisID]; * } * * private long getFrames() * { * // Get total number of frames, calculate if VBR header not found * if (vbrData.Found) return vbrData.Frames; * else * { * long MPEGSize = sizeInfo.FileSize - sizeInfo.ID3v2Size - sizeInfo.ID3v1Size - sizeInfo.APESize; * * return (long)Math.Floor(1.0*(MPEGSize - HeaderFrame.Position) / getFrameSize(HeaderFrame)); * } * } * * private byte getVBREncoderID() * { * // Guess VBR encoder and get ID * byte result = 0; * * if (VENDOR_ID_LAME == vbrData.VendorID.Substring(0, 4)) * result = MPEG_ENCODER_LAME; * if (VENDOR_ID_GOGO_NEW == vbrData.VendorID.Substring(0, 4)) * result = MPEG_ENCODER_GOGO; * if (VENDOR_ID_GOGO_OLD == vbrData.VendorID.Substring(0, 4)) * result = MPEG_ENCODER_GOGO; * if ( StreamUtils.StringEqualsArr(VBR_ID_XING,vbrData.ID) && * (vbrData.VendorID.Substring(0, 4) != VENDOR_ID_LAME) && * (vbrData.VendorID.Substring(0, 4) != VENDOR_ID_GOGO_NEW) && * (vbrData.VendorID.Substring(0, 4) != VENDOR_ID_GOGO_OLD) ) * result = MPEG_ENCODER_XING; * if ( StreamUtils.StringEqualsArr(VBR_ID_FHG,vbrData.ID)) * result = MPEG_ENCODER_FHG; * * return result; * } * * private byte getCBREncoderID() * { * // Guess CBR encoder and get ID * byte result = MPEG_ENCODER_FHG; * * if ( (HeaderFrame.OriginalBit) && * (HeaderFrame.ProtectionBit) ) * result = MPEG_ENCODER_LAME; * if ( (getBitRate(HeaderFrame) <= 160) && * (MPEG_CM_STEREO == HeaderFrame.ModeID)) * result = MPEG_ENCODER_BLADE; * if ((HeaderFrame.CopyrightBit) && * (HeaderFrame.OriginalBit) && * (! HeaderFrame.ProtectionBit) ) * result = MPEG_ENCODER_XING; * if ((HeaderFrame.Xing) && * (HeaderFrame.OriginalBit) ) * result = MPEG_ENCODER_XING; * if (MPEG_LAYER_II == HeaderFrame.LayerID) * result = MPEG_ENCODER_QDESIGN; * if ((MPEG_CM_DUAL_CHANNEL == HeaderFrame.ModeID) && * (HeaderFrame.ProtectionBit) ) * result = MPEG_ENCODER_SHINE; * if (VENDOR_ID_LAME == vendorID.Substring(0, 4)) * result = MPEG_ENCODER_LAME; * if (VENDOR_ID_GOGO_NEW == vendorID.Substring(0, 4)) * result = MPEG_ENCODER_GOGO; * * return result; * } * * private byte getEncoderID() * { * // Get guessed encoder ID * if (HeaderFrame.Found) * if (vbrData.Found) return getVBREncoderID(); * else return getCBREncoderID(); * else * return 0; * } * * private String getEncoder() * { * String VendorID = ""; * String result; * * // Get guessed encoder name and encoder version for LAME * result = MPEG_ENCODER[getEncoderID()]; * if (vbrData.VendorID != "") VendorID = vbrData.VendorID; * if (vendorID != "") VendorID = vendorID; * if ( (MPEG_ENCODER_LAME == getEncoderID()) && * (VendorID.Length >= 8) && * Char.IsDigit(VendorID[4]) && * (VendorID[5] == '.') && * (Char.IsDigit(VendorID[6]) && * Char.IsDigit(VendorID[7]) )) * result = * result + (char)32 + * VendorID[4] + * VendorID[5] + * VendorID[6] + * VendorID[7]; * return result; * } * * private bool getValid() * { * // Check for right MPEG file data * return * ((HeaderFrame.Found) && * (getBitRate() >= MIN_MPEG_BIT_RATE) && * (getBitRate() <= MAX_MPEG_BIT_RATE) && * (getDuration() >= MIN_ALLOWED_DURATION)); * }*/ public bool Read(BinaryReader source, SizeInfo sizeInfo, MetaDataIO.ReadTagParams readTagParams) { this.sizeInfo = sizeInfo; resetData(); bool result = false; BufferedBinaryReader reader = new BufferedBinaryReader(source.BaseStream); reader.Seek(sizeInfo.ID3v2Size, SeekOrigin.Begin); HeaderFrame = findFrame(reader, ref vbrData, sizeInfo); // Search for vendor ID at the end if CBR encoded /* * This is a nightmarish implementation; to be redone when vendor ID is required by upper interfaces * * if ( (HeaderFrame.Found) && (! FVBR.Found) ) * { * fs.Seek(sizeInfo.FileSize - Data.Length - sizeInfo.ID3v1Size - sizeInfo.APESize, SeekOrigin.Begin); * fs.Read(Data, 0, Data.Length); * vendorID = findVendorID(Data, HeaderFrame.Size * 5); * } */ result = HeaderFrame.Found; if (!result) { resetData(); LogDelegator.GetLogDelegate()(Log.LV_ERROR, "Could not detect MPEG Audio header starting @ " + sizeInfo.ID3v2Size); } return(result); }
public void AddSize(DirData data) { UIHandler.Execute(new Action(() => { if (!data.Size.HasValue) { Header += " [size undefined]"; Background = UIHandler.PaleRed; return; } SizeInfo sizeInfo = data.Size.Value; Header += $" [{sizeInfo.ToString()}]"; if (data.FilesOnly) { Background = UIHandler.PaleGreen; } else if (sizeInfo.Size == 0) { Background = Brushes.LightGray; } else if (sizeInfo.Unit == SizeInfo.SizeUnit.MBYTE && sizeInfo.Size >= MinMByteSizeToMark) { Background = Brushes.LightBlue; } else if (sizeInfo.Unit == SizeInfo.SizeUnit.GBYTE) { Background = Brushes.Thistle; } })); }
protected void SaveData() { try { if (vID != null) { //Edit on the object. int Id; if (int.TryParse(vID.ToString(), out Id)) { SizeInfo obj = SizeManager.Select(Id); obj.Sizename = txtName.Text; obj.Status = int.Parse(txtOrder.Text); SizeManager.Update(obj); } } else { //this is a new object. SizeInfo obj = new SizeInfo(); obj.Sizename = txtName.Text; obj.Status = int.Parse(txtOrder.Text); SizeManager.Insert(obj); } lblMessage.Text = "Đã lưu dữ liệu thành công!"; EditPanel.Enabled = false; BindData(); vID = null; } catch (Exception ex) { lblMessage.Text = ex.Message; } }
public Inspector(ref T t, InspectorMode mode = InspectorMode.All) { _mode = mode; Metadata = new MetadataInfo(ref t); Addresses = new AddressInfo(ref t); Sizes = new SizeInfo(); }
/// <summary> /// Function to get values from Size Table based on the parameter /// </summary> /// <param name="decSizeId"></param> /// <returns></returns> public SizeInfo SizeViewing(decimal decSizeId) { SizeInfo infoSize = new SizeInfo(); SqlDataReader sqldr = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("SizeViewing", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@sizeId", SqlDbType.Decimal).Value = decSizeId; sqldr = sqlcmd.ExecuteReader(); while (sqldr.Read()) { infoSize.SizeId = decimal.Parse(sqldr["SizeId"].ToString()); infoSize.Size = sqldr["Size"].ToString(); infoSize.Narration = sqldr["Narration"].ToString(); infoSize.Extra1 = sqldr["Extra1"].ToString(); infoSize.Extra2 = sqldr["Extra2"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqldr.Close(); sqlcon.Close(); } return(infoSize); }
private void btnModify_Click(object sender, EventArgs e) { if (!InputValidate()) { return; } if (!HasUserNameValidator(this.txtBoxSize.Text, true)) { return; } string errText; var SizeInfo = new SizeInfo() { SizeId = _currentId, SizeName = this.txtBoxSize.Text, Remark = this.txtBoxRemark.Text }; var i = _SizeInfoService.UpdateEntity(out errText, SizeInfo); if (i == 0) { MessageBox.Show(errText); return; } MessageBox.Show("修改成功!"); ClearPage(); InitData(); }
protected override void BeforeShowContextMenu() { SizeInfo sizeinfo = FocusedNode[(int)eColumns.Size] as SizeInfo; bool fullScanEnabled = sizeinfo != null && sizeinfo.Type == SizeInfo.SizeType.Partial; FindContextMenuItem("fullScan").Enabled = fullScanEnabled; }
public Boolean Read(BinaryReader source, SizeInfo sizeInfo, MetaDataIO.ReadTagParams readTagParams) { var signatureChunk = new Char[4]; this.sizeInfo = sizeInfo; resetData(); source.BaseStream.Seek(sizeInfo.ID3v2Size, SeekOrigin.Begin); var result = false; if (TTA_SIGNATURE.Equals(Utils.Latin1Encoding.GetString(source.ReadBytes(4)))) { isValid = true; audioFormat = source.ReadUInt16(); channels = source.ReadUInt16(); bitsPerSample = source.ReadUInt16(); sampleRate = source.ReadUInt32(); samplesSize = source.ReadUInt32(); cRC32 = source.ReadUInt32(); bitrate = (Double)(sizeInfo.FileSize - sizeInfo.TotalTagSize) * 8.0 / ((Double)samplesSize * 1000.0 / sampleRate); duration = (Double)samplesSize * 1000.0 / sampleRate; result = true; } return(result); }
/// <summary> /// Constructs a new instance of the cached GPU texture. /// </summary> /// <param name="context">GPU context that the texture belongs to</param> /// <param name="info">Texture information</param> /// <param name="sizeInfo">Size information of the texture</param> public Texture(GpuContext context, TextureInfo info, SizeInfo sizeInfo) { InitializeTexture(context, info, sizeInfo); TextureCreateInfo createInfo = TextureManager.GetCreateInfo(info, context.Capabilities); HostTexture = _context.Renderer.CreateTexture(createInfo); }
private void EditData(int Id) { SizeInfo obj = SizeManager.Select((int)Id); txtName.Text = obj.Sizename; txtOrder.Text = obj.Status.ToString(); vID = obj.SizeID; EditPanel.Enabled = true; }
void OnFullScan(object sender, EventArgs e) { SizeInfo sizeinfo = FocusedNode[(int)eColumns.Size] as SizeInfo; if (sizeinfo != null && sizeinfo.Type == SizeInfo.SizeType.Partial) { DoScanHandler d = new DoScanHandler(DoScan); d.BeginInvoke(FocusedNode, long.MaxValue, null, null); } }
/// <summary> /// Sets the message inside the image. /// </summary> /// <param name="imageBits">The image bits where the message will be hidden.</param> /// <param name="messageBits">The message bits to hide.</param> /// <param name="sizeInfo">How many bits hold the message size information and will be skipped.</param> /// <param name="skipAlpha">Should the alpha channel remain untouched?.</param> /// <returns>An array of bytes that contains the image with the message inside</returns> public static byte[] SetMessage(BitArray imageBits, BitArray messageBits, SizeInfo sizeInfo, bool skipAlpha) { int offset = 0; int size = (int)sizeInfo; //For every byte in the image: for (int i = 0; i < imageBits.Count / 8; i++) { //Start to load message after the size information int indexImage = i * 8 + size; //If we hit the alpha channel we will decrease the indexMessage by 2 each time, //so we won't loose any bit of the message. int indexMessage = i * 2 - offset; if (indexMessage >= messageBits.Count) { //If the message is done we can proceed. break; } if (skipAlpha) { //Skip alpha bytes if ((indexImage + 8) % 32 == 0) { offset += 2; continue; } } //If the bit of the image is the same as the bit of the message, do nothing. if (imageBits[indexImage] != messageBits[indexMessage]) { imageBits[indexImage] = messageBits[indexMessage]; } if (imageBits[indexImage + 1] != messageBits[indexMessage + 1]) { imageBits[indexImage + 1] = messageBits[indexMessage + 1]; } } byte[] imageEncrypted = new byte[imageBits.Count / 8]; //Change back to an byte array. imageBits.CopyTo(imageEncrypted, 0); return(imageEncrypted); }
/// <summary> /// Constructs a new instance of the cached GPU texture. /// </summary> /// <param name="context">GPU context that the texture belongs to</param> /// <param name="info">Texture information</param> /// <param name="sizeInfo">Size information of the texture</param> /// <param name="firstLayer">The first layer of the texture, or 0 if the texture has no parent</param> /// <param name="firstLevel">The first mipmap level of the texture, or 0 if the texture has no parent</param> private Texture( GpuContext context, TextureInfo info, SizeInfo sizeInfo, int firstLayer, int firstLevel) { InitializeTexture(context, info, sizeInfo); _firstLayer = firstLayer; _firstLevel = firstLevel; _hasData = true; }
/// <summary> /// Function to Update values in Size Table and return the status /// </summary> /// <param name="infoSize"></param> /// <returns></returns> public bool SizeEditing(SizeInfo infoSize) { bool isEdit = false; try { isEdit = spSize.SizeEditing(infoSize); } catch (Exception ex) { MessageBox.Show("SZ4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(isEdit); }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { SizeBll BllSize = new SizeBll(); SizeInfo infoSize = new SizeInfo(); infoSize.Size = txtSize.Text.Trim(); infoSize.Narration = txtNarration.Text.Trim(); infoSize.Extra1 = String.Empty; infoSize.Extra2 = String.Empty; if (BllSize.SizeNameCheckExistence(txtSize.Text.Trim().ToString(), 0) == false) { decIdentity = BllSize.SizeAdding(infoSize); if (decIdentity>0) { Messages.SavedMessage(); GridFill(); Clear(); } } else { Messages.InformationMessage(" Size already exist"); txtSize.Focus(); } } catch (Exception ex) { MessageBox.Show("SZ2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid cell double click for update or delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSize_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { if (dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value != null && dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value.ToString()!=string.Empty) { decSizeId = Convert.ToDecimal(dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value.ToString()); if (decSizeId != 1) { SizeBll BllSize = new SizeBll(); SizeInfo infoSize = new SizeInfo(); infoSize = BllSize.SizeViewing(decSizeId); txtSize.Text = infoSize.Size; txtNarration.Text = infoSize.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; txtSize.Focus(); } else { Messages.InformationMessage(" NA Size canot update or delete"); Clear(); } } } } catch (Exception ex) { MessageBox.Show("SZ12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit Function /// </summary> public void EditFunction() { try { SizeBll BllSize = new SizeBll(); SizeInfo infoSize = new SizeInfo(); infoSize.Size = txtSize.Text.Trim(); infoSize.Narration = txtNarration.Text.Trim(); infoSize.Extra1 = String.Empty; infoSize.Extra2 = String.Empty; infoSize.SizeId = decSizeId; if (BllSize.SizeNameCheckExistence(txtSize.Text.Trim().ToString(), decSizeId) == false) { if (BllSize.SizeEditing(infoSize)) { Messages.UpdatedMessage(); GridFill(); Clear(); } } else { Messages.InformationMessage("Size already exist"); txtSize.Focus(); } } catch (Exception ex) { MessageBox.Show("SZ3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }