Inheritance: Fleux.UIElements.UIElement
コード例 #1
0
ファイル: HomePage.cs プロジェクト: cail/hobd
        private PanoramaSection CreateFeaturedSection()
        {
            var img1 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png");
            var img2 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("squareimg.png");
            var img3 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail2.png");

            var titleStyle = new TextStyle(HOBD.theme.PhoneFontFamilySemiBold, HOBD.theme.PhoneFontSizeLarge, Color.White);
            var subtitleStyle = HOBD.theme.PhoneTextBlockBase;
            var moreStyle = new TextStyle(HOBD.theme.PhoneTextLargeStyle.FontFamily, HOBD.theme.PhoneFontSizeMediumLarge, HOBD.theme.PanoramaNormalBrush);

            var section = new PanoramaSection("small");

            var grid = new Grid
            {
                Columns = new MeasureDefinition[] { 120, 180 },
                Rows = new MeasureDefinition[] { 70, 50, 70, 50, 70, 50, 75 }
            };

            grid[0, 0] = new ImageElement(img1) { Size = new Size(100, 100) };
            grid[0, 1] = new DynamicElement("ONE") { Style = titleStyle };
            grid[1, 1] = new DynamicElement("LOREM IPSUM LOREM") { Style = subtitleStyle };

            grid[2, 0] = new ImageElement(img2) { Size = new Size(100, 100) };
            grid[2, 1] = new DynamicElement("TWO") { Style = titleStyle };
            grid[3, 1] = new DynamicElement("LOREM IPSUM LOREM") { Style = subtitleStyle };

            grid[4, 0] = new ImageElement(img3) { Size = new Size(100, 100) };
            grid[4, 1] = new DynamicElement("THREE") { Style = titleStyle };
            grid[5, 1] = new DynamicElement("LOREM IPSUM LOREM") { Style = subtitleStyle };

            grid[6, 1] = new TextElement("more") { Style = moreStyle };

            section.AddElement(grid);
            // , 0, 0, 300, 700

            return section;
        }
コード例 #2
0
ファイル: HomePage.cs プロジェクト: cail/hobd
        protected virtual void InitializePanorama()
        {
            panorama = new PanoramaElement();
            panorama.Sections.Location = new Point(0, 0);
            panorama.Sections.Size = new Size(layoutX, layoutY - SectionContentDelta);

            Fleux.Controls.Gestures.GestureDetectionParameters.Current.TapTimePeriod = 150;
            Fleux.Controls.Gestures.GestureDetectionParameters.Current.TapDistance = 50;

            /*
            panorama.SectionTitleDelta = 0;
            panorama.SectionContentDelta = 40;
            panorama.TitleWidth = 400;
            panorama.SectionsPadding = 30;

            panorama.DrawTitleAction = gr =>
               {   gr
                   .Style(HOBD.theme.PhoneTextPanoramaTitleStyle)
                   .MoveX(0).MoveY(0).DrawText(Title)
                   .Style(HOBD.theme.PhoneTextPanoramaSubTitleStyle)
                   .DrawText("v"+HOBDBuild.Version);
                   if (panorama.TitleWidth == 0)
                   {
                       panorama.TitleWidth = FleuxApplication.ScaleFromLogic(gr.Right);
                   }
               };
            */
            Bitmap original;
            if (HOBD.theme.Background != null){
                original = new Bitmap(Path.Combine( Path.GetDirectoryName(HOBD.theme.File), HOBD.theme.Background));
            }else{
                original = ResourceManager.Instance.GetBitmapFromEmbeddedResource(HomePage.DefaultBackground);
            }
            double scale = ((double)layoutY)/original.Height;
            var target = new Bitmap((int)(original.Width*scale), (int)(original.Height*scale));
            using (var gr = Graphics.FromImage(target))
            {
                gr.DrawImage(original,
                    new Rectangle(0, 0, target.Width, target.Height),
                    new Rectangle(0, 0, original.Width, original.Height),
                    GraphicsUnit.Pixel);
            }
            //var target = original;

            //            panorama.BackgroundImage = target;

            //            panorama.ClearSections();

            this.LoadSections();

            menuSection = this.CreateMenuSection();
            panorama.AddSection(menuSection);

            //panorama.AddSection(this.CreateFeaturedSection());
            //panorama.AddSection(this.CreateHorizontalFeaturedSection());

            panorama.OnSectionChange += this.SectionChanged;

            // activate first section
            this.SectionChanged(this.panorama, this.panorama.CurrentSection);

            statusField = new DynamicElement("///hobd") { Style = HOBD.theme.PhoneTextStatusStyle };
            statusField.Location = new Point(10, (layoutY-20));
            statusField.Size = new Size(layoutX, 20);
            panorama.AddElement(statusField);
            HOBD.engine.StateNotify += StateChanged;

            this.theForm.Text = HomePage.Title;
            this.theForm.Menu = null;

            var asm = Assembly.GetExecutingAssembly();
            var keyName = asm.GetManifestResourceNames().FirstOrDefault(p => p.EndsWith("hobd.ico"));
            this.theForm.Icon = new Icon(asm.GetManifestResourceStream(keyName));

            if (HOBD.config.Fullscreen){

                this.theForm.FormBorderStyle = FormBorderStyle.None;
                this.theForm.WindowState = FormWindowState.Maximized;
            }else{
                this.theForm.Width = layoutX.ToPixels();
                this.theForm.Height = layoutY.ToPixels()+30;
            }

            this.Control.AddElement(panorama);

            Logger.info("HomePage", "System DPI: " + this.theForm.CreateGraphics().DpiX);
            Logger.info("HomePage", "App DPI: " + FleuxApplication.TargetDesignDpi);

            Logger.info("HomePage", "system width: "+Screen.PrimaryScreen.Bounds.Width+", height: "+Screen.PrimaryScreen.Bounds.Height);
            Logger.info("HomePage", "form width: "+this.theForm.Width+", height: "+this.theForm.Height);

            HOBD.engine.Activate();
        }
コード例 #3
0
ファイル: HomePage.cs プロジェクト: cail/hobd
        protected virtual PanoramaSection CreateMenuSection()
        {
            var section = CreateCommonSection(t("Settings"));

            var style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);
            //style.FontSize = HOBD.theme.PhoneFontSizeLarge;

            var height0 = (layoutY - SectionContentDelta);
            var height = height0/6;

            menuGrid = new Grid
                           {
                               Columns = new MeasureDefinition[] { layoutX/3-20, layoutX/3-20, layoutX/3-20 },
                               Rows = new MeasureDefinition[] { height, height, height, height, height }
                           };

            menuGrid[0, 0] = new DynamicElement(t("Reset trips")) { Style = style, HandleTapAction = (e) => { HOBD.Registry.TriggerReset(); } };
            menuGrid[1, 0] = new DynamicElement(t("Minimize")) { Style = style, HandleTapAction = (e) => { /* TODO */ } };
            menuGrid[2, 0] = new DynamicElement(t("Exit")) {
                Style = style,
                HandleTapAction = (e) => Application.Exit()

            };

            menuGrid[0, 1] = new DynamicElement(t("Port settings")) {
                Style = style,
                HandleTapAction = (e) => CreatePortSection()
            };
            menuGrid[1, 1] = new DynamicElement(t("Vehicle")) {
                Style = style,
                HandleTapAction = (e) => CreateVehicleSection()
            };
            menuGrid[2, 1] = new DynamicElement(t("Theme")) {
                Style = style,
                HandleTapAction = (e) => CreateThemeSection()
            };
            menuGrid[3, 1] = new DynamicElement(t("Language")) {
                Style = style,
                HandleTapAction = (e) => CreateLanguageSection()
            };
            menuGrid[4, 1] = new DynamicElement(t("Display Units")) {
                Style = style,
                HandleTapAction = (e) => this.PushVolatileSection(
                    new ListSection(t("Display Units"), null, layoutX, layoutY-SectionContentDelta)
                    {
                        Selected = HOBD.config.Units,
                        Content  = new string[]{ "metric", "imperial" }.Select((s) => (object)s),
                        UIContent = (l) => t((string)l),
                        ChooseAction = (l) => {
                            panorama.CurrentSectionIndex -= 1;
                            HOBD.config.Units = (string)l;
                            HOBD.config.Save();
                            HOBD.ReloadUnits();
                            ReloadUI();
                        }
                    })
            };

            menuGrid[0, 2] = new DynamicElement(t("Sensor push")) {
                Style = style,
                HandleTapAction = (e) => CreateSensorPushSection()
            };

            section.AddElement(menuGrid);
            //, 10, 0, layoutX, height0

            var link = t("hobdrive.com");
            var info = new DynamicElement(link) {
                Style = new TextStyle(style){ FontSize = HOBD.theme.PhoneFontSizeNormal },
                HandleTapAction = (e) => {
                    try{
                        System.Diagnostics.Process.Start(link, "");
                    }catch(Exception){}
                }
            };

            section.AddElement(info);
            //, 10, height0 - 40, layoutX, 20

            return section;
        }
コード例 #4
0
ファイル: HomePage.cs プロジェクト: leewoody/hobd
        private PanoramaSection CreateFeaturedSection()
        {
            var img1 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png");
            var img2 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("squareimg.png");
            var img3 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail2.png");

            var titleStyle    = new TextStyle(HOBD.theme.PhoneFontFamilySemiBold, HOBD.theme.PhoneFontSizeLarge, Color.White);
            var subtitleStyle = HOBD.theme.PhoneTextBlockBase;
            var moreStyle     = new TextStyle(HOBD.theme.PhoneTextLargeStyle.FontFamily, HOBD.theme.PhoneFontSizeMediumLarge, HOBD.theme.PanoramaNormalBrush);

            var section = new PanoramaSection("small");

            var grid = new Grid
            {
                Columns = new MeasureDefinition[] { 120, 180 },
                Rows    = new MeasureDefinition[] { 70, 50, 70, 50, 70, 50, 75 }
            };

            grid[0, 0] = new ImageElement(img1)
            {
                Size = new Size(100, 100)
            };
            grid[0, 1] = new DynamicElement("ONE")
            {
                Style = titleStyle
            };
            grid[1, 1] = new DynamicElement("LOREM IPSUM LOREM")
            {
                Style = subtitleStyle
            };

            grid[2, 0] = new ImageElement(img2)
            {
                Size = new Size(100, 100)
            };
            grid[2, 1] = new DynamicElement("TWO")
            {
                Style = titleStyle
            };
            grid[3, 1] = new DynamicElement("LOREM IPSUM LOREM")
            {
                Style = subtitleStyle
            };

            grid[4, 0] = new ImageElement(img3)
            {
                Size = new Size(100, 100)
            };
            grid[4, 1] = new DynamicElement("THREE")
            {
                Style = titleStyle
            };
            grid[5, 1] = new DynamicElement("LOREM IPSUM LOREM")
            {
                Style = subtitleStyle
            };

            grid[6, 1] = new TextElement("more")
            {
                Style = moreStyle
            };

            section.AddElement(grid);
            // , 0, 0, 300, 700

            return(section);
        }
コード例 #5
0
ファイル: HomePage.cs プロジェクト: leewoody/hobd
        protected virtual void InitializePanorama()
        {
            panorama = new PanoramaElement();
            panorama.Sections.Location = new Point(0, 0);
            panorama.Sections.Size     = new Size(layoutX, layoutY - SectionContentDelta);

            Fleux.Controls.Gestures.GestureDetectionParameters.Current.TapTimePeriod = 150;
            Fleux.Controls.Gestures.GestureDetectionParameters.Current.TapDistance   = 50;

/*
 *          panorama.SectionTitleDelta = 0;
 *          panorama.SectionContentDelta = 40;
 *          panorama.TitleWidth = 400;
 *          panorama.SectionsPadding = 30;
 *
 *
 *          panorama.DrawTitleAction = gr =>
 *             {   gr
 *                 .Style(HOBD.theme.PhoneTextPanoramaTitleStyle)
 *                 .MoveX(0).MoveY(0).DrawText(Title)
 *                 .Style(HOBD.theme.PhoneTextPanoramaSubTitleStyle)
 *                 .DrawText("v"+HOBDBuild.Version);
 *                 if (panorama.TitleWidth == 0)
 *                 {
 *                     panorama.TitleWidth = FleuxApplication.ScaleFromLogic(gr.Right);
 *                 }
 *             };
 */
            Bitmap original;

            if (HOBD.theme.Background != null)
            {
                original = new Bitmap(Path.Combine(Path.GetDirectoryName(HOBD.theme.File), HOBD.theme.Background));
            }
            else
            {
                original = ResourceManager.Instance.GetBitmapFromEmbeddedResource(HomePage.DefaultBackground);
            }
            double scale  = ((double)layoutY) / original.Height;
            var    target = new Bitmap((int)(original.Width * scale), (int)(original.Height * scale));

            using (var gr = Graphics.FromImage(target))
            {
                gr.DrawImage(original,
                             new Rectangle(0, 0, target.Width, target.Height),
                             new Rectangle(0, 0, original.Width, original.Height),
                             GraphicsUnit.Pixel);
            }
            //var target = original;

//            panorama.BackgroundImage = target;

//            panorama.ClearSections();

            this.LoadSections();

            menuSection = this.CreateMenuSection();
            panorama.AddSection(menuSection);

            //panorama.AddSection(this.CreateFeaturedSection());
            //panorama.AddSection(this.CreateHorizontalFeaturedSection());

            panorama.OnSectionChange += this.SectionChanged;

            // activate first section
            this.SectionChanged(this.panorama, this.panorama.CurrentSection);

            statusField = new DynamicElement("///hobd")
            {
                Style = HOBD.theme.PhoneTextStatusStyle
            };
            statusField.Location = new Point(10, (layoutY - 20));
            statusField.Size     = new Size(layoutX, 20);
            panorama.AddElement(statusField);
            HOBD.engine.StateNotify += StateChanged;

            this.theForm.Text = HomePage.Title;
            this.theForm.Menu = null;

            var asm     = Assembly.GetExecutingAssembly();
            var keyName = asm.GetManifestResourceNames().FirstOrDefault(p => p.EndsWith("hobd.ico"));

            this.theForm.Icon = new Icon(asm.GetManifestResourceStream(keyName));

            if (HOBD.config.Fullscreen)
            {
                this.theForm.FormBorderStyle = FormBorderStyle.None;
                this.theForm.WindowState     = FormWindowState.Maximized;
            }
            else
            {
                this.theForm.Width  = layoutX.ToPixels();
                this.theForm.Height = layoutY.ToPixels() + 30;
            }

            this.Control.AddElement(panorama);

            Logger.info("HomePage", "System DPI: " + this.theForm.CreateGraphics().DpiX);
            Logger.info("HomePage", "App DPI: " + FleuxApplication.TargetDesignDpi);


            Logger.info("HomePage", "system width: " + Screen.PrimaryScreen.Bounds.Width + ", height: " + Screen.PrimaryScreen.Bounds.Height);
            Logger.info("HomePage", "form width: " + this.theForm.Width + ", height: " + this.theForm.Height);

            HOBD.engine.Activate();
        }
コード例 #6
0
ファイル: HomePage.cs プロジェクト: leewoody/hobd
        protected virtual PanoramaSection CreateMenuSection()
        {
            var section = CreateCommonSection(t("Settings"));

            var style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);
            //style.FontSize = HOBD.theme.PhoneFontSizeLarge;

            var height0 = (layoutY - SectionContentDelta);
            var height  = height0 / 6;

            menuGrid = new Grid
            {
                Columns = new MeasureDefinition[] { layoutX / 3 - 20, layoutX / 3 - 20, layoutX / 3 - 20 },
                Rows    = new MeasureDefinition[] { height, height, height, height, height }
            };

            menuGrid[0, 0] = new DynamicElement(t("Reset trips"))
            {
                Style = style, HandleTapAction = (e) => { HOBD.Registry.TriggerReset(); }
            };
            menuGrid[1, 0] = new DynamicElement(t("Minimize"))
            {
                Style = style, HandleTapAction = (e) => { /* TODO */ }
            };
            menuGrid[2, 0] = new DynamicElement(t("Exit"))
            {
                Style           = style,
                HandleTapAction = (e) => Application.Exit()
            };

            menuGrid[0, 1] = new DynamicElement(t("Port settings"))
            {
                Style           = style,
                HandleTapAction = (e) => CreatePortSection()
            };
            menuGrid[1, 1] = new DynamicElement(t("Vehicle"))
            {
                Style           = style,
                HandleTapAction = (e) => CreateVehicleSection()
            };
            menuGrid[2, 1] = new DynamicElement(t("Theme"))
            {
                Style           = style,
                HandleTapAction = (e) => CreateThemeSection()
            };
            menuGrid[3, 1] = new DynamicElement(t("Language"))
            {
                Style           = style,
                HandleTapAction = (e) => CreateLanguageSection()
            };
            menuGrid[4, 1] = new DynamicElement(t("Display Units"))
            {
                Style           = style,
                HandleTapAction = (e) => this.PushVolatileSection(
                    new ListSection(t("Display Units"), null, layoutX, layoutY - SectionContentDelta)
                {
                    Selected     = HOBD.config.Units,
                    Content      = new string[] { "metric", "imperial" }.Select((s) => (object)s),
                    UIContent    = (l) => t((string)l),
                    ChooseAction = (l) => {
                        panorama.CurrentSectionIndex -= 1;
                        HOBD.config.Units             = (string)l;
                        HOBD.config.Save();
                        HOBD.ReloadUnits();
                        ReloadUI();
                    }
                })
            };


            menuGrid[0, 2] = new DynamicElement(t("Sensor push"))
            {
                Style           = style,
                HandleTapAction = (e) => CreateSensorPushSection()
            };

            section.AddElement(menuGrid);
            //, 10, 0, layoutX, height0

            var link = t("hobdrive.com");
            var info = new DynamicElement(link)
            {
                Style = new TextStyle(style)
                {
                    FontSize = HOBD.theme.PhoneFontSizeNormal
                },
                HandleTapAction = (e) => {
                    try{
                        System.Diagnostics.Process.Start(link, "");
                    }catch (Exception) {}
                }
            };

            section.AddElement(info);
            //, 10, height0 - 40, layoutX, 20

            return(section);
        }