Exemplo n.º 1
0
 protected override UIElement BuildCustomItem(object arg, bool forList)
 {
     var canvas = new Canvas() { Size = new Size(Size.Width - 10, PopupItemHeight), };
     canvas.AddElement(
         new TextElement(((ColorItem)arg).Caption)
         {
             Style = ((forList) && ((ColorItem)arg == Items[SelectedIndex])) ?
                 new TextStyle(
                     MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontSizeNormal,
                     MetroTheme.PhoneAccentBrush) :
                 new TextStyle(
                     MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontSizeNormal,
                     MetroTheme.PhoneTextBoxFontBrush),
             Size = new Size(Size.Width - Padding - PopupItemHeight, PopupItemHeight),
             Location = new Point(55, 0),
         }
     );
     canvas.AddElement(
         new DelegateUIElement()
         {
             DrawingAction = graphics => DrawColor(graphics, arg),
             Size = new Size(PopupItemHeight, PopupItemHeight),
             Location = new Point(0, 0),
         }
         );
     return canvas;
 }
Exemplo n.º 2
0
        public ImageSettingsControl()
        {
            _lblCaption = new TextElement("<image parameter>")
                {
                    Size = new Size(SettingsConsts.MaxWidth, 50),
                };
            AddElement(_lblCaption);

            _pictureBox = new SettingsImageElement(new Bitmap(1, 1))
                {
                  Size = new Size(SettingsConsts.MaxWidth, 175),
                };
            AddElement(_pictureBox);

            AddElement(new Canvas { Size = new Size(SettingsConsts.MaxWidth, 10), });

            var buttonPanel = new Canvas { Size = new Size(SettingsConsts.MaxWidth, 50), };
            AddElement(buttonPanel);

            var buttonSelectImage = new Fleux.UIElements.Button("select".Localize())
                {
                    Size = new Size(SettingsConsts.MaxWidth / 2 - 10, 50),
                    Location = new Point(0, 0),
                    TapHandler = p => ButtonSelectBgClick(),
                };
            buttonPanel.AddElement(buttonSelectImage);

            var buttonClearImage = new Fleux.UIElements.Button("clear".Localize())
               {
                   Size = new Size(SettingsConsts.MaxWidth / 2 - 10, 50),
                   Location = new Point(SettingsConsts.MaxWidth / 2 + 10, 0),
                   TapHandler = p => { Value = ""; return true; },
               };
            buttonPanel.AddElement(buttonClearImage);
        }
Exemplo n.º 3
0
        internal static UIElement BuildItem(object textSource)
        {
            if (textSource is UIElement)
            {
                return textSource as UIElement;
            }
            else
            {
                var text = (string)textSource;

                var icon = ResourceManager.Instance.GetBitmapFromEmbeddedResource("item.icon.png", System.Reflection.Assembly.GetExecutingAssembly());
                var canvas = new Canvas() { Size = new Size(480, 90) };
                canvas.AddElement(new TextElement(text) { Style = MetroTheme.PhoneTextNormalStyle, Location = new Point(120, 0), Size = new Size(400, 50) });
                canvas.AddElement(new ImageElement(icon) { Location = new Point(40, 0), Size = new Size(60, 60) });
                var myStyle = MetroTheme.PhoneTextSmallStyle;
                myStyle.Foreground = MetroTheme.PhoneAccentBrush;
                canvas.AddElement(new TextElement("This is just a sample text!") { Style = myStyle, Location = new Point(120, 40), Size = new Size(400, 50) });
                return canvas;
            }
        }
Exemplo n.º 4
0
        public FileSettingsControl(FleuxControlPage settingsPage)
        {
            _lblCaption = new TextElement("<file selection>")
            {
                Size = new Size(SettingsConsts.MaxWidth, 50),
            };
            AddElement(_lblCaption);

            _inputBox = new TextBox(settingsPage)
            {
                Size = new Size(SettingsConsts.MaxWidth, 150),
                MultiLine = true,
            };
            _inputBox.TextChanged += (s, e) => NotifyPropertyChanged("Value");
            AddElement(_inputBox);

            AddElement(new Canvas() { Size = new Size(SettingsConsts.MaxWidth, 10), } );

            var buttonPanel = new Canvas() { Size = new Size(SettingsConsts.MaxWidth, 50), };
            AddElement(buttonPanel);

            var buttonSelectImage = new Fleux.UIElements.Button("select".Localize())
            {
                Size = new Size(SettingsConsts.MaxWidth / 2 - 10, 50),
                Location = new Point(0, 0),
                TapHandler = p => { BrowseFile(); return true; },
            };
            buttonPanel.AddElement(buttonSelectImage);

            var buttonClearImage = new Fleux.UIElements.Button("clear".Localize())
            {
                Size = new Size(SettingsConsts.MaxWidth / 2 - 10, 50),
                Location = new Point(SettingsConsts.MaxWidth / 2 + 10, 0),
                TapHandler = p => { Value = ""; return true; },
            };
            buttonPanel.AddElement(buttonClearImage);
        }
        public ContactSettingsControl()
        {
            _lblCaption = new TextElement("<contact selection>")
            {
                Size = new Size(SettingsConsts.MaxWidth, 50),
            };
            AddElement(_lblCaption);

            _labelContactName = new TextElement(ContactNotSelected)
            {
                Size = new Size(SettingsConsts.MaxWidth, 50),
                Style = MetroTheme.PhoneTextAccentStyle,
            };
            AddElement(_labelContactName);

            AddElement(new Canvas { Size = new Size(SettingsConsts.MaxWidth, 10), } );

            var buttonPanel = new Canvas { Size = new Size(SettingsConsts.MaxWidth, 50), };
            AddElement(buttonPanel);

            var buttonSelectImage = new Fleux.UIElements.Button("select")
            {
                Size = new Size(SettingsConsts.MaxWidth / 2 - 10, 50),
                Location = new Point(0, 0),
                TapHandler = p => { BrowseContact(); return true; },
            };
            buttonPanel.AddElement(buttonSelectImage);

            var buttonClearImage = new Fleux.UIElements.Button("clear")
            {
                Size = new Size(SettingsConsts.MaxWidth / 2 - 10, 50),
                Location = new Point(SettingsConsts.MaxWidth / 2 + 10, 0),
                TapHandler = p => { Value = -1; return true; },
            };
            buttonPanel.AddElement(buttonClearImage);
        }
Exemplo n.º 6
0
        public HubPage(string folderGuid)
            : base(false)
        {
            _folderGuid = folderGuid;

            ScreenRoutines.CursorWait();
            try
            {
                theForm.Menu = null;

                Control.ShadowedAnimationMode = FleuxControl.ShadowedAnimationOptions.FromRight;

                _background = new ScaledBackground("") { Size = this.Size.ToPixels() };
                Control.AddElement(_background);

                Content = new Canvas
                {
                    Size = new Size(this.Size.Width, this.Size.Height),
                    Location = new Point(0, 0)
                };
                Control.AddElement(Content);

                _appBar = new ApplicationBar
                {
                    Size = new Size(Content.Size.Width, AppBarHeight),
                    Location = new Point(0, Content.Size.Height - AppBarHeight)
                };
                _appBar.ButtonTap += OnAppBarButtonTap;
                _appBar.AddButton(ResourceManager.Instance.GetBitmapFromEmbeddedResource(
                    (MetroTheme.PhoneBackgroundBrush == Color.White) ?
                        "FolderWidget.Images.back-light.bmp" : "FolderWidget.Images.back-dark.bmp"
                    ));
                Content.AddElement(_appBar.AnimateHorizontalEntrance(false));

                _title = new TextElement("Folder hub")
                {
                    Style = MetroTheme.PhoneTextTitle1Style,
                    Location = new Point(24 - 3, 5), // -3 is a correction for Segoe fonts
                    AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight,
                };
                _title.ResizeForWidth(Content.Size.Width);
                Content.AddElement(_title);

                _tileGrid = new HubPageTileGrid(new TileThemeWP7() { TilesPaddingTop = 0 },
                    _background, "", 4, 100)
                                {
                                    OnReadSettings = ReadSettings,
                                    OnWriteSettings = WriteSettings,
                                    OnShowMainSettings = ShowHubSettings,
                                };
                SetTilesLocation(_title.Bounds.Bottom + 50);
                Content.AddElement(_tileGrid);

                ReadSettings();

            }
            finally
            {
                ScreenRoutines.CursorNormal();
            }
        }
Exemplo n.º 7
0
        public HomeScreen()
            : base(true)
        {
            this.Control.EntranceDuration = 500;
            homeScreenCanvas = new Canvas { Size = new Size(960, 740) };
            var canvas = new Canvas() { Size = new Size(400, 1203) };

            tiles.Add(this.CreateTile("Phone", 28, 93));
            tiles.Add(this.SetEntranceAnimationFromLeft(new PeopleTile(213, 93)));
            tiles.Add(this.CreateTile("Messaging", 28, 278));
            tiles.Add(this.CreateTile("Email", 213, 278));
            tiles.Add(this.CreateTile("Internet", 28, 463));
            tiles.Add(this.CreateTile("Games", 213, 463));
            tiles.Add(this.CreateTile("Calendar", 28, 648, true));
            tiles.Add(this.CreateTile("Pictures", 28, 833, true));
            tiles.Add(this.CreateTile("Zune", 28, 1018));
            tiles.Add(this.CreateTile("Marketplace", 213, 1018));

            tiles.ForEach(el => { canvas.AddElement(el); this.SetExitAnimationToLeft(el, this.ShowGames); });

            var sv = new ScrollViewer
            {
                Content = canvas,
                Size = new Size(400, this.Size.Height - 62),
                Location = new Point(0, 0),
                VerticalScroll = true,
            };

            this.homeScreenCanvas.AddElement(sv);

            this.Control.AddElement(new SoftKeys()
            {
                Size = new Size(480, 60),
                Location = new Point(0, this.Size.Height - 60)
            });

            this.switchArrow = new Arrow()
            {
                Location = new Point(400, 93),
                TapHandler = this.TapOnArrow,
            };
            this.homeScreenCanvas.AddElement(this.switchArrow);

            this.homeScreenCanvas.PanHandler = this.Pan;
            this.homeScreenCanvas.FlickHandler = this.Flick;

            var programsSv = new ScrollViewer { Size = new Size(315, this.Size.Height - 62), Location = new Point(574, 0), VerticalScroll = true };
            programsSv.Content = new ImageElement(ResourceManager.Instance.GetBitmapFromEmbeddedResource("Programs.png"))
            {
                Size = new Size(315, 893),
                EntranceAnimation = new NullAnimation(),
                ExitAnimation = new NullAnimation()
            };

            this.homeScreenCanvas.AddElement(programsSv);

            this.Control.AddElement(this.homeScreenCanvas);
            this.Control.AddElement(new Clock() { Location = new Point(425, 0) });

            this.homeScreenCanvas.TapHandler = p => { this.ReShow(); return true; };
        }
Exemplo n.º 8
0
 private static Canvas CreateSampleImageItem()
 {
     var sampleImageElement = new Canvas { Size = new Size(480, 200) };
     sampleImageElement.AddElement(new ImageElement(ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png")) { Location = new Point(120, 0), Size = new Size(200, 150) });
     return sampleImageElement;
 }
Exemplo n.º 9
0
        public HomeScreen()
            : base(false)
        {
            theForm.ControlBox = false;
            theForm.Menu = null;
            theForm.Text = "";

            Control.EntranceDuration = 100;

            ReadThemeSettings();

            var mainSettings = TinyIoCContainer.Current.Resolve<MainSettings>();
            _tileTheme = mainSettings.GetTileTheme();
            if (mainSettings.FullScreen)
                SwitchFullScreen(true); //!! do not decrease counter when start in normal mode

            // фон окна
            var background = new ThemedBackground { Location = new Point(0, 0), };
            Control.AddElement(background);
            TinyIoCContainer.Current.Register<ScaledBackground>(background);

            // загрузчик плагинов
            TinyIoCContainer.Current.Register<IPluginManager>(new PluginManager());

            // холст главной страницы
            _homeScreenCanvas = new Canvas
                                    {
                                        Size = this.Size,
                                        Location = new Point(0, 0),
                                    };

            // экран блокировки
            var lockScreen = new LockScreenManager();
            AddSection(lockScreen, 0);

            // прокрутчик холста плиток
            var tilesGrid = new TilesGrid.TilesGrid(_tileTheme)
                                {
                                    OnExit = ExitApp,
                                    OnShowMainSettings = ShowMainSettings,
                                };
            AddSection(tilesGrid, 1);

            // стрелка переключатель страниц
            _switchArrowNext = new ThemedImageButton("next")
            {
                Location = new Point(ArrowPosNext, _tileTheme.ArrowPosY),
                TapHandler = p => { CurrentSection = 2; return true; },
            };
            _homeScreenCanvas.AddElement(_switchArrowNext);

            _switchArrowBack = new ThemedImageButton("back")
            {
                Location = new Point(ArrowPosBack, _tileTheme.ArrowPosY),
                TapHandler = p => { CurrentSection = 1; return true; },
            };
            _homeScreenCanvas.AddElement(_switchArrowBack);

            // список программ
            var programsSv = new ProgramsMenuPage();
            AddSection(programsSv, 2);

            Control.AddElement(_homeScreenCanvas);

            _homeScreenCanvas.FlickHandler = Flick;

            _systemState.Changed += OnSystemStateChanged;
            TheForm.Deactivate += (s, e) => OnDeactivate();

            // deactivate all other pages but first
            CurrentSection = 1;

            // subscribe to events - show page and change main settings
            var messenger = TinyIoCContainer.Current.Resolve<ITinyMessengerHub>();
            messenger.Subscribe<ShowPageMessage>(msg => OnShowPage(msg.Page));
            messenger.Subscribe<SettingsChangedMessage>(OnSettingsChanged);
            messenger.Subscribe<FullScreenMessage>(OnFullScreen);
        }
Exemplo n.º 10
0
        private UIElement BuildItem(object aFileDescr)
        {
            var fileDescr = (FileDescr)aFileDescr;

            // special processing for first empty item
            if (fileDescr.Name == null)
            {
                return new Canvas { Size = new Size(ScreenConsts.ScreenWidth, 50), };
            }

            var canvas = new Canvas
            {
                Size = new Size(ScreenConsts.ScreenWidth, IconSize + BlankSize * 2 + BorderSize * 2)
            };

            // draw solid bacground for icon
            // direct draw to graphisc.image, so use scale from logic to pixels
            var image = new Bitmap(_rect.Width.ToPixels(), _rect.Height.ToPixels(), PixelFormat.Format16bppRgb565);
            var graphics = Graphics.FromImage(image);
            graphics.FillRectangle(_bgBrush, _rect.ToPixels());

            // draw icon
            // direct draw to graphisc.image, so use scale from logic to pixels
            try
            {
                FileRoutines.SHGetFileInfo(ref fileDescr.Path, 0, ref _refa, Marshal.SizeOf(_refa), 0x100);
                var icon = Icon.FromHandle(_refa.a);
                graphics.DrawIcon(icon, BorderSize.ToPixels(), BorderSize.ToPixels());
            }
            catch (Exception) { }

            canvas.AddElement(new ImageElement(image)
                                  {
                                      Size = _rect.Size,
                                      Location = new Point(0, BlankSize),
                                  });

            // draw program name
            const int textHeight = 15;
            canvas.AddElement(new TextElement(fileDescr.Name)
            {
                AutoSizeMode = TextElement.AutoSizeModeOptions.None,
                Style = new TextStyle(MetroTheme.PhoneFontFamilyNormal, 11, MetroTheme.PhoneForegroundBrush),
                Size = new Size(ScreenConsts.ScreenWidth - _rect.Width + PaddingHor, _rect.Height - textHeight),
                Location = new Point(_rect.Width + PaddingHor, textHeight),
            });

            // click handler = launch program
            canvas.TapHandler = point =>
                                    {
                                        FileRoutines.StartProcess(fileDescr.Path); return true;
                                    };

            // hold handler - show context menu
            canvas.HoldHandler = point =>
                                     {
                                         ShowPopupMenu(new Point(
                                             point.X + canvas.Bounds.Left + canvas.Parent.Bounds.Left,
                                             point.Y + canvas.Bounds.Top + canvas.Parent.Bounds.Top), fileDescr);
                                         return true;
                                     };

            return canvas;
        }
Exemplo n.º 11
0
        private void CreateControls()
        {
            ScreenRoutines.CursorWait();
            try
            {
                Control.ShadowedAnimationMode = FleuxControl.ShadowedAnimationOptions.FromRight;

                var appBar = new ApplicationBar
                {
                    Size = new Size(Size.Width, 48 + 2 * 10),
                    Location = new Point(0, Size.Height - 48 - 2 * 10)
                };
                appBar.AddButton(ResourceManager.Instance.GetBitmapFromEmbeddedResource(
                    (MetroTheme.PhoneBackgroundBrush == Color.White) ?
                        "Metrohome65.Settings.Controls.Images.back-light.bmp" : "Metrohome65.Settings.Controls.Images.back-dark.bmp"
                    ));
                appBar.ButtonTap += (sender, args) => Close();
                Control.AddElement(appBar.AnimateHorizontalEntrance(false));

                var stackPanel = new StackPanel { Size = new Size(SettingsConsts.MaxWidth, 10), };

                // buttons for selecting font family
                stackPanel.AddElement(
                    new TextElement("Font family") { AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, }
                );

                var fonts = new List<string>
                    {
                        MetroTheme.PhoneFontFamilyNormal,
                        MetroTheme.PhoneFontFamilyLight,
                        MetroTheme.PhoneFontFamilySemiLight,
                        MetroTheme.PhoneFontFamilySemiBold,
                    };
                var fontBindingManager = new BindingManager() { MultiBind = true, };
                foreach (var font in fonts)
                {
                    var button = new ToggleButton(font)
                        {
                            Size = new Size(SettingsConsts.MaxWidth, 50),
                        };
                    stackPanel.AddElement(button);
                    fontBindingManager.Bind(_textStyle, "FontFamily", button, "Value", true);
                    stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 10), });
                }

                stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 20) });

                // buttons for selecting font size
                stackPanel.AddElement(
                    new TextElement("Font size") { AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight, }
                );

                var sizePanel = new Canvas()
                {
                    Size = new Size(SettingsConsts.MaxWidth, 10),
                };
                stackPanel.AddElement(sizePanel);

                var sizeBindingManager = new BindingManager() { MultiBind = true, };
                var sizes = new List<int>
                    {
                         8, 10, 11, 12, 14,
                        16, 18, 20, 22, 24,
                        26, 28, 30, 32, 34,
                        36, 38, 42, 46, 50,
                    };
                var i = 0;
                foreach (var size in sizes)
                {
                    var button = new ToggleButton(size)
                            {
                                Location = new Point((i%5)*90, (i/5)*60),
                                Size = new Size(80, 50),
                            };
                    sizeBindingManager.Bind(_textStyle, "FontSize", button, "Value", true);
                    sizePanel.AddElement(button);
                    i++;
                }

                stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 20)});

                // font color
                var fontColor = new ColorSettingsControl(false)
                    {
                        Size = new Size(SettingsConsts.MaxWidth, 50),
                        Caption = "Font color",
                    };
                fontBindingManager.Bind(_textStyle, "Foreground", fontColor, "Value", true);
                stackPanel.AddElement(fontColor);

                stackPanel.AddElement(new DelegateUIElement() { Size = new Size(10, 20) });

                // example text block
                _example = new TextElement("Example")
                    {
                        AutoSizeMode = TextElement.AutoSizeModeOptions.OneLineAutoHeight,
                        Style = _textStyle,
                    };
                _textStyle.PropertyChanged += (sender, args) => _example.Update();
                stackPanel.AddElement(_example);

                var scroller = new SolidScrollViewer
                {
                    Content = stackPanel,
                    Location = new Point(SettingsConsts.PaddingHor, SettingsConsts.PaddingHor),
                    Size = new Size(this.Size.Width - SettingsConsts.PaddingHor, this.Size.Height - appBar.Size.Height - SettingsConsts.PaddingHor),
                    ShowScrollbars = true,
                    HorizontalScroll = false,
                    VerticalScroll = true,
                };

                Control.AddElement(scroller);
            }
            finally
            {
                ScreenRoutines.CursorNormal();
            }
        }