示例#1
0
        public bool SetSecure(Subject s)
        {
            try
            {
                ISecureContextData secure = Access <ISecureContextData>();
                List <string>      v      = new List <string>();
                string[]           names  = s.ToItemNameArray();
                object[]           values = s.ToItemValueArray();
                object             reasons;
                string             decision = "accept", appSignature = string.Empty;
                int  transaction;
                bool noContinue = true, disconnect = false;

                transaction = _ContextManager.StartContextChanges(_ParticipantCoupon);
                for (int i = 0; i < names.Length; i++)
                {
                    v.Add(values[i].ToString());
                }

                appSignature = _ParticipantCoupon.ToString() + string.Join("", names) +
                               string.Join("", v.ToArray()) + transaction.ToString();
                appSignature = CreateSignature(appSignature);
                secure.SetItemValues(_ParticipantCoupon, names, values, transaction, appSignature);
                reasons = _ContextManager.EndContextChanges(transaction, ref noContinue);

                //
                // If any application responded that they cannot apply the change we need to display
                // a dialog that displays the reasons for the problems.
                //
                if ((reasons != null && ((string[])reasons).Length > 0) || noContinue)
                {
                    ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue);
                    DialogResult  result;

                    result = pd.ShowDialog();
                    if (noContinue)
                    {
                        decision = "cancel";
                    }
                    if (result == DialogResult.OK)
                    {
                        decision = "accept";
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        decision = "cancel";
                    }
                    else
                    {
                        decision   = "cancel";
                        disconnect = true;
                    }
                }

                _ContextManager.PublishChangesDecision(transaction, decision);
                if (decision == "accept")
                {
                }

                if (disconnect)
                {
                    Leave();
                }
            }
            catch (Exception e)
            {
                Messager.ShowError(null, e);
                return(false);
            }
            return(true);
        }
示例#2
0
        //Use this load to load an image using the open dialog
        public int Load(IWin32Window owner, RasterCodecs codecs, bool autoLoad)
        {
            using (RasterOpenDialog ofd = new RasterOpenDialog(codecs))
            {
                ofd.DereferenceLinks             = true;
                ofd.CheckFileExists              = false;
                ofd.CheckPathExists              = true;
                ofd.EnableSizing                 = true;
                ofd.Filter                       = Filters;
                ofd.FilterIndex                  = _filterIndex;
                ofd.LoadFileImage                = false;
                ofd.LoadOptions                  = false;
                ofd.LoadRotated                  = true;
                ofd.LoadCompressed               = true;
                ofd.LoadMultithreaded            = codecs.Options.Jpeg.Load.Multithreaded;
                ofd.ShowLoadMultithreaded        = true;
                ofd.Multiselect                  = _multiSelect;
                ofd.ShowGeneralOptions           = true;
                ofd.ShowLoadCompressed           = true;
                ofd.ShowLoadOptions              = true;
                ofd.ShowLoadRotated              = true;
                ofd.ShowMultipage                = true;
                ofd.UseGdiPlus                   = UseGdiPlus;
                ofd.ShowPdfOptions               = ShowPdfOptions;
                ofd.ShowXpsOptions               = ShowXpsOptions;
                ofd.ShowXlsOptions               = ShowXlsOptions;
                ofd.ShowRasterizeDocumentOptions = ShowRasterizeDocumentOptions;
                ofd.EnableFileInfoModeless       = true;
                ofd.EnableFileInfoResizing       = true;
                ofd.ShowVffOptions               = ShowVffOptions;
                ofd.ShowAnzOptions               = ShowAnzOptions;
                ofd.ShowVectorOptions            = ShowVectorOptions;
                ofd.ShowPreview                  = true;
                ofd.ShowProgressive              = true;
                ofd.ShowRasterOptions            = true;
                ofd.ShowTotalPages               = true;
                ofd.ShowDeletePage               = true;
                ofd.ShowFileInformation          = true;
                ofd.UseFileStamptoPreview        = true;
                ofd.PreviewWindowVisible         = true;
                ofd.Title         = "LEADTOOLS Open Dialog";
                ofd.FileName      = FileName;
                ofd.LoadCorrupted = LoadCorrupted;
                ofd.PreferVector  = PreferVector;
                if (!String.IsNullOrEmpty(_openDialogInitialPath))
                {
                    ofd.InitialDirectory = _openDialogInitialPath;
                }

                if (ofd.ShowDialog(owner) == DialogResult.OK)
                {
                    foreach (RasterDialogFileData item in ofd.OpenedFileData)
                    {
                        FileName = item.Name;

                        _filterIndex = ofd.FilterIndex;

                        // Set the RasterizeDocument load options before calling GetInformation
                        codecs.Options.RasterizeDocument.Load.PageWidth    = item.Options.RasterizeDocumentOptions.PageWidth;
                        codecs.Options.RasterizeDocument.Load.PageHeight   = item.Options.RasterizeDocumentOptions.PageHeight;
                        codecs.Options.RasterizeDocument.Load.LeftMargin   = item.Options.RasterizeDocumentOptions.LeftMargin;
                        codecs.Options.RasterizeDocument.Load.TopMargin    = item.Options.RasterizeDocumentOptions.TopMargin;
                        codecs.Options.RasterizeDocument.Load.RightMargin  = item.Options.RasterizeDocumentOptions.RightMargin;
                        codecs.Options.RasterizeDocument.Load.BottomMargin = item.Options.RasterizeDocumentOptions.BottomMargin;
                        codecs.Options.RasterizeDocument.Load.Unit         = item.Options.RasterizeDocumentOptions.Unit;
                        codecs.Options.RasterizeDocument.Load.XResolution  = item.Options.RasterizeDocumentOptions.XResolution;
                        codecs.Options.RasterizeDocument.Load.YResolution  = item.Options.RasterizeDocumentOptions.YResolution;
                        codecs.Options.RasterizeDocument.Load.SizeMode     = item.Options.RasterizeDocumentOptions.SizeMode;

                        if (item.FileInfo.Format == RasterImageFormat.Afp || item.FileInfo.Format == RasterImageFormat.Ptoca)
                        {
                            codecs.Options.Ptoka.Load.Resolution = codecs.Options.RasterizeDocument.Load.XResolution;
                        }

                        // Set the user Options
                        codecs.Options.Load.Passes             = item.Passes;
                        codecs.Options.Load.Rotated            = item.LoadRotated;
                        codecs.Options.Load.Compressed         = item.LoadCompressed;
                        codecs.Options.Load.LoadCorrupted      = ofd.LoadCorrupted;
                        codecs.Options.Load.PreferVector       = ofd.PreferVector;
                        codecs.Options.Jpeg.Load.Multithreaded = item.LoadMultithreaded;

                        switch (item.Options.FileType)
                        {
                        case RasterDialogFileOptionsType.Meta:
                        {
                            // Set the user options
                            codecs.Options.Wmf.Load.XResolution = item.Options.MetaOptions.XResolution;
                            codecs.Options.Wmf.Load.YResolution = item.Options.MetaOptions.XResolution;
                            break;
                        }

                        case RasterDialogFileOptionsType.Pdf:
                        {
                            if (codecs.Options.Pdf.Load.UsePdfEngine)
                            {
                                // Set the user options
                                codecs.Options.Pdf.Load.DisplayDepth  = item.Options.PdfOptions.DisplayDepth;
                                codecs.Options.Pdf.Load.GraphicsAlpha = item.Options.PdfOptions.GraphicsAlpha;
                                codecs.Options.Pdf.Load.TextAlpha     = item.Options.PdfOptions.TextAlpha;
                                codecs.Options.Pdf.Load.UseLibFonts   = item.Options.PdfOptions.UseLibFonts;
                            }

                            break;
                        }

                        case RasterDialogFileOptionsType.Misc:
                        {
                            switch (item.FileInfo.Format)
                            {
                            case RasterImageFormat.Jbig:
                            {
                                // Set the user options
                                codecs.Options.Jbig.Load.Resolution = new LeadSize(item.Options.MiscOptions.XResolution,
                                                                                   item.Options.MiscOptions.YResolution);
                                break;
                            }

                            case RasterImageFormat.Cmw:
                            {
                                // Set the user options
                                codecs.Options.Jpeg2000.Load.CmwResolution = new LeadSize(item.Options.MiscOptions.XResolution,
                                                                                          item.Options.MiscOptions.YResolution);
                                break;
                            }

                            case RasterImageFormat.Jp2:
                            {
                                // Set the user options
                                codecs.Options.Jpeg2000.Load.Jp2Resolution = new LeadSize(item.Options.MiscOptions.XResolution,
                                                                                          item.Options.MiscOptions.YResolution);
                                break;
                            }

                            case RasterImageFormat.J2k:
                            {
                                // Set the user options
                                codecs.Options.Jpeg2000.Load.J2kResolution = new LeadSize(item.Options.MiscOptions.XResolution,
                                                                                          item.Options.MiscOptions.YResolution);
                                break;
                            }
                            }

                            break;
                        }

                        case RasterDialogFileOptionsType.Xls:
                        {
                            // Set the user options
                            codecs.Options.Xls.Load.MultiPageSheet  = item.Options.XlsOptions.MultiPageSheet;
                            codecs.Options.Xls.Load.ShowHiddenSheet = item.Options.XlsOptions.ShowHiddenSheet;
#if LEADTOOLS_V20_OR_LATER
                            codecs.Options.Xls.Load.MultiPageUseSheetWidth = item.Options.XlsOptions.MultiPageUseSheetWidth;
                            codecs.Options.Xls.Load.PageOrderDownThenOver  = item.Options.XlsOptions.PageOrderDownThenOver;
                            codecs.Options.Xls.Load.MultiPageEnableMargins = item.Options.XlsOptions.MultiPageEnableMargins;
#endif //#if LEADTOOLS_V20_OR_LATER
                        }
                        break;

                        case RasterDialogFileOptionsType.Vff:
                        {
                            codecs.Options.Vff.Load.View = item.Options.VffOptions.View;
                            break;
                        }

                        case RasterDialogFileOptionsType.Anz:
                        {
                            codecs.Options.Anz.Load.View = item.Options.AnzOptions.View;
                            break;
                        }

                        case RasterDialogFileOptionsType.Vector:
                        {
                            codecs.Options.Vector.Load.BackgroundColor      = item.Options.VectorOptions.Options.BackgroundColor;
                            codecs.Options.Vector.Load.BitsPerPixel         = item.Options.VectorOptions.Options.BitsPerPixel;
                            codecs.Options.Vector.Load.ForceBackgroundColor = item.Options.VectorOptions.Options.ForceBackgroundColor;
                            codecs.Options.Vector.Load.ViewHeight           = item.Options.VectorOptions.Options.ViewHeight;
                            codecs.Options.Vector.Load.ViewMode             = item.Options.VectorOptions.Options.ViewMode;
                            codecs.Options.Vector.Load.ViewWidth            = item.Options.VectorOptions.Options.ViewWidth;
                            break;
                        }
                        }

                        int firstPage = 1;
                        int lastPage  = 1;
                        int infoTotalPages;

                        CodecsImageInfo info = null;

                        using (WaitCursor wait = new WaitCursor())
                        {
                            info           = codecs.GetInformation(FileName, true);
                            infoTotalPages = info.TotalPages;
                        }

                        if (_showLoadPagesDialog)
                        {
                            firstPage = 1;
                            lastPage  = infoTotalPages;

                            if (firstPage != lastPage)
                            {
                                using (ImageFileLoaderPagesDialog dlg = new ImageFileLoaderPagesDialog(infoTotalPages, LoadOnlyOnePage))
                                {
                                    if (dlg.ShowDialog(owner) == DialogResult.OK)
                                    {
                                        firstPage = dlg.FirstPage;
                                        lastPage  = dlg.LastPage;
                                    }
                                    else
                                    {
                                        if (info != null)
                                        {
                                            info.Dispose();
                                        }
                                        return(0);
                                    }
                                }
                            }
                        }
                        else
                        {
                            firstPage = item.PageNumber;
                            lastPage  = item.PageNumber;
                        }

                        _firstPage = firstPage;
                        _lastPage  = lastPage;

                        if (!SetDocumentLoadResultion(codecs, info, firstPage, lastPage))
                        {
                            info.Dispose();
                            return(0);
                        }

                        if (autoLoad)
                        {
                            using (WaitCursor wait = new WaitCursor())
                            {
                                _image = codecs.Load(FileName, 0, CodecsLoadByteOrder.BgrOrGray, firstPage, lastPage);
                                if (codecs.LoadStatus != RasterExceptionCode.Success)
                                {
                                    String message = String.Format("The image was only partially loaded due to error: {0}", codecs.LoadStatus.ToString());
                                    Messager.Show(null, message, MessageBoxIcon.Information, MessageBoxButtons.OK);
                                }
                                if (_image != null)
                                {
                                    _image.CustomData.Add("IsBigTiff", info.Tiff.IsBigTiff);
                                    _images.Add(new ImageInformation(_image, item.Name));
                                }
                            }
                        }
                        info.Dispose();
                    }
                }

                return(ofd.OpenedFileData.Count);
            }
        }