|
I had to look that up, strange object huh!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Welcome to CodeProject. The problem I, and, I believe many people here, will have with your question is that is very general.
You have a group of files: what format are those files in ? What do you think is involved in getting the data you want to analyze out of those files ?
It would be helpful if you said more about what "sentimental analysis" means: for all we know it could be directly related to content in the files, or very indirectly related so that it would require almost "artificial intelligence" to analyze, and calculate a "score."
Charting and graphing ideas are easy to come by if we know what the data is, and how you want to display it.
«If you search in Google for 'no-one ever got fired for buying IBM:' the top-hit is the Wikipedia article on 'Fear, uncertainty and doubt'» What does that tell you about sanity in these times?
|
|
|
|
|
which person can tell me whether the method I used is correct? If not, please tell me what I should do.
i write a code that can convert cross table to vertical table
cross table :
=====================
Name,Sex,City
=====================
jason,male,hk
---------------------
vivia,Female,dk
---------------------
vertical table
=====================
Name,jason,vivia
=====================
Sex,male,Female
---------------------
City,hk,dk
---------------------
public static DataTable ConvertDataTable(DataTable source)
{
try
{
DataTable _dtResult = new DataTable(source.TableName, source.Namespace);
for (int i = 0; i < source.Columns.Count; i++)
{
List<string> _lstItems = new List<string>();
if (i == 0)
{
_dtResult.Columns.Add(source.Columns[i].ColumnName);
}
else
{
_lstItems.Add(source.Columns[i].ColumnName);
}
for (int ii = 0; ii < source.Rows.Count; ii++)
{
if (i == 0)
{
_dtResult.Columns.Add(source.Rows[ii][i].ToString());
}
else
{
_lstItems.Add(source.Rows[ii][i].ToString());
}
}
if (_lstItems.Count > 0)
{
_dtResult.Rows.Add(_lstItems.ToArray());
}
}
return _dtResult;
}
catch
{
return source;
}
}
|
|
|
|
|
What results do you expect, and what do you actually get?
|
|
|
|
|
I have a Grid inside another Grid, both Binded to a Model, the Parent Grid works well, but the child Grid Binding doesn't, I can't find the error, this is the object:
<pre lang="c#">using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace SAE_Connector
{
[XmlRoot("Configuracion")]
public class clsConfig
{
[XmlElement]
public Config config { get; set; }
[XmlArrayItem]
public List<PrePoliza> PrePolizas { get; set; }
public clsConfig()
{
config = new Config();
PrePolizas = new List<PrePoliza>();
}
}
public class Config
{
[XmlAttribute]
public string RutaDB { get; set; }
public Config()
{
Impuestos = new clsImpuestos();
}
private string _numEmp = "";
[XmlAttribute]
public string NumEmp
{
get
{
return NumeroEmpresaGet();
}
set
{
_numEmp = NumEmp;
}
}
[XmlAttribute]
public string InstanciaCompacSQL { get; set; }
[XmlAttribute]
public string EmpresaContPAQ { get; set; }
[XmlAttribute]
public string PassWord { get; set; }
[XmlElement("Impuestos")]
public clsImpuestos Impuestos { get; set; }
private string NumeroEmpresaGet()
{
string _result = "";
string _emp = string.IsNullOrEmpty(RutaDB) == false ? Path.GetFileNameWithoutExtension(RutaDB) : string.Empty;
if(string.IsNullOrEmpty(_emp)==false)
{
_result = _emp.Substring(_emp.Length - 2);
}
return _result;
}
}
#region impuestos
public class clsImpuestos
{
[XmlElement("Impuesto1")]
public clsImpuesto1 impuesto1 { get; set; }
[XmlElement("Impuesto2")]
public clsImpuesto2 impuesto2 { get; set; }
[XmlElement("Impuesto3")]
public clsImpuesto3 impuesto3 { get; set; }
[XmlElement("Impuesto4")]
public clsImpuesto4 impuesto4 { get; set; }
public clsImpuestos()
{
impuesto1 = new clsImpuesto1();
impuesto2 = new clsImpuesto2();
impuesto3 = new clsImpuesto3();
impuesto4 = new clsImpuesto4();
}
}
public class clsImpuesto1
{
[XmlAttribute]
public string Nombre { get; set; }
[XmlAttribute]
public double Tasa { get; set; }
}
public class clsImpuesto2
{
[XmlAttribute]
public string Nombre { get; set; }
[XmlAttribute]
public double Tasa { get; set; }
}
public class clsImpuesto3
{
[XmlAttribute]
public string Nombre { get; set; }
[XmlAttribute]
public double Tasa { get; set; }
}
public class clsImpuesto4
{
[XmlAttribute]
public string Nombre { get; set; }
[XmlAttribute]
public double Tasa { get; set; }
}
#endregion
public enum eTipoPol { Ingresos, Egresos, Diario }
public class PrePoliza
{
[XmlAttribute]
public int Id { get; set; }
[XmlAttribute]
public eTipoPol tipoPol { get; set; }
[XmlAttribute]
public string Nombre { get; set; }
[XmlAttribute]
public string Concepto { get; set; }
[XmlArrayItem]
public List<Cuenta> Cuentas { get; set; }
public enum eCargoAbono { Cargo, Abono }
public enum eProporcion { SubTotal, Impuesto1, Impuesto2, Impuesto3, Impuesto4, Total }
public enum eReferenciaConcepto { Vacio, Observaciones, Folio, Texto }
public PrePoliza()
{
Cuentas = new List<Cuenta>();
}
public class Cuenta
{
[XmlAttribute]
public int Id { get; set; }
[XmlAttribute]
public string CuentaCod { get; set; }
[XmlAttribute]
public string Descripcion { get; set; }
[XmlAttribute]
public bool EsCuentaCte { get; set; }
[XmlAttribute]
public eCargoAbono CargoAbono { get; set; }
[XmlAttribute]
public eProporcion Proporcion { get; set; }
[XmlAttribute]
public eReferenciaConcepto Referencia { get; set; }
[XmlAttribute]
public string RefText { get; set; }
[XmlAttribute]
public eReferenciaConcepto Concepto { get; set; }
[XmlAttribute]
public string ConcText { get; set; }
}
}
}
This is the complete XAML
<pre lang="c#"><Window x:Class="wpfSaePolizas.xWindows.wPrePolizas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Pre-Polizas" Height="600" Width="1000" Background="{StaticResource brBlue}" WindowState="Maximized" Loaded="Window_Loaded" >
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock" BasedOn="{StaticResource xTextBlockWhiteS}" >
<Setter Property="FontWeight" Value="Normal" />
</Style>
<Style TargetType="TextBox">
<Setter Property="Template" Value="{StaticResource TextBoxRoundCorners}" />
</Style>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderThickness="2" BorderBrush="{StaticResource brBorder}" Margin="5" >
<Border.Resources>
<Style TargetType="StackPanel" >
<Setter Property="Orientation" Value="Horizontal" />
</Style>
<Style TargetType="Image">
<Setter Property="Height" Value="20" />
</Style>
</Border.Resources>
<ToolBar Margin="5" Background="Transparent">
<Button Name="btnNva" Background="#FFFFD801" Width="90" Height="30" Click="btnNva_Click" >
<Button.Content>
<StackPanel>
<Image Source="..\img\Add1.png" />
<TextBlock Text="Nueva" />
</StackPanel>
</Button.Content>
</Button>
<Button Name="btnEliminar" Background="#FFFFD801" Width="90" Height="30" Click="btnEliminar_Click" >
<Button.Content>
<StackPanel>
<Image Source="..\img\Del.png" />
<TextBlock Text="Eliminar" />
</StackPanel>
</Button.Content>
</Button>
<Button Name="btnGuardar" Background="#FFFFD801" Width="90" Height="30" Click="btnGuardar_Click" >
<Button.Content>
<StackPanel>
<Image Source="..\img\Save.png" />
<TextBlock Text="Guardar" />
</StackPanel>
</Button.Content>
</Button>
<Button Name="btnSalir" Background="{StaticResource gradGris}" Width="90" Height="30" Click="btnSalir_Click">
<Button.Content>
<StackPanel>
<TextBlock Text="Salir" />
</StackPanel>
</Button.Content>
</Button>
</ToolBar>
</Border>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<DataGrid Name="dgCuentas" Grid.Column="1" Background="Transparent" AutoGenerateColumns="True" ></DataGrid>
<Border Name="brConfig" Grid.Column="0" BorderThickness="2" BorderBrush="{StaticResource brBorder}" Margin="5" >
<Viewbox VerticalAlignment="Top" Margin="5">
<Grid Name="gridPrePoliza">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Pre-Póliza:" Grid.Row="0" Grid.Column="0" />
<ComboBox Name="cmbPrePolizas" Grid.Row="0" Grid.Column="1" Margin="5" SelectionChanged="cmbPrePolizas_SelectionChanged" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Nombre}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Nombre:" Grid.Row="1" Grid.Column="0" />
<TextBox Name="txtNombre" Grid.Row="1" Grid.Column="1" Text="{Binding Nombre, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="Tipo de Póliza:" Grid.Row="2" Grid.Column="0" />
<ComboBox Name="cmbTiposPoliza" Grid.Row="2" Grid.Column="1" Margin="5" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding }" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Concepto Póliza:" Grid.Row="3" Grid.Column="0" />
<TextBox Name="txtConceptoPol" Grid.Row="3" Grid.Column="1" Text="{Binding Concepto, UpdateSourceTrigger=PropertyChanged}" />
<Grid Name="gridCuenta" Grid.Row="4" Grid.ColumnSpan="2" Margin="0, 20" IsEnabled="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Cuenta:" Grid.Row="0" Grid.Column="0" />
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1">
<TextBox Name="Cuenta" Width="157" Text="{Binding Path=CuentaCod, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TextChanged="Cuenta_TextChanged"/>
<Button Name="btnCuentaBuscar" Content="..." Style="{StaticResource MetroButton}" Width="35" Click="btnCuentaBuscar_Click" Margin="0,0,0,3" VerticalAlignment="Bottom" />
</StackPanel>
<TextBlock Name="lblCuentaNombre" Text="{Binding Path=Descripcion, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Row="1" Grid.ColumnSpan="2" TextWrapping="Wrap" HorizontalAlignment="Center" />
<CheckBox Name="chbEsCteProv" Grid.Row="2" Grid.ColumnSpan="2">
<CheckBox.Content>
<TextBlock Text="Es Cuenta de Cliente/Proveedor" />
</CheckBox.Content>
</CheckBox>
<TextBlock Text="Cargo/Abono:" Grid.Row="3" Grid.Column="0" />
<ComboBox Name="cmbCargoAbono" Grid.Row="3" Grid.Column="1" Margin="5" SelectionChanged="cmbCargoAbono_SelectionChanged" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Proporción:" Grid.Row="4" Grid.Column="0" />
<ComboBox Name="cmbProporcion" Grid.Row="4" Grid.Column="1" Margin="5" SelectionChanged="cmbProporcion_SelectionChanged" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Referencia:" Grid.Row="5" Grid.Column="0" />
<ComboBox Name="cmbRefer" Grid.Row="5" Grid.Column="1" Margin="5" SelectionChanged="cmbRefer_SelectionChanged" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Name="txtRefer" Grid.Row="6" Grid.ColumnSpan="2" IsEnabled="False"
Text="{Binding Path=RefText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<TextBlock Text="Concepto:" Grid.Row="7" Grid.Column="0" />
<ComboBox Name="cmbConcepto" Grid.Row="7" Grid.Column="1" Margin="5" SelectionChanged="cmbConcepto_SelectionChanged" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Name="txtConcepto" Grid.Row="8" Grid.ColumnSpan="2" IsEnabled="False"
Text="{Binding Path=ConcText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</Grid>
<Border Name="brCtasBotones" Grid.Row="5" Grid.ColumnSpan="2" BorderThickness="2" BorderBrush="{StaticResource brBorder}"
Padding="5" CornerRadius="5">
<StackPanel Name="stackBotones" Orientation="Horizontal" HorizontalAlignment="Center" IsEnabled="False" >
<Button Name="btnNvaCta" Background="#FFFFD801" Width="80" Height="30" Grid.Row="4" Click="btnNvaCta_Click" >
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="..\img\Nvo.png" Width="18" />
<TextBlock Text="Nueva" />
</StackPanel>
</Button.Content>
</Button>
<Button Name="btnEliminarCta" Background="#FFFFD801" Width="80" Height="30" Grid.Row="4" Click="btnEliminarCta_Click" >
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="..\img\Del.png" Width="18" />
<TextBlock Text="Borrar" />
</StackPanel>
</Button.Content>
</Button>
<Button Name="btnGuardarCta" Background="#FFFFD801" Width="80" Height="30" Grid.Row="4" Click="btnGuardarCta_Click" >
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="..\img\Save.png" Width="18" />
<TextBlock Text="Guardar" />
</StackPanel>
</Button.Content>
</Button>
</StackPanel>
</Border>
</Grid>
</Viewbox>
</Border>
</Grid>
</Grid>
This is for setting DataContext to Child Grid
PrePoliza.Cuenta _cta = new PrePoliza.Cuenta();
gridCuenta.DataContext = _cta;
And this is for setting DataContext to DataGrid
dgCuentas.ItemsSource = _prepoliza.Cuentas;
This is the Window of the UI:
http://postimg.org/image/ik94x4iwd/
|
|
|
|
|
|
I need to implement a mechanism that will display the latest or newly record entry from a SQL database on a silverlight application. I used a mousemove event plus a timer to send a query to the database, but it is too expensive and I think it can be done in more efficient way. Thanks suggestions or pointers? Thanks
|
|
|
|
|
The timer I can understand but why the mouse move?
I use a timer and a counter, lets the user know when the next refresh is due and does the refresh. The duration of the counter can be set by the admin.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
there are two master page 1)main.master 2)Security folder in Inside.master page
main.master in one Login.aspx page
1)how to pass username value to...
2)inside.master page Login_in.aspx to display label
how to write code ?
plz help me
|
|
|
|
|
i m new to asp.net and c# so need help with PInvoke Stack Imbalance. i don't know what it is. i would like to acquire
any information that is helpful. The error goes as follows :-
A call to PInvoke function 'yeti.mp3!Yeti.Lame.Lame_encDll::beEncodeChunk' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
|
|
|
|
|
You know what's missing here? Code. Without that, how could we hope to diagnose this issue?
You will need to show us what the DllImport looks like, and what the C++ API expects as parameters.
|
|
|
|
|
below is the code for asd.cs:-
//
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER
// REMAINS UNCHANGED.
// SEE http://www.mp3dev.org/ FOR TECHNICAL AND COPYRIGHT INFORMATION REGARDING
// LAME PROJECT.
//
// Email: yetiicb@hotmail.com
//
// Copyright (C) 2002-2003 Idael Cardoso.
//
//
// About Thomson and/or Fraunhofer patents:
// Any use of this product does not convey a license under the relevant
// intellectual property of Thomson and/or Fraunhofer Gesellschaft nor imply
// any right to use this product in any finished end user or ready-to-use final
// product. An independent license for such use is required.
// For details, please visit http://www.mp3licensing.com.
//
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Yeti.MMedia;
using Yeti.MMedia.Mp3;
using WaveLib;
namespace AudioCompress
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBoxInFile;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBoxOutFile;
private System.Windows.Forms.Button buttonInFile;
private System.Windows.Forms.Button buttonOutFile;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.Button buttonConfig;
private System.Windows.Forms.Button buttonCompress;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.ProgressBar progressBar;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.textBoxInFile = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBoxOutFile = new System.Windows.Forms.TextBox();
this.buttonInFile = new System.Windows.Forms.Button();
this.buttonOutFile = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.buttonConfig = new System.Windows.Forms.Button();
this.buttonCompress = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Wave file:";
//
// textBoxInFile
//
this.textBoxInFile.Location = new System.Drawing.Point(8, 16);
this.textBoxInFile.Name = "textBoxInFile";
this.textBoxInFile.ReadOnly = true;
this.textBoxInFile.Size = new System.Drawing.Size(256, 20);
this.textBoxInFile.TabIndex = 1;
this.textBoxInFile.Text = "";
this.toolTip1.SetToolTip(this.textBoxInFile, "Input file");
this.textBoxInFile.TextChanged += new System.EventHandler(this.textBoxInFile_TextChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Compressed file:";
//
// textBoxOutFile
//
this.textBoxOutFile.Enabled = false;
this.textBoxOutFile.Location = new System.Drawing.Point(8, 56);
this.textBoxOutFile.Name = "textBoxOutFile";
this.textBoxOutFile.ReadOnly = true;
this.textBoxOutFile.Size = new System.Drawing.Size(256, 20);
this.textBoxOutFile.TabIndex = 3;
this.textBoxOutFile.Text = "";
this.toolTip1.SetToolTip(this.textBoxOutFile, "Output file");
//
// buttonInFile
//
this.buttonInFile.Location = new System.Drawing.Point(272, 16);
this.buttonInFile.Name = "buttonInFile";
this.buttonInFile.TabIndex = 4;
this.buttonInFile.Text = "Browse...";
this.toolTip1.SetToolTip(this.buttonInFile, "Select the input wave file");
this.buttonInFile.Click += new System.EventHandler(this.buttonInFile_Click);
//
// buttonOutFile
//
this.buttonOutFile.Enabled = false;
this.buttonOutFile.Location = new System.Drawing.Point(272, 56);
this.buttonOutFile.Name = "buttonOutFile";
this.buttonOutFile.TabIndex = 5;
this.buttonOutFile.Text = "Browse...";
this.toolTip1.SetToolTip(this.buttonOutFile, "Change the output file name or location");
this.buttonOutFile.Click += new System.EventHandler(this.buttonOutFile_Click);
//
// openFileDialog1
//
this.openFileDialog1.DefaultExt = "wav";
this.openFileDialog1.Filter = "Wave files (*.wav)|*.wav|All files (*.*)|*.*\"";
this.openFileDialog1.Title = "Wave file to compress";
//
// saveFileDialog1
//
this.saveFileDialog1.DefaultExt = "mp3";
this.saveFileDialog1.Filter = "MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*\"";
this.saveFileDialog1.Title = "Compressed file";
//
// buttonConfig
//
this.buttonConfig.Enabled = false;
this.buttonConfig.Location = new System.Drawing.Point(184, 112);
this.buttonConfig.Name = "buttonConfig";
this.buttonConfig.TabIndex = 6;
this.buttonConfig.Text = "Config...";
this.toolTip1.SetToolTip(this.buttonConfig, "Configure the compressor");
this.buttonConfig.Click += new System.EventHandler(this.buttonConfig_Click);
//
// buttonCompress
//
this.buttonCompress.Enabled = false;
this.buttonCompress.Location = new System.Drawing.Point(272, 112);
this.buttonCompress.Name = "buttonCompress";
this.buttonCompress.TabIndex = 7;
this.buttonCompress.Text = "Compress";
this.toolTip1.SetToolTip(this.buttonCompress, "Convert the wave file to the selected format");
this.buttonCompress.Click += new System.EventHandler(this.buttonCompress_Click);
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(8, 96);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(336, 8);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "About...";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// progressBar
//
this.progressBar.Dock = System.Windows.Forms.DockStyle.Bottom;
this.progressBar.Location = new System.Drawing.Point(0, 139);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(352, 16);
this.progressBar.TabIndex = 9;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(352, 155);
this.Controls.Add(this.progressBar);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.buttonCompress);
this.Controls.Add(this.buttonConfig);
this.Controls.Add(this.buttonOutFile);
this.Controls.Add(this.buttonInFile);
this.Controls.Add(this.textBoxOutFile);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBoxInFile);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Audio Compress";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private Mp3WriterConfig m_Config = null;
private void buttonInFile_Click(object sender, System.EventArgs e)
{
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
try
{
WaveStream s = new WaveStream(openFileDialog1.FileName);
try
{
m_Config = new Mp3WriterConfig(s.Format);
textBoxInFile.Text = openFileDialog1.FileName;
textBoxOutFile.Text = System.IO.Path.ChangeExtension(textBoxInFile.Text, ".mp3");
}
finally
{
s.Close();
}
}
catch
{
MessageBox.Show(this, "Invalid wave file or format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBoxInFile.Text = "";
textBoxOutFile.Text = "";
}
}
}
private void textBoxInFile_TextChanged(object sender, System.EventArgs e)
{
if (textBoxInFile.Text != "")
{
buttonCompress.Enabled = buttonConfig.Enabled = buttonOutFile.Enabled = true;
}
else
{
buttonCompress.Enabled = buttonConfig.Enabled = buttonOutFile.Enabled = false;
}
}
private void buttonOutFile_Click(object sender, System.EventArgs e)
{
saveFileDialog1.FileName = textBoxOutFile.Text;
if (saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
textBoxOutFile.Text = saveFileDialog1.FileName;
}
}
private void buttonConfig_Click(object sender, System.EventArgs e)
{
Config cfg = new Config();
cfg.Mp3Config = m_Config;
if (cfg.ShowDialog(this) == DialogResult.OK)
{
m_Config = cfg.Mp3Config;
}
}
private bool Compressing = false;
private void RefreshControls()
{
if (Compressing)
{
buttonInFile.Enabled = false;
buttonOutFile.Enabled = false;
buttonConfig.Enabled = false;
buttonCompress.Enabled = false;
}
else
{
buttonInFile.Enabled = true;
buttonOutFile.Enabled = true;
buttonConfig.Enabled = true;
buttonCompress.Enabled = true;
}
}
private void buttonCompress_Click(object sender, System.EventArgs e)
{
if (File.Exists(textBoxOutFile.Text) && (MessageBox.Show(this, "Override the existing file?", "File exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes))
{
return;
}
try
{
progressBar.Value = 0;
toolTip1.SetToolTip(progressBar, "");
this.Text = "Audio Compress";
Compressing = true;
try
{
RefreshControls();
WaveStream InStr = new WaveStream(textBoxInFile.Text);
try
{
Mp3Writer writer = new Mp3Writer(new FileStream(textBoxOutFile.Text, FileMode.Create), m_Config);
try
{
byte[] buff = new byte[writer.OptimalBufferSize];
int read = 0;
int actual = 0;
long total = InStr.Length;
Cursor.Current = Cursors.WaitCursor;
try
{
while ((read = InStr.Read(buff, 0, buff.Length)) > 0)
{
Application.DoEvents();
writer.Write(buff, 0, read);
actual += read;
progressBar.Value = (int)(((long)actual * 100) / total);
toolTip1.SetToolTip(progressBar, string.Format("{0}% compresssed", progressBar.Value));
this.Text = string.Format("Audio Compress - {0}% compresssed", progressBar.Value);
Application.DoEvents();
}
toolTip1.SetToolTip(progressBar, "Done");
this.Text = "Audio Compress - Done";
}
finally
{
Cursor.Current = Cursors.Default;
}
}
finally
{
writer.Close();
}
}
finally
{
InStr.Close();
}
}
finally
{
Compressing = false;
RefreshControls();
}
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "An exception has ocurred with the following message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
RefreshControls();
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
About dlg = new About();
dlg.ShowDialog(this);
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = Compressing;
}
}
}
|
|
|
|
|
Do you really think we want to wade through the whole of your files looking for what might be relevant when you can't even be bothered to format it so it's indented properly?
I for one am not going to.
Edit these two posts, cut out anything and everything that isn't immediately relevant to your question, and use the "code block" feature (or <pre>...</pre> tags) to preserve the formatting and engage the syntax highlighter.
Help us to help you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
the code for lame is as follows:-
//
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER
// REMAINS UNCHANGED.
//
// Email: yetiicb@hotmail.com
//
// Copyright (C) 2002-2003 Idael Cardoso.
//
// LAME ( LAME Ain't an Mp3 Encoder )
// You must call the fucntion "beVersion" to obtain information like version
// numbers (both of the DLL and encoding engine), release date and URL for
// lame_enc's homepage. All this information should be made available to the
// user of your product through a dialog box or something similar.
// You must see all information about LAME project and legal license infos at
// http://www.mp3dev.org/ The official LAME site
//
//
// About Thomson and/or Fraunhofer patents:
// Any use of this product does not convey a license under the relevant
// intellectual property of Thomson and/or Fraunhofer Gesellschaft nor imply
// any right to use this product in any finished end user or ready-to-use final
// product. An independent license for such use is required.
// For details, please visit http://www.mp3licensing.com.
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using WaveLib;
namespace Yeti.Lame
{
public enum VBRMETHOD : int
{
VBR_METHOD_NONE = -1,
VBR_METHOD_DEFAULT = 0,
VBR_METHOD_OLD = 1,
VBR_METHOD_NEW = 2,
VBR_METHOD_MTRH = 3,
VBR_METHOD_ABR = 4
}
/* MPEG modes */
public enum MpegMode : uint
{
STEREO = 0,
JOINT_STEREO,
DUAL_CHANNEL, /* LAME doesn't supports this! */
MONO,
NOT_SET,
MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
}
public enum LAME_QUALITY_PRESET : int
{
LQP_NOPRESET =-1,
// QUALITY PRESETS
LQP_NORMAL_QUALITY = 0,
LQP_LOW_QUALITY = 1,
LQP_HIGH_QUALITY = 2,
LQP_VOICE_QUALITY = 3,
LQP_R3MIX = 4,
LQP_VERYHIGH_QUALITY = 5,
LQP_STANDARD = 6,
LQP_FAST_STANDARD = 7,
LQP_EXTREME = 8,
LQP_FAST_EXTREME = 9,
LQP_INSANE = 10,
LQP_ABR = 11,
LQP_CBR = 12,
LQP_MEDIUM = 13,
LQP_FAST_MEDIUM = 14,
// NEW PRESET VALUES
LQP_PHONE =1000,
LQP_SW =2000,
LQP_AM =3000,
LQP_FM =4000,
LQP_VOICE =5000,
LQP_RADIO =6000,
LQP_TAPE =7000,
LQP_HIFI =8000,
LQP_CD =9000,
LQP_STUDIO =10000
}
[StructLayout(LayoutKind.Sequential), Serializable]
public struct MP3 //BE_CONFIG_MP3
{
public uint dwSampleRate; // 48000, 44100 and 32000 allowed
public byte byMode; // BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
public ushort wBitrate; // 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed
public int bPrivate;
public int bCRC;
public int bCopyright;
public int bOriginal;
}
[StructLayout(LayoutKind.Sequential, Size=327), Serializable]
public struct LHV1 // BE_CONFIG_LAME LAME header version 1
{
public const uint MPEG1 = 1;
public const uint MPEG2 = 0;
// STRUCTURE INFORMATION
public uint dwStructVersion;
public uint dwStructSize;
// BASIC ENCODER SETTINGS
public uint dwSampleRate; // SAMPLERATE OF INPUT FILE
public uint dwReSampleRate; // DOWNSAMPLERATE, 0=ENCODER DECIDES
public MpegMode nMode; // STEREO, MONO
public uint dwBitrate; // CBR bitrate, VBR min bitrate
public uint dwMaxBitrate; // CBR ignored, VBR Max bitrate
public LAME_QUALITY_PRESET nPreset; // Quality preset
public uint dwMpegVersion; // MPEG-1 OR MPEG-2
public uint dwPsyModel; // FUTURE USE, SET TO 0
public uint dwEmphasis; // FUTURE USE, SET TO 0
// BIT STREAM SETTINGS
public int bPrivate; // Set Private Bit (TRUE/FALSE)
public int bCRC; // Insert CRC (TRUE/FALSE)
public int bCopyright; // Set Copyright Bit (TRUE/FALSE)
public int bOriginal; // Set Original Bit (TRUE/FALSE)
// VBR STUFF
public int bWriteVBRHeader; // WRITE XING VBR HEADER (TRUE/FALSE)
public int bEnableVBR; // USE VBR ENCODING (TRUE/FALSE)
public int nVBRQuality; // VBR QUALITY 0..9
public uint dwVbrAbr_bps; // Use ABR in stead of nVBRQuality
public VBRMETHOD nVbrMethod;
public int bNoRes; // Disable Bit resorvoir (TRUE/FALSE)
// MISC SETTINGS
public int bStrictIso; // Use strict ISO encoding rules (TRUE/FALSE)
public ushort nQuality; // Quality Setting, HIGH BYTE should be NOT LOW byte, otherwhise quality=5
// FUTURE USE, SET TO 0, align strucutre to 331 bytes
//[ MarshalAs( UnmanagedType.ByValArray, SizeConst=255-4*4-2 )]
//public byte[] btReserved;//[255-4*sizeof(DWORD) - sizeof( WORD )];
public LHV1(WaveFormat format, uint MpeBitRate)
{
if ( format.wFormatTag != (short)WaveFormats.Pcm )
{
throw new ArgumentOutOfRangeException("format", "Only PCM format supported");
}
if ( format.wBitsPerSample != 16)
{
throw new ArgumentOutOfRangeException("format", "Only 16 bits samples supported");
}
dwStructVersion = 1;
dwStructSize = (uint)Marshal.SizeOf(typeof(BE_CONFIG));
switch (format.nSamplesPerSec)
{
case 16000 :
case 22050 :
case 24000 :
dwMpegVersion = MPEG2;
break;
case 32000 :
case 44100 :
case 48000 :
dwMpegVersion = MPEG1;
break;
default :
throw new ArgumentOutOfRangeException("format", "Unsupported sample rate");
}
dwSampleRate = (uint)format.nSamplesPerSec; // INPUT FREQUENCY
dwReSampleRate = 0; // DON'T RESAMPLE
switch (format.nChannels)
{
case 1 :
nMode = MpegMode.MONO;
break;
case 2 :
nMode = MpegMode.STEREO;
break;
default:
throw new ArgumentOutOfRangeException("format", "Invalid number of channels");
}
switch (MpeBitRate)
{
case 32 :
case 40 :
case 48 :
case 56 :
case 64 :
case 80 :
case 96 :
case 112 :
case 128 :
case 160 : //Allowed bit rates in MPEG1 and MPEG2
break;
case 192 :
case 224 :
case 256 :
case 320 : //Allowed only in MPEG1
if (dwMpegVersion != MPEG1)
{
throw new ArgumentOutOfRangeException("MpsBitRate", "Bit rate not compatible with input format");
}
break;
case 8 :
case 16 :
case 24 :
case 144 : //Allowed only in MPEG2
if (dwMpegVersion != MPEG2)
{
throw new ArgumentOutOfRangeException("MpsBitRate", "Bit rate not compatible with input format");
}
break;
default :
throw new ArgumentOutOfRangeException("MpsBitRate", "Unsupported bit rate");
}
dwBitrate = MpeBitRate; // MINIMUM BIT RATE
nPreset = LAME_QUALITY_PRESET.LQP_NORMAL_QUALITY; // QUALITY PRESET SETTING
dwPsyModel = 0; // USE DEFAULT PSYCHOACOUSTIC MODEL
dwEmphasis = 0; // NO EMPHASIS TURNED ON
bOriginal = 1; // SET ORIGINAL FLAG
bWriteVBRHeader = 0;
bNoRes = 0; // No Bit resorvoir
bCopyright = 0;
bCRC = 0;
bEnableVBR = 0;
bPrivate = 0;
bStrictIso = 0;
dwMaxBitrate = 0;
dwVbrAbr_bps = 0;
nQuality = 0;
nVbrMethod = VBRMETHOD.VBR_METHOD_NONE;
nVBRQuality = 0;
}
}
[StructLayout(LayoutKind.Sequential), Serializable]
public struct ACC
{
public uint dwSampleRate;
public byte byMode;
public ushort wBitrate;
public byte byEncodingMethod;
}
[StructLayout(LayoutKind.Explicit), Serializable]
public class Format
{
[FieldOffset(0)]
public MP3 mp3;
[FieldOffset(0)]
public LHV1 lhv1;
[FieldOffset(0)]
public ACC acc;
public Format(WaveFormat format, uint MpeBitRate)
{
lhv1 = new LHV1(format, MpeBitRate);
}
}
[StructLayout(LayoutKind.Sequential), Serializable]
public class BE_CONFIG
{
// encoding formats
public const uint BE_CONFIG_MP3 = 0;
public const uint BE_CONFIG_LAME = 256;
public uint dwConfig;
public Format format;
public BE_CONFIG(WaveFormat format, uint MpeBitRate)
{
this.dwConfig = BE_CONFIG_LAME;
this.format = new Format(format, MpeBitRate);
}
public BE_CONFIG(WaveFormat format)
: this(format, 128)
{
}
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public class BE_VERSION
{
public const uint BE_MAX_HOMEPAGE = 256;
public byte byDLLMajorVersion;
public byte byDLLMinorVersion;
public byte byMajorVersion;
public byte byMinorVersion;
// DLL Release date
public byte byDay;
public byte byMonth;
public ushort wYear;
//Homepage URL
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=257/*BE_MAX_HOMEPAGE+1*/)]
public string zHomepage;
public byte byAlphaLevel;
public byte byBetaLevel;
public byte byMMXEnabled;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=125)]
public byte[] btReserved;
public BE_VERSION()
{
btReserved = new byte[125];
}
}
///
/// Lame_enc DLL functions
///
public class Lame_encDll
{
//Error codes
public const uint BE_ERR_SUCCESSFUL = 0;
public const uint BE_ERR_INVALID_FORMAT = 1;
public const uint BE_ERR_INVALID_FORMAT_PARAMETERS = 2;
public const uint BE_ERR_NO_MORE_HANDLES = 3;
public const uint BE_ERR_INVALID_HANDLE = 4;
///
/// This function is the first to call before starting an encoding stream.
///
/// <param name="pbeConfig" />Encoder settings
/// <param name="dwSamples" />Receives the number of samples (not bytes, each sample is a SHORT) to send to each beEncodeChunk() on return.
/// <param name="dwBufferSize" />Receives the minimun number of bytes that must have the output(result) buffer
/// <param name="phbeStream" />Receives the stream handle on return
/// <returns>On success: BE_ERR_SUCCESSFUL
[DllImport("Lame_enc.dll")]
public static extern uint beInitStream(BE_CONFIG pbeConfig, ref uint dwSamples, ref uint dwBufferSize, ref uint phbeStream);
///
/// Encodes a chunk of samples. Please note that if you have set the output to
/// generate mono MP3 files you must feed beEncodeChunk() with mono samples
///
/// <param name="hbeStream" />Handle of the stream.
/// <param name="nSamples" />Number of samples to be encoded for this call.
/// This should be identical to what is returned by beInitStream(),
/// unless you are encoding the last chunk, which might be smaller.
/// <param name="pInSamples" />Array of 16-bit signed samples to be encoded.
/// These should be in stereo when encoding a stereo MP3
/// and mono when encoding a mono MP3
/// <param name="pOutput" />Buffer where to write the encoded data.
/// This buffer should be at least of the minimum size returned by beInitStream().
/// <param name="pdwOutput" />Returns the number of bytes of encoded data written.
/// The amount of data written might vary from chunk to chunk
/// <returns>On success: BE_ERR_SUCCESSFUL
[DllImport("Lame_enc.dll")]
public static extern uint beEncodeChunk(uint hbeStream, uint nSamples, short[] pInSamples, [In, Out] byte[] pOutput, ref uint pdwOutput);
///
/// Encodes a chunk of samples. Please note that if you have set the output to
/// generate mono MP3 files you must feed beEncodeChunk() with mono samples
///
/// <param name="hbeStream" />Handle of the stream.
/// <param name="nSamples" />Number of samples to be encoded for this call.
/// This should be identical to what is returned by beInitStream(),
/// unless you are encoding the last chunk, which might be smaller.
/// <param name="pSamples" />Pointer at the 16-bit signed samples to be encoded.
/// InPtr is used to pass any type of array without need of make memory copy,
/// then gaining in performance. Note that nSamples is not the number of bytes,
/// but samples (is sample is a SHORT)
/// <param name="pOutput" />Buffer where to write the encoded data.
/// This buffer should be at least of the minimum size returned by beInitStream().
/// <param name="pdwOutput" />Returns the number of bytes of encoded data written.
/// The amount of data written might vary from chunk to chunk
/// <returns>On success: BE_ERR_SUCCESSFUL
[DllImport("Lame_enc.dll")]
protected static extern uint beEncodeChunk(uint hbeStream, uint nSamples, IntPtr pSamples, [In, Out] byte[] pOutput, ref uint pdwOutput);
///
/// Encodes a chunk of samples. Samples are contained in a byte array
///
/// <param name="hbeStream" />Handle of the stream.
/// <param name="buffer" />Bytes to encode
/// <param name="index" />Position of the first byte to encode
/// <param name="nBytes" />Number of bytes to encode (not samples, samples are two byte lenght)
/// <param name="pOutput" />Buffer where to write the encoded data.
/// This buffer should be at least of the minimum size returned by beInitStream().
/// <param name="pdwOutput" />Returns the number of bytes of encoded data written.
/// The amount of data written might vary from chunk to chunk
/// <returns>On success: BE_ERR_SUCCESSFUL
public static uint EncodeChunk(uint hbeStream, byte[] buffer, int index, uint nBytes, byte[] pOutput, ref uint pdwOutput)
{
uint res;
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
IntPtr ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32()+index);
res = beEncodeChunk(hbeStream, nBytes/2/*Samples*/, ptr, pOutput, ref pdwOutput);
}
finally
{
handle.Free();
}
return res;
}
///
/// Encodes a chunk of samples. Samples are contained in a byte array
///
/// <param name="hbeStream" />Handle of the stream.
/// <param name="buffer" />Bytes to encode
/// <param name="pOutput" />Buffer where to write the encoded data.
/// This buffer should be at least of the minimum size returned by beInitStream().
/// <param name="pdwOutput" />Returns the number of bytes of encoded data written.
/// The amount of data written might vary from chunk to chunk
/// <returns>On success: BE_ERR_SUCCESSFUL
public static uint EncodeChunk(uint hbeStream, byte[] buffer, byte[] pOutput, ref uint pdwOutput)
{
return EncodeChunk(hbeStream, buffer, 0, (uint)buffer.Length, pOutput, ref pdwOutput);
}
///
/// This function should be called after encoding the last chunk in order to flush
/// the encoder. It writes any encoded data that still might be left inside the
/// encoder to the output buffer. This function should NOT be called unless
/// you have encoded all of the chunks in your stream.
///
/// <param name="hbeStream" />Handle of the stream.
/// <param name="pOutput" />Where to write the encoded data. This buffer should be
/// at least of the minimum size returned by beInitStream().
/// <param name="pdwOutput" />Returns number of bytes of encoded data written.
/// <returns>On success: BE_ERR_SUCCESSFUL
[DllImport("Lame_enc.dll")]
public static extern uint beDeinitStream(uint hbeStream, [In, Out] byte[] pOutput, ref uint pdwOutput);
///
/// Last function to be called when finished encoding a stream.
/// Should unlike beDeinitStream() also be called if the encoding is canceled.
///
/// <param name="hbeStream" />Handle of the stream.
/// <returns>On success: BE_ERR_SUCCESSFUL
[DllImport("Lame_enc.dll")]
public static extern uint beCloseStream(uint hbeStream);
///
/// Returns information like version numbers (both of the DLL and encoding engine),
/// release date and URL for lame_enc's homepage.
/// All this information should be made available to the user of your product
/// through a dialog box or something similar.
///
/// <param name="pbeVersion" where="" version="" number,="" release="" date="" and="" url="" for="" homepage=""
="" is="" returned.<="" param="" />
[DllImport("Lame_enc.dll")]
public static extern void beVersion([Out] BE_VERSION pbeVersion);
[DllImport("Lame_enc.dll", CharSet=CharSet.Ansi)]
public static extern void beWriteVBRHeader(string pszMP3FileName);
[DllImport("Lame_enc.dll")]
public static extern uint beEncodeChunkFloatS16NI(uint hbeStream, uint nSamples, [In]float[] buffer_l, [In]float[] buffer_r, [In, Out]byte[] pOutput, ref uint pdwOutput);
[DllImport("Lame_enc.dll")]
public static extern uint beFlushNoGap(uint hbeStream, [In, Out]byte[] pOutput, ref uint pdwOutput);
[DllImport("Lame_enc.dll", CharSet=CharSet.Ansi)]
public static extern uint beWriteInfoTag(uint hbeStream, string lpszFileName);
}
}
|
|
|
|
|
And that is even worse.
At the top of the code you have the name of the author, an email address and a website link. Three places you can go for help.
|
|
|
|
|
Which design principle should we have to follow while designing the application?
|
|
|
|
|
Start with SOLID and you won't go far wrong.
|
|
|
|
|
Actually , I have switched from java domain to C#,will it ok if i use the java design principle??
|
|
|
|
|
What do you mean by Java design principle? What's a Java design principle? Do you mean, should you use the same tricks in C# as you do in Java? Well, that depends on the situation as .NET does some things differently and you should follow the .NET way of doing things. If you're talking about designing applications, then use SOLID and, where appropriate, use relevant design patterns.
|
|
|
|
|
perhaps you need to elaborate more on your question. What do you mean exactly when you say "design principle" ?
|
|
|
|
|
How about:
1. Form follows function
2. An application should fit the tools used to build-it, the users who will use it, and the people who will maintain and extend it ... like a custom-made glove fits the hand.
3. Less is More.
4. Achieving simplicity is more complex than achieving complexity.
5. If not you: who ? If not now: when ?
6. Both the wild-eyed dreamer in you, and the compulsive fanatic for order and correctness in you, need breathing room in the conceptual and design stages of an application; if you don't know how to play either of those two roles, or both: get someone else to play them.
7. Know the future users of your application: their skills; their limits; their backgrounds.
8. Put out welcome-mat saying: "Unknown welcome Here !"
cheers, Bill
«If you search in Google for 'no-one ever got fired for buying IBM:' the top-hit is the Wikipedia article on 'Fear, uncertainty and doubt'» What does that tell you about sanity in these times?
|
|
|
|
|
Hi all, I have a web service that used to work but stopped working when I migrated to a new computer. The new computer comes with Windows 8.1 and IIS Express. I made sure that I got everything I need by selecting every option under IIS.
I installed the same version of Visual studio (VS 2012) on the new machine and tried to run the same web app I had in the old machine. When I click a button which makes a call to my web service, nothing happens. I found out through Fidler2 that the problem was
"Data at the root level is invalid. Line 1, position 1."
I have searched online but none matched my situation. Basically all I'm trying to do is send text from a regular html page in the form of JSON to the web service. Then the web service will modify a text file on the server using the text it received. I know the code in the web service works because I called it directly in Visual Studio and it worked fine.
Please suggest a way to fix this problem, thanks in advance
modified 19-Nov-14 10:15am.
|
|
|
|
|
Sounds like mal-formed XML. Have a look and give an example.
|
|
|
|
|
Hi, thanks for responding. I am not reading or writing any XML. In fact even after removing all the code in the webmethod of my webservice except for the return statement
return "Success!"; I still get the same error.
|
|
|
|
|
Yes you are, you just don't know it.
Have a look in your web.config file and you'll probably file the XML in there is messed up.
|
|
|
|
|