Пример #1
0
        private void ExtractLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            /* Check if we have something selected */
            if (selectedpage == null)
            {
                Cursor = Cursors.Arrow;
                return;
            }

            Point posit = e.GetPosition(xaml_PageList);

            dropafterposition = GetCurrentIndex();
            putattop          = false;

            if (dropafterposition < 0)
            {
                /* Check if we are above or below */
                if (posit.Y < 0)
                {
                    putattop = true;
                }
                else
                {
                    dropafterposition = xaml_PageList.Items.Count - 1;
                }
            }
            Cursor = Cursors.Arrow;
            MoveItem();
            selectedpage = null;
        }
Пример #2
0
        private void ExtractLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            int index = GetCurrentIndex();

            if (index > -1 && index < Pages.Count)
            {
                selectedpage = Pages[index];
            }
        }
Пример #3
0
 public void SetPageList(int num_pages)
 {
     for (int k = 1; k < num_pages + 1; k++)
     {
         SelectPage Spage = new SelectPage();
         Spage.Page = k;
         Spage.PageString = k;
         Pages.Add(Spage);
     }
 }
Пример #4
0
 public void SetPageList(int num_pages)
 {
     for (int k = 1; k < num_pages + 1; k++)
     {
         SelectPage Spage = new SelectPage();
         Spage.Page       = k;
         Spage.PageString = k;
         ConvertPages.Add(Spage);
     }
 }
Пример #5
0
        private void ExtractLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            /* Check if we have something selected */
            if (selectedpage == null)
            {
                Cursor = Cursors.Arrow;
                return;
            }

            Point posit = e.GetPosition(xaml_PageList);
            dropafterposition = GetCurrentIndex();
            putattop = false;

            if (dropafterposition < 0)
            {
                /* Check if we are above or below */
                if (posit.Y < 0)
                    putattop = true;
                else
                    dropafterposition = xaml_PageList.Items.Count - 1;
            }
            Cursor = Cursors.Arrow;
            MoveItem();
            selectedpage = null;
        }
Пример #6
0
 private void ExtractLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     int index = GetCurrentIndex();
     if (index > -1 && index < Pages.Count)
         selectedpage = Pages[index];
 }
Пример #7
0
        /* A standard command line approach to using gs API */
        private void gsWork1(object sender, DoWorkEventArgs e)
        {
            gsParams_t    gsparams   = (gsParams_t)e.Argument;
            String        out_file   = gsparams.outputfile;
            String        in_file    = gsparams.inputfile;
            int           num_params = 8;    /* base number */
            int           rend_count = 1;
            String        options;
            int           count;
            List <String> optionlist;

            optionlist = GetOptions(gsparams.options);
            num_params = num_params + optionlist.Count;
            if (gsparams.pages != null)
            {
                rend_count = gsparams.pages.Count;
                num_params = num_params + 2;
            }
            if (gsparams.init_file != null)
            {
                num_params = num_params + 1;
            }
            if (gsparams.init_string != null)
            {
                num_params = num_params + 2;
            }

            var argParam = new GCHandle[num_params];
            var argPtrs  = new IntPtr[num_params];

            String[]      strParams      = new String[num_params];
            List <byte[]> CharacterArray = new List <byte[]>(num_params);
            GCHandle      argPtrsStable;

            /* New instance */
            int code = tc_gsapi_new_instance(out gsInstance, IntPtr.Zero);

            if (code < 0)
            {
                gsparams.result = GS_Result_t.gsFAILED;
                e.Result        = gsparams;
                return;
            }

            code = tc_gsapi_set_stdio(gsInstance, RaiseStdInCallback,
                                      RaiseStdOutCallback, RaiseStdErrCallback);
            code = tc_gsapi_set_arg_encoding(gsInstance, (int)gsEncoding.GS_ARG_ENCODING_UTF8);

            if (code == 0)
            {
                for (int jj = 0; jj < rend_count; jj++)
                {
                    strParams[0] = "gs";                       /* This does not matter */
                    strParams[1] = "-dNOPAUSE";
                    strParams[2] = "-dBATCH";
                    if (gsparams.devicename != null)
                    {
                        strParams[3] = "-sDEVICE=" + gsparams.devicename;
                    }
                    else
                    {
                        strParams[3] = "-sDEVICE=" + Enum.GetName(typeof(gsDevice_t), gsparams.device);
                    }
                    strParams[4] = "-r" + gsparams.resolution;
                    /* Create temp file if file not specified */
                    if (out_file == null)
                    {
                        out_file            = Path.GetTempFileName();
                        gsparams.outputfile = out_file;
                    }
                    count = 5;
                    /* Add in the options */
                    for (int kk = 0; kk < optionlist.Count; kk++)
                    {
                        strParams[count] = optionlist[kk];
                        count++;
                    }
                    /* We have discontinuous page selection */
                    if (gsparams.pages != null)
                    {
                        String firstpage, lastpage;
                        options = gsparams.options;
                        SelectPage curr_page = (SelectPage)(gsparams.pages[jj]);
                        firstpage        = "-dFirstPage=" + curr_page.Page;
                        lastpage         = "-dLastPage=" + curr_page.Page;
                        strParams[count] = firstpage;
                        count++;
                        strParams[count] = lastpage;
                        count++;
                        /* Look for file extension. */
                        string extension    = System.IO.Path.GetExtension(out_file);
                        int    len          = extension.Length;
                        String new_out_file = out_file.Substring(0, out_file.Length - len);
                        strParams[count] = "-o" + new_out_file + "_page" + curr_page.Page + extension;
                    }
                    else
                    {
                        if (gsparams.need_multi_page)
                        {
                            /* Look for file extension. */
                            string extension    = System.IO.Path.GetExtension(out_file);
                            int    len          = extension.Length;
                            String new_out_file = out_file.Substring(0, out_file.Length - len);
                            strParams[count] = "-o" + new_out_file + "_page%d" + extension;
                        }
                        else
                        {
                            strParams[count] = "-o" + out_file;
                        }
                    }
                    if (gsparams.init_string != null)
                    {
                        count++;
                        strParams[count] = "-c";
                        count++;
                        strParams[count] = gsparams.init_string;
                    }
                    count++;
                    strParams[count] = "-f";
                    if (gsparams.init_file != null)
                    {
                        count++;
                        strParams[count] = gsparams.init_file;
                    }
                    count++;
                    strParams[count] = in_file;

                    /* Now convert our Strings to char* and get pinned handles to these.
                     * This keeps the c# GC from moving stuff around on us */
                    for (int k = 0; k < num_params; k++)
                    {
                        CharacterArray.Add(System.Text.Encoding.UTF8.GetBytes(strParams[k].ToCharArray()));
                        argParam[k] = GCHandle.Alloc(CharacterArray[k], GCHandleType.Pinned);
                        argPtrs[k]  = argParam[k].AddrOfPinnedObject();
                    }
                    /* Also stick the array of pointers into memory that will not be GCd */
                    argPtrsStable = GCHandle.Alloc(argPtrs, GCHandleType.Pinned);

                    code = tc_gsapi_init_with_args(gsInstance, num_params, argPtrsStable.AddrOfPinnedObject());
                    /* All the pinned items need to be freed so the GC can do its job */
                    for (int k = 0; k < num_params; k++)
                    {
                        argParam[k].Free();
                    }
                    argPtrsStable.Free();
                    /* Free the character array list in case we have multiple runs */
                    CharacterArray.Clear();

                    if (code < 0)
                    {
                        break;
                    }
                }
            }

            int code1 = tc_gsapi_exit(gsInstance);

            if ((code == 0) || (code == gsConstants.E_QUIT))
            {
                code = code1;
            }

            tc_gsapi_delete_instance(gsInstance);
            if ((code == 0) || (code == gsConstants.E_QUIT))
            {
                gsparams.result = GS_Result_t.gsOK;
                e.Result        = gsparams;
                return;
            }

            gsparams.result = GS_Result_t.gsFAILED;
            e.Result        = gsparams;
            return;
        }