nature_net.user_controls.item_generic_v2.get_clone C# (CSharp) Метод

get_clone() публичный Метод

public get_clone ( ) : item_generic_v2
Результат item_generic_v2
        public item_generic_v2 get_clone()
        {
            item_generic_v2 i = new item_generic_v2();
            i.avatar.Source = this.avatar.Source; i.avatar.Visibility = this.avatar.Visibility; i.avatar.Width = this.avatar.Width; i.avatar.Height = this.avatar.Height; i.avatar.Tag = this.avatar.Tag;
            i.title.Text = this.title.Text; i.description.Text = this.description.Text; i.description.Visibility = this.description.Visibility;
            i.title.FontFamily = this.title.FontFamily; i.title.FontSize = this.title.FontSize; i.FontWeight = this.FontWeight;
            i.number.Text = this.number.Text; i.number.Visibility = this.number.Visibility;
            i.number_icon.Source = this.number_icon.Source; i.number_icon.Visibility = this.number_icon.Visibility;
            i.Width = this.Width; i.Tag = this.Tag;
            i.BorderThickness = this.BorderThickness;
            i.BorderBrush = this.BorderBrush;
            i.txt_level1.Text = this.txt_level1.Text; i.txt_level1.Visibility = this.txt_level1.Visibility; i.txt_level1.Margin = this.txt_level1.Margin;
            i.txt_level2.Text = this.txt_level2.Text; i.txt_level2.Visibility = this.txt_level2.Visibility; i.txt_level2.Margin = this.txt_level2.Margin;
            i.txt_level3.Text = this.txt_level3.Text; i.txt_level3.Visibility = this.txt_level3.Visibility; i.txt_level3.Margin = this.txt_level3.Margin;
            i.center_panel.VerticalAlignment = this.center_panel.VerticalAlignment;
            i.left_panel.Visibility = this.left_panel.Visibility;
            i.right_panel.Width = this.right_panel.Width;
            i.title.Margin = this.title.Margin;
            i.description.Margin = this.description.Margin;
            i.user_info.Visibility = this.user_info.Visibility;
            i.user_info_date.Text = this.user_info_date.Text; i.user_info_date.Margin = this.user_info_date.Margin;
            i.user_info_icon.Source = this.user_info_icon.Source; i.user_info_icon.Margin = this.user_info_icon.Margin;
            i.user_info_name.Text = this.user_info_name.Text;i.user_info_name.Margin = this.user_info_name.Margin;
            i.num_likes.Content = this.num_likes.Content; i.num_likes.Tag = this.num_likes.Tag;
            i.top_value = this.top_value;
            return i;
        }

Usage Example

        private bool start_drag(item_generic_v2 item, TouchEventArgs e)
        {
            if (item == null) return false;
            ContentControl cursorVisual = new ContentControl();
            cursorVisual.Content = item.get_clone();
            cursorVisual.Style = (FindResource("CursorStyle") as Style);

            List<TouchDevice> devices = new List<TouchDevice>();
            devices.Add(e.TouchDevice);
            foreach (TouchDevice touch in item.TouchesCapturedWithin)
            {
                if (touch != e.TouchDevice)
                {
                    devices.Add(touch);
                }
            }

            if (item.Tag == null) return false;

            //string avatar = "";
            //if (item.avatar.Source != null)
            //    avatar = item.avatar.Source.ToString();
            //string data = drag_prefix + ";" + ((int)item.Tag).ToString() + ";" + avatar + ";" +
            //    (string)item.title.Text + ";" + item.description.Text + ";" + "" + ";" + "";
            string data = drag_prefix + ";" + item.ToString();
            log.WriteInteractionLog(4, "start dragging the listbox item: " + item.ToString(), e.TouchDevice);
            Microsoft.Surface.Presentation.SurfaceDragCursor startDragOkay =
                Microsoft.Surface.Presentation.SurfaceDragDrop.BeginDragDrop(
                  this._list,                 // The SurfaceListBox object that the cursor is dragged out from.
                  item,                       // The item object that is dragged from the drag source.
                  cursorVisual,               // The visual element of the cursor.
                  data,                       // The data associated with the cursor.
                  devices,                    // The input devices that start dragging the cursor.
                  DragDropEffects.Copy);      // The allowed drag-and-drop effects of the operation.

            return (startDragOkay != null);
        }