|
Take a look at this[^], just one hit from googling for custom borders on windows forms
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanls
Have Fun
Never forget it
|
|
|
|
|
No, there isn't. It's always painted using the system colors.
|
|
|
|
|
|
half-life wrote: change the system colors, that an idea
No it's not, since any change you make there affects ALL applications and windows, not just your apps. Changing system-wide settings just to make your app look pretty will ultimately get your app uninstalled.
|
|
|
|
|
Yep, yuor'e right, that i knew a second Later, but what thw hack i'm doing this for my own eyes
Have Fun
Never forget it
|
|
|
|
|
Hi!
below is my codes. I am trying to play all the files in a playlist but it only plays one and stops
[STAThread]
static void Main()
{
Application.Run(new Form1());
Form1 frm = new Form1();
frm.queueMedia();
}
private void queueMedia()
{
string mediasource = "C:\\Test\\Media";
string[] filenames = Directory.GetFiles(mediasource);
foreach (string filename in filenames)
{
PlayMedia(filename);
}
}
private void PlayMedia(string filename)
{
CleanUp();
m_objFilterGraph = new FilgraphManager();
m_objFilterGraph.RenderFile(filename);
m_objBasicAudio = m_objFilterGraph as IBasicAudio;
try
{
m_objVideoWindow = m_objFilterGraph as IVideoWindow;
m_objVideoWindow.Owner = (int)panel1.Handle;
m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
catch (Exception)
{
m_objVideoWindow = null;
}
m_objMediaEvent = m_objFilterGraph as IMediaEvent;
m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
m_objMediaEventEx.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0);
m_objMediaPosition = m_objFilterGraph as IMediaPosition;
m_objMediaControl = m_objFilterGraph as IMediaControl;
this.Text = "DirectShow - [" + filename + "]";
m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;
UpdateStatusBar();
UpdateToolBar();
}
private void CleanUp()
{
if (m_objMediaControl != null)
m_objMediaControl.Stop();
m_CurrentStatus = MediaStatus.Stopped;
if (m_objMediaEventEx != null)
m_objMediaEventEx.SetNotifyWindow(0, 0, 0);
if (m_objVideoWindow != null)
{
m_objVideoWindow.Visible = 0;
m_objVideoWindow.Owner = 0;
}
if (m_objMediaControl != null) m_objMediaControl = null;
if (m_objMediaPosition != null) m_objMediaPosition = null;
if (m_objMediaEventEx != null) m_objMediaEventEx = null;
if (m_objMediaEvent != null) m_objMediaEvent = null;
if (m_objVideoWindow != null) m_objVideoWindow = null;
if (m_objBasicAudio != null) m_objBasicAudio = null;
if (m_objFilterGraph != null) m_objFilterGraph = null;
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Form1_SizeChanged(object sender, System.EventArgs e)
{
if (m_objVideoWindow != null)
{
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;
break;
case 1: m_objMediaControl.Pause();
m_CurrentStatus = MediaStatus.Paused;
break;
case 2: m_objMediaControl.Stop();
m_objMediaPosition.CurrentPosition = 0;
m_CurrentStatus = MediaStatus.Stopped;
break;
}
UpdateStatusBar();
UpdateToolBar();
}
protected override void WndProc( ref Message m)
{
if (m.Msg == WM_GRAPHNOTIFY)
{
int lEventCode;
int lParam1, lParam2;
while (true)
{
try
{
m_objMediaEventEx.GetEvent(out lEventCode,
out lParam1,
out lParam2,
0);
m_objMediaEventEx.FreeEventParams(lEventCode, lParam1, lParam2);
if (lEventCode == EC_COMPLETE)
{
m_objMediaControl.Stop();
m_objMediaPosition.CurrentPosition = 0;
m_CurrentStatus = MediaStatus.Stopped;
UpdateStatusBar();
UpdateToolBar();
}
}
catch (Exception)
{
break;
}
}
}
base.WndProc(ref m);
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if (m_CurrentStatus == MediaStatus.Running)
{
UpdateStatusBar();
}
}
private void UpdateStatusBar()
{
switch (m_CurrentStatus)
{
case MediaStatus.None : statusBarPanel1.Text = "Stopped"; break;
case MediaStatus.Paused : statusBarPanel1.Text = "Paused "; break;
case MediaStatus.Running: statusBarPanel1.Text = "Running"; break;
case MediaStatus.Stopped: statusBarPanel1.Text = "Stopped"; break;
}
if (m_objMediaPosition != null)
{
int s = (int) m_objMediaPosition.Duration;
int h = s / 3600;
int m = (s - (h * 3600)) / 60;
s = s - (h * 3600 + m * 60);
statusBarPanel2.Text = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
s = (int) m_objMediaPosition.CurrentPosition;
h = s / 3600;
m = (s - (h * 3600)) / 60;
s = s - (h * 3600 + m * 60);
statusBarPanel3.Text = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
}
else
{
statusBarPanel2.Text = "00:00:00";
statusBarPanel3.Text = "00:00:00";
}
}
private void UpdateToolBar()
{
switch (m_CurrentStatus)
{
case MediaStatus.None : toolBarButton1.Enabled = false;
toolBarButton2.Enabled = false;
toolBarButton3.Enabled = false;
break;
case MediaStatus.Paused : toolBarButton1.Enabled = true;
toolBarButton2.Enabled = false;
toolBarButton3.Enabled = true;
break;
case MediaStatus.Running: toolBarButton1.Enabled = false;
toolBarButton2.Enabled = true;
toolBarButton3.Enabled = true;
break;
case MediaStatus.Stopped: toolBarButton1.Enabled = true;
toolBarButton2.Enabled = false;
toolBarButton3.Enabled = false;
break;
}
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
Form2 dlg = new Form2();
dlg.ShowDialog();
}
}
please help
|
|
|
|
|
Don't use
foreach (string filename in filenames)
{
PlayMedia(filename);
}
Instead write an event. When one song is completed, fire that event within WndProc
if (lEventCode == EC_COMPLETE)
{
m_objMediaControl.Stop();
m_objMediaPosition.CurrentPosition = 0;
m_CurrentStatus = MediaStatus.Stopped;
UpdateStatusBar();
UpdateToolBar();
// Fire that event
}
Then clean up and start the next song. Hope it will help
|
|
|
|
|
Hi!
thanks, I am new to c# and also media files. could you please provide me a snippet as to how this can be achieved. I also need to delete it from file list once played. thanks in advance.
|
|
|
|
|
Sorry friend,
Today I am in a bit hurry. Currently I am in my office. You can consult any preliminary C# book on how to create an event and fire it. It is a very simple one. Sorry again, don't mind
|
|
|
|
|
|
based on what you have said, I created below delege method
public delegate void PlayNextFileEventHandler(string nextFile);
public event PlayNextFileEventHandler PlayNextFile;
private string file;
public string FileToPlay
{
get { return this.file; }
set
{
this.file = value;
if (this.PlayNextFile != null)
this.PlayNextFile(value);
}
}
codes in main
[STAThread]
static void Main()
{
Application.Run(new Form1());
Form1 frm = new Form1();
frm.PlayNextFile += new PlayNextFileEventHandler(queueMedia);
}
static void queueMedia(object source, MyEventArgs e)
{
string mediasource = "C:\\Test\\Media";
string[] filenames = Directory.GetFiles(mediasource);
foreach (string filename in filenames)
{
PlayMedia(filename);
}
}
not sure how to raise the event so that it plays next file. could someone please help?
|
|
|
|
|
ok, could someone please show me how to play the files sequentially in above codes. thank you
|
|
|
|
|
ok solved it. had to use enqueue and dequeue. thanks
|
|
|
|
|
Hi,
How to generate only 0's and 1's by loop through the condition. I have tried with Random Class like
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
Inside for loop i am having the following line;
int returnValue = RandomNumber(0, 1);
It's returning all 0's. Is any other method to use.
Thanks,
Subbu
|
|
|
|
|
Use
int returnValue = RandomNumber(0, 2); because it generates random numbers excluding the max
|
|
|
|
|
Thanks a lot Anindya.
One question. Is it possible to get 0's and 1's sequence (01010101010101...) like this?
|
|
|
|
|
Create a StringBuilder object. Append that random number to the object in an iteration. After desired iteration just use ToString() method of StringBuilder object and it will create a sequence like that.
Thanks
|
|
|
|
|
spalanivel wrote: private int RandomNumber(int min, int max) {
Random random = new Random();
return random.Next(min, max);
}
Don't create Random objects all the time, it makes no sense, since the Random class guarantees Next() will generate random numbers INSIDE a Random object, not AMONGST different Random objects. Instead create your Random object once, and keep a reference to it as a class member.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Suppose I have the following class :
public class A
{
public bool Boolean {get; set;}
public List<B> ListOfB {get; set;}
}
public class B
{
public String StringValue {get; set;}
public List<String> OneList {get; set;}
public List<String> AnotherList {get; set;}
}
I want to expose the class A and under it the B class in a propertygrid. I have tried a lot of thing, but no help. May be I am missing something. What I did is as follows :
[DefaultProperty("ListOfB")]
public class A
{
[Browsable(false)]
public bool Boolean {get; set;}
[Category("Visuals")]
[Description("YZYZYZ")]
[MergableProperty(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Localizable(true)]
[Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[Editor(typeof(BListEditor), typeof(UITypeEditor))]
public List<B> ListOfB {get; set;}
}
public class B
{
public String StringValue {get; set;}
[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
[Category("Visuals")]
[Description("XXYZ")]
[MergableProperty(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<String> OneList {get; set;}
[Description("PPPWRT")]
[MergableProperty(true)]
[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
[Category("Visuals")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<String> AnotherList {get; set;}
}
public class BListEditor : CollectionEditor
{
public BListEditor()
: base(typeof(List<B> ) )
{ }
protected override Type[] CreateNewItemTypes()
{
return new Type[] {typeof(B)};
}
protected override object SetItems(object editValue, object[] value)
{
A settings = (A)Context.Instance;
object ret = base.SetItems(editValue, value);
return ret;
}
}
I have tried that but no luck. The propertygrid can take the value in collection editor but can't able to store the value. After inserting one B item taking all the data when you click OK nothing actually being inserted into the List of B in class A.
Please help me out.
Thanks in advance.
|
|
|
|
|
It sounds like the ExpandableObjectConverter might be what you need. You can look that up on MSDN, or Google for it (you'll get lots of hits).
Take a look at Add Custom Properties to a PropertyGrid[^], it shows several methods to get what it sounds like you want to do.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Hi Forum,
I have to open a text file in c# and read few lines and then I need to update some lines in the middle of the file.
Let me tell you what am I doing. Here in my program I open a file and display it in a RTF control. I have provided one button to insert one selected character to recognize updation. Now if user clicks somewhere in the rtf control and click to that button, it should insert the selected character to that cursor position. This is same as we insert Emotion symbols here in this forum.
That character can be inserted anywhere in the file.
Please tell me how can I insert a character to a particular cursor position.
Thanks ......
Vishal Moharikar.
|
|
|
|
|
OK so what you want to do is add a character to the selected position is the richtextbox and then save the data back to the file?
to insert into richtextbox...
RichTextBox1.Text.Insert(RichTextBox1.SelectionStart, ":)");
...you should also check the length of the current selection and remove that first if greater than 0
then you just save you text back to the file, which I will assume you can attempt as you have managed to read from the file
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hello Musefan
Thanks for your kind reply. but its not helping me.
Just to see what happens;I used this :
string str = RichTextBox1.Text;
int icurpos = RichTextBox1.SelectionStart;
RichTextBox1.Text = str.Insert(icurpos,"a");
and you suggested me :
RichTextBox1.Text.Insert(icurpos, "smile");
I don't think that there is any difference between above two code blocks. But still behavior is simply different. First one works but not second. I am new to C# and find myself unable to find out the reason.
Secondly when I use the first code block, after inserting desired character at the right place cursor moves to the first character in the rich edit control.
I hope I made my view very clear. Please give any suggestion to resolve the problem.
Thanks in advance.
Vishal Moharikar.
|
|
|
|