|
You have no control whatsoever over what Photoshop does when you drag and drop a picture. However, the picture will be a bitmap in memory, Photoshop is just trying to save in it's default format when you try to save a file.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
OK, so I have my TabControl, which is by the way owner drawn, and I have my TabPages. I want to make the user able to, when a TabPage is clicked and the mouse is moving, move the contents of the TabPage. Now, the moving is working, but my MouseMove event is firing even though my mouse isn't moving!
This is the code:
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
bool foundItem = false;
int index = -1;
foreach (TabPage page in this.TabPages)
{
index++;
if (this.GetTabRect(index).Contains
(e.Location) == true)
{
_hoverIndex = index;
this.Invalidate();
foundItem = true;
if (this.TabMouseEnter != null)
{
TabMouseEventArgs tabArgs = new TabMouseEventArgs();
tabArgs.TabPage = page;
this.TabMouseEnter(this, tabArgs);
}
}
else if (foundItem == false)
{
_hoverIndex = -1;
this.Invalidate();
if (this.TabMouseLeave != null)
{
TabMouseEventArgs tabArgs = new TabMouseEventArgs();
tabArgs.TabPage = page;
this.TabMouseLeave(this, tabArgs);
}
}
}
if (e.Button == MouseButtons.Left)
{
if (_hoverIndex != -1)
{
DockStyle dockStyle = this.DockPanel.Dock;
this.DockPanel.DockPane.HideDockRectangles();
DockForm dockForm = new DockForm();
DockPanel dockPanel = this.DockPanel;
this.DockPanel.DockPane.Controls.Remove(dockPanel);
dockPanel.Dock = DockStyle.Fill;
dockForm.Location = Cursor.Position;
dockForm.Controls.Add(dockPanel);
dockForm.Renderer = this.Renderer;
dockForm.Show();
this.DockPanel.DockForm = dockForm;
List<TabPage> removePages = new List<TabPage>();
foreach (TabPage page in this.TabPages)
{
if (page != this.DockPanel.MainTabPage)
removePages.Add(page);
}
foreach (TabPage page in removePages)
{
foreach (Control control in page.Controls)
{
if (control is DockContainer)
{
DockContainer container = control as DockContainer;
this.DockPanel.DockPane.CreatePanel(container.Form, dockStyle);
this.TabPages.Remove(page);
}
}
}
}
}
}
This is really the only related code. Any ideas?
|
|
|
|
|
Theodor Storm Kristensen wrote: Any ideas?
It seems to be designed that way[^].
I are Troll
|
|
|
|
|
Thanks for the link, it works now.
|
|
|
|
|
I can't believe I'm doing this...
In my job, I have to digitally sign .MSI files before deployment. Previously, this was done using the CAPICOM 2.1 library and a manual wizard-based process to sign the .MSI.
Seeing an opportunity for process improvement, I scripted this process into a drag-and-drop operation where you just drop the .MSI file on the script and it would use the CAPICOM COM objects to find the appropriate code-signing certificate and sign the file for you, baking the signed hash into the file. When you went out to Explorer, you get the properties on the file and click the Digital Signatures tab, whaalaa, you can see the signature!
This process worked great under Windows XP...
Now, move to Windows 7 (we're skipping Vista! ). CAPICOM is no longer in the Windows SDK and is no longer supported as it is offically deprecated by MS. MS says that the same functionality CAPICOM provided can be cobbled together using managed code and the .NET Framework.
I've tried to get CAPICOM to work under Windows 7, but I haven't been able to get any of the COM objects to instantiate. So, now I'm trying to poke around the classes under the System.Security.Cryptography namespace and put together a process to digitally sign an .MSI file (or any other file for that matter,) but do it the with the signature in the file. Having a seperate signed hash in a p7s file does me no good. It must be baked into the .MSI just like the old CAPICOM process did it.
Anyone got any clues or research points to rebuilding this process in managed code? Which classes am I looking at?? I can see the the X509 certificates using the classes in the System.Security.Cryptography.X509Certificates namespace, but can't seem to piece together the signing process. What am I missing?
|
|
|
|
|
For the offical word on CAPICOM support under Windows 7, read this[^].
After about 90 minutes of excersizing my Google Fu, I finally found this[^], which states that I'll have to resort to P/Invoking the Win32 functions I need to get the files signed with an embedded signature. Yuk! Why couldn't they provide an entirely managed solution to replace CAPICOM?!
|
|
|
|
|
Hi,
I need to write a program which can copy a file simply from a source folder to a destination folder.
Please include the codes for a simple program doing so.
|
|
|
|
|
Below is the sample VB.NET Code. Hope you can convert it easily using C#.
using System.IO
Public Sub CopyDir(ByVal strSrc As String, ByVal strDest As String)
Dim dirInfo As New DirectoryInfo(strSrc)
Dim fsInfo As FileSystemInfo
If Not Directory.Exists(strDest) Then
Directory.CreateDirectory(strDest)
End If
For Each fsInfo In dirInfo.GetFileSystemInfos
Dim strDestFileName As String = Path.Combine(strDest, fsInfo.Name)
If TypeOf fsInfo Is FileInfo Then
File.Copy(fsInfo.FullName, strDestFileName, True)
'This will overwrite files that already exist
Else
CopyDir(fsInfo.FullName, strDestFileName)
End If
Next
End Sub
Source : http://abhijitjana.blogspot.com/2007/10/copy-files-from-one-directory-to.html[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
If you keep writing their code for them the will pass the exams, and one day you may end you having to mantain some of their code - even worse, I may end up having to fix it
Give a hint, but please refrain from giving code for something as trivial as this otherwise they will never learn that one of the more important aspects of development is learning how to work things out for yourself. I mean, how difficult is it to go to google and put in file copy c# and look at the top few of the 815,000 hits.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Ashfield wrote: Give a hint,
Most of the cases I did the same. Just give the hint so that they can take it forward.
Ashfield wrote: how difficult is it to go to google and put in file copy c# and look at the top few of the 815,000 hits.
I do the same and Got the link from my Old Blog and I put it over here.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
use
System.IO.File.Copy(src,dest)
where src and dest are source and target respectively.
|
|
|
|
|
If I were to invent a company policy about when programmers should or shouldn't override the Equals() function, what should that policy be and why?
I know when to do it on a case by case basis, but how would I establish a that in terms of a company policy or coding standards document?
Your thoughts?
|
|
|
|
|
When (not) to override Equals()[^].
Don't know if this actually helps you but I found it a couple of days ago.
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.”
|
|
|
|
|
Whenever a reference type's equality should be determined by something else (such as a field/property's value or reference) rather than the class' reference itself.
|
|
|
|
|
sory thet my english in is not good
i need to convert class i build to byte [] array,
for send it over socket .
after i received the byte i wona convert it again to my class
thenk for help
bar !
my class :
namespace WindowsFormsApplication1
{
public class Class1
{
private string a;
public Class1()
{ }
public Class1(string a)
{ this.a = a; }
public void set (string a)
{ this.a = a; }
public string get()
{ return this.a; }
}
}
|
|
|
|
|
|
who i can make it ?
you can send me a code?
tenks!
|
|
|
|
|
b.sahahf wrote: you can send me a code?
If you pay for it, yes. Otherwise, you'll have to write it yourself. The documentation is usually a good place to start, the link to the BinaryFormatter contains a sample that can almost be copied literally. It contains this sample;
static void Serialize()
{
Hashtable addresses = new Hashtable();
addresses.Add("Jeff", "123 Main Street, Redmond, WA 98052");
addresses.Add("Fred", "987 Pine Road, Phila., PA 19116");
addresses.Add("Mary", "PO Box 112233, Palo Alto, CA 94301");
FileStream fs = new FileStream("DataFile.dat", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
try
{
formatter.Serialize(fs, addresses);
}
catch (SerializationException e)
{
Console.WriteLine("Failed to serialize. Reason: " + e.Message);
throw;
}
finally
{
fs.Close();
}
} Good luck with your project
I are Troll
|
|
|
|
|
|
I wrote a program that will find all links to PDF's on a site and download them. However when I look at the downloaded PDF's they are all the same size and corrupted. If I download them via IE they are differnt sizes and they open just fine.
My download code is:
Webclient wc = new WebClient();
wc.DownLoadFile("http://www.somesite.com/somepage/somefile.pdf", "c:\site\somefile.pdf");
I get no errors. I'm not sure if this makes a difference but if I look at the source of the site they have the href to the pdf as href="/somepage/somefile.pdf" I string the hostname to the front of the URL.
I know I can do an httpwebrequest but how will I know how big to make my buffer.
Suggestions?
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
Have you ever looked what is in those corrupted PDFs? Maybe you will find a html-site that tells you that the file wasn't found on this server or you maybe haven't the right to access to file directly.
|
|
|
|
|
Your right....opened it with a hex editor and found HTML. Renamed the extension to .html and it's the logon page.
Okay so even though I have logged on outside of my app and checked the box to remember me, it does not use that cookie. So how do I pass the username and password in my app to grab the file?
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
To access files from a website that saves the login in a cookie is hard.
You have to find the cookie the website saved on your computer and send it with the HTTP-Request Header.
(I don't know an other way except the website has a possibility to login per querystring (ex. data.aspx?user=abc&pwd=pwd)).
|
|
|
|
|
If I dumped the html in to a bowser object on my app where the end user logged on, would those credentials carry over to my app? Hope this makes sense.
Tom Wright
tawright915@gmail.com
|
|
|
|
|
I think those credentials will only work in the scope of your app browser object.
But you can download those pdfs if you get your browser object to do this for you.
(I have build an app like yours a time ago and had the same problem, but I managed my browser object
to do the steps (but not downloading) I wanted to automate.)
|
|
|
|