0

다른 유형의 비트 맵을 그릴 수있는 세 개의 Windows 라이브러리가 있습니다. 공통점은 글꼴, 색상 및 펜입니다.글로벌 프로젝트 정적 변수

모든 표준 글꼴, 색 및 펜을 가질 수있는 라이브러리를 디자인하여 글꼴을 변경하면 다른 모든 라이브러리에서 전역 적으로 변경되도록하고 싶습니다.

예를 들어 : 나는 비트 맵에 그리는 세 개의 라이브러리를 가지고 그들은 모두이 같은 설정을 사용 :

 internal static readonly Font ELEVATION_FONT = new Font("Segoe UI Semibold", 7.9f), 
            DETAIL_BOX_FONT = new Font(FontFamily.GenericSerif, 8f, FontStyle.Regular);//"Palatino Linotype" 

    internal static readonly Color BACK_COLOR_SCREEN = Color.Black, 
            LINE_COLOR_SCREEN = Color.FromArgb(161, 161, 161), 
            BACK_COLOR = Color.White, 
            LINE_COLOR = Color.Black; 

나는 하나의 라이브러리라는 MySoluctionNameDrawing 이러한 설정을 사용하는 다른 모든 라이브러리를 만들고 싶습니다 비트 맵에 그리기 위해 MySoluctionNameDrawing의 비트 맵을 사용합니다.

유지 관리 용이기도합니다.

MySoluctionName은 내 솔루션의 이름 일 뿐이지 만 데모 목적으로 사용하는 것이 중요합니다.

누구나 하나의 라이브러리에서 내 모든 그리기 관련 도구를 사용하고 엉망으로 만드는 다른 라이브러리에서 액세스 할 수있는 가장 쉽고 깨끗한 방법으로 아이디어가 있습니까?


다음은 내가 생각해 낸 것입니다.

그리기 DLL

namespace AlumCloudDrawing 
    { 

     public static class DrawingOptions 
     { 
      public static readonly Font ELEVATION_FONT = new Font("Segoe UI Semibold", 7.9f), 
              DETAIL_BOX_FONT = new Font(FontFamily.GenericSerif, 8f, FontStyle.Regular);//"Palatino Linotype"  


      public static readonly Color BACK_COLOR_SCREEN = Color.Black, 
               LINE_COLOR_SCREEN = Color.FromArgb(161, 161, 161), 
               BACK_COLOR = Color.White, 
               LINE_COLOR = Color.Black; 
     } 
    } 

그리기 DLL 라이브러리에 의존하는 라이브러리에서 사용 REF.

internal static readonly Font ELEVATION_FONT = AlumCloudDrawing.DrawingOptions.ELEVATION_FONT, 
            DETAIL_BOX_FONT = AlumCloudDrawing.DrawingOptions.DETAIL_BOX_FONT; 

    internal static readonly Color BACK_COLOR_SCREEN = AlumCloudDrawing.DrawingOptions.BACK_COLOR_SCREEN, 
            LINE_COLOR_SCREEN = AlumCloudDrawing.DrawingOptions.LINE_COLOR_SCREEN, 
            BACK_COLOR = AlumCloudDrawing.DrawingOptions.BACK_COLOR, 
            LINE_COLOR = AlumCloudDrawing.DrawingOptions.LINE_COLOR; 

답변

1

나는 보통이 패턴

/src 
    FooApp.sln      -- solution file 
    /apps       -- folder for apps 
     /FooApp.Core     -- core project 
     /FooApp.Drawing1    -- project that references core 
     /FooApp.Drawing2    -- project that references core  
    /tests       -- tests 
     /FooApp.Core.Test 
     /FooApp.Drawing1.Test 
     /FooApp.Drawing2.Test 
+0

그래서 다음 나는 그냥 정적 라이브러리에서 상수 서로 라이브러리와 정적 상수를 사용하는 것이 참조를 가질 수있는 꿈 것 같아 마치 그들이 지역 색이었습니다. 색 색상 = MyConstants.BACK_COLOR –

+0

왜 안 되니? 정적 변수가 보이는지 확인해야합니다. 즉,'internal' =>'public'을 변경하면됩니다. – oleksii