Interaction logic for item_generic_v2.xaml
Inheritance: System.Windows.Controls.UserControl
 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;
 }
        private void create_submit_design_item()
        {
            submit_idea = new item_generic_v2();
            submit_idea.Background = Brushes.LightGray;
            submit_idea.avatar.Source = configurations.img_submit_idea_icon;
            submit_idea.avatar.Width = configurations.design_idea_item_avatar_width;
            submit_idea.avatar.Height = configurations.design_idea_item_avatar_width; submit_idea.avatar.Margin = new Thickness(5);
            submit_idea.num_likes.Visibility = System.Windows.Visibility.Collapsed;
            submit_idea.title.Text = configurations.submit_idea_item_title;
            //TextBlock.SetFontWeight(submit_idea.title, FontWeights.Normal);
            //submit_idea.title.FontSize = configurations.design_idea_item_title_font_size;
            submit_idea.description.Visibility = System.Windows.Visibility.Collapsed;
            submit_idea.user_info.Visibility = System.Windows.Visibility.Collapsed;
            submit_idea.info_panel.Visibility = System.Windows.Visibility.Collapsed;
            submit_idea.contribution_panel.Visibility = System.Windows.Visibility.Collapsed;
            submit_idea.txt_level1.Visibility = System.Windows.Visibility.Collapsed;
            submit_idea.center_panel.VerticalAlignment = VerticalAlignment.Center;
            submit_idea.Margin = new Thickness(2, 2, 2, 0);
            submit_idea.Height = configurations.user_item_avatar_width; //signup.avatar.Height;
            submit_idea.right_panel.Width = configurations.design_idea_right_panel_width;

            submit_idea.PreviewTouchDown += new EventHandler<TouchEventArgs>(submit_PreviewTouchDown);
            submit_idea.PreviewTouchUp += new EventHandler<TouchEventArgs>(submit_PreviewTouchUp);
            submit_idea_panel.Children.Add(submit_idea);

            //i.user_info.Margin = new Thickness(5);
            //i.user_info_name.Margin = new Thickness(2, 0, 0, 0); i.user_info_date.Margin = new Thickness(2, 0, 2, 0);
            //i.user_info_name.FontSize = configurations.design_idea_item_user_info_font_size; i.user_info_date.FontSize = configurations.design_idea_item_user_info_font_size;

            //submit_idea = new item_generic();
            //submit_idea.Background = Brushes.White;
            //submit_idea.user_desc.Visibility = System.Windows.Visibility.Collapsed;
            //submit_idea.number.Visibility = System.Windows.Visibility.Collapsed;
            //submit_idea.content.Visibility = System.Windows.Visibility.Collapsed;
            //submit_idea.desc.Visibility = System.Windows.Visibility.Collapsed;
            //submit_idea.username.Text = "Submit Idea";
            ////submit_idea.Background = new SolidColorBrush(Colors.LightGreen);
            //submit_idea.username.Foreground = new SolidColorBrush(Colors.Black);
            //submit_idea.user_desc.Foreground = new SolidColorBrush(Colors.White);
            //submit_idea.top_panel.Margin = new Thickness(13, 13, 13, 13);
            //submit_idea.avatar.Source = configurations.img_submit_idea_icon;
            //submit_idea.PreviewTouchDown += new EventHandler<TouchEventArgs>(submit_Click);
            //submit_idea_panel.Children.Add(submit_idea);
        }
Ejemplo n.º 3
0
        public static void open_design_idea_window(string[] idea_item, double pos_x, double pos_y, string title = "Design Idea")
        {
            if (window_manager.design_ideas_frames.Count + 1 > configurations.max_design_ideas_frame)
                return;

            window_frame frame = new window_frame();
            window_content content = new window_content();

            item_generic_v2 i = new item_generic_v2();
            i.title.Text = idea_item[3]; i.description.Visibility = Visibility.Collapsed;
            i.title.FontSize = 17;
            i.user_info.Margin = new Thickness(5);
            i.user_info_name.Text = idea_item[5]; i.user_info_date.Text = idea_item[4];
            i.user_info_name.Margin = new Thickness(2, 0, 0, 0); i.user_info_date.Margin = new Thickness(2, 0, 2, 0);
            i.user_info_name.FontSize = 10; i.user_info_date.FontSize = 10;
            i.user_info_icon.Source = new BitmapImage(new Uri(idea_item[2])); i.number.Text = idea_item[7]; i.number_icon.Visibility = Visibility.Collapsed;
            i.txt_level1.Text = configurations.designidea_num_desc;
            i.txt_level2.Visibility = Visibility.Collapsed; i.txt_level3.Visibility = Visibility.Collapsed;
            i.avatar.Source = configurations.img_thumbs_up_icon; i.num_likes.Content = idea_item[8]; i.avatar.Tag = i;
            i.avatar.Width = 45; i.avatar.Height = 45; i.avatar.Margin = new Thickness(5);
            i.right_panel.Width = configurations.design_idea_right_panel_width;
            i.set_like_handler();
            i.Tag = idea_item[1]; i.top_value = Convert.ToInt32(idea_item[8]);

            i.Background = new SolidColorBrush(Colors.White);
            i.Width = frame.Width;
            content.initialize_contents(i, Type.GetType("nature_net.Contribution"), Convert.ToInt32(idea_item[1]), frame, idea_item[5] + "'s " + title);

            frame.window_content.Content = content;

            window_manager.design_ideas_frames.Add(frame);
            open_window(frame, pos_x, pos_y);
            frame.hide_change_view();
            frame.set_title(idea_item[5] + "'s " + title);
        }
        public void display_all_design_ideas(List<design_idea_item> ideas)
        {
            this._list.Items.Clear();
            if (initial_item != null)
                this._list.Items.Add(initial_item);

            foreach (design_idea_item idea in ideas)
            {
                item_generic_v2 i = new item_generic_v2();
                i.Background = Brushes.White;
                i.title.Text = idea.design_idea.note; i.description.Visibility = Visibility.Collapsed;
                TextBlock.SetFontWeight(i.title, FontWeights.Normal);
                i.title.FontSize = configurations.design_idea_item_title_font_size;
                i.user_info.Margin = new Thickness(5);
                i.user_info_name.Text = idea.design_idea.name; i.user_info_date.Text = configurations.GetDate_Formatted(idea.last_date);
                i.user_info_name.Margin = new Thickness(2, 0, 0, 0); i.user_info_date.Margin = new Thickness(2, 0, 2, 0);
                i.user_info_name.FontSize = configurations.design_idea_item_user_info_font_size; i.user_info_date.FontSize = configurations.design_idea_item_user_info_font_size;
                i.user_info_icon.Source = idea.img; i.number.Text = idea.count.ToString(); i.number_icon.Visibility = Visibility.Collapsed;
                i.txt_level1.Text = configurations.designidea_num_desc;
                i.txt_level2.Visibility = Visibility.Collapsed; i.txt_level3.Visibility = Visibility.Collapsed;
                i.avatar.Source = configurations.img_thumbs_up_icon; i.num_likes.Content = idea.num_like.ToString();
                i.avatar.Width = configurations.design_idea_item_avatar_width; i.avatar.Height = configurations.design_idea_item_avatar_width; i.avatar.Margin = new Thickness(5); i.avatar.Tag = i;
                i.Tag = idea.design_idea.id;
                i.Margin = items_margins;
                if (item_width != 0) i.Width = item_width;
                i.right_panel.Width = configurations.design_idea_right_panel_width;
                //i.left_panel.VerticalAlignment = VerticalAlignment.Center; DockPanel.SetDock(i.number, Dock.Left); DockPanel.SetDock(i.txt_level1, Dock.Left);
                i.top_value = idea.num_like;
                i.drag_icon_vertical.Source = configurations.img_drag_vertical_icon;
                if (configurations.show_vertical_drag) i.drag_icon_vertical_panel.Visibility = Visibility.Visible;
                if (thumbs_up_handler != null)
                    i.avatar.Tag = i;
                this._list.Items.Add(i);
            }
            if (header.atoz.IsChecked.Value && header.atoz_order != null) header.atoz_order();
            if (header.top.IsChecked.Value && header.top_order != null) header.top_order();
            if (header.recent.IsChecked.Value && header.recent_order != null) header.recent_order();
            this._list.Items.Refresh();
            this._list.UpdateLayout();
        }
        public void display_all_activities(List<activity_item> activities)
        {
            this._list.Items.Clear();
            if (initial_item != null)
                this._list.Items.Add(initial_item);

            foreach (activity_item a in activities)
            {
                item_generic_v2 i = new item_generic_v2();
                i.title.Text = a.activity.name; i.title.Margin = new Thickness(5);
                i.description.Text = a.activity.description; i.description.Margin = new Thickness(5);
                i.txt_level2.Text = configurations.GetDate_Formatted(a.last_date);
                i.txt_level3.Text = a.username; i.number.Text = a.count.ToString();
                i.Tag = a.activity.id;
                i.txt_level1.Visibility = Visibility.Collapsed;
                i.left_panel.Visibility = Visibility.Collapsed;
                if (item_width != 0) i.Width = item_width;
                i.Margin = items_margins;
                i.user_info.Visibility = Visibility.Collapsed; i.user_info_date.Text = i.txt_level2.Text;
                i.top_value = a.count;
                i.drag_icon_vertical.Source = configurations.img_drag_vertical_icon;
                if (configurations.show_vertical_drag) i.drag_icon_vertical_panel.Visibility = Visibility.Visible;
                this._list.Items.Add(i);
            }
            if (header.atoz.IsChecked.Value && header.atoz_order != null) header.atoz_order();
            if (header.top.IsChecked.Value && header.top_order != null) header.top_order();
            if (header.recent.IsChecked.Value && header.recent_order != null) header.recent_order();
            this._list.Items.Refresh();
            this._list.UpdateLayout();
        }
        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);
        }
        public void display_all_users(List<user_item> users)
        {
            this._list.Items.Clear();
            if (initial_item != null)
                this._list.Items.Add(initial_item);

            foreach (user_item u in users)
            {
                item_generic_v2 i = new item_generic_v2();
                if (u.has_date)
                    i.txt_level2.Text = configurations.GetDate_Formatted(u.last_date);
                else
                    i.txt_level2.Text = configurations.users_no_date;
                i.title.Text = u.user.name; i.avatar.Source = u.img; i.Tag = u.user.id;
                i.number.Text = u.count.ToString();
                if (item_width != 0) i.Width = item_width;
                i.Margin = items_margins; i.txt_level2.Margin = new Thickness(0, 0, 0, 10);
                i.num_likes.Visibility = Visibility.Collapsed; i.txt_level1.Visibility = Visibility.Collapsed;
                i.txt_level3.Visibility = Visibility.Collapsed; i.description.Visibility = Visibility.Collapsed;
                i.center_panel.VerticalAlignment = VerticalAlignment.Center;
                i.avatar.Width = configurations.user_item_avatar_width; i.avatar.Height = configurations.user_item_avatar_width;
                i.user_info.Visibility = Visibility.Collapsed; i.user_info_date.Text = i.txt_level2.Text;
                i.top_value = u.count;
                i.drag_icon_vertical.Source = configurations.img_drag_vertical_icon;
                if (configurations.show_vertical_drag) i.drag_icon_vertical_panel.Visibility = Visibility.Visible;
                this._list.Items.Add(i);
            }
            if (header.atoz.IsChecked.Value && header.atoz_order != null) header.atoz_order();
            if (header.top.IsChecked.Value && header.top_order != null) header.top_order();
            if (header.recent.IsChecked.Value && header.recent_order != null) header.recent_order();
            this._list.Items.Refresh();
            this._list.UpdateLayout();
        }
Ejemplo n.º 8
0
        private void create_signup_item()
        {
            signup = new item_generic_v2();
            signup.Background = Brushes.LightGray;
            signup.avatar.Source = configurations.img_signup_icon;
            signup.num_likes.Visibility = System.Windows.Visibility.Collapsed;
            signup.title.Text = configurations.signup_item_title;
            signup.description.Visibility = System.Windows.Visibility.Collapsed;
            signup.user_info.Visibility = System.Windows.Visibility.Collapsed;
            signup.info_panel.Visibility = System.Windows.Visibility.Collapsed;
            signup.contribution_panel.Visibility = System.Windows.Visibility.Collapsed;
            signup.txt_level1.Visibility = System.Windows.Visibility.Collapsed;
            signup.center_panel.VerticalAlignment = VerticalAlignment.Center;
            signup.avatar.Width = configurations.user_item_avatar_width;
            signup.Margin = new Thickness(2, 2, 2, 0);
            signup.Height = configurations.user_item_avatar_width; //signup.avatar.Height;

            signup.PreviewTouchDown += new EventHandler<TouchEventArgs>(signup_PreviewTouchDown);
            signup.PreviewTouchUp += new EventHandler<TouchEventArgs>(signup_PreviewTouchUp);
            signup_panel.Children.Add(signup);

            //signup = new item_generic();
            //signup.Background = Brushes.White;
            //signup.user_desc.Visibility = System.Windows.Visibility.Collapsed;
            //signup.number.Visibility = System.Windows.Visibility.Collapsed;
            //signup.content.Visibility = System.Windows.Visibility.Collapsed;
            //signup.desc.Visibility = System.Windows.Visibility.Collapsed;
            //signup.username.Text = "Sign up";
            ////signup.Background = new SolidColorBrush(Colors.LightGreen);
            //signup.username.Foreground = new SolidColorBrush(Colors.Black);
            //signup.user_desc.Foreground = new SolidColorBrush(Colors.White);
            //signup.top_panel.Margin = new Thickness(13, 13, 13, 13);
            //signup.avatar.Source = configurations.img_signup_icon;
            //signup.PreviewTouchDown += new EventHandler<TouchEventArgs>(signup_PreviewTouchDown);
            //signup.avatar.Source = configurations.img_signup_icon;
            //signup_panel.Children.Add(signup);
        }