public static bool LoadFromFile(this EImage image, string file)
 {
     if (!string.IsNullOrEmpty(file))
     {
         return(image.Load(ResourcePath.GetPath(file)));
     }
     return(false);
 }
        public static async Task <bool> LoadFromImageSourceAsync(this EImage image, ImageSource source)
        {
            IImageSourceHandler handler;
            bool isLoadComplate = false;

            if (source != null && (handler = Forms.GetHandlerForObject <IImageSourceHandler>(source)) != null)
            {
                isLoadComplate = await handler.LoadImageAsync(image, source);
            }
            if (!isLoadComplate)
            {
                //If it fails, call the Load function to remove the previous image.
                image.Load(string.Empty);
            }

            return(isLoadComplate);
        }
Exemple #3
0
        protected virtual FormsMoreOptionItem CreateMoreOptionItem(ToolbarItem item)
        {
            var moreOptionItem = new FormsMoreOptionItem
            {
                MainText    = item.Text,
                ToolbarItem = item
            };
            var icon = item.IconImageSource as FileImageSource;

            if (icon != null)
            {
                var img = new ElmSharp.Image(_moreOption.Value);
                img.Load(ResourcePath.GetPath(icon));
                moreOptionItem.Icon = img;
            }
            return(moreOptionItem);
        }
Exemple #4
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && viewReady && !isDrawn)
            {
                Control.RemoveAll();

                var scale        = ElmSharp.Elementary.GetScale();
                int windowWidth  = (int)Math.Round(OverlayWidth * scale);
                int windowHeight = (int)Math.Round(OverlayHeight * scale);

                foreach (var pin in customPins)
                {
                    var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);

                    Control.Add(new TPin(coordinates, PinPath));

                    int width  = windowWidth;
                    int height = windowHeight;

                    var window = new ElmSharp.Box(Control);
                    window.Show();

                    {
                        var overlay = new ElmSharp.Box(window)
                        {
                            BackgroundColor = XamarinLogoColor,
                        };
                        overlay.SetAlignment(-1.0, -1.0);                     // fill
                        overlay.SetWeight(1.0, 0.0);                          // expand on X axis
                        overlay.Show();
                        window.PackEnd(overlay);

                        if (pin.Id == XamarinId)
                        {
                            var xamarin = new ElmSharp.Image(overlay);
                            xamarin.Load(XamarinPath);
                            xamarin.SetAlignment(-1.0, -1.0);                              // fill
                            var size = xamarin.ObjectSize;
                            xamarin.MinimumWidth  = size.Width;
                            xamarin.MinimumHeight = size.Height;
                            xamarin.Show();
                            overlay.PackEnd(xamarin);

                            height += size.Height;
                        }

                        {
                            var infoBox = new ElmSharp.Box(overlay)
                            {
                                IsHorizontal = true,
                            };
                            infoBox.SetAlignment(-1.0, -1.0);                         // fill
                            infoBox.SetWeight(1.0, 0.0);                              // expand on X axis
                            infoBox.Show();
                            overlay.PackEnd(infoBox);

                            {
                                var monkey = new ElmSharp.Image(infoBox);
                                monkey.Load(MonkeyPath);
                                monkey.SetAlignment(-1.0, -1.0);                             // fill
                                monkey.SetWeight(1.0, 0.0);                                  // expand on X axis
                                monkey.Show();
                                infoBox.PackEnd(monkey);
                            }

                            {
                                var textBox = new ElmSharp.Box(infoBox);
                                textBox.SetAlignment(-1.0, -1.0);                             // fill
                                textBox.SetWeight(1.0, 0.0);                                  // expand on X axis
                                textBox.Show();
                                infoBox.PackEnd(textBox);

                                {
                                    var title = new NLabel(textBox)
                                    {
                                        Text           = pin.Label,
                                        FontAttributes = FontAttributes.Bold,
                                        TextColor      = ElmSharp.Color.White,
                                    };
                                    title.SetAlignment(-1.0, -1.0);                                 // fill
                                    title.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    title.Show();
                                    textBox.PackEnd(title);
                                }

                                {
                                    var subtitle = new NLabel(textBox)
                                    {
                                        Text      = pin.Address,
                                        TextColor = ElmSharp.Color.White,
                                    };
                                    subtitle.SetAlignment(-1.0, -1.0);                                 // fill
                                    subtitle.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    subtitle.Show();
                                    textBox.PackEnd(subtitle);
                                }
                            }

                            {
                                var info = new ElmSharp.Image(infoBox);
                                info.Load(InfoPath);
                                info.SetAlignment(-1.0, -1.0);                             // fill
                                info.SetWeight(1.0, 0.0);                                  // expand on X axis
                                info.Show();
                                infoBox.PackEnd(info);
                            }
                        }
                    }

                    {
                        var expander = new ElmSharp.Box(window);
                        expander.SetAlignment(-1.0, -1.0);                     // fill
                        expander.SetWeight(1.0, 1.0);                          // expand
                        expander.Show();
                        window.PackEnd(expander);
                    }

                    window.Resize(width, height);

                    Control.Add(new Overlay(coordinates, window));
                }

                isDrawn = true;
            }
        }
Exemple #5
0
        protected override ElmSharp.EvasObject OnGetContent(Cell cell, string part)
        {
            if (part != MainContentPart)
            {
                return(null);
            }
            NativeCell viewCell      = (NativeCell)cell;
            var        minimumHeight = PageHeight > 800 ? 96 : 76;

            ElmSharp.Box mainBox = new ElmSharp.Box(Forms.NativeParent);
            mainBox.BackgroundColor = Color.LightYellow.ToNative();
            mainBox.MinimumHeight   = minimumHeight;
            mainBox.IsHorizontal    = false;
            mainBox.SetAlignment(-1, -1);
            mainBox.Show();

            ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent);
            contentBox.MinimumHeight = minimumHeight;
            contentBox.IsHorizontal  = true;
            contentBox.SetAlignment(-1, -1);
            contentBox.Show();

            ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent);
            left.IsHorizontal = false;
            left.Show();
            left.SetWeight(4.0, 1);
            left.SetAlignment(-1, -1);
            contentBox.PackEnd(left);

            ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent);
            left.PackEnd(titleName);
            titleName.Show();
            titleName.Text         = $"<span font_size=34 font_style=italic color=#7F3300>   {viewCell.Name}</span>";
            titleName.MinimumWidth = 250;
            titleName.SetAlignment(-1, -1);

            ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent);
            left.PackEnd(titleCategory);
            titleCategory.Show();
            titleCategory.Text = $"<span align=center font_size=24 color=#008000>{viewCell.Category}</span>";
            titleCategory.SetAlignment(-1, -1);

            ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent);
            right.Show();
            right.MinimumWidth  = 96;
            right.MinimumHeight = minimumHeight;
            right.SetWeight(1, 1);
            right.SetAlignment(-1, 0);

            ElmSharp.Image image;

            if (viewCell.ImageFilename != "")
            {
                image = new ElmSharp.Image(right);
                image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + viewCell.ImageFilename + ".jpg");
                image.SetAlignment(0.5, 0.5);
                image.MinimumHeight = minimumHeight;
                image.MinimumWidth  = minimumHeight;
                image.Show();
                right.PackEnd(image);
            }

            ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left);
            rec.MinimumHeight = 1;
            rec.MinimumWidth  = 400;
            rec.AlignmentX    = -1;
            rec.Color         = ElmSharp.Color.Gray;
            rec.Show();

            contentBox.PackEnd(right);

            mainBox.PackEnd(contentBox);
            mainBox.PackEnd(rec);

            return(mainBox);
        }