maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   HOWTO: C# compiling on the unit itself (https://talk.maemo.org/showthread.php?t=17119)

pipeline 2008-02-24 16:39

HOWTO: C# compiling on the unit itself
 
(Revised 3/22) For free c# programming ebook (pdf) click here

Here's the quick howto for setting up Mono 'compile-on-device' for OS2008/7 (not sure about 2006)

Step 1 :
Add mono repo : (name 'Mono', web address 'http://go-mono.com/maemo', distribution 'bora', components 'user')
Install mono-runtime and publicly-available mono libraries (this first iteration uses 1.0 libaries)
- Install mono-runtime
- Install gtk-sharp2
- Install libmono-system1.0-cil
- Optional grab all the other mono libs since they take up so little space
(close app manager)

Step 2 :
Install my deb of mono pkg-config files (needed for 'linking' against libs) :
http://wardenclyffetower.com/MaemoFi...-1.2.5.all.deb

Step 3 :
Install my deb of the mono compilers (since not available from mono maemo repo) :
http://wardenclyffetower.com/MaemoFi...-1.9.0.all.deb

Step 4 :
Enable red pill mode in the App Manager and then install this (pkg-config utility) :
http://wardenclyffetower.com/MaemoFi....2-1_armel.deb
Now go back into blue pill mode in app manager... and your done.

You can now natively compile mono gtk apps on device.

Step 5 :
Underneath your home directory create a new directory to work in.
Create hello.cs file there containing :
Code:

using System;

namespace CSharpFriends
{
    class Class1
    {
        ///
        /// The main entry point for the application.
        ///   
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World");   
        }
    }
}

Then compile it with mcs hello.cs and run it with mono hello.exe.


If you use namespaces in other assemblies, make sure you not only include the namespace but add the package to the compile command line.

For example a gtk/glade application will need to be compiled with :
mcs myappname.cs -pkg:gtk-sharp-2.0 -pkg:glade-sharp-2.0

fatdat888 2008-02-29 14:06

Re: HOWTO: C# compiling on the unit itself
 
Hi,

I went through the steps but when I try to compile, I get the following:

Package gtk-sharp-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing 'gtk-sharp-2.0.pc' to the PKG_CONFIG_PATH environment variable.

pipeline 2008-02-29 15:46

Re: HOWTO: C# compiling on the unit itself
 
My mistake the directory to copy to in step 3 is /usr/lib/pkgconfig.

Can you place those step 3 files there, verifying gtk-sharp-2.0.pc file is one of them, and try again.

BTW Glade rocks with this setup :) But thats a separate lib/pc file to include on compile line.

pipeline 2008-03-01 22:02

Re: HOWTO: C# compiling on the unit itself
 
1 Attachment(s)
I have written a sample program which i actually needed. It's only half-designed to be a sample and the other half complex network and parsing for real world application.

Its a program which (every 5 minutes) will check for new email on a pop email server and if you have new mail it will launch flite (separate speech synthesis program) to announce their 'From' and 'Subject' lines.

So you will need flite installed, and the mono, gtksharp, and pretty much install all the 1.0 libraries.

You also need to edit the glade file and set the default text of server, username, and password GtkEntry controls to your pop mail server settings.

It demonstates glade, launching processes, timers, string parsing/manipulation, and network streams (more advanced)

This sample used information from :
- This sample : http://www.codeproject.com/KB/IP/popapp.aspx
- This tutorial : http://nat.org/demos/gtksharp.html (<- Highly Recommend watching this!)

To rework (with help from flite) into this sample.

I've put up the source files (along with exe for those that just want to run it without compile) here :
http://wardenclyffetower.com/MaemoFiles/mono/samples/

(grab either tar or zip ... they are the same)

To compile :
mcs popmail-announcer.cs -pkg:gtk-sharp-2.0 -pkg:glade-sharp-2.0

To run :
mono popmail-announcer.exe

psykosis 2008-03-07 14:31

Re: HOWTO: C# compiling on the unit itself
 
Very much cool! Since this appears to be one of about next to zero sources of information about Mono on Maemo on the net - is there documentation anywhere on maemo-sharp?

pipeline 2008-03-07 17:15

Re: HOWTO: C# compiling on the unit itself
 
I haven't looked into maemo-sharp since the library version in the repo is bindings for maemo 2.2 (os2006). For most tasks that library is not needed and reduces portability, but that doesn't answer your question. I havent found an api for that lib and am not sure it would still be applicable on os 2008.

I'm trying to get/build newer libs to work and find out what plans the maintainer (Everaldo Canuto) has for releasing new builds. I'll pass on any info i get on that or you can check his blog here :
http://ecanuto.blogspot.com/

psykosis 2008-03-08 17:03

Re: HOWTO: C# compiling on the unit itself
 
Actually, Pipeline, I think you answered the question better than supplying the API - since I am also running OS2008 and I agree, it is doubtful that is overly useful to us.

Hopefully there will be more movement on porting Mono to OS2008 in it's entirety. In my searches, it seems someone was working on compiling the GDI libs, which I believe is our lacking as far as utilizing winforms.

pipeline 2008-03-21 02:16

Re: HOWTO: C# compiling on the unit itself
 
Update on mono developments :

Mono 1.9 libraries are currently in test and they look look really good.

They fixed my serialization and iterator issues and in general it looks very capable.

Additionally i am testing hacking together mono xsp server. Mono XSP is lightweight ASP.net server. I am still researching this and copying the files manually (they are all managed code libraries/executables... not maemo/arm specific).

Its too soon to say but there could possibly be winforms.

So things look like they are shaping up for nice 1.9 release. If you are willing to provide everaldo some feedback, drop him a message. If you just want to test out these unofficial 1.9 builds, p.m. me for repo info.

mscdex 2008-03-21 04:53

Re: HOWTO: C# compiling on the unit itself
 
This is slightly offtopic but, is there vb.net support for the current version of mono for maemo or at least planned support for it?

pipeline 2008-03-21 11:28

Re: HOWTO: C# compiling on the unit itself
 
Ok well the runtime (which is what they distribute in repos) includes no compilers at all (at least officially at the moment).

But compilers are managed code... meaning the work the same on x86/Macs/or even ARM linux devices... they just need relevant system runtime and libraries. So i pretty much grabbed the c# (mcs and gmcs) compilers (.exe's) from an actual mono x86 installation or devkit. Additionally there are msbuild libraries and webserver libraries (System.Web)... all waiting to be enabled on arm maemo :) I could use help though... but with 1.9 this looks like alot of potential.

So i'd guess you could use mono's Vbnc.exe compiler to compile against the 2.0 framework (no vb support for 1.0) but you probably wouldnt have visual basic specific namespaces (libraries). I'll test it out later but you probably grab out of a real mono installation.

Libararies are probably managed code though so once i figure out (or stumble onto) proper way to install them to gac, then probably any existing mono library including mono vb specific libraries can be added. So (I think) even old assemblies you may have built years ago on windows could be copied an run on maemo if they themselves use only namespaces which are in repo or hacked onto device.

pipeline 2008-03-22 15:45

Re: HOWTO: C# compiling on the unit itself
 
Well i mentioned that i compiled mono xsp (lightweight asp.net server) and got it running.

I made a swf video of it here :
http://wardenclyffetower.com/MaemoFi...s/monoasp.html

Cool stuff :) Its important for me to mention that the pages load so fast because the server has already run them before. The first time the pages load they are very slow (like 15sec - 1+ mins). But i'm more focused on functionality and ease of use right now.

If xsp servers aren't added to official 1.9 release then i will put a deb installer together for us maemo users (when 1.9 is officially released)

b-man 2008-03-22 16:48

Re: HOWTO: C# compiling on the unit itself
 
I've just installed the compiler that you provided and i would like to know ware can i get documentation on how to use this. Do you know ware i can obtain the documentation?
I've just started to lern how to compile with c++ and am looking forward to start using this.:D

pipeline 2008-03-22 17:14

Re: HOWTO: C# compiling on the unit itself
 
Yes c# is similar to c++ but its not the same. It is much easier to learn and the libraries are easier simpler to use.

Currently though most documentation covers winforms which is the windows way of creating/layout of forms, which as of right now is not available on maemo (although maybe soon :) ).

For now the compiler environment is to use gtk/glade to layout forms (this is more 'native-linux' way anyways). And then you code the handlers in c#.

Things are changing right now with newer version of mono in test, but go ahead and try to compile the sample i have above and run it (install flite too).

For now, i am using emelfm2 to launch compiler scripts, simple editing of source code, and launching the exe with mono runtime (i manually associated this so not in current download of emelfm2).

Hopefully once this next version is released, i will have nicer debs and possibly emelfm2 helpers to coordinate, but for now i usually end up using openssh from desktop to edit source files and set up glade files (ubuntu synaptic package glade-2).

Here is a good book for learning c# (in general), keep in mind some of it will be talking about winforms and it wont cover gtk/glade.
http://books.google.com/books?hl=en&...Ut-eUg#PPP1,M1

For mono documentation you can look here :
http://www.go-mono.com/docs/
http://www.mono-project.com/GtkSharp:_Hello_World

So basically the user interface can be either :
- console app
- gtk (where you add the controls in code)
- glade (best way to visually design forms to use with gtk/glade)
- winforms (may soon be available for maemo as it already is for x86 mono)
- webforms (where the program runs with a mini-webserver serving up webpages)

I'd recommend starting to learn with console apps, gtk, or glade for now.

zybook 2008-03-24 03:47

Re: HOWTO: C# compiling on the unit itself
 
very thanks pipeline,

i can compile cs file sucessful in my n800.

only a question, how can i add my exe file "ShortCut" in the Extras menu?

i don't want to key "mono xxx.exe" every time.

thanks.

pipeline 2008-03-24 04:26

Re: HOWTO: C# compiling on the unit itself
 
Is it a console app? If so i dont think you can.

If you've actually compiled a gtk/glade app with a window then you can setup a desktop file for it.

You should create a script like :
Code:

#!/bin/sh
cd /home/user/code/myappdir
mono myapp.exe

Set execute permission on it :
chmod 755 mylaunchscript

And point desktop to launch script

If you dont know how to make a desktop file then you can use LinkMaker utility (it needs python) and you will have to run 'LinkMakerAllow' as root before it can create the links.

zybook 2008-03-24 05:47

Re: HOWTO: C# compiling on the unit itself
 
thank pipeline's reply.

i will try it later.

now i have a question about compile, if my cs file only include "using Gtk;", so i can compile it sucess by "mcs hello.cs -pkg:gtk-sharp-2.0", but if cs file include" using Gtk;using Gdk;using Gnome;", how can i compile it by mcs?

thanks.

pipeline 2008-03-24 11:53

Re: HOWTO: C# compiling on the unit itself
 
Um never used gnome namespace... try just -pkg:gtk-sharp and it should suggest any packages that you didnt include... let me know their names.

I dont think its 1 namespace per package so its possible those (or one of those) dont need extra packages.

b-man 2008-03-25 00:57

Re: HOWTO: C# compiling on the unit itself
 
Does the program need too be in user or in root? Because when i use my notes application in planetext mode to create the program then transfer that planetext file to my ScITE programing editor put it in c# language then save the file under the mcs directory and open my emelFM2 file manager but my program witch i created had a owner as user not root. So when i tryed to compile it said compileation failed is the problem because the program is under user not root or could it be something else rong? I know that i rote the program correctly.
And one more question, how do i save the file as root in the first place?

pipeline 2008-03-25 01:21

Re: HOWTO: C# compiling on the unit itself
 
For the -current- version of mono i think you should install the deb file i made for compilers here :
http://wardenclyffetower.com/MaemoFi...-1.9.0.all.deb

This wont be necessary when 1.9 is officially released because they are making repo packages for compilers themselves :)

With that installed you dont need mcs directory, set up your own source directory or directory tree without compilers in it.

Then you can copy your source files to any directory you want and compile like :
mcs hello.cs -pkg:gtk-sharp-2.0

Your source code files should be owned by user (or user should have write permission to them) so if user doesnt have permission, then sudo gainroot and run emelfm2 (as root from xterm) find the file, highlight it, hit menu key for context menu, choose actions submenu, change permissions, and click the 'write' checkbox for all three user groups... then exit emelfm2 and exit xterm

pipeline 2008-03-25 02:42

Re: HOWTO: C# compiling on the unit itself
 
2 Attachment(s)
This is too cool... i wrote a simple windows forms app to refresh a couple webcams using Microsoft Visual Studio 2003 and the same exe file runs on both windows and maemo :) So windows forms/gdi will be in 1.9 and im running it... currently only works with 1.1 but hopefully 2.0 will be fixed. I have compiled several winforms apps on maemo so i expect the source will compile just as easily.

This will allow me to quickly generate alot of functional apps to fill void.

zybook 2008-03-25 03:13

Re: HOWTO: C# compiling on the unit itself
 
congratulation you, pipeline:

it is very great. how can u do it in vs2003?

zybook 2008-03-25 03:29

Re: HOWTO: C# compiling on the unit itself
 
pipeline:

I can compile the demo source sucessful in my xp2 mono, but i can not compile it in the n800. can u help me? thanks. here is the code.

// Canvas.cs - port of standard GNOME canvas demo
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
// (c) 2002 Rachel Hestilow

namespace GtkSamples {

using Gnome;
using Gtk;
using Gdk;
using System;

public class CanvasExample {
private int width = 400, height = 400;
private double remember_x = 0.0, remember_y = 0.0;

private Canvas canvas;
private Random random = new Random ();

public CanvasExample () {
Gtk.Window win = new Gtk.Window ("Canvas example");
win.DeleteEvent += new DeleteEventHandler (Window_Delete);

VBox vbox = new VBox (false, 0);
win.Add (vbox);

vbox.PackStart (new Label ("Drag - move object.\n" +
"Double click - change color\n" +
"Right click - delete object"),
false, false, 0);

canvas = new Canvas ();
canvas.SetSizeRequest (width, height);
canvas.SetScrollRegion (0.0, 0.0, (double) width, (double) height);
vbox.PackStart (canvas, false, false, 0);

HBox hbox = new HBox (false, 0);
vbox.PackStart (hbox, false, false, 0);

Button add_button = new Button ("Add an object");
add_button.Clicked += new EventHandler (AddObject);
hbox.PackStart (add_button, false, false, 0);

Button quit_button = new Button ("Quit");
quit_button.Clicked += new EventHandler (Quit);
hbox.PackStart (quit_button, false, false, 0);

win.ShowAll ();
}

void Swap (ref double a, ref double b) {
double tmp = a;
a = b;
b = tmp;
}

void AddObject (object obj, EventArgs args)
{
double x1 = random.Next (width);
double y1 = random.Next (height);
double x2 = random.Next (width);
double y2 = random.Next (height);

if (x1 > x2)
Swap (ref x1, ref x2);

if (y1 > y2)
Swap (ref y1, ref y2);

if ((x2 - x1) < 10)
x2 += 10;

if ((y2 - y1) < 10)
y2 += 10;

CanvasRE item = null;
if (random.Next (2) > 0)
item = new CanvasRect (canvas.Root ());
else
item = new CanvasEllipse (canvas.Root ());

item.X1 = x1;
item.Y1 = y1;
item.X2 = x2;
item.Y2 = y2;
item.FillColor = "white";
item.OutlineColor = "black";
item.WidthUnits = 1.0;

item.CanvasEvent += new Gnome.CanvasEventHandler (Item_Event);
}

void ChangeItemColor (CanvasRE item)
{
string[] colors = new string[] {"red", "yellow", "green", "cyan", "blue", "magenta"};
item.FillColor = colors[random.Next (colors.Length)];
}

void Item_Event (object obj, Gnome.CanvasEventArgs args) {
EventButton ev = new EventButton (args.Event.Handle);
CanvasRE item = (CanvasRE) obj;

switch (ev.Type) {
case EventType.ButtonPress:
if (ev.Button == 1) {
remember_x = ev.X;
remember_y = ev.Y;
args.RetVal = true;
return;
} else if (ev.Button == 3) {
item.Destroy ();
args.RetVal = true;
return;
}
break;
case EventType.TwoButtonPress:
ChangeItemColor (item);
args.RetVal = true;
return;
case EventType.MotionNotify:
Gdk.ModifierType state = (Gdk.ModifierType) ev.State;
if ((state & Gdk.ModifierType.Button1Mask) != 0) {
double new_x = ev.X, new_y = ev.Y;
item.Move (new_x - remember_x, new_y - remember_y);
remember_x = new_x;
remember_y = new_y;
args.RetVal = true;
return;
}
break;
case EventType.EnterNotify:
item.WidthUnits = 3.0;
args.RetVal = true;
return;
case EventType.LeaveNotify:
item.WidthUnits = 1.0;
args.RetVal = true;
return;
}

args.RetVal = false;
return;
}

void Quit (object obj, EventArgs args)
{
Application.Quit ();
}

void Window_Delete (object obj, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}

public static int Main (string[] args)
{
Application.Init ();

new CanvasExample ();

Application.Run ();
return 0;
}
}
}

b-man 2008-03-25 03:46

Re: HOWTO: C# compiling on the unit itself
 
I tryed thess steps but i got this compilation eror: home/user # cd /home/user/mcs
/home/user/mcs # mcs Hello.cs -pkg:gtk-sharp-2.0
error CS2001: Source file `Hello.cs' could not be found
Compilation failed: 1 error(s), 0 warnings
what did i do wrong?

speaking of witch this is my proogram: it's my own Hello.cs program i made my self frome those web sorses you provided:
using Gtk;
using System;

class Hello {

static void Main()
{
Application.Init ();

// Set up a button object.
Button btn = new Button ("Hello World");
// when this button is clicked, it'll run hello()
btn.Clicked += new EventHandler (hello);

Window window = new Window ("helloworld");
// when this window is deleted, it'll run delete_event()
window.DeleteEvent += delete_event;

// Add the button to the window and display everything
window.Add (btn);
window.ShowAll ();

Application.Run ();
}


// runs when the user deletes the window using the "close
// window" widget in the window frame.
static void delete_event (object obj, DeleteEventArgs args)
{
Application.Quit ();
}

// runs when the button is clicked.
static void hello (object obj, EventArgs args)
{
Console.WriteLine("Hello World");
Application.Quit ();
}
}

pipeline 2008-03-25 04:20

Re: HOWTO: C# compiling on the unit itself
 
bman : in /home/user/mcs type ls -l and post results

zybook : what is your error?

zybook 2008-03-25 04:39

Re: HOWTO: C# compiling on the unit itself
 
Quote:

Originally Posted by pipeline (Post 159769)
zybook : what is your error?

here is the error:
N800:/media/mmc1/cs# mcs CanvasExample.cs -pkg:gtk-sh arp-2.0 -pkg:glade-sharp-2.0
mono[2193]: GLIB ERROR ** default - file inssel.c: line 3645 ( mono_burg_emit): should not be reached
aborting...
Stacktrace:

at Mono.CSharp.Tokenizer.is_number (int) <0xffffffff>
at Mono.CSharp.Tokenizer.is_number (int) <0x0047c>
at Mono.CSharp.Tokenizer.xtoken () <0x0053f>
at Mono.CSharp.Tokenizer.token () <0x0001f>
at Mono.CSharp.CSharpParser.yyparse (Mono.CSharp.yyParser.yy Input) <0x00f5b>
at Mono.CSharp.CSharpParser.parse () <0x000a7>
at Mono.CSharp.Driver.parse (Mono.CSharp.SourceFile) <0x001e 3>
at Mono.CSharp.Driver.ProcessFiles () <0x0008f>
at Mono.CSharp.Driver.MainDriver (string[]) <0x0049f>
at Mono.CSharp.Driver.Main (string[]) <0x00087>
at (wrapper runtime-invoke) Mono.CSharp.Driver.runtime_invok e_int_string[] (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

/usr/bin/mono [0x10b924]
/usr/lib/libglib-2.0.so.0(g_logv+0x268) [0x4115b42d]

================================================== ============ ===
Got a SIGABRT while executing native code. This usually indica tes
a fatal error in the mono runtime or one of the native librari es
used by your application.
================================================== ============ ===

Aborted

pipeline 2008-03-25 04:53

Re: HOWTO: C# compiling on the unit itself
 
thats a legitimate bug... i suspect due to being version 1.2.5. i will verify this works tomorrow on 1.9.

pipeline 2008-03-25 10:55

Re: HOWTO: C# compiling on the unit itself
 
zybrook : although you should not have gotten that bug, it seems Gnome namespace has not been ported to maemo. Cairo has been ported though so maybe you could use samples here (i've tried these and they seem to work) :
http://www.mono-project.com/Mono.Cairo_Cookbook

As for how to do the image sample in vs2003, i just wrote the program and compiled it and copied the exe over. Its a simple program just using a timer and this (works only with winforms/gdi on 1.9) :
Code:

        public static Image ImageURIToImage(string url)
        {
                Image image = null;

                WebClient webClient = new WebClient();

                try
                {
                        MemoryStream ms = new MemoryStream();
                        Uri site = new Uri(url);
                               
                        Stream stream = webClient.OpenRead(url);
                        image = Image.FromStream(stream);
                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        stream.Close();
                }
                catch (Exception ex)       
                {
                        System.Diagnostics.Debug.WriteLine(ex.ToString());
                }

                return image;
        }

Then timer will do something like :
pictureBox1.Image = ImageURIToImage("http://mysite.com/myimage.jpg");

b-man :
Your sample program runs fine for me. The file name is case-sensitive so if its named hello.cs then compile with :
mcs hello.cs -pkg:gtk-sharp-2.0

Soon i will set up a good samples page so show alot of simple programs.

zybook 2008-03-25 13:29

Re: HOWTO: C# compiling on the unit itself
 
Quote:

Originally Posted by pipeline (Post 159833)
zybrook : although you should not have gotten that bug, it seems Gnome namespace has not been ported to maemo. Cairo has been ported though so maybe you could use samples here (i've tried these and they seem to work) :
http://www.mono-project.com/Mono.Cairo_Cookbook

.

i uses "mcs CanvasExample.cs -pkg:mono-cairo" and "mcs CanvasExample.cs -pkg:mono-cairo -pkg:gtk-sharp-2.0" to compile it ,both error, the error message same like before. :-(

i also compile the demo "Drawing Rounded Rects" in the website http://www.mono-project.com/Mono.Cairo_Cookbook , also error message same.

psykosis 2008-03-25 13:31

Re: HOWTO: C# compiling on the unit itself
 
I successfully ran a couple WinForm based apps using .NET 2.0 - it seems there is still an issue with the default buttons under 2.0 (gdiplus blows up drawing the button) but reducing the button to a flat one works great.

The main issue I am seeing is the startup time - It was taking ~45 seconds to launch a simple winform - have you experienced similar delay Pipeline?

pipeline 2008-03-25 14:55

Re: HOWTO: C# compiling on the unit itself
 
thanks for 2.0 info

im seeing basic startup times of around 15 seconds for 1.0 winforms apps, around 5 seconds for gtk apps and probably around 4 seconds for console apps.

do you have alot of logic in form_load? or perhaps 2.0 is slower? i guess there's big hit with winforms/gdi initialization that will be very apparent on 400mhz arm. hasnt't been a problem yet for me... a bigger issue for me is that winforms dont have task tray icons like gtk apps do.

b-man 2008-03-25 17:12

Re: HOWTO: C# compiling on the unit itself
 
This seems like a echo frome my last post but whenever i try to compile my program called roundedrects i get the same case-sensitive eror: /home/user/mcs # mcs roundedrects.cs -pkg:mono-cairo -pkg:gtk-sharp-2.0
error CS2001: Source file `roundedrects.cs' could not be found
Compilation failed: 1 error(s), 0 warnings
/home/user/mcs #
But even when i verry carefully type the compile in frome the web page and frome what you provided i still get the same eror. is this case-sensitive eror a bug in the compiler or frome a nother cause?
here's my program:
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Cairo;
using Gtk;

public class GtkCairo
{
static void Main ()
{
Application.Init ();
Gtk.Window w = new Gtk.Window ("Mono-Cairo Rounded Rectangles");

DrawingArea a = new CairoGraphic ();

Box box = new HBox (true, 0);
box.Add (a);
w.Add (box);
w.Resize (500, 500);
w.DeleteEvent += close_window;
w.ShowAll ();

Application.Run ();
}

static void close_window (object obj, DeleteEventArgs args)
{
Application.Quit ();
}
}

public class CairoGraphic : DrawingArea
{
static double min (params double[] arr)
{
int minp = 0;
for (int i = 1; i < arr.Length; i++)
if (arr[i] < arr[minp])
minp = i;

return arr[minp];
}

static void DrawRoundedRectangle (Cairo.Context gr, double x, double y, double width, double height, double radius)
{
gr.Save ();

if ((radius > height / 2) || (radius > width / 2))
radius = min (height / 2, width / 2);

gr.MoveTo (x, y + radius);
gr.Arc (x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
gr.LineTo (x + width - radius, y);
gr.Arc (x + width - radius, y + radius, radius, -Math.PI / 2, 0);
gr.LineTo (x + width, y + height - radius);
gr.Arc (x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
gr.LineTo (x + radius, y + height);
gr.Arc (x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
gr.ClosePath ();
gr.Restore ();
}

static void DrawCurvedRectangle (Cairo.Context gr, double x, double y, double width, double height)
{
gr.Save ();
gr.MoveTo (x, y + height / 2);
gr.CurveTo (x, y, x, y, x + width / 2, y);
gr.CurveTo (x + width, y, x + width, y, x + width, y + height / 2);
gr.CurveTo (x + width, y + height, x + width, y + height, x + width / 2, y + height);
gr.CurveTo (x, y + height, x, y + height, x, y + height / 2);
gr.Restore ();
}

protected override bool OnExposeEvent (Gdk.EventExpose args)
{
using (Context g = Gdk.CairoHelper.Create (args.Window)){
DrawCurvedRectangle (g, 30, 30, 300, 200);
DrawRoundedRectangle (g, 70, 250, 300, 200, 40);
g.Color = new Color (0.1, 0.6, 1, 1);
g.FillPreserve ();
g.Color = new Color (0.2, 0.8, 1, 1);
g.LineWidth = 5;
g.Stroke ();
}
return true;
}
}

p.s. That advice you provided finaly made my hello.cs program compile and run successfuly!:)

pipeline 2008-03-25 17:36

Re: HOWTO: C# compiling on the unit itself
 
your code is irrelevant since it cant find the file. that's why i asked for output of
ls -l

from that directory

and you dont need to compile as root

b-man 2008-03-25 21:12

Re: HOWTO: C# compiling on the unit itself
 
this is probibly a really annoying and silly question, but then again i am new at programing, how do i get output of is -l

pipeline 2008-03-25 23:26

Re: HOWTO: C# compiling on the unit itself
 
no problem.. it would be pretty important to know that in order to compile :)

from within xterm just do this :

/media/mmc1/source/winforms $ ls -l
-rw-r--r-- 1 user root 948 Mar 25 15:39 hello.cs
-rw-r--r-- 1 user root 4096 Mar 25 15:39 hello.exe
/media/mmc1/source/winforms $

so ls -l (read LS -L except lowercase) will print directory saying who owns it and what permissions are... i currently run off mmc (fat) so it just says user owns, anyone can read, and user can write.

So do an ls -l then using stylus highlight those lines and in menu do edit/copy... then paste into a reply to this message from device (if you can or just type here what the roundedrects.cs file permissions and owner is)

b-man 2008-03-26 02:53

Re: HOWTO: C# compiling on the unit itself
 
Do i have to create those folders /source/winforms/ in my external memory card? or do i need to obtain thoses frome a source?
As well do i need to be in root mode when doing this or not?
Just to be safe...

pipeline 2008-03-26 03:27

Re: HOWTO: C# compiling on the unit itself
 
Um no thats an example, run wherever your source files are...
You do not need to be root

pipeline 2008-04-20 21:09

Re: HOWTO: C# compiling on the unit itself
 
2 Attachment(s)
1.9 libs are working very nicely. Although they are still in testing, they are much more stable and capable than the official (old) runtime in the official repo.

So if anyone wants to run the -test- 1.9 libs :
- Uninstall all packages except the pkgconfig and then change repo to :
(web address 'http://go-mono.com/maemo', dist 'chinook', components 'test')
- If you want web servers install my xsp maemo package
- These libs are still 'test' so expect to have to reinstall all the many packages later.

Ok well that aside, i've been enjoying aspx development so i thought i'd pass along some screenshots showing a web based wysiwyg html editor based on the FreeTextBox control.

Also, to show how cool .net byte code and mono is, i grabbed the mono xsp web server binaries, zipped them up and ran them on Windows machine and the web server works exactly the same... running against microsoft's official .net framework (both 1.1 and 2.0). This makes a more even matched development environment if you dont need or have the full IDE for web development. XSP servers are fully functional and can accept connections from outside users. Grab xsp and xsp2 for your desktop if you want (linux desktop users can probably get it from mono repo)

You can grab this wysiwyg editor sample or check out several other samples (based on the 1.9 mono libs) here :
http://wardenclyffetower.com/MaemoFi...o/samples-1.9/

zybook 2008-04-21 02:58

Re: HOWTO: C# compiling on the unit itself
 
it seems very good!

psykosis 2008-04-21 13:32

Re: HOWTO: C# compiling on the unit itself
 
Looks excellent Pipeline. Are the 2.0 Winform libraries working properly with the previous version?

pipeline 2008-04-21 14:55

Re: HOWTO: C# compiling on the unit itself
 
Quote:

Originally Posted by psykosis (Post 172567)
Looks excellent Pipeline. Are the 2.0 Winform libraries working properly with the previous version?

Previous version of what...mono? Old mono/maemo never had gdilibs/winforms so 1.9 winforms is a first for maemo.

BTW the previous editor is aspx based running in microb... and the entire editor control is a pre-built binary/assembly built for real asp.net so its not like i had to hack it to get it to work. I just download the zipped sample web from internet and used that as base for adding simple document management to work with files in MyDocs.

Winforms still has issues i suppose with FlatStyle (2.0 cil problem only), FontDialog, ColorDialog, glitchy FIleDialog, missing taskbar icon, and no fullscreen. Hopefully Everaldo will be able to resolve some of these for official release.


All times are GMT. The time now is 05:39.

vBulletin® Version 3.8.8