Ejemplo n.º 1
0
        private static void InternalShowDialog(Action <Action> AnnounceCloseAction)
        {
            //var c = new JSCSolutionsNETWhiteCarouselCanvas();
            var c = new JSCSolutionsNETCarouselCanvas();

            if (AnnounceCloseAction != null)
            {
                AnnounceCloseAction(c.Close);
            }

            //c.Container.Effect = new DropShadowEffect();
            //c.Container.BitmapEffect = new DropShadowBitmapEffect();

            new System.Windows.Controls.TextBox
            {
                IsReadOnly      = true,
                Background      = Brushes.Transparent,
                BorderThickness = new System.Windows.Thickness(0),
                Foreground      = Brushes.Red,
                //BitmapEffect = new System.Windows.Media.Effects.OuterGlowBitmapEffect(),
                //Effect = new DropShadowEffect(),
                Text          = "evaluation version",
                FontFamily    = new FontFamily("Microsoft Sans Serif"),
                TextAlignment = System.Windows.TextAlignment.Right
            }.AttachTo(c).MoveTo(0, ImageCarouselCanvas.DefaultHeight - 96).SizeTo(ImageCarouselCanvas.DefaultWidth, 96);

            var w = c.ToWindow();

            w.ToTransparentWindow();

            c.AtClose += w.Close;

            // http://blog.joachim.at/?p=39
            // http://blogs.msdn.com/changov/archive/2009/01/19/webbrowser-control-on-transparent-wpf-window.aspx
            // http://blogs.interknowlogy.com/johnbowen/archive/2007/06/20/20458.aspx
            w.AllowsTransparency    = true;
            w.WindowStyle           = System.Windows.WindowStyle.None;
            w.Background            = Brushes.Transparent;
            w.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            w.Topmost       = true;
            w.ShowInTaskbar = false;
            w.Focusable     = false;

            //w.Loaded +=
            //    delegate
            //    {
            //        4000.AtDelay(
            //            delegate
            //            {
            //                w.RenderVisualTo(@"z:\jsc_logo.png", 900);
            //            }
            //        );
            //    };
            w.ShowDialog();
        }
        private void XInitialize()
        {
            //this.Background = Brushes.Black;
            this.Background = Brushes.White;

            var b = new JSCSolutionsNETCarouselCanvas();

            b.CloseOnClick = false;
            b.Container.AttachTo(this);

            var bg_black = new Canvas
            {
                Background = Brushes.Black
            }.AttachTo(this);

            var bg_black_opacity = bg_black.ToAnimatedOpacity();

            bg_black_opacity.Opacity = 0;

            var w = new JSCSolutionsNETWhiteCarouselCanvas();

            w.CloseOnClick = false;
            w.Container.AttachTo(bg_black);

            bool OtherView = false;

            //new { b.step }.With(
            //    x =>
            //    {
            //        var counter = 0;

            //        (1000 / 60).AtIntervalWithTimer(
            //            speedboost =>
            //            {
            //                counter++;

            //                b.step = x.step * (1 + counter * 0.1);

            //                if (counter == 60 * 2)
            //                    speedboost.Stop();

            //            }
            //        );

            //    }
            //);



            Action ChooseView =
                delegate
            {
                //V:\web\AvalonBrowserLogos\ApplicationCanvas___c__DisplayClass5.as(35): col: 36 Error: Implicit coercion of a value of type Boolean to an unrelated type Number.

                //            if (!(((this.__4__this.Width > this.__4__this.Height) ^ this.OtherView) == 0))
                //                                   ^

                //V:\web\AvalonBrowserLogos\ApplicationCanvas___c__DisplayClass5.as(35): col: 74 Error: Implicit coercion of a value of type Boolean to an unrelated type Number.

                //            if (!(((this.__4__this.Width > this.__4__this.Height) ^ this.OtherView) == 0))
                //                                                                         ^


                // X:\jsc.svn\examples\actionscript\Test\TestBooleanXor\TestBooleanXor\Class1.cs
                // actionscript thinks this operator results in int?
                //var flag = (Width > Height) ^ OtherView;
                var flag = (Width > Height);

                if (OtherView)
                {
                    flag = !flag;
                }

                if (flag)
                {
                    bg_black_opacity.Opacity = 0;
                }
                else
                {
                    bg_black_opacity.Opacity = 1;
                }
            };

            w.AtLogoClick +=
                delegate
            {
                OtherView = !OtherView;

                ChooseView();
            };

            b.AtLogoClick +=
                delegate
            {
                OtherView = !OtherView;

                ChooseView();
            };

            this.SizeChanged += (s, e) =>
            {
                ChooseView();

                w.Container.MoveTo(
                    (this.Width - 400) / 2, (this.Height - 400) / 2
                    );

                b.Container.MoveTo(
                    (this.Width - 400) / 2, (this.Height - 400) / 2
                    );

                bg_black.SizeTo(this.Width, this.Height);
            };
        }
Ejemplo n.º 3
0
        public JSCBrandedWindow()
        {
            this.Icon = new JSCSolutionsNETImage().Source;

            // dwmapi.dll will be missing on xp
            this.WithGlass();


            this.Title = "What do you want to create today?";

            var Overlay = new Window
            {
                AllowsTransparency = true,
                Background         = Brushes.Transparent,
                ShowInTaskbar      = false,
                WindowStyle        = System.Windows.WindowStyle.None,
                //Topmost = true,
                Width  = 400,
                Height = 400,
            };

            BrandedOverlay = Overlay;

            Overlay.SourceInitialized +=
                delegate
            {
                ScriptCoreLib.CSharp.Avalon.Extensions.DesktopWindowManager.MakeInteractive(
                    Overlay, false);
            };

            var Zoom = 0.4;

            Action MoveOverlay =
                delegate
            {
                Overlay.MoveTo(
                    this.Left - 200 * Zoom + 20,
                    this.Top - 200 * Zoom + 20
                    );
            };

            this.LocationChanged +=
                delegate
            {
                MoveOverlay();
            };



            var TitleCanvas = new Canvas().AttachTo(Overlay);

            cc = new JSCSolutionsNETCarouselCanvas();

            cc.StepSpeedToToggleSattelites = 0.20;
            cc.DisableTimerShutdown        = true;

            //cc.CloseOnClick = false;
            //cc.AtLogoClick +=
            //    delegate
            //    {
            //        Process.Start("http://www.jsc-solutions.net");
            //    };

            // http://stackoverflow.com/questions/741956/wpf-pan-zoom-image
            cc.Container.RenderTransform = new ScaleTransform(Zoom, Zoom);

            cc.AttachContainerTo(TitleCanvas);



            this.Deactivated +=
                delegate
            {
                if (!cc.SattelitesHidden)
                {
                    cc.HideSattelites();
                }
            };



            this.Activated +=
                delegate
            {
                if (EnableSattelites && cc.DisableTimerShutdown)
                {
                    if (cc.SattelitesHidden)
                    {
                        cc.ShowSattelitesAgain();
                    }
                }
            };


            this.cc.AtSattelitesShownAgain +=
                delegate
            {
                if (HideSattelitesAtDelay > 0)
                {
                    HideSattelitesAtDelay.AtDelay(cc.HideSattelites);
                }
            };

            this.StateChanged +=
                delegate
            {
                if (DisableStalliteToggleAtStateChange)
                {
                    return;
                }

                if (this.WindowState != System.Windows.WindowState.Normal)
                {
                    if (!cc.SattelitesHidden)
                    {
                        cc.HideSattelites();
                    }
                }
                else
                {
                    if (EnableSattelites && cc.DisableTimerShutdown)
                    {
                        if (cc.SattelitesHidden)
                        {
                            cc.ShowSattelitesAgain();
                        }
                    }
                }
            };

            this.SourceInitialized +=
                delegate
            {
                MoveOverlay();

                // http://blogs.msdn.com/b/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
                ScriptCoreLib.CSharp.Avalon.Extensions.DesktopWindowManager.SetWindowThemeAttribute(this, false, false);



                //Internal.SetParent(
                //    new WindowInteropHelper(Overlay).Handle,
                //    new WindowInteropHelper(this).Handle
                //);

                Overlay.Owner = this;
            };

            Overlay.Show();
        }
Ejemplo n.º 4
0
        public void __Application(IApplicationLoader app)
        {
            //app.LoadingAnimation.FadeOut();

            var DefaultTitle = "jsc solutions";


            Native.Document.title = DefaultTitle;

            StringActionAction GetTitleFromServer = new UltraWebService().GetTitleFromServer;



            GetTitleFromServer(
                n => Native.Document.title = n
            );

            var MyPagesBackground = new IHTMLDiv
            {

            };

            MyPagesBackground.style.overflow = IStyle.OverflowEnum.hidden;
            MyPagesBackground.style.position = IStyle.PositionEnum.absolute;
            MyPagesBackground.style.width = "100%";
            MyPagesBackground.style.height = "100%";
            MyPagesBackground.AttachToDocument();

            var MyPages = new IHTMLDiv
            {

            };

            MyPages.style.overflow = IStyle.OverflowEnum.auto;
            MyPages.style.position = IStyle.PositionEnum.absolute;
            MyPages.style.width = "100%";
            MyPages.style.height = "100%";
            MyPages.AttachToDocument();

            var MyPagesInternal = new IHTMLDiv();

            MyPagesInternal.style.margin = "4em";
            MyPagesInternal.AttachTo(MyPages);

            // http://www.google.com/support/forum/p/Google+Analytics/thread?tid=486a963e463df665&hl=en
            var gapathname = Native.Document.location.pathname;
            var gasearch = Native.Document.location.search;
            var gahash = Native.Window.escape(Native.Document.location.hash);
            var gapageview = gapathname + gasearch + gahash;

            var hash = Native.Document.location.hash;

            Action<string> Analytics = delegate { };

        #region logo
            {
                var IsStudio = Native.Document.location.hash.StartsWith("#/studio");

                if (Native.Document.location.host.StartsWith("studio."))
                {
                    IsStudio = true;
                }

                if (IsStudio)
                {
                    new StudioView(AddSaveButton).Content.AttachToDocument();
                }
                else if (Native.Document.location.hash.StartsWith("#/docs"))
                {
                    var view = new DocumentationCompilationViewer();

                    view.TouchTypeSelected +=
                        type =>
                        {
                            Native.Document.location.hash = "#/docs/" + type.FullName;

                            Analytics("#/docs/" + type.FullName);
                        };

                }
                else if (Native.Document.location.hash.StartsWith("#/warehouse"))
                {
                    new UltraWebService().ThreeDWarehouse(
                        y =>
                        {
                            Func<string, IHTMLAnchor> Build =
                                mid =>
                                {
                                    var a = new IHTMLAnchor { href = "http://sketchup.google.com/3dwarehouse/details?ct=hppm&mid=" + mid }.AttachTo(MyPagesInternal);
                                    var img = new IHTMLImage { src = "http://sketchup.google.com/3dwarehouse/download?rtyp=st&ctyp=other&mid=" + mid }.AttachTo(a);

                                    return a;
                                };

                            var imgs = Enumerable.ToArray(
                                from k in y.Elements()
                                select Build(k.Value)

                            );
                        }
                    );

                }

                else if (Native.Document.location.hash == "#/source")
                {

                    var sln = new TreeNode(() => new VistaTreeNodePage());

                    sln.Text = "Solution";
                    sln.IsExpanded = true;

                    Action<TreeNode> AddReferences =
                        p =>
                        {
                            var r = p.Add("References", new References());

                            r.Add("System", new Assembly());
                            r.Add("System.Core", new Assembly());
                            r.Add("ScriptCoreLib", new Assembly());
                            r.Add("ScriptCoreLib.Ultra", new Assembly());
                            r.Add("ScriptCoreLib.Ultra.Library", new Assembly());
                            r.Add("ScriptCoreLib.Ultra.Controls", new Assembly());
                            r.Add("ScriptCoreLibJava", new Assembly());
                            r.Add("jsc.meta", new Assembly());
                        };

                    Action<TreeNode> AddUltraSource =
                        p =>
                        {
                            var my = p.Add("My.UltraSource");
                            my.Add("Default.htm", new HTMLDocument());
                            my.Add("jsc.png", new ImageFile());

                        };

                    {
                        var p = sln.Add("Visual C# Project", new VisualCSharpProject());


                        AddReferences(p);
                        AddUltraSource(p);



                        p.Add("Application.cs", new VisualCSharpCode());
                        p.Add("WebService.cs", new VisualCSharpCode());
                        p.Add("Program.cs", new VisualCSharpCode());
                    }

                    {
                        var p = sln.Add("Visual Basic Project", new VisualBasicProject());

                        AddReferences(p);
                        AddUltraSource(p);

                        p.Add("Application.vb", new VisualBasicCode());
                        p.Add("WebService.vb", new VisualBasicCode());
                        p.Add("Program.vb", new VisualBasicCode());
                    }


                    {
                        var p = sln.Add("Visual F# Project", new VisualFSharpProject());

                        AddReferences(p);
                        AddUltraSource(p);


                        p.Add("Application.fs", new VisualFSharpCode());
                        p.Add("WebService.fs", new VisualFSharpCode());
                        p.Add("Program.fs", new VisualFSharpCode());
                    }

                    sln.Container.style.Float = IStyle.FloatEnum.right;
                    sln.Container.AttachTo(MyPagesInternal);

                    new SourceEditorHeader().Container.AttachTo(MyPagesInternal);

                    //new IHTMLElement(IHTMLElement.HTMLElementEnum.h1, "Create your own Ultra Application project template").AttachTo(MyPagesInternal);

                    var n = new TextEditor(MyPagesInternal);

                    n.Width = 600;
                    n.Height = 400;

                    //n.InnerHTML = "<p>Create your own <b>Ultra Application</b> Project Template</p>";


                    new DefaultPage1().Container.AttachTo(n.Document.body);

                    var m1 = new SimpleCodeView();

                    m1.Container.AttachTo(MyPagesInternal);
                    //m1.SelectType.onchange +=
                    //    delegate
                    //    {
                    //        m1.TypeName.innerText = m1.SelectType.value;
                    //    };

                    //m1.RunJavaScript.onclick +=
                    //    delegate
                    //    {
                    //        m1.RunJavaScript.style.color = JSColor.Blue;

                    //        try
                    //        {
                    //            Native.Window.eval(m1.Code1.value);

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //        catch
                    //        {
                    //            m1.RunJavaScript.style.color = JSColor.Red;

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //    };
                    new Compilation().GetArchives().SelectMany(k => k.GetAssemblies()).First(k => k.Name == "ScriptCoreLib").WhenReady(
                        ScriptCoreLib =>
                        {
                            // we do not have reflection in place for native wrappers :/

                            m1.SelectEvent.Clear();

                            var Element = ScriptCoreLib.GetTypes().Single(k => k.FullName == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");
                            //var Element = ScriptCoreLib.GetTypes().Single(k => k.HTMLElement == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");

                            Action<CompilationEvent> Add =
                                SourceEvent =>
                                {
                                    m1.SelectEvent.Add(
                                        new IHTMLOption { innerText = SourceEvent.Name }
                                    );
                                };

                            Element.GetEvents().ForEach(Add);

                        }
                    );


                    m1.SelectEvent.onchange +=
                        delegate
                        {
                            m1.EventName.innerText = m1.SelectEvent.value;
                        };




                }
                else if (Native.Document.location.hash == "#/UltraApplicationWithAssets")
                {
                    new UltraApplicationWithAssets().Container.AttachToDocument();
                }
                else
                    if (Native.Document.location.hash == "#/audio")
                    {
                        Action AtTimer = delegate { };

                        (1000 / 15).AtInterval(
                            tt =>
                            {
                                AtTimer();
                            }
                        );

                        new SoundCloudBackground().Container.AttachTo(MyPagesBackground);
                        new SoundCloudHeader().Container.AttachTo(MyPagesInternal);

                        var page = 1;

                        var Tracks = new IHTMLDiv().AttachTo(MyPagesInternal);
                        Tracks.style.margin = "1em";

                        var More = new SoundCloudMore();

                        var AudioLinks = default(AudioLink);

                        var LoadCurrentPage = default(Action);

                        LoadCurrentPage = delegate
                        {
                            var loading = new SoundCloudLoading();

                            loading.Container.AttachTo(Tracks);


                            new UltraWebService().SoundCloudTracksDownload(
                                System.Convert.ToString(page),
                                ee =>
                                {
                                    if (loading != null)
                                    {
                                        loading.Container.Orphanize();
                                        loading = null;
                                    }

                                    var t = new SoundCloudTrack();

                                    t.Content.ApplyToggleConcept(t.HideContent, t.ShowContent).Hide();

                                    t.Title.innerHTML = ee.trackName;
                                    t.Waveform.src = ee.waveformUrl;

                                    t.Audio.src = ee.streamUrl;
                                    t.Audio.autobuffer = true;


                                    AudioLinks = new AudioLink
                                    {
                                        Audio = t.Audio,
                                        Prev = AudioLinks
                                    };

                                    var _AudioLinks = AudioLinks;

                                    if (AudioLinks.Prev != null)
                                        AudioLinks.Prev.Next = AudioLinks;
                                    else
                                        // we are the first  :)
                                        t.Audio.play();

                                    t.MoreButton.onclick +=
                                        delegate
                                        {
                                            t.Audio.pause();

                                            if (_AudioLinks.Next != null)
                                            {
                                                _AudioLinks.Next.Audio.currentTime = 0;
                                                _AudioLinks.Next.Audio.play();

                                                if (_AudioLinks.Next.Next == null)
                                                {
                                                    page++;
                                                    LoadCurrentPage();
                                                }
                                            }
                                        };

                                    t.Audio.onended +=
                                        delegate
                                        {
                                            if (_AudioLinks.Next != null)
                                            {
                                                _AudioLinks.Next.Audio.currentTime = 0;
                                                _AudioLinks.Next.Audio.play();

                                                if (_AudioLinks.Next.Next == null)
                                                {
                                                    page++;
                                                    LoadCurrentPage();
                                                }
                                            }
                                        };

                                    t.Identity.innerText = ee.uid;

                                    t.Play.onclick += eee => { eee.PreventDefault(); t.Audio.play(); };
                                    t.Pause.onclick += eee => { eee.PreventDefault(); t.Audio.pause(); };

                                    t.Title.style.cursor = IStyle.CursorEnum.pointer;
                                    t.Title.onclick += eee =>
                                        {
                                            eee.PreventDefault();

                                            var playing = true;

                                            if (t.Audio.paused)
                                                playing = false;

                                            if (t.Audio.ended)
                                                playing = false;

                                            if (!playing)
                                                t.Audio.play();
                                            else
                                                t.Audio.pause();
                                        };

                                    DoubleAction SetProgress1 = p =>
                                    {

                                        t.Gradient3.style.width = System.Convert.ToInt32(800 * p) + "px";
                                        t.Gradient4.style.width = System.Convert.ToInt32(800 * p) + "px";
                                    };

                                    t.Gradient5.style.Opacity = 0.4;
                                    t.Gradient6.style.Opacity = 0.4;

                                    DoubleAction SetProgress2 = p =>
                                    {

                                        t.Gradient5.style.width = System.Convert.ToInt32(800 * p) + "px";
                                        t.Gradient6.style.width = System.Convert.ToInt32(800 * p) + "px";
                                    };

                                    AtTimer +=
                                        delegate
                                        {
                                            if (t.Audio.duration == 0)
                                            {
                                                t.Play.Hide();
                                                t.Pause.Hide();
                                                return;
                                            }
                                            else
                                            {

                                                var playing = true;

                                                if (t.Audio.paused)
                                                    playing = false;

                                                if (t.Audio.ended)
                                                    playing = false;

                                                if (!playing)
                                                    t.Title.style.color = Color.None;
                                                else
                                                    t.Title.style.color = Color.Blue;

                                                t.Play.Show(!playing);
                                                t.Pause.Show(playing);
                                            }

                                            var p = t.Audio.currentTime / t.Audio.duration;
                                            SetProgress1(p);
                                        };

                                    t.Waveform.onmouseout +=
                                        delegate
                                        {
                                            SetProgress2(0);
                                        };

                                    t.Waveform.onmousemove +=
                                        eee =>
                                        {
                                            SetProgress2(eee.OffsetX / 800.0);
                                        };

                                    t.Waveform.onclick +=
                                        eee =>
                                        {
                                            t.Audio.currentTime = t.Audio.duration * (eee.OffsetX / 800.0);
                                            t.Audio.play();
                                        };

                                    t.Waveform.style.cursor = IStyle.CursorEnum.pointer;

                                    SetProgress1(0);
                                    SetProgress2(0);

                                    t.Container.AttachTo(Tracks);
                                }
                            );


                            10000.AtDelay(
                                delegate
                                {
                                    More.MoreButton.FadeIn(0, 1000, null);
                                }
                            );
                        };


                        More.MoreButton.Hide();
                        More.Container.AttachTo(MyPagesInternal);

                        More.MoreButton.onclick += eee =>
                            {
                                eee.PreventDefault();
                                More.MoreButton.FadeOut(1, 300,
                                    delegate
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                );
                            };

                        LoadCurrentPage();

                    }
                    else
                    {
                        //new PromotionWebApplication1.HTML.Audio.FromAssets.Track1 { controls = true }.AttachToDocument();
                        //new PromotionWebApplication1.HTML.Audio.FromWeb.Track1 { controls = true, autobuffer = true }.AttachToDocument();

                        var IsAvalonJavaScript = hash == "#/avalon.js";
                        var IsAvalonActionScript = hash == "#/avalon.as";
                        var IsAvalon = IsAvalonActionScript || IsAvalonJavaScript;

                        //if (IsAvalon)
                        //{

                        //{
                        //    var ccc = new IHTMLDiv();

                        //    ccc.style.position = IStyle.PositionEnum.absolute;
                        //    ccc.style.left = "15%";
                        //    ccc.style.right = "15%";
                        //    ccc.style.top = "15%";


                        //    var Now = DateTime.Now;

                        //    var CountDown = new CountDownGadgetConcept(CountDownGadget.Create)
                        //    {
                        //        ShowOnlyDays = true,
                        //        Event = new DateTime(2010, 5, 24, 23, 59, 50),

                        //    };

                        //    CountDown.Element.GadgetContainer.style.color = "#808080";
                        //    CountDown.Element.GadgetContainer.style.textShadow = "#E0E0E0 1px 1px 1px";


                        //    CountDown.Element.GadgetContainer.AttachTo(ccc);
                        //    CountDown.Element.GadgetContainer.FadeIn(3000, 2000, null);

                        //    ccc.AttachToDocument();
                        //}

                        {
                            var ccc = new IHTMLDiv();

                            ccc.style.position = IStyle.PositionEnum.absolute;
                            ccc.style.left = "50%";
                            ccc.style.top = "50%";
                            ccc.style.marginLeft = (-JSCSolutionsNETCarouselCanvas.DefaultWidth / 2) + "px";
                            ccc.style.marginTop = (-JSCSolutionsNETCarouselCanvas.DefaultHeight / 2) + "px";

                            ccc.style.SetSize(JSCSolutionsNETCarouselCanvas.DefaultWidth, JSCSolutionsNETCarouselCanvas.DefaultHeight);

                            ccc.AttachToDocument();

                            if (IsAvalonActionScript)
                            {
                                var alof = new UltraSprite();
                                alof.ToTransparentSprite();
                                alof.AttachSpriteTo(ccc);
                            }
                            else
                            {
                                var alo = new JSCSolutionsNETCarouselCanvas();
                                alo.Container.AttachToContainer(ccc);

                                alo.AtLogoClick +=
                                    delegate
                                    {
                                        //Native.Window.open("http://sourceforge.net/projects/jsc/", "_blank");
                                        Native.Window.open("/download", "_blank");
                                    };

                            }
                        }
                        //}
                        //else
                        //{
                        //    var cc = new HTML.Pages.FromAssets.Controls.Named.CenteredLogo_Kamma();

                        //    cc.Container.AttachToDocument();

                        //    // see: http://en.wikipedia.org/wiki/Perl_control_structures
                        //    // "Unless" == "if not"  ;)

                        //    IsMicrosoftInternetExplorer.YetIfNotThen(cc.TheLogoImage.BeginPulseAnimation).ButIfSoThen(cc.TheLogoImage.HideNowButShowAtDelay);
                        //}

                        var aa = new About();
                        aa.Service.innerText = gapageview;
                        aa.Container.AttachToDocument();

                    }
            }
        #endregion


            Analytics =
                __hash =>
                {
                    var __gahash = Native.Window.escape(__hash);
                    var __gapageview = gapathname + gasearch + __gahash;


                    "UA-13087448-1".ToGoogleAnalyticsTracker(
                        pageTracker =>
                        {
                            pageTracker._setDomainName(".jsc-solutions.net");
                            pageTracker._trackPageview(__gapageview);


                        }
                    );
                };

            Analytics(Native.Document.location.hash);


        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var c = new JSCSolutionsNETCarouselCanvas
            {
                CloseOnClick = false
            };

            c.HideSattelites();


            //c.Container.Effect = new DropShadowEffect();
            //c.Container.BitmapEffect = new DropShadowBitmapEffect();

            //.MoveTo(0, ImageCarouselCanvas.DefaultHeight - 96).SizeTo(ImageCarouselCanvas.DefaultWidth, 96);

            var cc = new Canvas();


            // http://cloudstore.blogspot.com/2008/05/creating-custom-window-style.html
            var wcam = new Window();

            wcam.Background  = Brushes.Transparent;
            wcam.WindowStyle = WindowStyle.None;
            wcam.ResizeMode  = ResizeMode.NoResize;
            wcam.SizeTo(200, 200);
            wcam.AllowsTransparency = true;
            //wcam.Opacity = 0.5;
            wcam.ShowInTaskbar = false;
            wcam.Cursor        = Cursors.Hand;
            wcam.Focusable     = false;
            wcam.Topmost       = true;

            var w = cc.ToWindow();


            w.SizeToContent = SizeToContent.Manual;
            //w.SizeTo(400, 400);
            //w.ToTransparentWindow();


            // http://blog.joachim.at/?p=39
            // http://blogs.msdn.com/changov/archive/2009/01/19/webbrowser-control-on-transparent-wpf-window.aspx
            // http://blogs.interknowlogy.com/johnbowen/archive/2007/06/20/20458.aspx
            w.AllowsTransparency = true;
            w.WindowStyle        = System.Windows.WindowStyle.None;
            w.Focusable          = false;

            //w.Background = new SolidColorBrush(Color.FromArgb(0x20, 0, 0, 0));
            w.Background            = Brushes.Transparent;
            w.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            w.Topmost = true;
            //w.ShowInTaskbar = false;

            var winfoc = new Canvas();



            var winfo = winfoc.ToWindow();

            winfo.AllowsTransparency = true;
            winfo.ShowInTaskbar      = false;
            winfo.WindowStyle        = WindowStyle.None;
            //winfo.Background = Brushes.Transparent;
            winfo.Background = Brushes.Red;
            winfo.Opacity    = 0.3;

            winfo.ResizeMode = ResizeMode.NoResize;

            winfo.SizeToContent = SizeToContent.Manual;
            winfo.Topmost       = true;
            // http://www.squidoo.com/youtubehd



            var NextInputModeEnabled        = false;
            var NextInputModeKeyDownEnabled = false;

            Action <Key> NextInputModeKeyDown = delegate { };

            var CommandKeysEnabled = false;

            #region TopicText
            var TopicText = new System.Windows.Controls.TextBox
            {
                //IsReadOnly = true,
                Background      = Brushes.Transparent,
                BorderThickness = new System.Windows.Thickness(0),
                Foreground      = Brushes.White,
                Effect          = new DropShadowEffect(),
                Text            = "JSC C# Foo Bar",
                //TextDecorations = TextDecorations.Underline,
                FontFamily    = new FontFamily("Verdana"),
                FontSize      = 24,
                TextAlignment = System.Windows.TextAlignment.Right
            };
            #endregion


            #region KeyDown
            InterceptKeys.KeyDown +=
                key =>
            {
                if (key == Key.LeftShift)
                {
                    //w.Background = new SolidColorBrush(Color.FromArgb(2, 0, 0, 0));
                    //w.MakeInteractive(true);
                    NextInputModeEnabled = true;
                }
                else
                {
                    if (NextInputModeEnabled || NextInputModeKeyDownEnabled)
                    {
                        NextInputModeKeyDownEnabled = false;
                        NextInputModeKeyDown(key);
                    }

                    NextInputModeEnabled = false;
                }
            };
            #endregion

            #region KeyUp
            InterceptKeys.KeyUp +=
                key =>
            {
                if (key == Key.CapsLock)
                {
                    CommandKeysEnabled   = !CommandKeysEnabled;
                    TopicText.IsReadOnly = CommandKeysEnabled;
                    TopicText.Select(0, 0);
                }

                if (key == Key.LeftShift)
                {
                    NextInputModeKeyDownEnabled = false;
                }
                else
                {
                }

                NextInputModeEnabled = false;
            };
            #endregion


            var s = 7;

            var ThumbnailSize           = 0.4;
            var CaptionBackgroundHeight = 24;

            #region UpdateChildren
            Action UpdateChildren =
                delegate
            {
                if (w.ActualWidth == 0)
                {
                    return;
                }

                var ss  = s;
                var ss2 = 0;


                Console.WriteLine(
                    new { w.Left, w.Top });

                winfo.MoveTo(w.Left, w.Top).SizeTo(w.ActualWidth, w.ActualHeight);

                if (ThumbnailSize == 1)
                {
                    wcam.Background = Brushes.Black;
                    ss = 0;

                    var qw = w.ActualWidth - ss * 2;
                    var qh = w.ActualHeight - ss * 2;

                    // no status bars or menues please :)

                    wcam.MoveTo(
                        w.Left + ss + ss2,
                        w.Top + (w.ActualHeight - qh * ThumbnailSize - ss) - ss2
                        ).SizeTo(
                        qw * ThumbnailSize,
                        qh * ThumbnailSize
                        );
                }
                else
                {
                    wcam.Background = Brushes.Transparent;

                    //if (w.WindowState == WindowState.Maximized)
                    //{
                    //    ss2 = s;
                    //}

                    var qw = w.ActualWidth - ss * 2;
                    var qh = w.ActualHeight - ss * 2;



                    wcam.MoveTo(w.Left + ss + ss2, w.Top + (w.ActualHeight - qh * ThumbnailSize - ss) - ss2).SizeTo(qw * ThumbnailSize, qh * ThumbnailSize);
                }
            };
            #endregion


            w.LocationChanged +=
                delegate
            {
                UpdateChildren();
            };



            var Borders = Enumerable.Range(1, s * 2).Reverse().Select(
                Width =>
                new
            {
                Width = Width * 2,
                Left  = new Rectangle {
                    Fill = Brushes.Black, Opacity = 0.06
                }.MoveTo(0, 0).AttachTo(winfoc),
                Right = new Rectangle {
                    Fill = Brushes.Black, Opacity = 0.06
                }.MoveTo(0, 0).AttachTo(winfoc),
                Bottom = new Rectangle {
                    Fill = Brushes.Black, Opacity = 0.03
                }.MoveTo(0, 0).AttachTo(winfoc),
                Top = new Rectangle {
                    Fill = Brushes.Black, Opacity = 0.11
                }.MoveTo(0, 0).AttachTo(winfoc)
            }
                ).ToArray();

            var CaptionBackgroundOverlay = new Rectangle
            {
                Fill    = Brushes.Black,
                Opacity = 0.02,
            }.AttachTo(cc);

            var CaptionSysMenuOverlay = new Rectangle
            {
                Fill    = Brushes.Black,
                Opacity = 0.02,
            }.AttachTo(cc).SizeTo(CaptionBackgroundHeight * 4, CaptionBackgroundHeight);

            var ExtraBorderTop = new Rectangle
            {
                Fill    = Brushes.Black,
                Opacity = 0.0,
            }.AttachTo(winfoc);

            var ExtraBorderBottom = new Rectangle
            {
                Fill    = Brushes.Black,
                Opacity = 0.0,
            }.AttachTo(winfoc);

            var CaptionClose = new TextBox
            {
                Foreground      = Brushes.Red,
                FontFamily      = new FontFamily("Webdings"),
                Text            = "r",
                Background      = Brushes.Transparent,
                BorderThickness = new Thickness(0),
                TextAlignment   = System.Windows.TextAlignment.Center,
                Opacity         = 0.5
            }.AttachTo(winfoc);


            var CaptionText = new System.Windows.Controls.TextBox
            {
                IsReadOnly      = true,
                Background      = Brushes.Transparent,
                BorderThickness = new System.Windows.Thickness(0),
                Foreground      = Brushes.White,
                Effect          = new System.Windows.Media.Effects.DropShadowEffect(),
                Text            = "jsc-solutions.net",
                //TextDecorations = TextDecorations.Underline,
                FontFamily    = new FontFamily("Verdana"),
                FontSize      = 16,
                TextAlignment = System.Windows.TextAlignment.Right
            }
            .AttachTo(winfoc);

            TopicText.AttachTo(winfoc);

            #region SetCaption
            Action <string> SetCaption =
                text =>
            {
                if (string.IsNullOrEmpty(text))
                {
                    CaptionText.Text = "jsc-solutions.net";
                }
                else
                {
                    CaptionText.Text = text + " | jsc-solutions.net";
                }
            };
            #endregion



            c.AttachContainerTo(winfoc);

            var ExtraBorderSize = 0.10;


            var Intro = new PromotionBrandIntro.ApplicationCanvas().AttachTo(winfoc);
            Intro.Opacity = 0;

            #region SizeChanged
            Action SizeChanged =
                delegate
            {
                Intro.SizeTo(w.ActualWidth, w.ActualHeight);
                //ink.SizeTo(w.ActualWidth, w.ActualHeight - CaptionBackgroundHeight);

                var CaptionWidth = 200;

                CaptionBackgroundOverlay.MoveTo(w.ActualWidth - CaptionWidth, 0).SizeTo(CaptionWidth, CaptionBackgroundHeight);


                ExtraBorderTop.MoveTo(0, 0).SizeTo(w.ActualWidth, w.ActualHeight * ExtraBorderSize);
                ExtraBorderBottom.MoveTo(0, w.ActualHeight * (1 - ExtraBorderSize)).SizeTo(w.ActualWidth, w.ActualHeight * ExtraBorderSize);

                TopicText.MoveTo(
                    0,
                    w.ActualHeight - 48
                    ).SizeTo(w.ActualWidth - 48, 48);


                if (c != null)
                {
                    c.MoveContainerTo(-200 + 42, -200 + 38);
                }
                Borders.WithEach(k => k.Left.MoveTo(0, 0).SizeTo(k.Width, w.ActualHeight));
                Borders.WithEach(k => k.Right.MoveTo(w.ActualWidth - k.Width, 0).SizeTo(k.Width, w.ActualHeight));
                Borders.WithEach(k => k.Bottom.MoveTo(0, w.ActualHeight - k.Width).SizeTo(w.ActualWidth, k.Width));
                Borders.WithEach(k => k.Top.MoveTo(0, 0).SizeTo(w.ActualWidth, k.Width));
                CaptionText.MoveTo(0, 2).SizeTo(w.ActualWidth - CaptionBackgroundHeight, 32);
                CaptionClose.MoveTo(w.ActualWidth - CaptionBackgroundHeight, s).SizeTo(CaptionBackgroundHeight - s, CaptionBackgroundHeight - s);

                UpdateChildren();
            };
            #endregion

            w.SizeChanged +=
                delegate
            {
                SizeChanged();
            };

            w.StateChanged +=
                delegate
            {
                if (w.WindowState == WindowState.Maximized)
                {
                    w.WindowState = WindowState.Normal;
                }

                SizeChanged();
            };



            #region GetWindows
            Func <IEnumerable <Internal.Window> > GetWindows =
                delegate
            {
                var windows = new List <Internal.Window>();
                Internal.EnumWindows(
                    (IntPtr hwnd, int lParam) =>
                {
                    if (new WindowInteropHelper(wcam).Handle != hwnd &&
                        (Internal.GetWindowLongA(hwnd, Internal.GWL_STYLE) & Internal.TARGETWINDOW) == Internal.TARGETWINDOW
                        )
                    {
                        StringBuilder sb = new StringBuilder(100);
                        Internal.GetWindowText(hwnd, sb, sb.Capacity);

                        windows.Add(
                            new Internal.Window
                        {
                            Handle = hwnd,
                            Title  = sb.ToString()
                        }
                            );
                    }

                    return(true);        //continue enumeration
                }
                    , 0);

                return(windows.OrderBy(k => k.Title));
            };
            #endregion

            var ResetThumbnailSkip = 0;

            Func <Internal.Window> GetCurrentThumbnail = () => GetWindows().AsCyclicEnumerable().Skip(ResetThumbnailSkip).First();

            #region AnimationCompleted
            Intro.AnimationCompleted +=
                delegate
            {
                if (c == null)
                {
                    c = new JSCSolutionsNETCarouselCanvas
                    {
                        CloseOnClick = false
                    }.AttachContainerTo(winfoc);
                    c.HideSattelites();

                    CaptionClose.Show();
                    SizeChanged();
                }
            };
            #endregion


            wcam.SourceInitialized +=
                delegate
            {
                {
                    wcam.MakeInteractive(false);

                    UpdateChildren();
                }



                var thumb = IntPtr.Zero;
                ResetThumbnailSkip = GetWindows().Where(
                    k =>
                    k.Title.Contains("Chrome") ||
                    k.Title.Contains("Studio") ||
                    k.Title.Contains("Minefield")

                    ).TakeWhile(k => k.Handle != Internal.GetForegroundWindow()).Count();


                #region ResetThumbnail
                Action ResetThumbnail =
                    delegate
                {
                    GetCurrentThumbnail().With(
                        shadow =>
                    {
                        //t.Text = shadow.Title;

                        if (thumb != IntPtr.Zero)
                        {
                            Internal.DwmUnregisterThumbnail(thumb);
                        }

                        int i = Internal.DwmRegisterThumbnail(
                            new WindowInteropHelper(wcam).Handle, shadow.Handle, out thumb);

                        #region UpdateThumbnail
                        Action UpdateThumbnail =
                            delegate
                        {
                            if (thumb != IntPtr.Zero)
                            {
                                Internal.PSIZE size;
                                Internal.DwmQueryThumbnailSourceSize(thumb, out size);

                                Internal.DWM_THUMBNAIL_PROPERTIES props = new Internal.DWM_THUMBNAIL_PROPERTIES();

                                props.fVisible              = true;
                                props.dwFlags               = Internal.DWM_TNP_VISIBLE | Internal.DWM_TNP_RECTDESTINATION | Internal.DWM_TNP_OPACITY | Internal.DWM_TNP_SOURCECLIENTAREAONLY;
                                props.opacity               = (byte)((byte)(0x7F) + (byte)((0x80) * (ThumbnailSize)));
                                props.rcDestination         = new Internal.Rect(0, 0, (int)wcam.ActualWidth, (int)wcam.ActualHeight);
                                props.fSourceClientAreaOnly = true;

                                if (size.x < wcam.ActualWidth)
                                {
                                    props.rcDestination.Right = props.rcDestination.Left + size.x;

                                    props.rcDestination.Left  += ((int)wcam.ActualWidth - size.x) / 2;
                                    props.rcDestination.Right += ((int)wcam.ActualWidth - size.x) / 2;
                                }

                                if (size.y < wcam.ActualHeight)
                                {
                                    props.rcDestination.Bottom = props.rcDestination.Top + size.y;

                                    props.rcDestination.Top    += ((int)wcam.ActualHeight - size.y) / 2;
                                    props.rcDestination.Bottom += ((int)wcam.ActualHeight - size.y) / 2;
                                }



                                Internal.DwmUpdateThumbnailProperties(thumb, ref props);
                            }
                        };
                        #endregion


                        (1000 / 15).AtInterval(UpdateThumbnail);

                        wcam.SizeChanged += delegate { UpdateThumbnail(); };
                    }
                        );
                };
                #endregion



                ResetThumbnail();

                NextInputModeKeyDown +=
                    key =>
                {
                    if (key == Key.RightShift)
                    {
                        NextInputModeKeyDownEnabled = true;

                        if (c != null)
                        {
                            CaptionClose.Hide();
                            c.AtClose +=
                                delegate
                            {
                                c.OrphanizeContainer();
                            };
                            c.Close();
                            c = null;
                        }

                        Intro.Background      = Brushes.Transparent;
                        Intro.Overlay.Opacity = 1;
                        Intro.FadeIn(
                            delegate
                        {
                            2000.AtDelay(Intro.PrepareAnimation());
                        }
                            );
                    }

                    if (!CommandKeysEnabled)
                    {
                        if (key == Key.F2)
                        {
                            w.Activate();

                            TopicText.Focusable = true;
                            TopicText.Focus();
                            TopicText.SelectAll();
                        }
                        return;
                    }

                    if (key == Key.Right)
                    {
                        if (w.IsActive)
                        {
                            GetCurrentThumbnail().Activate();
                        }
                        else
                        {
                            NextInputModeKeyDownEnabled = true;
                            ResetThumbnailSkip          = GetWindows().TakeWhile(k => k.Handle != Internal.GetForegroundWindow()).Count();
                            ResetThumbnail();
                        }
                    }

                    if (key == Key.Up)
                    {
                        NextInputModeKeyDownEnabled = true;

                        if (ThumbnailSize < 0.3)
                        {
                            ThumbnailSize = 0.3;
                        }
                        else if (ThumbnailSize < 0.5)
                        {
                            ThumbnailSize = 0.5;
                        }
                        else if (ThumbnailSize < 1)
                        {
                            ThumbnailSize = 1;
                        }
                        else
                        {
                            if (c != null)
                            {
                                CaptionClose.Hide();
                                c.AtClose +=
                                    delegate
                                {
                                    c.OrphanizeContainer();
                                };
                                c.Close();
                                c = null;
                            }
                        }


                        UpdateChildren();
                    }
                    if (key == Key.Down)
                    {
                        NextInputModeKeyDownEnabled = true;
                        if (c == null)
                        {
                            c = new JSCSolutionsNETCarouselCanvas
                            {
                                CloseOnClick = false
                            }.AttachContainerTo(winfoc);
                            CaptionClose.Show();
                        }
                        else if (ThumbnailSize > 0.5)
                        {
                            ThumbnailSize = 0.5;
                        }
                        else if (ThumbnailSize > 0.3)
                        {
                            ThumbnailSize = 0.3;
                        }
                        else if (ThumbnailSize == 0.3)
                        {
                            ThumbnailSize = 0;
                        }

                        SizeChanged();
                    }



                    if (key == Key.Left)
                    {
                        if (w.IsActive)
                        {
                            NextInputModeKeyDownEnabled = true;
                            if (ExtraBorderTop.Opacity == 1)
                            {
                                ExtraBorderTop.Opacity    = 0;
                                ExtraBorderBottom.Opacity = 0;
                            }
                            else
                            {
                                ExtraBorderTop.Opacity    = 1;
                                ExtraBorderBottom.Opacity = 1;
                            }
                        }
                    }
                };
            };

            winfo.SourceInitialized +=
                delegate
            {
                winfo.MakeInteractive(false);
            };

            w.SourceInitialized +=
                delegate
            {
                // http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/61e93dca-e24c-4953-9719-22ce3f705353
                Matrix m  = PresentationSource.FromVisual(w).CompositionTarget.TransformToDevice;
                double dx = m.M11;
                double dy = m.M22;


                w.SizeTo(1280 / dx, 768 / dy);
                w.MoveTo(8, 0);
                SizeChanged();

                wcam.Owner  = w;
                winfo.Owner = w;
                wcam.Show();
                winfo.Show();

                HwndSource hwndSource = (HwndSource)HwndSource.FromVisual(w);
                hwndSource.AddHook(
                    (IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handeled) =>
                {
                    if (msg == 0x0084)         // WM_NCHITTEST
                    {
                        //http://agsmith.wordpress.com/2008/09/16/hit-testing-in-wpf/

                        var p = new
                        {
                            cx = w.ActualWidth - (Internal.LOWORD(lParam) - w.Left),
                            cy = w.ActualHeight - (Internal.HIWORD(lParam) - w.Top),
                            x  = Internal.LOWORD(lParam) - w.Left,
                            y  = Internal.HIWORD(lParam) - w.Top
                        };


                        CaptionText.Text = p.ToString();

                        handeled = true;

                        return((IntPtr)HitTestValues.HTCAPTION);        // HTCAPTION


                        if (false)
                        {
                            if (p.x < s)
                            {
                                if (p.y < s)
                                {
                                    return((IntPtr)HitTestValues.HTTOPLEFT);        // HTCAPTION
                                }
                            }
                            if (p.x < CaptionBackgroundHeight)
                            {
                                if (p.y < CaptionBackgroundHeight)
                                {
                                    return((IntPtr)HitTestValues.HTSYSMENU);        // HTCAPTION
                                }
                            }
                            if (p.cx < CaptionBackgroundHeight)
                            {
                                if (p.y < CaptionBackgroundHeight)
                                {
                                    return((IntPtr)HitTestValues.HTCLOSE);        // HTCAPTION
                                }
                            }
                            if (p.cx < s)
                            {
                                if (p.cy < s)
                                {
                                    return((IntPtr)HitTestValues.HTBOTTOMRIGHT);        // HTCAPTION
                                }
                            }
                            if (p.cx < s)
                            {
                                if (p.y < s)
                                {
                                    return((IntPtr)HitTestValues.HTTOPRIGHT);        // HTCAPTION
                                }
                            }
                            if (p.x < s)
                            {
                                if (p.cy < s)
                                {
                                    return((IntPtr)HitTestValues.HTBOTTOMLEFT);        // HTCAPTION
                                }
                            }
                            if (p.x < s)
                            {
                                return((IntPtr)HitTestValues.HTLEFT);        // HTCAPTION
                            }
                            if (p.y < s)
                            {
                                return((IntPtr)HitTestValues.HTTOP);        // HTCAPTION
                            }
                            if (p.cx < s)
                            {
                                return((IntPtr)HitTestValues.HTRIGHT);        // HTCAPTION
                            }
                            if (p.cy < s)
                            {
                                return((IntPtr)HitTestValues.HTBOTTOM);        // HTCAPTION
                            }
                            if (p.y < CaptionBackgroundHeight)
                            {
                                return((IntPtr)HitTestValues.HTCAPTION);        // HTCAPTION
                            }
                            return((IntPtr)HitTestValues.HTTRANSPARENT);        // HTCAPTION
                        }
                    }
                    return(IntPtr.Zero);
                }

                    );
            };



            InterceptKeys.InternalMain(
                Rehook =>
            {
                w.Deactivated +=
                    delegate
                {
                    TopicText.Focusable = false;
                };
                w.Activated +=
                    delegate
                {
                    //TopicText.Focus();
                    Rehook();
                };

                w.ShowDialog();
            }
                );
        }
        public JSCBrandedWindow()
        {
            this.Icon = new JSCSolutionsNETImage().Source;
            
            // dwmapi.dll will be missing on xp
            this.WithGlass();


            this.Title = "What do you want to create today?";

            var Overlay = new Window
            {
                AllowsTransparency = true,
                Background = Brushes.Transparent,
                ShowInTaskbar = false,
                WindowStyle = System.Windows.WindowStyle.None,
                //Topmost = true,
                Width = 400,
                Height = 400,


            };
            BrandedOverlay = Overlay;

            Overlay.SourceInitialized +=
              delegate
              {
                  ScriptCoreLib.CSharp.Avalon.Extensions.DesktopWindowManager.MakeInteractive(
                  Overlay, false);
              };

            var Zoom = 0.4;

            Action MoveOverlay =
                delegate
                {
                    Overlay.MoveTo(
                        this.Left - 200 * Zoom + 20,
                        this.Top - 200 * Zoom + 20
                     );

                };

            this.LocationChanged +=
                delegate
                {
                    MoveOverlay();
                };




            var TitleCanvas = new Canvas().AttachTo(Overlay);

            cc = new JSCSolutionsNETCarouselCanvas();

            cc.StepSpeedToToggleSattelites = 0.20;
            cc.DisableTimerShutdown = true;

            //cc.CloseOnClick = false;
            //cc.AtLogoClick +=
            //    delegate
            //    {
            //        Process.Start("http://www.jsc-solutions.net");
            //    };

            // http://stackoverflow.com/questions/741956/wpf-pan-zoom-image
            cc.Container.RenderTransform = new ScaleTransform(Zoom, Zoom);

            cc.AttachContainerTo(TitleCanvas);



            this.Deactivated +=
                delegate
                {
                    if (!cc.SattelitesHidden)
                        cc.HideSattelites();
                };



            this.Activated +=
                delegate
                {
                    if (EnableSattelites && cc.DisableTimerShutdown)
                        if (cc.SattelitesHidden)
                            cc.ShowSattelitesAgain();


                };


            this.cc.AtSattelitesShownAgain +=
                delegate
                {
                    if (HideSattelitesAtDelay > 0)
                        HideSattelitesAtDelay.AtDelay(cc.HideSattelites);
                };

            this.StateChanged +=
                delegate
                {
                    if (DisableStalliteToggleAtStateChange)
                        return;

                    if (this.WindowState != System.Windows.WindowState.Normal)
                    {
                        if (!cc.SattelitesHidden)
                            cc.HideSattelites();
                    }
                    else
                    {
                        if (EnableSattelites && cc.DisableTimerShutdown)
                            if (cc.SattelitesHidden)
                                cc.ShowSattelitesAgain();
                    }
                };

            this.SourceInitialized +=
               delegate
               {
                   MoveOverlay();

                   // http://blogs.msdn.com/b/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
                   ScriptCoreLib.CSharp.Avalon.Extensions.DesktopWindowManager.SetWindowThemeAttribute(this, false, false);



                   //Internal.SetParent(
                   //    new WindowInteropHelper(Overlay).Handle,
                   //    new WindowInteropHelper(this).Handle
                   //);

                   Overlay.Owner = this;
               };

            Overlay.Show();
        }
Ejemplo n.º 7
0
        public void __Application(IApplicationLoader app)
        {
            //app.LoadingAnimation.FadeOut();

            var DefaultTitle = "jsc solutions";


            Native.Document.title = DefaultTitle;

            StringActionAction GetTitleFromServer = new UltraWebService().GetTitleFromServer;



            GetTitleFromServer(
                n => Native.Document.title = n
                );

            var MyPagesBackground = new IHTMLDiv
            {
            };

            MyPagesBackground.style.overflow = IStyle.OverflowEnum.hidden;
            MyPagesBackground.style.position = IStyle.PositionEnum.absolute;
            MyPagesBackground.style.width    = "100%";
            MyPagesBackground.style.height   = "100%";
            MyPagesBackground.AttachToDocument();

            var MyPages = new IHTMLDiv
            {
            };

            MyPages.style.overflow = IStyle.OverflowEnum.auto;
            MyPages.style.position = IStyle.PositionEnum.absolute;
            MyPages.style.width    = "100%";
            MyPages.style.height   = "100%";
            MyPages.AttachToDocument();

            var MyPagesInternal = new IHTMLDiv();

            MyPagesInternal.style.margin = "4em";
            MyPagesInternal.AttachTo(MyPages);

            // http://www.google.com/support/forum/p/Google+Analytics/thread?tid=486a963e463df665&hl=en
            var gapathname = Native.Document.location.pathname;
            var gasearch   = Native.Document.location.search;
            var gahash     = Native.Window.escape(Native.Document.location.hash);
            var gapageview = gapathname + gasearch + gahash;

            var hash = Native.Document.location.hash;

            Action <string> Analytics = delegate { };

            #region logo
            {
                var IsStudio = Native.Document.location.hash.StartsWith("#/studio");

                if (Native.Document.location.host.StartsWith("studio."))
                {
                    IsStudio = true;
                }

                if (IsStudio)
                {
                    new StudioView(AddSaveButton).Content.AttachToDocument();
                }
                else if (Native.Document.location.hash.StartsWith("#/docs"))
                {
                    var view = new DocumentationCompilationViewer();

                    view.TouchTypeSelected +=
                        type =>
                    {
                        Native.Document.location.hash = "#/docs/" + type.FullName;

                        Analytics("#/docs/" + type.FullName);
                    };
                }
                else if (Native.Document.location.hash.StartsWith("#/warehouse"))
                {
                    new UltraWebService().ThreeDWarehouse(
                        y =>
                    {
                        Func <string, IHTMLAnchor> Build =
                            mid =>
                        {
                            var a = new IHTMLAnchor {
                                href = "http://sketchup.google.com/3dwarehouse/details?ct=hppm&mid=" + mid
                            }.AttachTo(MyPagesInternal);
                            var img = new IHTMLImage {
                                src = "http://sketchup.google.com/3dwarehouse/download?rtyp=st&ctyp=other&mid=" + mid
                            }.AttachTo(a);

                            return(a);
                        };

                        var imgs = Enumerable.ToArray(
                            from k in y.Elements()
                            select Build(k.Value)

                            );
                    }
                        );
                }

                else if (Native.Document.location.hash == "#/source")
                {
                    var sln = new TreeNode(() => new VistaTreeNodePage());

                    sln.Text       = "Solution";
                    sln.IsExpanded = true;

                    Action <TreeNode> AddReferences =
                        p =>
                    {
                        var r = p.Add("References", new References());

                        r.Add("System", new Assembly());
                        r.Add("System.Core", new Assembly());
                        r.Add("ScriptCoreLib", new Assembly());
                        r.Add("ScriptCoreLib.Ultra", new Assembly());
                        r.Add("ScriptCoreLib.Ultra.Library", new Assembly());
                        r.Add("ScriptCoreLib.Ultra.Controls", new Assembly());
                        r.Add("ScriptCoreLibJava", new Assembly());
                        r.Add("jsc.meta", new Assembly());
                    };

                    Action <TreeNode> AddUltraSource =
                        p =>
                    {
                        var my = p.Add("My.UltraSource");
                        my.Add("Default.htm", new HTMLDocument());
                        my.Add("jsc.png", new ImageFile());
                    };

                    {
                        var p = sln.Add("Visual C# Project", new VisualCSharpProject());


                        AddReferences(p);
                        AddUltraSource(p);



                        p.Add("Application.cs", new VisualCSharpCode());
                        p.Add("WebService.cs", new VisualCSharpCode());
                        p.Add("Program.cs", new VisualCSharpCode());
                    }

                    {
                        var p = sln.Add("Visual Basic Project", new VisualBasicProject());

                        AddReferences(p);
                        AddUltraSource(p);

                        p.Add("Application.vb", new VisualBasicCode());
                        p.Add("WebService.vb", new VisualBasicCode());
                        p.Add("Program.vb", new VisualBasicCode());
                    }


                    {
                        var p = sln.Add("Visual F# Project", new VisualFSharpProject());

                        AddReferences(p);
                        AddUltraSource(p);


                        p.Add("Application.fs", new VisualFSharpCode());
                        p.Add("WebService.fs", new VisualFSharpCode());
                        p.Add("Program.fs", new VisualFSharpCode());
                    }

                    sln.Container.style.Float = IStyle.FloatEnum.right;
                    sln.Container.AttachTo(MyPagesInternal);

                    new SourceEditorHeader().Container.AttachTo(MyPagesInternal);

                    //new IHTMLElement(IHTMLElement.HTMLElementEnum.h1, "Create your own Ultra Application project template").AttachTo(MyPagesInternal);

                    var n = new TextEditor(MyPagesInternal);

                    n.Width  = 600;
                    n.Height = 400;

                    //n.InnerHTML = "<p>Create your own <b>Ultra Application</b> Project Template</p>";


                    new DefaultPage1().Container.AttachTo(n.Document.body);

                    var m1 = new SimpleCodeView();

                    m1.Container.AttachTo(MyPagesInternal);
                    //m1.SelectType.onchange +=
                    //    delegate
                    //    {
                    //        m1.TypeName.innerText = m1.SelectType.value;
                    //    };

                    //m1.RunJavaScript.onclick +=
                    //    delegate
                    //    {
                    //        m1.RunJavaScript.style.color = JSColor.Blue;

                    //        try
                    //        {
                    //            Native.Window.eval(m1.Code1.value);

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //        catch
                    //        {
                    //            m1.RunJavaScript.style.color = JSColor.Red;

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //    };
                    new Compilation().GetArchives().SelectMany(k => k.GetAssemblies()).First(k => k.Name == "ScriptCoreLib").WhenReady(
                        ScriptCoreLib =>
                    {
                        // we do not have reflection in place for native wrappers :/

                        m1.SelectEvent.Clear();

                        var Element = ScriptCoreLib.GetTypes().Single(k => k.FullName == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");
                        //var Element = ScriptCoreLib.GetTypes().Single(k => k.HTMLElement == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");

                        Action <CompilationEvent> Add =
                            SourceEvent =>
                        {
                            m1.SelectEvent.Add(
                                new IHTMLOption {
                                innerText = SourceEvent.Name
                            }
                                );
                        };

                        Element.GetEvents().ForEach(Add);
                    }
                        );


                    m1.SelectEvent.onchange +=
                        delegate
                    {
                        m1.EventName.innerText = m1.SelectEvent.value;
                    };
                }
                else if (Native.Document.location.hash == "#/UltraApplicationWithAssets")
                {
                    new UltraApplicationWithAssets().Container.AttachToDocument();
                }
                else
                if (Native.Document.location.hash == "#/audio")
                {
                    Action AtTimer = delegate { };

                    (1000 / 15).AtInterval(
                        tt =>
                    {
                        AtTimer();
                    }
                        );

                    new SoundCloudBackground().Container.AttachTo(MyPagesBackground);
                    new SoundCloudHeader().Container.AttachTo(MyPagesInternal);

                    var page = 1;

                    var Tracks = new IHTMLDiv().AttachTo(MyPagesInternal);
                    Tracks.style.margin = "1em";

                    var More = new SoundCloudMore();

                    var AudioLinks = default(AudioLink);

                    var LoadCurrentPage = default(Action);

                    LoadCurrentPage = delegate
                    {
                        var loading = new SoundCloudLoading();

                        loading.Container.AttachTo(Tracks);


                        new UltraWebService().SoundCloudTracksDownload(
                            System.Convert.ToString(page),
                            ee =>
                        {
                            if (loading != null)
                            {
                                loading.Container.Orphanize();
                                loading = null;
                            }

                            var t = new SoundCloudTrack();

                            t.Content.ApplyToggleConcept(t.HideContent, t.ShowContent).Hide();

                            t.Title.innerHTML = ee.trackName;
                            t.Waveform.src    = ee.waveformUrl;

                            t.Audio.src        = ee.streamUrl;
                            t.Audio.autobuffer = true;


                            AudioLinks = new AudioLink
                            {
                                Audio = t.Audio,
                                Prev  = AudioLinks
                            };

                            var _AudioLinks = AudioLinks;

                            if (AudioLinks.Prev != null)
                            {
                                AudioLinks.Prev.Next = AudioLinks;
                            }
                            else
                            {
                                // we are the first  :)
                                t.Audio.play();
                            }

                            t.MoreButton.onclick +=
                                delegate
                            {
                                t.Audio.pause();

                                if (_AudioLinks.Next != null)
                                {
                                    _AudioLinks.Next.Audio.currentTime = 0;
                                    _AudioLinks.Next.Audio.play();

                                    if (_AudioLinks.Next.Next == null)
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                }
                            };

                            t.Audio.onended +=
                                delegate
                            {
                                if (_AudioLinks.Next != null)
                                {
                                    _AudioLinks.Next.Audio.currentTime = 0;
                                    _AudioLinks.Next.Audio.play();

                                    if (_AudioLinks.Next.Next == null)
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                }
                            };

                            t.Identity.innerText = ee.uid;

                            t.Play.onclick  += eee => { eee.PreventDefault(); t.Audio.play(); };
                            t.Pause.onclick += eee => { eee.PreventDefault(); t.Audio.pause(); };

                            t.Title.style.cursor = IStyle.CursorEnum.pointer;
                            t.Title.onclick     += eee =>
                            {
                                eee.PreventDefault();

                                var playing = true;

                                if (t.Audio.paused)
                                {
                                    playing = false;
                                }

                                if (t.Audio.ended)
                                {
                                    playing = false;
                                }

                                if (!playing)
                                {
                                    t.Audio.play();
                                }
                                else
                                {
                                    t.Audio.pause();
                                }
                            };

                            DoubleAction SetProgress1 = p =>
                            {
                                t.Gradient3.style.width = System.Convert.ToInt32(800 * p) + "px";
                                t.Gradient4.style.width = System.Convert.ToInt32(800 * p) + "px";
                            };

                            t.Gradient5.style.Opacity = 0.4;
                            t.Gradient6.style.Opacity = 0.4;

                            DoubleAction SetProgress2 = p =>
                            {
                                t.Gradient5.style.width = System.Convert.ToInt32(800 * p) + "px";
                                t.Gradient6.style.width = System.Convert.ToInt32(800 * p) + "px";
                            };

                            AtTimer +=
                                delegate
                            {
                                if (t.Audio.duration == 0)
                                {
                                    t.Play.Hide();
                                    t.Pause.Hide();
                                    return;
                                }
                                else
                                {
                                    var playing = true;

                                    if (t.Audio.paused)
                                    {
                                        playing = false;
                                    }

                                    if (t.Audio.ended)
                                    {
                                        playing = false;
                                    }

                                    if (!playing)
                                    {
                                        t.Title.style.color = Color.None;
                                    }
                                    else
                                    {
                                        t.Title.style.color = Color.Blue;
                                    }

                                    t.Play.Show(!playing);
                                    t.Pause.Show(playing);
                                }

                                var p = t.Audio.currentTime / t.Audio.duration;
                                SetProgress1(p);
                            };

                            t.Waveform.onmouseout +=
                                delegate
                            {
                                SetProgress2(0);
                            };

                            t.Waveform.onmousemove +=
                                eee =>
                            {
                                SetProgress2(eee.OffsetX / 800.0);
                            };

                            t.Waveform.onclick +=
                                eee =>
                            {
                                t.Audio.currentTime = t.Audio.duration * (eee.OffsetX / 800.0);
                                t.Audio.play();
                            };

                            t.Waveform.style.cursor = IStyle.CursorEnum.pointer;

                            SetProgress1(0);
                            SetProgress2(0);

                            t.Container.AttachTo(Tracks);
                        }
                            );


                        10000.AtDelay(
                            delegate
                        {
                            More.MoreButton.FadeIn(0, 1000, null);
                        }
                            );
                    };


                    More.MoreButton.Hide();
                    More.Container.AttachTo(MyPagesInternal);

                    More.MoreButton.onclick += eee =>
                    {
                        eee.PreventDefault();
                        More.MoreButton.FadeOut(1, 300,
                                                delegate
                        {
                            page++;
                            LoadCurrentPage();
                        }
                                                );
                    };

                    LoadCurrentPage();
                }
                else
                {
                    //new PromotionWebApplication1.HTML.Audio.FromAssets.Track1 { controls = true }.AttachToDocument();
                    //new PromotionWebApplication1.HTML.Audio.FromWeb.Track1 { controls = true, autobuffer = true }.AttachToDocument();

                    var IsAvalonJavaScript   = hash == "#/avalon.js";
                    var IsAvalonActionScript = hash == "#/avalon.as";
                    var IsAvalon             = IsAvalonActionScript || IsAvalonJavaScript;

                    //if (IsAvalon)
                    //{

                    //{
                    //    var ccc = new IHTMLDiv();

                    //    ccc.style.position = IStyle.PositionEnum.absolute;
                    //    ccc.style.left = "15%";
                    //    ccc.style.right = "15%";
                    //    ccc.style.top = "15%";


                    //    var Now = DateTime.Now;

                    //    var CountDown = new CountDownGadgetConcept(CountDownGadget.Create)
                    //    {
                    //        ShowOnlyDays = true,
                    //        Event = new DateTime(2010, 5, 24, 23, 59, 50),

                    //    };

                    //    CountDown.Element.GadgetContainer.style.color = "#808080";
                    //    CountDown.Element.GadgetContainer.style.textShadow = "#E0E0E0 1px 1px 1px";


                    //    CountDown.Element.GadgetContainer.AttachTo(ccc);
                    //    CountDown.Element.GadgetContainer.FadeIn(3000, 2000, null);

                    //    ccc.AttachToDocument();
                    //}

                    {
                        var ccc = new IHTMLDiv();

                        ccc.style.position   = IStyle.PositionEnum.absolute;
                        ccc.style.left       = "50%";
                        ccc.style.top        = "50%";
                        ccc.style.marginLeft = (-JSCSolutionsNETCarouselCanvas.DefaultWidth / 2) + "px";
                        ccc.style.marginTop  = (-JSCSolutionsNETCarouselCanvas.DefaultHeight / 2) + "px";

                        ccc.style.SetSize(JSCSolutionsNETCarouselCanvas.DefaultWidth, JSCSolutionsNETCarouselCanvas.DefaultHeight);

                        ccc.AttachToDocument();

                        if (IsAvalonActionScript)
                        {
                            var alof = new UltraSprite();
                            alof.ToTransparentSprite();
                            alof.AttachSpriteTo(ccc);
                        }
                        else
                        {
                            var alo = new JSCSolutionsNETCarouselCanvas();
                            alo.Container.AttachToContainer(ccc);

                            alo.AtLogoClick +=
                                delegate
                            {
                                //Native.Window.open("http://sourceforge.net/projects/jsc/", "_blank");
                                Native.Window.open("/download", "_blank");
                            };
                        }
                    }
                    //}
                    //else
                    //{
                    //    var cc = new HTML.Pages.FromAssets.Controls.Named.CenteredLogo_Kamma();

                    //    cc.Container.AttachToDocument();

                    //    // see: http://en.wikipedia.org/wiki/Perl_control_structures
                    //    // "Unless" == "if not"  ;)

                    //    IsMicrosoftInternetExplorer.YetIfNotThen(cc.TheLogoImage.BeginPulseAnimation).ButIfSoThen(cc.TheLogoImage.HideNowButShowAtDelay);
                    //}

                    var aa = new About();
                    aa.Service.innerText = gapageview;
                    aa.Container.AttachToDocument();
                }
            }
            #endregion


            Analytics =
                __hash =>
            {
                var __gahash     = Native.Window.escape(__hash);
                var __gapageview = gapathname + gasearch + __gahash;


                "UA-13087448-1".ToGoogleAnalyticsTracker(
                    pageTracker =>
                {
                    pageTracker._setDomainName(".jsc-solutions.net");
                    pageTracker._trackPageview(__gapageview);
                }
                    );
            };

            Analytics(Native.Document.location.hash);
        }