|
Hi OG,
I am inferring from your answer (upvoted), that, in this case, it would be best for the OP to loop through his List<bitmap> and specifically dispose of them: that he should not rely on just clearing the List<bitmap>: is that correct ?
thanks, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
Yes - clearing the list does not dispose of any of the items on it (thank goodness!) so the bitmaps will be left hanging until the garbage collector gets round to disposing of them for you.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
If I may be so bold as to humbly point you to a little article[^] that I wrote a while back on memory managing images, you might find that it helps a lot. I use this a lot.
|
|
|
|
|
Sorry chaps, I couldn't find an appropriate forum so I'll take a chance I won't get flamed for using this one. I have a regex question. Given an input string like this:
Some text containing % complete and not much else
If I use a regex of \bcomplete\b I can find the whole word complete just fine. What I want to do is find % complete. I've tried \b% complete\b and \b\% complete\b and \b\x25 complete\b and other variations I can think of but I can never get it to select % complete. Does anyone know if it's possible to do it and how? I can find nothing anywhere that says % cannot participate in an expression.
I've tried two different apps, such as RegexBuilder and RegexBuddy but I can't get it working in either. Does anyone have any ideas? Thanks.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Leslie Nielsen 151576 wrote: I couldn't find an appropriate forum
What, like this[^] one?
|
|
|
|
|
Point taken. I based my search on the menu you get when clicking discussions at the top of the page. I didn't notice the All Message Boards...
I'll post there.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Hi,
I have a problem with treeview in windows application
for example i have a treeview as follows with checkboxes:-
Root0
Node0
Node1
Root1
Node2
Node3
now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked
and if i check on root0 thn both nodes with be checked automatically
i m trying soo hard but m found nothing still, can anyone help me with it
|
|
|
|
|
Firstly I would suggest that you explain what you have done more, possibly show some code as we can then potentially see where the problem is rather than guess.
Secondly I wouldn't post your problem multiple times as this is condsidered rude / bad form.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Please don't repost.
Modify the original question if you have to.
|
|
|
|
|
Arun kumar Gautam wrote: now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked
and if i check on root0 thn both nodes with be checked automatically
i m trying soo hard but m found nothing still, can anyone help me with it
I'd expect this behaviour; can you explain why you think it's wrong?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
wel m now able to resolve it by using
#region TreeView
private void CheckChildNode(TreeNode currNode)
{
//set the children check status to the same as the current node
bool checkStatus = currNode.Checked;
foreach (TreeNode node in currNode.Nodes)
{
node.Checked = checkStatus;
CheckChildNode(node);
}
}
private void CheckParentNode(TreeNode currNode)
{
TreeNode parentNode = currNode.Parent;
if (parentNode == null)
return;
parentNode.Checked = true;
foreach (TreeNode node in parentNode.Nodes)
{
if (!node.Checked)
{
parentNode.Checked = false;
break; // TODO: might not be correct. Was : Exit For
}
}
CheckParentNode(parentNode);
}
#endregion
private void menuCollection_AfterCheck(object sender, TreeViewEventArgs e)
{
menuCollection.AfterCheck -= menuCollection_AfterCheck;
CheckChildNode(e.Node);
CheckParentNode(e.Node);
menuCollection.AfterCheck+=menuCollection_AfterCheck;
}
hope this code helps someone in future
|
|
|
|
|
Hi,
I have a problem with treeview in windows application
for example i have a treeview as follows with checkboxes:-
Root0
Node0
Node1
Root1
Node2
Node3
now if i checked node0 nothing will happn with root0 but if node0 and node1 both are checked thn root0 can be shows as checked
and if i check on root0 thn both nodes with be checked automatically
i m trying soo hard but m found nothing still, can anyone help me with it
|
|
|
|
|
|
KeithF wrote: So basically before i carry on with my design I am wondering from an OO point of view if I am approaching this task in the right way or if what I am doing is overkill and could be greatly simplified? There is no clear and specific "right way" in OO; it's called OO once you structure your methods and data into objects.
If you think the new code is more easily to maintain than the original code, than it'd be an improvement. If the new code looks "complex" or contains a lot of repetitions, then it'd be wise to re-evaluate the design.
Is it an improvement (from your viewpoint), in terms of readability?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yeah i suppose it make the code more flexible going forward but does add a level of complexity that may make it harder for a newbie to just jump in to the code base.
|
|
|
|
|
How to filter one interface with multiple method by diffrent class in C#. Please give answer with example.
|
|
|
|
|
Using IsAssignableFrom can help you figure out if the class uses that interface.
For e.g.
typeof(IMyInterface).IsAssignableFrom(typeof(MyClass));
|
|
|
|
|
Thank u sir, please explain in detail ,I am fresher so define it with C# example
|
|
|
|
|
You can also do this to determine if a class implements a specific interface:
if (myObject is IMyInterface)
{
}
else
{
}
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I know this is long, so please try not to TLDR me I have a reporting service that allows users to queue reports. All fine and dandy, they queue it, it goes into a database. I have a service that polls the DB queue and runs reports. I am stuck on the run part right now. The reports are Telerik reports, but it is not really relevant as it would be the same if they were crystal or anything else. I want to store the report type in the DB and pull it at run time. The report queue looks like this:
USE [litigatorPro]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ReportQueue](
[id] [int] IDENTITY(1,1) NOT NULL,
[reportId] [int] NOT NULL,
[userId] [int] NOT NULL,
[statusId] [int] NOT NULL,
[claimId] [int] NULL,
[propertyId] [int] NULL,
[startDate] [datetime] NULL,
[endDate] [datetime] NULL,
[datestamp] [datetime] NOT NULL,
CONSTRAINT [PK_ReportQueue] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
And the Report table:
USE [litigatorPro]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Report](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](100) NOT NULL,
[fileName] [nvarchar](100) NOT NULL,
[queryString] [nvarchar](2500) NOT NULL,
[scopeId] [int] NOT NULL,
[reportType] [nvarchar](50) NULL,
CONSTRAINT [PK_Report] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
Some of the fields are not use, but the important point is that the service checks the report queue table and gets the report type and parameters. I want to then process the report using something like this:
private bool RunReport<T>(int id) where T: Telerik.Reporting.Report
{
var targetReport = (T)Activator.CreateInstance(typeof(T), new object[] { id });
return false;
}
The issue, for now, is how to call the function with information from the DB. Here is what I am looking at with crossed eyes right now:
private int ProcessReport(ReportQueue item)
{
using (litigatorProEntities _db = new litigatorProEntities())
{
ReportPolling.Model.Report report = _db.Reports.Single(r => r.id == item.reportId);
Type type = Type.GetType(report.reportType);
if (RunReport<type>(report))
{
return 1;
}
return 2;
}
return 2;
}
I need to figure out how to supply the type based on a text field from the DB as seen in the line that says:
if (RunReport<type>(report))
After that I will figure out how to pass the arguments (userId, claimId, propertyId, etc...)
I am not great with some of the fundamental items like generics and boxing, so forgive me if the question is stupid.
Cheers, --EA
|
|
|
|
|
I've just started using Telerik reports and use the .trdx file, have not worked out how to pass in parameters but I'm certain it can be done then the viewer displays! Ahh the light goes on, you want it to process, I'll await further enlightenment (should have deleted this reply I suppose )
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have used Telerik a bit so I am not super unfamiliar with it. So that I am not sitting on my hands all day I decided to just switch() the report name parameter until I can figure out the anonymous access piece.
private bool RunReport(string reportName, int? claimId, int? propertyId, int? ecrId)
{
switch (reportName)
{
case "COR - Cost Summary By Address":
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
CostSummaryByAddress myReport = new CostSummaryByAddress(ecrId, claimId);
instanceReportSource.ReportDocument = myReport;
Telerik.Reporting.Processing.RenderingResult result =
reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
string fileName = result.DocumentName + "." + result.Extension;
string path = System.IO.Path.GetTempPath();
string filePath = System.IO.Path.Combine(path, fileName);
using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
break;
}
return true;
}
And the report class:
public partial class CostSummaryByAddress : Telerik.Reporting.Report
{
public CostSummaryByAddress(int? ecrId, int? claimId)
{
if (ecrId == null)
{
ecrId = 1;
}
InitializeComponent();
using (litigatorProEntities _db = new litigatorProEntities())
{
var model = from d in _db.ECRDatas.Where(e => e.ecrId == ecrId)
select new CostSummaryViewModel
{
claimName = d.ECR.Claim.description,
property = d.property,
totalCost = d.totalCost
};
this.DataSource = model.ToList();
}
}
Frankly, I have built all of these reports in Crystal so I am not sure I am going to stick with Telerik for reporting as all of the reporting is done on an application server with a note being emailed to the user. Since none of it is being displayed in a viewer I am thinking it is more work than it is worth. We will see, though.
Cheers, --EA
|
|
|
|
|
We use SSRS for our server based reporting, Telerik will only be used for reports embedded into the application, there is no integrated viewer for any other reporting system in SilverLight.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm looking for direction on how to do this. I've looked at RegistryMonitor, but I'm having a hard time following how the code works.
I was expecting it to be like a normal event where I could use e.cancel and stop it if needed, but it appears that .net doesn't have that for the registry.
This code example monitors changes on "SYSTEM\CurrentControlSet\Control\Test" in HKLM, but how can I catch it and stop the change from completing?
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
public class RegistryTester
{
const int INFINITE = -1;
const int WAIT_OBJECT_0 = 0;
const long HKEY_LOCAL_MACHINE = 0x80000002L;
const long REG_NOTIFY_CHANGE_LAST_SET = 0x00000004L;
[DllImport("advapi32.dll", EntryPoint = "RegNotifyChangeKeyValue")]
static extern long RegNotifyChangeKeyValue(IntPtr key,
bool watchSubTree, int notifyFilter, IntPtr regEvent, bool
async);
[DllImport("advapi32.dll", EntryPoint = "RegOpenKey")]
static extern IntPtr RegOpenKey(IntPtr key, String subKey,
out IntPtr resultSubKey);
[DllImport("kernel32.dll", EntryPoint = "CreateEvent")]
static extern IntPtr CreateEvent(IntPtr eventAttributes,
bool manualReset, bool initialState, String name);
[DllImport("kernel32.dll", EntryPoint = "WaitForMultipleObjects")]
static extern unsafe int WaitForMultipleObjects(int numHandles,
IntPtr* handleArrays, bool waitAll, int timeOut);
[DllImport("kernel32.dll", EntryPoint = "CloseHandle")]
static extern IntPtr CloseHandle(IntPtr handle);
public unsafe static void Main(String[] args)
{
args = new string[] { "1", @"SYSTEM\CurrentControlSet\Control\Test" };
int ret = 0;
if (args.Length < 2)
{
Console.WriteLine("Usage: RegistryTester NUMKEYS KEY1 KEY2...");
return;
}
int numKeys = 0;
try
{
numKeys = int.Parse(args[0]);
}
catch (Exception)
{
Console.WriteLine("Invalid argument for NUMKEYS");
return;
}
if (numKeys != args.Length - 1)
{
Console.WriteLine("Did not provide correct number of key arguments.");
return;
}
String[] keys = new String[numKeys];
for (int i = 0; i < numKeys; i++)
{
keys[i] = args[i + 1];
}
IntPtr[] eventHandles = new IntPtr[numKeys];
for (int i = 0; i < numKeys; i++)
{
eventHandles[i] = CreateEvent((IntPtr)null, false, false,
null);
IntPtr myKey;
unchecked
{
RegOpenKey(new IntPtr((int)HKEY_LOCAL_MACHINE),
keys[i], out myKey);
}
RegNotifyChangeKeyValue(myKey, true,
(int)REG_NOTIFY_CHANGE_LAST_SET, eventHandles[i],
true);
}
Console.WriteLine("Waiting on " + numKeys + " keys.");
fixed (IntPtr* handlePtr = eventHandles)
{
ret = WaitForMultipleObjects(numKeys, handlePtr, false,
INFINITE);
}
Console.WriteLine(keys[ret - WAIT_OBJECT_0] + " was changed.");
Console.ReadLine();
}
}
}
|
|
|
|
|
The short answer is you can't stop it from happening. If the user has the permissions to make the change, then the change will be made.
Having said that, the long answer is it's possible, depending on your requirements.
You could just change the permissions on the key for user in question. But, since it looks like you're trying to block something under KEY_LOCAL_MACHINE, the user will already have admin permissions and can just remove your permissions block and grant him/herself permissions to it again.
The other method is to intercept the API calls for registry access. You would need a library, called Detours, to do this. This library is not cheap if you want 64-bit support! This method is also NOT TRIVIAL! It's extremely complicated to do.
You would have to examine the caller to see what code is making the call to change the registry. You can't just stop all registry access because you'd be stopping the system from modifying critical values in the registry. You have to example not only where the call is being made from but who is running the code making the call! After all, what good is blocking the change from your app code if the user can just open RegEdit and make the change manually?!
|
|
|
|
|