How to use silvermoon for development

Jan 30, 2010 at 10:42 AM
Edited Jan 30, 2010 at 10:47 AM

Hi,

Im rather new to .net compact framework. i have to create a windows mobile and i came across your UI controls.

I have included GdiPlus, OpenGl, and SilverMoon as a new proj. I've evenGdiPlus, OpenGl, and SilverMoon dll files. But im still not sure how to use your controls. Apparently, i've seen others providing very positive feedback to your work. I must have missed out somethings here.

Q:

1. Can I just simply drag and drop ur control from the toolbox. if so how?

2. When i run the demo, it says Can't find PInvoke DLL 'libgles_cm.dll'. on display = egl.GetDisplay(new EGLNativeDisplayType(window)); in file Silvermoon.OpenGl.Devices.cs. why?

3. I create a new proj and added the various class and references. When i run, it prompts an error saying silvermoon.exe does not contain a staitc main Method suitable for an entry  point

 

is there a simple tutorial  on how to use your control for noobs like me?? I just simply need to create a listview when click, it will show another form. 

Feb 23, 2010 at 1:13 PM
Edited Feb 23, 2010 at 1:16 PM

Create a new C# Devcie Application. (Smart Device - Windows Mobile 6 Professional)
Add references to silvermoon dlls (SilverMoon.dll and OpenGL.dll)
In the Form1 (renamed to MainForm) initialize Silvermoon:

using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

using Silvermoon.Animations;
using Silvermoon.Controls;
using Silvermoon.OpenGL;

namespace Test
{
    public partial class MainForm : Form
    {
        public Silvermoon.Core.Screen _screen;

        public MainForm()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            if (_screen != null)
            {
                _screen.Invalidate();
                _screen.Render();
            }
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            _screen = Silvermoon.Core.Screen.Initialize(this);
            _screen.Renderer.BackgroundColor = Color.White;
            _screen.Renderer.Perspective = true;

            TestForm testForm = new TestForm();
            testForm.Color = Color.White;
            testForm.TransitionDuration = 1500;
            testForm.Show(TransitionMode.FadeIn);
        }
    }
}
And the TestForm will be your entry form for your app: (no drag&drop support, create a new class and inherit from Window or Dialog)
using System;
using System.Drawing;

using Silvermoon.Controls;

namespace Test
{
    public class TestForm : Window
    {
        public TestForm()
            : base()
        {
            Initialize();
        }

        private void Initialize()
        {
            ChromeButton cmdTest = new ChromeButton();
            cmdTest.Text = "test";
            cmdTest.Color = Color.DarkCyan;
            cmdTest.Size = new Size(160, 64);
            cmdTest.Margin = new Margin(null, null, 240 + 32, 100);
            cmdTest.Click += new EventHandler(cmdTest_Click);
            Controls.Add(cmdTest);
        }
        void cmdTest_Click(object sender, EventArgs e)
        {
            Screen.Close();
        }
    }
}
To run this app (and any other opengles apps) on the emulator you have to copy the libgles_cm.dll (211KB, in silvermoon demo folder) to the emulator's /windows folder.
(save the emulator state so you don't have to this everytime again) This is a software renderer and shouldn't be copied to your device!
It's slow but enough for development. (animations/transitons have to be checked on the device)