示例#1
0
        private void OnEnable()
        {
            editor = (MarchingSquaresEditorComponent)target;

            if (meshers == null)
            {
                meshers = new List <EditorMesher>();
            }
            meshers.Clear();

            CreateMeshers();

            if (editor.DataComponent != null && editor.DataComponent.Data == null)
            {
                editor.DataComponent.Load();
            }

            props = new ComponentProperties <PropName>(serializedObject);

            editMode              = EditorPrefs.GetBool(PrefEditMode, false);
            showGrid              = EditorPrefs.GetBool(PrefShowGrid, true);
            brushModeIndex        = EditorPrefs.GetInt(PrefBrushModeIndex, 0);
            brushShapeIndex       = EditorPrefs.GetInt(PrefBrushShapeIndex, 0);
            heightBrushModeIndex  = EditorPrefs.GetInt(PrefHeightBrushModeIndex, 0);
            heightChangeModeIndex = EditorPrefs.GetInt(PrefHeightChangeModeIndex, 0);
            heightBrushFoldout    = EditorPrefs.GetBool(PrefHeightBrushFoldout, false);
            removeBorder          = EditorPrefs.GetBool(PrefRemoveBorder, false);
            autoSave              = EditorPrefs.GetBool(PrefAutoSave, false);

            SceneView.beforeSceneGui -= BeforeSceneGUI;
            SceneView.beforeSceneGui += BeforeSceneGUI;
        }
示例#2
0
        private async void RenderRootComponentsOnHotReload()
        {
            // Before re-rendering the root component, also clear any well-known caches in the framework
            _componentFactory.ClearCache();
            ComponentProperties.ClearCache();
            Routing.QueryParameterValueSupplier.ClearCache();

            await Dispatcher.InvokeAsync(() =>
            {
                if (_rootComponentsLatestParameters is null)
                {
                    return;
                }

                IsRenderingOnMetadataUpdate = true;
                try
                {
                    foreach (var(componentId, parameters) in _rootComponentsLatestParameters)
                    {
                        var componentState = GetRequiredComponentState(componentId);
                        componentState.SetDirectParameters(parameters);
                    }
                }
                finally
                {
                    IsRenderingOnMetadataUpdate = false;
                }
            });
        }
示例#3
0
        private void ProcessClient(TcpClient client)
        {
            var stream = client.GetStream();

            using (var reader = new StreamReader(stream))
            {
                string serializedMsg      = reader.ReadToEnd();
                ComponentProperties props = serializer.Deserialize <ComponentProperties>(serializedMsg);
            }
        }
示例#4
0
        public ParameterTypeCache(Type componentType)
        {
            ParameterInfoByName = new(StringComparer.OrdinalIgnoreCase);
            var candidateProperties = ComponentProperties.GetCandidateBindableProperties(componentType);

            foreach (var propertyInfo in candidateProperties)
            {
                if (propertyInfo.IsDefined(typeof(ParameterAttribute)))
                {
                    ParameterInfoByName.Add(propertyInfo.Name, new(propertyInfo.PropertyType));
                }
            }
        }
示例#5
0
        private IComponent constructComponent(Type componentType, dynamic[] args, ComponentProperties properties)
        {
            Type[] argTypes = new Type[args.Length];
            for (int argIndex = 0; argIndex < args.Length; argIndex++)
            {
                argTypes[argIndex] = args[argIndex].GetType();
            }

            object componentObj = componentType.GetConstructor(argTypes).Invoke(args);

            properties?.ForEach(propPair =>
            {
                PropertyInfo propInfo = componentType.GetProperty(propPair.Key, BindingFlags.Public | BindingFlags.Instance);
                propInfo?.TakeIf(_ => _.CanWrite)?.SetValue(componentObj, propPair.Value, null);
            });

            return((IComponent)componentObj);
        }
示例#6
0
 public Component(ComponentProperties settings)
 {
     Properties = settings;
 }
示例#7
0
 public void AddComponent <T>(ComponentProperties properties, params dynamic[] args)
 {
     AddComponent(typeof(T), properties, args);
 }
示例#8
0
        public void AddComponent(Type componentType, ComponentProperties properties, params dynamic[] args)
        {
            IComponent componenet = constructComponent(componentType, args, properties);

            Manager.AddComponent(this, componenet, componentType);
        }
示例#9
0
        public Inject ComponentProperties(string id, string section)
        {
            if (R.isSessionLost() == true)
            {
                return(lostInject());
            }
            Inject response = new Inject();

            response.element = ".winProperties .props-content";

            //check security
            if (R.User.Website(R.Page.websiteId).getWebsiteSecurityItem("dashboard/pages", 0) == false)
            {
                return(response);
            }

            //load properties window
            ComponentView comp      = R.Page.GetComponentViewById(id);
            string        cid       = comp.ComponentName.Replace(" ", ".");
            string        className = "Rennder.Components.Properties." + cid;
            Type          type      = Type.GetType(className, false, true);

            if (type == null)
            {
                return(response);
            }
            ComponentProperties properties = (ComponentProperties)Activator.CreateInstance(type, new object[] { R, comp });

            if (comp == null)
            {
                return(response);
            }

            //load properties.js
            string js = "";

            if (R.Server.Cache.ContainsKey("props-" + cid) == true & R.isLocal == false)
            {
                //load from cache
                js = (string)R.Server.Cache["props-" + cid];
            }
            else
            {
                //load from file
                string jsp = File.ReadAllText(R.Server.MapPath("/app/components/" + cid + "/properties.js"));
                js = jsp;
                if (R.isLocal == false)
                {
                    //save to cache
                    R.Server.Cache.Add("props-" + cid, jsp);
                }
            }
            R.Page.RegisterJS("props", "R.editor.components.properties.loaded('" + comp.ComponentName +
                              "'," + properties.Width + ");" + js);

            //finally, render properties window
            response.html = properties.Render();
            response.js   = CompileJs();

            return(response);
        }
示例#10
0
 public Component(ComponentProperties properties)
 {
     Properties = properties;
 }