2017-02-21 15 views
0

画像の拡大機能を画像ボックスに追加しました。私は画像のスケールを表示したいと思います(マップの左下のように)。どうすればそれを達成できますか?画像ボックスに画像の縮尺を表示する方法

+0

私たちは、あなたがUIにあなたが実装され、ズーム機能に行われたアクションを反映するために求めているので、その答えにするためのズーム機能を知っていなければならないと思います。 – KernelMode

+0

あなたの問題を解決しましたか? – TaW

答えて

0

Paintイベントを使用すると、スケールを上に描画できます。ズームを想定し

が、これは一例になりX、Y方向に対称である:

private void pictureBox1_Paint(object sender, PaintEventArgs e) 
{ 
    float zoom =100f * pictureBox1.ClientSize.Width/pictureBox1.Image.Width; 
    // this may or may not be necessary, depending on how to have implemented zooming! 
    if (pictureBox1.SizeMode == PictureBoxSizeMode.Normal) zoom = 100f; 

    string s = zoom.ToString("#.#")+ "%"; 
    StringFormat format = new StringFormat() 
     { LineAlignment = StringAlignment.Far, 
     Alignment = StringAlignment.Far }; 
    Rectangle bounds = pictureBox1.ClientRectangle; 
    Rectangle bounds1 = pictureBox1.ClientRectangle; 
    bounds1.Offset(1, 1); 

    using (Font font = new Font("Consolas", 14f)) 
    { 
     e.Graphics.DrawString(s, font, Brushes.White, bounds , format); 
     e.Graphics.DrawString(s, font, Brushes.Black, bounds1 , format); 
    } 
} 

あなたが好きあなたにアライメントを選ぶことができます。任意の背景を可能にするために1つのピクセルずつオフセット私は黒に一度白と1回、2回、文字列を描画

注..また

Imageに注意してはoistrichです。風景は、(スケーリングされていないBackgroundImageです!

enter image description hereenter image description here

+0

ありがとう!これが助けになりました。 – Illuminati0x5B

関連する問題