|
BitArray bitArray = new BitArray(8,false);
bitArray.Set(1,true);
byte[] b = new byte[2];
bitArray.CopyTo(b, 0);
|
|
|
|
|
byte b = 0;
for(int i = 0;i<8;++i)
{
b += bitArray[i] << (7-i);
}
That should do it. There's probably an easier way....
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
how I can use from c#.net to listen a port.
computer
|
|
|
|
|
See MSDN. You must use TcpListener and TcpClient.
|
|
|
|
|
public NewDBBroker(string Path)
{
FileInfo fi = new FileInfo(path);
if (!fi.Exists)
CreateDataBase(Path);
else
{
DBFile = Path;
OpenDataBase();
}
}
public void CreateDataBase(Path);
{
FileStream fi = File.Create(path);
fi.Close();
}
Hi,
I tried the above code,I am developing WIndowsMobile Application using VisualStudio 2005,I am using SQLLite Database.
NotSupportedException coming.. for class FileInfo, Even I cannot Create Database.The part of the path could not find Exception coming.
Anybody help me,
sarala
|
|
|
|
|
Read this:
http://msdn2.microsoft.com/en-us/library/system.io.fileinfo.aspx
"Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: Because file systems for devices operate differently, the .NET Compact Framework does not support getting or setting file attributes."
|
|
|
|
|
Friends,
My application displays modal dialog boxes in case of certain events. The problem is that, when a dialog box is displayed, the winform application continues processing the events and in case of any other event, it displays other dialog box on top of the previous. if many events occur simultaneously, there are many dialog boxes on the screen.
What is want is that when application is displaying a dialog box, it should not not display other dialog box. In ideal case it queues the other requests till the first dialog box is dismissed by the user. How can i do so ?
Imtiaz
|
|
|
|
|
Your app must be multithreaded, otherwise your main form would stop and wait, that's what modal means. So, you need to set a flag that stops other forms from showing when one is already up.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi, everyone.
I'm working on a program to backup playlists in iTunes. The main criteria for the program is that it maintains the same directory structure as the iTunes library. For example, if the song's full filename is E:\iTunes\Queen\The Works\01 Radio GaGa.mp3 and the destination directory is C:\Temp, then the destination filename should be C:\Temp\Queen\The Works\01 Radio GaGa.mp3.
The problem is, I know the method I'm using to build the filenames is pretty inefficient. Here's the relavent code I'm using to build the filenames:
foreach(IITFileOrCDTrack iTrack in iTracks)
{
string srcPath = iTrack.Location;
int a = srcPath.LastIndexOf('\\');
int b = srcPath.LastIndexOf('\\', a - 1);
int start = srcPath.LastIndexOf('\\', b - 1);
string destPath = srcPath.Remove(0, start);
destPath = destPath.Insert(0, tmpPath);
start = destPath.LastIndexOf('\\');
string tmpDest = destPath.Substring(0, start);
string tmpSongName = destPath.Substring(start + 1);
There has got to be a better way to parse the strings than using this method. I've read about the StringBuilder class and it should work, however I'm not certain how I'd set that up in this situation. Does anyone have any ideas on how I could do this?
Thanks in advance.
Flynn
|
|
|
|
|
StringBuilder builds strings, it doesn't parse them.
System.IO.Path contains static methods to get the filename or directory name only from a path. the Split method on a string will turn it into an array of directories if you split on \.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Erm, yeah. Parsing wasn't quite the word I was looking for, just the best fit at the time, heh.
I'll take a look at the Split method. I'm hoping once I get this part fixed and the code cleaned up a little that I can write an article on it. Mostly from the angle of working with the iTunes COM object, and a useful utility for the community.
Thanks again.
Flynn
|
|
|
|
|
There are many ways to do this. Here's a Regex approach:
Match m = Regex.Match(srcPath, @".*\\(?<Artist>.+)\\(?<Album>.+)\\(?<Song>.+)");
if (m.Success)
{
destFolder = tmpPath + m.Groups["Artist"].Value + @"\" + m.Groups["Album"].Value + @"\";
destPath = destPath + m.Groups["Song"].Value;
}
- Bitwise
-- modified at 10:43 Wednesday 16th August, 2006
|
|
|
|
|
Does anyone know a way to integrate a custom set of permissions into active directory using C#?
|
|
|
|
|
How can I add C++ Class to a C#/VC++6 Projects?
|
|
|
|
|
Fahmawi wrote: C#/VC++6 Projects
There's no such thing, a VC6 project cannot know about C#.
Also, a VC6 project cannot work with .NET, unless it does so via COM.
Your options are to build a dll using managed C++, or using COM.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i want to do this effect where i draw a string in a control using the gdi drawstring thing and behind certain words i want to draw a small filled rectangle the length and size of the word/words i want to highlight.
one of my attempts was to use the SetMeasurableCharacterRanges process to locate the position of each character in a string and then knowing the index of the letters to highlight, and the position of where to draw...i could achieve what i wanted... but then theirs the 32 CharacterRange limit that leads to an overflow exception if i try to calcuate the position of more then 32 characters in a string...
see it even says it in the description about the limit
<br />
public void SetMeasurableCharacterRanges(CharacterRange[] ranges);<br />
so i need to know...is it possible to draw text this way at all? i'd settle for a workaround for the SetMeasurableCharacterRanges problem.
|
|
|
|
|
The graphics class has a MeasureString method which returns a size. Then draw a rectangle of that size.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I tried something with measurestring but i found it to not work appearence-wise. Has to do with letter kerning. Also i dont mean highlight the whole string...just certain words in a string. like draw a yellow rectangle behind the word "fox" in the string "The quick orange fox".
|
|
|
|
|
i made a solution to measuring more then 32 characters
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace DrawStringOneCharAtATime<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private Color RandomColor()<br />
{<br />
Random random = new Random();<br />
<br />
return Color.FromArgb(random.Next(256), random.Next(256), random.Next(256));<br />
}<br />
<br />
private Color InvertColor(Color color)<br />
{<br />
byte bRed = (byte)~(color.R);<br />
byte bGreen = (byte)~(color.G);<br />
byte bBlue = (byte)~(color.B);<br />
<br />
return Color.FromArgb(bRed, bGreen, bBlue);<br />
<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
<br />
if (this.DesignMode)<br />
return;<br />
<br />
using (SolidBrush foreColorSolidBrush = new SolidBrush(this.ForeColor))<br />
using (SolidBrush backColorSolidBrush = new SolidBrush(Color.Yellow))<br />
{<br />
string text = "Never send a human to do a wolf's job cause it would be really really really be funny to watch. :p";<br />
<br />
RectangleF displayRectangle = new RectangleF(0, 40, 200, 200);<br />
<br />
<br />
<br />
StringFormat strFormat = StringFormat.GenericTypographic;<br />
strFormat.FormatFlags =<br />
StringFormatFlags.FitBlackBox | <br />
StringFormatFlags.NoClip |
StringFormatFlags.MeasureTrailingSpaces;
<br />
CharacterRange[] ranges;<br />
Region[] charRegions;<br />
<br />
Color foreColor;<br />
Color backColor;<br />
<br />
for (int index = 0, i; index < text.Length; index += 32)<br />
{<br />
if (text.Length - index < 1)
break;<br />
<br />
else if (text.Length - index > 32)
ranges = new CharacterRange[32];<br />
<br />
else
ranges = new CharacterRange[text.Length - index];<br />
<br />
for (i = 0; i < ranges.Length; i++)<br />
ranges[i] = new CharacterRange(index + i, 1);<br />
<br />
strFormat.SetMeasurableCharacterRanges(ranges);<br />
<br />
charRegions = e.Graphics.MeasureCharacterRanges(text, this.Font, displayRectangle, strFormat);<br />
<br />
for (i = 0; i < charRegions.Length; i++)<br />
{<br />
foreColor = RandomColor();<br />
backColor = InvertColor(foreColor);<br />
<br />
foreColorSolidBrush.Color = foreColor;<br />
backColorSolidBrush.Color = backColor;<br />
<br />
e.Graphics.FillRegion(backColorSolidBrush, charRegions[i]);<br />
<br />
RectangleF bounds = charRegions[i].GetBounds(e.Graphics);<br />
<br />
e.Graphics.DrawString(text[index + i].ToString(), this.Font, foreColorSolidBrush, bounds, strFormat);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
}<br />
|
|
|
|
|
|
aeliminate wrote: on a variety of windows and non-windows based devices, such as Windows XP, Windows Mobile 5.0, Microsoft Pocket PC, Windows Media Centre Edition, etc.
I don't see a non-windows platform listed.
aeliminate wrote: The student
This is the point at which this is clearly homework. So, do your homework, and if you get stuck, ask *specific* questions.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
dear madhav! this is your professor at the university. for shame on you since you posted my homework on the cpian. i at first have a doubt about you, hoping and praying to swami you would not failsexed me. but now you cheated! for shame on you.!!11 now you get blackened grade for school. you make me cry.
Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas
|
|
|
|
|
Professor Sharada Ulhas wrote: you cheated! for shame on you
You tell 'em, professor
That's no moon, it's a space station. - Obi-wan Kenobi
|
|
|
|
|
Stick it to him, doc!
|
|
|
|
|
aeliminate wrote: please help me.
With what?
---
b { font-weight: normal; }
|
|
|
|