Esempio n. 1
0
        protected SpacePart InitSpace(SpaceName name)
        {
            //only call from ctor?
            SpacePart dockspace = new SpacePart(this, 10, 10, name);

            return(dockspace);
        }
Esempio n. 2
0
            CustomWidgets.EaseBox CreateTinyControlBox(SpaceName name)
            {
                int controllerBoxWH = 10;
                var tinyBox         = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);

                tinyBox.BackColor = PixelFarm.Drawing.Color.Red;
                tinyBox.Tag       = name;
                //add handler for each tiny box

                //---------------------------------------------------------------------

                tinyBox.MouseDrag += (s, e) =>
                {
                    ResizeTargetWithSnapToGrid((SpaceName)tinyBox.Tag, this, e);
                    e.MouseCursorStyle = MouseCursorStyle.Pointer;
                    e.CancelBubbling   = true;
                };
                tinyBox.MouseUp += (s, e) =>
                {
                    if (e.IsDragging)
                    {
                        ResizeTargetWithSnapToGrid2(this, e);
                    }
                    e.MouseCursorStyle = MouseCursorStyle.Default;
                    e.CancelBubbling   = true;
                };
                return(tinyBox);
            }
Esempio n. 3
0
        /// <summary>
        /// Creates a new space.
        /// </summary>
        /// <param name="name">The name of the space-to-be.</param>
        /// <returns>The newly created space.</returns>
        public async Task <ISpace> CreateSpace(SpaceName name)
        {
            var space = _spaceFactory.NewSpace(name);
            await _spaceRepository.Add(space);

            return(space);
        }
Esempio n. 4
0
 internal SpacePart(NinespaceController ownerDockspaceController, int spaceWidth, int spaceHeight, SpaceName docSpacename)
 {
     this.ownerDockspaceController = ownerDockspaceController;
     this.spaceWidth = spaceWidth;
     this.spaceHeight = spaceHeight;
     this.spaceName = docSpacename;
 }
Esempio n. 5
0
        /// <summary>
        /// Creates the page with the given name.
        /// </summary>
        /// <param name="spaceName">Name of the space that the page should be created in.</param>
        /// <param name="pageName">Name of the page to create.</param>
        /// <param name="sourceFile">The file to read the initial page content from.</param>
        /// <returns>Task.</returns>
        public async Task CreatePage(SpaceName spaceName, PageName pageName, FileInfo sourceFile)
        {
            string content = await File.ReadAllTextAsync(sourceFile.FullName);

            var input = new CreatePageInput(spaceName, pageName, content);
            await _mediator.PublishAsync(input);
        }
Esempio n. 6
0
 internal SpacePart(NinespaceController ownerDockspaceController, int spaceWidth, int spaceHeight, SpaceName docSpacename)
 {
     this.ownerDockspaceController = ownerDockspaceController;
     this.spaceWidth  = spaceWidth;
     this.spaceHeight = spaceHeight;
     this.spaceName   = docSpacename;
 }
Esempio n. 7
0
 static SimpleBox CreateSpaceBox(SpaceName name, Color bgcolor)
 {
     int controllerBoxWH = 10;
     SimpleBox spaceBox = new SimpleBox(controllerBoxWH, controllerBoxWH);
     spaceBox.BackColor = bgcolor;
     spaceBox.Tag = name;
     return spaceBox;
 }
Esempio n. 8
0
            static CustomWidgets.EaseBox CreateSpaceBox(SpaceName name, PixelFarm.Drawing.Color bgcolor)
            {
                int controllerBoxWH = 10;
                var tinyBox         = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);

                tinyBox.BackColor = bgcolor;
                tinyBox.Tag       = name;
                return(tinyBox);
            }
Esempio n. 9
0
        static SimpleBox CreateSpaceBox(SpaceName name, Color bgcolor)
        {
            int       controllerBoxWH = 10;
            SimpleBox spaceBox        = new SimpleBox(controllerBoxWH, controllerBoxWH);

            spaceBox.BackColor = bgcolor;
            spaceBox.Tag       = name;
            return(spaceBox);
        }
        public void portlisten()
        {
            System.Net.Sockets.Socket udplistener= new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint local = new IPEndPoint(myip,9090);
            udplistener.Bind(local);

            listening=new Thread(new ThreadStart(
                delegate()
                {
                    while (true)
                    {
                        IPEndPoint i = new IPEndPoint(IPAddress.Any,9090);
                        EndPoint client = (EndPoint)i;
                        byte[] buffer = new byte[1024];
                        int rev = udplistener.ReceiveFrom(buffer, ref client);

                        string 客户端 = System.Text.Encoding.UTF8.GetString(buffer);
                        SpaceName your = isay(客户端);
                        SpaceName my = new SpaceName();
                        if (myspacenamelist.ContainsKey(your.NameHead))
                            my = myspacenamelist[your.NameHead];

                        SpaceName ret = new SpaceName();
                        ret.NameHead = your.NameHead;

                        if (Mirror.Atom.Equal+Mirror.Unicode8.toMirror(client.ToString()) == my["(1983&1&1,###,###)"])
                        {
                            ret.Add("(1983&1&1,###,###)", my["(1983&1&1,###,###)"]);
                            udplistener.SendTo(System.Text.Encoding.UTF8.GetBytes(ret.ToString()), client);
                        }
                        else
                        {
                            foreach (KeyValuePair<string, string> m in my)
                            {
                                foreach (KeyValuePair<string, string> n in your)
                                {
                                    if (n.Value == m.Value)
                                    {
                                        ret.Add("(1983&1&1,###,###)",Mirror.Atom.Equal+Mirror.Unicode8.toMirror( client.ToString()));
                                        goto END;
                                    }
                                }
                            }
                            udplistener.SendTo(System.Text.Encoding.UTF8.GetBytes(ret.ToString()), client);
                            continue;
                            END:
                                {
                                    my["(1983&1&1,###,###)"] = Mirror.Atom.Equal + Mirror.Unicode8.toMirror(client.ToString());
                                    udplistener.SendTo(System.Text.Encoding.UTF8.GetBytes(ret.ToString()), client);
                            }
                        }
                    }
                }
                ));
            listening.Start();
        }
Esempio n. 11
0
        /// <inheritdoc />
        public Task <ISpace> Get(SpaceName name)
        {
            Space space = _context.Spaces.SingleOrDefault(x => x.Name.Equals(name));

            if (space == null)
            {
                throw new SpaceNotFoundException($"The space '{name}' does not exist.");
            }

            return(Task.FromResult <ISpace>(space));
        }
Esempio n. 12
0
        public void New_Space_Is_Empty()
        {
            var entityFactory = new InMemoryEntityFactory();

            // Arrange
            var spaceName = new SpaceName("Demo");

            // Act
            ISpace space = entityFactory.NewSpace(spaceName);

            // Assert
            Assert.Equal(space.Name, spaceName);
            Assert.Empty(space.Pages.GetPageNames());
        }
 public void loadsave()
 {
     myspacenamelist = new SpaceNameDictionary();
     string[] files = System.IO.Directory.GetFiles(root, "*.❣");
     for (int i = 0; i < files.Length; i++)
     {
         string filetext = System.IO.File.ReadAllText(files[i]);
         string filename=new System.IO.FileInfo(files[i]).Name;
         string head = filename.Substring(0, filename.Length - 2);
         string body = filetext.Substring(filetext.IndexOf(head));
         SpaceName sn = new SpaceName(head, body);
         myspacenamelist.Add(sn);
     }
 }
Esempio n. 14
0
        public void portlisten()
        {
            System.Net.Sockets.Socket udplistener= new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint local = new IPEndPoint(myip,213);
            udplistener.Bind(local);

            listening=new Thread(new ThreadStart(
                delegate()
                {
                    while (true)
                    {
                        IPEndPoint i = new IPEndPoint(IPAddress.Any,213);
                        EndPoint client = (EndPoint)i;
                        byte[] buffer = new byte[1024];
                        int rev = udplistener.ReceiveFrom(buffer, ref client);

                        string yousay = System.Text.Encoding.UTF8.GetString(buffer);
                        SpaceName your = isay(yousay);
                        SpaceName my=new SpaceName() ;
                        if(myspacenamelist.ContainsKey(your.NameHead))
                            my = myspacenamelist[your.NameHead];

                        SpaceName ret = new SpaceName();
                        ret.NameHead = your.NameHead;

                        foreach (KeyValuePair<string, string> m in your)
                        {
                            foreach (KeyValuePair<string, string> n in my)
                            {
                                if (m.Key == n.Key)
                                {
                                    if (m.Value[0] == '=' && n.Value[0] == '≡')
                                    {
                                        ret.Add(n.Key, n.Value);
                                    }
                                }
                            }
                        }
                        udplistener.SendTo(System.Text.Encoding.UTF8.GetBytes(ret.ToString()), client);
                    }
                }
                ));
            listening.Start();
        }
Esempio n. 15
0
        CustomWidgets.EaseBox CreateTinyControlBox(SpaceName name)
        {
            int controllerBoxWH = 10;

            CustomWidgets.EaseBox tinyBox = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);
            tinyBox.BackColor = PixelFarm.Drawing.Color.Red;
            tinyBox.Tag       = name;
            //add handler for each tiny box

            tinyBox.MouseDrag += (s, e) =>
            {
                ResizeTargetWithSnapToGrid2((SpaceName)tinyBox.Tag, this, e, e.DiffCapturedX, e.DiffCapturedY);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
                e.CancelBubbling   = true;
            };
            tinyBox.MouseUp += (s, e) =>
            {
                if (e.IsDragging)
                {
                    ResizeTargetWithSnapToGridWhenDragRelease(this, e);
                }
                //if (e.IsDragging)
                //{
                //    //var targetBox = this.TargetBox;
                //    //var newRect = new Rectangle(targetBox.Left, targetBox.Top, targetBox.Width, targetBox.Height);

                //    //this.DesignBoardModule.HistoryRecordDzElementNewBounds(
                //    //  targetBox,
                //    //  this.beginRect,
                //    //  newRect);
                //    //this.beginRect = newRect;

                //    //ResizeTargetWithSnapToGridWhenMouseUp(this, e);
                //}
                e.MouseCursorStyle = MouseCursorStyle.Default;
                e.CancelBubbling   = true;
            };
            return(tinyBox);
        }
Esempio n. 16
0
        /// <summary>
        /// Looks up all existing directories that we can possibly use as spaces, contained within our root path.
        /// </summary>
        /// <returns>A collection of all existing spaces.</returns>
        public Task <SpacesCollection> All()
        {
            SpacesCollection spaces = new SpacesCollection();

            foreach (DirectoryInfo directory in _physicalRootDirectory.GetDirectories())
            {
                if (!Repository.IsValid(directory.FullName))
                {
                    continue;
                }

                try
                {
                    var spaceName = new SpaceName(directory.Name);
                    spaces.Add(spaceName);
                }
                catch (InvalidSpaceNameException)
                {
                    // ignore this folder entirely
                }
            }

            return(Task.FromResult(spaces));
        }
Esempio n. 17
0
        /// <summary>
        /// Retrieves the space with the given name.
        /// </summary>
        /// <remarks>The original space name passed to this method, and the name of the returned space, may differ on case-insensitive file systems.</remarks>
        /// <param name="name">The name of the space to retrieve.</param>
        /// <returns>The space that was retrieved.</returns>
        /// <exception cref="SpaceNotFoundException">Thrown when the directory does not exist or is not a valid git repository.</exception>
        public Task <ISpace> Get(SpaceName name)
        {
            #region Windows: Try to retrieve the name with correct case sensitivity
            var    fsInfo     = _physicalRootDirectory.GetFileSystemInfos(name.ToString());
            string folderName = name.ToString();
            if (fsInfo.Length == 1)
            {
                folderName = fsInfo[0].Name;
            }
            #endregion

            DirectoryInfo spaceDirectory = new DirectoryInfo(Path.Combine(_physicalRootDirectory.FullName, folderName));
            if (!spaceDirectory.Exists || !Repository.IsValid(spaceDirectory.FullName))
            {
                throw new SpaceNotFoundException($"Space '{name}' does not exist.");
            }

            var space = new Space(new SpaceName(spaceDirectory.Name))
            {
                BaseDirectory = spaceDirectory,
            };

            return(Task.FromResult <ISpace>(space));
        }
Esempio n. 18
0
 /// <summary>
 /// Adds a new space name.
 /// </summary>
 /// <param name="space">The space name to add.</param>
 public void Add(SpaceName space) => _spaceNames.Add(space);
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Page"/> class.
 /// </summary>
 /// <param name="space">Space this page exists in.</param>
 /// <param name="name">Name of the page.</param>
 public Page(SpaceName space, PageName name)
 {
     Space          = space;
     Name           = name;
     CurrentVersion = new UnknownVersion();
 }
Esempio n. 20
0
            CustomWidgets.EaseBox CreateTinyControlBox(SpaceName name)
            {
                int controllerBoxWH = 10;
                var tinyBox = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);
                tinyBox.BackColor = PixelFarm.Drawing.Color.Red;
                tinyBox.Tag = name;
                //add handler for each tiny box

                //---------------------------------------------------------------------

                tinyBox.MouseDrag += (s, e) =>
                {
                    ResizeTargetWithSnapToGrid((SpaceName)tinyBox.Tag, this, e);
                    e.MouseCursorStyle = MouseCursorStyle.Pointer;
                    e.CancelBubbling = true;
                };
                tinyBox.MouseUp += (s, e) =>
                {
                    if (e.IsDragging)
                    {
                        ResizeTargetWithSnapToGrid2(this, e);
                    }
                    e.MouseCursorStyle = MouseCursorStyle.Default;
                    e.CancelBubbling = true;
                };
                return tinyBox;
            }
Esempio n. 21
0
 /// <summary>
 /// Creates the space with the given name.
 /// </summary>
 /// <param name="name">The name of the new space to create.</param>
 /// <returns>Task.</returns>
 public async Task CreateSpace(SpaceName name)
 {
     var input = new CreateSpaceInput(name);
     await _mediator.PublishAsync(input);
 }
        void ResizeTargetWithSnapToGrid2(SpaceName tinyBoxSpaceName, UIControllerBox controllerBox, UIMouseEventArgs e, int dx, int dy)
        {
            //sample move with snap to grid
            Point pos = controllerBox.Position;
            int newX = pos.X + dx;// e.XDiff;
            int newY = pos.Y + dy;// e.YDiff;
            //snap to gridsize =5;
            //find nearest snap x 
            int gridSize = 5;
            float halfGrid = (float)gridSize / 2f;
            int nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
            int nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;
            int xdiff = nearestX - pos.X;
            int ydiff = nearestY - pos.Y;
            int diffX = 0, diffY = 0;
            var targetBox = controllerBox.TargetBox;
            if (targetBox != null)
            {
                var targetBoxLocation = targetBox.GetGlobalLocation();
                diffX = this.Left - targetBoxLocation.X;
                diffY = this.Top - targetBoxLocation.Y;
            }


            switch (tinyBoxSpaceName)
            {
                case SpaceName.LeftTop:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top + ydiff);
                            controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height - ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                    targetBox.Top + diffY + 5,
                                    controllerBox.Width - 10,
                                    controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
                case SpaceName.RightTop:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetLocation(controllerBox.Left, controllerBox.Top + ydiff);
                            controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height - ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                   targetBox.Top + diffY + 5,
                                   controllerBox.Width - 10,
                                   controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
                case SpaceName.RightBottom:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height + ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                   targetBox.Top + diffY + 5,
                                   controllerBox.Width - 10,
                                   controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
                case SpaceName.LeftBottom:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top);
                            controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height + ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                   targetBox.Top + diffY + 5,
                                   controllerBox.Width - 10,
                                   controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
            }
        }
        CustomWidgets.EaseBox CreateTinyControlBox(SpaceName name)
        {
            int controllerBoxWH = 10;
            CustomWidgets.EaseBox tinyBox = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);
            tinyBox.BackColor = PixelFarm.Drawing.Color.Red;
            tinyBox.Tag = name;
            //add handler for each tiny box 

            tinyBox.MouseDrag += (s, e) =>
            {
                ResizeTargetWithSnapToGrid2((SpaceName)tinyBox.Tag, this, e, e.DiffCapturedX, e.DiffCapturedY);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
                e.CancelBubbling = true;
            };
            tinyBox.MouseUp += (s, e) =>
            {
                if (e.IsDragging)
                {
                    ResizeTargetWithSnapToGridWhenDragRelease(this, e);
                }
                //if (e.IsDragging)
                //{
                //    //var targetBox = this.TargetBox;
                //    //var newRect = new Rectangle(targetBox.Left, targetBox.Top, targetBox.Width, targetBox.Height);

                //    //this.DesignBoardModule.HistoryRecordDzElementNewBounds(
                //    //  targetBox,
                //    //  this.beginRect,
                //    //  newRect);
                //    //this.beginRect = newRect;

                //    //ResizeTargetWithSnapToGridWhenMouseUp(this, e);
                //}
                e.MouseCursorStyle = MouseCursorStyle.Default;
                e.CancelBubbling = true;
            };
            return tinyBox;
        }
Esempio n. 24
0
 static void ResizeTargetWithSnapToGrid(SpaceName tinyBoxSpaceName, UIControllerBox controllerBox, UIMouseEventArgs e)
 {
     //sample move with snap to grid
     Point pos = controllerBox.Position;
     int newX = pos.X + e.XDiff;
     int newY = pos.Y + e.YDiff;
     //snap to gridsize =5;
     //find nearest snap x 
     int gridSize = 5;
     float halfGrid = (float)gridSize / 2f;
     int nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
     int nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;
     int xdiff = nearestX - pos.X;
     int ydiff = nearestY - pos.Y;
     switch (tinyBoxSpaceName)
     {
         case SpaceName.LeftTop:
             {
                 if (xdiff != 0 || ydiff != 0)
                 {
                     controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top + ydiff);
                     controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height - ydiff);
                     var targetBox = controllerBox.TargetBox;
                     if (targetBox != null)
                     {
                         //move target box too 
                         targetBox.SetBounds(controllerBox.Left + 5,
                             controllerBox.Top + 5,
                             controllerBox.Width - 10,
                             controllerBox.Height - 10);
                     }
                 }
             }
             break;
         case SpaceName.RightTop:
             {
                 if (xdiff != 0 || ydiff != 0)
                 {
                     controllerBox.SetLocation(controllerBox.Left, controllerBox.Top + ydiff);
                     controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height - ydiff);
                     var targetBox = controllerBox.TargetBox;
                     if (targetBox != null)
                     {
                         //move target box too 
                         targetBox.SetBounds(controllerBox.Left + 5,
                             controllerBox.Top + 5,
                             controllerBox.Width - 10,
                             controllerBox.Height - 10);
                     }
                 }
             }
             break;
         case SpaceName.RightBottom:
             {
                 if (xdiff != 0 || ydiff != 0)
                 {
                     controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height + ydiff);
                     var targetBox = controllerBox.TargetBox;
                     if (targetBox != null)
                     {
                         //move target box too 
                         targetBox.SetBounds(controllerBox.Left + 5,
                             controllerBox.Top + 5,
                             controllerBox.Width - 10,
                             controllerBox.Height - 10);
                     }
                 }
             }
             break;
         case SpaceName.LeftBottom:
             {
                 if (xdiff != 0 || ydiff != 0)
                 {
                     controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top);
                     controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height + ydiff);
                     var targetBox = controllerBox.TargetBox;
                     if (targetBox != null)
                     {
                         //move target box too 
                         targetBox.SetBounds(controllerBox.Left + 5,
                             controllerBox.Top + 5,
                             controllerBox.Width - 10,
                             controllerBox.Height - 10);
                     }
                 }
             }
             break;
     }
 }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreatePageInput"/> class.
 /// </summary>
 /// <param name="spaceName">Name of the space that the page should be created in.</param>
 /// <param name="pageName">Name of the page to create.</param>
 /// <param name="content">Initial content of the newly created page.</param>
 public CreatePageInput(SpaceName spaceName, PageName pageName, string content)
 {
     SpaceName = spaceName;
     PageName  = pageName;
     Content   = content;
 }
Esempio n. 26
0
        void ResizeTargetWithSnapToGrid2(SpaceName tinyBoxSpaceName, UIControllerBox controllerBox, UIMouseEventArgs e, int dx, int dy)
        {
            //sample move with snap to grid
            Point pos  = controllerBox.Position;
            int   newX = pos.X + dx; // e.XDiff;
            int   newY = pos.Y + dy; // e.YDiff;
            //snap to gridsize =5;
            //find nearest snap x
            int   gridSize = 5;
            float halfGrid = (float)gridSize / 2f;
            int   nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
            int   nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;

            int xdiff = nearestX - pos.X;
            int ydiff = nearestY - pos.Y;


            int diffX = 0, diffY = 0;
            var targetBox = controllerBox.TargetBox;

            if (targetBox != null)
            {
                var targetBoxLocation = targetBox.GetGlobalLocation();
                diffX = this.Left - targetBoxLocation.X;
                diffY = this.Top - targetBoxLocation.Y;
            }


            switch (tinyBoxSpaceName)
            {
            case SpaceName.LeftTop:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top + ydiff);
                    controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height - ydiff);


                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;

            case SpaceName.RightTop:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetLocation(controllerBox.Left, controllerBox.Top + ydiff);
                    controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height - ydiff);


                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;

            case SpaceName.RightBottom:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height + ydiff);

                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;

            case SpaceName.LeftBottom:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top);
                    controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height + ydiff);


                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;
            }
        }
            static void ResizeTargetWithSnapToGrid(SpaceName tinyBoxSpaceName, UIControllerBox controllerBox, int dx, int dy)
            {
                //sample move with snap to grid
                Point pos  = controllerBox.Position;
                int   newX = pos.X + dx;
                int   newY = pos.Y + dy;
                //snap to gridsize =5;
                //find nearest snap x
                int   gridSize = 5;
                float halfGrid = (float)gridSize / 2f;
                int   nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
                int   nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;

                int xdiff = nearestX - pos.X;
                int ydiff = nearestY - pos.Y;

                switch (tinyBoxSpaceName)
                {
                case SpaceName.LeftTop:
                {
                    if (xdiff != 0 || ydiff != 0)
                    {
                        controllerBox.SetBounds(controllerBox.Left + xdiff, controllerBox.Top + ydiff,
                                                controllerBox.Width - xdiff, controllerBox.Height - ydiff);

                        var targetBox = controllerBox.TargetBox;
                        if (targetBox != null)
                        {
                            //move target box too
                            targetBox.SetBounds(targetBox.Left + xdiff, targetBox.Top + ydiff,
                                                targetBox.Width - xdiff, targetBox.Height - ydiff);
                        }
                    }
                } break;

                case SpaceName.RightTop:
                {
                    if (xdiff != 0 || ydiff != 0)
                    {
                        controllerBox.SetBounds(controllerBox.Left, controllerBox.Top + ydiff,
                                                controllerBox.Width + xdiff, controllerBox.Height - ydiff);

                        var targetBox = controllerBox.TargetBox;
                        if (targetBox != null)
                        {
                            targetBox.SetBounds(targetBox.Left, targetBox.Top + ydiff,
                                                targetBox.Width + xdiff, targetBox.Height - ydiff);
                        }
                    }
                } break;

                case SpaceName.RightBottom:
                {
                    if (xdiff != 0 || ydiff != 0)
                    {
                        controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height + ydiff);
                        var targetBox = controllerBox.TargetBox;
                        if (targetBox != null)
                        {
                            //move target box too
                            targetBox.SetSize(targetBox.Width + xdiff, targetBox.Height + ydiff);
                        }
                    }
                } break;

                case SpaceName.LeftBottom:
                {
                    if (xdiff != 0 || ydiff != 0)
                    {
                        controllerBox.SetBounds(controllerBox.Left + xdiff, controllerBox.Top,
                                                controllerBox.Width - xdiff, controllerBox.Height + ydiff);

                        var targetBox = controllerBox.TargetBox;
                        if (targetBox != null)
                        {
                            //move target box too
                            targetBox.SetBounds(targetBox.Left + xdiff, targetBox.Top,
                                                targetBox.Width - xdiff, targetBox.Height + ydiff);
                        }
                    }
                } break;
                }
            }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Space"/> class.
 /// </summary>
 /// <param name="name">The name of the space.</param>
 public Space(SpaceName name)
 {
     Name = name;
 }
 static CustomWidgets.EaseBox CreateSpaceBox(SpaceName name, PixelFarm.Drawing.Color bgcolor)
 {
     int controllerBoxWH = 10;
     var tinyBox = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);
     tinyBox.BackColor = bgcolor;
     tinyBox.Tag = name;
     return tinyBox;
 }
Esempio n. 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateSpaceInput"/> class.
 /// </summary>
 /// <param name="spaceName">The name of the space to create.</param>
 public CreateSpaceInput(SpaceName spaceName)
 {
     SpaceName = spaceName;
 }
Esempio n. 31
0
 /// <inheritdoc/>
 public ISpace NewSpace(SpaceName name) => new Entities.Space(name);
 protected SpacePart InitSpace(SpaceName name)
 {
     //only call from ctor?
     SpacePart dockspace = new SpacePart(this, 10, 10, name);
     return dockspace;
 }