Example #1
0
        internal static void LoadStyle()
        {
            Gtk.Style  defaultStyle;
            Gtk.Widget styledWidget;
            if (IdeApp.Workbench == null || IdeApp.Workbench.RootWindow == null)
            {
                styledWidget = new Gtk.Label(String.Empty);
                defaultStyle = styledWidget.Style;
            }
            else
            {
                styledWidget = IdeApp.Workbench.RootWindow;
                defaultStyle = Gtk.Rc.GetStyle(styledWidget);
            }

            BackgroundColor              = defaultStyle.Background(Gtk.StateType.Normal).ToXwtColor();  // must be the bg color from Gtkrc
            BaseBackgroundColor          = defaultStyle.Base(Gtk.StateType.Normal).ToXwtColor();        // must be the base color from Gtkrc
            BaseForegroundColor          = defaultStyle.Foreground(Gtk.StateType.Normal).ToXwtColor();  // must be the text color from Gtkrc
            BaseSelectionBackgroundColor = defaultStyle.Base(Gtk.StateType.Selected).ToXwtColor();
            BaseSelectionTextColor       = defaultStyle.Text(Gtk.StateType.Selected).ToXwtColor();

            LinkForegroundColor = ((Gdk.Color)styledWidget.StyleGetProperty("link-color")).ToXwtColor();
            if (LinkForegroundColor == Colors.Black)             // the style returs black when not initialized
            {
                LinkForegroundColor = Colors.Blue;               // set the link color to generic blue until initialization is finished
            }
            DefaultFont     = defaultStyle.FontDescription.Copy();
            DefaultFontName = DefaultFont.ToString();

            if (IdeApp.Preferences == null || IdeApp.Preferences.UserInterfaceTheme == Theme.Light)
            {
                LoadLightStyle();
            }
            else
            {
                LoadDarkStyle();
            }

            // Shared colors

            DockBarLabelColor  = BaseIconColor;
            DockSeparatorColor = DockFrameBackground;
            PropertyPadLabelBackgroundColor = PrimaryBackgroundColor;
            PadCategoryBorderColor          = SeparatorColor;
            PadCategoryLabelColor           = BaseForegroundColor;
            PadCategoryBackgroundColor      = SecondaryBackgroundLighterColor;
            PadLabelColor = BaseForegroundColor;
            SubTabBarActiveBackgroundColor = BaseSelectionBackgroundColor;
            SubTabBarActiveTextColor       = BaseSelectionTextColor;
            SubTabBarSeparatorColor        = SubTabBarTextColor;
            InactiveBrowserPadBackground   = InactivePadBackground;
            SecondaryTextColor             = Color.FromName("#808080");
            SecondarySelectionTextColor    = Color.FromName("#93cbff");

            // Tabs

            TabBarBackgroundColor   = DockFrameBackground;
            TabBarInactiveTextColor = InactivePadLabelColor;
            TabBarActiveTextColor   = BaseForegroundColor;

            // Breadcrumbs

            BreadcrumbTextColor = BaseForegroundColor;

            // Document Subview Tabs

            SubTabBarTextColor = BaseForegroundColor;

            // Popover Window

            PopoverWindow.InformationBackgroundColor = StatusInformationBackgroundColor;
            PopoverWindow.InformationTextColor       = StatusInformationTextColor;
            PopoverWindow.WarningBackgroundColor     = StatusWarningBackgroundColor;
            PopoverWindow.WarningTextColor           = StatusWarningTextColor;
            PopoverWindow.ErrorBackgroundColor       = StatusErrorBackgroundColor;
            PopoverWindow.ErrorTextColor             = StatusErrorTextColor;

            // Code Completion

            CodeCompletion.SelectionBackgroundColor = BaseSelectionBackgroundColor;
            CodeCompletion.SelectionTextColor       = BaseSelectionTextColor;

            // Global Search

            GlobalSearch.BackgroundColor                    = PrimaryBackgroundColor;
            GlobalSearch.HeaderBackgroundColor              = SecondaryBackgroundLighterColor;
            GlobalSearch.HeaderTextColor                    = DimTextColor;
            GlobalSearch.SeparatorLineColor                 = SeparatorColor;
            GlobalSearch.SelectionBackgroundColor           = BaseSelectionBackgroundColor;
            GlobalSearch.ResultTextColor                    = BaseForegroundColor;
            GlobalSearch.ResultDescriptionTextColor         = DimTextColor;
            GlobalSearch.SelectedResultTextColor            = BaseSelectionTextColor;
            GlobalSearch.SelectedResultDescriptionTextColor = BaseSelectionTextColor;
            GlobalSearch.SelectedResultMatchTextColor       = BaseSelectionTextColor;

            // New Project Dialog

            NewProjectDialog.TemplateBackgroundColor                      = PrimaryBackgroundColor;
            NewProjectDialog.TemplateLanguageButtonTriangle               = BaseIconColor;
            NewProjectDialog.ProjectConfigurationPreviewLabelColor        = BaseForegroundColor;
            NewProjectDialog.CategoriesBackgroundColor                    = SecondaryBackgroundDarkerColor;
            NewProjectDialog.ProjectConfigurationLeftHandBackgroundColor  = SecondaryBackgroundDarkerColor;
            NewProjectDialog.ProjectConfigurationRightHandBackgroundColor = PrimaryBackgroundColor;

            // Wizards

            Wizard.PageBackgroundColor      = SecondaryBackgroundDarkerColor;
            Wizard.RightSideBackgroundColor = PrimaryBackgroundColor;

            // Editor

            Editor.SmartTagMarkerColorLight   = Color.FromName("#ff70fe").WithAlpha(.5);
            Editor.SmartTagMarkerColorDark    = Color.FromName("#ffffff").WithAlpha(.5);
            Editor.SearchErrorForegroundColor = ErrorForegroundColor;

            // Key Bindings Preferences

            KeyBindingsPanel.KeyBackgroundColor          = BackgroundColor;
            KeyBindingsPanel.KeyForegroundColor          = BaseForegroundColor;
            KeyBindingsPanel.KeyDuplicateBackgroundColor = StatusWarningBackgroundColor;
            KeyBindingsPanel.KeyDuplicateForegroundColor = StatusWarningTextColor;
            KeyBindingsPanel.KeyConflictBackgroundColor  = StatusErrorBackgroundColor;
            KeyBindingsPanel.KeyConflictForegroundColor  = StatusErrorTextColor;

            if (Changed != null)
            {
                Changed(null, EventArgs.Empty);
            }
        }
Example #2
0
 public static void Init(SpriteBatch spriteBatch)
 {
     SpriteBatch = spriteBatch;
     DefaultFont.Load(CurrentGame.ContentManager);
 }
 public static void Unload()
 {
     _sceneContents.Dispose();
     _sceneContents = new SceneContents(CurrentGame.ContentManager);
     DefaultFont.Load(CurrentGame.ContentManager);
 }
Example #4
0
 public static void Unload()
 {
     _sceneContents.Dispose();
     _sceneContents = new SceneContents(_game.Content);
     DefaultFont.Load(_game.Content);
 }
        private void ChartForm_Load(object sender, EventArgs e)
        {
            // Add a title to the chart
            Title chtTitle = new Title("", Docking.Top, new Font("Arial", 16), Color.Black);

            chtTitle.Name = "Title";
            EfficiencyChart.Titles.Add(chtTitle);

            chtTitle      = new Title("", Docking.Top, new Font("Arial", 8), Color.Black);
            chtTitle.Name = "InfoTitle";
            EfficiencyChart.Titles.Add(chtTitle);

            // Lines for best fit series
            Series series;

            foreach (String seriesName in new List <String> {
                "y1", "y1-oh", "y1-omega", "y2", "y2-oh", "y2-omega"
            })
            {
                series = new Series(seriesName);
                if (seriesName.IndexOf("-") < 0)
                {
                    series.ChartType = SeriesChartType.Point;
                }
                else
                {
                    series.ChartType   = SeriesChartType.Spline;
                    series.BorderWidth = 2;
                }
                if (seriesName.IndexOf("2") >= 0)
                {
                    series.YAxisType = AxisType.Secondary;
                }
                EfficiencyChart.Series.Add(series);
            }

            // Format Chart Area
            ChartArea chartArea = EfficiencyChart.ChartAreas[0];
            Font      labelFont = new Font(DefaultFont.ToString(), 10, FontStyle.Bold);

            chartArea.AxisX.Title                    = "Problem Size";
            chartArea.AxisX.TitleFont                = labelFont;
            chartArea.AxisY.TitleFont                = labelFont;
            chartArea.AxisY2.TitleFont               = labelFont;
            chartArea.AxisX.IsMarginVisible          = false;
            chartArea.AxisX.Minimum                  = 0;
            chartArea.AxisY.IsMarginVisible          = false;
            chartArea.AxisY.Minimum                  = 0;
            chartArea.AxisY.LabelStyle.Angle         = -25;
            chartArea.AxisY2.IsMarginVisible         = false;
            chartArea.AxisY2.Minimum                 = 0;
            chartArea.AxisY2.LabelStyle.Angle        = -25;
            chartArea.AxisY2.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
            chartArea.AxisY2.MajorGrid.LineColor     = Color.Gray;

            // Format Legend
            Legend legend = EfficiencyChart.Legends[0];

            legend.Docking                 = Docking.Bottom;
            legend.Alignment               = StringAlignment.Center;
            legend.BorderColor             = Color.Black;
            legend.BorderDashStyle         = ChartDashStyle.Dash;
            legend.IsDockedInsideChartArea = false;

            // Add to the chart
            update_chart(sender, e);
        }
Example #6
0
 public TempButton(String text)
     : base(text, DefaultFont, 0, 0, DefaultWidth, DefaultFont.FontHeight())
 {
 }
Example #7
0
 private bool ShouldSerializeFont()
 {
     return(!DefaultFont.Equals(Font));
 }
Example #8
0
        /// <summary>
        /// Dibuja el turno de la mesa.
        /// </summary>
        public void drawTurn()
        {
            Vector2 turnPosition = new Vector2(ScreenWidth - DefaultFont.MeasureString("Turn: " + ActualData.Turn).X, 0);

            Game.SpriteBatch.DrawString(DefaultFont, "Turn: " + ActualData.Turn, turnPosition, Color.White);
        }
Example #9
0
        public __Form()
        {
            Console.WriteLine("event: enter new " + this.GetType().Name + "()");
            //IStyleSheet.all.disabled = true;

            this.InternalTrackInitializeComponents = delegate
            {
                ConstructorStopwatch.Stop();

                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201402/20140205
                // will this help us? no?
                //IStyleSheet.all.disabled = false;

                //Console.WriteLine("event: new " + new { this.GetType().Name } + " InternalResumeLayout " + new { ConstructorStopwatch.ElapsedMilliseconds });
                Console.WriteLine("event: new " + this.GetType().Name + "() " + new { ConstructorStopwatch.ElapsedMilliseconds });


                //474ms new { Name = FooActivity } InternalResumeLayout { ElapsedMilliseconds = 464 }


                new XAttribute(
                    "ConstructorStopwatch",
                    new { ConstructorStopwatch.ElapsedMilliseconds }.ToString()
                    ).AttachTo(this.HTMLTargetRef);
            };

            //25:584ms event: exit DataGridView .ctor { ElapsedMilliseconds = 525 } view-source:35983
            //48:1043ms event: exit DataGridView .ctor { ElapsedMilliseconds = 445 } view-source:35983
            //95:1509ms event: exit DataGridView .ctor { ElapsedMilliseconds = 420 } view-source:35983
            //96:1713ms at FlowLayoutPanel InternalResumeLayout { ElapsedMilliseconds = 628, Name = flowLayoutPanel1, Controls = 2 } view-source:35955
            //97:1724ms at FlowLayoutPanel InternalResumeLayout { ElapsedMilliseconds = 1674, Name = flowLayoutPanel1, Controls = 9 } view-source:35955
            //97:1724ms at FlowLayoutPanel InternalResumeLayout { ElapsedMilliseconds = 1137, Name = flowLayoutPanel2, Controls = 3 } view-source:35996
            //97:1724ms at FlowLayoutPanel InternalResumeLayout { ElapsedMilliseconds = 1128, Name = flowLayoutPanel3, Controls = 1 } view-source:35996
            //97:1724ms event: new FooActivity() { ElapsedMilliseconds = 1706 }

            this.StartPosition = FormStartPosition.CenterScreen;

            var TargetElement = new IHTMLDiv
            {
                // do this ahead of time
                // type inheritance?
                className = typeof(Form).Name + " " + this.GetType().Name
            };

            // thanks host, but we do our own resizers
            // http://stackoverflow.com/questions/13224184/css-resize-handles-with-resize-both-property
            // http://www.w3schools.com/cssref/css3_pr_resize.asp
            //TargetElement.style.resize = "none !important";

            TargetElement.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            TargetElement.style.left     = "0px";
            TargetElement.style.top      = "0px";

            HTMLTarget = TargetElement;

            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2013/201312/20131222-form
            outer_css = TargetElement.css;

            #region TargetOuterBorder
            TargetOuterBorder = new IHTMLDiv().AttachTo(TargetElement);
            //HTMLTarget.style.backgroundColor = Shared.Drawing.Color.System.ThreeDFace;
            TargetOuterBorder.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            TargetOuterBorder.style.left     = "0px";
            TargetOuterBorder.style.top      = "0px";
            TargetOuterBorder.style.bottom   = "0px";
            TargetOuterBorder.style.right    = "0px";

            TargetOuterBorder.style.borderWidth       = "1px";
            TargetOuterBorder.style.borderStyle       = "solid";
            TargetOuterBorder.style.borderBottomColor = "#424142";
            TargetOuterBorder.style.borderRightColor  = "#424142";
            TargetOuterBorder.style.borderLeftColor   = "#D6D3CE";
            TargetOuterBorder.style.borderTopColor    = "#D6D3CE";
            //HTMLTarget.style.SetLocation(64, 64, 100, 100);
            TargetOuterBorder.style.padding = "0";
            #endregion

            #region TargetInnerBorder
            var TargetInnerBorder = new IHTMLDiv().AttachTo(TargetOuterBorder);
            ////HTMLTarget.style.backgroundColor = Shared.Drawing.Color.System.ThreeDFace;
            TargetInnerBorder.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            TargetInnerBorder.style.left     = "0px";
            TargetInnerBorder.style.top      = "0px";
            TargetInnerBorder.style.bottom   = "0px";
            TargetInnerBorder.style.right    = "0px";

            TargetInnerBorder.style.borderWidth       = "1px";
            TargetInnerBorder.style.borderStyle       = "solid";
            TargetInnerBorder.style.borderLeftColor   = "#FFFFFF";
            TargetInnerBorder.style.borderTopColor    = "#FFFFFF";
            TargetInnerBorder.style.borderRightColor  = "#848284";
            TargetInnerBorder.style.borderBottomColor = "#848284";

            // ?
            //TargetInnerBorder.style.backgroundColor = "#D6D3CE";

            //HTMLTarget.style.SetLocation(64, 64, 100, 100);
            #endregion


            #region TargetResizerPadding
            TargetResizerPadding = new IHTMLDiv().AttachTo(TargetInnerBorder);
            TargetResizerPadding.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            TargetResizerPadding.style.left     = "2px";
            TargetResizerPadding.style.top      = "2px";
            TargetResizerPadding.style.bottom   = "2px";
            TargetResizerPadding.style.right    = "2px";
            #endregion

            #region TargetNoBorder
            TargetNoBorder = new IHTMLDiv().AttachTo(TargetResizerPadding);
            TargetNoBorder.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            TargetNoBorder.style.left     = "0px";
            TargetNoBorder.style.top      = "0px";
            TargetNoBorder.style.bottom   = "0";
            TargetNoBorder.style.right    = "0";
            #endregion


            TargetOuterBorder.style.boxShadow = "black 3px 3px 6px -3px";


            #region caption
            //IHTMLImage icon = "assets/ScriptCoreLib.Windows.Forms/App.ico";

            icon.style.SetLocation(5, 5, 16, 16);

            //caption.style.backgroundColor = JSColor.System.ActiveCaption;
            Caption.style.backgroundColor = JSColor.FromRGB(0x08, 0x24, 0x6B);

            Caption.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            Caption.style.left     = 0 + "px";
            Caption.style.top      = 0 + "px";
            Caption.style.right    = 0 + "px";
            Caption.style.height   = "26px";
            Caption.style.margin   = "0px";

            //Caption.style.paddingTop = "6px";
            //Caption.style.paddingLeft = "26px";
            Caption.style.font = new Font("Segoe UI", 9.0F, FontStyle.Regular, GraphicsUnit.Point, 0).ToCssString();

            CaptionShadow = (IHTMLDiv)Caption.cloneNode(false);
            CaptionShadow.style.backgroundColor = JSColor.Black;
            CaptionShadow.style.Opacity         = 0;



            CaptionContent             = new IHTMLHeader1();
            CaptionContent.style.color = Shared.Drawing.Color.White;

            CaptionContent.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            CaptionContent.style.left     = 0 + "px";
            CaptionContent.style.top      = 0 + "px";
            CaptionContent.style.right    = 0 + "px";
            CaptionContent.style.height   = "26px";
            CaptionContent.style.margin   = "0px";

            CaptionContent.style.fontSize   = "1em";
            CaptionContent.style.fontWeight = "100";

            CaptionContent.style.backgroundColor = JSColor.None;

            CaptionContent.style.font = DefaultFont.ToCssString();

            (CaptionContent.style as dynamic).textOverflow = "ellipsis";



            //CaptionContent.style.WithDynamic(
            //    style => style.textOverflow = "ellipsis"
            //);

            CaptionContent.style.lineHeight = "26px";
            CaptionContent.style.left       = "26px";
            CaptionContent.style.right      = "30px";

            CaptionContent.style.overflow = IStyle.OverflowEnum.hidden;



            CaptionForeground = (IHTMLDiv)Caption.cloneNode(false);
            CaptionForeground.style.backgroundColor = ScriptCoreLib.Shared.Drawing.Color.FromRGB(255, 0, 255);
            CaptionForeground.style.Opacity         = 0;
            CaptionForeground.className             = "caption";
            CaptionForeground.style.right           = "26px";

            // http://dojotoolkit.org/pipermail/dojo-checkins/2005-December/002867.html


            //            new IFunction(@"
            //                try { this.style.MozUserSelect = 'none'; } catch (e) { }
            //                try { this.style.KhtmlUserSelect = 'none'; } catch (e) { }
            //                try { this.unselectable = 'on'; } catch (e) { }
            //                "
            //            ).apply(caption_foreground);

            //            caption_foreground.onselectstart +=
            //                (e) =>
            //                {
            //                    e.PreventDefault();
            //                    e.StopPropagation();
            //                };
            #endregion

            // http://developer.apple.com/mac/library/documentation/AppleApplications/Reference/Dashboard_Ref/Dashboard_Ref.pdf
            // for some reason we cannot exclude caption
            // from apple dashboard

            //caption_foreground.style.appleDashboardRegion = "none";

            //container.style.backgroundColor = "#A0A0A0";
            //container.style.appleDashboardRegion = "dashboard-region(control rectangle)";

            #region ContentContainer
            //ContentContainerPadding.title = "ContentContainerPadding";
            ContentContainerPadding.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            ContentContainerPadding.style.left     = 0 + "px";
            ContentContainerPadding.style.top      = (26 + innerborder + 0) + "px";
            ContentContainerPadding.style.right    = 0 + "px";
            ContentContainerPadding.style.bottom   = 0 + "px";

            ContentContainer = new IHTMLDiv().AttachTo(ContentContainerPadding);
            //ContentContainer.title = "ContentContainer";
            ContentContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            ContentContainer.style.left     = 0 + "px";
            ContentContainer.style.top      = 0 + "px";
            ContentContainer.style.right    = 0 + "px";
            ContentContainer.style.bottom   = 0 + "px";
            ContentContainer.style.overflow = IStyle.OverflowEnum.hidden;

            // is this needed?
            //ContentContainer.style.zIndex = 1000;

            var ContentContainerShadow = new IHTMLDiv().AttachTo(ContentContainerPadding);
            //ContentContainerShadow.title = "ContentContainerShadow";
            ContentContainerShadow.style.position        = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            ContentContainerShadow.style.left            = 0 + "px";
            ContentContainerShadow.style.top             = 0 + "px";
            ContentContainerShadow.style.right           = 0 + "px";
            ContentContainerShadow.style.bottom          = 0 + "px";
            ContentContainerShadow.style.overflow        = IStyle.OverflowEnum.hidden;
            ContentContainerShadow.style.backgroundColor = JSColor.Red;
            ContentContainerShadow.style.Opacity         = 0.0;
            ContentContainerShadow.style.display         = IStyle.DisplayEnum.none;
            ContentContainerShadow.style.zIndex          = 1001;
            #endregion

            InternalMouseCapured +=
                delegate
            {
                // is this enough to capture resizer in a chrome AppWindow?
                ContentContainerShadow.style.display = IStyle.DisplayEnum.block;
            };

            InternalMouseReleased +=
                delegate
            {
                ContentContainerShadow.style.display = IStyle.DisplayEnum.none;
            };


            #region ResizeGripElement
            ResizeGripElement = new IHTMLDiv().AttachTo(ContentContainerPadding);
            ResizeGripElement.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            ResizeGripElement.style.width    = "12px";
            ResizeGripElement.style.height   = "12px";
            ResizeGripElement.style.bottom   = "0px";
            ResizeGripElement.style.right    = "0px";
            ResizeGripElement.style.cursor   = IStyle.CursorEnum.se_resize;
            new IHTMLImage {
                src = "assets/ScriptCoreLib.Windows.Forms/FormResizeGrip.png"
            }.ToBackground(ResizeGripElement);
            ResizeGripElement.style.zIndex = 1002;
            #endregion

            #region ResizeGripDrag
            ResizeGripDrag = new ScriptCoreLib.JavaScript.Controls.DragHelper(ResizeGripElement);

            ResizeGripDrag.Enabled = true;

            #region AtSizeChanged
            Action AtSizeChanged = delegate
            {
                var Size = this.Size;

                ResizeGripDrag.Position = new Shared.Drawing.Point(Size.Width, Size.Height);
            };

            this.SizeChanged +=
                delegate
            {
                AtSizeChanged();
            };
            AtSizeChanged();
            #endregion

            ResizeGripDrag.DragStart +=
                delegate
            {
                Capture = true;
                InternalMouseCapured();
            };
            ResizeGripDrag.DragMove +=
                delegate
            {
                this.Size = new Size(ResizeGripDrag.Position.X, ResizeGripDrag.Position.Y);
            };

            ResizeGripDrag.DragStop +=
                delegate
            {
                Capture = false;
                InternalMouseReleased();
            };
            #endregion



            #region CloseButton
            InternalCloseButton = new IHTMLDiv {
                name = "CloseButton"
            };
            InternalCloseButton.style.textAlign  = IStyle.TextAlignEnum.center;
            InternalCloseButton.style.fontWeight = "bold";
            //InternalCloseButton.style.cursor = IStyle.CursorEnum.@default;
            InternalCloseButton.style.cursor = IStyle.CursorEnum.pointer;

            InternalCloseButtonContent = new IHTMLDiv {
            }.AttachTo(InternalCloseButton);

            InternalCloseButtonContent.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            InternalCloseButtonContent.style.left     = "0px";
            InternalCloseButtonContent.style.top      = "0px";
            InternalCloseButtonContent.style.bottom   = "0";
            InternalCloseButtonContent.style.right    = "0";



            InternalCloseButtonContent.title     = "Close";
            InternalCloseButtonContent.innerHTML = "&times";



            InternalCloseButton.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;

            //CloseButton.style.backgroundColor = JSColor.System.ThreeDFace;
            InternalCloseButton.style.backgroundColor = "#D6D3CE";

            InternalCloseButton.style.height = "18px";
            InternalCloseButton.style.width  = "18px";
            InternalCloseButton.style.right  = (innerborder + 3) + "px";
            InternalCloseButton.style.top    = (innerborder + 2) + "px";

            InternalCloseButton.style.borderWidth = "1px";
            InternalCloseButton.style.borderStyle = "solid";

            InternalCloseButton.style.borderRightColor  = "#424142";
            InternalCloseButton.style.borderBottomColor = "#424142";
            InternalCloseButton.style.borderLeftColor   = "#FFFFFF";
            InternalCloseButton.style.borderTopColor    = "#FFFFFF";



            InternalCloseButtonContent.style.borderWidth = "1px";
            InternalCloseButtonContent.style.borderStyle = "solid";

            InternalCloseButtonContent.style.borderLeftColor   = "#D6D3CE";
            InternalCloseButtonContent.style.borderTopColor    = "#D6D3CE";
            InternalCloseButtonContent.style.borderRightColor  = "#848284";
            InternalCloseButtonContent.style.borderBottomColor = "#848284";

            #region CloseButton onclick

            InternalCloseButton.css.hover[IHTMLElement.HTMLElementEnum.div].style.color = "red";

            //InternalCloseButton.onmouseover +=
            //     delegate
            //     {
            //         InternalCloseButtonContent.style.color = JSColor.Red;
            //     };

            //InternalCloseButton.onmouseout +=
            //    delegate
            //    {
            //        InternalCloseButtonContent.style.color = JSColor.None;
            //    };

            InternalCloseButton.onmousedown +=
                e =>
            {
                e.stopPropagation();
                e.preventDefault();
            };

            InternalCloseButton.onclick +=
                delegate
            {
                InternalClose(reason: CloseReason.UserClosing);
            };
            #endregion

            #endregion

            TargetNoBorder.appendChild(

                ContentContainerPadding,



                Caption, CaptionShadow, CaptionContent,
                icon, CaptionForeground

                , InternalCloseButton

                );

            CaptionForeground.oncontextmenu +=
                e =>
            {
                // can we show our own menu?
                e.preventDefault();
                e.stopPropagation();
            };

            #region InternalCaptionDrag
            InternalCaptionDrag = new ScriptCoreLib.JavaScript.Controls.DragHelper(CaptionForeground);

            // http://forum.mootools.net/topic.php?id=534
            // disable text selection
            // look at http://forkjavascript.com/

            InternalCaptionDrag.Enabled = true;
            #endregion

            var BeforePosition = new Shared.Drawing.Point(0, 0);

            var FirstMove = false;
            var AnyMove   = false;

            var DragStartMaximized  = false;
            var DragStartMaximizedY = 0;



            this.MaximizeBox        = true;
            this.InternalControlBox = true;

            #region DragStart
            InternalCaptionDrag.DragStartValidate +=
                e =>
            {
                // if there is no max, then there is no restore. then do not allow to
                // drag back either
                e.Value = this.MaximizeBox;
            };

            InternalCaptionDrag.DragStart +=
                delegate
            {
                TargetNoBorder.style.cursor       = IStyle.CursorEnum.move;
                CaptionForeground.style.cursor    = IStyle.CursorEnum.move;
                Native.Document.body.style.cursor = IStyle.CursorEnum.move;



                BeforePosition = InternalCaptionDrag.Position;

                FirstMove          = true;
                DragStartMaximized = this.WindowState == FormWindowState.Maximized;
                //if (DragStartMaximized)
                //    DragStartMaximizedY = this.InternalRestoreLocation.Y;

                // offsetWidth: 1045

                //Console.WriteLine(new { BeforePosition, DragStartMaximized });

                Capture = true;
                InternalMouseCapured();
            };
            #endregion

            #region WindowState
            Action InternalEnterFullscreen =
                delegate
            {
                Console.WriteLine("InternalEnterFullscreen WindowState <- Maximized");
                this.WindowState = FormWindowState.Maximized;
            };


            Action InternalExitFullscreen =
                delegate
            {
                Console.WriteLine("InternalExitFullscreen WindowState <- Normal");

                this.WindowState = FormWindowState.Normal;
            };
            #endregion


            #region DragMove
            InternalCaptionDrag.DragMove +=
                delegate
            {
                if (!Capture)
                {
                    return;
                }


                //Console.WriteLine(new { InternalCaptionDrag.Position, BeforePosition, DragStartMaximized });

                // { Position = [192, 205.5], BeforePosition = [192, 205.5], DragStartMaximized = true }

                if (InternalCaptionDrag.Position.X == BeforePosition.X)
                {
                    if (InternalCaptionDrag.Position.Y == BeforePosition.Y)
                    {
                        //Console.WriteLine("FirstMove without move");
                        return;
                    }
                }

                // { InternalHostHeight = 0, y = 301 }
                //var MinimizeY = InternalHostHeight - 26;
                var y = InternalCaptionDrag.Position.Y;
                //Console.WriteLine(new { InternalHostHeight, y });
                //y = Math.Min(MinimizeY, Math.Max(-4, y));
                y = Math.Max(-4, y);


                if (FirstMove)
                {
                    FirstMove = false;

                    if (this.WindowState == FormWindowState.Maximized)
                    {
                        //Capture = false;

                        //this.InternalRestoreLocation = new Point(InternalCaptionDrag.Position.X, y);


                        // we have a small glitch here
                        Console.WriteLine("InternalCaptionDrag.DragMove FirstMove " + new { this.InternalRestoreLocation });

                        InternalExitFullscreen();

                        //return;
                    }
                }


                AnyMove = true;


                //if (Native.Document.fullscreenElement == TargetNoBorder)
                this.Location = new Point(InternalCaptionDrag.Position.X, y);

                //Console.WriteLine(new { Location });

                if (y < 0)
                {
                    CaptionShadow.Show();
                }
                //else
                //{

                //    if (y < MinimizeY)
                //        CaptionShadow.Hide();
                //    else
                //        CaptionShadow.Show();
                //}
            };
            #endregion

            #region DragStop
            InternalCaptionDrag.DragStop +=
                delegate
            {
                if (!Capture)
                {
                    return;
                }


                Capture = false;
                InternalMouseReleased();

                if (!AnyMove)
                {
                    return;
                }

                // tested by
                // X:\jsc.svn\examples\javascript\MatrixTransformBExample\MatrixTransformBExperiment\Application.cs

                //var Location = this.Location;

                //this.Text = new { drag.Position.X, drag.Position.Y }.ToString();

                TargetNoBorder.style.cursor       = IStyle.CursorEnum.@default;
                CaptionForeground.style.cursor    = IStyle.CursorEnum.@default;
                Native.document.body.style.cursor = IStyle.CursorEnum.@default;


                //var MinimizeY = InternalHostHeight - 26;
                var y = InternalCaptionDrag.Position.Y;

                //if (this.HTMLTarget.parentNode != Native.document.body)
                //{
                //    // this window is in a nested element, or even in another window.
                //    // bail!

                //    return;
                //}

                if (y < 0)
                {
                    InternalCaptionDrag.Position = BeforePosition;

                    InternalEnterFullscreen();

                    this.InternalRestoreLocation = new Point(BeforePosition.X, BeforePosition.Y);
                }
                //else if (y >= MinimizeY)
                //{
                //    if (this.WindowState != FormWindowState.Minimized)
                //    {
                //        // do we need this?

                //        var cs = this.ClientSize;
                //        var ll = this.Location;

                //        //drag.Position = BeforePosition;
                //        //this.Location = new Point(BeforePosition.X, BeforePosition.Y);

                //        this.WindowState = FormWindowState.Minimized;

                //        //this.InternalRestoreClientSIze = cs;
                //        this.InternalRestoreLocation = ll;
                //    }
                //}
                else
                {
                    //Console.WriteLine("to Normal ? " + new { this.WindowState });

                    if (this.WindowState == FormWindowState.Minimized)
                    {
                        var cs = this.ClientSize;
                        var ll = this.Location;

                        this.WindowState = FormWindowState.Normal;

                        //this.ClientSize = cs;
                        this.Location = ll;
                    }
                }
            };
            #endregion


            #region MiddleClick
            InternalCaptionDrag.MiddleClick +=
                delegate
            {
                Capture = false;

                if (!this.MaximizeBox)
                {
                    // X:\jsc.svn\examples\javascript\forms\FormsWithVisibleTitle\FormsWithVisibleTitle\Application.cs
                    // not supposed to restore
                    return;
                }

                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.WindowState = FormWindowState.Normal;
                    return;
                }

                if (this.WindowState == FormWindowState.Maximized)
                {
                    Console.WriteLine("InternalCaptionDrag.MiddleClick  InternalExitFullscreen");

                    InternalExitFullscreen();
                }
                else
                {
                    Console.WriteLine("InternalCaptionDrag.MiddleClick  InternalEnterFullscreen");
                    InternalEnterFullscreen();
                }
            };
            #endregion


            #region ondblclick
            CaptionForeground.ondblclick +=
                delegate
            {
                Capture = false;

                if (!this.MaximizeBox)
                {
                    // X:\jsc.svn\examples\javascript\forms\FormsWithVisibleTitle\FormsWithVisibleTitle\Application.cs
                    // not supposed to restore
                    return;
                }

                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.WindowState = FormWindowState.Normal;
                    return;
                }


                if (this.WindowState == FormWindowState.Maximized)
                {
                    InternalExitFullscreen();
                }
                else
                {
                    InternalEnterFullscreen();
                }
            };
            #endregion



            // to be replaiced with #shadow-root content select?
            this.InternalStyler = new FormStyler
            {
                Context = this,

                Caption        = Caption,
                CaptionContent = CaptionContent,
                CaptionShadow  = CaptionShadow,

                CloseButton        = InternalCloseButton,
                CloseButtonContent = InternalCloseButtonContent,

                TargetInnerBorder = TargetInnerBorder,
                TargetOuterBorder = TargetOuterBorder,

                ContentContainerPadding = ContentContainerPadding,

                TargetResizerPadding = TargetResizerPadding
            };


            //HTMLTarget.style.backgroundColor = "#B0B0B0";
            this.BackColor = Color.FromArgb(0xD6, 0xD3, 0xCE);

            this.Size = new Size(400, 400);


            FormStyler.RaiseAtFormCreated(
                this.InternalStyler
                );


            //this.ControlAdded +=
            //    (sender, args) =>
            //    {
            //        if (InternalTrackInitializeComponents)
            //        {

            //            // report what controls are being added and

            //            Console.WriteLine("at Form ControlAdded " + new
            //            {
            //                ConstructorStopwatch.ElapsedMilliseconds,
            //                Control = args.Control.GetType().Name,
            //                this.GetType().Name
            //            });
            //        }
            //    };

            //312ms at Form InternalResumeLayout { FormConstructorStopwatch = 0.00:00:00, Name = FooActivity }
            //Console.WriteLine("exit Form .ctor " + new { ConstructorStopwatch.ElapsedMilliseconds, this.GetType().Name });
        }
Example #10
0
 /// <summary>
 /// Dibuja todos los elementos de la pantalla.
 /// </summary>
 /// <param name="gameTime">Valor temporal interno.</param>
 public void Draw(GameTime gameTime)
 {
     Game.SpriteBatch.Begin();
     BtnBack.draw(Game);
     Game.SpriteBatch.DrawString(
         DefaultFont,
         RoomMessage,
         new Vector2(ScreenWidth / 2 - DefaultFont.MeasureString(RoomMessage).X / 2, ScreenHeight / 10),
         Color.Black
         );
     TxtInputRoom.draw(Game);
     Game.SpriteBatch.DrawString(
         DefaultFont,
         NameMessage,
         new Vector2(ScreenWidth / 2 - DefaultFont.MeasureString(NameMessage).X / 2, ScreenHeight / 2 - DefaultFont.MeasureString(NameMessage).Y),
         Color.Black
         );
     if (NameError)
     {
         Game.SpriteBatch.DrawString(ErrorFont, ErrorNameMsg, new Vector2(ScreenWidth / 2 - ErrorFont.MeasureString(ErrorNameMsg).X / 2, ScreenHeight * 15 / 20), Color.Red);
     }
     if (RoomError)
     {
         Game.SpriteBatch.DrawString(ErrorFont, ErrorRoomMsg, new Vector2(ScreenWidth / 2 - ErrorFont.MeasureString(ErrorRoomMsg).X / 2, ScreenHeight * 7 / 20), Color.Red);
     }
     TxtInputName.draw(Game);
     BtnStart.draw(Game);
     Game.SpriteBatch.End();
 }