Pues básicamente la duda es esa, estoy haciendo una tonteria para hacer los primeros pinitos en c#, es un generador de nick con un "live view", la cosa es que necesito aplicar diferentes estilos a una misma cadena de texto, por ejemplo:
"Esto
es un ej
emplo de lo
que necesito"
Y la cosa está chunga, por que no tengo ni idea de aplicar fonts, a un textfield si, pero no a una cadena, para que entendais un poquito el código si encuentro "$i" es italic por ejemplo.
Os pego lo que tengo..
Código c#:
Ver originalusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace NickCreator
{
public partial class Form1 : Form
{
String nick = "";
String live = "";
String formato = "";
public Form1()
{
InitializeComponent();
}
private void Copiar_Click(object sender, EventArgs e)
{
tNick.SelectAll();
tNick.Copy();
}
private void Limpiar_Click(object sender, EventArgs e)
{
tNick.Text = "";
tLive.Text = "";
}
private void tNick_TextChanged(object sender, EventArgs e)
{
MostrarLive(nick, formato);
}
private void MostrarLive(String nick, String formato)
{
tLive.Text = tNick.Text;
}
private void cBFormato_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
private void Form1_Shown(object sender, EventArgs e)
{
tNick.Focus();
}
private void cBFormato_SelectedIndexChanged(object sender, EventArgs e)
{
DevolverFormato();
TransformarNick();
}
private void TransformarNick()
{
formato = DevolverFormato();
int tamaño = nick.Length;
int posCursor = tNick.SelectionStart;
nick = tNick.Text;
String prin = nick.Substring(0, posCursor);
prin = prin + formato;
String fin = nick.Substring(posCursor);
prin = prin + fin;
nick = prin;
tNick.Text = nick;
TransformarLive();
}
private void TransformarLive()
{
live = tNick.Text;
int pos = live.IndexOf("$i");
int tam = live.Length;
String cad = live.Substring(0, pos);
}
private String DevolverFormato()
{
int a = cBFormato.SelectedIndex;
formato = "";
switch (a)
{
case 0: formato = "$t";
break;
case 1: formato = "$i";
break;
case 2: formato = "$w";
break;
case 3: formato = "$n";
break;
case 4: formato = "$g";
break;
case 5: formato = "$m";
break;
case 6: formato = "$z";
break;
}
return formato;
}
private void tNick_KeyPress(object sender, KeyPressEventArgs e)
{
}
}
Alguna idea de por donde tengo que encaminarme?, gracias y un saludo.