コード例 #1
0
        public JsonResult AddMetaPage(string pageName, string widgetName)
        {
            var success = "OK";
            var message = "";

            try
            {
                if (String.IsNullOrWhiteSpace(pageName))
                {
                    pageName = "** New Page For Widget **";
                }

                var encodedName = AntiXssEncoder.HtmlEncode(pageName, false);

                var metaPage = new MetaPage {
                    Breadcrumb = string.Empty, IsSystem = false, MetaDefinition = "", PageDefinition = widgetName, PageName = encodedName, metapage_guid = Guid.NewGuid(), IsVisible = false
                };
                _unitOfWork.Repository <MetaPage>().Save(metaPage);
            }
            catch (Exception ex)
            {
                success = "FAILED";
                message = ex.Message;
            }

            var result = new { Success = success, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        /// <summary>
        /// Draw all objects of the page to current PDF file page
        /// </summary>
        /// <param name="meta">MetaFile containing the page</param>
        /// <param name="page">MetaPage to be drawn</param>
        override public void DrawPage(MetaFile meta, MetaPage page)
        {
//            for (int i = 0; i < page.Objects.Count; i++)
//            {
//                DrawObject(page, page.Objects[i]);
//            }
        }
コード例 #3
0
ファイル: PageCustom.aspx.cs プロジェクト: romaner/PViMS
        private void SavePage()
        {
            var encodedName       = AntiXssEncoder.HtmlEncode(txtName.Value, false);
            var encodedDefinition = AntiXssEncoder.HtmlEncode(txtDefinition.Value, false);
            var encodedBreadcrumb = AntiXssEncoder.HtmlEncode(txtBreadcrumb.Value, false);

            if (_metaPage == null)
            {
                // Prepare new page
                _metaPage = new MetaPage {
                    Breadcrumb = encodedBreadcrumb, IsSystem = false, MetaDefinition = "", PageDefinition = encodedDefinition, PageName = encodedName, metapage_guid = Guid.NewGuid(), IsVisible = (ddlVisible.Value == "Yes")
                };

                UnitOfWork.Repository <MetaPage>().Save(_metaPage);
            }
            else
            {
                // Prepare updated page
                _metaPage.PageName       = encodedName;
                _metaPage.PageDefinition = encodedDefinition;
                _metaPage.Breadcrumb     = encodedBreadcrumb;
                _metaPage.IsVisible      = (ddlVisible.Value == "Yes");

                UnitOfWork.Repository <MetaPage>().Update(_metaPage);
            }

            UnitOfWork.Complete();

            HttpCookie cookie = new HttpCookie("PopUpMessage");

            cookie.Value = String.Format("Page {0} successfully", _formMode == FormMode.AddMode ? "added" : "updated");
            Response.Cookies.Add(cookie);

            Response.Redirect("PageViewer.aspx?guid=" + _metaPage.metapage_guid.ToString());
        }
コード例 #4
0
        public void DoUpdatePageSize(MetaPage MetaFilepage)
        {
            Point apagesize;

            // Sets page orientation and size
            PageDetail.PhysicWidth        = MetaFile.CustomX;
            PageDetail.PhysicHeight       = MetaFile.CustomY;
            MetaFilepage.Orientation      = CurrentOrientation;
            MetaFilepage.PageDetail.Index = PageSizeIndex;
            if (!UpdatePageSize)
            {
                MetaFilepage.PageDetail = PageDetail;
                return;
            }
            MetaFilepage.UpdatedPageSize = true;
            // Sets and gets page size from the driver
            FDriver.SetOrientation(CurrentOrientation);
            if (PageSize != PageSizeType.Default)
            {
                apagesize = FDriver.SetPageSize(PageDetail);
            }
            else
            {
                apagesize = FDriver.GetPageSize(out PageSizeIndex);
            }
            InternalPageWidth  = apagesize.X;
            InternalPageHeight = apagesize.Y;

            PageDetail.PhysicWidth  = apagesize.X;
            PageDetail.PhysicHeight = apagesize.Y;
            MetaFilepage.PageDetail = PageDetail;
        }
コード例 #5
0
        private void pd_QueryPageSettingsEvent(object sender, QueryPageSettingsEventArgs e)
        {
            doprint = true;
            if (FMeta.Finished)
            {
//				if (doc.PrinterSettings.ToPage > FMeta.Pages.CurrentCount)
            }
            //   throw new Exception("Imprimiendo por: " + e.PageSettings.PrinterSettings.PrinterName);
            while ((FCurrentPage + 1) < doc.PrinterSettings.FromPage)
            {
                FCurrentPage++;
            }
            UpdateHardMargins();
            if ((FCurrentPage + 1) > doc.PrinterSettings.ToPage)
            {
                doprint = false;
            }
            if (doprint)
            {
                FMeta.RequestPage(FCurrentPage + 1);
                if (FMeta.Pages.CurrentCount > FCurrentPage)
                {
                    FPrintPage = FCurrentPage;
                    MetaPage apage = (MetaPage)FMeta.Pages[FCurrentPage];

                    if (apage.UpdatedPageSize)
                    {
                        // Check for page size
                        int nwidth  = apage.PhysicWidth;
                        int nheight = apage.PhysicHeight;
                        if (FMeta.Orientation == OrientationType.Landscape)
                        {
                            nwidth  = apage.PhysicHeight;
                            nheight = apage.PhysicWidth;
                        }
                        e.PageSettings.PaperSize = FindPaperSize(apage.PageDetail.Index, nwidth, nheight);
                        if (apage.Orientation == OrientationType.Default)
                        {
                            e.PageSettings.Landscape = doc.DefaultPageSettings.Landscape;
                        }
                        else
                        if (apage.Orientation == OrientationType.Landscape)
                        {
                            e.PageSettings.Landscape = true;
                        }
                        else
                        {
                            e.PageSettings.Landscape = false;
                        }
                    }
                    else
                    {
                        e.PageSettings = doc.DefaultPageSettings;
                    }
                }
            }
            docancel = false;
            FCurrentPage++;
        }
コード例 #6
0
 /// <summary>
 /// Creates a new page
 /// </summary>
 override public void NewPage(MetaFile meta, MetaPage page)
 {
     // Sets the page size for the pdf file, first if it's a qt page
     if (page.UpdatedPageSize)
     {
         FPageWidth  = page.PageDetail.PhysicWidth;
         FPageHeight = page.PageDetail.PhysicHeight;
     }
     FPDFFile.NewPage(FPageWidth, FPageHeight);
 }
コード例 #7
0
 private void pd_PrintPage(object sender, PrintPageEventArgs ev)
 {
     Fev = ev;
     try
     {
         if (doprint)
         {
             while ((FCurrentPrintPage + 1) < doc.PrinterSettings.FromPage)
             {
                 FCurrentPrintPage++;
             }
             FMeta.RequestPage(FCurrentPrintPage + 1);
             if (FMeta.Pages.CurrentCount > FCurrentPrintPage)
             {
                 MetaPage apage = (MetaPage)FMeta.Pages[FCurrentPrintPage];
                 Fev.Graphics.PageUnit = GraphicsUnit.Pixel;
                 Scale = 1.0f;
                 NewPage(FMeta, apage);
                 DrawPage(FMeta, apage);
                 EndPage(FMeta);
                 FPagesPrinted++;
                 if (doc.PrinterSettings.Copies != 1)
                 {
                     FPagesPrinted = FPagesPrinted + doc.PrinterSettings.Copies;
                 }
                 else
                 {
                     FPagesPrinted++;
                 }
             }
         }
         docancel = false;
         bool hasmorepages = false;
         FCurrentPrintPage++;
         if ((FCurrentPrintPage < doc.PrinterSettings.ToPage) && (FCurrentPrintPage < FMeta.Pages.CurrentCount))
         {
             hasmorepages = true;
         }
         else
         {
             hasmorepages      = false;
             FCurrentPrintPage = 0;
         }
         ev.HasMorePages = hasmorepages;
         ev.Cancel       = docancel;
     }
     finally
     {
         Fev = null;
     }
 }
コード例 #8
0
//		public PaperSize PageDetailToPaperSize(PageSizeDetail PageDetail)
//		{
//			PaperSize psize = new PaperSize("dfsdsd", 12, 12);
//
//			return (psize);
//		}
//		public PaperSource PageDetailToPaperSource(PageSizeDetail PageDetail)
//		{
//			return (new PrinterSettings().PaperSources[0]);
//		}
        /// <summary>
        /// Draw a page to the print surface
        /// </summary>
        /// <param name="meta">MetaFile containing the page</param>
        /// <param name="page">MetaPage to be drawn</param>
        override public void DrawPage(MetaFile meta, MetaPage page)
        {
            if (Fev == null)
            {
                base.DrawPage(meta, page);
                return;
            }
            Graphics gr = Fev.Graphics;

            for (int i = 0; i < page.Objects.Count; i++)
            {
                DrawObject(gr, page, page.Objects[i]);
            }
        }
コード例 #9
0
        static void PrintObject(string[,] pmatrix, MetaPage page, MetaObject obj, int precision, SortedList <string, int> rows,
                                SortedList <string, int> columns)
        {
            string topstring  = (obj.Top / precision).ToString("0000000000");
            string leftstring = (obj.Left / precision).ToString("0000000000");
            int    arow       = rows.IndexOfKey(topstring);
            int    acolumn    = columns.IndexOfKey(leftstring);

            switch (obj.MetaType)
            {
            case MetaObjectType.Text:
                pmatrix[arow, acolumn] = page.GetText((MetaObjectText)obj);
                break;

            default:
                break;
            }
        }
コード例 #10
0
ファイル: PageCustom.aspx.cs プロジェクト: romaner/PViMS
        protected void Page_Init(object sender, EventArgs e)
        {
            Master.SetPageHeader(new Models.PageHeaderDetail()
            {
                Title = "Manage Page", SubTitle = "", Icon = "fa fa-windows fa-fw"
            });

            if (Request.QueryString["id"] != null)
            {
                _id = Convert.ToInt32(Request.QueryString["id"]);
                if (_id > 0)
                {
                    _metaPage = UnitOfWork.Repository <MetaPage>().Queryable().SingleOrDefault(u => u.Id == _id);
                }
                else
                {
                    _metaPage = null;
                    _formMode = FormMode.AddMode;
                }
            }
            else
            {
                throw new Exception("id not passed as parameter");
            }

            string action = string.Empty;

            if (Request.QueryString["a"] != null)
            {
                action = Request.QueryString["a"];
                switch (action)
                {
                case "edit":
                    _formMode = FormMode.EditMode;
                    break;
                } // switch (_action)
            }

            RenderButtons();
            ToggleView();
        }
コード例 #11
0
        //attenzione
        void DoFunction(string tag)
        {
            string[] parts = tag.Split('.');
            if (parts.Length < 2)
            {
                return;
            }
            string           meta    = parts[0];
            string           edittye = parts[1];
            ApplicationState APS     = ApplicationState.GetApplicationState(this);

            if (APS == null)
            {
                MetaPage.SessionTimeOut(this);
                return;
            }
            MetaData M = APS.Dispatcher.Get(meta);

            M.edit_type = edittye;
            APS.CallPage(this, M, false);
        }
コード例 #12
0
        public void CreateTable <K, V>(string name)
        {
            // Meta.AddTable(name, typeof(K), typeof(V));
            int      tableId        = _meta.Tables.Count;
            MetaPage firstIndexPage = _pageManager.AllocEmptyPage();

            _meta.Tables.Add(
                name,
                new StoreMetaTable {
                KeyType        = typeof(K).FullName,
                ValueType      = typeof(V).FullName,
                TableName      = name,
                FirstIndexPage = page,
            }
                );

            _meta.Pages[page].RowCount = 0;

            _file.Seek(_header.MetaBegin, SeekOrigin.Begin);
            BinarySerializer.Serialize(_file, _meta);
        }
コード例 #13
0
ファイル: rplabelitem.cs プロジェクト: chtheis/reportman.net
        override protected void DoPrint(PrintOut adriver, int aposx, int aposy,
                                        int newwidth, int newheight, MetaFile metafile, Point MaxExtent,
                                        ref bool PartialPrint)
        {
            int aalign;

            base.DoPrint(adriver, aposx, aposy, newwidth, newheight,
                         metafile, MaxExtent, ref PartialPrint);
            MetaPage       apage   = metafile.Pages[metafile.CurrentPage];
            MetaObjectText metaobj = new MetaObjectText();

            metaobj.TextP        = apage.AddString(Text);
            metaobj.TextS        = Text.Length;
            metaobj.LFontNameP   = apage.AddString(LFontName);
            metaobj.LFontNameS   = LFontName.Length;
            metaobj.WFontNameP   = apage.AddString(WFontName);
            metaobj.WFontNameS   = WFontName.Length;
            metaobj.FontSize     = FontSize;
            metaobj.BackColor    = BackColor;
            metaobj.FontRotation = FontRotation;
            metaobj.FontStyle    = (short)FontStyle;
            metaobj.FontColor    = FontColor;
            metaobj.Type1Font    = Type1Font;
            metaobj.CutText      = CutText;
            metaobj.Transparent  = Transparent;
            metaobj.WordWrap     = WordWrap;
            metaobj.Top          = aposy;
            metaobj.Left         = aposx;
            metaobj.Width        = PrintWidth;
            metaobj.Height       = PrintHeight;
            metaobj.RightToLeft  = RightToLeft;
            metaobj.PrintStep    = PrintStep;
            aalign = PrintAlignment | VPrintAlignment;
            if (SingleLine)
            {
                aalign = aalign | MetaFile.AlignmentFlags_SingleLine;
            }
            metaobj.Alignment = aalign;
            apage.Objects.Add(metaobj);
        }
コード例 #14
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (error_dep)
            {
                return;
            }

            string     error;
            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                return;
            }

            DateTime D = DateTime.Now;

            object Onedip = Session["DepCode"];

            if (Onedip == null)
            {
                MetaPage.SessionTimeOut(this);
                return;
            }
            //Onedip = "amministrazione";

            ConnectToDepartment(Onedip.ToString(), null, null, D);
            Easy_DataAccess UsrConnTemp = GetVars.GetUserConn(this);

            if (UsrConnTemp == null || UsrConnTemp.Open() == false)
            {
                //Il Server del Dipartimento non è in rete.
                //Il servizio non è disponibile in quanto il computer potrebbe essere spento.
                labExtMessage.Text = "Il Server del Dipartimento " + Onedip.ToString() + " non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito";
                txtCodice.ReadOnly = true;
                WebLog.Log(this, "Il Server del dipartimento " + Onedip.ToString() + "non risponde.");
                return;
            }



            DataSet DDecode = UsrConnTemp.CallSP("calc_bookingid", new object[] { txtCodice.Text }, true);

            UsrConnTemp.Close();
            if (DDecode == null || DDecode.Tables.Count == 0)
            {
                lblMessaggio.Text = "Errore nel contattare il dipartimento o codice errato.";
                return;
            }

            DataTable TDecode = DDecode.Tables[0];

            if (TDecode.Rows.Count == 0)
            {
                lblMessaggio.Text = "Errore nel contattare il dipartimento  o codice errato.";
                return;
            }

            DataRow RCode = TDecode.Rows[0];

            if (RCode["iddep"].ToString() == "")
            {
                lblMessaggio.Text = "Errore nella lettura del codice a barre";
                txtCodice.Text    = "";
                return;
            }
            string depcode   = RCode["iddep"].ToString();
            string idbooking = RCode["idbooking"].ToString();

            ConnectToDepartment(depcode, null, null, D);

            Easy_DataAccess UsrConn = GetVars.GetUserConn(this);

            if (UsrConn == null || UsrConn.Open() == false)
            {
                //Il Server del Dipartimento non è in rete.
                //Il servizio non è disponibile in quanto il computer potrebbe essere spento.
                labExtMessage.Text = "Il Server del Dipartimento " + depcode + " non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito";
                txtCodice.ReadOnly = true;
                WebLog.Log(this, "Il Server del dipartimento " + depcode + "non risponde.");
                return;
            }

            labExtMessage.Text = "Connessione al server effettuata.";



            ScaricaPrenotazione(UsrConn, idbooking);
        }
コード例 #15
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.IsInRole("PublisherAdmin"))
            {
                _isPublisher = true;
            }

            if (Request.QueryString["guid"] != null)
            {
                _guid     = Guid.Parse(Request.QueryString["guid"]);
                _metaPage = UnitOfWork.Repository <MetaPage>().Queryable().Single(mp => mp.metapage_guid == _guid);

                // Prepare report
                RenderHeader();

                // Render unpublished widgets
                if (_isPublisher)
                {
                    var widgetCount = 12;
                    var div         = new HtmlGenericControl("div");
                    foreach (MetaWidget uwidget in _metaPage.Widgets.Where(w => w.WidgetStatus == MetaWidgetStatus.Unpublished))
                    {
                        if (widgetCount == 12)
                        {
                            if (div.Controls.Count > 0)
                            {
                                spnUnpublished.Controls.Add(div);
                            }
                            ;

                            // add new row
                            div = new HtmlGenericControl("div");
                            div.Attributes.Add("class", "row");
                            widgetCount = 0;
                        }
                        widgetCount += 1;

                        var section = RenderUnpublishedWidget(uwidget);
                        div.Controls.Add(section);
                    }
                    if (div.Controls.Count > 0)
                    {
                        spnUnpublished.Controls.Add(div);
                    }
                    ;
                }
                else
                {
                    spnUnpublished.Visible = false;
                }

                // Render top widgets
                var widget = _metaPage.Widgets.FirstOrDefault(w => w.WidgetStatus == MetaWidgetStatus.Published && w.WidgetLocation == MetaWidgetLocation.TopLeft);
                RenderWidget(widget, MetaWidgetLocation.TopLeft, 1);
                widget = _metaPage.Widgets.FirstOrDefault(w => w.WidgetStatus == MetaWidgetStatus.Published && w.WidgetLocation == MetaWidgetLocation.TopRight);
                RenderWidget(widget, MetaWidgetLocation.TopRight, 2);

                // Render middle widgets
                widget = _metaPage.Widgets.FirstOrDefault(w => w.WidgetStatus == MetaWidgetStatus.Published && w.WidgetLocation == MetaWidgetLocation.MiddleLeft);
                RenderWidget(widget, MetaWidgetLocation.MiddleLeft, 3);
                widget = _metaPage.Widgets.FirstOrDefault(w => w.WidgetStatus == MetaWidgetStatus.Published && w.WidgetLocation == MetaWidgetLocation.MiddleRight);
                RenderWidget(widget, MetaWidgetLocation.MiddleRight, 4);

                // Render bottom widgets
                widget = _metaPage.Widgets.FirstOrDefault(w => w.WidgetStatus == MetaWidgetStatus.Published && w.WidgetLocation == MetaWidgetLocation.BottomLeft);
                RenderWidget(widget, MetaWidgetLocation.BottomLeft, 5);
                widget = _metaPage.Widgets.FirstOrDefault(w => w.WidgetStatus == MetaWidgetStatus.Published && w.WidgetLocation == MetaWidgetLocation.BottomRight);
                RenderWidget(widget, MetaWidgetLocation.BottomRight, 6);
            }
            else
            {
                throw new Exception("guid not passed as parameter");
            }
            divReturn.Visible = false;
            if (Request.QueryString["ruid"] != null)
            {
                _ruid = Guid.Parse(Request.QueryString["ruid"]);
                HyperLink hyp = new HyperLink()
                {
                    ID          = "btnReturn",
                    NavigateUrl = "PageViewer.aspx?guid=" + _ruid.ToString(),
                    CssClass    = "btn btn-default",
                    Text        = "Return"
                };
                spnButtons.Controls.Add(hyp);
                divReturn.Visible = true;
            }
        }
コード例 #16
0
        /// <summary>
        /// Draw an object to the PDF file
        /// </summary>
        /// <param name="page">MetaPage conatining the object</param>
        /// <param name="obj">Object to be drawn</param>
        public void DrawObject(MetaPage page, MetaObject obj)
        {
            if (CalculateOnly)
            {
                return;
            }
            int          X, Y, W, H, S;
            int          Width, Height, posx, posy;
            Rectangle    rec;
            int          aalign;
            MemoryStream stream;
            string       astring;

            posx = obj.Left;
            posy = obj.Top;
            switch (obj.MetaType)
            {
            case MetaObjectType.Text:
                MetaObjectText objt = (MetaObjectText)obj;
                FPDFFile.Canvas.Font.WFontName = page.GetWFontNameText(objt);
                FPDFFile.Canvas.Font.FontName  = FPDFFile.Canvas.Font.WFontName.Replace(" ", "");
                FPDFFile.Canvas.Font.LFontName = page.GetLFontNameText(objt);
                FPDFFile.Canvas.Font.Style     = objt.FontStyle;
                // Transparent ?
                FPDFFile.Canvas.Font.Name        = (PDFFontType)objt.Type1Font;
                FPDFFile.Canvas.Font.Size        = objt.FontSize;
                FPDFFile.Canvas.Font.Color       = objt.FontColor;
                FPDFFile.Canvas.Font.Bold        = (objt.FontStyle & 1) > 0;
                FPDFFile.Canvas.Font.Italic      = (objt.FontStyle & 2) > 0;
                FPDFFile.Canvas.Font.Underline   = (objt.FontStyle & 4) > 0;
                FPDFFile.Canvas.Font.StrikeOut   = (objt.FontStyle & 8) > 0;
                FPDFFile.Canvas.Font.BackColor   = objt.BackColor;
                FPDFFile.Canvas.Font.Transparent = objt.Transparent;
                FPDFFile.Canvas.UpdateFonts();
                aalign  = objt.Alignment;
                rec     = new Rectangle(posx, posy, posx + objt.Width, posy + objt.Height);
                astring = page.GetText(objt);
                FPDFFile.Canvas.TextRect(rec, astring, aalign, objt.CutText,
                                         objt.WordWrap, objt.FontRotation, objt.RightToLeft);
                break;

            case MetaObjectType.Draw:
                MetaObjectDraw objd = (MetaObjectDraw)obj;
                Width  = objd.Width;
                Height = objd.Height;
                FPDFFile.Canvas.BrushStyle = objd.BrushStyle;
                FPDFFile.Canvas.PenStyle   = objd.PenStyle;
                FPDFFile.Canvas.PenColor   = objd.PenColor;
                FPDFFile.Canvas.BrushColor = objd.BrushColor;
                FPDFFile.Canvas.PenWidth   = objd.PenWidth;
                X = (int)FPDFFile.Canvas.PenWidth / 2;
                Y = X;
                W = Width - FPDFFile.Canvas.PenWidth + 1;
                H = Height - FPDFFile.Canvas.PenWidth + 1;
                if (FPDFFile.Canvas.PenWidth == 0)
                {
                    W--;
                    H--;
                }
                if (W < H)
                {
                    S = W;
                }
                else
                {
                    S = H;
                }
                ShapeType shape = (ShapeType)objd.DrawStyle;
                if ((shape == ShapeType.Square) || (shape == ShapeType.RoundSquare) ||
                    (shape == ShapeType.Circle))
                {
                    X = X + (int)((W - S) / 2);
                    Y = Y + (int)((H - S) / 2);
                    W = S;
                    H = S;
                }
                switch (shape)
                {
                case ShapeType.Rectangle:
                case ShapeType.Square:
                    FPDFFile.Canvas.Rectangle(X + posx, Y + posy, X + posx + W, Y + posy + H);
                    break;

                case ShapeType.RoundRect:
                case ShapeType.RoundSquare:
                    FPDFFile.Canvas.RoundedRectangle(X + posx, Y + posy, X + posx + W, Y + posy + H, Rectangle_Radius);
                    break;

                case ShapeType.Ellipse:
                case ShapeType.Circle:
                    FPDFFile.Canvas.Ellipse(X + posx, Y + posy, X + posx + W, Y + posy + H);
                    break;

                case ShapeType.HorzLine:
                    FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx + W, Y + posy);
//							if (objd.PenStyle >= 3 && objd.PenStyle <= 4)
//							{
//								FPDFFile.Canvas.PenStyle = 6;
//								FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx, Y + posx + H);
//							}
                    break;

                case ShapeType.VertLine:
                    FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx, Y + posy + H);
                    break;

                case ShapeType.Oblique1:
                    FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx + W, Y + posy + H);
                    break;

                case ShapeType.Oblique2:
                    FPDFFile.Canvas.Line(X + posx, Y + posy + H, X + posx + W, Y + posy);
                    break;
                }
                break;

            case MetaObjectType.Image:
                MetaObjectImage obji = (MetaObjectImage)obj;
                // In pdf draw also preview only images
                //if (!obji.PreviewOnly)
                {
                    Width  = obji.Width;
                    Height = obji.Height;
                    rec    = new Rectangle(posx, posy, Width, Height);
                    stream = page.GetStream(obji);
                    ImageDrawStyleType dstyle = (ImageDrawStyleType)obji.DrawImageStyle;
                    long intimageindex        = -1;
                    if (obji.SharedImage)
                    {
                        intimageindex = obji.StreamPos;
                    }
                    bool adaptsize = false;
                    if (dstyle == ImageDrawStyleType.Full)
                    {
                        adaptsize = true;
                        dstyle    = ImageDrawStyleType.Crop;
                    }
                    switch (dstyle)
                    {
                    case ImageDrawStyleType.Full:
                        FPDFFile.Canvas.DrawImage(rec, stream, obji.DPIRes, false, false, intimageindex);
                        break;

                    case ImageDrawStyleType.Stretch:
                        FPDFFile.Canvas.DrawImage(rec, stream, 0, false, false, intimageindex);
                        break;

                    case ImageDrawStyleType.Crop:
                        int bitmapwidth  = 0;
                        int bitmapheight = 0;
                        using (Image nimage = Image.FromStream(stream))
                        {
                            bitmapwidth  = nimage.Width;
                            bitmapheight = nimage.Height;
                        }
                        if (adaptsize)
                        {
                            double nwidth  = bitmapwidth * Twips.TWIPS_PER_INCH / obji.DPIRes;
                            double nheight = bitmapheight * Twips.TWIPS_PER_INCH / obji.DPIRes;
                            if (nwidth > rec.Width)
                            {
                                rec = new Rectangle(rec.Left, rec.Top, Convert.ToInt32(nwidth), Height);
                            }
                            if (nheight > rec.Height)
                            {
                                rec = new Rectangle(rec.Left, rec.Top, rec.Width, Convert.ToInt32(nheight));
                            }
                        }

                        double propx = (double)rec.Width / bitmapwidth;
                        double propy = (double)rec.Height / bitmapheight;
                        H = 0;
                        W = 0;
                        if (propy > propx)
                        {
                            H   = Convert.ToInt32(Math.Round(rec.Height * propx / propy));
                            rec = new Rectangle(rec.Left, Convert.ToInt32(rec.Top + (rec.Height - H) / 2), rec.Width, H);
                        }
                        else
                        {
                            W   = Convert.ToInt32(rec.Width * propy / propx);
                            rec = new Rectangle(rec.Left + (rec.Width - W) / 2, rec.Top, W, rec.Height);
                        }
                        FPDFFile.Canvas.DrawImage(rec, stream, 0, false, false, intimageindex);
                        break;

                    case ImageDrawStyleType.Tile:
                    case ImageDrawStyleType.Tiledpi:
                        FPDFFile.Canvas.DrawImage(rec, stream, PDFFile.CONS_PDFRES, true, true, intimageindex);
                        break;
                    }
                }
                break;
            }
        }
コード例 #17
0
        /// <summary>
        /// Internal main procedure performing the draw of the page at selected scale
        /// </summary>
        protected void ReDrawPage()
        {
            if (Parent == null)
            {
                return;
            }
            if (FMetaFile == null)
            {
                return;
            }
#if REPMAN_COMPACT
#else
            SuspendLayout();
            prdriver.Previewing = true;
            try
            {
#endif
            if (FPage < 0)
            {
                FPage = 0;
            }
            if (FPage >= FMetaFile.Pages.CurrentCount)
            {
                FMetaFile.RequestPage(FPage + FEntirePageCount - 1);
                if (FPage >= FMetaFile.Pages.CurrentCount)
                {
                    FPage = FMetaFile.Pages.CurrentCount - 1;
                }
            }
            MetaPage metapage = FMetaFile.Pages[FPage];
            int newwidth, newheight;
            int pagerows = 1, pagecols = 1;
            int intentirepcount = 1;
            SizeF clients       = new SizeF((float)(Parent.ClientSize.Width),
                                            (float)(Parent.ClientSize.Height));
            SizeF asize = new SizeF((float)metapage.PhysicWidth * dpix / 1440,
                                    (float)metapage.PhysicHeight * dpiy / 1440);
            switch (AutoScale)
            {
            case AutoScaleType.Real:
                ChangePreviewScale(1.0F);
                break;

            case AutoScaleType.EntirePage:
                float scalev, scaleh;
                if (FEntirePageCount > 1)
                {
                    FMetaFile.RequestPage(FPage + FEntirePageCount - 1);
                    intentirepcount = FMetaFile.Pages.CurrentCount - FPage;
                    if (intentirepcount > FEntirePageCount)
                    {
                        intentirepcount = FEntirePageCount;
                    }
                    if (intentirepcount < 1)
                    {
                        intentirepcount = 1;
                    }
                    // Look for diferent page sizes
                    int      pagesequal = 1;
                    SizeF    newsize;
                    MetaPage newpage;
                    while (pagesequal < intentirepcount)
                    {
                        newpage = FMetaFile.Pages[FPage + pagesequal];
                        newsize = new SizeF((float)newpage.PhysicWidth * dpix / 1440,
                                            (float)newpage.PhysicHeight * dpiy / 1440);
                        if (newsize != asize)
                        {
                            intentirepcount = pagesequal;
                            break;
                        }
                        pagesequal++;
                    }
                }
                if (intentirepcount == 1)
                {
                    scalev = clients.Height / asize.Height;
                    scaleh = clients.Width / asize.Width;
                    if (scalev < scaleh)
                    {
                        ChangePreviewScale(scalev);
                    }
                    else
                    {
                        ChangePreviewScale(scaleh);
                    }
                }
                else
                {
                    // Determine how many pages will fit horizontal
                    int intpagerowsv = 0;
                    int intpagecolsv = intentirepcount;
                    int pixelwidth;
                    do
                    {
                        intpagerowsv++;
                        scalev     = (clients.Height / intpagerowsv) / asize.Height;
                        pixelwidth = (int)(asize.Width * scalev);
                        if (pixelwidth <= 0)
                        {
                            scalev = 0.0F;
                            break;
                        }
                        intpagecolsv = (int)(clients.Width / pixelwidth);
                    } while (((intpagecolsv * intpagerowsv) < intentirepcount) || (intpagecolsv < 0));
                    while (((intpagecolsv - 1) * intpagerowsv) >= intentirepcount)
                    {
                        intpagecolsv--;
                    }
                    while (intpagerowsv > intentirepcount)
                    {
                        intpagerowsv--;
                    }
                    int intpagerowsh = intentirepcount;
                    int intpagecolsh = 0;
                    int pixelheight;
                    do
                    {
                        intpagecolsh++;
                        scaleh      = (clients.Width / intpagecolsh) / asize.Width;
                        pixelheight = (int)(asize.Height * scaleh);
                        if (pixelheight <= 0)
                        {
                            scaleh = 0.0F;
                            break;
                        }
                        intpagerowsh = (int)(clients.Height / pixelheight);
                    } while (((intpagecolsh * intpagerowsh) < intentirepcount) || (intpagerowsh <= 0));
                    while (((intpagecolsh) * (intpagerowsh - 1)) >= intentirepcount)
                    {
                        intpagerowsh--;
                    }
                    while (intpagecolsh > intentirepcount)
                    {
                        intpagecolsh--;
                    }
                    if (scaleh > scalev)
                    {
                        pagerows = intpagerowsh;
                        pagecols = intpagecolsh;
                        scalev   = scaleh;
                    }
                    else
                    {
                        pagerows = intpagerowsv;
                        pagecols = intpagecolsv;
                    }
                    if (pagecols < 0)
                    {
                        pagecols = 1;
                    }
                    if (pagerows < 0)
                    {
                        pagerows = 1;
                    }
                    ChangePreviewScale(scalev);
                }
                break;

            case AutoScaleType.Wide:
                float scalewide = (float)(clients.Width - FBarWidth) / asize.Width;
                ChangePreviewScale(scalewide);
                break;

            case AutoScaleType.Height:
                float scaleheight = (float)(clients.Height - FBarHeight) / asize.Height;
                ChangePreviewScale(scaleheight);
                break;
            }
            bool dorefresh = false;
            int pwidth     = (int)((float)metapage.PhysicWidth * FPreviewScale * dpix / 1440);
            int pheight    = (int)((float)metapage.PhysicHeight * FPreviewScale * dpiy / 1440);
            if (pwidth <= 0)
            {
                pwidth = 2;
            }
            if (pheight <= 0)
            {
                pheight = 2;
            }
            pagewidthdrawn  = pwidth;
            pageheightdrawn = pheight;
            newwidth        = pwidth * pagecols;
            newheight       = pheight * pagerows;
            if (newwidth <= 0)
            {
                newwidth = 1;
            }
            if (newheight <= 0)
            {
                newheight = 1;
            }
            if ((newheight != FBitmap.Height) || (newwidth != FBitmap.Width))
            {
                dorefresh = true;
                if (FBitmap != null)
                {
                    FBitmap.Dispose();
                    FBitmap = null;
                }
                FBitmap      = new Bitmap(newwidth, newheight);
                image.Image  = FBitmap;
                image.Width  = newwidth;
                image.Height = newheight;
            }
            else
            if ((FPageDrawn != FPage) || (FScaleDrawn != FPreviewScale) || FPagesDrawn != intentirepcount)
            {
                dorefresh = true;
            }
            if ((dorefresh) || (forcerefresh))
            {
                FPagesDrawn = intentirepcount;
                Graphics gr   = Graphics.FromImage(FBitmap);
                Pen      apen = new Pen(BackColor);
                pagecolsdrawn = pagecols;
                pagerowsdrawn = pagerows;


                if (intentirepcount == 1)
                {
                    prdriver.Output = FBitmap;
#if REPMAN_COMPACT
#else
                    prdriver.OptimizeWMF = OptimizeWMF;
#endif
                    prdriver.DrawPage(FMetaFile, FMetaFile.Pages[FPage]);
                    gr.DrawLine(apen, FBitmap.Width - 1, 0, FBitmap.Width - 1, FBitmap.Height - 1);
                    gr.DrawLine(apen, 0, FBitmap.Height - 1, FBitmap.Width - 1, FBitmap.Height - 1);
                }
                else
                {
                    if (FIntBitmap == null)
                    {
                        FIntBitmap = new Bitmap(pwidth, pheight);
                    }
                    else
                    {
                        if ((FIntBitmap.Width != pwidth) || (FIntBitmap.Height != pheight))
                        {
                            FIntBitmap.Dispose();
                            FIntBitmap = null;
                            FIntBitmap = new Bitmap(pwidth, pheight);
                        }
                    }
                    int pdrawn = 0;
                    int x;
                    int y;
                    if (FEntireTopDown)
                    {
                        for (x = 0; x < pagecols; x++)
                        {
                            for (y = 0; y < pagerows; y++)
                            {
                                if (pdrawn < intentirepcount)
                                {
                                    prdriver.Output = FIntBitmap;
#if REPMAN_COMPACT
#else
                                    prdriver.OptimizeWMF = OptimizeWMF;
#endif
                                    prdriver.DrawPage(FMetaFile, FMetaFile.Pages[FPage + pdrawn]);
                                    gr.DrawImage(FIntBitmap, x * pwidth, y * pheight);
                                    gr.DrawLine(apen, (x + 1) * pwidth - 1, y * pheight - 1, (x + 1) * pwidth - 1, (y + 1) * pheight - 1);
                                    gr.DrawLine(apen, (x) * pwidth - 1, (y + 1) * pheight - 1, (x + 1) * pwidth - 1, (y + 1) * pheight - 1);
                                }
                                else
                                {
                                    Brush abrush = new SolidBrush(BackColor);
                                    gr.FillRectangle(abrush, x * pwidth, y * pheight, (x + 1) * pwidth, (y + 1) * (pheight));
                                }
                                pdrawn++;
                            }
                        }
                    }
                    else
                    {
                        for (y = 0; y < pagerows; y++)
                        {
                            for (x = 0; x < pagecols; x++)
                            {
                                if (pdrawn < intentirepcount)
                                {
                                    prdriver.Output = FIntBitmap;
#if REPMAN_COMPACT
#else
                                    prdriver.OptimizeWMF = OptimizeWMF;
#endif
                                    prdriver.DrawPage(FMetaFile, FMetaFile.Pages[FPage + pdrawn]);
                                    gr.DrawImage(FIntBitmap, x * pwidth, y * pheight);
                                    gr.DrawLine(apen, (x + 1) * pwidth - 1, y * pheight - 1, (x + 1) * pwidth - 1, (y + 1) * pheight - 1);
                                    gr.DrawLine(apen, (x) * pwidth - 1, (y + 1) * pheight - 1, (x + 1) * pwidth - 1, (y + 1) * pheight - 1);
                                }
                                else
                                {
                                    Brush abrush = new SolidBrush(BackColor);
                                    gr.FillRectangle(abrush, x * pwidth, y * pheight, (x + 1) * pwidth, (y + 1) * (pheight));
                                }
                                pdrawn++;
                            }
                        }
                    }
                }
                FPageDrawn  = FPage;
                FScaleDrawn = FPreviewScale;
                image.Refresh();
            }
            DoResize();
            if (dorefresh)
            {
                if (OnPageDrawn != null)
                {
                    OnPageDrawn(this);
                }
            }
#if REPMAN_COMPACT
#else
        }

        finally
        {
            prdriver.Previewing = false;
            ResumeLayout();
        }
#endif
        }
コード例 #18
0
 /// <summary>
 /// The driver should start a new page
 /// </summary>
 public override void NewPage(MetaFile meta, MetaPage page)
 {
 }
コード例 #19
0
        public static void PrintObject(object sh, MetaPage page, MetaObject obj, int dpix,
                                       int dpiy, SortedList rows, SortedList columns,
                                       string FontName, int FontSize, int rowinit, double Precision)
        {
            const int xlHAlignCenter = -4108;
            const int xlHAlignLeft   = -4131;
            const int xlHAlignRight  = -4152;
            string    atext;
            int       arow;
            int       acolumn;
            bool      isanumber;
            FontStyle astyle;
            Color     acolor;
            bool      isadate;

            string topstring  = ((double)obj.Top / Precision).ToString("0000000000");
            string leftstring = ((double)obj.Left / Precision).ToString("0000000000");

            arow    = rows.IndexOfKey(topstring) + 1 + rowinit;
            acolumn = columns.IndexOfKey(leftstring) + 1;
            if (acolumn < 1)
            {
                acolumn = 1;
            }
            if (arow < 1)
            {
                arow = 1;
            }
            object cells = sh.GetType().InvokeMember("Cells",
                                                     System.Reflection.BindingFlags.GetProperty, null, sh, null);

            object[] param2 = new object[2];
            param2[0] = arow;
            param2[1] = acolumn;
            object[] param1 = new object[1];
            object   cell   = cells.GetType().InvokeMember("Item",
                                                           System.Reflection.BindingFlags.GetProperty, null, cells, param2);

            switch (obj.MetaType)
            {
            case MetaObjectType.Text:
                MetaObjectText objt = (MetaObjectText)obj;
                atext = page.GetText(objt);

                // If it's a number
                bool assigned = false;
                isanumber = DoubleUtil.IsNumeric(atext, System.Globalization.NumberStyles.Any);
                if (isanumber)
                {
                    param1[0] = System.Convert.ToDouble(atext);
                    cell.GetType().InvokeMember("Value",
                                                System.Reflection.BindingFlags.SetProperty,
                                                null, cell, param1);
                    assigned = true;
                }
                else
                {
                    DateTime mydate;
                    isadate = DateUtil.IsDateTime(atext, out mydate);
                    if (isadate)
                    {
                        param1[0] = mydate;
                        cell.GetType().InvokeMember("Value",
                                                    System.Reflection.BindingFlags.SetProperty,
                                                    null, cell, param1);
                        assigned = true;
                    }
                    else
                    if (atext.Length > 0)
                    {
                        if (atext[0] == '=')
                        {
                            atext = "'" + atext;
                        }
                        param1[0] = atext;
                        cell.GetType().InvokeMember("Value",
                                                    System.Reflection.BindingFlags.SetProperty,
                                                    null, cell, param1);
                        assigned = true;
                    }
                }
                if (assigned)
                {
                    object shfont = cell.GetType().InvokeMember("Font",
                                                                System.Reflection.BindingFlags.GetProperty,
                                                                null, cell, null);
                    string nfontname = page.GetWFontNameText(objt);
                    if (FontName != nfontname)
                    {
                        param1[0] = nfontname;
                        shfont.GetType().InvokeMember("Name",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    if (objt.FontSize != FontSize)
                    {
                        param1[0] = objt.FontSize;
                        shfont.GetType().InvokeMember("Size",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    acolor = GraphicUtils.ColorFromInteger(objt.FontColor);
                    if (acolor.ToArgb() != Color.Black.ToArgb())
                    {
                        param1[0] = objt.FontColor;
                        shfont.GetType().InvokeMember("Color",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    astyle = GraphicUtils.FontStyleFromInteger(objt.FontStyle);
                    if ((astyle & FontStyle.Italic) > 0)
                    {
                        param1[0] = true;
                        shfont.GetType().InvokeMember("Italic",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    if ((astyle & FontStyle.Bold) > 0)
                    {
                        param1[0] = true;
                        shfont.GetType().InvokeMember("Bold",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    if ((astyle & FontStyle.Underline) > 0)
                    {
                        param1[0] = true;
                        shfont.GetType().InvokeMember("Underline",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    if ((astyle & FontStyle.Strikeout) > 0)
                    {
                        param1[0] = true;
                        shfont.GetType().InvokeMember("Strikethrough",
                                                      System.Reflection.BindingFlags.SetProperty,
                                                      null, shfont, param1);
                    }
                    // Font rotation not possible
                    if ((objt.Alignment & MetaFile.AlignmentFlags_AlignHCenter) > 0)
                    {
                        param1[0] = xlHAlignCenter;
                        cell.GetType().InvokeMember("HorizontalAlignment",
                                                    System.Reflection.BindingFlags.SetProperty,
                                                    null, cell, param1);
                    }
                    // Multiline not supported
                    //    if (obj.AlignMent AND AlignmentFlags_SingleLine)=0 then
                    //     sh.Cells.item[arow,acolumn].Multiline:=true;
                    if ((objt.Alignment & MetaFile.AlignmentFlags_AlignLeft) > 0)
                    {
                        if (isanumber)
                        {
                            param1[0] = xlHAlignLeft;
                            cell.GetType().InvokeMember("HorizontalAlignment",
                                                        System.Reflection.BindingFlags.SetProperty,
                                                        null, cell, param1);
                        }
                    }
                    if ((objt.Alignment & MetaFile.AlignmentFlags_AlignRight) > 0)
                    {
                        if (!isanumber)
                        {
                            param1[0] = xlHAlignRight;
                            cell.GetType().InvokeMember("HorizontalAlignment",
                                                        System.Reflection.BindingFlags.SetProperty,
                                                        null, cell, param1);
                        }
                    }
                    // Word wrap not supported
                    //    if obj.WordWrap then
                    //     sh.Cells.item[arow,acolumn].WordWrap:=True;
                    //    if Not obj.CutText then
                    //     aalign:=aalign or DT_NOCLIP;
                    //    if obj.RightToLeft then
                    //     aalign:=aalign or DT_RTLREADING;
                    // In office 97, not supported
                    //    if Not obj.Transparent then
                    //     sh.Cells.Item[arow,acolumn].Color:=CLXColorToVCLColor(obj.BackColor);
                }
                break;
            }
        }
コード例 #20
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            if (DesignMode)
            {
                base.RenderContents(output);
                return;
            }
            Bitmap bm;
            // Execute the report and save the memory stream and
            // the mimetype on cache
            string cacheid = GetCacheId();
            // Check if there is a metafile
            MetaFile meta = GetMetaFile();

            Monitor.Enter(meta);
            try
            {
                PrintOutNet prdriver = (PrintOutNet)Page.Cache[cacheid + "PrintOut"];
                if (prdriver == null)
                {
                    prdriver = new PrintOutNet();
                }

                if (meta != null)
                {
                    int pagenum = CurrentPage;
                    meta.RequestPage(pagenum);
                    if (meta.Pages.CurrentCount <= pagenum)
                    {
                        pagenum = meta.Pages.CurrentCount - 1;
                        Page.Cache.Insert(cacheid + "LastPage", pagenum, null,
                                          DateTime.Now.AddMinutes(30), TimeSpan.Zero);
                    }
                    else
                    {
                        Page.Cache.Remove(cacheid + "LastPage");
                    }
                    if (pagenum < meta.Pages.CurrentCount)
                    {
                        System.Drawing.Imaging.Metafile metaf;
                        MetaPage metap = meta.Pages[pagenum];
                        if (metap.WindowsMetafile == null)
                        {
                            bm = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
                            prdriver.Output = bm;
                            prdriver.DrawPage(meta, metap);
                            metaf = metap.WindowsMetafile;
                            if (metaf == null)
                            {
                                throw new Exception("No se pudo crear el metafile");
                            }
                        }
                        else
                        {
                            metaf = metap.WindowsMetafile;
                        }
                        string       mimetype;
                        MemoryStream mems = new MemoryStream();
                        try
                        {
                            switch (Format)
                            {
                            case "WMF":
                                GraphicUtils.WriteWindowsMetaFile(metaf,
                                                                  mems, PreviewScale / metap.WindowsMetafileScale);
                                mimetype = "application/x-msMetafile";
                                break;

                            default:
                                GraphicUtils.WriteWindowsMetaFileCodec(metaf,
                                                                       mems, PreviewScale / metap.WindowsMetafileScale,
                                                                       Format, out mimetype);
                                break;
                            }
                            Page.Cache.Insert(cacheid + "mimetype", mimetype, null,
                                              DateTime.Now.AddMinutes(10), TimeSpan.Zero);
                            Page.Cache.Insert(cacheid + "memstream", mems, null,
                                              DateTime.Now.AddMinutes(10), TimeSpan.Zero);
                        }
                        catch
                        {
                            mems.Dispose();
                            throw;
                        }
                    }
                }
            }
            finally
            {
                Monitor.Exit(meta);
            }
            base.RenderContents(output);
        }
コード例 #21
0
        public async Task <IActionResult> CreateMetaPage(
            [FromBody] MetaPageForUpdateDto metaPageForUpdate)
        {
            if (metaPageForUpdate == null)
            {
                ModelState.AddModelError("Message", "Unable to locate payload for new request");
            }

            if (Regex.Matches(metaPageForUpdate.PageName, @"[a-zA-Z0-9 ]").Count < metaPageForUpdate.PageName.Length)
            {
                ModelState.AddModelError("Message", "Page name contains invalid characters (Enter A-Z, a-z, 0-9, space)");
                return(BadRequest(ModelState));
            }

            if (!string.IsNullOrWhiteSpace(metaPageForUpdate.PageDefinition))
            {
                if (Regex.Matches(metaPageForUpdate.PageDefinition, @"[-a-zA-Z0-9 .,]").Count < metaPageForUpdate.PageDefinition.Length)
                {
                    ModelState.AddModelError("Message", "Page definition contains invalid characters (Enter A-Z, a-z, 0-9, space, hyphen, period, comma)");
                    return(BadRequest(ModelState));
                }
            }

            if (!string.IsNullOrWhiteSpace(metaPageForUpdate.Breadcrumb))
            {
                if (Regex.Matches(metaPageForUpdate.Breadcrumb, @"[-a-zA-Z0-9 .,]").Count < metaPageForUpdate.Breadcrumb.Length)
                {
                    ModelState.AddModelError("Message", "Bread crumb contains invalid characters (Enter A-Z, a-z, 0-9, space, hyphen, period, comma)");
                    return(BadRequest(ModelState));
                }
            }

            if (_unitOfWork.Repository <MetaPage>().Queryable().
                Where(l => l.PageName == metaPageForUpdate.PageName)
                .Count() > 0)
            {
                ModelState.AddModelError("Message", "Item with same name already exists");
            }

            if (ModelState.IsValid)
            {
                var newMetaPage = new MetaPage()
                {
                    PageName       = metaPageForUpdate.PageName,
                    PageDefinition = metaPageForUpdate.PageDefinition,
                    Breadcrumb     = metaPageForUpdate.Breadcrumb,
                    IsSystem       = false,
                    MetaDefinition = string.Empty,
                    MetaPageGuid   = Guid.NewGuid(),
                    IsVisible      = (metaPageForUpdate.Visible == Models.ValueTypes.YesNoValueType.Yes)
                };

                _metaPageRepository.Save(newMetaPage);

                var mappedMetaPage = await GetMetaPageAsync <MetaPageIdentifierDto>(newMetaPage.Id);

                if (mappedMetaPage == null)
                {
                    return(StatusCode(500, "Unable to locate newly added item"));
                }

                return(CreatedAtAction("GetMetaPageByIdentifier",
                                       new
                {
                    id = mappedMetaPage.Id
                }, CreateLinksForMetaPage <MetaPageIdentifierDto>(mappedMetaPage)));
            }

            return(BadRequest(ModelState));
        }
コード例 #22
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                _id = Convert.ToInt32(Request.QueryString["id"]);
                if (_id > 0)
                {
                    _metaWidget = UnitOfWork.Repository <MetaWidget>().Get(_id);

                    string action;
                    if (Request.QueryString["action"] != null)
                    {
                        action = Request.QueryString["action"];
                        switch (action)
                        {
                        case "35EF6F4A-1CF6-4F94-B92A-145AC57D1135":
                            _formMode = FormMode.EditMode;
                            Master.SetPageHeader(new Models.PageHeaderDetail()
                            {
                                Title = "Edit Widget", SubTitle = "", Icon = "fa fa-windows fa-fw"
                            });

                            break;
                        } // switch (_action)
                    }
                    else
                    {
                        throw new Exception("action not passed as parameter");
                    }
                }
                else
                {
                    _metaWidget = null;
                    _formMode   = FormMode.AddMode;
                    Master.SetPageHeader(new Models.PageHeaderDetail()
                    {
                        Title = "Add New Widget", SubTitle = "", Icon = "fa fa-windows fa-fw"
                    });

                    if (Request.QueryString["pid"] != null)
                    {
                        _pid = Convert.ToInt32(Request.QueryString["pid"]);
                        if (_pid > 0)
                        {
                            _metaPage = UnitOfWork.Repository <MetaPage>().Get(_pid);
                        }
                        else
                        {
                            throw new Exception("pid not passed as parameter");
                        }
                    }
                }
            }
            else
            {
                throw new Exception("id not passed as parameter");
            }

            LoadDropDownList();
            RenderButtons();
            RenderPage();
            if (_metaWidget != null)
            {
                RenderWidget();
            }
            ToggleView();
        }
コード例 #23
0
ファイル: rplabelitem.cs プロジェクト: chtheis/reportman.net
        override protected void DoPrint(PrintOut adriver, int aposx, int aposy,
                                        int newwidth, int newheight, MetaFile metafile, Point MaxExtent,
                                        ref bool PartialPrint)
        {
            int    newposition;
            string avalue;

            base.DoPrint(adriver, aposx, aposy, newwidth, newheight,
                         metafile, MaxExtent, ref PartialPrint);
            LastMetaIndex = -1;

            TextObjectStruct TextObj = GetTextObject();

            if (PrintOnlyOne)
            {
                if (FOldString == TextObj.Text)
                {
                    return;
                }
            }
            FOldString = TextObj.Text;
            if (MultiPage || FForcedPartial)
            {
                MaxExtent.X = PrintWidth;
                newposition = MetaFile.CalcTextExtent(Report.Driver, MaxExtent, TextObj);
                if (newposition < TextObj.Text.Length)
                {
                    if (!FIsPartial)
                    {
                        PartialPos = 0;
                    }
                    FIsPartial   = true;
                    PartialPrint = true;
                    PartialPos   = PartialPos + newposition;
                    TextObj.Text = TextObj.Text.Substring(0, newposition);
                }
                else
                {
                    FIsPartial     = false;
                    FForcedPartial = false;
                }
            }
            MetaPage       apage = metafile.Pages[metafile.CurrentPage];
            MetaObjectText aobj  = new MetaObjectText();

            aobj.MetaType     = MetaObjectType.Text;
            aobj.Left         = aposx;
            aobj.Top          = aposy;
            aobj.Width        = PrintWidth;
            aobj.Height       = PrintHeight;
            aobj.Alignment    = TextObj.Alignment;
            aobj.PrintStep    = PrintStep;
            aobj.BackColor    = BackColor;
            aobj.Transparent  = Transparent;
            aobj.CutText      = CutText;
            aobj.FontColor    = FontColor;
            aobj.FontRotation = FontRotation;
            aobj.Type1Font    = Type1Font;
            aobj.FontSize     = FontSize;
            aobj.FontStyle    = (short)FontStyle;
            aobj.TextP        = apage.AddString(TextObj.Text);
            aobj.TextS        = TextObj.Text.Length;
            aobj.WordWrap     = WordWrap;
            aobj.LFontNameP   = apage.AddString(LFontName);
            aobj.LFontNameS   = LFontName.Length;
            aobj.WFontNameP   = apage.AddString(WFontName);
            aobj.WFontNameS   = WFontName.Length;
            apage.Objects.Add(aobj);

            LastMetaIndex = metafile.Pages[metafile.CurrentPage].Objects.Count - 1;
            // Is Total pages variable?
            if (IsPageCount)
            {
                Report.AddTotalPagesItem(metafile.CurrentPage, metafile.Pages[metafile.CurrentPage].Objects.Count - 1, DisplayFormat);
            }
            if (ExportValue.VarType != VariantType.Null)
            {
                try
                {
                    avalue = FExportValue.ToString(ExportDisplayFormat, ParamType.Unknown, true);

                    MetaObjectExport nobj = new MetaObjectExport();
                    nobj.MetaType  = MetaObjectType.Export;
                    nobj.Left      = aposx;
                    nobj.Top       = aposy;
                    nobj.Width     = PrintWidth;
                    nobj.Height    = PrintHeight;
                    nobj.TextExpP  = apage.AddString(avalue);
                    nobj.TextExpS  = avalue.Length;
                    nobj.Line      = ExportLine;
                    nobj.Position  = ExportPosition;
                    nobj.DoNewLine = ExportDoNewLine;
                    nobj.Size      = ExportSize;
                    apage.Objects.Add(nobj);
                }
                catch (Exception E)
                {
                    throw new ReportException(E.Message + "Expression-" + Name + " ExportDisplayFormat",
                                              this, "ExportDisplayFormat");
                }
            }
        }