0

さまざまな種類のビットマップを描画するための 3 つの Windows ライブラリがあります。それらすべてに共通しているのは、フォント、色、ペンです。

フォントを変更すると、他のすべてのライブラリでグローバルに変更されるように、すべての標準フォント、色、およびペンを使用できるライブラリを設計したいと考えています。

例: ビットマップに描画する 3 つのライブラリがあり、それらはすべて同じ設定を使用します。

      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;

MySolutionNameDrawing という 1 つのライブラリと、これらの設定を使用してビットマップに描画する他のすべてのライブラリを作成したいと考えています。

これもメンテナンス性のためです。

MySolutionName は私のソリューションの名前にすぎませんが、デモの目的で私の主張を理解していると確信しています。

描画関連のツールをすべて 1 つのライブラリにまとめて、混乱させることなく他のライブラリからそれらのツールにアクセスする最も簡単でクリーンな方法について、誰かアイデアを思いついた人はいますか?


これが私が思いついたものです。

描画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 ライブラリに依存するライブラリからの参照を使用します。

 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;
4

1 に答える 1

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
于 2013-05-02T22:29:34.440 に答える