Autor Beitrag
SSC streezer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

WinXP, Vista Ultimate
C# (VS 05 n' 08), PHP
BeitragVerfasst: Mo 27.10.08 15:18 
hallo zusammen,

ich hab einen kleinen konfigurationsdialog geschrieben um die icons anpassen zu können in meinem treeview.

die icons werden schön in den treeview geladen und auch angezeigt.

jedoch stimmt der focus nicht - die icons sind nicht ganz zu sehen - nur immer der obere linke teil.

ich habe bereits diese funktion gefunden welche die images in einer imagebox verkleinert (hab ich auch gebraucht - und funzt auch super):
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
public Bitmap ResizePicByWidth(Image sourceImage, double newWidth)
        {
            double sizeFactor = newWidth / sourceImage.Width;
            double newHeigth = sizeFactor * sourceImage.Height;
            Bitmap newImage = new Bitmap((int)newWidth, (int)newHeigth);
            using (Graphics g = Graphics.FromImage(newImage))
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.DrawImage(sourceImage, new Rectangle(00, (int)newWidth, (int)newHeigth));
            }
            return newImage;
        }


nun würde ich gerne wissen wie man so etwas ähnliches für den treeview macht - also das bild resizen / anpassen...


gruss,
streezer

_________________
>> Swiss Soldiers Clan << visit us
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mo 27.10.08 16:12 
Deine Frage verstehe ich nicht ganz - die Methode ist doch nicht auf PictureBoxes zugeschnitten und sollte genauso gut mit TreeViews funktionieren :?:

_________________
>λ=
SSC streezer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

WinXP, Vista Ultimate
C# (VS 05 n' 08), PHP
BeitragVerfasst: Mo 27.10.08 16:26 
stimmt xD ich könnte dieselbe methode verwenden...

mein problem ist: die grösse der icons im treeview - ich muss der methode ja eine grösse mitgeben welche die output grösse sein soll - und die weiss ich nicht...

weisst du das?

_________________
>> Swiss Soldiers Clan << visit us
SSC streezer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

WinXP, Vista Ultimate
C# (VS 05 n' 08), PHP
BeitragVerfasst: Mo 27.10.08 16:58 
jau hat geklappt:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
        private void PruefePfadContextMenuIcon(string setting, Bitmap button, ToolStripMenuItem contextMenuButton)
        {
            if (setting != "")
            {
                button = new Bitmap(setting);
                ResizeImage resizer = new ResizeImage();
                contextMenuButton.Image = resizer.ResizePicByWidth(button, 16.0);
            }
        }


ausblenden C#-Quelltext
1:
2:
            Bitmap exportbutton = null;
            PruefePfadContextMenuIcon(Settings.Default.ExportButton, exportbutton, nodeExportierenToolStripMenuItem);

_________________
>> Swiss Soldiers Clan << visit us