예제 #1
0
        public void SetFrameSize(CGSize newFrameSize, bool animating)
        {
            CGRect newFrame = FrameForNewSizePinnedToTopLeft(newFrameSize);

            if (animating)
            {
                NSAnimation animation = new NSViewAnimation(new [] {
                    NSDictionary.FromObjectsAndKeys(
#if MONOMAC
                        new object[] { this, NSValue.FromRectangleF(Frame), NSValue.FromRectangleF(newFrame) },
#else
                        new object[] { this, NSValue.FromCGRect(Frame), NSValue.FromCGRect(newFrame) },
#endif
                        new object[] { NSViewAnimation.TargetKey, NSViewAnimation.StartFrameKey, NSViewAnimation.EndFrameKey }
                        )
                });
                animation.AnimationBlockingMode = NSAnimationBlockingMode.Nonblocking;
                animation.Duration = 0.25;
                animation.StartAnimation();
            }
            else
            {
                Superview.SetNeedsDisplayInRect(Frame);
                Frame        = newFrame;
                NeedsDisplay = true;
            }
        }
        void StartViewAnotation(NSView currentView)
        {
            var dict1 = SideBarViewAnimation(currentView, true);

            NSDictionary [] dict = new NSDictionary[1];
            dict.SetValue(dict1, 0);
            using (var animation = new NSViewAnimation(dict)) {
                animation.Duration       = 0;
                animation.AnimationCurve = NSAnimationCurve.Linear;
                animation.StartAnimation();
            }
        }
예제 #3
0
        // Shared initialization code
        void Initialize()
        {
            this.Window.AlphaValue = 0;
            this.Window.MakeKeyAndOrderFront(this);

            // Fade in splash screen
            NSMutableDictionary dict = new NSMutableDictionary();
            dict.Add(NSViewAnimation.TargetKey, Window);
            dict.Add(NSViewAnimation.EffectKey, NSViewAnimation.FadeInEffect);
            NSViewAnimation anim = new NSViewAnimation(new List<NSMutableDictionary>(){ dict }.ToArray());
            anim.Duration = 0.4f;
            anim.StartAnimation();
        }
예제 #4
0
		public MainWindowController(Action<IBaseView> onViewReady) : base ("MainWindow", onViewReady)
        {
            this.Window.AlphaValue = 0;
            ShowWindowCentered();

            // Fade in main window
            NSMutableDictionary dict = new NSMutableDictionary();
            dict.Add(NSViewAnimation.TargetKey, Window);
            dict.Add(NSViewAnimation.EffectKey, NSViewAnimation.FadeInEffect);
            NSViewAnimation anim = new NSViewAnimation(new List<NSMutableDictionary>(){ dict }.ToArray());
            anim.Duration = 0.25f;
            anim.StartAnimation();
        }
        partial void SplitButtonClick(NSObject sender)
        {
            NSView currentView;

            if (ContentButton.State == NSCellStateValue.On)
            {
                currentView = TocCustomView;
            }
            else if (IndexButton.State == NSCellStateValue.On)
            {
                currentView = IndexCustomView;
            }
            else
            {
                currentView = AnnotationView;
            }
                        #if false
            isSideBarShow = !isSideBarShow;
            var             sidebarViewDict = SideBarViewAnimation(currentView, isSideBarShow);
            NSDictionary [] dict            = new NSDictionary[1];
            dict.SetValue(sidebarViewDict, 0);
            using (var animation = new NSViewAnimation(dict)) {
                animation.Duration       = 0.2;
                animation.AnimationCurve = NSAnimationCurve.EaseIn;
                animation.StartAnimation();
            }
            bool isFull = !isSideBarShow;
            RelayoutContentPageView(isFull);
                        #endif

                        #if true
            isSideBarShow = !isSideBarShow;
            var  sidebarViewDict = SideBarViewAnimation(currentView, isSideBarShow);
            bool isFull          = !isSideBarShow;
            var  contentViewDict = ContentViewAnimation(BookContentView, isFull);

            NSDictionary [] dict = new NSDictionary[2];
            dict.SetValue(sidebarViewDict, 0);
            dict.SetValue(contentViewDict, 1);
            using (var animation = new NSViewAnimation(dict)) {
                animation.Duration       = 0.2;
                animation.AnimationCurve = NSAnimationCurve.Linear;
                animation.StartAnimation();
            }
                        #endif
        }
예제 #6
0
        private void DisplayViewController(NSViewController vc)
        {
            BeginInvokeOnMainThread(() => {
                NSWindow w = box.Window;

                bool ended = w.MakeFirstResponder(w);
                if (!ended) {
                    AppKitFramework.NSBeep();
                    return;
                }
                // get the new View
                NSView newView = vc.View;

                // Get the old View
                NSView oldView = (NSView)box.ContentView;

                if (oldView == newView)
                    return;

                // Compute the new window frame
                CGSize currentSize = oldView.Frame.Size;
                CGSize newSize = newView.Frame.Size;

                nfloat deltaWidth = newSize.Width - currentSize.Width;
                nfloat deltaHeight = newSize.Height - currentSize.Height;
                CGRect windowframe = w.Frame;
                windowframe.Size = new CGSize(windowframe.Size.Width, windowframe.Size.Height + deltaHeight);
                windowframe.Location = new CGPoint(windowframe.Location.X, windowframe.Location.Y - deltaHeight);
                windowframe.Size = new CGSize(windowframe.Size.Width + deltaWidth, windowframe.Size.Height);

                NSDictionary windowResize = NSDictionary.FromObjectsAndKeys( new NSObject[]{w, NSValue.FromCGRect(windowframe)}, new NSObject[]{NSViewAnimation.TargetKey, NSViewAnimation.EndFrameKey});
                NSDictionary oldViewFadeOut = NSDictionary.FromObjectsAndKeys( new NSObject[]{oldView, NSViewAnimation.FadeOutEffect}, new NSObject[]{NSViewAnimation.TargetKey, NSViewAnimation.EffectKey});
                NSDictionary newViewFadeOut = NSDictionary.FromObjectsAndKeys( new NSObject[]{newView, NSViewAnimation.FadeOutEffect}, new NSObject[]{NSViewAnimation.TargetKey, NSViewAnimation.EffectKey});
                NSDictionary fadeIn = NSDictionary.FromObjectsAndKeys( new NSObject[]{newView, NSViewAnimation.FadeInEffect}, new NSObject[]{NSViewAnimation.TargetKey, NSViewAnimation.EffectKey});

                NSViewAnimation animation = new NSViewAnimation(new NSDictionary[]{oldViewFadeOut});
                animation.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation.AnimationCurve = NSAnimationCurve.Linear;
                animation.Duration = 0.1;
                animation.StartAnimation();

                NSViewAnimation animation2 = new NSViewAnimation(new NSDictionary[]{newViewFadeOut});
                animation2.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation2.Duration = 0.0;
                animation2.StartAnimation();

                box.ContentView = newView;

                NSViewAnimation animation3 = new NSViewAnimation(new NSDictionary[]{windowResize});
                animation3.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation3.AnimationCurve = NSAnimationCurve.EaseInOut;
                animation3.Duration = 0.2;
                animation3.StartAnimation();

                NSViewAnimation animation4 = new NSViewAnimation(new NSDictionary[]{fadeIn});
                animation4.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation4.AnimationCurve = NSAnimationCurve.Linear;
                animation4.Duration = 0.1;
                animation4.StartAnimation();
            });
        }
예제 #7
0
        public void InitDone()
        {
            InvokeOnMainThread(delegate {
                lblMessage.StringValue = "Initialization successful!";                

                // Fade out splash screen
                NSMutableDictionary dict = new NSMutableDictionary();
                dict.Add(NSViewAnimation.TargetKey, Window);
                dict.Add(NSViewAnimation.EffectKey, NSViewAnimation.FadeOutEffect);
                NSViewAnimation anim = new NSViewAnimation(new List<NSMutableDictionary>(){ dict }.ToArray());
                anim.Duration = 0.4f;
                anim.StartAnimation();

            });
        }
예제 #8
0
		// Call to load from the XIB/NIB file
		public MainWindowController(Action<IBaseView> onViewReady) : base ("MainWindow", onViewReady)
        {
            // Set properties
            this.albumCoverCacheService = new AlbumCoverCacheService();

            this.Window.AlphaValue = 0;
            this.Window.MakeKeyAndOrderFront(this);

            // Fade in main window
            NSMutableDictionary dict = new NSMutableDictionary();
            dict.Add(NSViewAnimation.TargetKey, Window);
            dict.Add(NSViewAnimation.EffectKey, NSViewAnimation.FadeInEffect);
            NSViewAnimation anim = new NSViewAnimation(new List<NSMutableDictionary>(){ dict }.ToArray());
            anim.Duration = 0.4f;
            anim.StartAnimation();
		}		
예제 #9
0
        partial void SplitButtonClick(NSObject sender)
        {
            NSView currentView;

            if (ContentButton.State == NSCellStateValue.On)
            {
                currentView = TocCustomView;
                var             dict1 = SideBarViewAnimation(TocCustomView, isSideBarShow);
                var             dict2 = ContentViewAnimation(BookContentView, !isSideBarShow);
                NSDictionary [] dict  = new NSDictionary[2];
                dict.SetValue(dict1, 0);
                dict.SetValue(dict2, 1);
                var animation = new NSViewAnimation(dict);
                animation.Duration       = 0.3;
                animation.AnimationCurve = NSAnimationCurve.EaseIn;
                animation.StartAnimation();

                isSideBarShow = !isSideBarShow;

//				if (isSideBarShow) {
//					isSideBarShow = false;
//					var dict1 = SideBarViewAnimation(TocCustomView, true);
//					var dict2 = ContentViewAnimation(BookContentView,false);
//					NSDictionary []dict = new NSDictionary[2];
//					dict.SetValue(dict1,0);
//					dict.SetValue(dict2,1);
//					var animation = new NSViewAnimation(dict);
//					animation.Duration = 0.3;
//					animation.AnimationCurve = NSAnimationCurve.EaseIn;
//					animation.StartAnimation();
//				} else {
//					isSideBarShow = true;
//					var dict1 = SideBarViewAnimation(TocCustomView, false);
//					var dict2 = ContentViewAnimation(BookContentView,true);
//					NSDictionary []dict = new NSDictionary[2];
//					dict.SetValue(dict1,0);
//					dict.SetValue(dict2,1);
//					var animation = new NSViewAnimation(dict);
//					animation.Duration = 0.3;
//					animation.AnimationCurve = NSAnimationCurve.EaseIn;
//					animation.StartAnimation();
//				}
            }
            else if (IndexButton.State == NSCellStateValue.On)
            {
                if (IndexCustomView.Hidden)
                {
                    IndexCustomView.Hidden = false;
                    RelayoutIndexCustomView(true);
                }
                else
                {
                    IndexCustomView.Hidden = true;
                    RelayoutIndexCustomView(false);
                }
            }
            else
            {
                if (AnnotationView.Hidden)
                {
                    AnnotationView.Hidden = false;
                    RelayoutAnnotaionView(true);
                }
                else
                {
                    AnnotationView.Hidden = true;
                    RelayoutAnnotaionView(false);
                }
            }
        }
예제 #10
0
        private void DisplayViewController(NSViewController vc)
        {
            BeginInvokeOnMainThread(() => {
                NSWindow w = box.Window;

                bool ended = w.MakeFirstResponder(w);
                if (!ended)
                {
                    AppKitFramework.NSBeep();
                    return;
                }
                // get the new View
                NSView newView = vc.View;

                // Get the old View
                NSView oldView = (NSView)box.ContentView;

                if (oldView == newView)
                {
                    return;
                }

                // Compute the new window frame
                CGSize currentSize = oldView.Frame.Size;
                CGSize newSize     = newView.Frame.Size;

                nfloat deltaWidth    = newSize.Width - currentSize.Width;
                nfloat deltaHeight   = newSize.Height - currentSize.Height;
                CGRect windowframe   = w.Frame;
                windowframe.Size     = new CGSize(windowframe.Size.Width, windowframe.Size.Height + deltaHeight);
                windowframe.Location = new CGPoint(windowframe.Location.X, windowframe.Location.Y - deltaHeight);
                windowframe.Size     = new CGSize(windowframe.Size.Width + deltaWidth, windowframe.Size.Height);


                NSDictionary windowResize   = NSDictionary.FromObjectsAndKeys(new NSObject[] { w, NSValue.FromCGRect(windowframe) }, new NSObject[] { NSViewAnimation.TargetKey, NSViewAnimation.EndFrameKey });
                NSDictionary oldViewFadeOut = NSDictionary.FromObjectsAndKeys(new NSObject[] { oldView, NSViewAnimation.FadeOutEffect }, new NSObject[] { NSViewAnimation.TargetKey, NSViewAnimation.EffectKey });
                NSDictionary newViewFadeOut = NSDictionary.FromObjectsAndKeys(new NSObject[] { newView, NSViewAnimation.FadeOutEffect }, new NSObject[] { NSViewAnimation.TargetKey, NSViewAnimation.EffectKey });
                NSDictionary fadeIn         = NSDictionary.FromObjectsAndKeys(new NSObject[] { newView, NSViewAnimation.FadeInEffect }, new NSObject[] { NSViewAnimation.TargetKey, NSViewAnimation.EffectKey });

                NSViewAnimation animation       = new NSViewAnimation(new NSDictionary[] { oldViewFadeOut });
                animation.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation.AnimationCurve        = NSAnimationCurve.Linear;
                animation.Duration = 0.1;
                animation.StartAnimation();

                NSViewAnimation animation2       = new NSViewAnimation(new NSDictionary[] { newViewFadeOut });
                animation2.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation2.Duration = 0.0;
                animation2.StartAnimation();

                box.ContentView = newView;

                NSViewAnimation animation3       = new NSViewAnimation(new NSDictionary[] { windowResize });
                animation3.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation3.AnimationCurve        = NSAnimationCurve.EaseInOut;
                animation3.Duration = 0.2;
                animation3.StartAnimation();


                NSViewAnimation animation4       = new NSViewAnimation(new NSDictionary[] { fadeIn });
                animation4.AnimationBlockingMode = NSAnimationBlockingMode.Blocking;
                animation4.AnimationCurve        = NSAnimationCurve.Linear;
                animation4.Duration = 0.1;
                animation4.StartAnimation();
            });
        }