[C#] Aiuto esportazione tema su libreria di classe ( dll )

Sevenjeak

Utente Attivo
27 Nov 2012
81
2
8
35
sevenjeak.altervista.org
Salve,

Sto, da qualche giorno, rifacendo un mio browser multi scheda, che tempo fa, quando era ancora aperto megaupload, avevo realizzato in vb.net.

Ora, piuttostoc che ripartire dal browser che avevo fatto in vb.net, ne sto progettando un'altro da zero, ma in c#, con un tema personalizzato, quindi, ho subito iniziato a generare il tema del mio programma, in un file contenuto nello stesso progetto, posto qui sotto il codice del tema, almeno quello che ho realizzato fino ad ora:

Codice:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;

abstract class cnControl :  ContainerControl
{
    protected Bitmap _Bitmap;
    protected Graphics _Graphics;

    protected SolidBrush brushTitle = new SolidBrush(Color.FromArgb(103, 112, 120));
    protected Color bgControl = Color.FromArgb(191, 203, 222);
    protected Color borderColor = SystemColors.ActiveBorder;
    protected Color borderColorActive = SystemColors.ActiveCaption;

    protected bool elementFocus, mouseHover, mousePress = False;
    protected int pointerX, pointerY;

    public cnControl()
    {
        SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
    }

    [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
        (
            int nLeftRect, // x-coordinate of upper-left corner
            int nTopRect, // y-coordinate of upper-left corner
            int nRightRect, // x-coordinate of lower-right corner
            int nBottomRect, // y-coordinate of lower-right corner
            int nWidthEllipse, // height of ellipse
            int nHeightEllipse // width Of ellipse
    );

    protected void DrawCorner(PaintEventArgs e, Border3DStyle style)
    {
        Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 10, 10));

        Rectangle borderCorner = ClientRectangle;

        ControlPaint.DrawBorder3D(e.Graphics, borderCorner, style);
    }
}

class cnForm :  cnControl
{
    private Point lastPoint;

    public cnForm()
    {
    Dock = DockStyle.Fill;
    BackColor = bgControl;
    Padding = new Padding(3, 25, 3, 3);
    }

    protected sealed override void OnHandleCreated(EventArgs e)
    {
        base.OnHandleCreated(e);

        FindForm().BackColor = SystemColors.Control;
        FindForm().TransparencyKey = SystemColors.Control;
        FindForm().FormBorderStyle = 0;
    }

    protected override void OnMouseDown(MouseEventArgs e)
    {
        base.OnMouseDown(e);

        this.lastPoint = e.Location;
    }

    protected override void OnMouseUp(MouseEventArgs e)
    {
        base.OnMouseUp(e);
    }

    protected override void OnMouseMove(MouseEventArgs e)
    {
        base.OnMouseMove(e);

        pointerX = e.X;
        pointerY = e.Y;

        if(e.Button == MouseButtons.Left)
        {
            FindForm().Left += e.X - lastPoint.X;
            FindForm().Top += e.Y - lastPoint.Y;
        }

        Invalidate();
    }

    protected override void OnMouseClick(MouseEventArgs e)
    {
        base.OnMouseClick(e);

        #region "Form Control Button"

        /* ---------------------- SET CLOSE BUTTON ------------------------ */
        Rectangle ButtonCloseRange = new Rectangle(Width - 23, 6, 15, 17);

        if(ButtonCloseRange.Contains(new Point(pointerX, pointerY)) && e.Button == MouseButtons.Left) FindForm().Close();

    /* ---------------------- SET MAXIMEZE BUTTON ------------------------ */
    Rectangle ButtonMinMaxRange = new Rectangle(Width - 52, 6, 13, 15);

    if(ButtonMinMaxRange.Contains(new Point(pointerX, pointerY)) && e.Button == MouseButtons.Left)
        {
        if(FindForm().WindowState == FormWindowState.Maximized)
                FindForm().WindowState = FormWindowState.Normal;
        else
            FindForm().WindowState = FormWindowState.Maximized;
    }

    /* ---------------------- SET MINIMEZE BUTTON ------------------------ */
    Rectangle ButtonMinRange = new Rectangle(Width - 76, 6, 13, 15);

    if(ButtonMinRange.Contains(new Point(pointerX, pointerY)) && e.Button == MouseButtons.Left) FindForm().WindowState = FormWindowState.Minimized;

    #endregion
}

protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    _Bitmap = new Bitmap(Width, Height);
    _Graphics = Graphics.FromImage(_Bitmap);

    DrawCorner(e, Border3DStyle.Raised);

    _Graphics.DrawIcon(new Icon(FindForm().Icon, 10, 10), 10, 10);
    _Graphics.DrawString(FindForm().Text, new Font("arial", 10), brushTitle, 28, 10);

    #region "Control button"

    /* ---------------------- SET CLOSE BUTTON ------------------------ */
    Rectangle ButtonCloseRange = new Rectangle(Width - 26, 6, 13, 15);
    //_Graphics.DrawRectangle(New Pen(New SolidBrush(Color.Red)), ButtonCloseRange);

    if(ButtonCloseRange.Contains(new Point(pointerX, pointerY)))
            _Graphics.DrawImage(new Bitmap(CrossNet.Properties.Resources.close_hover), new Point(Width - 25, 9));
    else
            _Graphics.DrawImage(new Bitmap(CrossNet.Properties.Resources.close), new Point(Width - 25, 9));

    /* ---------------------- SET MAXIMEZE BUTTON -------------------- */
    Rectangle ButtonMinMaxRange = new Rectangle(Width - 52, 6, 13, 15);
    //_Graphics.DrawRectangle(New Pen(New SolidBrush(Color.Orange)), ButtonMinMaxRange);

    if(ButtonMinMaxRange.Contains(new Point(pointerX, pointerY)))
            _Graphics.DrawImage(new Bitmap(CrossNet.Properties.Resources.minmax_hover), new Point(Width - 50, 9));
    else
            _Graphics.DrawImage(new Bitmap(CrossNet.Properties.Resources.minmax), new Point(Width - 50, 9));


    /* ---------------------- SET MINIMEZE BUTTON -------------------- */
    Rectangle ButtonMinRange = new Rectangle(Width - 76, 6, 13, 15);
    //_Graphics.DrawRectangle(New Pen(New SolidBrush(Color.Orange)), ButtonMinRange);

    if(ButtonMinRange.Contains(new Point(pointerX, pointerY)))
            _Graphics.DrawImage(new Bitmap(CrossNet.Properties.Resources.minimeze_hover), new Point(Width - 75, 9));
    else
            _Graphics.DrawImage(new Bitmap(CrossNet.Properties.Resources.minimeze), new Point(Width - 75, 9));

    #endregion

    e.Graphics.DrawImage(_Bitmap, 0, 0);
    _Bitmap.Dispose();
    _Graphics.Dispose();


}
}

Premettendo che, il codice lo scritto personalmente io, escluso la parte del DLLImport, quello lo presa da internet.

Cmq, il codice qui sopra non mi da nessun problema, fino a quando rimane nello stesso progetto, ma se, voglio inserirlo in una libreria di classe mi restituisce alcuni errori, che vi allego in un file di testo qui sotto, visto che non me le fa postare, mi dice che il messaggio che vi elenco in questo link:

https://mega.nz/#!NwExWYZR!i6IopcLbINDpjSUakNLQCqOq5cxbLvvNE2o4ZBy4f1Q

Dato che, scrivendoli nella discussione non mi fa postare il tutto per la lunghezza del messaggio.

Non so se ho spiegato bene il mio problema, ma come potrei risolvere tutto ciò?
 
Discussioni simili
Autore Titolo Forum Risposte Data
N Aiuto esportazione logo a photoshop a web! Photoshop 4
E Aiuto per query PHP 8
R Aiuto ripristino sito web Presentati al Forum 0
L Aiuto con DataGridView Visual Basic 1
F Aiuto! cambio immagine di sfondo al cambio pagina HTML e CSS 2
I aiuto urgente per thunderbird Posta Elettronica 0
I aiuto per outlook Posta Elettronica 0
D aiuto funzioni javascript Javascript 1
T aiuto per trasformare un quiz fatto in JS in un quiz in JQUERY jQuery 0
D Aiuto CSS in ELEMENTOR - Cambiare un testo CMS (Content Management System) 0
M Fullcalendar in Codeigniter, un aiuto per la chiamata $ajax ? jQuery 0
K Aiuto con file audio in html HTML e CSS 1
G Script notifiche dekstop aiuto Javascript 0
P Aiuto per rendere un Bot Telegram Privato PHP 1
M Un aiuto da chi ha apple Mac e Software 0
P Richiesta di aiuto Presentati al Forum 1
A Aiuto per pagina php PHP 0
M Questa pagina non carica correttamente Google Maps: aiuto!! HTML e CSS 1
I Aiuto php Dependent Lookup PHP 0
R Aiuto con le query MS Access 2
M AIUTO ESERCIZIO JAVA Javascript 1
G Aiuto con htaccess e rewriterule PHP 0
T cercasi aiuto per file d1 (open-edge db) Database 0
M Aiuto con inserimento immagini WordPress 6
D aiuto schermata photoshop Photoshop 0
L Aiuto per programma web php/mySQL PHP 2
A Aiuto php colore diverso PHP 10
L Aiuto creazione menu mancante WordPress 0
C Aiuto compiuto scuola PHP/MySQL PHP 2
G Insert into select - Aiuto MySQL 0
I Aiuto bash linux Programmazione 1
F Aiuto java script Javascript 2
R Cerco aiuto Offerte e Richieste di Lavoro e/o Collaborazione 7
I Aiuto query MySQL 8
G Aiuto HTML, collegamento con un bottone a una <div> di un' altra pagna HTML e CSS 5
motleyrulez Aiuto con un ciclo PHP 0
R Aiuto sito html Offerte e Richieste di Lavoro e/o Collaborazione 3
claudio_lorenzo [Javascript] aiuto su jquery per calcolo altezze dom Javascript 1
G Mi dite come faccio? Aiuto photoshop ? Photoshop 1
C prestashop paragamento contrassegno aiuto modulo E-Commerce 0
Michelebozzo [PHP] Rimuovere pubblicazione nome pagina ... aiuto! PHP 7
Caldus richiesta aiuto Mac e Software 0
R [Javascript] Aiuto su questo script Javascript 2
Z Gestionale in Php/mysql: Quanto farsi pagare? Aiuto! Discussioni Varie 0
Giacomo92 [HTML] AIUTO!! Regular Expression :( Offerte e Richieste di Lavoro e/o Collaborazione 15
T Aiuto per php7 e mysqli PHP 3
T mysql tutorial per importare tabelle access in mysql aiuto MySQL 2
K [Java] aiuto switch case Java 1
E salve tutti spero si essere di aiuto e di trovare aiuto Presentati al Forum 2
D [MS Access] aiuto non riesco a capire MS Access 6

Discussioni simili