Esempio n. 1
0
    public static FlowDocument AddFlow(this StackPanel sp, Flow flow, MainWindow win)
    {
      FlowDocumentParser fdp = new FlowDocumentParser() { TextAlignment = TextAlignment.Left };
      fdp.Doc.Cursor = Cursors.Hand;

      fdp.AddBold(flow.Title);
      fdp.AddNewLine();
      fdp.AddBold("by " + flow.Author.Name + " at " + 
        String.Format("{0:dd/MM/yyyy HH:mm}", flow.UpdatedAt));
      fdp.AddNewLine();
      fdp.AddBold("Tags: ");
      fdp.AddPart(String.Join(", ", flow.Tags));

      FlowDocumentScrollViewer fdsv = new FlowDocumentScrollViewer()
      {
        HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
        Document = fdp.Doc,
        VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
        Foreground = new SolidColorBrush(Colors.White),
        Cursor = Cursors.Hand
      };

      Border border = new Border()
      {
        BorderThickness = new Thickness(2, 5, 2, 5),
        CornerRadius = new CornerRadius(10),
        Padding = new Thickness(3),
        Background = new SolidColorBrush(Colors.Black),
        Cursor = Cursors.Hand,
        Child = fdsv
      };

      border.PreviewMouseDown += new MouseButtonEventHandler((object sender, MouseButtonEventArgs e) =>
      {
        e.Handled = true;
        win.LoadFlow(flow.ID);
      });

      fdp.Doc.PreviewMouseWheel += Bubbler;
      fdsv.PreviewMouseWheel += Bubbler;
      fdsv.SizeChanged += Resizer;

      sp.Children.Add(border);

      return fdp.Doc;
    }
Esempio n. 2
0
 static public void AddFlows(this StackPanel sp, Flow[] flows, MainWindow win)
 {
   for (int i = 0; i < flows.Length; i++)
     sp.AddFlow(flows[i], win);
 }