protected bool ValidateOrReplaceViewSite(ref ViewSite viewSite, WindowProfileValidationContext context)
        {
            if (viewSite.Parent != null)
            {
                return(false);
            }
            FloatSite floatSite = viewSite as FloatSite;

            if (floatSite != null)
            {
                if (floatSite.Children.Count == 0)
                {
                    return(false);
                }
                bool flag = this.ValidateOrReplaceFloatSite(ref floatSite, context);
                viewSite = (ViewSite)floatSite;
                return(flag);
            }
            MainSite mainSite = viewSite as MainSite;

            if (mainSite == null)
            {
                return(this.ValidateOrReplaceCustomViewSite(ref viewSite, context));
            }
            context.MainSites.Add(mainSite);
            bool flag1 = this.ValidateOrReplaceMainSite(ref mainSite, context);

            viewSite = (ViewSite)mainSite;
            return(flag1);
        }
Example #2
0
        public ActionResult Days(int SiteCode = -1, int YYYY = -1, int MM = -1, int DD = -1)
        {
            DateTime currDate;

            try
            {
                currDate = new DateTime(YYYY, MM, DD);
            }
            catch
            {
                currDate = DateTime.Now;
            }

            ViewBag.currDate = currDate;

            Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient();

            ViewLevel theView  = new ViewLevel();
            const int TYPE_AGK = 6;

            theView.theSiteList      = ViewSite.GetAll(TYPE_AGK);
            theView.SelectedSiteCode = SiteCode;
            if (theView.SelectedSiteCode == -1)
            {
                theView.SelectedSiteCode = theView.theSiteList[0].Code;
            }

            return(View(theView));
        }
Example #3
0
        //
        // GET: /Water/

        public ActionResult Index(int WaterObject = -1)
        {
            Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient();
            ViewWater theViewData             = new ViewWater();

            theViewData.SelectedWaterObject      = WaterObject;
            theViewData.theWaterObjectCollection = theHydro.GetWaterObjects(false);

            if (theViewData.SelectedWaterObject == -1)
            {
                theViewData.SelectedWaterObject = theViewData.theWaterObjectCollection[0].Id;
            }

            theViewData.theSites    = theHydro.GetSitesByWaterObject(theViewData.SelectedWaterObject);
            theViewData.theSiteList = ViewSite.GetAll();
            return(View(theViewData));
        }
        private void WmWindowPosChanging(IntPtr lParam)
        {
            var windowpos = (Windowpos)Marshal.PtrToStructure(lParam, typeof(Windowpos));

            if (((int)windowpos.flags & 2) != 0 || ((int)windowpos.flags & 1) != 0 ||
                (windowpos.cx <= 0 || windowpos.cy <= 0))
            {
                return;
            }
            var floatRect = new Rect(windowpos.x, windowpos.y, windowpos.cx, windowpos.cy).DeviceToLogicalUnits();

            if (_useLogicalSizeForRestore)
            {
                floatRect = _logicalSizeForRestore;
                _logicalSizeForRestore    = Rect.Empty;
                _useLogicalSizeForRestore = false;
            }
            var rect = ViewSite.GetOnScreenPosition(floatRect).LogicalToDeviceUnits();

            windowpos.x = (int)rect.X;
            windowpos.y = (int)rect.Y;
            Marshal.StructureToPtr((object)windowpos, lParam, true);
        }
 protected virtual bool ValidateOrReplaceCustomViewSite(ref ViewSite viewSite, WindowProfileValidationContext context)
 {
     return(false);
 }
        protected bool ValidateOrReplaceViewGroup(ref ViewGroup viewGroup, WindowProfileValidationContext context)
        {
            DockOperations.TryCollapse((ViewElement)viewGroup);
            DockGroup dockGroup = viewGroup as DockGroup;

            if (dockGroup != null)
            {
                bool flag = this.ValidateOrReplaceDockGroup(ref dockGroup, context);
                viewGroup = (ViewGroup)dockGroup;
                this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
                return(flag);
            }
            NestedGroup nestedGroup = viewGroup as NestedGroup;

            if (nestedGroup != null)
            {
                bool flag = this.ValidateOrReplaceNestedGroup(ref nestedGroup, context);
                viewGroup = (ViewGroup)nestedGroup;
                this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
                return(flag);
            }
            AutoHideGroup autoHideGroup = viewGroup as AutoHideGroup;

            if (autoHideGroup != null)
            {
                autoHideGroup.SelectedElement = (ViewElement)null;
                bool flag = this.ValidateOrReplaceAutoHideGroup(ref autoHideGroup, context);
                viewGroup = (ViewGroup)autoHideGroup;
                this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
                return(flag);
            }
            AutoHideChannel autoHideChannel = viewGroup as AutoHideChannel;

            if (autoHideChannel != null)
            {
                bool flag = this.ValidateOrReplaceAutoHideChannel(ref autoHideChannel, context);
                viewGroup = (ViewGroup)autoHideChannel;
                this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
                return(flag);
            }
            ViewSite viewSite = viewGroup as ViewSite;

            if (viewSite != null)
            {
                bool flag = this.ValidateOrReplaceViewSite(ref viewSite, context);
                viewGroup = (ViewGroup)viewSite;
                this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
                return(flag);
            }
            AutoHideRoot autoHideRoot = viewGroup as AutoHideRoot;

            if (autoHideRoot != null)
            {
                bool flag = this.ValidateOrReplaceAutoHideRoot(ref autoHideRoot, context);
                viewGroup = (ViewGroup)autoHideRoot;
                this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
                return(flag);
            }
            DockRoot dockRoot = viewGroup as DockRoot;

            if (dockRoot == null)
            {
                return(this.ValidateOrReplaceCustomViewGroup(ref viewGroup, context));
            }
            bool flag1 = this.ValidateOrReplaceDockRoot(ref dockRoot, context);

            viewGroup = (ViewGroup)dockRoot;
            this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context);
            return(flag1);
        }
Example #7
0
        private IEnumerable <GeneratedPage> GenerateHtml(GenerationContext context)
        {
            var viewSite = new ViewSite
            {
                Posts = context.Pages.Where(p => p.Post != null).Select(p => new ViewPost {
                    Title = p.Post.Header.Title, AbsoluteUrl = PathToUrl(GetEndPath(p))
                }).ToList()
            };

            foreach (Page page in context.Pages)
            {
                var generated = new GeneratedPage();
                generated.RelativePath = GetEndPath(page);
                var templateContext = new TemplateContext();
                templateContext.FileProvider = new PhysicalFileProvider(context.IncludePath);
                templateContext.MemberAccessStrategy.MemberNameStrategy = MemberNameStrategies.CamelCase;
                templateContext.MemberAccessStrategy.Register <ViewPage>();
                templateContext.MemberAccessStrategy.Register <ViewPost>();
                templateContext.MemberAccessStrategy.Register <ViewSite>();
                templateContext.Filters.AddFilter("relative_url", (input, args, ctx) => new StringValue(GetRelativeUrl(input.ToStringValue(), PathToUrl(generated.RelativePath))));

                string templateContent = null;

                var    viewPage = new ViewPage();
                string content  = null;

                if (page.Post != null)
                {
                    string layout = null;
                    if (page.Post.Header != null)
                    {
                        viewPage.Title = page.Post.Header.Title;
                        layout         = page.Post.Header.Layout;
                    }
                    viewPage.Title = viewPage.Title ?? "Untitled";
                    content        = Markdown.ToHtml(page.Post.RawContent, pipeline);

                    var htmlTemplate = context.Templates.Find(f => Path.GetFileNameWithoutExtension(f.Name).Equals(layout, StringComparison.InvariantCulture));
                    if (htmlTemplate == null)
                    {
                        Console.WriteLine($"Couldn't find template {layout}");
                        // Dump the markdown itself if template doesn't exist.
                        templateContent = content;
                    }
                    else
                    {
                        templateContent = htmlTemplate.Content;
                    }
                }
                else
                {
                    templateContent = page.RawContent;
                }

                templateContext.SetValue("site", viewSite);
                templateContext.SetValue("page", viewPage);
                templateContext.SetValue("content", content);
                if (FluidTemplate.TryParse(templateContent, out FluidTemplate template))
                {
                    generated.Content = template.Render(templateContext, System.Text.Encodings.Web.HtmlEncoder.Default);
                }
                else
                {
                    Console.WriteLine($"Invalid Liquid in {page.FileName}");
                    generated.Content = page.RawContent;
                }

                yield return(generated);
            }
        }
Example #8
0
        public ActionResult Months(int SiteCode = -1, int YYYY = -1, int MM = -1, int DD = 1)
        {
            DateTime currDate;

            try
            {
                currDate = new DateTime(YYYY, MM, DD);
            }
            catch
            {
                currDate = DateTime.Now;
            }

            ViewBag.currDate = currDate;

            Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient();

            ViewLevel theView  = new ViewLevel();
            const int TYPE_AGK = 6;

            theView.theSiteList      = ViewSite.GetAll(TYPE_AGK);
            theView.SelectedSiteCode = SiteCode;
            if (theView.SelectedSiteCode == -1)
            {
                theView.SelectedSiteCode = theView.theSiteList[0].Code;
            }

            int SiteID = theView.theSiteList.Where(x => x.Code == theView.SelectedSiteCode).Single().ID;

            DateTime dateBgn = new DateTime(currDate.Year, currDate.Month, 1);
            DateTime dateEnd = new DateTime(currDate.Year, currDate.Month, DateTime.DaysInMonth(currDate.Year, currDate.Month));

            const int LEVEL_CODE = 2;

            var ValueCollection = theHydro.GetDataValues(SiteID, dateBgn, dateEnd, LEVEL_CODE, null, null, null);

            if (ValueCollection == null)
            {
                return(View(theView));
            }

            foreach (var item in ValueCollection)
            {
                if (item.Value > -9000)
                {
                    ViewLevel.Level theLevel = new ViewLevel.Level();
                    theLevel.Value = item.Value;
                    theLevel.YYYY  = item.Date.Year;
                    theLevel.MM    = item.Date.Month;
                    theLevel.DD    = item.Date.Day;
                    theLevel.HH    = item.Date.Hour;
                    theLevel.MI    = 0;
                    theLevel.SS    = 0;
                    theLevel.ID    = item.Id;
                    theView.theLevelList.Add(theLevel);
                }
            }

            const int HydroPostType = 2;

            var HydroPost = theHydro.GetSite(theView.SelectedSiteCode.ToString(), HydroPostType);
            var HydroPostValueCollection = theHydro.GetDataValues(HydroPost.SiteId, dateBgn, dateEnd, LEVEL_CODE, null, null, null);

            if (HydroPostValueCollection == null)
            {
                return(View(theView));
            }

            foreach (var item in HydroPostValueCollection)
            {
                if (item.Value > -9000)
                {
                    ViewLevel.Level theLevel = new ViewLevel.Level();
                    theLevel.Value = item.Value;
                    theLevel.YYYY  = item.Date.Year;
                    theLevel.MM    = item.Date.Month;
                    theLevel.DD    = item.Date.Day;
                    theLevel.HH    = item.Date.Hour;
                    theLevel.MI    = 0;
                    theLevel.SS    = 0;
                    theLevel.ID    = item.Id;
                    theView.theHydroPostLevelList.Add(theLevel);
                }
            }



            return(View(theView));
        }