Je travaille sur un projet de bibliothèque de classes pdf. Je crée une classe abstraite de base pour tous les processus de sortie.Problème d'implémentation de méthode abstraite VC++/CLI pour C#
Voici le code:
public ref class PDFPrinter
{
internal:
int index;
SPDFPrinter* p;
public:
PDFPrinter();
virtual property int HorizontalDPI { int get(){ return 72; } }
virtual property int VerticalDPI { int get(){ return 72; } }
virtual property bool UseMediaBox { bool get(){ return true; } }
virtual property bool CropPage { bool get(){ return true; } }
virtual property Second::PDF::PageRotation PageRotation
{ Second::PDF::PageRotation get()
{return Second::PDF::PageRotation::Rotate0; }
}
virtual property bool IsUpsideDownCoordinateSystem { bool get() = 0; }
virtual property bool CanUseDrawChar { bool get() = 0; }
virtual property bool IsType3CharsInterpretted { bool get() = 0; }
virtual property bool CanUseTilingPatternFill { bool get() = 0; }
virtual property bool CanUseShadedFills{ bool get() = 0; }
virtual property bool CanUseDrawForm{ bool get() = 0; }
virtual property bool CanResolveText { bool get() = 0; }
virtual property bool CanCreateAntialiasedVectors { bool get() = 0; }
virtual bool CanDrawPageSlice(PDFPage page,
System::Drawing::PointF resolution, Second::PDF::PageRotation rotation,
System::Drawing::Rectangle slice, bool useMediaBox,
bool cropEnabled, bool isPrinting) = 0;
};
et voici les métadonnées:
using System;
using System.Drawing;
namespace Second.PDF
{
public abstract class PDFPrinter
{
public PDFPrinter();
public abstract bool CanCreateAntialiasedVectors { get; }
public abstract bool CanResolveText { get; }
public abstract bool CanUseDrawChar { get; }
public abstract bool CanUseDrawForm { get; }
public abstract bool CanUseShadedFills { get; }
public abstract bool CanUseTilingPatternFill { get; }
public virtual bool CropPage { get; }
public virtual int HorizontalDPI { get; }
public abstract bool IsType3CharsInterpretted { get; }
public abstract bool IsUpsideDownCoordinateSystem { get; }
public virtual PageRotation PageRotation { get; }
public virtual bool UseMediaBox { get; }
public virtual int VerticalDPI { get; }
public abstract bool CanDrawPageSlice(PDFPage page, PointF resolution,
PageRotation rotation, Rectangle slice, bool useMediaBox,
bool cropEnabled, bool isPrinting);
}
}
lorsque je tente d'utiliser cette classe en C# comme ceci:
class Printer : PDFPrinter
{
public override bool CanCreateAntialiasedVectors
{
get { throw new NotImplementedException(); }
}
public override bool CanResolveText
{
get { throw new NotImplementedException(); }
}
public override bool CanUseDrawChar
{
get { throw new NotImplementedException(); }
}
public override bool CanUseDrawForm
{
get { throw new NotImplementedException(); }
}
public override bool CanUseShadedFills
{
get { throw new NotImplementedException(); }
}
public override bool CanUseTilingPatternFill
{
get { throw new NotImplementedException(); }
}
public override bool IsType3CharsInterpretted
{
get { throw new NotImplementedException(); }
}
public override bool IsUpsideDownCoordinateSystem
{
get { throw new NotImplementedException(); }
}
public override bool CanDrawPageSlice(PDFPage page,
System.Drawing.PointF resolution, PageRotation rotation,
System.Drawing.Rectangle slice, bool useMediaBox,
bool cropEnabled, bool isPrinting)
{
throw new NotImplementedException();
}
}
Je reçois cette étrange erreur:
Erreur 1 'Second.PDFLib.CSharp.Test.Printer' n'a pas hérité abstrait METTRE EN ŒUVRE membre 'Second.PDF.PDFPrinter.CanDrawPageSlice()' C: \ Projects \ de Visual Studio \ test \ Second.PDFLib .CSharp.Test \ Program.cs 8 11 Second.PDFLib.CSharp.Test
erreur 2 « Second.PDFLib.CSharp.Test.Printer.CanDrawPageSlice (Second.PDF.PDFPage, System.Drawing.PointF, Second.PDF.PageRotation, System.Drawing.Rectangle, bool, bool, bool) ': aucune méthode appropriée trouvée à override C: \ Projects \ Visual Studio \ test \ Second.PDFLib.CSharp.Test \ Program.cs 51 30 Second.PDFLib.CSharp.Test
Avez-vous une idée pour corriger cette erreur?
Merci
P.S: Seule cette méthode abstraite (CanDrawPageSlice) génère des erreurs. Il n'y a pas de problème sans cette méthode.
EDIT
Honte! La honte! La honte! Honte sur moi! :) C'est complètement mon erreur!
Je compris .. source de problème est C++ classe
J'ai oublié d'utiliser l'opérateur de niveau supérieur (^) ici (page de PDFPage)
virtual bool CanDrawPageSlice(PDFPage page,
System::Drawing::PointF resolution, Second::PDF::PageRotation rotation,
System::Drawing::Rectangle slice, bool useMediaBox,
bool cropEnabled, bool isPrinting) = 0;
il devrait être comme:
virtual bool CanDrawPageSlice(PDFPage^ page,
System::Drawing::PointF resolution, Second::PDF::PageRotation rotation,
System::Drawing::Rectangle slice, bool useMediaBox,
bool cropEnabled, bool isPrinting) = 0;
Avez-vous généré le remplacement en tapant override et en laissant VS peupler la liste des paramètres, ou l'avez-vous tapé vous-même?Est-il possible que la classe de base prenne différentes classes pour les 4 premiers paramètres? –
Juste utilisé l'option "Implémenter la classe abstraite 'PDFPrinter'". Je veux dire qu'il est généré automatiquement. –
prenez votre solution, répondez à votre propre question, puis sélectionnez la bonne réponse. Peut sembler un peu étrange ou ringard, mais c'est la procédure standard ici pour cela. – Will