28-03-2009

Color de un ComboBox Item

Los items de los combobox en windows forms no se les puede definir el color del foreground y background.
Si los objetos que se ponden son del tipo ListViewItem, entonces se puede usar el evento comboBox.DrawItem para dibujarles los colores, con lo siguiente:


void OnDrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index<0)

return;


Graphics g = e.Graphics;

Rectangle r = e.Bounds ;

e.DrawBackground();


Color textColor = SystemColors.ControlText; //Queda con etse color

if (e.State == (DrawItemState.Focus | DrawItemState.Selected ) )

textColor = SystemColors.HighlightText;

if (e.State == DrawItemState.None)

textColor = SystemColors.WindowText;


ListViewItem item = combo.Items[e.Index] as ListViewItem;


if (item.ForeColor != SystemColors.WindowText)

textColor = item.ForeColor;


//Rectangulo interno

// Rectangle rectangle = new Rectangle(2, e.Bounds.Top+2, e.Bounds.Height, e.Bounds.Height-4);

// e.Graphics.FillRectangle(new SolidBrush(Color.Salmon), rectangle);


g.DrawString(item.ToString(), new Font("Ariel", 8), new SolidBrush(textColor), r);

e.DrawFocusRectangle();


}



O más simple aún, reemplazar OnDrawItem:


public class ColorComboBox : ComboBox
{

protected override void OnDrawItem(DrawItemEventArgs e)
{
base.OnDrawItem (e);

if (e.Index<0)
return;

Control item = this.Items[e.Index] as Control;
if (item==null)
return;

Graphics g = e.Graphics;
Rectangle r = e.Bounds ;
if (item.ForeColor != SystemColors.WindowText)
g.DrawString(item.ToString(), Parent.Font, new SolidBrush(item.ForeColor), r);

}

}

17-02-2009

System.Windows.Forms

Curiosamente no es lo mismo

ventana.Hide();

que

ventana.Show();
ventana.Hide();



Cuando se hace lo primero, entonces cualquier cosa que haga en otro hilo (con Invoke) no funciona.

:P

31-01-2009

CVS Mirror

Para los interesados:

export CVSROOT":pserver:anoncvs@cvsup.freebsd.cl:/home/ncvs"
cvs login (clave anoncvs)
cvs co ports

suerte!

03-12-2008

FreeBSD 6.4

FYI

26-11-2008

'Casteo ascendente'

Lo encontre choro....

Si en una clase llamada Clase, le ponemos un constructor asi:

public Clase : Dictionary<string,string>
{
public Clase(Dictionary
<string,string> dic) : base(dic)
{}
}

Entonces es posible escribir:

Clase clase = new Clase(new Dictionary
<string,string>());

:P

21-11-2008

OpenOffice 3

Ayer instale Openoffice 3, y me encontre con la sorpresa que no se pueden instalar extensiones ni diccionarios:

"bad tranfer url"

Alguien lo ha podido hacer?


Referencias:
http://www.freebsd.org/cgi/query-pr.cgi?pr=127946
http://archivos.sofsis.cl/freebsd/openoffice/

01-10-2008

Disk partitions

man sade

04-09-2008

Installing FreeNAS into a USB stick

1.- Put the stick into the USB (dont mount it...)
2.- fdisk -BI /dev/da0 [ignore Geom not found "da0"]
3.- bsdlabel -B -w da0s1
4.- newfs -U -L MyBoot /dev/da0s1a
5.- mdconfig -a -f FreeNAS-i386-liveCD-0.7.3514.iso
6.- mount_cd9660 /dev/md0 /dist/
7.- mount /dev/da0s1a /mnt/
8.- cp -rip /dist/* /mnt
9.- umount /mnt

No matter if you update your firmware, if "USB Keyboard" is not enabled in the BIOS some motherboards will not boot! (took me hourse to realize that.. :P)

13-08-2008

CSharp Unixtime to DateTime

DateTime unixEpoch = new DateTime (1970, 1, 1);
TimeSpan timeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow);
DateTime myTime = unixEpoch.AddSeconds(myUnixtime + timeZoneOffset.TotalSeconds);

ISO-8601 DateTime .NET

Wiered...

DateTime.Now.ToString('s') -> 2008-08-13T13:22:32
DateTime.now.ToString('u') -> 2008-08-13 13:22:32Z

None of them are close enough to iso8601?...

One has to use
DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'sszz'00'") -> 2008-08-13T13:22:32-0400

Any shorter way to do this?....

12-08-2008

Writing DVDs

Ive never copy DVD's before...
1) readom dev=/dev/hda f=lalala.iso
2) growisofs -dvd-compat -Z /dev/hda=lalala.iso

:P

19-07-2008

Castle!

Wow.. hammet, 'the leader' of the castle project just got hired at microsoft.

That project had good stuffs like a container and web MVC framework for .NET.
I hope this does not mean castle project will not continue to envolve, and that the new MVC framework at microsoft will be good.

!

13-07-2008

Tabs


There are rumors that gnome 3.0 gui's, will be heavily based on tabs. Some people may like it (i do for some applications...).
I dont think its a good idea to hard-code the applications with the tabs. Instead of that, there should be a generic way to group content in a more high-level logic fashon, and let the user decide if he/she wants tabs, treeviews, or some other kind of representation...

30-06-2008

Calendar on N800

Ok.. From now on, ill try to write on english.. lets see if i post more frequently.. :P

I was depress i coulnt syncronize my N800 with our intranet engine in the office (egroupware), until last week. Pimlico, is a company that makes PIM applications for maemo and openmoko platforms. They have a quite cool calendar application.

Some time ago, Patrik released a beta for he's syncevolution project, so i give it a try. Surprise you death.... it works!

Its just as easy as:


syncevolution --configure --sync-property username=pneumann --sync-property password=**** --source-property sync=none scheduleworld memo todo

cd ~/.config/syncevolution && mv scheduleworld your_company_name

syncevolution --configure --source-property sync=none --source-property uri=calendar your_company_name


And of course, a little cron that does sync every 10min only if there is a conection to the server.

Lets see if i finally arrive to the meetings!..

:P


Updated: Data is keept in ~/.evolution/calendar.
You can delete it by: PIDS=`pidof e-calendar-factory` && kill -15 $PIDS && rm -rf $HOME/.evolution/calendar

19-05-2008

Como levantar un DNS en 1 minuto

echo named_enabled="YES" >> /etc/rc.conf
echo pass in on $ext_if proto {tcp,udp} from any to any port domain >> /etc/pf.conf
$EDITOR /var/named/etc/namedb/named.conf
$EDITOR las_zonas
/etc/rc.d/named restart
/etc/rc.d/pf restart

ridiculamente facil...

PD: la cosa queda chruteada... :P

01-04-2008

Nerd bytes

Se me habia olvidado ya que tenia un blog nerdyyii...

Os dejo un scripcillo que se conecta a un music player daemon y publica lo que se esta todando ahi, en una cuenta MSN que este siendo usada por algun programa que use telepatia.

Probablemente sea buena idea transformarlo en un plugin...

simple, preciso y feo.. :P


#!/usr/bin/env python

import dbus
import time
import mpdclient
import unicodedata

#Configs
MSN_ACCOUNT="your_msn_account@hotmail.com"
STRING="%s: %s [%s] Some more strings..."
NO_SONG_NAME="When no tag can be found in the song"
SLEEP=3
HOST='host.of.your.mpd'
PORT=6600

#Globals
NAME='org.freedesktop.Telepathy.Connection.butterfly.msn.'+ MSN_ACCOUNT.replace('@','_40').replace('.','_2e')
SERVER='/org/freedesktop/Telepathy/Connection/butterfly/msn/'+MSN_ACCOUNT.replace('@','_40').replace('.','_2e')
msn = None
mpd = None
last_song = None

def connect_dbus():
global msn
bus = dbus.SessionBus()
msn = bus.get_object(NAME, SERVER)

def connect_mpd():
global mpd
try:
mpd = mpdclient.MpdController(HOST, PORT)
except mpdclient.MpdConnectionPortError, e:
print "Cannot connect: %s" %e

def song_name(song):
if (len(song.artist)<2):
return NO_SONG_NAME
utf8 = STRING %(song.artist,song.title,song.album)
out = ""
for s in utf8.decode('utf-8'):
dec = unicodedata.decomposition(s)
if (len(dec)<1):
out += s
else:
out += chr(int(dec.split(' ')[0],16))
return out

while (1):

time.sleep(SLEEP)

try:
current_song = mpd.getCurrentSong()

except (mpdclient.MpdStoredError), e:
print e
continue
except (mpdclient.MpdNoResponseError, AttributeError, mpdclient.MpdError), e:
print "Not connection to mpd, reconnecting..."
connect_mpd()
continue

if current_song is False:
print "Nothing to see.."
continue

song = song_name(current_song)
if (last_song==song):
continue

print "New song: %s" %song
last_song = song

try:
msn.SetAliases( {1: song} )
except (dbus.exceptions.DBusException, AttributeError), e:
print "No connection to dbus, reconnecting..."
connect_dbus()
last_song = None

27-03-2008

Proyecto Mono

No es para nada agradable ver como proyectos en los que uno esta metido involucionan, pues siempre he creido que los resultados son reflejo del estado del conciente e inconciente grupal de la gente que los soporta.
No se si estare desequilibrado (uno nunca sabe!) pero el estado de este proyecto deja mucho que desear. Es por eso que para efectos de sanidad y tranquilidad mental personal, pretendo darle un poco mas de bola al asunto.
En otras palabras:
  • Mejorar la mantencion de los ports 'experimentales' existentes, como por ejemplo meter mono-1.9 y sus amigos de SilverLight
  • Agregar programas comunes. (como banshee o gnome-do). Lo que la genta quiera
  • Facilitar la prueba de mono en FreeBSD, para los desarrolladores de Novel
  • Integrar más gente al proyecto

El ultimo punto ayudaria directamente a los otros.. pero es lo mas dicifil de hacer. Por el otro lado, como www.bsd.cl esta respirando de manera estable uno pudiese pensar en que van a haber eventos en algun futuro cercano. Si hay uno, dejo por adelantada mi proupuesta para una mini-capacitación de como hacer ports, y ofrecer un proyecto en donde entretenerse...


(solo para que no se me olvide...)

13-03-2008

Hilos

Se acaba de anunciar que freebsd ya no va a soportar el modelo de hilos N:M (KSE). Me parece excelente ver como la decisión original de soportar varios modelos, fue buena ya que pemitió no descartar a priori ninguno de los otros.
El mercado/recursos eligió uno de ellos. Lets use it! :)

28-01-2008

Resurreccion

bsd.cl revive.
si!

27-01-2008

DJ random shit (24x7)

Exelente: http://200.73.13.54:8000/music.ogg


Auspiciado por DJ random_shit:


[killfill@flash ~]$ cat dj_random_shit.sh
#!/usr/bin/env bash

p=`mpc playlist`
cantidad=`echo "${p##*>}"|wc -l`

if [ $cantidad -lt 3 ]; then
total=`mpc stats|grep Songs|awk -F\ '{print $2}'`
number=$((RANDOM%$total))
mpc listall|head -n $number|tail -n 1|head -n 1| mpc add
fi