C#블록의 코드를 실행하는 디자이너에
-
05-07-2019 - |
문제
나의 수행 라인에 실패한 코드를 실행하는 디자이너에서 일으키는 나의 모든 제어의 대중성을 더 이상에서 디자이너입니다.이 때문에 나는 더 이상 볼 수 없이 어떤 나의 형태는 사용을 제어하는 시각 디자인 스튜디오 보기입니다.
라인의 코드를 호출이 안전하지 않은 코드는 프로젝트가 조금의 이미지를 처리주석이 그것을 밖으로 만드 디자인 보입니다.그러나 코드를 실행하게,그래서 나는 볼 수 없습니다 왜 코드에서 실패하면 디자이너입니다.이 코드가 호출되는:
/// <summary>
/// Performs a color adjustment on the source bitmap.
/// </summary>
/// <param name="source">The bitmap to be processed. This is changed by the
/// process action.</param>
/// <param name="redChange">change to the red value. Can be negative.</param>
/// <param name="greenChange">change to the green value. Can be negative.</param>
/// <param name="blueChange">change to the blue value. Can be negative.</param>
/// <returns></returns>
public static Bitmap ProcessColor(Bitmap source, int redChange, int greenChange, int blueChange)
{
sourceBitmap = source;
// lock the source bitmap
sourceBitmapData = getBitmapData(sourceBitmap, ref sourceWidth);
sourcepBase = (Byte*)sourceBitmapData.Scan0.ToPointer();
PixelData* pPixel;
for (int y = 0; y < source.Height; y++)
{
pPixel = (PixelData*)(sourcepBase + y * sourceWidth);
for (int x = 0; x < source.Width; x++)
{
int redVal = pPixel->red + redChange;
if ( redVal <0 ) redVal = 0;
if ( redVal > 255) redVal = 255;
pPixel->red = (byte)redVal;
int greenVal = pPixel->green + greenChange;
if ( greenVal <0 ) greenVal = 0;
if ( greenVal > 255) greenVal = 255;
pPixel->green = (byte)greenVal;
int blueVal = pPixel->blue + blueChange;
if (blueVal < 0) blueVal = 0;
if (blueVal > 255) blueVal = 255;
pPixel->blue = (byte)blueVal;
pPixel++;
}
}
sourceBitmap.UnlockBits(sourceBitmapData);
sourceBitmapData = null;
sourcepBase = null;
return source;
}
(Courtesy of the OpenNETCF 커뮤니티)
내 프로젝트에 표시되어 있지 않으로 안전하지 않지만,프로젝트 위 코드에서는 표시되어 안전하지 않습니다.모두 프로젝트를 필요로 표시하는 안전하지 않은?
또는 있는 방법을 차단할 수 있는 코드 라인을 발사에서 디자이너(지 않아요 실제로 필요한 출력의 이 코드는 디자인에 넣으로 그것은 단지 생성 장애인의 버전에 이미지에서 제공되는 이미지).
편집:을 차단하는 코드에서 실행되지 않는 문제가 해결됩니다.만 댓글을 라인 밖으로 허용한 디자인 보기를 작동합니다.을 가지는 선(심지어는 때에 넣을 경우[false==true]성명)원인 디자이너는 오류를 표시하려면,대신합니다.
해결책
포장의 한 부분에 코드 if
:
if(!DesignMode)
{
// Your "unsafe" code goes here
}
를 사용하는 경우 Compact Framework,사용:
if(Site != null && !Site.DesignMode)
{
// Your "unsafe" code goes here
}
보 이 게시물 모드에서 정보에는 어떤 짐승 DesignMode
사실입니다.
다른 팁
를 만들지 않았지만,이 것이라고 생각했 추가 유용한 속이 발견 -->여기에<--.
단지 이것을 추가하 제어하고 적절하게 사용.
public static bool IsDesignMode
{
get
{
return AppDomain.CurrentDomain.FriendlyName.Contains("DefaultDomain");
}
}
또 우리를 위해 VB.NET 사람들:
Public Shared ReadOnly Property IsDesignMode() As Boolean
Get
Return AppDomain.CurrentDomain.FriendlyName.Contains("DefaultDomain")
End Get
End Property