Inheritance: Editor
    static void AddWindow()
    {
        Rect     wr     = new Rect(0, 0, 500, 500);
        MyEditor window = (MyEditor)EditorWindow.GetWindowWithRect(typeof(MyEditor), wr, true, "CreatWindow");

        window.Show();
    }
Exemple #2
0
        private async void MyEditor_EditorLoaded(object sender, EventArgs e)
        {
            IsInit = true;
            await InitThemes();

            await MyEditor.SetThemeAsync("dark");
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Editor> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                MyEditor entity = e.NewElement as MyEditor;
                this.Control.Hint = entity.Placeholder;
                this.Control.SetHintTextColor(entity.PlaceholderColor.ToAndroid());

                ShapeDrawable shape = new ShapeDrawable(new RectShape());
                shape.Paint.Color       = Xamarin.Forms.Color.Transparent.ToAndroid();
                shape.Paint.StrokeWidth = 5;
                shape.Paint.SetStyle(Paint.Style.Stroke);
                this.Control.SetBackground(shape);


                //Control.SetLines(4);
                //Control.VerticalScrollBarEnabled = true;
                //Control.MovementMethod = ScrollingMovementMethod.Instance;
                //Control.ScrollBarStyle = ScrollbarStyles.InsideInset;
                ////Force scrollbars to be displayed
                //TypedArray a = Control.Context.Theme.ObtainStyledAttributes(new int[0]);
                //InitializeScrollbars(a);
                //a.Recycle();
            }
        }
        private void OnGUI()
        {
            var selected = MyGUI.DropAreaPaths("Drag Texture", 20);

            using (new EditorGUILayout.HorizontalScope())
            {
                _width  = EditorGUILayout.IntField("Width", _width);
                _height = EditorGUILayout.IntField("Width", _height);
            }

            if (_texture != null)
            {
                EditorGUILayout.LabelField(new GUIContent(_texture), GUILayout.Width(_width), GUILayout.Height(_height));
            }

            if (selected == null || selected.Length == 0)
            {
                return;
            }

            string content = Convert.ToBase64String(File.ReadAllBytes(selected[0]));

            _representation = content;

            MyEditor.CopyToClipboard(_representation);
            ShowNotification(new GUIContent(selected[0] + "\nCopied to Clipboard as string"));

            _texture = ImageStringConverter.ImageFromString(_representation, _width, _height);
        }
 private async void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
 {
     if (IsInit)
     {
         await MyEditor.SetFontSizeAsync(e.NewValue);
     }
 }
        private bool CheckContextAction(MyGuiContextMenuItemActionType action)
        {
            var editorState   = MyEditor.GetCurrentState();
            var contextHelper = MyGuiContextMenuHelpers.GetEditorContextMenuHelper(editorState);

            return(contextHelper != null && contextHelper.IsActionTypeAvailable(action));
        }
Exemple #7
0
    static void AddWindow()
    {
        //创建窗口
        Rect     wr     = new Rect(0, 0, 500, 500);
        MyEditor window = (MyEditor)EditorWindow.GetWindowWithRect(typeof(MyEditor), wr, true, "widow name");

        window.Show();
    }
Exemple #8
0
        private static void CheckAssets()
        {
            var toFill = MyBoxSettings.EnableSOCheck ?
                         MyEditor.GetFieldsWithAttributeFromAll <AutoPropertyAttribute>() :
                         MyEditor.GetFieldsWithAttributeFromScenes <AutoPropertyAttribute>();

            toFill.ForEach(FillProperty);
        }
 private async void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (IsInit)
     {
         var font = FontFamilyComboBox.SelectedItem as SystemFont;
         await MyEditor.SetFontFamilyAsync(font.Name);
     }
 }
Exemple #10
0
        private static void CheckComponentsInScene()
        {
            var autoProperties = MyEditor.GetFieldsWithAttribute <AutoPropertyAttribute>();

            for (var i = 0; i < autoProperties.Length; i++)
            {
                FillProperty(autoProperties[i]);
            }
        }
Exemple #11
0
 private async void ThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (IsInit)
     {
         var    item      = ThemeComboBox.SelectedItem as ComboBoxItem;
         string themeName = item.Tag.ToString();
         await MyEditor.SetThemeAsync(themeName);
     }
 }
Exemple #12
0
    private static void FoldHierarchyButton()
    {
        if (!GUILayout.Button(_icoFold, MyGUI.ResizableToolbarButtonStyle, GUILayout.Height(32), GUILayout.Width(32)))
        {
            return;
        }

        MyEditor.FoldSceneHierarchy();
    }
Exemple #13
0
        private static void CheckComponentsInPrefab(GameObject prefab)
        {
            var autoProperties = MyEditor.GetFieldsWithAttribute <AutoPropertyAttribute>(prefab);

            for (var i = 0; i < autoProperties.Length; i++)
            {
                FillProperty(autoProperties[i]);
            }
        }
Exemple #14
0
        private void OnCopySpotDiffuseColor(MyGuiControlButton sender)
        {
            var prefabLight = m_prefabLights.FirstOrDefault();

            if (prefabLight != null)
            {
                MyLight light = prefabLight.GetLight();
                MyEditor.SetClipboard(light.ReflectorColor);
            }
        }
        public void HeapEditor_Basics_Struct_Array()
        {
            var e = new MyEditor();

            var p = new KeyValuePair <string, int>[] { new("Bart", 21) };

            e.Walk(p, _ => true);

            Assert.AreEqual("BART", p[0].Key);
        }
Exemple #16
0
 private void MouseLeftButtonDownHandler(object sender, MouseButtonEventArgs e)
 {
     if (ActiveModel != null)
     {
         PluginChangedEventArgs args = new PluginChangedEventArgs(ActiveModel.Plugin, ActiveModel.GetName(), DisplayPluginMode.Normal);
         MyEditor.onSelectedPluginChanged(args);
         e.Handled = true;
     }
     return;
 }
Exemple #17
0
        private void OnCopyPointSpecularColor(MyGuiControlButton sender)
        {
            var prefabLight = m_prefabLights.FirstOrDefault();

            if (prefabLight != null)
            {
                MyLight light = prefabLight.GetLight();
                MyEditor.SetClipboard(light.SpecularColor);
            }
        }
        public void HeapEditor_Basics_Struct_Box()
        {
            var e = new MyEditor();

            var p = new StrongBox <KeyValuePair <string, int> >(new("Bart", 21));

            e.Walk(p, _ => true);

            Assert.AreEqual("BART", p.Value.Key);
        }
        public void HeapEditor_Basics_Class()
        {
            var e = new MyEditor();

            var p = new Person("Bart", 21);

            e.Walk(p, _ => true);

            Assert.AreEqual("BART", p.Name);
        }
Exemple #20
0
        public NoteEditPage(NoteEditModel model)
        {
            _model = model;
            _note  = model.Note;
            _isNew = model.IsNew;
            Title  = "Note";

            entry = new Entry()
            {
                Placeholder = "Title",
            };
            entry.Text = _note.Title;

            editor = new MyEditor()
            {
                Keyboard        = Keyboard.Create(KeyboardFlags.All),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Text            = _note.Body
            };

            deleteCancel = new Button()
            {
                Text = _isNew ? "Cancel" : "Delete"
            };

            deleteCancel.Clicked += (object sender, EventArgs e) =>
            {
                _isCanceling = true;

                if (!_isNew)
                {
                    _note.IsDeleted = true;
                    _model.Save();
                }

                Navigation.PopAsync();
            };

            Content = new StackLayout()
            {
                Children =
                {
                    new Label {
                        Text = "Title"
                    },
                    entry,
                    new Label {
                        Text = "Note"
                    },
                    editor,
                    deleteCancel
                },
                Padding = new Thickness(5, 5, 5, 5)
            };
        }
 private async void LineNumberSwitcher_Toggled(object sender, RoutedEventArgs e)
 {
     if (IsInit)
     {
         var obj = new
         {
             lineNumbers = LineNumberSwitcher.IsOn ? "on" : "off"
         };
         await MyEditor.UpdateEditorOptionsAsync(JsonConvert.SerializeObject(obj));
     }
 }
Exemple #22
0
 private void MyEditor_Focused(object sender, FocusEventArgs e)
 {
     if (!MyEditor.Focus())
     {
         Debug.WriteLine("keyboard chưa hiển thị lên");
     }
     else
     {
         Debug.WriteLine("keyboard hiển thị lên");
     }
 }
        public void HeapEditor_Basics_Array()
        {
            var e = new MyEditor();

            var xs = new[] { "foo", "bar" };

            e.Walk(xs, _ => true);

            Assert.AreEqual("FOO", xs[0]);
            Assert.AreEqual("BAR", xs[1]);
        }
 private async void MinimapSwitcher_Toggled(object sender, RoutedEventArgs e)
 {
     if (IsInit)
     {
         var obj = new
         {
             minimap = new
             {
                 enabled = MinimapSwitcher.IsOn
             }
         };
         await MyEditor.UpdateEditorOptionsAsync(JsonConvert.SerializeObject(obj));
     }
 }
Exemple #25
0
        private void OnPasteSpotDiffuseColor(MyGuiControlButton sender)
        {
            Color color;

            if (MyEditor.GetClipboard <Color>(out color))
            {
                foreach (var prefabLight in m_prefabLights)
                {
                    MyLight light = prefabLight.GetLight();
                    light.ReflectorColor = color.ToVector4();
                    InitializeValues(prefabLight);
                }
            }
        }
Exemple #26
0
        private void OnSelectGroup(MyGuiControlButton sender)
        {
            var group = GetFocusedGroup();

            if (group != null && group.GetCount() > 0)
            {
                var container = group.GetContainer();
                if (MyEditor.Static.IsEditingPrefabContainer() && MyEditor.Static.GetEditedPrefabContainer() == container)
                {
                    MyEditorGizmo.AddEntitiesToSelection(group.GetEntities());
                }
                else
                {
                    var editorState   = MyEditor.GetCurrentState();
                    var contextHelper = MyGuiContextMenuHelpers.GetEditorContextMenuHelper(editorState);

                    // If exit/enter to prefab container available
                    if (container != null &&
                        (editorState == MyEditorStateEnum.NOTHING_SELECTED ||
                         contextHelper.IsActionTypeAvailable(MyGuiContextMenuItemActionType.ENTER_PREFAB_CONTAINER) ||
                         contextHelper.IsActionTypeAvailable(MyGuiContextMenuItemActionType.EXIT_EDITING_MODE)))
                    {
                        // Switch to group container
                        if (MyEditor.Static.IsEditingPrefabContainer())
                        {
                            MyEditor.Static.ExitActivePrefabContainer();
                        }
                        MyEditor.Static.EditPrefabContainer(container);

                        if (MyEditor.Static.IsEditingPrefabContainer() && MyEditor.Static.GetEditedPrefabContainer() == container)
                        {
                            MyEditorGizmo.AddEntitiesToSelection(group.GetEntities());
                        }
                    }
                    else if (container == null)
                    {
                        if (MyEditor.Static.IsEditingPrefabContainer())
                        {
                            MyEditor.Static.ExitActivePrefabContainer();
                        }
                        MyEditorGizmo.ClearSelection();
                        MyEditorGizmo.AddEntitiesToSelection(group.GetEntities());
                    }
                    else
                    {
                        MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, new StringBuilder("Can't select group."), new StringBuilder("Select Group Error"), MyTextsWrapperEnum.Ok, null));
                    }
                }
            }
        }
Exemple #27
0
        private async Task InitThemes()
        {
            var lightFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/light.json"));

            string lightJson = await FileIO.ReadTextAsync(lightFile);

            await MyEditor.DefineThemeAsync("light", lightJson);

            var darkFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/dark.json"));

            string darkJson = await FileIO.ReadTextAsync(darkFile);

            await MyEditor.DefineThemeAsync("dark", darkJson);
        }
        public void HeapEditor_Basics_MultidimensionalArray()
        {
            var e = new MyEditor();

            var xs = new string[2, 2] {
                { "foo", "bar" }, { "qux", "baz" }
            };

            e.Walk(xs, _ => true);

            Assert.AreEqual("FOO", xs[0, 0]);
            Assert.AreEqual("BAR", xs[0, 1]);
            Assert.AreEqual("QUX", xs[1, 0]);
            Assert.AreEqual("BAZ", xs[1, 1]);
        }
Exemple #29
0
        private async void MyEditor_ControlLoaded(object sender, EventArgs e)
        {
            var displayOptions  = DisplayOptions.CreateOptions();
            var editorOptions   = EditorOptions.CreateOptions();
            var languageOptions = await EditorLanguageOptions.GetDefaultEnOptionsAsync();

            editorOptions.Theme = "";
            await MyEditor.Initialize("# Hello Markdown!", displayOptions, editorOptions, "", languageOptions);

            var cssFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/acrmd.css"));

            string css = await FileIO.ReadTextAsync(cssFile);

            await MyEditor.SetPreviewStyle(css);
        }
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            MyEditor obj = (MyEditor)sender;

            if (e.PropertyName == "IsFocused")
            {
                if (obj.IsFocused)
                {
                    ThreadPool.QueueUserWorkItem(s =>
                    {
                        Thread.Sleep(100);                                         // For some reason, a short delay is required here. ((Android.Views.InputMethods.InputMethodManager)Context.GetSystemService((Android.Content.Context.InputMethodService))).ShowSoftInput(this.Control,Android.Views.InputMethods.ShowFlags.Implicit);
                    });
                }
            }
            base.OnElementPropertyChanged(sender, e);
        }
Exemple #31
0
		private Grid setupProjectPage(){
			Grid content = createContentGrid ();
			StackLayout bodyStack = createBodyStack ();

			StackLayout locationStack = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Padding = new Thickness(10)
			};

			Label locationLabel = new Label {
				Text = "Location:",
				TextColor = Color.White,
				FontSize = 16
			};

			Entry locationEntry = new Entry {
				BackgroundColor = Color.White,
				TextColor = Color.Black,
				WidthRequest = 250
			};

			locationEntry.TextChanged += (object sender, TextChangedEventArgs e) => {
				Location = e.NewTextValue;
			};

			locationStack.Children.Add (locationLabel);
			locationStack.Children.Add (locationEntry);

			StackLayout tagStack = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Padding = new Thickness (10)
			};

			Label tagLabel = new Label {
				Text = "*Tags:\t\t",
				TextColor = Color.White,
				FontSize = 16
			};

			Button tagBtn = new Button{
				Text = "Select Tags",
				TextColor = Color.Black,
				BackgroundColor = Color.White,
				WidthRequest = 250,
				HeightRequest = 40
			};

			tagBtn.Clicked += tagClicked;

			tagStack.Children.Add (tagLabel);
			tagStack.Children.Add (tagBtn);

			StackLayout detailsStack = new StackLayout {
				Orientation = StackOrientation.Vertical
			};

			Label detailLabel = new Label {
				Text = "*Details:\t",
				TextColor = Color.White,
				FontSize = 16
			};

			MyEditor information = new MyEditor {
				WidthRequest = 300,
				HeightRequest = 200
			};

			information.TextChanged += (object sender, TextChangedEventArgs e) => {
				Details = e.NewTextValue;
			};

			detailsStack.Children.Add (detailLabel);
			detailsStack.Children.Add (information);

			StackLayout peopleStack = new StackLayout {
				Orientation = StackOrientation.Vertical
			};

			Label peopleLabel = new Label {
				Text = "*Expertise Wanted:\t",
				TextColor = Color.White,
				FontSize = 16
			};

			MyEditor peopleEditor = new MyEditor {
				WidthRequest = 300,
				HeightRequest = 200
			};

			peopleEditor.TextChanged += (object sender, TextChangedEventArgs e) => {
				Expertise = e.NewTextValue;
			};

			peopleStack.Children.Add (peopleLabel);
			peopleStack.Children.Add (peopleEditor);

			bodyStack.Children.Add (locationStack);
			bodyStack.Children.Add (tagStack);
			bodyStack.Children.Add (detailsStack);
			bodyStack.Children.Add(peopleStack);

			StackLayout submitStack = new StackLayout {
				Padding = new Thickness (20),
				Orientation = StackOrientation.Vertical,
				VerticalOptions = LayoutOptions.EndAndExpand
			};

			Button submitProject = new Button {
				Text = "Submit Project",
				TextColor = Color.Black,
				BackgroundColor = Color.White
			};

			submitProject.Clicked += (object sender, EventArgs e) => {
				saveProject();
			};

			submitStack.Children.Add (submitProject);
			bodyStack.Children.Add (submitStack);

			ScrollView scroll = createScroll ();
			scroll.Content = bodyStack;

			content.Children.Add (scroll, 0, 0);
			content.Children.Add (createFooter (), 0, 1);
			return content;
		}
 private void createCustomEditor()
 {
     subjectEditor = new MyEditor ();
     subjectEditor.WidthRequest = 350;
     subjectEditor.HeightRequest = 200;
     subjectSection.Children.Add (subjectEditor);
 }
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IDefault page)
        {
  

            var n = new MyEditor();

            n.Container.AttachToDocument();

            //var a = new IHTMLAnchor(
            //    "http://sketchup.google.com/3dwarehouse/search?q=stargate",
            //    "Open 3dwarehouse in another window"
            //);
            //a.style.fontSize = "large-xx";
            //a.AttachToDocument();



            //ii.setAttribute("src", "http://sketchup.google.com/3dwarehouse/");


            IHTMLDiv Control = new IHTMLDiv();

            n.Edit1.parentNode.replaceChild(Control, n.Edit1);

            //n.Logo.src = "assets/TextEditorDemo2/Preview.png";

            //Control.AttachToDocument();


            var text = new TextEditor(Control);


            text.InnerHTML = "Drag images to this frame!<hr />";

            // IE error

            text.Height = 200;
            text.Width = 400;
            //text.InnerHTML = n.Edit1.value;

            text.IsFadeEnabled = false;

            //var i = new IHTMLImage(21, 20) { src = "assets/TextEditorDemo2/cal.png" };

            var CurrentList = new List<InternalExtensions.GoogleThreeDWarehouseImage>();

            n.ToLarge.onclick += e =>
            {
                CurrentList.ForEach(k => k.AnimationZoom = 4);
            };

            n.ToMedium.onclick += e =>
            {
                CurrentList.ForEach(k => k.AnimationZoom = 1);
            };
            n.ToSmall.onclick += e =>
            {
                CurrentList.ForEach(k => k.AnimationZoom = 0.5);
            };

            Action<string[], IHTMLButton> ToPreview =
                (data, button) =>
                {
                    var ii = new IHTMLImage(40, 30) { src = data[0] };
                    ii.style.verticalAlign = "middle";

                    var sp = new IHTMLSpan();
                    sp.style.marginLeft = "1em";
                    sp.AttachTo(button);

                    ii.AttachTo(button).ToGoogleThreeDWarehouseImage().Animate();

                };
            n.Nasa.onclick +=
                delegate
                {
                    text.InnerHTML = NasaSource.Text;

                };


            //n.Houses.onclick +=
            //    delegate
            //    {
            //        text.InnerHTML = Pages.Houses.Static.HTML;

            //    };

            n.CnC.onclick +=
                delegate
                {
                    text.InnerHTML = CnCSource.Text;

                };

            n.Ships.onclick +=
            delegate
            {
                text.InnerHTML = ShipsSource.Text;
            };

            //ToPreview(Ships..Images, n.Ships);
            //ToPreview(CnC.Static.Images, n.CnC);
            ////ToPreview(Houses.Static.Images, n.Houses);
            //ToPreview(Nasa.Static.Images, n.Nasa);


            //i.AttachToDocument();
            n.OK.onclick +=
                delegate
                {
                    n.ContainerForImages.removeChildren();
                    CurrentList.Clear();
                    //text.Document.getElementsByTagName("img").ToGoogleThreeDWarehouseImages().Animate();

                    var clones = text.Document.GetClonedImages();
                    foreach (IHTMLImage iii in clones)
                    {


                        var w = iii.AttachTo(n.ContainerForImages).ToGoogleThreeDWarehouseImage();

                        w.Animate();

                        CurrentList.Add(w);
                    }

                };
            //);

            //OK.Control.style.paddingLeft = "1em";
            //text.BottomToolbarContainer.appendChild(OK.Control);

            text.TopToolbarContainer.Hide();
            text.BottomToolbarContainer.Hide();
        }