|
Are you speaking of a situation in which you have a png file with transparency: and you want to produce, for multi-color printing, a separation plate that contains all the 'transparent' pixels in the .png file, with the idea that those transparent pixels will be rendered in white on that plate ?
And then you want to trim the boundaries of that plate only ?
Even if that is the scenario you describe here, it doesn't make a lot of sense to me. By the way, I've written color-separation software for Adobe products in the past, and am quite familiar with what's involved with complex color-separation scenarios involving both CMYK plates, and spot-colors, custom varnish overlay plates, etc.
best, Bill
"I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone." Bjarne Stroustrop circa 1990
|
|
|
|
|
I am referring to commenting out a section within a line using block comments like this:
Console.WriteLine(((x + y) / 2));
Is there a keyboard shortcut or quick way to do this? I tried to highlight it and select "surround with", but I didn't see any options for comments.
I also know there is the CTRL+K, CTRL+C shortcut, but this comments the entire line and not just the small selection I have highlighted.
I'm using a vanilla install of Visual Studio 2010 with no add-ons.
Thanks all.
|
|
|
|
|
You can create your own snippets. Create a new file in VS (from the File menu, New, XML file is fine.)
="1.0"="utf-8"
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>CommentBlock</Title>
<Shortcut>CB</Shortcut>
<Description>Code snippet for Comment block</Description>
<Author>Microsoft Corporation / Paul Griffin modified</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>comment</ID>
<ToolTip>comment block</ToolTip>
<Default>MyComment</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets> Save the file in the folder:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C# As CommentBlock.snippet
It will now appear in the Surround With list for C# files.
It's a bit rough and ready - it's the first one I have done - but it works.
[edit]Typos in the introduction text - OriginalGriff[/edit]
[edit]I have re-worked this a little, and posted it as a Tip/Trick: Adding a Snippet to Visual Studio[^] - OriginalGriff[/edit]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
modified 16-Nov-11 6:12am.
|
|
|
|
|
Wow, Griff, thank you SO much, that is Awesome!!!
It worked perfectly - just like you said and I've got it all set up now and everything.
Seriously, thank you VERY much.
|
|
|
|
|
Griff's answer is excellent, I'm just surprised that the 7 keystrokes you'd need to do that right now (slash, star, ctrl+right 3 times, star, slash) annoyed you enough to want to find a shortcut.
|
|
|
|
|
You mean 10 keystrokes. A "star" is Shift + 8 which is 2 keystrokes, and you forgot to count the CTRL keystroke, though I only counted it once since I could hold it down.
And that's just to comment out a simple Math.Truncate phrase. If I were doing a much bigger section of a line or even multiple lines, the keystrokes could exponentially grow.
Thanks for the Ctrl+right tip though, I didn't know that either and I like it.
|
|
|
|
|
Consider the following example..
public class Student
{
public string Name { get; set; }
public IList<Course> Courses { get; set; }
}
public class Course
{
public string Name { get; set; }
public IList<Student> Students { get; set; }
}
In this example a circular dependency exists between Student class and Course class. The scenario arises when we are dealing with entity framework - wherein db tables are created as classes for a Student database management system.
In case of C++ we use the concept of forward declaration for telling a class 'A' that another class called 'B' exists even before defining the class 'B'.
Can anybody explain how C# compiler solves this problem of circular dependency between classes?
PS: Please avoid telling me that the classes sould be redesigned to avoid circular dependency. The question is not related to designing since the below mentioned classes are very much from day-to-day programming scenarios.
If asking a question is bad; then not knowing the answer is worse!
|
|
|
|
|
With Interfaces.
public interface IStudent { String Name ... } ;
public class Student : IStudent
{
public string Name { get; set; }
public IList<ICourse> Courses { get; set; }
}
public interface ICourse { String Name ... } ;
public class Course : ICourse
{
public string Name { get; set; }
public IList<IStudent> Students { get; set; }
}
Or something like that.
|
|
|
|
|
I am by no means an expert, so don't take this answer as gospel. I am posting more to see if the gurus out there will correct any bad assumptions I have.
As I believe: C++ is based on C. When C was created there was a need to keep compilers efficient - CPU time = $$$$. Therefore, the C language was designed with the idea that its compilers should not need to make multiple passes of the code. In a single-pass compiling strategy, you have to know what something is before you can use it. Hence procedures and variables had to be declared before they could be used. That led to the need for header files and forward declarations.
I don't know if C++ compilers really need forward declarations, or whether it was just a carry over from C. But either way, this why I believe C++ has header files too.
C# simply broke the tradition. If you allow your compiler to go over the code once and categorize the classes/methods/properties/fields and then go over it again to compile it, then there is no need for forward declaration, nor for header files.
Am I way off base, Gurus?
Clive Pottinger
Victoria, BC
|
|
|
|
|
That's right; Eric Lippert explained it in more detail on his blog[^]
|
|
|
|
|
Ah!! Multiple parsing is the secret!!
Thank you very much Clive for answering my question and thank you Harold for sharing that wonderful link.
|
|
|
|
|
In C++ the compiler only needed a function's prototype or a class declaration, both usually found in headers. The compiler left it to the linker to locate the implementations and resolve those dependencies. When working with C++, this is a common error. The compiler compiles all sources without problems, but the linker stops with an error because you forgot to tell it where to locate a library which belongs to one of the headers you have included.
So you may very well see the linker as a second pass after compiling.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
Hello Gurus.
Yes, I've painted myself into yet another corner. It seems to be what I do best, so I guess I should stick with it.
This time I am trying use reflection to find an event that I have attached to a class, but reflection is not showing the event. I don't know why.
I have created a simple class called ListPicker that is based on the DomainUpDown control. It is supposed to act just like a DomainUpDown control, but it supports the Modified property and the ModifiedChanged events that DomainUpDown does not. Here is the code:
using System;
using System.Windows.Forms;
namespace WindowsFormsControlLibrary
{
public partial class ListPicker : DomainUpDown
{
public EventHandler ModifiedChanged;
public ListPicker()
{
InitializeComponent();
TextChanged += new EventHandler(ListPicker_TextChanged);
Modified = false;
}
public bool Modified { get; set; }
public void ListPicker_TextChanged(object sender, EventArgs args)
{
Modified = true;
OnModifiedChanged();
}
protected void OnModifiedChanged()
{
if (ModifiedChanged != null)
{
ModifiedChanged(this, null);
}
}
}
}
The Modified property works just as I wanted it to, and the ModifiedChanged event fires when it is supposed to, but when I use this code (where ctl is a reference to the ListPicker control)
var x = ctl.GetType().GetEvents();
var modifiedChangedEventInfo = ctl.GetType().GetEvent("ModifiedChanged");
to look for the events on the ListPicker, it does not show the ModifiedChanged event. All the other DomainUpDown event show up in x, but not the ModifiedChanged event and modifiedChangedEventInfo is null
Any ideas? ... and many thanks
Clive Pottinger
Victoria, BC
|
|
|
|
|
Of what type is ctl? Is it of the class DomainUpDown or of ListPicker? If it is of DomainUpDown, you probably only see the events of this class and not of any derived classes.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
that must be because it isn't an event, it is just a delegate. Add the event keyword to your declaration and it should show up.
|
|
|
|
|
Good eyes! I just saw what I expected to see.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
Whoa! I feel like I've just gone to the hospital to ask a surgeon why I keep getting headaches whenever I hit my head with a hammer. There should be a facepalm emoticon.
Thanks guys. I'll apply your suggestion to the code tonight and see what happens.
Clive Pottinger
Victoria, BC
modified 15-Nov-11 12:38pm.
|
|
|
|
|
Yup - that was it.
embarassing... that's all I have to say... embarassing
oh, and thanks.
BTW: I find it interesting that the question from one C.D.P was answered by another C.D.P.
Clive Pottinger
Victoria, BC
|
|
|
|
|
Don't worry.
And you're welcome.
BTW: you shouldn't reply to self, as nobody gets mail notification when you do.
|
|
|
|
|
Clive D. Pottinger wrote: BTW: I find it interesting that the question from one C.D.P was answered by
another C.D.P
In my case the 'CDP' has nothing to do with my name or initials. A CDP1802 or RCA1802[^] was the CPU in my first computer. Look closely at the assembly code sample. One of the instructions, the one to designate the stack pointer, still does not fail to bring a wide grin to programming.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
An instruction any man would love to comply with I think
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Yes, who does not like to set the stack pointer
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
Good catch. I read right over that.
|
|
|
|
|
Hi,
I have an Web Application developed in .NET Framework 4.0 and created an deployment setup for the same. The client requirement is to create an custom Apppool and assign it to the virtual directory which is currently installing. To address this issue i created an custom actions project as described in following article.
http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx[^]
I wrote the following code to create an apppool and assign it to the virtual directory.
private void CreateAppPoolIIS7()
{
using (ServerManager serverManager = new ServerManager())
{
string appPoolName = this.Context.Parameters["APPPOOL"];
ApplicationPool newPool;
newPool = serverManager.ApplicationPools.FirstOrDefault(x => x.Name == appPoolName);
if (newPool == null)
newPool = serverManager.ApplicationPools.Add(appPoolName);
newPool.ManagedRuntimeVersion = "v4.0";
newPool.ManagedPipelineMode = ManagedPipelineMode.Classic;
serverManager.CommitChanges();
}
}
private void AssignIIS7AppPoolToVirDir()
{
using (ServerManager serverManager = new ServerManager())
{
Microsoft.Web.Administration.Application newApp = null;
string appPoolName = this.Context.Parameters["APPPOOL"];
Site site = serverManager.Sites.First(s => s.Id == 1);
string installpath = this.Context.Parameters["INSTALLDIR"];
installpath = installpath.TrimEnd('\\');
string virdirname = "/" + installpath.Substring(installpath.LastIndexOf('\\') + 1);
newApp = site.Applications.FirstOrDefault(x => x.Path == virdirname);
if (newApp != null)
{
newApp.ApplicationPoolName = appPoolName;
serverManager.CommitChanges();
}
else
{
MessageBox.Show("Website not found");
}
}
}
I call these methods in the Install event of the installer as follows..
public override void Install(IDictionary stateSaver)
{
.......
CreateAppPoolIIS7();
AssignIIS7AppPoolToVirDir();
The assigned app pool is reflected in the IIS as long as the control is in the custom action project. The apppool resets back to the default selected at the start of the installer once the setup exits the custom action project.
It would be grateful if some one could help.
When you fail to plan, you are planning to fail.
|
|
|
|
|
Hi All,
I am using the WPF ribbon Library in my application for getting a ribbon control attached in my application.
I need the functionality where I can trap the minimize event in ribbon and do some additional stuff of code in there.
But, to my surprise I could not find any property named Minimized in ribbon .. I could found out collapsed and Expanded but they were of no use.
Can some body tell me what does IsMinimize property correspond to. As,if I know for which property the minimize functionality is attached,I can then easily solve my problem statement.
-Kushagra
I believe in Me !!!
|
|
|
|