|
|
Start getting a feed from Scott Gu's Blog (Scott Guthrie). He is one of the Gu'rus on all things MVC
"You get that on the big jobs."
|
|
|
|
|
url = @"http://tests.com/video/network_(a).wmv";
client.DownloadFileAsync(new Uri(url), @"..\Video\network_(a).wmv");
Video.Source = new Uri(url);
Video.Play();
I would like to ask about the above coding, this is a download and play video coding correct,
is it consider as progressive streaming, or real time streaming, i am abit lost on this
|
|
|
|
|
Do you download the entire file and then play it?
In that case, you are doing neither of the two.
See here[^] for a discussion on this by MS.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
but is it possible to do the 2 streaming, in expression blend 4 collaborated with C# VS2010 event handler?
|
|
|
|
|
Below is a configuration for a 31x60 dialog I wanted for a small button column which I could load besides my main form. The Height works, but the Width does not go to 31, and although the Debug version says the Form's Width is 31, it still draws something much wider. Is there some minimum width a form can go to?
//
// Utilities
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(32, 60);
this.ControlBox = false;
this.Controls.Add(this.btSettings);
this.Controls.Add(this.btEvents);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(32, 60);
this.MinimizeBox = false;
this.Name = "Utilities";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Utilities";
this.TopMost = true;
this.ResumeLayout(false);
|
|
|
|
|
Not too sure, but is ClientSize the culprit?
|
|
|
|
|
All the property setting you already have plus MinimumSize = 1,1
Why you want to do it though is another question?
[edit] I forgot to add that the forms Text value needs to be empty.
"You get that on the big jobs."
modified on Monday, February 7, 2011 8:01 AM
|
|
|
|
|
Thanks!
It was the Min set to 1,1..I would have guessed the Text.
|
|
|
|
|
Set the MinimumSize property to the same as your MaximumSize property.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hello Everyone
I have created a login form and when I try to login I get error saying Object reference not set to an instance of an object.
The error I get is in this line of code...
dtAdapter.SelectCommand.CommandText = "SELECT * FROM Users WHERE ID = '" + txtUserId + "' AND Password = '" + txtPassword + "'";
Can someone tell me please if I'm missing something...
thanks in advance
kind regards
lapeci
|
|
|
|
|
You're missing a ton of the code relevant to us answering your question.
Show us how you initialize your adapter and your command. Also ensure that txtUserId and txtPassword are not null objects.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
 Hi Marcus
Here is the full code of login button click event...
public partial class ClientLogin : Window
{
public Client client = new Client();
OleDbConnection conn = new OleDbConnection();
OleDbDataAdapter dtAdapter = new OleDbDataAdapter();
OleDbCommand command = new OleDbCommand();
OleDbDataReader dataReader;
public ClientLogin()
{
InitializeComponent();
conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\AP_AE\Desktop\DTPOS_ClientServer\DataBase\DtposMenu.accdb";
}
public void infoChecker(Client formOne)
{
this.client = formOne;
this.Show();
}
static bool IsNumeric(object Expression)
{
bool isNum;
double retNum;
isNum = Double.TryParse(Convert.ToString(Expression), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);
return isNum;
}
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
try
{
if (IsNumeric(txtUserId.Text) & IsNumeric(txtPassword.Text))
{
conn.Open();
dtAdapter.SelectCommand.CommandText = "SELECT * FROM Users WHERE ID = '" + txtUserId.Text + "' AND Password = '" + txtPassword.Text + "'";
dataReader = dtAdapter.SelectCommand.ExecuteReader();
dataReader.Read();
MessageBox.Show(" - You Have Loged In As: - " + dataReader["Access Level"].ToString() + "\n" + "\n" + " - Welcome " + dataReader["Name"].ToString() + "\n" + "\n" + " - To DTPOS - Point Of Sale System ", "Login Successful", MessageBoxButton.OK, MessageBoxImage.Information);
UserLoginModule.UserAccessLevel = dataReader["Access Level"].ToString();
UserLoginModule.UserFullName = dataReader["Name"].ToString();
this.client.startServer(txtIpAddress.Text.ToString().Trim(), Convert.ToInt32(txtPortNumber.Text.ToString().Trim()), Convert.ToInt32(txtUserId.Text.ToString().Trim()), Convert.ToInt32(txtPassword.Text.ToString().Trim()));
if ((dataReader != null))
{
dataReader.Close();
}
this.Close();
}
else
{
MessageBox.Show("You must enter data in order to proceed further. Please try again...", "Error: Non Data Entry", MessageBoxButton.OK, MessageBoxImage.Information);
txtUserId.Focus();
}
}
catch (System.Data.OleDb.OleDbException exception)
{
MessageBox.Show(exception.StackTrace);
MessageBox.Show(exception.ToString(), "Unable to open database!");
}
catch (InvalidOperationException invalidOperationException)
{
MessageBox.Show(invalidOperationException.Message, "An Invalid Operation Exception");
}
finally
{
if ((conn.State == ConnectionState.Open))
{
conn.Close();
}
}
this.Close();
}
kind regards
lapeci
|
|
|
|
|
Hi lapeci,
Just as a side note regarding connections. .NET uses a connection pool so there is no need to have a class variable which represents a connection. Best practises recommends connections should be created, used and disposed of on-the-fly.
Use a class string variable which represents the connection string by all means.
Also your problem is that you need to set the SelectCommand
dtAdapter.SelectCommand = command
"You get that on the big jobs."
|
|
|
|
|
Slightly off topic, but the code snippet is vulnerable to a form of attack called SQL Injection and leaves a wide open security flaw. A user could stick a user name plus the characters '-- to simply bypass the password check, or something far more malicious. A bit vague description but look it up!
Regards,
Rob Philpott.
|
|
|
|
|
Object reference not set to an instance of an object means some reference type variable or property, that is followed by a period, still is null. There are two candidates in the line shown. Most IDE's have debug capabilities to watch the current value, try it and learn to help yourself, we can't guess what exactly you did wrong.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
1. Either dtAdapter or dtAdapter is null.
2. txtUserId and txtPassword look like names of textboxes rather than string. If they are textboxes, you will need to add .Text as well. If they are string, you may want to revisit the naming convention guidelines you are using.
|
|
|
|
|
Hy everyone,
I am desperate, a newbie to programming and I really need your help guys. I work a lot with sound files in Sound Forge 10 and I started to use the included C# scripts, but I don't know how to personalize them for my personal use. If somebody can help me I'll appreciate it very much.
Here is what I want my script to do:
1. - with the file open, get the path and name of the file.
2. - render the file in the same format to a specified location with the name from an .xml file in the same location and
the same name as the sound file ex:
The name of the opened file is : oldies_20110206144516.wav there is a oldies_20110206144516.xml also,
and I want to replace "oldies" with <artist> from the xml file, insert a character between date and time like
20110206144516 to 2011-02-06_14.45.16 then add two more fields from xml; final name should be something like
<artist>_2011-02-06_14.45.16_<song>-<album>.wav
3. - Close the opened file without saving and without confirmation.
Here is a sample script from sound forge:
______________________________________________________________________________
/* =======================================================================================================
* Script Name: Normalize and Render to Multiple Formats
* Description: This script applies an effect the open file and renders it to each of the given formats.
*
* Initial State: Run with one file open and the Script Editor visible (Menu: View, Script Editor)
*
* Parameters (Args):
* Dir - the directory to render the file to - DEFAULT: prompts user
* fx - the effect to apply - DEFAULT: Normalize
* preset - the preset to use for the given effect - DEFAULT: Maximize peak values
*
* Output: The rendered file names and the format used
*
* ==================================================================================================== */
using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;
//Run with a file open and the Script Editor visible (Menu: View, Script Editor)
//BEHAVIOR:
//- Normalize to maximize peak value
//- If needed, prompts for a target folder
//- Saves the file to one or more formats
//NOTE: Look for MODIFY HERE to quickly update the Script Args with your own preferences
public class EntryPoint {
public string Begin(IScriptableApp app) {
//start MODIFY HERE -------------------------
// the array called outputs stores the file formats used for rendering
//NOTE: some file formats share extensions (WAV) (MPG)
// For MainConcept MPEG-1 use this : "6529C198-A432-409f-8A91-3F62198B0E1A|Default Template"
// For Scott Studio WAV use this: "D284C499-FE95-11d3-BB48-0050DA1A5B06|Default Template"
string[] outputs = new string[] {
".pca|Default Template",
".wma|64 Kbps Stereo Music",
// ".mp3|192 Kbps, CD Transparent Audio", //Commented out because MP3 fails until it's registered.
};
string szDir = GETARG("Dir", @""); //type a default output folder between the quotes
string szPlug = GETARG("fx", "Normalize"); //change the effect here
string szPreset = GETARG("preset", "Maximize peak value"); //change the preset for the effect here
// GETARG is a function that defines the default script settings. You can use the Script Args field to over-ride
// the values within GETARG().
// Example: To over-ride GETARG(Key, valueA), type Key=valueB in the Script Args field.
// Use an ampersand (&) to separate different Script Args: KeyOne=valueB&KeyTwo=valueC
//Example Script Args: Dir=f:\Media&fx=Insert Silence&preset=[Sys] 1 second at end of file
//end MODIFY HERE -------------------------
ISfFileHost file = app.CurrentFile;
if (null == file)
return "No files are open. Script canceled.";
// make sure that the directory exists...
if (szDir == null || szDir.Length <= 0)
szDir = PromptForPath("C:\\");
if (szDir == null || szDir.Length <= 0)
return "No output directory. Script canceled.";
ISfRendererList rends = app.Renderers; // this can take a while, so do it before we show the dialog.
Directory.CreateDirectory(szDir);
// ok, now do the deed.
try
{
file.DoEffect(szPlug, szPreset,
new SfAudioSelection(0, file.Length),
EffectOptions.EffectOnly | EffectOptions.WaitForDoneOrCancel);
} catch(Exception)
{
return "Normalize did not complete, script canceled.";
}
string szBase = file.Window.Title;
DPF("Start Rendering... ");
foreach (string output in outputs)
{
string[] fmt = output.Split(new char[]{'|',';'},2);
if (fmt.Length != 2)
{
DPF("'{0}' is not a valid render format specifier - use \"<renderer name>|<preset name>\" ", output);
continue;
}
// find the renderer
//
ISfRenderer rend = null;
if (fmt[0].StartsWith("."))
rend = app.FindRenderer(null, fmt[0]);
else
rend = app.FindRenderer(fmt[0], null);
if (null == rend)
{
DPF("renderer for type {0} not found - skipping to next", fmt[0]);
continue;
}
// determine if the preset is a string or an integer
//
object vPreset = fmt[1];
try {
int iPreset = int.Parse(fmt[1]);
vPreset = iPreset;
} catch (FormatException) {}
string szName = String.Format("{0}-({1}).{2}", szBase, fmt[1], rend.Extension);
DPF("rendering {0}", szName);
string szFilename = Path.Combine(szDir, szName);
DPF(" ~ {0}", szFilename);
DPF(rend.Guid + " " + vPreset + " '" + szDir + "'");
// now, render the file
//
file.RenderAs(szFilename, rend.Guid, vPreset, null, RenderOptions.RenderOnly);
SfStatus result = file.WaitForDoneOrCancel();
if (result != SfStatus.Success)
continue;
} // foreach
return null;
}
public string PromptForPath(string szDir) {
FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.Description = "Select folder for rendered files:";
if (null != szDir && "" != szDir)
dlg.SelectedPath = szDir;
else
dlg.SelectedPath = @"C:\";
dlg.ShowNewFolderButton = true;
DialogResult res = dlg.ShowDialog();
if (res == DialogResult.OK)
return dlg.SelectedPath;
return null;
}
public void FromSoundForge(IScriptableApp app) {
ForgeApp = app; //execution begins here
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
string msg = Begin(app);
app.SetStatusText(msg != null ? msg : String.Format("Script '{0}' is done.", Script.Name));
}
public static IScriptableApp ForgeApp = null;
public static void DPF(string sz) { ForgeApp.OutputText(sz); }
public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); }
public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); }
public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); }
public static string GETARG(string k, string d) { string val = Script.Args.ValueOf(k); if (val == null || val.Length == 0) val = d; return val; }
public static int GETARG(string k, int d) { string s = Script.Args.ValueOf(k); if (s == null || s.Length == 0) return d; else return Script.Args.AsInt(k); }
public static bool GETARG(string k, bool d) { string s = Script.Args.ValueOf(k); if (s == null || s.Length == 0) return d; else return Script.Args.AsBool(k); }
} //EntryPoint
_______________________________________________________________________________
Thank you in advance for your time.
1000000xxxxxxx
|
|
|
|
|
Firstly: Don't just dump code: post only the relevant fragments. Otherwise we have to wade through it all to work out what is going on.
Secondly: Use <pre> tags or the "code block" widget around your code: it preserves the formatting and makes it easier to read.
Thirdly: What have you tried? Where are you stuck?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
 I've succeeded to make the script render the file to a specified location keeping the original name and close without saving the opened one. I don't know how to get the fields from the xml file and set them to the output filename.
I know I must get the path of the .xml file then extract the needed fields from it but I don't know how to do it.
Here is the script I use:
using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;
public class EntryPoint {
public string Begin(IScriptableApp app) {
string[] outputs = new string[] {
".wav|Default Template",
};
string szDir = GETARG("Dir", @"c:\");
ISfFileHost file = app.CurrentFile;
if (null == file)
return "No files are open. Script canceled.";
string szBase = file.Window.Title;
DPF("Start Rendering... ");
foreach (string output in outputs)
{
string[] fmt = output.Split(new char[]{'|',';'},2);
ISfRenderer rend = null;
if (fmt[0].StartsWith("."))
rend = app.FindRenderer(null, fmt[0]);
else
rend = app.FindRenderer(fmt[0], null);
if (null == rend)
{
DPF("renderer for type {0} not found - skipping to next", fmt[0]);
continue;
}
object vPreset = fmt[1];
string szName = String.Format("{0}", szBase, fmt[1], rend.Extension);
DPF("rendering {0}", szName);
string szFilename = Path.Combine(szDir, szName);
DPF(" ~ {0}", szFilename);
file.RenderAs(szFilename, rend.Guid, vPreset, null, RenderOptions.RenderOnly);
SfStatus result = file.WaitForDoneOrCancel();
if (result != SfStatus.Success)
continue;
file.Close(CloseOptions.DiscardChanges);
}
return null;
}
public void FromSoundForge(IScriptableApp app) {
ForgeApp = app;
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
string msg = Begin(app);
app.SetStatusText(msg != null ? msg : String.Format("Script '{0}' is done.", Script.Name));
}
public static IScriptableApp ForgeApp = null;
public static void DPF(string sz) { ForgeApp.OutputText(sz); }
public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); }
public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); }
public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); }
public static string GETARG(string k, string d) { string val = Script.Args.ValueOf(k); if (val == null || val.Length == 0) val = d; return val; }
public static int GETARG(string k, int d) { string s = Script.Args.ValueOf(k); if (s == null || s.Length == 0) return d; else return Script.Args.AsInt(k); }
public static bool GETARG(string k, bool d) { string s = Script.Args.ValueOf(k); if (s == null || s.Length == 0) return d; else return Script.Args.AsBool(k); }
}
Thank you.
|
|
|
|
|
Aargh...that is just too much code to go through!
Using String.indexOf and string concatenation, you should be able to get _ into the xml file name (if that is what you were looking for).
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Hi.
My goal is:
I wont to create for every user his private data base, thus after I've received his user name I create an accdb file for him, connect to this data base and create tables.
The problem:
after I create the file it won't connect to it, it throws an exception at line :DataBaseManager.conn.Open();, says that the file already in use.
Help please, thanks.
modified on Monday, February 7, 2011 6:23 AM
|
|
|
|
|
Be sure your connection string is correct when you write
sqlconnection obj=new sqlconnection(@"connection string");
to have true connection string don't write own go in properties and copy and past it.
also use @ before.
make sense?
|
|
|
|
|
When you create the file, how are you doing that?
Please show the code, as it sounds like the file creation process is not fully releasing the file...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
here:
public DataBaseManager(String userName)
{
this.userName = userName;
if (!File.Exists(Environment.CurrentDirectory + "\\" + userName + ".accdb"))
{
using (fs = File.Create(Environment.CurrentDirectory + "\\" + userName + ".accdb"))
{
}
}
}
public void connectToDatabase()
{
DataBaseManager.conn = new OleDbConnection(this.dbConnPath);
if (DataBaseManager.conn == null)
{
MessageBox.Show("Can't connect to database", "WorkManager", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
String state = DataBaseManager.conn.State.ToString();
using (File.Open(Environment.CurrentDirectory + "\\" + userName + ".accdb", FileMode.Open))
{
if (state.Equals("Closed"))
{
DataBaseManager.conn.Open();
}
}
}
}
|
|
|
|
|