Exemple #1
0
        private PanoramaSection CreateHorizontalImagesSection()
        {
            var img1 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png");
            var img2 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("squareimg.png");
            var img3 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail2.png");
            var img4 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail3.png");

            var section = new PanoramaSection("images");

            section.Body.AddElement(this.CreateIcon(img1, 0, 0,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("one", "FLEUX SAMPLE", img1))));
            section.Body.AddElement(this.CreateIcon(img2, 200, 0,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("two", "FLEUX SAMPLE", img2))));
            section.Body.AddElement(this.CreateIcon(img3, 400, 0,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("three", "FLEUX SAMPLE", img3))));
            section.Body.AddElement(this.CreateIcon(img4, 600, 0,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("four", "FLEUX SAMPLE", img4))));
            section.Body.AddElement(this.CreateIcon(img4, 0, 160,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("four", "FLEUX SAMPLE", img4))));
            section.Body.AddElement(this.CreateIcon(img3, 200, 160,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("three", "FLEUX SAMPLE", img3))));
            section.Body.AddElement(this.CreateIcon(img1, 400, 160,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("one", "FLEUX SAMPLE", img1))));
            section.Body.AddElement(this.CreateIcon(img2, 600, 160,
                                                    p => this.NavigateToHandler(new ImageDetailsPage("two", "FLEUX SAMPLE", img2))));

            return(section);
        }
Exemple #2
0
        protected virtual void SectionChanged(PanoramaElement panorama, PanoramaSection section)
        {
            if (section == menuSection)
            {
                if (volatileSection != null)
                {
                    panorama.RemoveSection(volatileSection);
                    volatileSection = null;
                }
                return;
            }
            List <SensorListener> sensors = null;

            sectionSensorMap.TryGetValue(section, out sensors);

            // remove from all sensors
            HOBD.Registry.RemoveListener(this.SensorChanged);

            if (sensors != null)
            {
                foreach (SensorListener sl in sensors)
                {
                    HOBD.Registry.AddListener(sl.sensor, this.SensorChanged, sl.period);
                }
            }
        }
Exemple #3
0
        private PanoramaSection CreateImagesSection()
        {
            var img1 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png");
            var img2 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("squareimg.png");
            var img3 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail2.png");

            var section = new PanoramaSection("small");

            section.Body.AddElement(new ListElement
            {
                DataTemplateSelector = item => i => (UIElement)i, // Our sample list items are all UIElements
                SourceItems          = new BindingList <object>
                {
                    this.CreatePictureItem(img1, "ONE", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img2, "TWO", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img3, "THREE", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img1, "FOUR", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img1, "ONE", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img2, "TWO", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img3, "THREE", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img1, "FOUR", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img1, "ONE", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img2, "TWO", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img3, "THREE", "LOREM IPSUM LOREM"),
                    this.CreatePictureItem(img1, "FOUR", "LOREM IPSUM LOREM"),
                },
                Size           = new Size(380, 466),
                ShowScrollbars = false
            });

            return(section);
        }
Exemple #4
0
 protected virtual void PushVolatileSection(PanoramaSection section)
 {
     if (this.volatileSection == null)
     {
         panorama.AddSection(section);
         this.volatileSection          = section;
         panorama.CurrentSectionIndex += 1;
     }
 }
Exemple #5
0
        protected virtual UIElement CreateItem(Dictionary <string, string> attrs, PanoramaSection section)
        {
            string id = "";

            try{
                if (!attrs.TryGetValue("id", out id))
                {
                    return(null);
                }

                var sensor = HOBD.Registry.Sensor(id);
                if (sensor != null)
                {
                    var sensorItem = new SensorTextElement(sensor, attrs);
                    sensorItem.HandleTapAction = () => { sensorItem.Text = HOBD.t("sdesc." + sensor.Name); Redraw(); };

                    List <SensorTextElement> ui_list = null;
                    sensorUIMap.TryGetValue(sensor, out ui_list);
                    if (ui_list == null)
                    {
                        ui_list = new List <SensorTextElement>();
                        sensorUIMap.Add(sensor, ui_list);
                    }
                    ui_list.Add(sensorItem);

                    List <SensorListener> sensor_list = null;
                    sectionSensorMap.TryGetValue(section, out sensor_list);
                    if (sensor_list == null)
                    {
                        sensor_list = new List <SensorListener>();
                        sectionSensorMap.Add(section, sensor_list);
                    }

                    SensorListener sl = new SensorListener();
                    sl.sensor = sensor;
                    sl.period = 0;
                    string period = null;
                    if (attrs.TryGetValue("period", out period))
                    {
                        sl.period = int.Parse(period);
                    }

                    sensor_list.Add(sl);

                    return(sensorItem);
                }
            }catch (Exception e)
            {
                Logger.error("CreateItem", "Failed creating Sensor Element: " + id, e);
            }
            return(new DynamicElement("n/a: " + id)
            {
                Style = HOBD.theme.PhoneTextSmallStyle
            });
        }
Exemple #6
0
        private PanoramaSection CreateHorizontalFeaturedSection()
        {
            var img1      = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png");
            var img2      = ResourceManager.Instance.GetBitmapFromEmbeddedResource("squareimg.png");
            var img3      = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail2.png");
            var img4      = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail3.png");
            var imageSize = new Size(190, 150);

            var grid = new Grid
            {
                Columns = new MeasureDefinition[] { 200, 200, 200, 200 },
                Rows    = new MeasureDefinition[] { 160, 160 }
            };

            grid[0, 0] = new ImageElement(img1)
            {
                Size = imageSize
            };
            grid[0, 1] = new ImageElement(img2)
            {
                Size = imageSize
            };
            grid[0, 2] = new ImageElement(img3)
            {
                Size = imageSize
            };
            grid[0, 3] = new ImageElement(img4)
            {
                Size = imageSize
            };
            grid[1, 0] = new ImageElement(img3)
            {
                Size = imageSize
            };
            grid[1, 1] = new ImageElement(img4)
            {
                Size = imageSize
            };
            grid[1, 2] = new ImageElement(img1)
            {
                Size = imageSize
            };
            grid[1, 3] = new ImageElement(img2)
            {
                Size = imageSize
            };

            var section = new PanoramaSection("features");

            section.AddElement(grid);
            //, 0, 0, 480, 320
            return(section);
        }
Exemple #7
0
        protected virtual PanoramaSection CreateCommonSection(string title)
        {
            var s = new PanoramaSection(title)
            {
                Location = new Point(0, 0), Size = new Size(layoutX, layoutY)
            };

            s.Body.Location = new Point(0, this.SectionContentDelta);
            s.Body.Size     = new Size(layoutX, layoutY - this.SectionContentDelta);

            //dg => dg.Style(HOBD.theme.PhoneTextPanoramaSectionTitleStyle).DrawText(
            return(s);
        }
Exemple #8
0
        protected virtual void CreatePortSection()
        {
            var section = new ConfigurationSection(layoutX, layoutY - SectionContentDelta)
            {
                ChoosePortAction = () => {
                    panorama.CurrentSectionIndex -= 1;
                    HOBD.config.Save();
                    HOBD.EngineConnect();
                    HOBD.engine.Activate();
                }
            };

            panorama.AddSection(section);
            this.volatileSection          = section;
            panorama.CurrentSectionIndex += 1;
        }
Exemple #9
0
        private PanoramaSection CreateMenuSection()
        {
            var style = new TextStyle(MetroTheme.PhoneTextLargeStyle.FontFamily,
                                      MetroTheme.PhoneFontSizeMediumLarge,
                                      MetroTheme.PanoramaNormalBrush);

            var section = new PanoramaSection("welcome");

            section.Body.AddElement(this.CreateMenuSectionElement(0, "gestures", p => this.NavigateToHandler(new GesturesTestPage())));
            section.Body.AddElement(this.CreateMenuSectionElement(80, "list page", p => this.NavigateToHandler(new ListPage())));
            section.Body.AddElement(this.CreateMenuSectionElement(160, "pivot", p => this.NavigateToHandler(new PivotPage())));
            section.Body.AddElement(this.CreateMenuSectionElement(240, "text samples", p => this.NavigateToHandler(new TextPage())));

            section.Body.AddElement(new TextElement("more is coming...")
            {
                Style    = MetroTheme.PhoneTextNormalStyle,
                Location = new Point(20, 320),
                Size     = new Size(300, 80)
            });

            return(section);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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();
        }