/// <summary>
 ///Agrega eventos a los template list item
 /// </summary>
 /// <param name="templateListItemWpf">Item a agregar a la lista</param>
 public void AttachTemplateListItemEvents(TemplateListItemWpf templateListItemWpf)
 {
     templateListItemWpf.ComponentPreviewMouseDown      += new MouseButtonEventHandler(templateListItemWpf_ComponentPreviewMouseDown);
     templateListItemWpf.ComponentPreviewMouseUp        += new MouseButtonEventHandler(templateListItemWpf_ComponentPreviewMouseUp);
     templateListItemWpf.ComponentPreviewImageMouseDown += new MouseButtonEventHandler(templateListItemWpf_ComponentPreviewImageMouseDown);
     templateListItemWpf.ComponentPreviewImageMouseUp   += new MouseButtonEventHandler(templateListItemWpf_ComponentPreviewMouseUp);
 }
 void templateListItem_ComponentPreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (this.templateListItemWpfSelected != null)
     {
         this.templateListItemWpfSelected.Border = Brushes.Black;
     }
     this.templateListItemWpfSelected    = sender as TemplateListItemWpf;
     templateListItemWpfSelected.Border  = Brushes.Red;
     this.CanvasColorSelected.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(templateListItemWpfSelected.FontColor));
     this.DataContext = templateListItemWpfSelected;
 }
 private void templateListItemWpf_ComponentPreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (IsDragDropAction || IsResizeAction)
     {
         IsResizeAction   = false;
         IsDragDropAction = false;
         TemplateListItemWpf templateListItemWpf = sender as TemplateListItemWpf;
         templateListItemWpf.XCoordinateRelativeToParent = Canvas.GetLeft(templateListItemWpf.UIElement);
         templateListItemWpf.YCoordinateRelativeToParent = Canvas.GetTop(templateListItemWpf.UIElement);
     }
 }
 private void loadVisualizationDesigner()
 {
     foreach (LogicalLibrary.Component component in tempComponents)
     {
         TemplateListItemWpf templateListItemWPF = component as TemplateListItemWpf;
         templateListItemWPF.Rectangle.Width  = component.Width;
         templateListItemWPF.Rectangle.Height = component.Height;
         templateListItemWPF.MakeCanvas();
         templateListItemWPF.ComponentPreviewMouseDown += new MouseButtonEventHandler(templateListItem_ComponentPreviewMouseDown);
         templateListFormDocument.AttachTemplateListItemEvents(templateListItemWPF);
         templateListFormDocument.AddCanvasToCanvasDraw(templateListItemWPF);
     }
 }
 /// <summary>
 /// Funcion llamada cuando el boton agregar es presionado. Este metodo agrega un template list item a la lista de items a mostrar
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Field selectedField = listBoxFields.SelectedItem as Field;
         TemplateListItemWpf templateListItem = new TemplateListItemWpf(selectedField, FontName.Arial, PresentationLayer.ServerDesignerClasses.FontSize.Medium, selectedField.DataType);
         templateListItem.MakeCanvas();
         templateListItem.ComponentPreviewMouseDown += new MouseButtonEventHandler(templateListItem_ComponentPreviewMouseDown);
         templateListFormDocument.AttachTemplateListItemEvents(templateListItem);
         tempComponents.Add(templateListItem);
         templateListFormDocument.AddCanvasToCanvasDraw(templateListItem);
     }
     catch (Exception error)
     {
         Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.UnhandledError +
                              ": " + error.Message);
     }
 }
 private void canvasDraw_MouseMove(object sender, MouseEventArgs e)
 {
     if (templateListFormDocument.IsDragDropAction)
     {
         Point newPosition = new Point();
         newPosition.X = e.GetPosition(canvasDraw).X - templateListFormDocument.MousePosition.X;
         newPosition.Y = e.GetPosition(canvasDraw).Y - templateListFormDocument.MousePosition.Y;
         UIElement element = templateListFormDocument.CurrentElement;
         if (newPosition.X < 0 || newPosition.Y < 0 || newPosition.Y > canvasDraw.ActualHeight || newPosition.X > canvasDraw.Width)
         {
             return;
         }
         Canvas.SetLeft(element, newPosition.X);
         Canvas.SetTop(element, newPosition.Y);
     }
     else if (templateListFormDocument.IsResizeAction)
     {
         TemplateListItemWpf element = templateListFormDocument.CurrentComponent as TemplateListItemWpf;
         double width  = e.GetPosition(canvasDraw).X - Canvas.GetLeft(element.MyCanvas);
         double height = e.GetPosition(canvasDraw).Y - Canvas.GetTop(element.MyCanvas);
         element.LoadElementSize(width, height);
     }
 }
 public void RemoveTemplateListItem(TemplateListItemWpf item)
 {
     base.AddComponent(item);
 }
 /// <summary>
 /// Agrega un nuevo item a la lista de templatelistitem.
 /// </summary>
 /// <param name="templateListItemWpf">Item a agregar a la lista</param>
 public void AddTemplateListItem(TemplateListItemWpf templateListItemWpf)
 {
     base.AddComponent(templateListItemWpf);
     this.AttachTemplateListItemEvents(templateListItemWpf);
     this.AddCanvasToCanvasDraw(templateListItemWpf);
 }
 public void RemoveCanvasToCanvasDraw(TemplateListItemWpf templateListItemWpf)
 {
     this.canvasDraw.Children.Remove(templateListItemWpf.MyCanvas);
 }
 public void AddCanvasToCanvasDraw(TemplateListItemWpf templateListItemWpf)
 {
     this.canvasDraw.Children.Add(templateListItemWpf.MyCanvas);
     Canvas.SetLeft(templateListItemWpf.MyCanvas, templateListItemWpf.XCoordinateRelativeToParent);
     Canvas.SetTop(templateListItemWpf.MyCanvas, templateListItemWpf.YCoordinateRelativeToParent);
 }