예제 #1
0
        public static Size ConstrainSize(Size size, SizeConstraints constraints)
        {
            if (constraints == null)
            {
                return(size);
            }

            if (size.Width > constraints.MaxWidth)
            {
                size.Width = constraints.MaxWidth.Value;
            }
            if (size.Height > constraints.MaxHeight)
            {
                size.Height = constraints.MaxHeight.Value;
            }

            if (size.Width < constraints.MinWidth)
            {
                size.Width = constraints.MinWidth;
            }
            if (size.Height < constraints.MinHeight)
            {
                size.Height = constraints.MinHeight;
            }

            return(size);
        }
예제 #2
0
        public void Configure(IApplicationBuilder app)
        {
            System.Net.ServicePointManager.DefaultConnectionLimit = 1024;
            ConfigurationBinder.Bind(Configuration.GetSection("ImageServer"), Conf);

            app.UseOwin(buildFunc =>
            {
                buildFunc(next => RequestId.Middleware(next));
                buildFunc(next => SizeConstraints.Middleware(next));
                buildFunc(next => RequestLogging.Middleware(next, Log));
                buildFunc(next => PerformanceLogging.Middleware(next, Log));
                buildFunc(next => new MonitoringMiddleware(next, HealthCheckAsync).InvokeAsync);
                buildFunc.UseNancy(opt => opt.Bootstrapper = new Bootstrapper(Conf, Log, httpClient));
            });
        }
예제 #3
0
파일: TemplateVM.cs 프로젝트: DavidAlt/ITG
        private void Init()
        {
            // apply a default size
            Width  = 700;
            Height = 700;

            // apply size constraints
            _constraints = new SizeConstraints(600, 2000, 400, 3000);
            Constrained  = true;

            // setup the pages
            _pages.Add(new TemplatePageVM("Resources", this)); // by default will be at index 0
            _pages.Add(new TemplatePageVM("Tab 1", this));
            _currentPage = _pages[1];

            // setup commands
        }
예제 #4
0
        /// <summary>
        /// Reduces the value of maxSize based on the constraints provided. This
        /// will use width/height and maxwidth/maxheight from the constraints object
        /// and return
        /// </summary>
        /// <param name="maxSize"></param>
        /// <param name="constraints"></param>
        /// <returns>The new maximum size of the widget.</returns>
        public static Size ConstrainMaxSize(Size maxSize, SizeConstraints constraints)
        {
            if (constraints == null)
            {
                return(maxSize);
            }

            if (maxSize.Width > constraints.MaxWidth)
            {
                maxSize.Width = constraints.MaxWidth.Value;
            }
            if (maxSize.Height > constraints.MaxHeight)
            {
                maxSize.Height = constraints.MaxHeight.Value;
            }

            return(maxSize);
        }
예제 #5
0
        public void ConstrainMaxSizeWithFixedSizeConstraintTest(
            int initialWidth,
            int initialHeight,
            int maxWidth,
            int maxHeight,
            int expectedMaxWidth,
            int expectedMaxHeight)
        {
            Size initial = new Size(initialWidth, initialHeight);

            SizeConstraints constraints = new SizeConstraints
            {
                MaxWidth  = maxWidth,
                MaxHeight = maxHeight,
            };

            Size result = LayoutMath.ConstrainMaxSize(initial, constraints);

            result.Width.Should().Be(expectedMaxWidth);
            result.Height.Should().Be(expectedMaxHeight);
        }
예제 #6
0
        private void Init()
        {
            // apply a default size
            Width  = 700;
            Height = 700;

            // apply size constraints
            _constraints = new SizeConstraints(600, 2000, 400, 3000);
            Constrained  = true;

            // setup default ItemData
            // A: "N=1|L=V=13:DF=1:PS=1:TP=0:MR=F:BS=1:TWS=0:PB=3:NB=3:ROS=1:PL=0:FB=0:EM=0:CB=2"
            // T: "N=1|L=V=13:DF=1:PS=1:TP=0:MR=T:BS=0:TWS=0:PB=2:NB=0:ROS=1:PL=0:FB=0:EM=0:CB=2:HHL=F"
            //_tabstripItemData.Add(new ObjectIdOption("1"));

            // setup the pages
            _pages.Add(new TemplatePageVM("Resources", this)); // by default will be at index 0
            _pages.Add(new TemplatePageVM("Tab 1", this));
            _currentPage = _pages[1];

            // setup commands
        }
예제 #7
0
 public CanvasItemBase(SizeConstraints constraints)
     : base()
 {
     _constraints = constraints;
     Constrained  = true;
 }