Exemplo n.º 1
0
    private void AddExcludeDir()
    {
        string dir = QFileDialog.GetExistingDirectory(this,"Select path to exclude",PathFinder.HomeDir);

        if (dir == null)
        {
            return;
        }
        Console.WriteLine("Excluding '{0}'",dir);

        // Check if the new dir is already part of some excluded directory in the list
        bool seen = false;

        for (int i = 0; i < main.ExcludeDirList.Count; ++i)
        {
            if (main.ExcludeDirList.Item(i).Text().StartsWith(dir))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The list contains a path that is included in the new path.","OK");
            }
            else if (dir.StartsWith(main.ExcludeDirList.Item(i).Text()))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The path is already included in one of the paths in the list.","OK");
            }
        }

        if (!seen)
        {
            main.ExcludeDirList.AddItem(dir);
        }
    }
Exemplo n.º 2
0
        public string PickExistingFile(PickingData data)
        {
            return(QFileDialog.GetOpenFileName(
                       (Central.Manager.IDE as LinuxIDE),
                       "Select File",
                       Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                       "All Files (*.*)"
                       ));

            /*FileChooserDialog fcd = new FileChooserDialog(
             *  "Select File",
             *  (Central.Manager.IDE as LinuxIDE),
             *  FileChooserAction.Open,
             *  "Cancel", ResponseType.Cancel,
             *  "Open", ResponseType.Accept);
             * fcd.Filter = new FileFilter();
             * string[] f = data.Filter.Split(new char[] { '|' });
             * for (int i = 0; i < f.Length; i += 2)
             *  fcd.Filter.AddPattern(f[i + 1]);
             * string result = null;
             * if (fcd.Run() == (int)ResponseType.Accept)
             *  result = fcd.Filename;
             * fcd.Destroy();
             * return result;*/
        }
Exemplo n.º 3
0
    private void ShowDirChooser()
    {
        string new_root = QFileDialog.GetExistingDirectory(this,"Choose new path for beagle to index","/");

        if (new_root == null)
        {
            return;
        }
        Console.WriteLine("Selected new root '{0}'",new_root);

        // Check if the new_root is already part of some root in the list
        bool seen = false;

        for (int i = 0; i < main.RootsList.Count; ++i)
        {
            Console.WriteLine("Checking against {0}",main.RootsList.Item(i).Text());
            if (main.RootsList.Item(i).Text().StartsWith(new_root))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The list contains a path that is included in the new path.","OK");
            }
            else if (new_root.StartsWith(main.RootsList.Item(i).Text()))
            {
                seen = true;
                QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The path is already included in one of the paths in the list.","OK");
            }
        }

        if (!seen)
        {
            main.RootsList.AddItem(new_root);
        }
    }
Exemplo n.º 4
0
        void HandleInsertImageActionTriggered()
        {
            var dialog = new QFileDialog(this.TopLevelWidget(),"Select Photo");

            dialog.fileMode = QFileDialog.FileMode.ExistingFile;
            if (dialog.Exec() == (int)QFileDialog.DialogCode.Accepted && dialog.SelectedFiles().Count > 0)
            {
                string fileName = dialog.SelectedFiles()[0];
                textEdit.InsertImage(fileName);
            }
        }
Exemplo n.º 5
0
        public void SlotOpen()
        {
            string fileName =
                QFileDialog.GetOpenFileName("","Coverage Files (*.cov)",this,
                                            "","Choose a file","Coverage Files (*.cov)");

            if (fileName != null)
            {
                openFile(fileName);
            }
        }
Exemplo n.º 6
0
        private void open()
        {
            QFileDialog dialog = new QFileDialog();
            dialog.setAcceptMode(QFileDialog.AcceptMode.AcceptOpen);
            dialog.setFileMode(QFileDialog.FileMode.DirectoryOnly);

            dialog.setModal(true);
            dialog.show();
            if (dialog.exec() != 0)
            {
                string jsFunc = RunDirectoryScan((string)dialog.selectedFiles().get(0));
                webView.page().mainFrame().evaluateJavaScript(jsFunc);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Open command file
        /// </summary>
        private void OpenCommandFile()
        {
            // New dialog for select command file
            string selectedFile = QFileDialog.GetOpenFileName(this,
                                                              GlobalObj.LMan.GetString("selectfile"),
                                                              null,
                                                              "*.comex");

            if (string.IsNullOrEmpty(selectedFile))
            {
                return;
            }


            // path of a right file returned
            commandFilePath = selectedFile;
            commandFileName = System.IO.Path.GetFileNameWithoutExtension(commandFilePath);
            log.Debug("file selected: " + commandFilePath);

            UpdateGuiForCommandFile();
        }
Exemplo n.º 8
0
        void on_avatarBrowseButton_clicked()
        {
            var dialog = new QFileDialog(this.TopLevelWidget(), "Select Avatar");

            dialog.fileMode = QFileDialog.FileMode.ExistingFile;
            if (dialog.Exec() == (int)DialogCode.Accepted && dialog.SelectedFiles().Count > 0)
            {
                string fileName = dialog.SelectedFiles()[0];

                try {
                    byte[] buffer = null;
                    Image  image  = Image.FromFile(fileName);
                    using (MemoryStream stream = new MemoryStream()) {
                        image.Save(stream, image.RawFormat);
                        buffer = stream.GetBuffer();
                    }
                    SetAvatar(buffer, image.RawFormat);
                } catch (Exception ex) {
                    Application.Client.ShowErrorWindow("Failed to set avatar. The file you selected may be an unsupported image type or may be damaged.", ex);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Choose file to save contacts.
        /// </summary>
        private string ChooseFileToSave(string dialogTitle)
        {
            // New dialog for select contacts file

            string fileToSave = QFileDialog.GetSaveFileName(this,
                                                            GlobalObjUI.LMan.GetString("openfileact"),
                                                            null,
                                                            "monosim files *.monosim (*.monosim)");

            if (string.IsNullOrEmpty(fileToSave))
            {
                return("");
            }


            if (fileToSave.Substring(fileToSave.Length - 8) != ".monosim")
            {
                fileToSave += ".monosim";
            }

            return(fileToSave);
        }
Exemplo n.º 10
0
        private void open()
        {
            QFileDialog dialog = new QFileDialog();
            dialog.setAcceptMode(QFileDialog.AcceptMode.AcceptOpen);
            dialog.setFileMode(QFileDialog.FileMode.DirectoryOnly);

            dialog.setModal(true);
            dialog.show();
            if (dialog.exec() != 0)
            {
                RunDirectoryScan((string)dialog.selectedFiles().get(0));

            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Open contacts file.
        /// </summary>
        private void OpenContactsFile()
        {
            GlobalObjUI.ContactsFilePath = "";

            // New dialog for select contacts file
            string selectedFile = QFileDialog.GetOpenFileName(this,
                                                              GlobalObjUI.LMan.GetString("openfileact"),
                                                              null,
                                                              "monosim files *.monosim (*.monosim)");

            if (string.IsNullOrEmpty(selectedFile))
            {
                return;
            }

            // path of a right file returned
            GlobalObjUI.ContactsFilePath = selectedFile;

            // Update gui
            UpdateFileControls(false);

            // Clear ListView
            mainwindow_Ui.LstFileContacts.Clear();
            MainClass.QtWait();

            try
            {
                GlobalObjUI.FileContacts = new Contacts();
                StreamReader sr       = new StreamReader(GlobalObjUI.ContactsFilePath);
                string       descRow  = sr.ReadLine();
                string       phoneRow = "";
                while (!sr.EndOfStream)
                {
                    phoneRow = sr.ReadLine();
                    // check for right values
                    if (descRow.Trim() != "" && phoneRow.Trim() != "")
                    {
                        GlobalObjUI.FileContacts.SimContacts.Add(new Contact(descRow, phoneRow));
                    }

                    // read new contact description
                    descRow = sr.ReadLine();
                }
                sr.Close();
                sr.Dispose();
                sr = null;
            }
            catch (Exception Ex)
            {
                log.Error("MainWindowClass::OpenContactsFile: " + Ex.Message + "\r\n" + Ex.StackTrace);
                MainClass.ShowMessage(this, "ERROR", Ex.Message, MainClass.MessageType.Error);
                return;
            }

            // loop to append data readed from file
            List <string> rowContent = null;

            foreach (Contact cnt in GlobalObjUI.FileContacts.SimContacts)
            {
                rowContent = new List <string>();
                rowContent.Add(" ");
                rowContent.Add(cnt.Description);
                rowContent.Add(cnt.PhoneNumber);
                new QTreeWidgetItem(mainwindow_Ui.LstFileContacts, rowContent);
            }

            UpdateFileControls(true);
        }