Esempio n. 1
0
 public void NSIndexSet_EmptyToArray()
 {
     NSIndexSet a = new NSIndexSet ();
     #pragma warning disable 0219
     var b = a.ToArray ();
     #pragma warning restore 0219
 }
Esempio n. 2
0
        public void NSIndexSet_EmptyToArray()
        {
            NSIndexSet a = new NSIndexSet();

#pragma warning disable 0219
            var b = a.ToArray();
#pragma warning restore 0219
        }
Esempio n. 3
0
        public void ExtractRAR(MainWindow  window, NSTableView TableView, NSIndexSet nSelRows, string rarFile, string extractPath)
        {
            clsIOPrefs ioPrefs = new clsIOPrefs ();
            string txtRAR = ioPrefs.GetStringValue ("CaminhoRAR");
            if (txtRAR.Length > 0) {

                if (nSelRows.Count > 0) {

                    ProgressWindowController sheet = null;
                    TableView.InvokeOnMainThread (delegate {
                        sheet = new ProgressWindowController  ();
                        sheet.ShowSheet (window);
                    });

                    sheet.InvokeOnMainThread(delegate{
                        sheet.ProgressBarMinValue = 0;
                        sheet.ProgressBarMaxValue = nSelRows.Count;
                    });

                    double conta = 0;
                    bool Cancela = false;

                    nuint[] nRows = nSelRows.ToArray ();

                    ViewArquivosDataSource datasource = null;
                    TableView.InvokeOnMainThread(delegate
                        {
                            datasource = (ViewArquivosDataSource)TableView.DataSource;
                        });

                    foreach (int lRow in nRows) {
                        string NomeArq = datasource.ViewArquivos [lRow].Nome;

                        ++conta;

                        sheet.InvokeOnMainThread(delegate{
                            sheet.LabelArqValue = "Extraindo arquivo: " + NomeArq;
                            sheet.ProgressBarValue = conta;
                        });

                        string[] launchArgs = { "x", rarFile, NomeArq, extractPath };
                        NSPipe pipeOut = new NSPipe ();
                        NSTask t = new NSTask ();
                        t.LaunchPath = txtRAR;
                        t.Arguments = launchArgs;
                        t.StandardOutput = pipeOut;
                        t.Launch ();
                        t.WaitUntilExit();

                        //string txtRET = pipeOut.ReadHandle.ReadDataToEndOfFile ().ToString ();

                        sheet.InvokeOnMainThread(delegate{
                            Cancela = sheet.Canceled;
                        });
                        if(Cancela) {
                            break;
                        }

                    }

                    sheet.InvokeOnMainThread (delegate {
                        sheet.CloseSheet ();
                        sheet = null;
                    });

                    if (!Cancela)
                    {
                        TableView.InvokeOnMainThread (delegate {
                            NSAlert alert = new NSAlert () {
                                AlertStyle = NSAlertStyle.Informational,
                                InformativeText = "Arquivo(s) extraido(s) com sucesso !",
                                MessageText = "Extrair arquivos",
                            };
                            alert.RunSheetModal(window);
                        });

                    }

                }
            }
        }
Esempio n. 4
0
        public void ExtractRAR(MainWindow window, NSTableView TableView, NSIndexSet nSelRows, string rarFile, string extractPath)
        {
            clsIOPrefs ioPrefs = new clsIOPrefs();
            string     txtRAR  = ioPrefs.GetStringValue("CaminhoRAR");

            if (txtRAR.Length > 0)
            {
                if (nSelRows.Count > 0)
                {
                    ProgressWindowController sheet = null;
                    TableView.InvokeOnMainThread(delegate {
                        sheet = new ProgressWindowController();
                        sheet.ShowSheet(window);
                    });

                    sheet.InvokeOnMainThread(delegate {
                        sheet.ProgressBarMinValue = 0;
                        sheet.ProgressBarMaxValue = nSelRows.Count;
                    });

                    double conta   = 0;
                    bool   Cancela = false;

                    nuint[] nRows = nSelRows.ToArray();

                    ViewArquivosDataSource datasource = null;
                    TableView.InvokeOnMainThread(delegate
                    {
                        datasource = (ViewArquivosDataSource)TableView.DataSource;
                    });

                    foreach (int lRow in nRows)
                    {
                        string NomeArq = datasource.ViewArquivos [lRow].Nome;

                        ++conta;

                        sheet.InvokeOnMainThread(delegate {
                            sheet.LabelArqValue    = "Extraindo arquivo: " + NomeArq;
                            sheet.ProgressBarValue = conta;
                        });

                        string[] launchArgs = { "x", rarFile, NomeArq, extractPath };
                        NSPipe   pipeOut    = new NSPipe();
                        NSTask   t          = new NSTask();
                        t.LaunchPath     = txtRAR;
                        t.Arguments      = launchArgs;
                        t.StandardOutput = pipeOut;
                        t.Launch();
                        t.WaitUntilExit();

                        //string txtRET = pipeOut.ReadHandle.ReadDataToEndOfFile ().ToString ();

                        sheet.InvokeOnMainThread(delegate {
                            Cancela = sheet.Canceled;
                        });
                        if (Cancela)
                        {
                            break;
                        }
                    }

                    sheet.InvokeOnMainThread(delegate {
                        sheet.CloseSheet();
                        sheet = null;
                    });

                    if (!Cancela)
                    {
                        TableView.InvokeOnMainThread(delegate {
                            NSAlert alert = new NSAlert()
                            {
                                AlertStyle      = NSAlertStyle.Informational,
                                InformativeText = "Arquivo(s) extraido(s) com sucesso !",
                                MessageText     = "Extrair arquivos",
                            };
                            alert.RunSheetModal(window);
                        });
                    }
                }
            }
        }
Esempio n. 5
0
        private void procBtn(int state = 1)
        {
            if (state == 4)
            {
                string[]    filetypes = { "rar" };
                NSOpenPanel dlg       = NSOpenPanel.OpenPanel;
                dlg.Title                   = "Selecione";
                dlg.CanChooseFiles          = true;
                dlg.CanChooseDirectories    = false;
                dlg.AllowedFileTypes        = filetypes;
                dlg.AllowsMultipleSelection = false;
                dlg.ResolvesAliases         = true;
                dlg.ReleasedWhenClosed      = true;
                dlg.BeginSheet(this, (i) => {
                    try
                    {
                        if (dlg.Url != null)
                        {
                            var urlString = dlg.Url.Path;
                            if (!string.IsNullOrEmpty(urlString))
                            {
                                //NSDate DateLoop = new NSDate ();
                                //DateLoop = DateLoop.AddSeconds (0.1);
                                //NSRunLoop.Current.RunUntil(DateLoop );

                                NSThread.Start(() => {
                                    clsRAR orar = new clsRAR();
                                    rarFile     = orar.OpenRAR(urlString, this, this.tbv_Arquivos);
                                    orar        = null;
                                });
                            }
                        }
                    }
                    finally
                    {
                        dlg.Dispose();
                        dlg = null;
                    }
                });
            }
            else
            {
                NSIndexSet nSelRows = this.tbv_Arquivos.SelectedRows;
                if (nSelRows.Count > 0)
                {
                    nuint[] nRows = nSelRows.ToArray();
                    if (nRows.Length > 0)
                    {
                        ViewArquivosDataSource datasource = (ViewArquivosDataSource)this.tbv_Arquivos.DataSource;
                        clsViewArquivos        cvarqs     = new clsViewArquivos();
                        string aState = string.Empty;
                        foreach (nint lRow in nRows)
                        {
                            switch (state)
                            {
                            case 1:
                                aState = "1";
                                break;

                            case 2:
                                aState = cvarqs.GetTagsArquivo(datasource, (int)lRow, 1);
                                break;

                            case 3:
                                NSOpenPanel dlg = NSOpenPanel.OpenPanel;
                                dlg.Title                   = "Salvar em";
                                dlg.CanChooseFiles          = false;
                                dlg.CanChooseDirectories    = true;
                                dlg.AllowsMultipleSelection = false;
                                dlg.ResolvesAliases         = true;
                                dlg.ReleasedWhenClosed      = true;
                                dlg.BeginSheet(this, (i) => {
                                    try {
                                        string urlString = dlg.Url.Path;
                                        if (!string.IsNullOrEmpty(urlString))
                                        {
                                            nSelRows = this.tbv_Arquivos.SelectedRows;
                                            NSThread.Start(() => {
                                                clsRAR exRAR = new clsRAR();
                                                exRAR.ExtractRAR(this, this.tbv_Arquivos, nSelRows, rarFile, urlString);
                                                exRAR = null;
                                            });
                                        }
                                    } finally {
                                        dlg.Dispose();
                                        dlg = null;
                                    }
                                    this.tbv_Arquivos.ReloadData();
                                });
                                break;

                            case 5:

                                break;
                            }
                            if (state != 3)
                            {
                                cvarqs.SetTagsArquivo(datasource, (int)lRow, aState);
                                cvarqs     = null;
                                datasource = null;
                                this.tbv_Arquivos.ReloadData();
                            }
                        }
                    }
                }
                else
                {
                    string mText = string.Empty;
                    string iText = string.Empty;
                    switch (state)
                    {
                    case 1:
                        mText = "Remover Arquivo(s)";
                        iText = "Selecione ao menos um aquivo para Remover !";
                        break;

                    case 2:
                        mText = "Desfazer Ação";
                        iText = "Selecione ao menos um arquivo para\r\n Desfazer a Ação !";
                        break;

                    case 3:
                        mText = "Extrair Arquivos";
                        iText = "Selecione ao menos um arquivo para Extrair !";
                        break;
                    }

                    NSAlert alert = new NSAlert()
                    {
                        AlertStyle      = NSAlertStyle.Warning,
                        InformativeText = iText,
                        MessageText     = mText,
                    };
                    alert.RunSheetModal(this);
                }
            }
        }