/// <summary>
        /// Manejo del evento que provocado por el controlador cuando comienza
        /// a tratar una nueva imagen.
        /// </summary>
        /// <param name="sender">El objeto que provoca el evento.</param>
        /// <param name="arg">El argumento del evento.</param>
        private void OnControllerBitmapProcessedByDatabase(object sender,
                                                           BitmapProcessedArgs arg)
        {
            Gtk.Application.Invoke(sender, arg,
                                   delegate(object resender, EventArgs a)
            {
                if (treeview.NodeSelection.SelectedNodes.Length > 0)
                {
                    // Si hay un simbolo seleccionado,
                    // nos traemos sus imagenes procesadas.
                    SegmentedNode node =
                        (SegmentedNode)(treeview.NodeSelection.SelectedNode);


                    ImageArea imageAreaProcessed = new ImageArea();
                    imageAreaProcessed.Image     =
                        node.MathTextBitmap.LastProcessedImage.CreatePixbuf();
                    imageAreaProcessed.ImageMode = ImageAreaMode.Zoom;


                    processedImageNB.AppendPage(imageAreaProcessed,
                                                new Label(String.Format("BD {0}",
                                                                        processedImageNB.NPages + 1)));

                    processedImageNB.Page = processedImageNB.NPages - 1;

                    // Solo mostramos los tabs si hay mas de una imagen procesada
                    processedImageNB.ShowTabs =
                        node.MathTextBitmap.ProcessedImages.Count > 1;
                }
            });
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="originalContentUrl">
 /// URL of the video file (Max: 1000 characters)
 /// HTTPS, mp4
 /// / Max: 1 minute
 /// / Max: 10 MB
 /// / Note: A very wide or tall video may be cropped when played in some environments.
 /// </param>
 /// <param name="previewImageUrl">
 /// URL of the preview image (Max: 1000 characters)
 /// HTTP, JPEG
 /// / Max: 240 x 240 pixels
 /// / Max: 1 MB
 /// </param>
 /// <param name="area">
 /// Imagemap Area
 /// </param>
 /// <param name="externalLink">
 /// Label. Displayed after the video is finished.
 /// And Webpage URL. Called when the label displayed after the video is tapped.
 /// </param>
 public Video(string originalContentUrl, string previewImageUrl, ImageArea area, ExternalLink externalLink)
 {
     OriginalContentUrl = originalContentUrl;
     PreviewImageUrl    = previewImageUrl;
     Area         = area;
     ExternalLink = externalLink;
 }
Example #3
0
        /// <summary>
        /// Каждое изобржение из базы поделить на зоны
        /// </summary>
        /// <param name="step">шаг зоны</param>
        public static void SaveAreasFromImages(int pattern_id, int step = 128)
        {
            List <ImageArea> areas = new List <ImageArea>();
            int index = DBConnector.GetList <ImageArea>().Max(img => img.Id) + 1;

            foreach (var img_file in DBConnector.GetList <ImageFile>().Where(img => img.PatternId == pattern_id))
            {
                for (int i = 0; i < img_file.Height; i += step)
                {
                    for (int j = 0; j < img_file.Width; j += step)
                    {
                        var area = new ImageArea()
                        {
                            // в аксесе не получилось имполльзовать IsDbGenerated, так как запрос на всатвку с этим атрибутом падал
                            Id       = index,
                            FileName = img_file.FileName,
                            X1       = j,
                            Y1       = i,
                            X2       = j + step,
                            Y2       = i + step,
                            IsDefect = false
                        };
                        //area.Print();
                        index++;
                        areas.Add(area);
                    }
                }
            }
            DBConnector.CreateList(areas);
        }
Example #4
0
        private void OnEnable()
        {
            this.maxSize = new Vector2(600, 600);

            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/BWC/Editor/Game_BWC.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);
            WC      = Resources.Load <Texture2D>("bai");
            BC      = Resources.Load <Texture2D>("hei");
            map     = new Map(guiCanvas.Find <Area>("map"));
            wCount  = guiCanvas.Find <Label>("top/count/w/count");
            bCount  = guiCanvas.Find <Label>("top/count/b/count");
            jiesuan = guiCanvas.Find <ImageArea>("jiesuan");


            GameObject go = new GameObject("BG");

            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            BG           = go.AddComponent <AudioSource>();
            BG.clip      = Resources.Load <AudioClip>("BG");
            BG.Play();
            BG.loop = true;

            go           = new GameObject("sound");
            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            Sound        = go.AddComponent <AudioSource>();
        }
        private void InitializeWidgets()
        {
            originalImageArea           = new ImageArea();
            originalImageArea.ImageMode = ImageAreaMode.Zoom;

            unassistedImagePlaceholder.Add(originalImageArea);

            segmentationStore = new NodeStore(typeof(SegmentedNode));
        }
        private void ImageArea_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            ImageArea.CaptureMouse();
            var MyStylusPointCollection = new StylusPointCollection();

            MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(ImageArea));
            _newStroke = new Stroke(MyStylusPointCollection);
            _newStroke.DrawingAttributes.Color = (LocalizedStrings.LocalizedResources.FeedbackDrawingColor as string).ConvertStringToColor(Colors.Red);

            ImageArea.Strokes.Add(_newStroke);
        }
Example #7
0
 private void TaskStart()
 {
     CameraConfigBox.Enabled = false;
     specButton.Enabled      = saveButton.Enabled = darkButton.Enabled = false;
     Abort.Enabled           = Pause.Enabled = true;
     WorkImage           = Camera.Image;
     GraphScroll.Enabled = imageAcqButton.Checked;
     UpdateGraphScroll();
     Graph.ClearData();
     Graph.MarkerColor = Graph.ColorOrder[0];
     Graph.Invalidate();
     WorkCts = new CancellationTokenSource();
     Paused.Set();
 }
        protected void InitializeWidgets()
        {
            store = new NodeStore(typeof(SegmentedNode));

            // Creamos el NodeView, podría hacerse en el fichero de Glade,
            // aunque alguna razón habría por la que se hizo así.
            treeview           = new NodeView(store);
            treeview.RulesHint = true;

            treeview.ShowExpanders = true;
            treeview.AppendColumn("Imagen",
                                  new CellRendererText(),
                                  "text", 0);

            CellRendererText cellRenderer = new CellRendererText();

            cellRenderer.Xalign = 0.5f;
            treeview.AppendColumn("Etiqueta", cellRenderer, "text", 1);
            treeview.AppendColumn("Posición",
                                  new CellRendererText(),
                                  "text", 2);

            scrolledtree.Add(treeview);

            foreach (TreeViewColumn col in treeview)
            {
                col.Sizing = TreeViewColumnSizing.Autosize;
            }



            // Asignamos el evento para cuando se produzca la selección de un
            // nodo en el árbol.
            treeview.NodeSelection.Changed += OnTreeviewSelectionChanged;

            treeview.ButtonPressEvent +=
                new ButtonPressEventHandler(OnTreeviewButtonPress);

            imageAreaOriginal           = new ImageArea();
            imageAreaOriginal.ImageMode = ImageAreaMode.Zoom;

            frameOriginal.Add(imageAreaOriginal);


            imageAreaNode           = new ImageArea();
            imageAreaNode.ImageMode = ImageAreaMode.Zoom;
            frameNodeActual.Add(imageAreaNode);

            learnImageItem.Image = ImageResources.LoadImage("database16");
        }
Example #9
0
        private Rectangle ConvertImgToPicBox(ImageArea area)
        {
            Point p = new Point(area.X1, area.Y1);
            //Point p = pictureBox1.PointToClient(Cursor.Position);
            Point unscaled_p = new Point();
            Size  size       = new Size();

            // image and container dimensions
            int w_i = pictureBox1.Image.Width;
            int h_i = pictureBox1.Image.Height;
            int w_c = pictureBox1.Width;
            int h_c = pictureBox1.Height;

            float imageRatio     = w_i / (float)h_i; // image W:H ratio
            float containerRatio = w_c / (float)h_c; // container W:H ratio

            if (imageRatio >= containerRatio)
            {
                // horizontal image
                float scaleFactor  = w_c / (float)w_i;
                float scaledHeight = h_i * scaleFactor;
                // calculate gap between top of container and top of image
                float filler = Math.Abs(h_c - scaledHeight) / 2;
                unscaled_p.X = (int)(p.X * scaleFactor);
                unscaled_p.Y = (int)((p.Y * scaleFactor + filler));

                size.Width  = (int)(area.w * scaleFactor);
                size.Height = (int)((area.h * scaleFactor));
            }
            else
            {
                // vertical image
                float scaleFactor = h_c / (float)h_i;
                float scaledWidth = w_i * scaleFactor;
                float filler      = Math.Abs(w_c - scaledWidth) / 2;
                unscaled_p.X = (int)(p.X * scaleFactor + filler);
                unscaled_p.Y = (int)(p.Y * scaleFactor);

                size.Width  = (int)(area.w * scaleFactor);
                size.Height = (int)((area.h * scaleFactor));
            }



            return(new Rectangle(unscaled_p, size));
        }
Example #10
0
        /**
         * render image area to PDF
         *
         * @param area the image area to render
         */

        public void RenderImageArea(ImageArea area)
        {
            int x = this.currentXPosition + area.getXOffset();
            int y = this.currentYPosition;
            int w = area.getContentWidth();
            int h = area.GetHeight();

            this.currentYPosition -= h;

            FonetImage img = area.getImage();

            PdfXObject xobj = this.pdfCreator.AddImage(img);

            CloseText();
            currentStream.FillImage(x, y, w, h, xobj);



            this.currentXPosition += area.getContentWidth();
        }
        /// <summary>
        /// Inicializa los controles de la ventana.
        /// </summary>
        private void Initialize()
        {
            mainWindow.Title = title;

            imageAreaOriginal           = new ImageArea();
            imageAreaOriginal.ImageMode = ImageAreaMode.Zoom;
            frameOriginal.Add(imageAreaOriginal);

            imageAreaProcessed           = new ImageArea();
            imageAreaProcessed.ImageMode = ImageAreaMode.Zoom;
            frameProcessed.Add(imageAreaProcessed);

            logView = new LogView();
            expanderLog.Add(logView);

            // La imagen reducida en la primera columna
            imagesIV.PixbufColumn      = 0;
            imagesIV.SelectionChanged +=
                new EventHandler(OnImagesIVSelectionChanged);

            imagesStore = new ListStore(typeof(Gdk.Pixbuf),
                                        typeof(Gdk.Pixbuf));

            imagesIV.Model = imagesStore;

            imagesStore.RowInserted += OnImagesStoreRowInserted;
            imagesStore.RowDeleted  += OnImagesStoreRowDeleted;

            toolNewDatabase.IconWidget =
                ImageResources.LoadImage("database-new22");

            menuDatabase.Image = ImageResources.LoadImage("database-new16");

            symbolLabelEditor = new SymbolLabelEditorWidget();

            symbolEditorPlaceholder.Add(symbolLabelEditor);

            labelTooltips = new Tooltips();

            mainWindow.ShowAll();
        }
        /// <summary>
        /// Manejo del evento provocado cuando se hace click en un nodo de la
        /// vista de árbol.
        /// </summary>
        /// <param name="sender">El objeto que provoco el evento.</param>
        /// <param name="arg">Los argumentos del evento.</param>
        private void OnTreeviewSelectionChanged(object sender, EventArgs arg)
        {
            // Si hemos acabado el proceso y hemos seleccionado algo.
            if (treeview.Selection.CountSelectedRows() > 0)
            {
                SegmentedNode node =
                    (SegmentedNode)(treeview.NodeSelection.SelectedNode);

                imageAreaNode.Image = node.MathTextBitmap.Pixbuf;

                // Vaciamos el notebook
                while (processedImageNB.NPages > 0)
                {
                    processedImageNB.RemovePage(0);
                }

                if (recognizementFinished)
                {
                    // Añadimos las imagenes procesasdas al notebook

                    // Solo mostramos los tabs si hay mas de una imagen procesada
                    processedImageNB.ShowTabs =
                        node.MathTextBitmap.ProcessedImages.Count > 1;

                    // Si hemos terminado podemos hacer esto sin peligro.
                    foreach (Pixbuf p in node.MathTextBitmap.ProcessedPixbufs)
                    {
                        ImageArea imageAreaProcessed = new ImageArea();
                        imageAreaProcessed.Image     = p;
                        imageAreaProcessed.ImageMode = ImageAreaMode.Zoom;


                        processedImageNB.AppendPage(imageAreaProcessed,
                                                    new Label(String.Format("BD {0}",
                                                                            processedImageNB.NPages + 1)));
                    }
                }

                MarkImage(node.MathTextBitmap);
            }
        }
Example #13
0
        /// <summary>
        /// Initializes the dialogs' widgets.
        /// </summary>
        /// <param name="node">
        /// A <see cref="SegmentedNode"/>
        /// </param>
        private void InitializeWidgets(SegmentedNode node)
        {
            imageNameLabel.Text = String.Format(imageNameLabel.Text, node.Name);

            labelEditor = new SymbolLabelEditorWidget();
            if (node.Symbols.Count == 0)
            {
                labelEditor.Label = node.Label;
            }
            else
            {
                // If we have various posibilities, we add radio buttons.
                RadioButton group = new RadioButton("group");
                foreach (MathSymbol symbol in node.Symbols)
                {
                    RadioButton rb      = new RadioButton(group, symbol.Text);
                    Alignment   rbAlign = new Alignment(0, 0.5f, 0, 0);
                    rbAlign.Add(rb);
                    symbolEditorPlaceholder.Add(rbAlign);

                    rb.Clicked += new EventHandler(OnLabelOptionClicked);
                }

                Alignment rbOtherAlign = new Alignment(0, 0.5f, 0, 0);
                otherLabelRB          = new RadioButton(group, "Otra:");
                otherLabelRB.Clicked += new EventHandler(OnLabelOptionClicked);

                rbOtherAlign.Add(otherLabelRB);
                symbolEditorPlaceholder.Add(rbOtherAlign);
                labelEditor.Sensitive = false;
            }

            symbolEditorPlaceholder.Add(labelEditor);

            nodeImage           = new ImageArea();
            nodeImage.Image     = node.MathTextBitmap.Pixbuf;
            nodeImage.ImageMode = ImageAreaMode.Zoom;

            imagePlaceholder.Add(nodeImage);
        }
Example #14
0
        /// <summary>
        /// Inicializa los controles del panel del asistente.
        /// </summary>
        /// <param name="imagesStore">
        /// El almacén de imagenes creado en el paso anterior, para que las
        /// imagenes sean seleccionables en la vista de previsualización.
        /// </param>
        private void InitializeWidgets(ListStore imagesStore)
        {
            NodeStore store = new NodeStore(typeof(BitmapProcessNode));

            processesView = new NodeView(store);

            processesView.ShowExpanders = false;

            processesView.RulesHint = true;

            processesView.NodeSelection.Changed += OnProcessesSelectionChanged;

            processesView.AppendColumn("Algoritmo",
                                       new CellRendererText(),
                                       "text", 0);

            processesView.AppendColumn("Parámetros",
                                       new CellRendererText(),
                                       "text", 1);

            bitmapsProcessSW.Add(processesView);

            originIA    = new ImageArea();
            processedIA = new ImageArea();

            originIA.ImageMode    = ImageAreaMode.Zoom;
            processedIA.ImageMode = ImageAreaMode.Zoom;

            originFrame.Add(originIA);
            processedFrame.Add(processedIA);

            imagesTV.Model = imagesStore;

            imagesTV.AppendColumn("Imagen", new CellRendererText(), "text", 1);

            imagesTV.Selection.Changed += OnImagesTVSelectionChanged;

            LoadDefaults();
        }
Example #15
0
        /// <summary>
        /// Initializes the dialog's widgets.
        /// </summary>
        private void InitializeWidgets()
        {
            textviewOutput.Buffer.Text = output;

            originalImageArea           = new ImageArea();
            originalImageArea.ImageMode = ImageAreaMode.Zoom;
            this.outputOriginalPlaceholder.Add(originalImageArea);

            if (Config.RecognizerConfig.Instance.ShowOutputConversion)
            {
                this.outputImageArea           = new ImageArea();
                this.outputImageArea.ImageMode = ImageAreaMode.Zoom;

                this.outputOutputPlaceholder.Add(outputImageArea);

                RefreshOutputView();
            }
            else
            {
                this.outputOutputFrame.Visible = false;
            }
        }
        /// <summary>
        /// Initializes the child widgets of the widget.
        /// </summary>
        private void InitializeWidgets()
        {
            syntacticalCoverModel =
                new NodeStore(typeof(SyntacticalCoverNode));

            syntacticalCoverTree           = new NodeView(syntacticalCoverModel);
            syntacticalCoverTree.RulesHint = true;

            syntacticalCoverTree.AppendColumn("Elemento de análisis",
                                              new CellRendererText(),
                                              "markup", 0);

            syntacticalCoverTree.RowActivated +=
                new RowActivatedHandler(OnSyntacticalCoverTreeRowActivated);

            syntacticalCoverTree.Selection.Changed +=
                new EventHandler(OnSyntacticalCoverTreeSelectionChanged);

            //syntacticalCoverTree.ShowExpanders = false;

            syntacticalTreePlaceholder.Add(syntacticalCoverTree);


            remainingItemsStore = new ListStore(typeof(Gdk.Pixbuf),
                                                typeof(string),
                                                typeof(Token));
            remainingItemsIconView.Model = remainingItemsStore;

            remainingItemsIconView.PixbufColumn = 0;
            remainingItemsIconView.TextColumn   = 1;

            originalImageArea           = new  ImageArea();
            originalImageArea.ImageMode = ImageAreaMode.Zoom;

            synImageOriginalPlaceholder.Add(originalImageArea);

            originalImageArea.ShowAll();
        }
Example #17
0
        /**
         * render image area to PDF
         *
         * @param area the image area to render
         */

        public void RenderImageArea(ImageArea area)
        {
            int x = this.currentXPosition + area.getXOffset();
            int y = this.currentYPosition;
            int w = area.getContentWidth();
            int h = area.GetHeight();

            this.currentYPosition -= h;

            FonetImage img = area.getImage();

            PdfXObject xobj = this.pdfDoc.AddImage(img);

            CloseText();

            currentStream.Write("ET\nq\n" + PdfNumber.doubleOut(((float)w) / 1000f) + " 0 0 "
                                + PdfNumber.doubleOut(((float)h) / 1000f) + " "
                                + PdfNumber.doubleOut(((float)x) / 1000f) + " "
                                + PdfNumber.doubleOut(((float)(y - h)) / 1000f) + " cm\n" + "/" + xobj.Name.Name
                                + " Do\nQ\nBT\n");

            this.currentXPosition += area.getContentWidth();
        }
Example #18
0
 public JobParameters(ImageArea imageArea)
 {
     this.ImageArea = imageArea;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="area">
 /// Defined tappable area
 /// </param>
 /// <param name="text">
 /// Message to send
 /// Max: 400 characters
 /// </param>
 /// <param name="label">
 /// Label for the action. Spoken when the accessibility feature is enabled on the client device.
 /// Max: 50 characters
 /// Supported on LINE iOS version 8.2.0 and later.
 /// </param>
 public MessageImagemapAction(ImageArea area, string text, string label = null)
 {
     Area  = area;
     Text  = text.Substring(0, Math.Min(text.Length, 400));
     Label = label?.Substring(0, Math.Min(label.Length, 50));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="area">
 /// Defined tappable area
 /// </param>
 /// <param name="linkUri">
 /// Label for the action. Spoken when the accessibility feature is enabled on the client device.
 /// Max: 50 characters
 /// Supported on LINE iOS version 8.2.0 and later.
 /// </param>
 /// <param name="label">
 /// Label for the action. Spoken when the accessibility feature is enabled on the client device.
 /// Max: 50 characters
 /// Supported on LINE iOS version 8.2.0 and later.
 /// </param>
 public UriImagemapAction(ImageArea area, string linkUri, string label = null)
 {
     Area    = area;
     LinkUri = linkUri;
     Label   = label?.Substring(Math.Min(label.Length, 50));
 }
Example #21
0
 public JobParameters(ImageArea imageArea)
 {
     this.ImageArea = imageArea;
 }
Example #22
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
            Version target  = new Version(1, 5);

            if (version < target)
            {
                throw new NotSupportedException(String.Format(
                                                    "OpenGL {0} is required (you only have {1}).", target, version));
            }


            this.VSync = VSyncMode.On;


            cube = new SingleMaterialVBO();

            cube.SetDemoCube("Colors.png");

            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Fastest);



            testImageArea    = new ImageArea("ship.png", Color.Magenta);
            testImageArea.X0 = 200;
            testImageArea.Y0 = 150;



            //   Color y = System.Drawing.Color.FromArgb(255, 0, 0);



            textArea           = new TextArea();
            textArea.Text      = "Hello World";
            textArea.TextColor = new OpenTK.Graphics.Color4(0, 255, 0, 255);
            textArea.Width     = 96;


            GL.ClearColor(System.Drawing.Color.Black);


            GL.Enable(EnableCap.DepthTest);

            //GL.Enable(EnableCap.CullFace); //does this require points to be specified in a certain order?


            // Lighting //should be encapsulated somewhere
            GL.Light(LightName.Light0, LightParameter.Position, new float[] { 10.0f, 10.0f, 50f });
            GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 0.3f, 0.3f, 0.3f, 1.0f });
            GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
            GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
            GL.Light(LightName.Light0, LightParameter.SpotExponent, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
            GL.LightModel(LightModelParameter.LightModelAmbient, new float[] { 0.2f, 0.2f, 0.2f, 1.0f });
            GL.LightModel(LightModelParameter.LightModelTwoSide, 1);
            GL.LightModel(LightModelParameter.LightModelLocalViewer, 1);
            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.Light0);
        }
Example #23
0
 internal static void AddJob(ImageArea imageArea)
 {
     ApplicationManager.StartStaThread(ProcessJob, new JobParameters(imageArea));
 }
Example #24
0
 internal static void AddJob(ImageArea imageArea)
 {
     ApplicationManager.StartStaThread(ProcessJob, new JobParameters(imageArea));
 }
Example #25
0
 public static Bitmap Cut( this Bitmap b, ImageArea area )
 {
     return b.Cut( area.Topleft, area.Bottomright );
 }
Example #26
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align       = this.properties.GetProperty("text-align").GetEnum();
                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();

                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();

                this.width  = this.properties.GetProperty("width").GetLength().MValue();
                this.height = this.properties.GetProperty("height").GetLength().MValue();

                this.src = this.properties.GetProperty("src").GetString();
                this.id  = this.properties.GetProperty("id").GetString();

                area.getIDReferences().CreateID(id);
                this.marker = 0;
            }

            try
            {
                FonetImage img = FonetImageFactory.Make(src);
                if ((width == 0) || (height == 0))
                {
                    double imgWidth  = img.Width;
                    double imgHeight = img.Height;

                    if ((width == 0) && (height == 0))
                    {
                        width  = (int)((imgWidth * 1000d));
                        height = (int)((imgHeight * 1000d));
                    }
                    else if (height == 0)
                    {
                        height = (int)((imgHeight * ((double)width)) / imgWidth);
                    }
                    else if (width == 0)
                    {
                        width = (int)((imgWidth * ((double)height)) / imgHeight);
                    }
                }

                double ratio = (double)width / (double)height;

                Length maxWidth  = this.properties.GetProperty("max-width").GetLength();
                Length maxHeight = this.properties.GetProperty("max-height").GetLength();

                if (maxWidth != null && width > maxWidth.MValue())
                {
                    width  = maxWidth.MValue();
                    height = (int)(((double)width) / ratio);
                }
                if (maxHeight != null && height > maxHeight.MValue())
                {
                    height = maxHeight.MValue();
                    width  = (int)(ratio * ((double)height));
                }

                int areaWidth  = area.getAllocationWidth() - startIndent - endIndent;
                int pageHeight = area.getPage().getBody().getMaxHeight() - spaceBefore;

                if (height > pageHeight)
                {
                    height = pageHeight;
                    width  = (int)(ratio * ((double)height));
                }
                if (width > areaWidth)
                {
                    width  = areaWidth;
                    height = (int)(((double)width) / ratio);
                }

                if (area.spaceLeft() < (height + spaceBefore))
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }

                this.imageArea =
                    new ImageArea(propMgr.GetFontState(area.getFontInfo()), img,
                                  area.getAllocationWidth(), width, height,
                                  startIndent, endIndent, align);

                if ((spaceBefore != 0) && (this.marker == 0))
                {
                    area.addDisplaySpace(spaceBefore);
                }

                if (marker == 0)
                {
                    area.GetMyRefs().ConfigureID(id, area);
                }

                imageArea.start();
                imageArea.end();

                if (spaceAfter != 0)
                {
                    area.addDisplaySpace(spaceAfter);
                }
                if (breakBefore == BreakBefore.PAGE ||
                    ((spaceBefore + imageArea.GetHeight())
                     > area.spaceLeft()))
                {
                    return(new Status(Status.FORCE_PAGE_BREAK));
                }

                if (breakBefore == BreakBefore.ODD_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_ODD));
                }

                if (breakBefore == BreakBefore.EVEN_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
                }

                if (area is BlockArea)
                {
                    BlockArea ba = (BlockArea)area;
                    LineArea  la = ba.getCurrentLineArea();
                    if (la == null)
                    {
                        return(new Status(Status.AREA_FULL_NONE));
                    }
                    la.addPending();
                    if (imageArea.getContentWidth() > la.getRemainingWidth())
                    {
                        la = ba.createNextLineArea();
                        if (la == null)
                        {
                            return(new Status(Status.AREA_FULL_NONE));
                        }
                    }
                    la.addInlineArea(imageArea, GetLinkSet());
                }
                else
                {
                    area.addChild(imageArea);
                    area.increaseHeight(imageArea.getContentHeight());
                }
                imageArea.setPage(area.getPage());

                if (breakAfter == BreakAfter.PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return(new Status(Status.FORCE_PAGE_BREAK));
                }

                if (breakAfter == BreakAfter.ODD_PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return(new Status(Status.FORCE_PAGE_BREAK_ODD));
                }

                if (breakAfter == BreakAfter.EVEN_PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
                }
            }
            catch (FonetImageException imgex)
            {
                FonetDriver.ActiveDriver.FireFonetError("Error while creating area : " + imgex.Message);
            }

            return(new Status(Status.OK));
        }
Example #27
0
        /// <summary>
        /// Initialize the widget's children widgets.
        /// </summary>
        private void InitializeWidgets()
        {
            this.Add(tokenizingStageWidgetBase);

            sequencesModel = new NodeStore(typeof(SequenceNode));

            sequencesNV = new NodeView(sequencesModel);

            sequencesNV.ShowExpanders = true;
            sequencesNV.RulesHint     = true;
            sequencesNVPlaceholder.Add(sequencesNV);

            sequencesNV.AppendColumn("Secuencia",
                                     new CellRendererText(),
                                     "text", 0);

            sequencesNV.AppendColumn("Símbolos",
                                     new CellRendererText(),
                                     "text", 1);

            sequencesNV.AppendColumn("Ítem",
                                     new CellRendererText(),
                                     "text", 2);

            // We tell the treeview's columns to resize automatically.
            foreach (TreeViewColumn column in sequencesNV.Columns)
            {
                column.Sizing = TreeViewColumnSizing.Autosize;
            }

            // We handle the pressing of the mouse buttons, so we can show
            // the contextual menu.

            sequencesNV.Events            = Gdk.EventMask.ButtonPressMask;
            sequencesNV.ButtonPressEvent +=
                new ButtonPressEventHandler(OnSequencesNVButtonPress);

            symbolsModel = new ListStore(typeof(Gdk.Pixbuf),
                                         typeof(string),
                                         typeof(Token));

            symbolsIV.Model = symbolsModel;

            symbolsIV.TextColumn   = 1;
            symbolsIV.PixbufColumn = 0;

            baselineImageArea           = new ImageArea();
            baselineImageArea.ImageMode = ImageAreaMode.Zoom;
            currentImageFrm.Add(baselineImageArea);

            sequenceMatchingImageArea           = new ImageArea();
            sequenceMatchingImageArea.ImageMode = ImageAreaMode.Zoom;
            sequenceImageFrm.Add(sequenceMatchingImageArea);

            tokenizingRulesTV.AppendColumn("Item generado",
                                           new CellRendererText(),
                                           "text", 0);
            tokenizingRulesTV.AppendColumn("Expresión",
                                           new CellRendererText(),
                                           "text", 1);

            tokenizingRulesTV.Columns[0].Sizing = TreeViewColumnSizing.Autosize;
            tokenizingRulesTV.Columns[1].Sizing = TreeViewColumnSizing.Autosize;



            tokenizingButtonsNB.Page = 0;
            tokenizingStepsNB.Page   = 0;

            tokenizingStageWidgetBase.ShowAll();
        }