Esempio n. 1
0
 internal MouseEventManager(RootControl root, InputManager inputManager)
 {
     this.root         = root;
     this.inputManager = inputManager;
 }
Esempio n. 2
0
        /// <summary>
        ///     Initializes the scene.
        /// </summary>
        internal virtual void Initialize()
        {
            state = SceneState.Default;

            input = Manager.Input;

            var settings = Manager.Settings;
            Interface = new RootControl
            {
                Active = true,
                Position = Vector2.Zero,
                Size = new Vector2(settings.Resolution.BaseWidth, settings.Resolution.BaseHeight),
                Parent = null
            };

            focus = Interface;

            OnInitialize();
        }
Esempio n. 3
0
        /// <inheritdoc />
        protected override void AddUpdateCallbacks(RootControl root)
        {
            base.AddUpdateCallbacks(root);

            root.UpdateCallbacksToAdd.Add(_update);
        }
Esempio n. 4
0
        /// <inheritdoc />
        protected override void RemoveUpdateCallbacks(RootControl root)
        {
            base.RemoveUpdateCallbacks(root);

            root.UpdateCallbacksToRemove.Add(_update);
        }
 public void DisposeAllComponents()
 {
     RootControl.DisposeAllChildren();
 }
Esempio n. 6
0
        /// <summary>
        /// Loads the surface from bytes. Clears the surface before and uses context source data as a surface bytes source.
        /// </summary>
        /// <remarks>
        /// Assume this method does not throw exceptions but uses return value as a error code.
        /// </remarks>
        /// <returns>True if failed, otherwise false.</returns>
        public bool Load()
        {
            Surface._isUpdatingBoxTypes++;

            try
            {
                // Prepare
                Clear();

                Loading?.Invoke(this);

                // Load bytes
                var bytes = Context.SurfaceData;
                if (bytes == null)
                {
                    throw new Exception("Failed to load surface data.");
                }

                // Load graph (empty bytes data means empty graph for simplicity when using subgraphs)
                if (bytes.Length > 0)
                {
                    using (var stream = new MemoryStream(bytes))
                        using (var reader = new BinaryReader(stream))
                        {
                            LoadGraph(reader);
                        }
                }

                // Load surface meta
                var meta = _meta.GetEntry(10);
                if (meta.Data != null)
                {
                    Utils.ByteArrayToStructure(meta.Data, out CachedSurfaceMeta);
                }
                else
                {
                    // Reset view
                    CachedSurfaceMeta.ViewCenterPosition = Vector2.Zero;
                    CachedSurfaceMeta.Scale = 1.0f;
                }

                // [Deprecated on 04.07.2019] Load surface comments
                var commentsData = _meta.GetEntry(666);
                if (commentsData.Data != null)
                {
                    using (var stream = new MemoryStream(commentsData.Data))
                        using (var reader = new BinaryReader(stream))
                        {
                            var commentsCount = reader.ReadInt32();

                            for (int i = 0; i < commentsCount; i++)
                            {
                                var title  = reader.ReadStr(71);
                                var color  = new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                                var bounds = new Rectangle(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                                var comment = SpawnComment(ref bounds, title, color);
                                if (comment == null)
                                {
                                    throw new InvalidOperationException("Failed to create comment.");
                                }

                                OnControlLoaded(comment);
                            }
                        }
                }

                // Post load
                for (int i = 0; i < RootControl.Children.Count; i++)
                {
                    if (RootControl.Children[i] is SurfaceControl control)
                    {
                        control.OnSurfaceLoaded();
                    }
                }

                RootControl.UnlockChildrenRecursive();

                // Update boxes types for nodes that dependant box types based on incoming connections
                {
                    bool keepUpdating = false;
                    int  updateLimit  = 100;
                    do
                    {
                        for (int i = 0; i < RootControl.Children.Count; i++)
                        {
                            if (RootControl.Children[i] is SurfaceNode node && !node.HasDependentBoxesSetup)
                            {
                                node.UpdateBoxesTypes();
                                keepUpdating = true;
                            }
                        }
                    } while (keepUpdating && updateLimit-- > 0);
                }

                Loaded?.Invoke(this);

                // Clear modification flag
                _isModified = false;
            }
            catch (Exception ex)
            {
                // Error
                Editor.LogWarning("Loading Visject Surface data failed.");
                Editor.LogWarning(ex);
                return(true);
            }
            finally
            {
                Surface._isUpdatingBoxTypes--;
            }

            return(false);
        }
 public void Dispose()
 {
     RootControl?.Dispose();
 }
 public void Update(GameTime args)
 {
     RootControl.DoUpdate(args);
 }
Esempio n. 9
0
 public void Update(FrameEventArgs args)
 {
     RootControl.DoUpdate(args);
 }
Esempio n. 10
0
 /// <summary>
 /// Loads whole docking layout from the file.
 /// </summary>
 /// <param name="path">Source file path</param>
 /// <param name="setupWindow">Function that creates windows. String argument contains serialized window typename.</param>
 /// <param name="mainWindow">Main window</param>
 /// <returns>True if cannot load data, otherwise false</returns>
 public bool LoadLayout(string path, Func <MasterDockPanel, string, DockWindow> setupWindow, RootControl mainWindow)
 {
     throw new NotImplementedException("Finish loading layout from xml file");
 }
Esempio n. 11
0
 /// <summary>
 /// Saves whole docking layout to the file.
 /// </summary>
 /// <param name="path">Destination file path</param>
 /// <param name="mainWindow">Main window</param>
 /// <returns>True if cannot save data, otherwise false</returns>
 public bool SaveLayout(string path, RootControl mainWindow)
 {
     throw new NotImplementedException("Finish saving layout to xml file");
 }
Esempio n. 12
0
 public EventManager(
     RootControl root,
     InputManager inputManager) : this(root, inputManager, null)
 {
 }
Esempio n. 13
0
 protected override void InitControl(OrientationType orientation)
 {
     MyRootControl = new RootControl(this.Children.Controls);
     MyRootControl.LinearLayoutStrategy.Orientation = orientation;
 }