Interaction logic for item_generic.xaml
상속: System.Windows.Controls.UserControl
예제 #1
0
 public item_generic get_clone()
 {
     item_generic i = new item_generic();
     i.avatar.Source = this.avatar.Source; i.avatar.Visibility = this.avatar.Visibility;
     i.username.Text = this.username.Text; i.user_desc.Content = this.user_desc.Content;
     i.username.TextDecorations = this.username.TextDecorations;
     i.number.Text = this.number.Text; i.number.Visibility = this.number.Visibility;
     i.user_desc.Visibility = this.user_desc.Visibility;
     i.desc.Content = this.desc.Content; i.content.Text = this.content.Text;
     i.desc.Visibility = this.desc.Visibility;
     i.content.Visibility = this.content.Visibility;
     i.Width = this.Width; i.Tag = this.Tag;
     i.BorderThickness = this.BorderThickness;
     i.BorderBrush = this.BorderBrush;
     i.toolbar.Visibility = this.toolbar.Visibility;
     i.label_like.Content = this.label_like.Content; i.label_dislike.Content = this.label_dislike.Content;
     i.img_like.Tag = this.img_like.Tag; i.img_dislike.Tag = this.img_dislike.Tag;
     return i;
 }
예제 #2
0
 public void display_all_activities(object arg, RunWorkerCompletedEventArgs e)
 {
     this._list.Items.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
        new System.Action(() =>
        {
            this._list.Items.Clear();
            List<Activity> activities = (List<Activity>)e.Result;
            foreach (Activity a in activities)
            {
                item_generic i = new item_generic();
                i.username.Text = a.name;
                i.user_desc.Content = configurations.GetDate_Formatted(a.creation_date);
                //i.user_desc.Visibility = System.Windows.Visibility.Collapsed;
                i.desc.Content = "Description:";
                i.content.Text = a.description;
                if (parent != null) { i.Width = parent.ActualWidth - 75; }
                i.username.FontWeight = FontWeights.Bold;
                i.username.Width = i.username.Width + 30;
                i.BorderBrush = Brushes.Gray; i.BorderThickness = new Thickness(0, 0, 0, 2);
                i.avatar.Visibility = System.Windows.Visibility.Collapsed;
                //i.avatar.Source = new BitmapImage(new Uri(configurations.GetAbsoluteAvatarPath() + c.User.avatar));
                i.Tag = a.id;
                if (configurations.use_avatar_drag) i.set_touchevent(this.avatar_drag);
                i.Margin = items_margins;
                this._list.Items.Add(i);
            }
            this._list.Items.Refresh();
            this._list.UpdateLayout();
        }));
 }
예제 #3
0
 private void _list_SelectionChanged(item_generic item)
 {
     if (list_design_ideas)
     {
         string[] idea_item = ("design idea;" + item.ToString()).Split(new Char[] { ';' });
         window_manager.open_design_idea_window(idea_item, 0, item.PointToScreen(new Point(0, 0)).Y);
         _list.SelectedIndex = -1;
         return;
     }
     if (list_users)
     {
         window_manager.open_collection_window((string)item.username.Text, (int)item.Tag, 0, item.PointToScreen(new Point(0, 0)).Y);
         ///////window_manager.open_collections_balloon(item.PointToScreen(new Point(0, 0)).Y, (string)item.username.Content);
         _list.SelectedIndex = -1;
         return;
     }
     if (list_comments)
     {
         string[] idea_item = ("comment;" + item.ToString()).Split(new Char[] { ';' });
         //window_manager.open_design_idea_window(idea_item,
         //    configurations.RANDOM((int)(window_manager.main_canvas.ActualWidth - item.ActualWidth) - 20,
         //    (int)(window_manager.main_canvas.ActualWidth - item.ActualWidth)),
         //    item.PointToScreen(new Point(0, 0)).Y);
         _list.SelectedIndex = -1;
         return;
     }
     if (list_activities)
     {
         string[] activity_item = ("activity;" + item.ToString()).Split(new Char[] { ';' });
         window_manager.open_activity_window(activity_item[3], Convert.ToInt32(activity_item[1]), 0, item.PointToScreen(new Point(0, 0)).Y);
         _list.SelectedIndex = -1;
         return;
     }
     _list.SelectedIndex = -1;
 }
예제 #4
0
 public void display_all_users(object us, RunWorkerCompletedEventArgs e)
 {
     this._list.Items.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
         new System.Action(() =>
         {
             this._list.Items.Clear();
             List<user_item> users = (List<user_item>)e.Result;
             foreach (user_item u in users)
             {
                 item_generic i = new item_generic();
                 i.username.Text = u.user.name;
                 //i.user_desc.Content = u.email;
                 i.user_desc.Visibility = System.Windows.Visibility.Collapsed;
                 i.desc.Visibility = System.Windows.Visibility.Collapsed;
                 i.content.Visibility = System.Windows.Visibility.Collapsed;
                 i.avatar.Source = u.img;
                 if (parent != null) i.Width = parent.Width - 10;
                 i.Tag = u.user.id;
                 if (configurations.use_avatar_drag) i.set_touchevent(this.avatar_drag);
                 i.Margin = items_margins;
                 this._list.Items.Add(i);
             }
             this._list.Items.Refresh();
             this._list.UpdateLayout();
         }));
 }
예제 #5
0
 public void display_all_design_ideas(object di, RunWorkerCompletedEventArgs e)
 {
     this._list.Items.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
         new System.Action(() =>
         {
             this._list.Items.Clear();
             List<design_idea_item> ideas = (List<design_idea_item>)e.Result;
             foreach (design_idea_item idea in ideas)
             {
                 item_generic i = new item_generic();
                 i.username.Text = idea.design_idea.name;
                 //i.user_desc.Visibility = System.Windows.Visibility.Collapsed;
                 i.user_desc.Content = configurations.GetDate_Formatted(idea.design_idea.date);
                 i.desc.Content = "Contributed:";
                 i.content.Text = idea.design_idea.note;
                 if (configurations.use_avatar_drag) i.set_touchevent(this.avatar_drag);
                 if (parent != null) i.Width = parent.Width - 10;
                 i.avatar.Source = idea.img;
                 i.Tag = idea.design_idea.id;
                 i.Margin = items_margins;
                 this._list.Items.Add(i);
             }
             this._list.Items.Refresh();
             this._list.UpdateLayout();
         }));
 }
예제 #6
0
        public void display_all_comments(object c_obj, RunWorkerCompletedEventArgs e)
        {
            this._list.Items.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
               new System.Action(() =>
               {
                   this._list.Items.Clear();
                   if (initial_comment != null)
                       this._list.Items.Add(initial_comment);

                   List<Feedback> comments = (List<Feedback>)e.Result;
                   foreach (Feedback c in comments)
                   {
                       item_generic i = new item_generic();
                       i.username.Text = c.User.name;
                       i.user_desc.Content = configurations.GetDate_Formatted(c.date);
                       //i.user_desc.Visibility = System.Windows.Visibility.Collapsed;
                       i.desc.Content = "Commented:";
                       i.content.Text = c.note;
                       if (parent != null) i.Width = parent.Width - 10;
                       i.avatar.Source = new BitmapImage(new Uri(configurations.GetAbsoluteAvatarPath() + c.User.avatar));
                       i.Tag = c.id;
                       if (configurations.use_avatar_drag) i.set_touchevent(this.avatar_drag);
                       i.Margin = items_margins;
                       this._list.Items.Add(i);
                   }
                   this._list.Items.Refresh();
                   this._list.Padding = new Thickness(0);
                   this._list.UpdateLayout();
               }));
        }
        public void display_all_comments(object c_obj, RunWorkerCompletedEventArgs e)
        {
            this._list.Items.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
               new System.Action(() =>
               {
                   this._list.Items.Clear();
                   if (initial_item != null)
                       this._list.Items.Add(initial_item);

                   List<comment_item_generic> comments = (List<comment_item_generic>)e.Result;
                   if (this.total_number != null)
                       this.total_number.Text = comments.Count.ToString();
                   foreach (comment_item_generic cig in comments)
                   {
                       item_generic i = new item_generic();
                       //i.username.Text = cig.comment.User.name + ":"; TextBlock.SetFontWeight(i.username, FontWeights.Bold);
                       i.username.Text = "";
                       i.username.Inlines.Add(new Bold(new Run(cig.comment.User.name + ": ")));
                       i.username.Inlines.Add(cig.comment.note);
                       i.user_desc.Visibility = Visibility.Collapsed; //i.user_desc.Content = configurations.GetDate_Formatted(cig.comment.date);
                       i.number.Text = configurations.GetDate_Formatted(cig.comment.date); //i.number.Visibility = System.Windows.Visibility.Collapsed;
                       i.number.FontSize = configurations.design_idea_item_user_info_font_size;
                       i.desc.Visibility = Visibility.Collapsed;// i.desc.Content = "Commented:";
                       i.topleft_panel.VerticalAlignment = VerticalAlignment.Top;
                       i.top_panel.Margin = new Thickness(5, 10, 5, 10);
                       //i.content.Text = cig.comment.note;
                       i.content.Visibility = Visibility.Collapsed;
                       if (item_width != 0) i.Width = item_width + 2;
                       i.avatar.Source = new BitmapImage(new Uri(configurations.GetAbsoluteAvatarPath() + cig.comment.User.avatar));
                       i.Tag = cig.comment.id;
                       if (configurations.use_avatar_drag) i.set_touchevent(this.avatar_drag);
                       i.Margin = new Thickness(0);
                       i.second_border.Margin = new Thickness(cig.level * 25, 0, 0, 0);
                       i.first_border.BorderBrush = Brushes.Gray; i.first_border.BorderThickness = new Thickness(0, 0, 0, 1);
                       i.second_border.BorderBrush = Brushes.DarkGray; i.second_border.BorderThickness = new Thickness(1, 0, 0, 0);
                       if (this.reply_clicked_handler != null && cig.level < (configurations.max_thread_reply - 1)) i.set_replybutton(this.reply_clicked_handler);
                       this._list.Items.Add(i);
                   }

                   if (this._list.Items.Count == 0)
                       this._list.Height = 0;
                   else
                       this._list.Height = Double.NaN;

                   this._list.Items.Refresh();
                   this._list.Padding = new Thickness(0);
                   this._list.UpdateLayout();
               }));
        }