private void ItemInit(object sender, RoutedEventArgs e) { //Initalisierung eines News Items (Animationen, Position) ScatterViewItem item = sender as ScatterViewItem; TranslateTransform offsetTransform = new TranslateTransform(); item.RenderTransform = offsetTransform; Random rnd = new Random(); item.CanScale = false; item.SingleInputRotationMode = SingleInputRotationMode.ProportionalToDistanceFromCenter; item.Orientation = rnd.Next(30) - 15; Point startPoint = new Point(1820 - item.ActualWidth / 2, 400); Point endPoint = new Point(840 - item.ActualWidth / 2, 450); item.Center = endPoint; FillBehavior fillBehavior = FillBehavior.Stop; PointAnimation offsetYAnimation = new PointAnimation(startPoint, endPoint, new Duration(TimeSpan.FromSeconds(.5)), fillBehavior); offsetYAnimation.BeginTime = TimeSpan.FromSeconds(0); item.BeginAnimation(ScatterViewItem.CenterProperty, offsetYAnimation); DoubleAnimation scaleAnimation = new DoubleAnimation(60, 500, new Duration(TimeSpan.FromSeconds(.5)), fillBehavior); scaleAnimation.BeginTime = TimeSpan.FromSeconds(0); item.BeginAnimation(ScatterViewItem.HeightProperty, scaleAnimation); }
public void PointerUpdatedEvent(RemotePointer updatedPointer) { this.Dispatcher.Invoke(new Action(() => { try { ScatterViewItem pointerContainer = findViewItemWithPointerID(updatedPointer.Id); if (pointerContainer == null) { return; } if (!updatedPointer.IsActive) { //make pointer fade out DoubleAnimation anim = new DoubleAnimation(0, TimeSpan.FromSeconds(2)); pointerContainer.BeginAnimation(UserControl.OpacityProperty, anim); //pointerContainer.Visibility = System.Windows.Visibility.Hidden; sv_RemotePointerCanvas.UpdateLayout(); pointerContainer.Tag = updatedPointer; Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerLeft(updatedPointer)); } else { //make pointer fade in if (!((RemotePointer)pointerContainer.Tag).IsActive) { DoubleAnimation anim = new DoubleAnimation(1, TimeSpan.FromSeconds(0.2)); pointerContainer.BeginAnimation(UserControl.OpacityProperty, anim); Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerReentered(updatedPointer)); } //update location int X = (int)(updatedPointer.X * canvasesContainer.Width); int Y = (int)(updatedPointer.Y * canvasesContainer.Height); pointerContainer.Center = new System.Windows.Point(X, Y); if (((RemotePointer)pointerContainer.Tag).IsActive) { Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerMoved(updatedPointer)); } pointerContainer.Tag = updatedPointer; sv_RemotePointerCanvas.UpdateLayout(); } } catch (Exception ex) { Utilities.UtilitiesLib.LogError(ex); } })); }
//---------------------------------------------------------// /// <summary> /// Animates all current pieces off the side of the screen. /// </summary> private void RemoveAllPieces() { if (scatter.Items.Count == 0) { selectionEnabled = true; return; } // Use a for loop here instead of a foreach so the variable used in the animation complete // callback is not modified between the time the callback is hooked up and the time it is called. for (int i = 0; i < scatter.Items.Count; i++) { ScatterViewItem item = (ScatterViewItem)scatter.Items[i]; PointAnimation remove = ((PointAnimation)Resources["RemovePiece"]).Clone(); // Can't animate if center isn't set yet, which would happen if a piece has not yet been manipulated if (double.IsNaN(item.Center.X)) { item.Center = item.ActualCenter; } // Set up a callback that passes the ScatterViewItem that will be needed when the animation completes remove.Completed += delegate(object sender, EventArgs e) { OnRemoveAnimationCompleted(item); }; // Start the animation item.BeginAnimation(ScatterViewItem.CenterProperty, remove, HandoffBehavior.SnapshotAndReplace); } }
void timer_Tick(object sender, EventArgs e) { this.ParentJanitor.ScreenSaverRuns = true; this.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, (DummyDelegate) delegate { ScatterViewItem svi = new ScatterViewItem(); //Viewbox svi = new Viewbox(); Viewbox vb = new Viewbox(); Label label = new Label(); label.Content = d[rand.Next(0, d.Count)]; label.Foreground = new SolidColorBrush(Colors.White); label.Width = 200; label.Height = 50; label.FontSize = 20; label.FontWeight = FontWeights.ExtraLight; label.HorizontalContentAlignment = HorizontalAlignment.Center; vb.Child = label; svi.Content = vb; vb.IsEnabled = false; svi.Orientation = 0; svi.Opacity = 0; svi.Width = 4000; svi.Height = 1000; BlurEffect blur = new BlurEffect(); blur.Radius = 50; blur.RenderingBias = RenderingBias.Performance; blur.KernelType = KernelType.Gaussian; svi.Effect = blur; svi.ApplyTemplate(); svi.Background = new SolidColorBrush(Colors.Transparent); svi.ShowsActivationEffects = false; Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome ssc; ssc = svi.Template.FindName("shadow", svi) as Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome; ssc.Visibility = Visibility.Hidden; svi.BorderBrush = Brushes.Transparent; svi.IsHitTestVisible = false; svi.ClipToBounds = false; DoubleAnimation blurAnim = new DoubleAnimation(20, 10, new Duration(TimeSpan.FromSeconds(4)), FillBehavior.Stop); blurAnim.AutoReverse = true; blur.BeginAnimation(BlurEffect.RadiusProperty, blurAnim, HandoffBehavior.Compose); DoubleAnimation WidthAnim = new DoubleAnimation(200, 4000, new Duration(TimeSpan.FromSeconds(8)), FillBehavior.Stop); WidthAnim.Completed += new EventHandler(WidthAnim_Completed); svi.BeginAnimation(ScatterViewItem.WidthProperty, WidthAnim, HandoffBehavior.Compose); DoubleAnimation HeightAnim = new DoubleAnimation(50, 1000, new Duration(TimeSpan.FromSeconds(8)), FillBehavior.Stop); svi.BeginAnimation(ScatterViewItem.HeightProperty, HeightAnim, HandoffBehavior.Compose); DoubleAnimation OpacityAnim = new DoubleAnimation(0, .5, new Duration(TimeSpan.FromSeconds(4)), FillBehavior.Stop); OpacityAnim.AutoReverse = true; svi.BeginAnimation(ScatterViewItem.OpacityProperty, OpacityAnim, HandoffBehavior.Compose); //sb.Children.Add(blurAnim); //sb.Children.Add(WidthAnim); //sb.Children.Add(HeightAnim); //sb.Children.Add(OpacityAnim); //Storyboard.SetTarget(blurAnim, blur); //Storyboard.SetTarget(WidthAnim, svi); //Storyboard.SetTarget(HeightAnim, svi); //Storyboard.SetTarget(OpacityAnim, svi); //Storyboard.SetTargetProperty(blurAnim, new PropertyPath(BlurEffect.RadiusProperty)); //Storyboard.SetTargetProperty(WidthAnim, new PropertyPath(ScatterViewItem.WidthProperty)); //Storyboard.SetTargetProperty(HeightAnim, new PropertyPath(ScatterViewItem.HeightProperty)); //Storyboard.SetTargetProperty(OpacityAnim, new PropertyPath(ScatterViewItem.OpacityProperty)); //sb.Begin(); MainSV.Items.Add(svi); }); }
private void ScatterView_Drop(object sender, Microsoft.Surface.Presentation.SurfaceDragDropEventArgs e) { //Darstellen des Dokuments das in den Viewer(ScatterView) gedropped wird. //Leeren des Viewers viewer.Items.Clear(); //Bestimmen des Pfades des darzustellenden Dokuments aus e.Cursor.Data FileInfo file = new FileInfo(System.IO.Path.Combine((e.Cursor.Data as InfoItem).FolderPath, (e.Cursor.Data as InfoItem).fileName)); //Erstellt ein ScatterViewItem als Träger für das Dokument ScatterViewItem newItemSVI = new ScatterViewItem(); //Überprüfen ob es sich um ein als png gerendertes pdf handelt, oder ein rtf if (file.Extension.Equals(".rtf")) { //Erstellen und füllen einer RichTextBox im ScatterViewItem falls rtf var newItem = new RichTextBox(); newItem.Background = Brushes.Transparent; FileStream fs = new FileStream(System.IO.Path.Combine((e.Cursor.Data as InfoItem).FolderPath, (e.Cursor.Data as InfoItem).fileName), FileMode.Open, FileAccess.Read); TextRange RTBText = new TextRange(newItem.Document.ContentStart, newItem.Document.ContentEnd); RTBText.Load(fs, DataFormats.Rtf); newItem.IsHitTestVisible = false; newItemSVI.Content = newItem; newItemSVI.Background = Brushes.White; //newItemSVI.BeginAnimation(ScatterViewItem.HeightProperty, animY); } else { //Konvertierung des Datei-strings in ein Bild im ScatterViewItem falls png (bzw. nicht rtf) Image image = new Image(); //image.Source = (new ImageSourceConverter().ConvertFromString(file.FullName)) as ImageSource; var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(file.FullName); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.EndInit(); image.Source = bitmap; newItemSVI.Content = image; newItemSVI.Background = Brushes.Transparent; } newItemSVI.Width = 491; newItemSVI.Height = 700; //ImageBrush imgBrush = new ImageBrush(); //imgBrush.ImageSource = (new ImageSourceConverter().ConvertFromString("Images\\noun_project_450.png")) as ImageSource; //newItemSVI.Background = imgBrush; //Erzeugen und einblenden des ScatterViewItems das das Dokument beinhaltet, zuweisen des TouchVerhaltens newItemSVI.IsHitTestVisible = true; newItemSVI.Orientation = 0; newItemSVI.CanScale = false; newItemSVI.CanRotate = false; newItemSVI.CanMove = false; DropShadowEffect effect = new DropShadowEffect(); effect.BlurRadius = 20; newItemSVI.Effect = effect; //newItemSVI.Center = e.Cursor.GetPosition(viewer); newItemSVI.Center = new Point(490, 390); viewer.Items.Add(newItemSVI); //DoubleAnimation animRot = new DoubleAnimation(0, 0, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); DoubleAnimation animX = new DoubleAnimation(156, 491, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); DoubleAnimation animY = new DoubleAnimation(200, 700, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); PointAnimation animCenter = new PointAnimation(e.Cursor.GetPosition(viewer), new Point(490, 390), new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); //DoubleAnimation animCenterY = new DoubleAnimation(e.Cursor.GetPosition(viewer).Y, 350, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); //newItemSVI.BeginAnimation(ScatterViewItem.OrientationProperty, animRot); newItemSVI.BeginAnimation(ScatterViewItem.WidthProperty, animX); newItemSVI.BeginAnimation(ScatterViewItem.HeightProperty, animY); newItemSVI.BeginAnimation(ScatterViewItem.CenterProperty, animCenter); infoItems.Remove((e.Cursor.Data as InfoItem)); infoItems.Add(new InfoItem((e.Cursor.Data as InfoItem).FolderPath, (e.Cursor.Data as InfoItem).fileName, (e.Cursor.Data as InfoItem).GroupName)); //MessageBox.Show((e.Cursor.Data as InfoItem).FolderPath+"\\"+(e.Cursor.Data as InfoItem).fileName); //GenerateItems(); newItemSVI.PreviewTouchUp += new EventHandler<TouchEventArgs>(newItemSVI_PreviewTouchUp); newItemSVI.PreviewTouchDown += new EventHandler<TouchEventArgs>(newItemSVI_PreviewTouchDown); }
void newItemSVI_PreviewTouchUp(object sender, TouchEventArgs e) { //Vergrößern/Verkleinern des gewählten Dokuments durch TouchEvent ScatterViewItem displayedItem = (sender as ScatterViewItem); double targetwidth = 758; double targetheight = 1080; Point targetcenter = new Point(490, 390); double initialwidth = 491; double initialheight = 700; Point initialcenter = new Point(400, 390); double duration = .25; //Vergrößern, wenn Darstellung klein ist. if (displayedItem.Height == 700) { targetheight = 1080; targetwidth = 758; targetcenter = new Point(400, 390); initialwidth = 491; initialheight = 700; initialcenter = new Point(490, 390); displayedItem.Height = targetheight; displayedItem.Width = targetwidth; displayedItem.Center = targetcenter; //Menübuttons deaktivieren _hauptformular.button1.IsEnabled = false; _hauptformular.button2.IsEnabled = false; _hauptformular.button3.IsEnabled = false; _hauptformular.button4.IsEnabled = false; _hauptformular.homeButton.IsEnabled = false; _hauptformular.button6.IsEnabled = false; _hauptformular.button7.IsEnabled = false; } //Verkleiner, wenn Darstellung groß ist. else { targetheight = 700; targetwidth = 491; targetcenter = new Point(490, 390); initialwidth = 758; initialheight = 1080; initialcenter = new Point(400, 390); displayedItem.Height = 700; displayedItem.Width = 491; displayedItem.Center = new Point(490, 390); //Menüttons, bis auf den Infoscreen Button aktivieren _hauptformular.button1.IsEnabled = true; _hauptformular.button2.IsEnabled = true; _hauptformular.button3.IsEnabled = true; _hauptformular.button4.IsEnabled = true; _hauptformular.homeButton.IsEnabled = false; _hauptformular.button6.IsEnabled = true; _hauptformular.button7.IsEnabled = true; } //Animation ausführen DoubleAnimation animX = new DoubleAnimation(initialwidth, targetwidth, new Duration(TimeSpan.FromSeconds(duration)), FillBehavior.Stop); DoubleAnimation animY = new DoubleAnimation(initialheight, targetheight, new Duration(TimeSpan.FromSeconds(duration)), FillBehavior.Stop); PointAnimation animCenter = new PointAnimation(initialcenter, targetcenter, new Duration(TimeSpan.FromSeconds(duration)), FillBehavior.Stop); displayedItem.BeginAnimation(ScatterViewItem.WidthProperty, animX); displayedItem.BeginAnimation(ScatterViewItem.HeightProperty, animY); displayedItem.BeginAnimation(ScatterViewItem.CenterProperty, animCenter); }
private void ScatterView_Drop(object sender, Microsoft.Surface.Presentation.SurfaceDragDropEventArgs e) { //Darstellen des Dokuments das in den Viewer(ScatterView) gedropped wird. //Leeren des Viewers viewer.Items.Clear(); //Bestimmen des Pfades des darzustellenden Dokuments aus e.Cursor.Data FileInfo file = new FileInfo(System.IO.Path.Combine((e.Cursor.Data as InfoItem).FolderPath, (e.Cursor.Data as InfoItem).fileName)); //Erstellt ein ScatterViewItem als Träger für das Dokument ScatterViewItem newItemSVI = new ScatterViewItem(); //Überprüfen ob es sich um ein als png gerendertes pdf handelt, oder ein rtf if (file.Extension.Equals(".rtf")) { //Erstellen und füllen einer RichTextBox im ScatterViewItem falls rtf var newItem = new RichTextBox(); newItem.Background = Brushes.Transparent; FileStream fs = new FileStream(System.IO.Path.Combine((e.Cursor.Data as InfoItem).FolderPath, (e.Cursor.Data as InfoItem).fileName), FileMode.Open, FileAccess.Read); TextRange RTBText = new TextRange(newItem.Document.ContentStart, newItem.Document.ContentEnd); RTBText.Load(fs, DataFormats.Rtf); newItem.IsHitTestVisible = false; newItemSVI.Content = newItem; newItemSVI.Background = Brushes.White; //newItemSVI.BeginAnimation(ScatterViewItem.HeightProperty, animY); } else { //Konvertierung des Datei-strings in ein Bild im ScatterViewItem falls png (bzw. nicht rtf) Image image = new Image(); //image.Source = (new ImageSourceConverter().ConvertFromString(file.FullName)) as ImageSource; var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(file.FullName); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.EndInit(); image.Source = bitmap; newItemSVI.Content = image; newItemSVI.Background = Brushes.Transparent; } newItemSVI.Width = 491; newItemSVI.Height = 700; //ImageBrush imgBrush = new ImageBrush(); //imgBrush.ImageSource = (new ImageSourceConverter().ConvertFromString("Images\\noun_project_450.png")) as ImageSource; //newItemSVI.Background = imgBrush; //Erzeugen und einblenden des ScatterViewItems das das Dokument beinhaltet, zuweisen des TouchVerhaltens newItemSVI.IsHitTestVisible = true; newItemSVI.Orientation = 0; newItemSVI.CanScale = false; newItemSVI.CanRotate = false; newItemSVI.CanMove = false; DropShadowEffect effect = new DropShadowEffect(); effect.BlurRadius = 20; newItemSVI.Effect = effect; //newItemSVI.Center = e.Cursor.GetPosition(viewer); newItemSVI.Center = new Point(490, 390); viewer.Items.Add(newItemSVI); //DoubleAnimation animRot = new DoubleAnimation(0, 0, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); DoubleAnimation animX = new DoubleAnimation(156, 491, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); DoubleAnimation animY = new DoubleAnimation(200, 700, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); PointAnimation animCenter = new PointAnimation(e.Cursor.GetPosition(viewer), new Point(490, 390), new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); //DoubleAnimation animCenterY = new DoubleAnimation(e.Cursor.GetPosition(viewer).Y, 350, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.Stop); //newItemSVI.BeginAnimation(ScatterViewItem.OrientationProperty, animRot); newItemSVI.BeginAnimation(ScatterViewItem.WidthProperty, animX); newItemSVI.BeginAnimation(ScatterViewItem.HeightProperty, animY); newItemSVI.BeginAnimation(ScatterViewItem.CenterProperty, animCenter); infoItems.Remove((e.Cursor.Data as InfoItem)); infoItems.Add(new InfoItem((e.Cursor.Data as InfoItem).FolderPath, (e.Cursor.Data as InfoItem).fileName, (e.Cursor.Data as InfoItem).GroupName)); //MessageBox.Show((e.Cursor.Data as InfoItem).FolderPath+"\\"+(e.Cursor.Data as InfoItem).fileName); //GenerateItems(); newItemSVI.PreviewTouchUp += new EventHandler <TouchEventArgs>(newItemSVI_PreviewTouchUp); newItemSVI.PreviewTouchDown += new EventHandler <TouchEventArgs>(newItemSVI_PreviewTouchDown); }