Example #1
0
        static void Testbed()
        {
            // Create the main form
            Form frmMain = new Form("frmMain");

            // Add a button
            Button btn1 = new Button("btn1", "Launch Sample App", Fonts.Droid16, 4, 4);

            //btn1.Tap += (object sender, point e) => new Thread(LaunchApp).Start();
            frmMain.AddChild(btn1);

            // Activate the form
            Core.ActiveContainer = frmMain;
        }
Example #2
0
        private static void SetupMainForm()
        {
            // Step 4.1: Create the main form
            //             "mainForm":      Every control in Tinkr has a name
            //             Colors.DarkGray: Every Form has also a background color
            //           The width and height of a form is automatically set to screen size
            var frm = new Form("mainForm", Colors.DarkGray);

            // Step 4.2: Create a simple label
            //             "label":       The name of the label
            //             "Tutorial...": Text of the label
            //             Fonts.Droid12Bold: The font used to render the label
            //             10, 10:        The top left x and y coordinates of the label
            //           The size of the label is automatically calculated acoording to the content when using this constructor
            var label = new Label("label", "Tutorial 01: Getting started (NETMF)", Fonts.Droid12Bold, 10, 10);

            // Step 4.3: Add the label to the form
            //           Every control needs to be added to the form.
            //           Every control derived from Container can hold controls
            //           These contols are rendered recursively
            frm.AddChild(label);

            // Step 4.4: Create a button
            //             "button":      The name of the button
            //             "Show prompt": The content text of the button
            //             Fonts.Droid11: The font used to render the content text
            //             10, 40:        The top left x and y coordinates of the button
            //           The size of the button is automatically calculated according to the content when using this constructor
            var button = new Button("button", "Show prompt", Fonts.Droid11, 10, 40);

            // Step 4.5: Add a tap handler to the button
            //           The tap event is like the click event in a desktop application.
            //           But since NETMF devices usually have a touch screen it's called tap.
            button.Tap += ButtonOnTap;

            // Step 4.6: Add the button to the form
            frm.AddChild(button);

            // Step 4.7: Set the form as the active container.
            //           The active container is rendered and all touch events are directed to it.
            Core.ActiveContainer = frm;
        }
Example #3
0
        public static string Show(string title, Font titleFont, Font bodyFont)
        {
            IContainer prv      = Core.ActiveContainer;
            var        frmModal = new Form("modalAlertForm", Colors.Ghost);

            _result = string.Empty;

            Core.Screen.SetClippingRectangle(0, 0, frmModal.Width, frmModal.Height);
            Core.Screen.DrawRectangle(0, 0, 4, 4, frmModal.Width - 8, frmModal.Height - 8, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
            Core.ShadowRegion(4, 4, frmModal.Width - 8, frmModal.Height - 8);

            Core.Screen.DrawTextInRect(title, 8, 8, frmModal.Width - 16, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.Charcoal, titleFont);

            var tv1 = new Treeview("tv1", bodyFont, 8, 16 + titleFont.Height, frmModal.Width - 16, frmModal.Height - 41 - bodyFont.Height - titleFont.Height);

            VolumeInfo[] vi = VolumeInfo.GetVolumes();

            for (int i = 0; i < vi.Length; i++)
            {
                var viNode = new TreeviewNode(vi[i].RootDirectory)
                {
                    Tag = vi[i].RootDirectory
                };

                if (vi[i].IsFormatted)
                {
                    if (Directory.GetDirectories(vi[i].RootDirectory).Length > 0)
                    {
                        var ni = new TreeviewNode(string.Empty)
                        {
                            Tag = null
                        };
                        viNode.AddNode(ni);
                    }
                }

                tv1.AddNode(viNode);
            }
            tv1.NodeExpanded += tv1_NodeExpanded;
            frmModal.AddChild(tv1);

            var btnSelect = new Button("btnSel", "Select", bodyFont, 8, frmModal.Height - 22 - bodyFont.Height)
            {
                BorderColor        = ColorUtility.ColorFromRGB(13, 86, 124),
                NormalColorTop     = Colors.LightBlue,
                NormalColorBottom  = ColorUtility.ColorFromRGB(26, 129, 182),
                PressedColorBottom = Colors.LightBlue
            };

            btnSelect.PressedColorTop  = btnSelect.NormalColorBottom;
            btnSelect.NormalTextColor  = Colors.White;
            btnSelect.PressedTextColor = Colors.White;
            btnSelect.Tap += (sender, e) => ReturnSelection(tv1);
            frmModal.AddChild(btnSelect);

            Color cR1       = ColorUtility.ColorFromRGB(226, 92, 79);
            Color cR2       = ColorUtility.ColorFromRGB(202, 48, 53);
            var   btnCancel = new Button("btnCancel", "Cancel", bodyFont, 0, btnSelect.Y, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
            {
                NormalColorTop     = cR1,
                NormalColorBottom  = cR2,
                PressedColorTop    = cR2,
                PressedColorBottom = cR1
            };

            btnCancel.X    = frmModal.Width - btnCancel.Width - 8;
            btnCancel.Tap += (sender, e) => _activeBlock.Set();

            frmModal.AddChild(btnCancel);

            Core.SilentlyActivate(frmModal);
            frmModal.Render(new rect(4, 12 + titleFont.Height, frmModal.Width - 8, frmModal.Height - 20 - titleFont.Height));
            Core.Screen.Flush();

            ModalBlock();

            Core.ActiveContainer = prv;

            return(_result);
        }
Example #4
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        // ReSharper disable once UnusedParameter.Local
        //TODO: check why param extensions is not in use
        private static string CreateDialog(string title, Font titleFont, Font bodyFont, string startDirectory, string[] extentions)
        {
            IContainer prv = Core.ActiveContainer;

            lock (Core.Screen)
            {
                var frmModal = new Form("modalAlertForm", Colors.Ghost);
                _inputResult = string.Empty;

                Core.Screen.SetClippingRectangle(0, 0, frmModal.Width, frmModal.Height);
                Core.Screen.DrawRectangle(0, 0, 4, 4, frmModal.Width - 8, frmModal.Height - 8, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
                Core.ShadowRegion(4, 4, frmModal.Width - 8, frmModal.Height - 8);

                Core.Screen.DrawTextInRect(title, 8, 8, frmModal.Width - 16, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.Charcoal, titleFont);

                var tv1 = new Treeview("tv1", bodyFont, 8, 16 + titleFont.Height, 120, frmModal.Height - 45 - bodyFont.Height - titleFont.Height);

                VolumeInfo[] vi = VolumeInfo.GetVolumes();

                for (int i = 0; i < vi.Length; i++)
                {
                    var viNode = new TreeviewNode(vi[i].RootDirectory)
                    {
                        Tag = vi[i].RootDirectory
                    };

                    if (vi[i].IsFormatted)
                    {
                        if (Directory.GetDirectories(vi[i].RootDirectory).Length > 0)
                        {
                            var ni = new TreeviewNode(string.Empty)
                            {
                                Tag = null
                            };
                            viNode.AddNode(ni);
                        }
                    }

                    tv1.AddNode(viNode);
                }
                tv1.NodeExpanded += tv1_NodeExpanded;
                frmModal.AddChild(tv1);

                var fb1 = new Filebox("fb1", null, bodyFont, 132, tv1.Y, frmModal.Width - 141, tv1.Height);
                frmModal.AddChild(fb1);


                Color cR1       = ColorUtility.ColorFromRGB(226, 92, 79);
                Color cR2       = ColorUtility.ColorFromRGB(202, 48, 53);
                var   btnCancel = new Button("btnCancel", "Cancel", bodyFont, 8, frmModal.Height - 26 - bodyFont.Height, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                btnCancel.Height += 4;
                btnCancel.Tap    += (sender, e) => _activeBlock.Set();

                var btnSelect = new Button("btnSel", (_isSave) ? "Save File" : "Open File", bodyFont, 8, frmModal.Height - 26 - bodyFont.Height)
                {
                    BorderColor        = ColorUtility.ColorFromRGB(13, 86, 124),
                    NormalColorTop     = Colors.LightBlue,
                    NormalColorBottom  = ColorUtility.ColorFromRGB(26, 129, 182),
                    PressedColorBottom = Colors.LightBlue
                };
                btnSelect.PressedColorTop  = btnSelect.NormalColorBottom;
                btnSelect.NormalTextColor  = Colors.White;
                btnSelect.PressedTextColor = Colors.White;
                btnSelect.X       = frmModal.Width - btnSelect.Width - 8;
                btnSelect.Height += 4;
                btnSelect.Enabled = false;
                frmModal.AddChild(btnSelect);

                frmModal.AddChild(btnCancel);

                var txt1 = new Textbox("txt1", string.Empty, bodyFont, Colors.Charcoal, btnCancel.X + btnCancel.Width + 4, btnCancel.Y, frmModal.Width - 28 - btnCancel.Width - btnSelect.Width, btnSelect.Height, ' ', !_isSave);
                frmModal.AddChild(txt1);

                Core.SilentlyActivate(frmModal);
                frmModal.Render(new rect(4, 12 + titleFont.Height, frmModal.Width - 8, frmModal.Height - 20 - titleFont.Height));
                Core.Screen.Flush();

                tv1.NodeTapped           += (node, e) => tv1_NodeTapped(node, fb1);
                fb1.PathChanged          += (sender, value) => SetTvPath(value, tv1, fb1);
                fb1.SelectedIndexChanged += (sender, value) => FbIndexChange(fb1, txt1);
                txt1.TextChanged         += (sender, value) => btnSelect.Enabled = txt1.Text != string.Empty;
                SetTvPath(startDirectory, tv1, fb1);
                btnSelect.Tap += (sender, e) => ReturnSelection(tv1, txt1);
            }

            ModalBlock();

            Core.ActiveContainer = prv;

            return(_inputResult);
        }