Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            refreshButton.Clicked += RefreshButton_Clicked;

            // Set the binding BEFORE adding items so as to avoid restyling everything
            styleManager = new StyleManager();
            bindings.Add(this.SetBinding(() => ViewModelLocator.Styles.CustomTags, () => styleManager.CustomTags));

            styleOne = styleManager.Add(titleOne, TextStyles.H2);
            bindings.Add(this.SetBinding(() => Vm.TitleOne, () => styleOne.Text));

            styleTwo = styleManager.Add(titleTwo, TextStyles.H1);
            bindings.Add(this.SetBinding(() => Vm.TitleTwo, () => styleTwo.Text));

            styleThree = styleManager.Add(titleThree, TextStyles.H2);
            bindings.Add(this.SetBinding(() => Vm.TitleThree, () => styleThree.Text));

            styleBody = styleManager.Add(textBody, TextStyles.Body);
            bindings.Add(this.SetBinding(() => Vm.Body, () => styleBody.Text));

            styleEntry = styleManager.Add(textEntry, TextStyles.Body, enableHtmlEditing: true);
            bindings.Add(this.SetBinding(() => Vm.Entry, () => styleEntry.Text));

            Xamarin.IQKeyboardManager.SharedManager.EnableAutoToolbar          = true;
            Xamarin.IQKeyboardManager.SharedManager.ShouldResignOnTouchOutside = true;

            var touchGesture = new UITapGestureRecognizer(HandleAction);

            View.AddGestureRecognizer(touchGesture);
        }
Esempio n. 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //TextUtils.ListFontNames ("open");

            // Load the CSS file
            var style = File.ReadAllText("StyleOne.css");

            TextStyle.Instance.SetCSS(style);

            // TEMP
            var stopwatch = Stopwatch.StartNew();

            // Create a StyleManager to handle any CSS changes automatically
            _styleManager = new StyleManager();
            _styleManager.Add(labelOne, "h2", headingOne);
            _styleManager.Add(labelTwo, "h1", headingTwo);
            _styleManager.Add(labelThree, "h2", headingThree, new List <CssTagStyle> {
                new CssTagStyle("spot")
                {
                    CSS = "spot{color:" + Colors.SpotColor.ToHex() + "}"
                }
            });
            _styleManager.Add(body, "body", textBody);

            Console.WriteLine("Elapsed time {0}", stopwatch.ElapsedMilliseconds);

            AddUIElements();
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Register Fonts
            TextStyle.Default.AddFont("Archistico-Normal", "Archistico_Simple.ttf");
            TextStyle.Default.AddFont("Avenir-Medium", "Avenir-Medium.ttf");
            TextStyle.Default.AddFont("Avenir-Book", "Avenir-Book.ttf");
            TextStyle.Default.AddFont("Avenir-Heavy", "Avenir-Heavy.ttf");
            TextStyle.Default.AddFont("BreeSerif-Regular", "BreeSerif-Regular.ttf");
            TextStyle.Default.AddFont("OpenSans-CondensedBold", "OpenSans-CondBold.ttf");
            TextStyle.Default.AddFont("OpenSans-CondensedLight", "OpenSans-CondLight.ttf");

            SimpleIoc.Default.Register <ITextStyle>(() => TextStyle.Default);
            AppBootstrapper.Init();

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar.Title = "Native Text Demo";
            SetActionBar(toolbar);


            // Set the binding BEFORE adding items so as to avoid restyling everything
            styleManager = new StyleManager();
            bindings.Add(this.SetBinding(() => ViewModelLocator.Styles.CustomTags, () => styleManager.CustomTags));

            // Assign and bind the views
            styleOne = styleManager.Add(FindViewById <TextView>(Resource.Id.titleOne), TextStyles.H2);
            bindings.Add(this.SetBinding(() => Vm.TitleOne, () => styleOne.Text));

            styleTwo = styleManager.Add(FindViewById <TextView>(Resource.Id.titleTwo), TextStyles.H1);
            bindings.Add(this.SetBinding(() => Vm.TitleTwo, () => styleTwo.Text));

            styleThree = styleManager.Add(FindViewById <TextView>(Resource.Id.titleThree), TextStyles.H2);
            bindings.Add(this.SetBinding(() => Vm.TitleThree, () => styleThree.Text));

            styleBody = styleManager.Add(FindViewById <TextView>(Resource.Id.textBody), TextStyles.Body);
            bindings.Add(this.SetBinding(() => Vm.Body, () => styleBody.Text));

            editText   = FindViewById <EditText>(Resource.Id.textEdit);
            styleEntry = styleManager.Add(editText, TextStyles.Body, enableHtmlEditing: true);
            bindings.Add(this.SetBinding(() => Vm.Entry, () => styleEntry.Text));

            // Dismiss keyboard on tap of background
            editText.EditorAction += (sender, e) =>
            {
                if (e.ActionId == ImeAction.Done)
                {
                    DismissKeyboard();
                }
            };

            var layout = (LinearLayout)FindViewById(Resource.Id.layout);

            layout.Touch += (sender, e) => DismissKeyboard();
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            _cssOne = OpenCSSFile("StyleOne.css");
            _cssTwo = OpenCSSFile("StyleTwo.css");

            TextStyle.Instance.AddFont("Archistico", "Archistico_Simple.ttf");
            TextStyle.Instance.AddFont("Avenir-Medium", "Avenir-Medium.ttf");
            TextStyle.Instance.AddFont("Avenir-Book", "Avenir-Book.ttf");
            TextStyle.Instance.AddFont("Avenir-Heavy", "Avenir-Heavy.ttf");
            TextStyle.Instance.AddFont("BreeSerif-Regular", "BreeSerif-Regular.ttf");
            TextStyle.Instance.AddFont("OpenSans-CondBold", "OpenSans-CondBold.ttf");
            TextStyle.Instance.AddFont("OpenSans-CondLight", "OpenSans-CondLight.ttf");

            TextStyle.Instance.SetCSS(_cssOne);

            var labelOne   = FindViewById <TextView> (Resource.Id.labelOne);
            var labelTwo   = FindViewById <TextView> (Resource.Id.labelTwo);
            var labelThree = FindViewById <TextView> (Resource.Id.labelThree);
            var body       = FindViewById <TextView> (Resource.Id.body);

            // Create a StyleManager to handle any CSS changes automatically
            _styleManager = new StyleManager();
            _styleManager.Add(labelOne, "h2", headingOne);
            _styleManager.Add(labelTwo, "h1", headingTwo);
            _styleManager.Add(labelThree, "h2", headingThree, new List <CssTagStyle> {
                new CssTagStyle("spot")
                {
                    CSS = "spot{color:" + Colors.SpotColor.ToHex() + "}"
                }
            });
            _styleManager.Add(body, "body", textBody);

            var toggleButton = FindViewById <ImageButton> (Resource.Id.refreshIcon);

            toggleButton.Click += (sender, e) => {
                Console.WriteLine("Toggled");

                var css = _isFirstStyleSheet ? _cssTwo : _cssOne;
                _isFirstStyleSheet = !_isFirstStyleSheet;
                TextStyle.Instance.SetCSS(css);
            };
        }
Esempio n. 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //TextUtils.ListFontNames ("open");
            _parsedStylesOne = CssTextStyleParser.Parse(File.ReadAllText("StyleOne.css"));
            _parsedStylesTwo = CssTextStyleParser.Parse(File.ReadAllText("StyleTwo.css"));
            TextStyle.Main.SetStyles(_parsedStylesOne);

            // TEMP
            var stopwatch = Stopwatch.StartNew();

            // Create a StyleManager to handle any CSS changes automatically
            _styleManager = new StyleManager(TextStyle.Main);
            _styleManager.Add(labelOne, "h2", headingOne);
            _styleManager.Add(labelTwo, "h1", headingTwo);
            _styleManager.Add(labelThree, "h2", headingThree, new List <CssTag> {
                new CssTag("spot")
                {
                    CSS = "spot{color:" + Colors.SpotColor.ToHex() + "}"
                }
            });
            _styleManager.Add(body, "body", textBody);
            _styleManager.Add(entry, "body", @"hello <i>world</i>", enableHtmlEditing: true);

            body.DataDetectorTypes = UIDataDetectorType.PhoneNumber;

            // Using extension methods
            //body.AttributedText = "Hello world <b>this is a test</b>".ToAttributedString ();

            // TEMP
            //labelOne.Style("h2", headingOne);
            //_styleManager.Add(labelOne, "h2", headingOne);

            Console.WriteLine("Elapsed time {0}", stopwatch.ElapsedMilliseconds);

            var tapper = new UITapGestureRecognizer(() => { View.EndEditing(true); })
            {
                CancelsTouchesInView = false
            };

            View.AddGestureRecognizer(tapper);

            AddUIElements();
        }
Esempio n. 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Load the CSS file
            var style = File.ReadAllText ("StyleOne.css");
            TextStyle.Instance.SetCSS (style);

            // Create a StyleManager to handle any CSS changes automatically
            _styleManager = new StyleManager ();
            _styleManager.Add (labelOne, "h2", headingOne);
            _styleManager.Add (labelTwo, "h1", headingTwo);
            _styleManager.Add (labelThree, "h2", headingThree, new List<CssTagStyle> {
                new CssTagStyle ("spot"){ CSS = "spot{color:" + Colors.SpotColor.ToHex () + "}" }
            });
            _styleManager.Add (body, "body", textBody);

            AddUIElements ();
        }
Esempio n. 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            panel1.Visible = true;
            engine         = new Engine();
            engine.Flag    = Engine.ExecutanFlags.RamOptimized;
            engine.Evaluate(fastColoredTextBox1.Text);
            fastColoredTextBox1.Text =
                fastColoredTextBox1.Text.Replace(
                    "Console.WriteLine(\"hello world\"); #gets replaced by msg box in load event",
                    "MessageBox.Show(\"hello world\");");
            listBox1.Items.Clear();
            if (ShowConsole == false)
            {
                panel1.Visible = false;
            }

            var items = new List <AutocompleteItem>();

            items.Add(new MethodAutocompleteItem2("Console.WriteLine"));
            items.Add(new SnippetAutocompleteItem("if ^[expression]\r\n\r\t#do something\nend if"));
            items.Add(new SnippetAutocompleteItem("try \r\n\r^#do something\n\rcatch ex\r\n#do something\n\nfinally\n#do something\nend try"));
            items.Add(new SnippetAutocompleteItem("switch ^parent \r\n\r#do something\ncase condition:\r\n#do something\nbreak;\ndefault:\n#do something\nend switch"));

            foreach (var node in AddinManager.GetExtensionObjects("/EcIDE/Intellisense/Snippets"))
            {
                var cmd = node.CreateInstances <ISnippet>();

                Array.ForEach(cmd, c => items.Add(new SnippetAutocompleteItem(c.GetSnippet())));
            }

            foreach (var node in AddinManager.GetExtensionObjects("/EcIDE/Intellisense/Commands"))
            {
                var cmd = node.CreateInstances <IIntellisenseCommand>();

                foreach (var intellisenseCommand in cmd)
                {
                    StyleManager.Add(intellisenseCommand.GetPattern(), intellisenseCommand.GetColor(), intellisenseCommand.GetStyle());
                    InfoManager.Add(intellisenseCommand.GetPattern(), intellisenseCommand.GetDescription());

                    items.Add(new AutocompleteItem(intellisenseCommand.GetPattern(), 0));
                }
            }

            var menu = new AutocompleteMenu(fastColoredTextBox1);

            menu.SearchPattern = @"[\w\.]";
            menu.AllowTabKey   = true;
            menu.ImageList     = imageList1;
            menu.Items.SetAutocompleteItems(items);
        }
Esempio n. 8
0
        public MainForm()
        {
            var items = new List <AutocompleteItem>
            {
                new SnippetAutocompleteItem(
                    "if ^[expression]\r\n\r\t#do something\nend if"),
                new SnippetAutocompleteItem(
                    "try \r\n\r^#do something\n\rcatch ex\r\n#do something\n\nfinally\n#do something\nend try"),
                new SnippetAutocompleteItem(
                    "switch ^parent \r\n\r#do something\ncase condition:\r\n#do something\nbreak;\ndefault:\n#do something\nend switch")
            };

            //items.Add(new MethodAutocompleteItem2("Console.WriteLine"));

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/Intellisense/Snippets"))
            {
                var cmd = node.CreateInstances <ISnippet>();

                cmd.ForEach(c => c.Init(new ServiceContainer()));
                cmd.ForEach(c => items.Add(new SnippetAutocompleteItem(c.GetSnippet())));
            }

            IntellisenseManager.PopulateClass(items, typeof(Console));
            IntellisenseManager.PopulateClass(items, typeof(MessageBox));

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/Intellisense/Commands"))
            {
                var cmd = node.CreateInstances <IIntellisenseCommand>();

                cmd.ForEach(c => c.Init(new ServiceContainer()));

                foreach (IIntellisenseCommand intellisenseCommand in cmd)
                {
                    StyleManager.Add(
                        intellisenseCommand.GetPattern(),
                        intellisenseCommand.GetColor(),
                        intellisenseCommand.GetStyle());
                    InfoManager.Add(intellisenseCommand.GetPattern(), intellisenseCommand.GetDescription());

                    items.Add(new AutocompleteItem(intellisenseCommand.GetPattern(), 0));
                }
            }

            this.InitializeComponent();

            var menu = new AutocompleteMenu(this.fastColoredTextBox1)
            {
                SearchPattern = @"[\w\.]", AllowTabKey = true
            };

            menu.Items.SetAutocompleteItems(items);

            Console.SetOut(new ControlWriter(this.console));
            Console.SetIn(this.rdtxt);
            engine = new Engine {
                Flag = Engine.ExecutanFlags.RamOptimized
            };

            OptionsManager.Load();

            ServiceProviderContainer.AddService(new EditorService(this.fastColoredTextBox1));
            ServiceProviderContainer.AddService(new MenuService(this.MainMenu));
            ServiceProviderContainer.AddService(new AddinService(AddinManager.Registry));
            ServiceProviderContainer.AddService(new NotificationService(this.RadDesktopAlert));
            ServiceProviderContainer.AddService(new WindowService(this.dock));
            ServiceProviderContainer.AddService(new OptionsService());

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/StartupCommands"))
            {
                var cmd = node.CreateInstances <ICommand>();

                cmd.ForEach(c => c.Init(new ServiceContainer()));
                cmd.ForEach(c => c.Run());

                var ecommand = node.GetCommand();

                foreach (var ec in ecommand)
                {
                    var ep = ec as window;
                    if (ep != null)
                    {
                        if (ep.title != "")
                        {
                            this.Text = ep.title;
                        }
                        if (ep.close != "")
                        {
                            cmd.ForEach(
                                c =>
                            {
                                this.FormClosing += (sender, args) => c.GetType().GetMethod(ep.close).Invoke(c, null);
                            });
                        }
                    }
                }
            }

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/Menu"))
            {
                foreach (var ec in node.GetCommand())
                {
                    var ep = ec as menuitem;
                    if (ep != null)
                    {
                        var target = node.CreateInstances <IMenu>()[0];
                        target.Init(new ServiceContainer());

                        MainMenu.Items.Add(
                            new ToolStripMenuItem(ep.text, null, (sender, args) => target.GetType().GetMethod(ep.click).Invoke(target, new[] { sender, args })));
                    }
                }
            }

            MenuBinder.Bind(MainMenu);

            explorerTree.ExpandAll();

            projectProperties1.AddCurrentTabPage(new GeneralPage());
            this.AddPropertyTabPage("General", new GeneralPage());

            dock.CloseWindow(propertiesWindow);

            fastColoredTextBox1.Refresh();
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            this.Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan);

            // Register Fonts
            TextStyle.Default.AddFont("Archistico-Normal", "Archistico_Simple.ttf");
            TextStyle.Default.AddFont("Avenir-Medium", "Avenir-Medium.ttf");
            TextStyle.Default.AddFont("Avenir-Book", "Avenir-Book.ttf");
            TextStyle.Default.AddFont("Avenir-Heavy", "Avenir-Heavy.ttf");
            TextStyle.Default.AddFont("BreeSerif-Regular", "BreeSerif-Regular.ttf");
            TextStyle.Default.AddFont("OpenSans-CondBold", "OpenSans-CondBold.ttf");
            TextStyle.Default.AddFont("OpenSans-CondLight", "OpenSans-CondLight.ttf");

            // Pre-parse the style sheets
            _parsedStylesOne = CssTextStyleParser.Parse(OpenCSSFile("StyleOne.css"));
            _parsedStylesTwo = CssTextStyleParser.Parse(OpenCSSFile("StyleTwo.css"));
            TextStyle.Default.SetStyles(_parsedStylesOne);

            // Get references to our UI Elements
            var labelOne   = FindViewById <TextView>(Resource.Id.labelOne);
            var labelTwo   = FindViewById <TextView>(Resource.Id.labelTwo);
            var labelThree = FindViewById <TextView>(Resource.Id.labelThree);
            var body       = FindViewById <TextView>(Resource.Id.body);
            var editText   = FindViewById <TextView>(Resource.Id.editText);

            editText.Click += (sender, e) =>
            {
                editText.SetCursorVisible(true);
            };

            // Create a StyleManager to handle any CSS changes automatically
            _styleManager = new StyleManager(TextStyle.Default);
            _styleManager.Add(labelOne, "h2", headingOne);
            _styleManager.Add(labelTwo, "h1", headingTwo);
            _styleManager.Add(labelThree, "h2", headingThree, new List <CssTag> {
                new CssTag("spot")
                {
                    CSS = "spot{color:" + Colors.SpotColor.ToHex() + "}"
                }
            });
            _styleManager.Add(body, "body", textBody);
            _styleManager.Add(editText, "body", editbody, enableHtmlEditing: true);

            // Dismiss keyboard on tap of background
            var layout = (LinearLayout)FindViewById(Resource.Id.layout);

            layout.Touch += (sender, e) =>
            {
                InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(editText.WindowToken, 0);
                editText.ClearFocus();
            };

            // Create a toggle button for swapping between styles
            var toggleButton = FindViewById <ImageButton>(Resource.Id.refreshIcon);

            toggleButton.SetBackgroundColor(Color.Transparent);
            toggleButton.Click += (sender, e) =>
            {
                var styles = _isFirstStyleSheet ? _parsedStylesTwo : _parsedStylesOne;
                TextStyle.Default.SetStyles(styles);

                _isFirstStyleSheet = !_isFirstStyleSheet;
            };

            editText.ClearFocus();
        }
Esempio n. 10
0
 [HttpPost]      // Post: Blogs
 public async Task <ActionResult> Post([FromBody] Style style)
 {
     return(Created("Object Created", await _styleManager.Add(style)));
 }