Re: [Mono-list] Reliable OS identification on Mono

2008-09-22 Thread Marc Glenn

Hi.

You can use a condition statement like this.

*if(System.Environment.OSVersion.Platform == PlatformID.Unix)

**Here is the link to the Mono API:*
http://www.go-mono.com/docs/index.aspx?link=T%3aSystem.OperatingSystem%2f*

However, I can't find a way to check if its in MAC.

Hope this helps,

Marc Glenn

Vladislav Rastrusny wrote:

Hello.

Is there a way to reliably determine OS, application is running on in Mono?
My application needs to access files of some external application
(also multiplatform) and those files are located in different places
depending on OS.
On Windows it is under ApplicationData, on Linux under /home/user/app
and on MacOS... I don't know ;) Never installed it.

Thanks in advance.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


  


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Mono Sqlite Question

2008-08-15 Thread Marc Glenn

Hello guys,

I found this code at http://www.mono-project.com/SQL_Lite

   I want to ask why it is important to assign null to the Sqlite 
objects used in the main function.
   Since the function will exit and the local variables used will be 
deallocated,

   Is it really important to assign *null *to those variables?
   Is there a specific behaviour of Mono Sqlite that I should know about?

Thanks in advance,
Marc Glenn

*Please see code below:
* using System;
using System.Data;
using Mono.Data.SqliteClient;

public class Test
{
   public static void Main(string[] args)
   {
  string connectionString = URI=file:SqliteTest.db;
  IDbConnection dbcon;
  dbcon = (IDbConnection) new SqliteConnection(connectionString);
  dbcon.Open();
  IDbCommand dbcmd = dbcon.CreateCommand();
  // requires a table to be created named employee
  // with columns firstname and lastname
  // such as,
  //CREATE TABLE employee (
  //   firstname varchar(32),
  //   lastname varchar(32));
  string sql =
 SELECT firstname, lastname  +
 FROM employee;
  dbcmd.CommandText = sql;
  IDataReader reader = dbcmd.ExecuteReader();
  while(reader.Read()) {
   string FirstName = reader.GetString (0);
   string LastName = reader.GetString (1);
   Console.WriteLine(Name:  +
   FirstName +   + LastName);
  }
  *// clean up*
  reader.Close();
  *reader = null;*
  dbcmd.Dispose();
  *dbcmd = null;*
  dbcon.Close();
  *dbcon = null;*
   }
}
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Mono Sqlite Question

2008-08-15 Thread Marc Glenn

Ok. Thank you very much for the response. :)

Chris Howie wrote:

On Fri, Aug 15, 2008 at 2:04 AM, Marc Glenn [EMAIL PROTECTED] wrote:
  

I want to ask why it is important to assign null to the Sqlite objects
used in the main function.
Since the function will exit and the local variables used will be
deallocated,
Is it really important to assign null to those variables?
Is there a specific behaviour of Mono Sqlite that I should know about?



Those lines will do pretty much nothing, semantically speaking.
Usually when you dispose or close something in general it's a good
idea to assign null to it, but usually that's more in the case of
object fields when that object may still exist for a while.  This
allows the GC to reclaim those objects if the object that was holding
references isn't eligible for GC yet.  In this case it's not necessary
or useful.

  


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Linux Shell Commands in C#

2008-05-29 Thread Marc Glenn

Hello guys,

I am wondering if there is a way to do system calls in Unix using 
Mono C#.
I am trying to use 
*System.Diagnostics.Process.Start(/home/tester/myscript.sh)*; but it 
seems not to work.


I hope you can help me.
Thanks

Regards,
Hybrid
   
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Linux Printing Exception

2008-04-02 Thread Marc Glenn
Hello Sebastien,

I installed libgdiplus on redhat 9 and it solved the problem.
Thanks very much.

Regards,
Marc Glenn

Sebastien Pouliot wrote:
 Hello Marc,

 On Tue, 2008-04-01 at 17:25 +0800, Marc Glenn wrote:
   
 Hello guys,

  I am using System.Drawing.Printing namespace to print a data.
  I tried it first in *mono-1.2.5.1-Windows* and prints without a 
 problem.

  However, when I tried compiling the same source code in *Redhat 9* 
 with *mono-1.2.6* installed,
 

 Did you install/compile libgdiplus in this system ? If so make sure it's
 the same version (1.2.6) than your mono installation.

   
  I received this exception from the console:

 /Exception: System.TypeInitializationException: An exception was thrown 
 by the type initializer for System.Drawing.Printing.SysPrn --- 
 System.TypeInitializationException: An exception was thrown by the 
 type initializer for System.Drawing.GDIPlus --- 
 *System.DllNotFoundException: gdiplus.dll*
   at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup 
 (ulong,System.Drawing.GdiplusStartupInput,System.Drawing.GdiplusStartupOutput)
   at System.Drawing.GDIPlus..cctor () [0x0] --- End of inner 
 exception stack trace ---

   at System.Drawing.Printing.SysPrn..cctor () [0x0] --- End of inner 
 exception stack trace ---

   at System.Drawing.Printing.PrinterSettings..ctor () [0x0]
   at System.Drawing.Printing.PrintDocument..ctor () [0x0]
   at (wrapper remoting-invoke-with-check) 
 System.Drawing.Printing.PrintDocument:.ctor ()
 /
  Anyone knows why this is happening?

 Thanks in advance,
 Marc Glenn

 ___
 Mono-list maillist  -  Mono-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-list
 



   


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Cannot Print Landscape

2008-02-27 Thread Marc Glenn

Hello guys,

I am using System.Drawing.Printing namespace to print a string in a 
*landscape* page orientation.
   
I set the property *PrintDocument.DefaultPageSettings.Landscape* = 
true so the PrintDocument

would print in *landscape*.

I compiled it in Windows using SharpDevelop's .NET C# Compiler and 
it prints in landscape fine.
But when I used *gmcs* to compile, it still prints in portrait 
orientation.


I am using *mono1.2.5.1 *in *win32. *I also compiled it in 
*mono1.9(Preview3)* but the same problem

still occurs.

Is this a bug of mono or am I just doing something wrong?
I attached my source code. Please help me.

Thanking in advance,
Marc Glenn
   
using System;
using System.IO;
using System.Drawing.Printing;
using System.Drawing;

namespace DefaultNamespace
{
 
enum PageOrient
{
landscape,
portrait
}

class MyPrinter  
{

 PrintDocument pv_PrintDocument;
 Font pv_PrintFont;
 StringReader pv_PrintDataReader;
 
 public MyPrinter( string in_PrintData, PageOrient in_PageOrient )
 {
pv_PrintDocument = new PrintDocument();
pv_PrintDocument.PrintPage += OnPrintPageEvent;
  
pv_PrintDataReader = new StringReader( in_PrintData );
  
pv_PrintFont = new System.Drawing.Font(Arial, 10);

if ( in_PageOrient.Equals( PageOrient.landscape ) )
{
pv_PrintDocument.DefaultPageSettings.Landscape = true;
}

this.Start();
 }
 
 public int Start()
 {
pv_PrintDocument.Print();

return ( 0 );
 }
  
 public void OnPrintPageEvent(object sender, PrintPageEventArgs e)
 {
float yPos = 0f;
int count = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
string line = null;
float linesPerPage = 
e.MarginBounds.Height/pv_PrintFont.GetHeight(e.Graphics);

while (count  linesPerPage)
{
line = pv_PrintDataReader.ReadLine();
if (line == null)
{
break;
}
yPos = topMargin + count * pv_PrintFont.GetHeight(e.Graphics);
e.Graphics.DrawString(line, pv_PrintFont, Brushes.Black, 
leftMargin, yPos, new StringFormat());
count++;
}
if (line != null)
{
e.HasMorePages = true;
}
 }
 
 static void Main( string[] args )
 {
new MyPrinter( Lorem Ipsum is simply dummy text of the printing\n and 
typesetting industry. Lorem Ipsum has been the industry's standard dummy text 
ever since the 1500s, when an unknown printer took a galley of type and 
scrambled it to make a type specimen book. It has survived not only five 
centuries, but also the leap into electronic typesetting, remaining essentially 
unchanged. It was popularised in the 1960s with the release of Letraset sheets 
containing Lorem Ipsum passages, and more recently with desktop publishing 
software like Aldus PageMaker including versions of Lorem Ipsum., 
PageOrient.landscape );
 }

}

}

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Need help in compilation

2008-02-25 Thread Marc Glenn

Hello folks,

I installed the mono-1.2.5.1 installer for windows xp. It has 
gtk-sharp 2.10 and gnome 2.16 included.
   
I also found *PrintSample.cs* in the samples directory. This 
PrintSample.cs uses the Gnome namespace to print.


I am having problems on how to compile it using mono on windows. I 
don't know what library to include so the Gnome namespace can be 
accessible. Butwhen I compile it on mono(linux), it runs fine.


Also, when I tried copying the PrintSample.exe which is produced by 
a mono(linux) compilation. It won't run on my mono(windows). It outputs 
a  System.DllNotFoundException.


Attached is the *PrintSample.cs *file.

Does anyone know how to compile it correctly on a windows machine?

Desperate already,
Marc Glenn


using System;
using Gtk;
using Gnome;

class PrintSample
{
TextView tv;

static void Main ()
{
new PrintSample ();
}

PrintSample ()
{
Application.Init ();
Gtk.Window win = new Gtk.Window (Print sample);
win.SetDefaultSize (400, 300);
win.DeleteEvent += new DeleteEventHandler (OnWinDelete);

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

tv = new TextView ();
tv.Buffer.Text = Hello World;
vbox.PackStart (tv, true, true, 0);

Button print = new Button (Gtk.Stock.Print);
print.Clicked += new EventHandler (OnPrintClicked);
vbox.PackStart (print, false, true, 0); 

win.ShowAll ();
Application.Run ();
}

void MyPrint (Gnome.PrintContext gpc)
{
gpc.BeginPage (demo);
gpc.MoveTo (1, 700);
gpc.Show (tv.Buffer.Text);
gpc.ShowPage ();
}

void OnPrintClicked (object o, EventArgs args)
{
Gnome.PrintJob pj = new Gnome.PrintJob 
(Gnome.PrintConfig.Default ());
Gnome.PrintDialog dialog = new Gnome.PrintDialog (pj, Print 
Test, 0);
int response = dialog.Run ();
Console.WriteLine (response:  + response);

if (response == (int) PrintButtons.Cancel) {
Console.WriteLine (Canceled);
dialog.Hide ();
dialog.Dispose ();
return;
}

Gnome.PrintContext ctx = pj.Context;
MyPrint (ctx); 

pj.Close ();

switch (response) {
case (int) PrintButtons.Print: 
pj.Print (); 
break;
case (int) PrintButtons.Preview:
new PrintJobPreview (pj, Print Test).Show ();
break;
}

dialog.Hide ();
dialog.Dispose ();
}

void OnWinDelete (object o, DeleteEventArgs args)
{
Application.Quit ();
}
}
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] [Gtk-sharp-list] Need help in compilation

2008-02-25 Thread Marc Glenn

Thanks for the reply. :)

Actually, I tried using the example in the GtkDemo first. But when I try 
to use the PrintOperationAction.PrintDialog property, I can't seem to 
find a way to make the dialog modal with the parent because I don't have 
a reference to the actual dialog widget.


I also can't find documentations for the PrintContext or PrintOperation 
class. Do you know any documentation for these classes?


Mike Kestner wrote:

On Mon, 2008-02-25 at 16:25 +0800, Marc Glenn wrote:
  

Hello folks,

 I installed the mono-1.2.5.1 installer for windows xp. It has
gtk-sharp 2.10 and gnome 2.16 included.
 
 I also found PrintSample.cs in the samples directory. This

PrintSample.cs uses the Gnome namespace to print.



You should use the Gtk printing capability.  Gnome.Print is deprecated
now and relies on libgnomeprintui which is probably not available for
win32.

There is a sample of how to use Gtk.Print in the GtkDemo application
located in gtk-sharp/samples.


  
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Mono for RedHat 9

2008-02-15 Thread Marc Glenn
Hello everyone,

 I need to install mono on Red Hat 9.
 However, I can't install version 1.2.5.1 due to glibc conflict.

 Do you know the latest possible version of mono that can be 
installed on Red Hat 9??

 Thanks in advance.

Regards,
Marc Glenn

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Fail to detect printers

2008-01-16 Thread Marc Glenn

Hello everyone,

I compiled this source code on my windows machine. I have mono 
1.2.5.1 installed.

But the output does not show all the printers installed on my machine.

Does anyone know why this happens??

Thanks in advance.

Regards


using System;
using System.Drawing.Printing;

class PrintSample
{
static void Main(string[] args)
{
foreach (string printerName in PrinterSettings.InstalledPrinters)
{
Console.WriteLine(Printer: {0}, printerName);
}
}
}
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Problem with GtkWindow.Deletable

2007-10-21 Thread Marc Glenn

Hello everyone,

I am having problems when I try to remove the close button of a 
window in a GTK# application.


I tried setting the property GtkWindow.Deletable to *false* and it 
was able to remove the close button. But it has also removed the rest of 
the window except from the *title bar*.


Attached with this message is a sample code of the problem that I 
experienced.

I compiled the code in a windows environment using
*gmcs -pkg:glade-sharp-2.0 DeletableTester.cs

* Is this a problem with Mono?

Thanks in advance.

Regards,
Marc Glenn
   

   
/*
 * Created by SharpDevelop.
 * User: Hybrid
 * Date: 10/17/2007
 * Time: 5:16 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using Gtk;

public class DeletableTester
{
public static void Main (string[] args)
{
new DeletableTester (args);
}
 
public DeletableTester (string[] args) 
{

Application.Init();


MessageDialog md1 = new MessageDialog (null, 
  DialogFlags.Modal,
   MessageType.Question, 
  ButtonsType.YesNo, );

md1.UseMarkup = true;
md1.SecondaryUseMarkup = true;
md1.Text = bWindow cannot be deleted/b;

md1.Deletable = false;

md1.Title = Undeletable Window;

md1.Run();

md1.Destroy();

Application.Run();

}
}
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] GTKSharp API

2007-10-15 Thread Marc Glenn
Hello everyone,

 I am trying to create GUI applications using GTK# and am looking 
for references. I tried the gtk+ API but it seems that the functions are 
for C++ only.

 Do you know where I can find the API for GTK#?

 I would like to see all the available functions for the widgets 
that GTK provides and use it in C#.

Thanks in advance
Marc Glenn

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] GTKSharp API

2007-10-15 Thread Marc Glenn

Okay. Found it.
THanks

Everaldo Canuto wrote:

Hey,

  

 Do you know where I can find the API for GTK#?




Yes, you can install monodoc or go to online version:

   http://www.go-mono.com/docs/[EMAIL PROTECTED]

You can be also interesting in http://www.go-mono.com/docs/ and expand
gnome libraries.

-Everaldo



  


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Need Help: Mono under Windows-problems in using events

2007-10-14 Thread Marc Glenn

Hello guys,

   I tried compiling a csharp code that uses gtk# and event handlers 
under Mono.


   // 04-gtk/01-basics
   using System;
   using Gtk;
   class MainClass {
   public static void Main (string[] args)
   {
   Application.Init ();
   Window w = new Window (Gtk# Basics);
   Button b = new Button (Hit me);
   w.DeleteEvent += new DeleteEventHandler (Window_Delete);
   b.Clicked += new EventHandler (Button_Clicked);
   // initialize the GUI
   w.Add (b);
   w.SetDefaultSize (200, 100);
   w.ShowAll ();
   Application.Run ();
   }
   static void Window_Delete (object o,
   DeleteEventArgs args)
   {
   Application.Quit ();
   args.RetVal = true;
   }
   static void Button_Clicked (object o, EventArgs
   args)
   {
   System.Console.WriteLine (Hello, World!);
   }
   }

   The program prints a Hello World on the Console after clicking the 
button Hit Me.


   I executed it under Fedora Core 6 using the latest version of Mono 
compiler and it operates perfectly.
  
   But when I try to run it under Mono-Windows(latest version) and 
click the button Hit Me, the program crashes.

   I have tried to comment out these lines
  w.DeleteEvent += new DeleteEventHandler (Window_Delete);
  b.Clicked += new EventHandler (Button_Clicked);
   and when I click the button Hit Me, the program does not crash 
anymore.


   Does this mean that Mono have problems with csharp events or I just 
have a wrong configuration of my Mono-Runtime..


   Need help..

   Thanks in advance

  
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list