|
Yes you're completely right. While we're on the subject, would it be possible to compile all of these photos into one single encrypted package which can then only be opened by the application? That would be ideal, but if I have to store all the files separately then that's not a train smash either.
|
|
|
|
|
Yes - the encryption doesn't care what the content is. I would suggest either a simple directory structure, or just a length prefix/filename combination to each file so you can extract them from the decrypted stream.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
What you are looking for is called encryption. The photos can be in the original format (.jpg or whatever), but the files should be encrypted using a good algorithm and a strong password to keep the data protected.
You can either use some ready-to-use encryption software, or create your own program from scratch... If you decide to write your own program, see the System.Security.Cryptography namespace (there are high-quality encryption algortihms ready for you in the .NET library). There are also several articles about encryption here at CodeProject.
|
|
|
|
|
put the hi-res files inside a password-protected ZIP; or encrypt them.
|
|
|
|
|
Luc Pattyn wrote: a password-protected ZIP
very easy to copy and crack
Luc Pattyn wrote: encrypt them
better alternative.
|
|
|
|
|
You do realize that password-protecting a ZIP file is a form of encryption, right?
|
|
|
|
|
One of the weakest types of encryption, huh!
|
|
|
|
|
I don't know, is 256-bit AES encryption weak?
|
|
|
|
|
An alternate idea...
Save the high resolution images to a database on your computer. Associate a unique key to each photo, or just create a single key for an entire batch of images. Include that key(s) on the DVD with the low resolution images. When the customer gives you the DVD, use that key to lookup the high resolution pictures on your computer. The "database", "key", and "computer" can be anything you like. For example, one configuration might be:
Database: SQL Server
Key: GUID
Computer: PC
Alternate cofiguration:
Database: Excel File
Key: Customer name and date the photos were put on the DVD
Computer: DVD's with the key written on them
No need to put the data in the user's hands.
|
|
|
|
|
Store the Picture in Sqlite DataBase and lock it with password
I know nothing , I know nothing ...
|
|
|
|
|
The best way to keep secrets is to not have any. If they must come to him to have images printed anyway, why even store them on the disc? Keeping them does put the onus on the photographer for storage but I'd be surprised if doesn't already have a backup plan. It also gives the option for a client to call/email an order and have them sent.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I asked the same question The only reason I can think of is that he does not want to keep backups of all his photos.
|
|
|
|
|
Another Idea.
Leave the hi-res images as hi-res so the customer can open them and see the difference. But put distinct watermark, so when printed it does not look good.
|
|
|
|
|
Hi all,
I am trying to have my program detect when the system's memory is low. Is there an event or a windows API that I can use to achieve this?
Thanks in advance.
|
|
|
|
|
What for?
No, I don't think you can do that in a reliable way, short of actually requesting lots of memory until you aren't getting any more.
Each new version of Windows is trying harder to have all memory in use all the time, by caching everything they encounter.
|
|
|
|
|
I just need to find a way that will let me know if the OS's memory/resources is low. Is there a windows API or maybe an event in .Net that I can just plug-in to?
|
|
|
|
|
I haven't had it happen since I got more than 512MB ram, and set a decent size page file, however I recall windows pops a message for you if you are running out of memory. It would ask permission to increase the size of the page file. Leave it to Windows I say.
|
|
|
|
|
It's called try/catch . That's the best you can do. Besides, what *is* low memory in windows? It pages to disk, so you shouldn't have to worry about it.
.45 ACP - because shooting twice is just silly ----- "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 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
|
Yes, you can observe the GC.GetTotalMemory, query the WMI information or use the unmanaged APIs. But as you've been told above, this does not make much sense in general... Your question makes sense, if your application itself manages chunks of memory for specific purposes, such as caching.
P.S. The situation is different, if we are talking about some kind of mobile device...
modified on Sunday, August 29, 2010 6:54 AM
|
|
|
|
|
It's generally pointless to try.
|
|
|
|
|
I am trying to access a property on a System.__ComObject by name. I can do this for normal objects:
var mapping = m.GoogleMapping as SimpleGoogleMapping;
var propInfo = googleContact.GetType().GetProperty(mapping.PropertyName);
googleValue = propInfo.GetValue(googleContact, null);
googleContact is a normal class so this doesn't cause a problem.
I tried this (outlookContact is a ContactItem retreived using Outlook Interop, but during debugging, shows as a System.__ComObject):
var mapping = m.OutlookMapping as SimpleOutlookMapping;
var propInfo = outlookContact.GetType().GetProperty(mapping.PropertyName);
propInfo.SetValue(outlookContact, googleValue, null);
But propInfo ends up being null , even though the property name is correct. I've also tried:
var propInfo = typeof(ContactItem).GetProperty(mapping.PropertyName);
without success.
Edit: Using outlookContact.GetType().GetProperties() or typeof(ContactItem).GetProperties() returns an empty list, as does GetMembers() .
Does anyone know how to achieve this with a dynamic object?
I am using .Net 4
|
|
|
|
|
You cannot query a COM wrapper for CLR properties since it does not have any. Have you tried to extract the properties directly from the assembly which defines the COM CoClass? Something like this:
using System.Reflection;
const string sOutlookInteropAssemblyName =
"Microsoft.Office.Interop.Outlook";
const string sContactItemTypeName =
"_ContactItem";
PropertyInfo FindProperty(string pPropertyName) {
Assemby tOulookInterop =
Assembly.ReflectionOnlyLoad(sOutlookInteropAssembly);
Type tContactItemType =
tOutlookInterop.GetType(sContactItemTypeName);
PropertyInfo [] tProperties =
tContactItemType.GetProperties();
return tProperties.Find(Property => Property.Name == pPropertyName);
}
Huch, there is a lot of stuff which can go wrong, I just typed in the code without checking it, but I hope you get the point.
modified on Saturday, August 28, 2010 4:28 AM
|
|
|
|
|
Can anyone help me this is my whole code
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
using System.Diagnostics;<br />
using Gadgets.Properties;<br />
<br />
namespace Gadgets<br />
{<br />
<br />
public partial class Form1 : Form<br />
{<br />
<br />
public const int WM_NCLBUTTONDOWN = 0xA1;<br />
public const int HTCAPTION = 0x2;<br />
[DllImportAttribute("user32.dll")]<br />
public static extern bool ReleaseCapture();<br />
[DllImportAttribute("user32.dll")]<br />
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
pictureBox2.MouseDown += new MouseEventHandler(p2_MouseDown);<br />
<br />
}<br />
Note newNote = new Note();<br />
Search newSearch = new Search();<br />
SRLS newSRLS = new SRLS();<br />
Alarm newAlarm = new Alarm();<br />
QuickLaunch newQuickLaunch = new QuickLaunch();<br />
Calender newCalender = new Calender();<br />
Time newformtime = new Time();<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
notifyIcon1.Visible = true;<br />
<br />
if (timeToolStripMenuItem.Checked == true)<br />
{<br />
newformtime.Visible = true;<br />
}<br />
if (alarmToolStripMenuItem.Checked == true)<br />
{<br />
newAlarm.Visible = true;<br />
}<br />
if (calenderToolStripMenuItem.Checked == true)<br />
{<br />
newCalender.Visible = true;<br />
}<br />
if (sRLSToolStripMenuItem.Checked == true)<br />
{<br />
newSRLS.Visible = true;<br />
}<br />
if (searchToolStripMenuItem.Checked == true)<br />
{<br />
newSearch.Visible = true;<br />
}<br />
if (noteToolStripMenuItem.Checked == true)<br />
{<br />
newNote.Visible = true;<br />
}<br />
if (quickLaunchToolStripMenuItem.Checked == true)<br />
{<br />
newQuickLaunch.Visible = true;<br />
}<br />
<br />
<br />
timeToolStripMenuItem.Checked = Settings.Default.timecheck;<br />
alarmToolStripMenuItem.Checked = Settings.Default.calendercheck;<br />
calenderToolStripMenuItem.Checked = Settings.Default.alarmcheck;<br />
sRLSToolStripMenuItem.Checked = Settings.Default.srlscheck;<br />
searchToolStripMenuItem.Checked = Settings.Default.searchcheck;<br />
noteToolStripMenuItem.Checked = Settings.Default.notecheck;<br />
quickLaunchToolStripMenuItem.Checked = Settings.Default.quickLaunchcheck;<br />
<br />
}<br />
<br />
private void p2_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
if (e.Button == MouseButtons.Left)<br />
{<br />
ReleaseCapture();<br />
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);<br />
}<br />
}<br />
<br />
private void p1_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
this.pictureBox1.Image = Properties.Resources.minimize2;<br />
}<br />
<br />
private void p1_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
this.pictureBox1.Image = Properties.Resources.minimize3;<br />
}<br />
<br />
private void p1_MouseLeave(object sender, EventArgs e)<br />
{<br />
this.pictureBox1.Image = Properties.Resources.minimize1;<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private void pictureBox1_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
}<br />
<br />
<br />
<br />
<br />
<br />
private void copyright_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
this.copyright.Image = Properties.Resources.l2;<br />
}<br />
<br />
private void copyright_MouseLeave(object sender, EventArgs e)<br />
{<br />
this.copyright.Image = Properties.Resources.l1;<br />
}<br />
<br />
private void copyright_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
this.copyright.Image = Properties.Resources.l3;<br />
}<br />
<br />
private void copyright_Click(object sender, EventArgs e)<br />
{<br />
System.Diagnostics.Process.Start("www.systemerror.co.nr");<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
if (newformtime.Visible == true)<br />
{<br />
timeToolStripMenuItem.Checked = false;<br />
newformtime.Visible = false;<br />
}<br />
else if (newformtime.Visible == false)<br />
{<br />
timeToolStripMenuItem.Checked = true;<br />
newformtime.Visible = true;<br />
}<br />
}<br />
<br />
Form2 newForm2 = new Form2();<br />
private void button11_Click(object sender, EventArgs e)<br />
{<br />
newForm2.Visible = true;<br />
}<br />
<br />
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
if (newCalender.Visible == true)<br />
{<br />
calenderToolStripMenuItem.Checked = false;<br />
newCalender.Visible = false;<br />
}<br />
else if (newCalender.Visible == false)<br />
{<br />
calenderToolStripMenuItem.Checked = true;<br />
newCalender.Visible = true;<br />
} <br />
}<br />
<br />
<br />
private void button3_Click(object sender, EventArgs e)<br />
{<br />
if (newAlarm.Visible == true)<br />
{<br />
alarmToolStripMenuItem.Checked = false;<br />
newAlarm.Visible = false;<br />
}<br />
else if (newAlarm.Visible == false)<br />
{<br />
alarmToolStripMenuItem.Checked = true;<br />
newAlarm.Visible = true;<br />
}<br />
}<br />
<br />
<br />
private void button4_Click(object sender, EventArgs e)<br />
{<br />
if (newSRLS.Visible == true)<br />
{<br />
sRLSToolStripMenuItem.Checked = false;<br />
newSRLS.Visible = false;<br />
}<br />
else if (newSRLS.Visible == false)<br />
{<br />
sRLSToolStripMenuItem.Checked = true;<br />
newSRLS.Visible = true;<br />
}<br />
}<br />
<br />
<br />
private void button6_Click(object sender, EventArgs e)<br />
{<br />
if (newSearch.Visible == true)<br />
{<br />
searchToolStripMenuItem.Checked = false;<br />
newSearch.Visible = false;<br />
}<br />
else if (newSearch.Visible == false)<br />
{<br />
searchToolStripMenuItem.Checked = true;<br />
newSearch.Visible = true;<br />
}<br />
}<br />
<br />
<br />
private void button7_Click(object sender, EventArgs e)<br />
{<br />
if (newNote.Visible == true)<br />
{<br />
noteToolStripMenuItem.Checked = false;<br />
newNote.Visible = false;<br />
}<br />
else if (newNote.Visible == false)<br />
{<br />
noteToolStripMenuItem.Checked = true;<br />
newNote.Visible = true;<br />
}<br />
}<br />
<br />
<br />
private void button9_Click(object sender, EventArgs e)<br />
{<br />
if (newQuickLaunch.Visible == true)<br />
{<br />
quickLaunchToolStripMenuItem.Checked = false;<br />
newQuickLaunch.Visible = false;<br />
}<br />
else if (newQuickLaunch.Visible == false)<br />
{<br />
quickLaunchToolStripMenuItem.Checked = true;<br />
newQuickLaunch.Visible = true;<br />
}<br />
}<br />
<br />
private void pictureBox2_Click(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
<br />
private void exitToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
this.Close();<br />
}<br />
<br />
private void notifyIcon1_DoubleClick(object sender, EventArgs e)<br />
{<br />
this.Show();<br />
}<br />
<br />
private void timeToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
timeToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["timecheck"] = timeToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void calenderToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
<br />
calenderToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["calendercheck"] = calenderToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void alarmToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
<br />
alarmToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["alarmcheck"] = alarmToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void sRLSToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
sRLSToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["srlscheck"] = sRLSToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void searchToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
searchToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["searchcheck"] = searchToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void noteToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
noteToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["notecheck"] = noteToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void quickLaunchToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
quickLaunchToolStripMenuItem.Checked = true;<br />
<br />
<br />
Settings.Default["quickLaunchcheck"] = quickLaunchToolStripMenuItem.Checked;<br />
Settings.Default.Save();<br />
}<br />
<br />
private void CMS_CheckChanged(object sender, EventArgs e)<br />
{<br />
foreach (ToolStripItem item in ((ToolStripDropDownItem)sender).Owner.Items)<br />
{<br />
if (item.GetType() == typeof(ToolStripMenuItem))<br />
{<br />
if (item == sender)<br />
((ToolStripMenuItem)item).Checked = true;<br />
else<br />
((ToolStripMenuItem)item).Checked = false;<br />
}<br />
}<br />
}<br />
<br />
}<br />
}
And in the program.cs I get this error
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
On this code
Application.Run(new Form1());
|
|
|
|
|
This is not your whole code - this is only Form1. My suspicion is that you might have a problem in one of the following lines:
Note newNote = new Note();
Search newSearch = new Search();
SRLS newSRLS = new SRLS();
Alarm newAlarm = new Alarm();
QuickLaunch newQuickLaunch = new QuickLaunch();
Calender newCalender = new Calender();
Time newformtime = new Time(); To prove this, you need to set a breakpoint in your Form_Load to see if you ever actually hit the Form_Load event. If you get the exception beforehand, then it's likely that your problem is in there (and the problem is that you have something that is recursively calling the same method).
Now, your coding style - it's never a good idea to leave default names for items you have any form of interaction with in your code, so you should rename things like button1, etc, to something much more meaningful. Also, you could condense a lot of your methods down. Take this one:
if (newAlarm.Visible == true)
{
alarmToolStripMenuItem.Checked = false;
newAlarm.Visible = false;
}
else if (newAlarm.Visible == false)
{
alarmToolStripMenuItem.Checked = true;
newAlarm.Visible = true;
} That could be rewritten more succinctly (and clearly) as:
newAlarm.Visible = !newAlarm.Visible;<br />
alarmToolStripMenuItem.Checked = newAlarm.Visible; You could get terser than that, but this is fairly clear in what it does.
|
|
|
|
|