Created
June 27, 2012 06:31
-
-
Save monotocho/3001973 to your computer and use it in GitHub Desktop.
Selected custom element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//******************** | |
//Navigate to DVC1 !!! | |
//******************** | |
namespace EMALI | |
{ | |
public partial class vPtoVentaTipo : DialogViewController | |
{ | |
public int PaginaIndex { get; set; } | |
public vPtoVentaTipo (int index) : base (UITableViewStyle.Grouped, null) | |
{ | |
PaginaIndex = index; | |
RootElement root; | |
DataTable dt; | |
if (PaginaIndex == 0) { | |
dt = EMALI.Comun.PtoVenta.ConsultaPtoVenta (6000000114); | |
root = new RootElement ("Detalle Punto Venta") { | |
new Section (""){ | |
new StringElement ("Código", dt.Rows[0]["PV_CODIGO_PUNTO_VENTA"].ToString()), | |
new eTextoLargo ("Nombre", dt.Rows[0]["PV_DENOMINACION"].ToString()), | |
new eTextoLargo ("Dirección", dt.Rows[0]["PV_DIRECCION"].ToString()), | |
new StringElement ("Población", dt.Rows[0]["PV_POBLACION"].ToString()), | |
new StringElement ("Provincia", dt.Rows[0]["PV_NOMBRE_PROVINCIA"].ToString()), | |
new StringElement ("Teléfono", dt.Rows[0]["PV_TELEFONO"].ToString()), | |
new StringElement ("Fax", dt.Rows[0]["PV_FAX"].ToString()) | |
} | |
}; | |
} else { | |
root = CargaSucursales (); | |
} | |
Root = root; | |
} | |
//******************** | |
//Navigate to DVC1 !!! | |
//******************** | |
private RootElement CargaSucursales () | |
{ | |
DataTable dt; | |
RootElement root; | |
eSucursal elemento; | |
Section seccion = new Section (); | |
//eSucursal.OnSelected += delegate(object sender, EventArgs e) { | |
// | |
//}; | |
//eSucursal.OnSelected += | |
dt = EMALI.Comun.PtoVenta.ConsultaClientesPtoVenta (6000000114); | |
foreach (DataRow d in dt.Rows) { | |
elemento = new eSucursal ( | |
d ["CLTE_NOMBRE"].ToString (), | |
d ["DIC_RAZON_SOCIAL"].ToString (), | |
d ["CLTE_DNI_CIF"].ToString (), | |
d ["DIC_DIRECCION_ENVIO"].ToString (), | |
d ["EMP_NOMBRE_ABREVIADO"].ToString (), | |
Convert.ToInt32 (d ["CLTE_CLIENTE"]), | |
Convert.ToInt32 (d ["DIC_SUCURSAL"]) | |
); | |
seccion.Add (elemento); | |
} | |
root = new RootElement ("Sucursales Pto Venta"); | |
root.Add (seccion); | |
return root; | |
} | |
// public void CargaDetalleSucursal(int cliente, int sucursal) | |
// { | |
// vSucursalDetalle sdetalle = new vSucursalDetalle (cliente, sucursal); | |
// this.NavigationController.PushViewController (sdetalle, true); | |
// } | |
} | |
} | |
//************** | |
//CUSTOM ELEMENT | |
//************** | |
namespace Test1 | |
{ | |
public class eSucursal : OwnerDrawnElement | |
{ | |
CGGradient gradient; | |
private UIFont subjectFont = UIFont.SystemFontOfSize (13.0f); | |
private UIFont fromFont = UIFont.BoldSystemFontOfSize (14.0f); | |
private UIFont dateFont = UIFont.BoldSystemFontOfSize (14.0f); | |
public eSucursal (string nomcli, string nomsuc, string cif, string direc, string emp, int cli, int suc) : base(UITableViewCellStyle.Default, "sampleOwnerDrawnElement") | |
{ | |
this.NombreCliente = nomcli; | |
this.NombreSucursal = nomsuc; | |
this.CIF = cif; | |
this.Direccion = direc; | |
this.cEmpresa = emp; | |
this.cCliente = cli; | |
this.cSucursal = suc; | |
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB (); | |
gradient = new CGGradient ( | |
colorSpace, | |
new float[] { 0.95f, 0.95f, 0.95f, 1, | |
0.85f, 0.85f, 0.85f, 1}, | |
new float[] { 0, 1 }); | |
} | |
public string NombreSucursal { | |
get; | |
set; | |
} | |
public string NombreCliente { | |
get; | |
set; | |
} | |
public string CIF { | |
get; | |
set; | |
} | |
public string Direccion { | |
get; | |
set; | |
} | |
public string cEmpresa { | |
get; | |
set; | |
} | |
public int cCliente { | |
get; | |
set; | |
} | |
public int cSucursal { | |
get; | |
set; | |
} | |
public string FormatDate (DateTime date) | |
{ | |
if (DateTime.Today == date.Date) { | |
return date.ToString ("hh:mm"); | |
} else if ((DateTime.Today - date.Date).TotalDays < 7) { | |
return date.ToString ("ddd hh:mm"); | |
} else { | |
return date.ToShortDateString (); | |
} | |
} | |
static public event EventHandler<EventArgs> OnSelected; | |
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path) | |
{ | |
base.Selected (dvc, tableView, path); | |
vSucursalDetalle sdetalle = new vSucursalDetalle (cliente, sucursal); | |
dvc.NavigationController.PushViewController (sdetalle, true); | |
// if (OnSelected != null) | |
// OnSelected(this, EventArgs.Empty); | |
} | |
public override void Draw (RectangleF bounds, CGContext context, UIView view) | |
{ | |
UIColor.White.SetFill (); | |
context.FillRect (bounds); | |
context.DrawLinearGradient ( | |
gradient, | |
new PointF (bounds.Left, bounds.Top), | |
new PointF (bounds.Left, bounds.Bottom), | |
CGGradientDrawingOptions.DrawsAfterEndLocation | |
); | |
UIColor.Blue.SetColor (); | |
view.DrawString ( | |
this.NombreSucursal, | |
new RectangleF (10, 5, bounds.Width / 2 + bounds.Width / 4, 10), | |
fromFont, | |
UILineBreakMode.MiddleTruncation | |
); | |
UIColor.Brown.SetColor (); | |
view.DrawString ( | |
this.cEmpresa, | |
new RectangleF (bounds.Width / 2, 5, (bounds.Width / 2), 10), | |
dateFont, | |
UILineBreakMode.TailTruncation, | |
UITextAlignment.Right | |
); | |
UIColor.DarkGray.SetColor (); | |
view.DrawString (this.NombreCliente + this.CIF, new RectangleF (10, 20, bounds.Width - 20, 10), subjectFont, UILineBreakMode.WordWrap); | |
UIColor.DarkGray.SetColor (); | |
view.DrawString (this.Direccion, new RectangleF (10, 33, bounds.Width - 20, 10), subjectFont, UILineBreakMode.WordWrap); | |
} | |
public override float Height (RectangleF bounds) | |
{ | |
//var height = 40.0f + TextHeight (bounds); | |
var height = 50.0f; | |
return height; | |
} | |
private float TextHeight (RectangleF bounds) | |
{ | |
SizeF size; | |
using (NSString str = new NSString (this.Direccion)) { | |
size = str.StringSize (subjectFont, new SizeF (bounds.Width - 20, 1000), UILineBreakMode.WordWrap); | |
} | |
return size.Height; | |
} | |
public override string ToString () | |
{ | |
return string.Format (NombreSucursal); | |
} | |
} | |
} | |
//*************** | |
//CREATE DVC2 | |
//*************** | |
namespace EMALI | |
{ | |
public partial class vSucursalDetalle : DialogViewController | |
{ | |
DataTable dt; | |
public vSucursalDetalle (int ccliente, int csucursal) : base (UITableViewStyle.Grouped, null, true) | |
{ | |
dt = EMALI.Comun.Sucursal.ConsultaSucursal(ccliente, csucursal); | |
Root = new RootElement ("Detalle Punto Venta") { | |
new Section (""){ | |
new StringElement ("Código", dt.Rows[0]["DIC_CLIENTE"].ToString()), | |
new eTextoLargo ("Nombre", dt.Rows[0]["DIC_RAZON_SOCIAL"].ToString()), | |
new eTextoLargo ("Dirección", dt.Rows[0]["DIC_DIRECCION_ENVIO"].ToString()), | |
new StringElement ("Población", dt.Rows[0]["DIC_POBLACION_ENVIO"].ToString()), | |
new StringElement ("Provincia", dt.Rows[0]["DIC_NOMBRE_PROV_ENVIO"].ToString()), | |
new StringElement ("Teléfono", dt.Rows[0]["DIC_TELEFONO"].ToString()), | |
new StringElement ("Fax", dt.Rows[0]["DIC_OBSERVACIONES"].ToString()) | |
} | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment