// This block of code attempts to minimize the number of // type operations and assignments involved in figuring out what // trigger type we're dealing here. // Attempted casts are done in the order of decreasing expected frequency. // rearrange as expectations change. private static void DetermineTriggerType( TriggerBase triggerBase, out Trigger trigger, out MultiTrigger multiTrigger, out DataTrigger dataTrigger, out MultiDataTrigger multiDataTrigger, out EventTrigger eventTrigger ) { if( (trigger = (triggerBase as Trigger)) != null ) { multiTrigger = null; dataTrigger = null; multiDataTrigger = null; eventTrigger = null; } else if( (multiTrigger = (triggerBase as MultiTrigger)) != null ) { dataTrigger = null; multiDataTrigger = null; eventTrigger = null; } else if( (dataTrigger = (triggerBase as DataTrigger)) != null ) { multiDataTrigger = null; eventTrigger = null; } else if( (multiDataTrigger = (triggerBase as MultiDataTrigger)) != null ) { eventTrigger = null; } else if( (eventTrigger = (triggerBase as EventTrigger)) != null ) { ; // Do nothing - eventTrigger is now non-null, and everything else has been set to null. } else { // None of the above - the caller is expected to throw an exception // stating that the trigger type is not supported. } }
public TraditionalClock() { //http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard.aspx // Create a name scope for the window. NameScope.SetNameScope(this, new NameScope()); this.Name = "clockWindow"; this.AllowsTransparency=true; this.Background=Brushes.Transparent; this.WindowStyle=WindowStyle.None; this.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.LeftButtonDown); //this.RegisterName(this.Name, this); Storyboard clockHandStoryboard = new Storyboard(); //// create the parallel timeline which contains the clockhand animations ParallelTimeline pt = new ParallelTimeline(TimeSpan.FromSeconds(0)); //<DoubleAnimation From="-9" To="351" Duration="00:01:00" RepeatBehavior="Forever" // Storyboard.TargetProperty="Angle" Storyboard.TargetName="secondHandAngle"/> DoubleAnimation secondHandAnimation = new DoubleAnimation(-9, 351, new Duration(new TimeSpan(0, 1, 0))); Storyboard.SetTargetName(secondHandAnimation, "secondHandAngle"); Storyboard.SetTargetProperty(secondHandAnimation, new PropertyPath(RotateTransform.AngleProperty)); secondHandAnimation.RepeatBehavior = RepeatBehavior.Forever; //<DoubleAnimation From="-9" To="351" Duration="12:00:00" RepeatBehavior="Forever" // Storyboard.TargetProperty="Angle" Storyboard.TargetName="hourHandAngle" /> DoubleAnimation hourHandAngleAnimation = new DoubleAnimation(-9, 351, new Duration(new TimeSpan(12, 0, 0))); Storyboard.SetTargetName(hourHandAngleAnimation, "hourHandAngle"); Storyboard.SetTargetProperty(hourHandAngleAnimation, new PropertyPath(RotateTransform.AngleProperty)); hourHandAngleAnimation.RepeatBehavior = RepeatBehavior.Forever; //<DoubleAnimation From="-9" To="351" Duration="01:00:00" RepeatBehavior="Forever" // Storyboard.TargetProperty="Angle" Storyboard.TargetName="minuteHandAnimation" /> DoubleAnimation minuteHandAnimation = new DoubleAnimation(-9, 351, new Duration(new TimeSpan(1, 0, 0))); Storyboard.SetTargetName(minuteHandAnimation, "minuteHandAngle"); Storyboard.SetTargetProperty(minuteHandAnimation, new PropertyPath(RotateTransform.AngleProperty)); minuteHandAnimation.RepeatBehavior = RepeatBehavior.Forever; //// add the animations to the timeline pt.Children.Add(secondHandAnimation); pt.Children.Add(hourHandAngleAnimation); pt.Children.Add(minuteHandAnimation); //// add the timeline to the storyboard clockHandStoryboard.Children.Add(pt); this.Resources.Add("clockHandStoryboard", clockHandStoryboard); this.RegisterName("clockHandStoryboard", clockHandStoryboard); ////<Canvas Name="clockCanvas" Width="292" Height="493" > clockCanvas.Name = "clockCanvas"; clockCanvas.Width = 292; clockCanvas.Height = 493; //<EventTrigger RoutedEvent="Canvas.Loaded"> EventTrigger canvasTrigger = new EventTrigger(); canvasTrigger.RoutedEvent = Canvas.LoadedEvent; //<BeginStoryboard Name ="clockHandStoryboard" Storyboard="{StaticResource clockHandStoryboard}" /> BeginStoryboard beginStory = new BeginStoryboard(); beginStory.Name = "clockHandStoryboard"; beginStory.Storyboard = clockHandStoryboard; canvasTrigger.Actions.Add(beginStory); clockCanvas.Triggers.Add(canvasTrigger); /** Clock Hands */ //<Image Source="TradClock.png" Loaded="SetTime" /> Image tradClock = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.BeginInit(); bi3.UriSource = new Uri("TradClock.png", UriKind.Relative); bi3.EndInit(); tradClock.Source = bi3; tradClock.Loaded += new RoutedEventHandler(this.SetTime); clockCanvas.Children.Add(tradClock); //<Polygon Name="hourHand" Canvas.Top="214" Canvas.Left="173" Points="0,5 3,0 4,0 8,5 8,50 0,50"> Polygon hourHand = new Polygon(); //http://msdn.microsoft.com/en-us/library/system.windows.shapes.polygon.points.aspx Point hPoint1 = new Point(0, 5); Point hPoint2 = new Point(3, 0); Point hPoint3 = new Point(4, 0); Point hPoint4 = new Point(8, 5); Point hPoint5 = new Point(8, 50); Point hPoint6 = new Point(0, 50); PointCollection myPointCollection = new PointCollection(); myPointCollection.Add(hPoint1); myPointCollection.Add(hPoint2); myPointCollection.Add(hPoint3); myPointCollection.Add(hPoint4); myPointCollection.Add(hPoint5); myPointCollection.Add(hPoint6); hourHand.Points = myPointCollection; //<LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> //http://msdn.microsoft.com/en-us/library/system.windows.shapes.shape.fill.aspx LinearGradientBrush hourHandBrush = new LinearGradientBrush(); hourHandBrush.StartPoint = new Point(0, 0); hourHandBrush.EndPoint = new Point(1, 0); //<LinearGradientBrush.GradientStops> //<GradientStop Offset="0" Color="White" /> //<GradientStop Offset="1" Color="DarkGray" /> //http://msdn.microsoft.com/en-us/library/system.windows.media.lineargradientbrush.aspx hourHandBrush.GradientStops.Add(new GradientStop(Colors.White, 0)); hourHandBrush.GradientStops.Add(new GradientStop(Colors.DarkGray, 1)); hourHand.Fill = hourHandBrush; hourHand.Name = "hourHand"; //<Polygon.RenderTransform> //<RotateTransform x:Name="hourHandAngle" CenterX="4" CenterY="45" /> //http://msdn.microsoft.com/en-us/library/ms752357.aspx RotateTransform hourHandAngle = new RotateTransform(); this.RegisterName("hourHandAngle", hourHandAngle); hourHandAngle.CenterX = 4; hourHandAngle.CenterY = 45; hourHand.RenderTransform = hourHandAngle; //http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.top.aspx Canvas.SetTop(hourHand, 214); Canvas.SetLeft(hourHand, 173); clockCanvas.Children.Add(hourHand); //<Polygon Name="minuteHand" Canvas.Top="183" Canvas.Left="173" Points="0,5 1,0 2,0 4,5 4,80 0,80"> Polygon minuteHand = new Polygon(); Point mPoint1 = new Point(0, 5); Point mPoint2 = new Point(1, 0); Point mPoint3 = new Point(2, 0); Point mPoint4 = new Point(4, 5); Point mPoint5 = new Point(4, 80); Point mPoint6 = new Point(0, 80); PointCollection myPointCollection2 = new PointCollection(); myPointCollection2.Add(mPoint1); myPointCollection2.Add(mPoint2); myPointCollection2.Add(mPoint3); myPointCollection2.Add(mPoint4); myPointCollection2.Add(mPoint5); myPointCollection2.Add(mPoint6); minuteHand.Points = myPointCollection2; minuteHand.Fill = hourHandBrush; minuteHand.Name = "minuteHand"; //<RotateTransform x:Name="minuteHandAnimation" CenterX="2" CenterY="75"/> RotateTransform minuteHandAngle = new RotateTransform(); this.RegisterName("minuteHandAngle", minuteHandAngle); minuteHandAngle.CenterX = 2; minuteHandAngle.CenterY = 75; minuteHand.RenderTransform = minuteHandAngle; Canvas.SetTop(minuteHand, 183); Canvas.SetLeft(minuteHand, 173); clockCanvas.Children.Add(minuteHand); //<Polygon Name="secondHand" Canvas.Top="170" Canvas.Left="175" Points="0,0 2,0 2,95 0,95" > Polygon secondHand = new Polygon(); Point sPoint1 = new Point(0, 0); Point sPoint2 = new Point(2, 0); Point sPoint3 = new Point(2, 95); Point sPoint4 = new Point(0, 95); PointCollection myPointCollection3 = new PointCollection(); myPointCollection3.Add(sPoint1); myPointCollection3.Add(sPoint2); myPointCollection3.Add(sPoint3); myPointCollection3.Add(sPoint4); secondHand.Points = myPointCollection3; secondHand.Fill = hourHandBrush; secondHand.Name = "minuteHand"; //<RotateTransform x:Name="secondHandAngle" CenterX="0" CenterY="90"/> RotateTransform secondHandAngle = new RotateTransform(); this.RegisterName("secondHandAngle", secondHandAngle); secondHandAngle.CenterX = 0; secondHandAngle.CenterY = 90; secondHand.RenderTransform = secondHandAngle; Canvas.SetTop(secondHand, 170); Canvas.SetLeft(secondHand, 175); clockCanvas.Children.Add(secondHand); //<!--Center circles--> //<Ellipse Canvas.Top="248" Canvas.Left="168" Width="18" Height="20" Stroke="DarkGray"> Ellipse outerEllipse = new Ellipse(); Canvas.SetTop(outerEllipse, 248); Canvas.SetLeft(outerEllipse, 168); outerEllipse.Width = 18; outerEllipse.Height = 20; outerEllipse.Stroke = Brushes.DarkGray; //<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> LinearGradientBrush outerEllipseBrush = new LinearGradientBrush(); outerEllipseBrush.StartPoint = new Point(0, 0); outerEllipseBrush.EndPoint = new Point(1, 0); //<LinearGradientBrush.GradientStops> //<GradientStop Offset="0" Color="LightCoral"/> //<GradientStop Offset="1" Color="Red"/> outerEllipseBrush.GradientStops.Add(new GradientStop(Colors.LightCoral, 0)); outerEllipseBrush.GradientStops.Add(new GradientStop(Colors.Red, 1)); outerEllipse.Fill = outerEllipseBrush; clockCanvas.Children.Add(outerEllipse); //<Ellipse Canvas.Top="254" Canvas.Left="174" Width="6" Height="8" Fill="DarkGray" Stroke="Black" /> Ellipse innerEllipse = new Ellipse(); Canvas.SetTop(innerEllipse, 254); Canvas.SetLeft(innerEllipse, 174); innerEllipse.Width = 6; innerEllipse.Height = 8; innerEllipse.Fill = Brushes.DarkGray; innerEllipse.Stroke = Brushes.Black; clockCanvas.Children.Add(innerEllipse); this.Content = clockCanvas; }
public void EventTriggerBasicTest() { EventTrigger trigger = new EventTrigger { RoutedEvent = Event1Event }; trigger.Actions.Add(new Setter { Property = new DependencyPropertyPathElement(Value1Property), Value = 1 }); FrameworkElement element = new FrameworkElement(); Assert.AreEqual(0, element.GetValue(Value1Property)); element.Triggers.Add(trigger); Assert.AreEqual(0, element.GetValue(Value1Property)); element.RaiseEvent(new RoutedEventArgs(Event1Event, element)); Assert.AreEqual(1, element.GetValue(Value1Property)); element.Triggers.Remove(trigger); Assert.AreEqual(0, element.GetValue(Value2Property)); }
private static void OnIsEnabledChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) { var element = target as FrameworkElement; if (element == null) return; if (!(bool)e.NewValue) return; var animation = new DoubleAnimation { To = 1, From = 0, EasingFunction = new PowerEase { EasingMode = EasingMode.EaseOut }, Duration = TimeSpan.FromMilliseconds(700), }; Storyboard.SetTarget(animation, element); Storyboard.SetTargetProperty(animation, new PropertyPath(UIElement.OpacityProperty)); var story = new Storyboard(); story.Children.Add(animation); var trigger = new EventTrigger(); trigger.Actions.Add(new BeginStoryboard { Storyboard = story, }); element.Triggers.Add(trigger); }
internal EventTriggerSourceListener( EventTrigger trigger, FrameworkElement host ) { _owningTrigger = trigger; _owningTriggerHost = host; }
private EventTrigger CloseAnimation(RoutedEvent RE) { EventTrigger eventTrigger = new EventTrigger(RE); BeginStoryboard beginStoryBoard = new BeginStoryboard(); Storyboard storyBoard = new Storyboard(); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.From = panelHeight; doubleAnimation.To = 0; doubleAnimation.Duration = new Duration(new TimeSpan(5000000)); Storyboard.SetTargetName(doubleAnimation, "spPanel"); Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(StackPanel.Height)")); storyBoard.Children.Add(doubleAnimation); beginStoryBoard.Storyboard = storyBoard; eventTrigger.Actions.Add(beginStoryBoard); return eventTrigger; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.grd = ((System.Windows.Controls.Grid)(target)); return; case 2: this.txtTitle = ((System.Windows.Controls.TextBlock)(target)); return; case 3: this.txtText = ((System.Windows.Controls.TextBlock)(target)); return; case 4: #line 17 "..\..\NotificationWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click); #line default #line hidden return; case 5: this.trig = ((System.Windows.EventTrigger)(target)); return; case 6: #line 30 "..\..\NotificationWindow.xaml" ((System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames)(target)).Completed += new System.EventHandler(this.DoubleAnimationUsingKeyFrames_Completed); #line default #line hidden return; } this._contentLoaded = true; }
// // This method // 1. Adds the trigger information to the data structure that will be // used when it's time to add the delegate to the event route. // internal static void ProcessEventTrigger ( EventTrigger eventTrigger, HybridDictionary childIndexFromChildName, ref HybridDictionary triggerActions, ref ItemStructList<ChildEventDependent> eventDependents, FrameworkElementFactory templateRoot, FrameworkTemplate frameworkTemplate, ref EventHandlersStore eventHandlersStore, ref bool hasLoadedChangeHandler) { if( eventTrigger == null ) { return; } // The list of actions associated with the event of this EventTrigger. List<TriggerAction> actionsList = null; bool actionsListExisted = true; bool actionsListChanged = false; TriggerAction action = null; FrameworkElementFactory childFef = null; // Find a ChildID for the EventTrigger. if( eventTrigger.SourceName == null ) { eventTrigger.TriggerChildIndex = 0; } else { int childIndex = StyleHelper.QueryChildIndexFromChildName(eventTrigger.SourceName, childIndexFromChildName); if( childIndex == -1 ) { throw new InvalidOperationException(SR.Get(SRID.EventTriggerTargetNameUnresolvable, eventTrigger.SourceName)); } eventTrigger.TriggerChildIndex = childIndex; } // We have at least one EventTrigger - will need triggerActions // if it doesn't already exist if (triggerActions == null) { triggerActions = new HybridDictionary(); } else { actionsList = triggerActions[eventTrigger.RoutedEvent] as List<TriggerAction>; } // Set up TriggerAction list if one doesn't already exist if (actionsList == null) { actionsListExisted = false; actionsList = new List<TriggerAction>(); } for (int i = 0; i < eventTrigger.Actions.Count; i++) { action = eventTrigger.Actions[i]; // Any reason we shouldn't use this TriggerAction? Check here. if( false /* No reason not to use it right now */ ) { // continue; } // Looks good, add to list. Debug.Assert(action.IsSealed, "TriggerAction should have already been sealed by this point."); actionsList.Add(action); actionsListChanged = true; } if (actionsListChanged && !actionsListExisted) { triggerActions[eventTrigger.RoutedEvent] = actionsList; } // Add a special delegate to listen for this event and // fire the trigger. if( templateRoot != null || eventTrigger.TriggerChildIndex == 0 ) { // This is a FEF-style template, or the trigger is keying off of // the templated parent. // Get the FEF that is referenced by this trigger. if (eventTrigger.TriggerChildIndex != 0) { childFef = StyleHelper.FindFEF(templateRoot, eventTrigger.TriggerChildIndex); } // If this trigger needs the loaded/unloaded events, set the optimization // flag. if ( (eventTrigger.RoutedEvent == FrameworkElement.LoadedEvent) ||(eventTrigger.RoutedEvent == FrameworkElement.UnloadedEvent)) { if (eventTrigger.TriggerChildIndex == 0) { // Mark the template to show it has a loaded or unloaded handler hasLoadedChangeHandler = true; } else { // Mark the FEF to show it has a loaded or unloaded handler childFef.HasLoadedChangeHandler = true; } } // Add a delegate that'll come back and fire these actions. // This information will be used by FrameworkElement.AddStyleHandlersToEventRoute StyleHelper.AddDelegateToFireTrigger(eventTrigger.RoutedEvent, eventTrigger.TriggerChildIndex, templateRoot, childFef, ref eventDependents, ref eventHandlersStore); } else { // This is a baml-style template. // If this trigger needs the loaded/unloaded events, set the optimization // flag. if (eventTrigger.RoutedEvent == FrameworkElement.LoadedEvent || eventTrigger.RoutedEvent == FrameworkElement.UnloadedEvent ) { FrameworkTemplate.TemplateChildLoadedFlags templateChildLoadedFlags = frameworkTemplate._TemplateChildLoadedDictionary[ eventTrigger.TriggerChildIndex ] as FrameworkTemplate.TemplateChildLoadedFlags; if( templateChildLoadedFlags == null ) { templateChildLoadedFlags = new FrameworkTemplate.TemplateChildLoadedFlags(); frameworkTemplate._TemplateChildLoadedDictionary[ eventTrigger.TriggerChildIndex ] = templateChildLoadedFlags; } if( eventTrigger.RoutedEvent == FrameworkElement.LoadedEvent ) { templateChildLoadedFlags.HasLoadedChangedHandler = true; } else { templateChildLoadedFlags.HasUnloadedChangedHandler = true; } } // Add a delegate that'll come back and fire these actions. StyleHelper.AddDelegateToFireTrigger(eventTrigger.RoutedEvent, eventTrigger.TriggerChildIndex, ref eventDependents, ref eventHandlersStore); } }
public void IconSelectSetIconSourcePaths(string[] iconSourceFilePaths) { try { DoubleAnimation mo_animation = new DoubleAnimation { From = 1.0, To = 0.1, Duration = new Duration(TimeSpan.FromSeconds(0.25)), AutoReverse = true }; var mo_storyboard = new Storyboard { RepeatBehavior = RepeatBehavior.Forever }; Storyboard.SetTargetProperty(mo_animation, new PropertyPath("(Opacity)")); mo_storyboard.Children.Add(mo_animation); BeginStoryboard enterBeginStoryboard = new BeginStoryboard { Name = this.Name + "_esb",//img.Name + "_esb", Storyboard = mo_storyboard }; // Set the name of the storyboard so it can be found NameScope.GetNameScope(this).RegisterName(enterBeginStoryboard.Name, enterBeginStoryboard); registeredNames.Add(enterBeginStoryboard.Name); // create event callbacks var moe = new EventTrigger(MouseEnterEvent); moe.Actions.Add(enterBeginStoryboard); var mle = new EventTrigger(MouseLeaveEvent); mle.Actions.Add( new StopStoryboard { BeginStoryboardName = enterBeginStoryboard.Name }); for (int fileCount = 0; fileCount < iconSourceFilePaths.Length; fileCount++) { if (string.Empty != iconSourceFilePaths[fileCount]) { if ( (System.IO.File.Exists(iconSourceFilePaths[fileCount]) || System.IO.Directory.Exists(iconSourceFilePaths[fileCount])) ) { int imgCount = 0; //if (null != ibm) ibm.Clear(); ObservableCollection<IconBitMap> iconBitmaps = ico2bmap.ExtractAllIconBitMapFromFile(iconSourceFilePaths[fileCount]); foreach (IconBitMap ico in iconBitmaps) { IconImage img = new IconImage() { idxFile = fileCount, idxIcon = imgCount, Name = "iconselect_img_" + imgCount.ToString() + "_" + fileCount.ToString(), Source = ico.bitmapsource, Width = ico.BitmapSize, Margin = new Thickness(4) }; img.MouseDown += Img_MouseDown; /// storyboard /// img.Triggers.Add(moe); img.Triggers.Add(mle); img.MouseEnter += Img_MouseEnter; //+= (s, e) => Mouse.OverrideCursor = Cursors.Hand; img.MouseLeave += Img_MouseLeave; // Add it and count it to make sure each has a unique name MainIconPanel.Children.Add(img); imgCount++; } iconBitmaps.Clear(); } } //else { lnkio.WriteProgramLog("Cannot find or read icon source file: " + (string.Empty == iconSourceFilePaths[fileCount] ? "File name is missing" : iconSourceFilePaths[fileCount])); } } } catch( Exception e ) { lnkio.WriteProgramLog("IconSelect() error: " + e.Message); //throw new Exception("Get new icon error: " + e.Message); } //finally { if (ibm != null) ibm.Clear(); } MainIconPanel.Visibility = Visibility.Visible; // create a panel to draw in //Content = MainPanel; return; }
private void AddPathAnimation() { EventTrigger et = new EventTrigger(Path.MouseEnterEvent); BeginStoryboard bs = new BeginStoryboard(); ColorAnimation ca = new ColorAnimation { To = Colors.LightBlue, Duration = TimeSpan.FromSeconds(0), AutoReverse = false }; Storyboard.SetTarget(ca, Path); Storyboard.SetTargetProperty(ca, new PropertyPath("Stroke.Color")); bs.Storyboard = new Storyboard(); bs.Storyboard.Children.Add(ca); bs.Storyboard.Completed += (o, e) => { Path.StrokeThickness = _strokePathThickness * 2; }; et.Actions.Add(bs); Path.Triggers.Add(et); et = new EventTrigger(Path.MouseLeaveEvent); bs = new BeginStoryboard(); ca = new ColorAnimation { To = ((SolidColorBrush)Path.Stroke).Color, Duration = TimeSpan.FromSeconds(0), AutoReverse = false }; Storyboard.SetTarget(ca, Path); Storyboard.SetTargetProperty(ca, new PropertyPath("Stroke.Color")); bs.Storyboard = new Storyboard(); bs.Storyboard.Children.Add(ca); bs.Storyboard.Completed += (o, e) => { Path.StrokeThickness = _strokePathThickness; }; et.Actions.Add(bs); Path.Triggers.Add(et); Path.ToolTip = Edge.SourceNode.LabelText + " " + _category + " " + Edge.TargetNode.LabelText; }
public MainWindow() { InitializeComponent(); Name = "KickoffMainWindow"; // Windows logoff or shutdown Application.Current.SessionEnding += Current_SessionEnding; //Program ending Application.Current.Exit += Current_Exit; //ObservableCollection<IconBitMap> allico = ico2bmap.ExtractAllIconBitMapFromFile("shell32.dll"); // allow data to be dragged into app AllowDrop = true; //WindowStyle = WindowStyle.ToolWindow; //WindowStyle = WindowStyle.SingleBorderWindow;//WindowStyle.None;// WindowStyle.SingleBorderWindow; //this.WindowStyle = WindowStyle.None; this. //AllowsTransparency = true; // Turn off the min and max buttons and add my menu items to the main window context menu WindowStyle = WindowStyle.SingleBorderWindow; this.SourceInitialized += (x, y) => { this.HideMinimizeAndMaximizeButtons(); this.ModifyMenu(); }; ResizeMode = ResizeMode.CanResize; SizeToContent = SizeToContent.Manual; //.WidthAndHeight; ////Height = 400; Width = 150; Background = System.Windows.Media.Brushes.AntiqueWhite; // SystemColors.WindowBrush; // Brushes.AntiqueWhite; Foreground = System.Windows.SystemColors.WindowTextBrush; // Brushes.DarkBlue; //MainPanel = new WrapPanel(); MainPanel.Margin = new Thickness(2); MainPanel.Width = Double.NaN; //auto MainPanel.Height = Double.NaN; //auto MainPanel.AllowDrop = true; MainPanel.Visibility = Visibility.Visible; // add handlers for mouse entering and leaving the main window MouseEnter += MainWindow_MouseEnter; MouseLeave += MainWindow_MouseLeave; DragEnter += MainWindow_DragEnter; DragOver += MainWindow_DragOver; GiveFeedback += MainWindow_GiveFeedback; Drop += MainWindow_Drop; ShortcutCounter = 0; /// MENUS // Shortcut Right Click context menu MenuItem miSC_ChangeICO = new MenuItem(); miSC_ChangeICO.Width = 160; miSC_ChangeICO.Header = "_Change Icon"; miSC_ChangeICO.Click += MiSC_ChangeICO_Click; shortcutCtxMenu.Items.Add(miSC_ChangeICO); MenuItem miSC_Delete = new MenuItem(); miSC_Delete.Width = 120; miSC_Delete.Header = "_Delete"; miSC_Delete.Click += MiSC_Delete_Click; shortcutCtxMenu.Items.Add(miSC_Delete); // Create animation storyboard DoubleAnimation mo_animation = new DoubleAnimation { From = 1.0, To = 0.1, Duration = new Duration(TimeSpan.FromSeconds(0.35)), AutoReverse = true //RepeatBehavior = RepeatBehavior.Forever }; var mo_storyboard = new Storyboard { RepeatBehavior = RepeatBehavior.Forever }; Storyboard.SetTargetProperty(mo_animation, new PropertyPath("(Opacity)")); mo_storyboard.Children.Add(mo_animation); BeginStoryboard enterBeginStoryboard = new BeginStoryboard { Name = this.Name + "_esb", //sc.Name + "_esb", Storyboard = mo_storyboard }; // Set the name of the storyboard so it can be found NameScope.GetNameScope(this).RegisterName(enterBeginStoryboard.Name, enterBeginStoryboard); moe = new EventTrigger(MouseEnterEvent); moe.Actions.Add(enterBeginStoryboard); mle = new EventTrigger(MouseLeaveEvent); mle.Actions.Add( new StopStoryboard { BeginStoryboardName = enterBeginStoryboard.Name }); // create a panel to draw in Content = MainPanel; // add load behavior to change size and position to last saved Loaded += MainWindow_Loaded; //DataContext = this; }