|
You really should start making use of the documentation[^] for yourself, and Google and CodeProject articles.
|
|
|
|
|
i would need to know the most effective way get the name of the application from the Registry/LocalMachine/Software/Classes/.docx/shell/Open/Command . for example from this
"C:\Program Files (x86)\Microsoft Office\Office15\POWERPNT.EXE" "%1" /ou "%u"
i would need only the 'POWERPNT.EXE'. substring and replace is not effective as the value inside appears differently. for example
"C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE" /dde "C:\Program Files (x86)\Skype\Phone\Skype.exe" "/uri:%l"
|
|
|
|
|
|
I've programatically built up a Path object. This part works perfect.
Now I want to add a vertical "threshold". So say my path goes from Y=0 to Y=100. The "threshold" may be at Y=50 or whatever. I want the path Y <= 50 to be blue and the path Y > 50 to be green or whatever.
So, right now, I'm using a LinearGradientBrush (oriented vertical and calculate the transition point and do something like
0 color1
0.5 color1
0.5 color2
1 color2
By having the two stops at 0.5, you get the hard color transition which is what I'm looking for.
Now the problem ...
Depending on where the threshold line is, the LinearGradientBrush gets round off errors and sometimes the color break is 1 line too high, sometimes 1 line too low.
What I mean is, my control is 27 pixels high, so the threshold line is at y=14. So theoretically, color1 should always be above the line and color2 below, but sometimes it shifts up due to the round off errors.
Any other way to do this that'll yield better results?
|
|
|
|
|
That's an interesting problem which takes me back to when I was at Adobe implementing the PostScript code for printing the very complex gradients that Illustrator 5.0 enabled.
It might be helpful if you could post a link to a graphic, or two. Knowing what type of elements you used to build the Path would also be useful: arc ? bezier ?
I wonder if your use-cases are approaching the limits of what can be resolved in terms of color-shift on the screen ?
One idea/guess: what if you built a Graphics Region of only "line-to's" ("flattening" arcs or beziers into line segments), and then rendered the Path by enumerating the Region ? Well, does sound far-fetched and what about impact on performance, but no harm done trying to think-outside-the-box, here.
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Here is perhaps a simple example. I might be getting thrown off by the gradient behavior. If you print screen and zoom in with Paint (or some program that doesn't muck with the pixels as you zoom), you'll see the gradient isn't doing a clean break. Even though if you punch the numbers into Calc, they looks correct to me.
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
UseLayoutRounding="True" SnapsToDevicePixels="True">
<Grid>
<Grid Background="LightGray" Height="27" Width="103">
<Line X1="0" X2="103" Y1="21" Y2="21" Stroke="Red" RenderOptions.EdgeMode="Aliased" />
<Rectangle Height="27" Width="50">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0.0" Color="Black" />
<GradientStop Offset="0.77777777777777779" Color="Black" />
<GradientStop Offset="0.77777777777777779" Color="Orange" />
<GradientStop Offset="1" Color="Orange" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Grid>
</Window>
|
|
|
|
|
Sorry, SledgeHammer, I think my post was way off-target in terms of really understanding what you are doing.
I certainly do have a deep experience in "gradient fills," and some form of awkward out-of-kilter color transitions (banding) resulting from "impedance mismatch" between bitmap resolution and rendering-device resolution and type is certainly a typical problem. I spent months while at Adobe (in the late Neolithic era) doing systematic research on creating optimized PostScript code that took into account device characteristics (from 300 dpi laser-printers, to 2400 dpi photo-typesetters, to inkjets, etc.) in deciding how to render gradients in color separations, as well as mono-color.
So, please forget my whacko idea about using 'Regions: I focused on "Path" in terms of how you might be "stroking it" rather than "filling it."
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
modified 3-Dec-14 0:51am.
|
|
|
|
|
It is a stroked line.
Think of a stock chart for example. Typically, its a line graph where the above last close is stroked green and the below last close is stroked red. The last close line is typically a 1 pixel horizontal line. So, its very important asthetically for red pixels not to "bleed" over into the part of the chart thats above the last close line and for green pixels not to "bleed" over into the part of the chart thats below the last close line.
So... I'm trying to implement something similiar.
Paths don't natively support that kind of stroking, so the WPF "trick" is to use a vertical LinearGradientBrush and do a hard color change over at the correct Y position to match up with the horizontal line.
Unfortunately, the LinearGradientBrush works on a 0.0 to 1.0 coordinate system where as a line placed on a grid is going to work on a 0.0 to 26.0 coordinate system (control is 27 pixels high).
I kind of gave up on splitting the path as that has the same issue as the LinearGradientBrush and introduces the whole problem of having to write my own split algorithm.
So it seems like the real problem is I'm not "rounding / fudging" the LinearGradientBrush in the same way that a 1 pixel horizontal line is going to get rounded / fudged on to the grid.
Think about it, if I have a 27 pixel high control, there is certainly a center horizontal line at y=14 and you are left with 13 pixels on either side. HOWEVER, mathamatically speaking, that point is at 13.5.
Since my control is 27 pixels high, I think the y position needs to be rounded to .5's to match up the gradient break with the line break.
Haven't quite matched the WPF fudging though
|
|
|
|
|
Okay, well I understood your question more than I thought I did
Given the presence of a "last close" line in some color other than red or green, and assuming there's always at least one pixel of "open space" both below and above the integer value of the height of the close line:
I'd simply draw the red line up to close line height minus one, and draw the green line beginning vertically at close line height plus one. So I'd be validating the last vertical position of the red line, and the first vertical position of the green line and "doing the right thing."
I'd also draw the close line last ... as an overlay ... to hide any mistakes that were made.
Am I on your frequency yet ?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Jesus... why is everything like pulling teeth?
So I tried going down a different path (no pun intended) and decided to split the path along the threshold line. That way I wouldn't have to deal with the gradient rounding errors.
So, I find some code to split the path (combining the geometry with an exclusion rectangle) and I tweak it to split it how I want it. Then I notice that the half that has the last point auto closes to the first point!!
Are you serious? What good is that?
I find a post about somebody else complaining about it **5 YEARS** ago on the MSDN forums and the MSDN guys respond saying they "know about it, but oh well, that's how it works..."
|
|
|
|
|
Hi,
I am sending email using C#. I would like to know, while sending, ow can I get a delivery receipt or flag in order to update my database with the status?
Thaks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Did you consider searching CodeProject: [^].
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
but this will send a delivery receipt email..
How can I receive it as a flag when sending the email so that I can update my database table status accordingly?
Technology News @ www.JassimRahma.com
|
|
|
|
|
You can't - you have to process the receipt emails and update your DB from them.
But be aware, many systems do not send automatic receipts: they will only send them when the email is read, and they usually ask the user if he wants the receipt sent first.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi,
I would like to save a license key and the connectionstring for my application on the user's PC but I want to make sure it's encrypted strongly so user won't be able to decrypt in order to protect my license key and connection string.
any suggestion?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
Hi,
I'm having a problem with using a BindingList as DataSource for a DataGridView.
The BindingList and the objects in it come from another assembly, thus I cannot modify the object itself to conform to what I want to display in a DataGridView column.
Basically, the object looks something like this:
public class DownloadItem : INotifyPropertyChanged
{
public int Progress { get; private set;}
public string State { get; private set;}
}
In my own program (my assembly) I would bind the items like this:
dataGridViewDownloads.DataSource = _manager.GetDownloads();
Instead of having two columns (Progress and State) I would like to combine them to one (Status) which would display something like "23% Downloading".
I've made my own classes for custom column/cell (DataGridViewTextBoxCell and DataGridViewColumn) but from what I can tell, you can only have one PropertyName assigned to the column.
My initial thought was to create some sort of adapter for the DownloadItem class, but I'm not sure how I would create such adapter without creating another BindingList holding the adapter versions of DownloadItem, which in turn would then break the INotifyPropertyChange interface.
Searching for DataGridView and Adapter gives me results about SqlDataAdapter or DataTable. And I know the SQL adapter is not what I need. Not Sure about the DataTable though?
I would appreciate any hints and thoughts on this, or even hints on what I should search for.
[Solved, sort of]
I found a hackish way to do this without any kind of adapters:
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
DataGridViewElementStates cellState, object value, object formattedValue, string errorText,
DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
StringFormat stringFormat = new StringFormat {
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center,
Trimming = StringTrimming.None,
FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.NoWrap
};
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value,
formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
var item = (DownloadItem)DataGridView.Rows[rowIndex].DataBoundItem;
graphics.DrawString(item.Progress + "% " + item.State, cellStyle.Font, new SolidBrush(cellStyle.ForeColor), cellBounds, stringFormat);
}
Basically, I created my custom column(and cell) with DataPropertyName set to "Progress" then I totally ignore the fact that the column "subscribes" to the Progress property and display whatever I want in the overridden Paint method
Even though this works, I am interested in how you people would have solved it
modified 30-Nov-14 14:04pm.
|
|
|
|
|
Actually I find the C# version of ( Link-grammar 5.1.3) and trying to use it under Windows (i.e. MSVC). In my current research I need to include the link grammar inside my C# project, But I would like to know how I can get the (.dll files) for the Link grammar 5.1.3 ?
|
|
|
|
|
its a touch unclear what you're asking for - for example - if you're using the c/C++ version, you simply link to the DLL's (afaik) and you have access to the parser/grammar
If you have found a c# version, does that not come as a dll/assembly ? (I did a quick search for a c# version and couldn't find it myself - I'd probably use the c/c++ dll's and p/invoke them if I couldn't find c# source)
|
|
|
|
|
I am trying to retrieve text results from a URL, but it redirects me to a second URL to authenticate then later redirects me back to the original URL to see the results. GetResponse ends up returning the html of the second URL instead of the text from the URL that I intended to get results from.
Here's how I am currently attempting to make the web requests.
string URL = "http://somesite.net/results";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
httpWebRequest.Headers.Add("Authorization", "Basic " + auth);
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Method = "GET";
Is there a way that I can handle the redirect to the login URL so I can pull the right data?
Any help will be greatly appreciated, and thank you for taking the time to look over this. Please let me know if I need to provide any additional information.
|
|
|
|
|
WinForms Visual Studio 2013/4 .NET 4.5
I'm executing the code shown here without error, and with valid user-domain and filepath values:
using System.IO;
using System.Security.AccessControl;
private string filePath = validFilepath;
private void setNoDelete()
{
string user = Environment.UserDomainName + "\\" + validAccountName;
FileSecurity security = File.GetAccessControl(filePath);
security.AddAccessRule(new FileSystemAccessRule(user, FileSystemRights.Delete, AccessControlType.Deny));
File.SetAccessControl(filePath, security);
} But, the test file ... in a folder on the Desktop ... can still be deleted in the usual way after this is called.
One hypothesis is that my current user-account has some kind of elevated privileges that cannot be over-ridden by executing this code, but I am not at the place I can really evaluate that idea.
Appreciate any response !
«If you search in Google for 'no-one ever got fired for buying IBM:' the top-hit is the Wikipedia article on 'Fear, uncertainty and doubt'» What does that tell you about sanity in these times?
modified 2-Dec-14 3:04am.
|
|
|
|
|
Is the user a local admin?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks, Eddy,
Yep, my Win8.1 machine has one user-account which I boot into, and I set its type to
'Admin.
«If you search in Google for 'no-one ever got fired for buying IBM:' the top-hit is the Wikipedia article on 'Fear, uncertainty and doubt'» What does that tell you about sanity in these times?
|
|
|
|
|
As Manfred proves, it is possible.
To my limited knowledge, that would make the file completely "undeletable"? And your application uninstallable?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: To my limited knowledge, that would make the file completely "undeletable"?
Not quite! If you don't take away the rights to read and set access permissions, the involved group/account that was denied the delete permission can always change these back. All that I proved is that it is possible to remove the delete right even when moving to elevated mode. So it is still possible to delete the file, but the group/account involved would have to change the file permissions first. I still have some more experiments to run, but that is what I have discovered so far.
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|