将achartengine移植到Xamarin

时间:2014-06-26 09:09:35

标签: c# xamarin xamarin.android achartengine

我正在尝试将achrtengine库移植到Xamarin.Droid。

我所做的是: -

1-创建一个新的Android Java Bindings Library项目。 2-将.jar添加到Jars文件夹。 3-将构建操作设置为EmbededJar

但得到了这个错误: -

'Pan': member names cannot be the same as their enclosing type

在这一行:

public event EventHandler Pan {
            add {
                global::Java.Interop.EventHelper.AddEventHandler<global::Org.Achartengine.Tools.IPanListener, global::Org.Achartengine.Tools.IPanListenerImplementor>(
                        ref weak_implementor_AddPanListener,
                        __CreateIPanListenerImplementor,
                        AddPanListener,
                        __h => __h.Handler += value);
            }
            remove {
                global::Java.Interop.EventHelper.RemoveEventHandler<global::Org.Achartengine.Tools.IPanListener, global::Org.Achartengine.Tools.IPanListenerImplementor>(
                        ref weak_implementor_AddPanListener,
                        global::Org.Achartengine.Tools.IPanListenerImplementor.__IsEmpty,
                        RemovePanListener,
                        __h => __h.Handler -= value);
            }
        }

我认为这是因为班级名称也是Pan

// Metadata.xml XPath class reference: path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']"
    [global::Android.Runtime.Register ("org/achartengine/tools/Pan", DoNotGenerateAcw=true)]
    public partial class Pan : global::Org.Achartengine.Tools.AbstractTool {

更新: -

我插入此行来解决此问题

<attr path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']" name="name">PanClass</attr>

更改班级的名称。

但是遇到了这些错误: -

Error CS0019: Operator '==' cannot be applied to operands of type 'AChartEngine.Renderer.XYSeriesRenderer.FillOutsideLine.Type' and 'System.Type' (CS0019) (AChartEngineBindings)

Error CS1503: Argument 2: cannot convert from 'string' to 'System.IntPtr' (CS1503) (AChartEngineBindings)

谁知道如何解决这个问题?!

任何帮助都很有用。 感谢。

1 个答案:

答案 0 :(得分:3)

我在这里找到了答案:http://forums.xamarin.com/discussion/1935/achartengine-org-jar-binding-error

你应该将它们添加到元数据:

<attr path="/api/package[@name='org.achartengine.renderer']/class[@name='XYSeriesRenderer.FillOutsideLine']/method[@name='getType' and count(parameter)=0]" name="managedName">GetBehaviorType</attr>
    <attr path="/api/package[@name='org.achartengine.renderer']/class[@name='XYSeriesRenderer.FillOutsideLine.Type']" name="managedName">FillOutsideLineBehaviorType</attr>
    <attr path="/api/package[@name='org.achartengine']" name="managedName">AChartEngine</attr>
    <attr path="/api/package[@name='org.achartengine.chart']" name="managedName">AChartEngine.Chart</attr>
    <attr path="/api/package[@name='org.achartengine.model']" name="managedName">AChartEngine.Model</attr>
    <attr path="/api/package[@name='org.achartengine.renderer']" name="managedName">AChartEngine.Renderer</attr>
    <attr path="/api/package[@name='org.achartengine.tools']" name="managedName">AChartEngine.Tools</attr>
    <attr path="/api/package[@name='org.achartengine.util']" name="managedName">AChartEngine.Util</attr>

    <attr path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']/method[@name='addPanListener']" name="eventName">PanEvent</attr>

将FillOutsideLine.GetType()和FillOutsideLine.Type重命名为GetBehaviorType()和FillOutsideLineBehaviorType。

并更改活动名称。

我已经通过示例将源代码添加到github:https://github.com/mostafa-elabady/Xamarin_achartengine