Ejemplo n.º 1
0
        protected internal virtual IHtmlString RenderView(ViewPosition viewPosition)
        {
            try
            {
                Func <IHtmlString> renderView = () => this.RenderView(viewPosition.ViewName, PageContext.GetPositionViewData(viewPosition.PagePositionId), viewPosition.ToParameterDictionary(), false);
                if (viewPosition.EnabledCache)
                {
                    var cacheKey = string.Format("View OutputCache - Full page name:{0};Raw request url:{1};PagePositionId:{2};ViewName:{3};LayoutPositionId:{4}"
                                                 , PageContext.PageRequestContext.Page.FullName, PageContext.ControllerContext.HttpContext.Request.RawUrl, viewPosition.PagePositionId, viewPosition.ViewName, viewPosition.LayoutPositionId);
                    var cacheItemPolicy = viewPosition.OutputCache.ToCachePolicy();
                    return(this.PageContext.PageRequestContext.Site.ObjectCache().GetCache <IHtmlString>(cacheKey,
                                                                                                         renderView,
                                                                                                         cacheItemPolicy));
                }
                else
                {
                    return(renderView());
                }
            }
            catch (Exception e)
            {
                if (viewPosition.SkipError)
                {
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    return(new HtmlString(""));
                }

                throw;
            }
        }
Ejemplo n.º 2
0
 private void SaveViewPosition()
 {
     _savedViewPosition = new ViewPosition {
         CaretPosition = GetCaretPosition(),
         ViewportTop   = DiskBuffer.GetFirstView()?.ViewportTop
     };
 }
Ejemplo n.º 3
0
 public bool UpdatePostion(ViewPosition position)
 {
     return(Function(context =>
     {
         return Update(Mapper.Map <Position>(position));
     }));
 }
Ejemplo n.º 4
0
        private void RestoreViewPosition()
        {
            var textView = DiskBuffer.GetFirstView();

            if (textView == null)
            {
                _savedViewPosition = null;
                return;
            }

            if (_savedViewPosition?.CaretPosition != null)
            {
                var caretPosition = GetCaretPosition();
                if (caretPosition.HasValue && caretPosition.Value != _savedViewPosition.CaretPosition)
                {
                    textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, _savedViewPosition.CaretPosition.Value));
                }
            }

            if (_savedViewPosition?.ViewportTop != null)
            {
                textView.ViewScroller.ScrollViewportVerticallyByPixels(textView.ViewportTop - _savedViewPosition.ViewportTop.Value);
            }

            _savedViewPosition = null;
        }
Ejemplo n.º 5
0
        protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
        {
            var    positionType = controllerContext.HttpContext.Request["PositionType"];
            object model        = null;

            switch (positionType)
            {
            case "View":
                model = new ViewPosition();
                break;

            case "Module":
                model = new ModulePosition();
                break;

            case "Content":
                model = new HtmlPosition();
                break;

            default:
                break;
            }
            bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, model.GetType());
            return(model);
        }
Ejemplo n.º 6
0
 public bool AddPostion(ViewPosition position)
 {
     return(Function(context =>
     {
         return Create(Mapper.Map <Position>(position));
     }));
 }
Ejemplo n.º 7
0
    public void SetPerspective(ViewPosition newPosition, bool animate = true)
    {
        if (_perspectiveSwitchRoutine != null)
        {
            StopCoroutine(_perspectiveSwitchRoutine);
        }

        _perspectiveSwitchRoutine = StartCoroutine(SwitchPerspectiveRoutine(newPosition, animate));
    }
Ejemplo n.º 8
0
 public virtual ActionResult ProcessView(ViewPosition pos)
 {
     if (IsGet())
     {
         var manager = ServiceFactory.GetService <ViewManager>();
         ViewData["Policys"] = Enum.GetNames(typeof(ExpirationPolicy));
         return(View(manager.GetNamespace(Site)));
     }
     else
     {
         pos.Parameters = ParseViewParameters(pos.Parameters);
         return(Json(new { html = new PageDesignViewContent(pos).ToHtmlString() }));
     }
 }
Ejemplo n.º 9
0
 public PageDesignViewContent(ViewPosition pos)
     : base(pos)
 {
     this.Parameter.Add("ViewName", PageDesignContent.Code(pos.ViewName));
     this.Parameter.Add("SkipError", pos.SkipError.ToString().ToLower());
     if (pos.OutputCache != null)
     {
         var outputCacheJson = new
         {
             EnableCaching    = pos.OutputCache.EnableCaching,
             Duration         = pos.OutputCache.Duration,
             ExpirationPolicy = pos.OutputCache.ExpirationPolicy.ToString()
         };
         var serializer            = new JavaScriptSerializer();
         var outputCacheJsonString = serializer.Serialize(outputCacheJson);
         this.Parameter.Add("OutputCache", PageDesignContent.Code(outputCacheJsonString));
     }
     if (pos.Parameters != null && pos.Parameters.Count > 0)
     {
         var parameters = new List <object>();
         pos.Parameters.ForEach((p) =>
         {
             var value = string.Empty;
             if (p.Value != null)
             {
                 value = p.Value.ToString();
                 if (p.DataType == DataType.DateTime)
                 {
                     var date = ((DateTime)p.Value);
                     value    = date.ToLocalTime().ToShortDateString();
                 }
             }
             parameters.Add(new
             {
                 Name     = p.Name,
                 DataType = p.DataType.ToString(),
                 Value    = value
             });
         });
         var serializer     = new JavaScriptSerializer();
         var parametersJson = serializer.Serialize(parameters);
         this.Parameter.Add("Parameters", PageDesignContent.Code(parametersJson));
     }
 }
Ejemplo n.º 10
0
        public ControllerColck(ColckWindowView View)
        {
            this.View           = View;
            colck.SecondChange += SecondChangeHandler;

            colck.MinuteChange      += MinuteChangeHandler;
            colck.HourChange        += HourChangeHandler;
            colck.YearChange        += YearChangeHandler;
            colck.DayChange         += DayChangeHandler;
            colck.MonthChange       += MonthChangeHandler;;
            colck.MillisecondChange += MillisecondChangeEventHandler;

            network.Update += NetworkChangeHandler;

            menu = new MyMenu(Configure);
            viewGrid.ContextMenu = menu;
            AddMenuEvent();
            _thisViewPosition = ViewPosition.InitialValue;
        }
Ejemplo n.º 11
0
        public virtual ActionResult ViewEntry(string viewName)
        {
            viewName = Server.UrlDecode(viewName);
            var viewPosition = new ViewPosition()
            {
                LayoutPositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5),
                ViewName         = viewName,
                PagePositionId   = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5)
            };
            //pageUrl: product/detail/product1
            var rawPage = new Page(Site, "____VisitViewPage_____")
            {
                IsDummy = false
            };

            rawPage.PagePositions.Add(viewPosition);

            var requestUrl = "/";

            var pageRequestContext = new PageRequestContext(this.ControllerContext, FrontHttpRequest.RawSite, FrontHttpRequest.Site, rawPage, rawPage,
                                                            FrontHttpRequest.RequestChannel, requestUrl);

            Page_Context.Current.InitContext(pageRequestContext, ControllerContext);

            var actionResult = Page_Context.Current.ExecutePlugins();

            if (actionResult != null)
            {
                return(actionResult);
            }

            Page_Context.Current.ExecuteDataRules();

            var viewMock = new ViewMock()
            {
                ViewData = new ViewDataDictionary(ViewData)
            };
            ViewContext viewContext = new ViewContext(this.ControllerContext, viewMock, ViewData, this.TempData, Response.Output);

            HtmlHelper html = new HtmlHelper(viewContext, viewMock);

            return(Content(html.FrontHtml().RenderView(viewPosition).ToString()));
        }
Ejemplo n.º 12
0
        protected virtual IHtmlString RenderView(ViewPosition viewPosition)
        {
            string cacheKey = null;
            var    site     = PageContext.PageRequestContext.Site;

            if (viewPosition.EnabledCache)
            {
                cacheKey = GetOutputCacheKey(PageContext.ControllerContext.HttpContext, PageContext.PageRequestContext.Page, viewPosition);
                var outputCache = PageContext.PageRequestContext.Site.ObjectCache().Get(cacheKey);
                if (outputCache != null)
                {
                    return(new HtmlString(outputCache.ToString()));
                }
            }
            var htmlString = RenderView(viewPosition.ViewName, Page_Context.Current.GetPositionViewData(viewPosition.PagePositionId), viewPosition.ToParameterDictionary(), false);

            if (!string.IsNullOrEmpty(cacheKey))
            {
                PageContext.PageRequestContext.Site.ObjectCache().Add(cacheKey, htmlString, viewPosition.OutputCache.ToCachePolicy());
            }

            return(htmlString);
        }
Ejemplo n.º 13
0
 private void CalculationViewPosition()
 {
     if (View.Dispatcher.CheckAccess())
     {
         var thisPoint = View.Left - View.Width / 2;
         var core      = (View.WindowWidth - View.Width) / 2 - View.Width;
         if (thisPoint >= core)//左
         {
             var edgePoint = View.WindowWidth - View.Width - viewGrid.Width / 2;
             if (thisPoint >= edgePoint)
             {
                 _thisViewPosition = ViewPosition.LetfEdge;
             }
             else
             {
                 _thisViewPosition = ViewPosition.Letf;
             }
         }
         else  //右边
         {
             var edgePoint = -viewGrid.Width - 50;
             if (thisPoint <= edgePoint)
             {
                 _thisViewPosition = ViewPosition.RightEdge;
             }
             else
             {
                 _thisViewPosition = ViewPosition.Right;
             }
         }
     }
     else
     {
         CalculationPosition Calculation = CalculationViewPosition;
         View.Dispatcher.Invoke(Calculation);
     }
 }
Ejemplo n.º 14
0
    public IEnumerator SwitchPerspectiveRoutine(ViewPosition newPosition, bool animate)
    {
        var target = newPosition == ViewPosition.FirstPerson ? firstPersonCamPositionMarker : thirdPersonCamPositionMarker;

        var targetPosition = target.localPosition;
        var startPosition  = CachedTransform.localPosition;
        var elapsedSeconds = 0f;
        var duration       = animate ? perspectiveSwitchDurationSeconds : 0f;

        _currentViewPos = newPosition;

        while (elapsedSeconds < duration && duration > 0f)
        {
            elapsedSeconds += Time.deltaTime;
            CachedTransform.localPosition = Vector3.Lerp(startPosition, targetPosition, elapsedSeconds / duration);
            yield return(null);
        }

        CachedTransform.localPosition = targetPosition;

        camManagerClient.CanShake = newPosition == ViewPosition.FirstPerson;

        _perspectiveSwitchRoutine = null;
    }
Ejemplo n.º 15
0
        // public method
        public static List <PagePosition> ParsePagePositions(string clientJson)
        {
            clientJson = HttpUtility.UrlDecode(clientJson);

            var positions = new List <PagePosition>();
            var list      = ParseJson <List <Dictionary <string, object> > >(clientJson);

            foreach (var item in list)
            {
                PagePosition pos = null;
                var          t   = item.Str("Type");
                if (t == PageDesignViewContent.TypeKey)
                {
                    pos = new ViewPosition()
                    {
                        ViewName    = item.Str("ViewName"),
                        Parameters  = ParseViewParameters(item.Str("Parameters")),
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                else if (t == PageDesignModuleContent.TypeKey)
                {
                    pos = new ModulePosition()
                    {
                        ModuleName = item.Str("ModuleName"),
                        Exclusive  = (item.Str("Exclusive") == "true"),
                        Entry      = ParseModuleEntry(item.Str("EntryAction"), item.Str("EntryController"))
                    };
                }
                else if (t == PageDesignFolderContent.TypeKey)
                {
                    pos = new ContentPosition()
                    {
                        Type     = ParseEnum <ContentPositionType>(item.Str("ContentPositionType")),
                        DataRule = ParseJson <FolderDataRule>(item.Str("DataRule"))
                    };
                }
                else if (t == PageDesignHtmlContent.TypeKey)
                {
                    pos = new HtmlPosition()
                    {
                        Html = item.Str("Html")
                    };
                }
                else if (t == PageDesignHtmlBlockContent.TypeKey)
                {
                    pos = new HtmlBlockPosition()
                    {
                        BlockName = item.Str("BlockName")
                    };
                }
                // add
                if (pos != null)
                {
                    pos.LayoutPositionId = item.Str("LayoutPositionId");
                    pos.PagePositionId   = item.Str("PagePositionId");
                    pos.Order            = item.Int("Order");
                    positions.Add(pos);
                }
            }
            // ret
            return(positions);
        }
Ejemplo n.º 16
0
        public void SetViewPosition(ViewPosition position)
        {
            UIAnchor.Side side      = UIAnchor.Side.Center;
            int           widthAdd  = 0;
            int           heightAdd = 0;

            if (this.position != position)
            {
                switch (position)
                {
                case ViewPosition.TopLeft:
                    side      = UIAnchor.Side.TopLeft;
                    widthAdd  = Width / 2;
                    heightAdd = -Height / 2;
                    break;

                case ViewPosition.Top:
                    side      = UIAnchor.Side.Top;
                    heightAdd = -Height / 2;
                    break;

                case ViewPosition.TopRight:
                    side      = UIAnchor.Side.TopRight;
                    widthAdd  = -Width / 2;
                    heightAdd = -Height / 2;
                    break;

                case ViewPosition.Left:
                    side     = UIAnchor.Side.Left;
                    widthAdd = Width / 2;
                    break;

                case ViewPosition.Center:
                    break;

                case ViewPosition.Right:
                    side     = UIAnchor.Side.Right;
                    widthAdd = -Width / 2;
                    break;

                case ViewPosition.BottomLeft:
                    side      = UIAnchor.Side.BottomLeft;
                    widthAdd  = Width / 2;
                    heightAdd = Height / 2;
                    break;

                case ViewPosition.Bottom:
                    side      = UIAnchor.Side.Bottom;
                    heightAdd = Height / 2;
                    break;

                case ViewPosition.BottomRight:
                    side      = UIAnchor.Side.BottomRight;
                    widthAdd  = -Width / 2;
                    heightAdd = Height / 2;
                    break;
                }

                if (uiAnchor != null)
                {
                    uiAnchor.side = side;
                }

                if (uiPanel != null)
                {
                    uiPanel.transform.localPosition += new Vector3(widthAdd, heightAdd, 0);
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Скорректировать скроллбары и их значения
        /// </summary>
        public void CorrectScrolls(ViewPosition viewPos)
        {
            this.SetScrollParams(_bscanLength, _maxAscanLength);

            if (viewPos == ViewPosition.End) // Переместиться в конец профиля
                hScrollBar1.Value = PictureCoords.Instance.BscanLenMinusWidthPt <= 0 ? 0 : PictureCoords.Instance.BscanLenMinusWidthPt;
        }
Ejemplo n.º 18
0
        private static string GetOutputCacheKey(HttpContextBase httpContext, Page page, ViewPosition viewPosition)
        {
            var cacheKey = string.Format("View OutputCache - Full page name:{0};Raw request url:{1};PagePositionId:{2};ViewName:{3};LayoutPositionId:{4}"
                                         , page.FullName, httpContext.Request.RawUrl, viewPosition.PagePositionId, viewPosition.ViewName, viewPosition.LayoutPositionId);

            return(cacheKey);
        }
Ejemplo n.º 19
0
 public IActionResult GetUpdatePostion(ViewPosition position)
 {
     return(Ok(_postionsService.UpdatePostion(position)));
 }
Ejemplo n.º 20
0
        // public method
        public static List <PagePosition> ParsePagePositions(string clientJson)
        {
            clientJson = HttpUtility.UrlDecode(clientJson);

            var positions = new List <PagePosition>();
            var list      = ParseJson <List <Dictionary <string, object> > >(clientJson);

            foreach (var item in list)
            {
                PagePosition pos = null;
                var          t   = item.Str("Type");
                if (t == PageDesignViewContent.TypeKey)
                {
                    bool skipError = false;
                    bool.TryParse(item.Str("SkipError"), out skipError);
                    pos = new ViewPosition()
                    {
                        ViewName    = item.Str("ViewName"),
                        SkipError   = skipError,
                        Parameters  = ParseViewParameters(item.Str("Parameters")),
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                else if (t == PageDesignModuleContent.TypeKey)
                {
                    bool skipError = false;
                    bool.TryParse(item.Str("SkipError"), out skipError);
                    pos = new ModulePosition()
                    {
                        ModuleName = item.Str("ModuleName"),
                        SkipError  = skipError,
                        Exclusive  = (item.Str("Exclusive") == "true"),
                        Entry      = ParseModuleEntry(item)
                    };
                }
                else if (t == PageDesignFolderContent.TypeKey)
                {
                    pos = new ContentPosition()
                    {
                        Type     = ParseEnum <ContentPositionType>(item.Str("ContentPositionType")),
                        DataRule = ParseJson <FolderDataRule>(item.Str("DataRule"))
                    };
                }
                else if (t == PageDesignHtmlContent.TypeKey)
                {
                    pos = new HtmlPosition()
                    {
                        Html = item.Str("Html")
                    };
                }
                else if (t == PageDesignHtmlBlockContent.TypeKey)
                {
                    pos = new HtmlBlockPosition()
                    {
                        BlockName = item.Str("BlockName")
                    };
                }
                else if (t == PageDesignProxyContent.TypeKey)
                {
                    pos = new ProxyPosition()
                    {
                        Host        = item.Str("Host"),
                        RequestPath = item.Str("RequestPath"),
                        NoProxy     = item.Str("NoProxy") == "true",
                        //ProxyStylesheet = item.Str("ProxyStylesheet") == "true",
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                // add
                if (pos != null)
                {
                    pos.LayoutPositionId = item.Str("LayoutPositionId");
                    pos.PagePositionId   = item.Str("PagePositionId");
                    pos.Order            = item.Int("Order");
                    positions.Add(pos);
                }
            }
            // ret
            return(positions);
        }
Ejemplo n.º 21
0
            public void Capture()
            {
                if (_viewer.TotalNumberOfLines <= 1)
                {
                    return;
                }

                // store the previous view position
                var currentViewPosition = new ViewPosition
                {
                    ActiveLineNum      = null,
                    FirstLine          = _viewer.GetLineText(0),
                    TotalNumberOfLines = _viewer.TotalNumberOfLines,
                    CaretPosition      = _viewer.TextEditor.ActiveTextAreaControl.Caret.Position,
                    FirstVisibleLine   = _viewer.FirstVisibleLine
                };

                currentViewPosition.CaretVisible = currentViewPosition.CaretPosition.Line >= currentViewPosition.FirstVisibleLine &&
                                                   currentViewPosition.CaretPosition.Line < currentViewPosition.FirstVisibleLine + _viewer.TextEditor.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount;

                if (_viewer.TextEditor.ShowLineNumbers)
                {
                    // a diff was displayed
                    _currentViewPosition = currentViewPosition;
                    return;
                }

                int initialActiveLine = currentViewPosition.CaretVisible ?
                                        currentViewPosition.CaretPosition.Line :
                                        currentViewPosition.FirstVisibleLine;

                // search downwards for a code line, i.e. a line with line numbers
                int activeLine = initialActiveLine;

                while (activeLine < currentViewPosition.TotalNumberOfLines && currentViewPosition.ActiveLineNum == null)
                {
                    SetActiveLineNum(activeLine);
                    ++activeLine;
                }

                // if none found, search upwards
                activeLine = initialActiveLine - 1;
                while (activeLine >= 0 && currentViewPosition.ActiveLineNum == null)
                {
                    SetActiveLineNum(activeLine);
                    --activeLine;
                }

                _currentViewPosition = currentViewPosition;
                return;

                void SetActiveLineNum(int line)
                {
                    currentViewPosition.ActiveLineNum = _viewer._lineNumbersControl.GetLineInfo(line);
                    if (currentViewPosition.ActiveLineNum == null)
                    {
                        return;
                    }

                    if (currentViewPosition.ActiveLineNum.LeftLineNumber == DiffLineInfo.NotApplicableLineNum &&
                        currentViewPosition.ActiveLineNum.RightLineNumber == DiffLineInfo.NotApplicableLineNum)
                    {
                        currentViewPosition.ActiveLineNum = null;
                    }
                }
            }
Ejemplo n.º 22
0
 public IActionResult GetAddPostion(ViewPosition position)
 {
     return(Ok(_postionsService.AddPostion(position)));
 }