Beispiel #1
0
        public OpenFileResult OpenFile(string customFilter, bool multiselect)
        {
            List<string> baseFilters = new List<string>();
            if (!string.IsNullOrEmpty(customFilter))
            {
                baseFilters.Add(customFilter);
            }
            baseFilters.Add(Resources.Translations.FilterAllSupported);
            baseFilters.Add(Resources.Translations.FilterAllFiles);

            string delimiter = "|";
            string filter = baseFilters.Aggregate((i, j) => i + delimiter + j);

            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = filter;
            dialog.FilterIndex = 1;
            dialog.Multiselect = multiselect;

            List<OpenedFile> openedFiles = new List<OpenedFile>();
            if (dialog.ShowDialog() == true)
            {
                string[] fileNames = dialog.FileNames;

                foreach (var filePath in fileNames)
                {
                    string fileName = Path.GetFileName(filePath);
                    Stream stream = File.OpenRead(filePath);
                    openedFiles.Add(new OpenedFile(stream, fileName));
                }
            }

            return new OpenFileResult(openedFiles);
        }
        public void ImportaSentencas()
        {
            //List<string> mensagemLinha = new List<string>();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title = "";
            openFileDialog.InitialDirectory = @"c:\temp";
            openFileDialog.Filter = "Arquivos texto (*.txt)|*.txt| All files (*.*)|*.*";
            openFileDialog.FilterIndex = 2;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == true)
                arquivo = openFileDialog.FileName;

            if (String.IsNullOrEmpty(arquivo))
            {
                MessageBox.Show("Arquivo Invalido", "Alerta", MessageBoxButton.OK);
            }
            else
            {
                using (StreamReader texto = new StreamReader(arquivo))
                {
                    while ((mensagem = texto.ReadLine()) != null)
                    {
                        //mensagemLinha.Add(mensagem);
                        CadastroSentenca.Adiciona(new Sentenca(0, mensagem, (bool)rbtn100.IsChecked));
                    }
                }
            }

            Atualizar();
        }
        public BrowseResult Browse(BrowseParams browseParams)
        {
            if(browseParams==null) browseParams = new BrowseParams();

            FileDialog dialog = new OpenFileDialog();
            return OpenDialog(dialog, browseParams);
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            bool? result = null;

            OpenFileDialog fileDlg = new OpenFileDialog();
            fileDlg.Filter = "Dynamic Linked Libraries|*.dll";
            fileDlg.Title = "Add Plugin Assembly...";
            fileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            result = fileDlg.ShowDialog(this);

            if (result != null && result == true)
            {
                if (ValidateAndAddAssembly(fileDlg.FileName))
                {
                    // Notify the user of the impending restart
                    MessageBox.Show(this, "The application must now restart to ensure the Plugin is fully functional.", "Plugin Added!", MessageBoxButton.OK, MessageBoxImage.Information);

                    // Restart
                    try
                    {
                        Process.Start(Application.ResourceAssembly.Location);
                        Application.Current.Shutdown();
                    }
                    catch (Exception ex)
                    {
                        PluginManager.log.Error("An exception was thrown while attempting to restart the application as a result of a plugin removal.", ex);
                    }
                }
            }
        }
        private void AddLanguageFile_OnClick(object sender, RoutedEventArgs e)
        {
            // Configure open file dialog box.
            OpenFileDialog dlg = new OpenFileDialog { DefaultExt = ".txt", Filter = "Language Files (.txt)|*.txt" };

            // Show open file dialog box.
            bool? result = dlg.ShowDialog();

            // Process open file dialog box results 
            if (result != true)
            {
                return;
            }

            // Show language name dialog box.
            TextBoxWindow textboxDlg = new TextBoxWindow();
            result = textboxDlg.ShowDialog("Add Language", "Please enter the name of the language!");

            if (result != true)
            {
                return;
            }

            // Add language file to project.
            ProjectSettings projectSettings = (ProjectSettings)this.DataContext;
            LanguageFile languageFile = new LanguageFile { LanguageTag = textboxDlg.Text, Path = dlg.FileName };
            projectSettings.AddLanguageFile(languageFile);

            // Refresh list.
            this.LanguageFileList.Items.Refresh();
        }
Beispiel #6
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            const string initialDirectory = "g:\\temp\\";

            if (Directory.Exists(initialDirectory))
                openFileDialog1.InitialDirectory = initialDirectory;

            openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == true)
            {
                var result = LogParser.Parse(openFileDialog1.FileName);
                _battles = LogParser.DivideIntoBattlesAndApplyGuards(result);
                ListBattles.Items.Clear();

                ListBattles.BeginInit();
                foreach (var battle in _battles)
                {
                    ListBattles.Items.Add(battle.ToString());
                }
                ListBattles.EndInit();
            }
        }
Beispiel #7
0
        private void OnLoadModule(object sender, System.Windows.RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                CheckFileExists = true,
                Filter          = "Binary Files (*.bin, *.exe, *.img, *.iso, *.o)|*.bin;*.exe;*.img;*.iso;*.o|"
                                + "All Files (*.*)|*.*|Image Files (*.img, *.iso)|*.img;*.iso|"
                                + "Object Files (*.bin, *.o, *.exe)|*.bin;*.o;*.exe",
                FilterIndex     = 0,
                Title           = "Select Debug Binary",
                Multiselect     = true,
            };
            bool? result = dialog.ShowDialog(this);

            if (result.HasValue && result.Value)
            {
                foreach (string modulePath in dialog.FileNames)
                {
                    try
                    {
                        Loader.LoadImage(modulePath, null);
                    }
                    catch (Exception x)
                    {
                        var msg = String.Format("An error occured and the module '{0}' "
                            + "has not been loaded:\n{1}", modulePath, x.ToString());

                        MessageBox.Show(msg, "Error Loading Module", MessageBoxButton.OK,
                            MessageBoxImage.Error);
                    }
                }
                this.RefreshItems();
            }
        }
        private void bOpen_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();
            if (dialog.ShowDialog() == true)
            {
                var lines = System.IO.File.ReadAllLines(dialog.FileName);
                FuncList.Clear();
                foreach (var line in lines)
                {
                    if (line.StartsWith("Engine") || line.StartsWith("-----"))
                        continue;

                    var arr = line.Split(new[]{' ','\t','\r'},  StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length == 8)
                    {
                        var data = new CompareData {
                            Engine    = arr[0],
                            Function1 = arr[1],
                            Function2 = arr[2],
                            Address1  = arr[3],
                            Address2  = arr[4],
                            CRC       = arr[5],
                            CRC1      = arr[6],
                            CRC2      = arr[7],
                        };

                        if (!data.Function2.StartsWith("sub_"))
                            FuncList.Add(data);
                    }
                }
            }
        }
Beispiel #9
0
        private void BrowseButton_Click(object sender, RoutedEventArgs e)
        {

            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = def;
            dlg.Filter = fil;

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                if (dlg.FileName.Length > 0)
                {
                    SelectedFileTextBox.Text = dlg.FileName;
                    location = String.Concat(System.IO.Path.GetDirectoryName(dlg.FileName), "\\",
                                   System.IO.Path.GetFileNameWithoutExtension(dlg.FileName), ".xps");
                    
                    // Set DocumentViewer.Document to XPS document 
                    if (txtTitle.Text.Trim().Length == 0)
                    {
                        String title = dlg.SafeFileName;
                        txtTitle.Text = title.Substring(0, title.Length - 4);
                    }

                    btnCreate.IsEnabled = true;
                }
            }
        }
Beispiel #10
0
 private void _vmSaveFileInteractionEvent(object sender, InteractionRequestedEventArgs e)
 {
     SaveFileConfirmation _confirmation = e.Context as SaveFileConfirmation;
       if (_confirmation == null)
     return;
       string _msg = $"Click Yes to save configuration to {_confirmation.FilePath}, No to slecet new file, Cancel to cancel";
       //switch (MessageBox.Show(_confirmation.Title, _msg, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel))
       switch (MessageBox.Show(_msg, _confirmation.Title, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel))
       {
     case MessageBoxResult.None:
     case MessageBoxResult.OK:
     case MessageBoxResult.Yes:
       break;
     case MessageBoxResult.Cancel:
       _confirmation.FilePath = string.Empty;
       break;
     case MessageBoxResult.No:
       OpenFileDialog _dialog = new OpenFileDialog()
       {
     AddExtension = true,
     CheckPathExists = true,
     DefaultExt = ".xml",
     Filter = "Configuration (.xml)|*.xml",
     FileName = _confirmation.FilePath,
     Title = "Save file as ..",
     CheckFileExists = false,
     ValidateNames = true,
       };
       _confirmation.FilePath = _dialog.ShowDialog().GetValueOrDefault(false) ? _dialog.FileName : string.Empty;
       e.Callback();
       break;
     default:
       break;
       }
 }
		void Browse()
		{
			var dialog = new OpenFileDialog();
			if (dialog.ShowDialog() ?? false) {
				SvcUtilPath = dialog.FileName;
			}
		}
Beispiel #12
0
        /// <summary>
        /// vykonávacia logika príkazu
        /// </summary>
        /// <param name="parameter">parameter príkazu</param>
        public void Execute(object parameter)
        {
            if (((MainWindowViewModel)parameter).HadProject == true)
            {
                string messageText = "Nemôžu byť otvorené dva projekty súčasne. Vymazať projekt?";
                string messageCaption = "Vymazať projekt";
                MessageBoxResult res = MessageBox.Show(messageText, messageCaption, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);
                if (res == MessageBoxResult.Yes)
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.Filter = "XML documents (.xml)|*.xml";
                    if (dialog.ShowDialog() == true)
                    {
                        string filename = dialog.FileName;

                        ((MainWindowViewModel)parameter).Load(filename);
                    }
                }

                ((MainWindow)Application.Current.MainWindow).mainFrame.Navigate(new Uri("Views/Pages/WelcomePage.xaml", UriKind.Relative));

            }
            else
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "XML documents (.xml)|*.xml";
                if (dialog.ShowDialog() == true)
                {
                    string filename = dialog.FileName;

                    ((MainWindowViewModel)parameter).Load(filename);
                }
                ((MainWindowViewModel)parameter).HadProject = true;
            }
        }
Beispiel #13
0
        private void OpenCommand_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == true)
            {
                ellipses.Clear();

                StreamReader sr = new StreamReader(ofd.FileName);
                while (!sr.EndOfStream)
                {
                    String[] g = sr.ReadLine().Split(' ');
                    Circle circle = new Circle() { R = double.Parse(g[0]), X = double.Parse(g[1]), Y = double.Parse(g[2]) };
                    ellipses.Add(circle);
                }
                sr.Close();

                vd = new VD<Circle, DeloneCircle>(ellipses[0], ellipses[1], null);
                for (int i = 2; i < ellipses.Count; i++)
                    vd.Insert(ellipses[i]);

                if (vd != null)
                    BuildTriples(vd.NextTriple(vd.NullTriple), gg_triples, true);
                else
                    gg_triples.Children.Clear();
                triple = vd.NextTriple(vd.NullTriple);
            }
        }
        public void AssertMultiselectStoreValueInDialog()
        {
            var openFileDialog = new OpenFileDialog();

            var editorOpenFileDialog = Setup(openFileDialog);

            // Testing default value

            Assert.IsFalse(editorOpenFileDialog.Multiselect);
            Assert.IsFalse(openFileDialog.Multiselect);

            // Testing set value from .Net dialog

            openFileDialog.Multiselect = true;

            Assert.IsTrue(editorOpenFileDialog.Multiselect);
            Assert.IsTrue(openFileDialog.Multiselect);

            // Testing set value from editor dialog

            editorOpenFileDialog.Multiselect = false;

            Assert.IsFalse(editorOpenFileDialog.Multiselect);
            Assert.IsFalse(openFileDialog.Multiselect);
        }
Beispiel #15
0
        public static MEFile OpenFile()
        {
            string content = "";
            // Create OpenFileDialog
            OpenFileDialog dlg = new OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".txt";
            dlg.Filter = TextFileFilter;

            // Display OpenFileDialog by calling ShowDialog method
            bool? result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                content = File.ReadAllText(dlg.FileName);
                string FileName = Path.GetFileNameWithoutExtension(dlg.SafeFileName);
                string Extension = Path.GetExtension(dlg.SafeFileName);
                return new MEFile(FileName, Extension, content, dlg.FileName);
            }
            else
            {
                return MEFile.ERROR_ME_FILE;
            }

            throw new NotImplementedException();
        }
Beispiel #16
0
 public string ShowOpenFileDialog()
 {
     var dlg = new OpenFileDialog();
     if (dlg.ShowDialog() == true)
         return dlg.FileName;
     return null;
 }
        protected override void InnerExecute(object parameter)
        {

            OpenFileDialog openEnvironmentConfigurationDeltaDialog = new OpenFileDialog
                                                                         {
                                                                             Filter = DesignResources.DeltaDialogFilter,
                                                                             Title = DesignResources.OpenDeltaDialogTitle
                                                                         };

            var openFileResult = UIService.ShowFileDialog(openEnvironmentConfigurationDeltaDialog);
            if (openFileResult.DialogResult != true)
            {
                return;
            }

            try
            {
                var configuration = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = openFileResult.FileName }, ConfigurationUserLevel.None);
                EnvironmentalOverridesSection mergeSection = (EnvironmentalOverridesSection)configuration.GetSection(EnvironmentalOverridesSection.EnvironmentallyOverriddenProperties);

                sourceModel.LoadEnvironment(mergeSection, openFileResult.FileName);
            }
            catch (Exception ex)
            {
                ConfigurationLogWriter.LogException(ex);
                UIService.ShowMessageWpf(string.Format(CultureInfo.CurrentCulture, Resources.ErrorLoadingDeltaFile, ex.Message),
                                         Resources.ErrorTitle,
                                         MessageBoxButton.OK);
            }
        }
        private void OpenCommandHandler(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName = "Document"; // Default file name
            dlg.DefaultExt = ".txt"; // Default file extension
            dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;

                TextRange range;
                FileStream fStream;
                if (File.Exists(filename))
                {
                    tabControl1.SelectedIndex = 1;
                    range = new TextRange(rtb1.Document.ContentStart, rtb1.Document.ContentEnd);
                    fStream = new FileStream(filename, FileMode.OpenOrCreate);
                    range.Load(fStream, DataFormats.Text);
                    fStream.Close();                    
                }
                FormatWholeDocument();
            }
        }
        public override void Execute()
        {
            // Ask the user to select a file.
            var dlg = new OpenFileDialog();
            bool? result = dlg.ShowDialog();

            // If the user pressed Cancel, don't continue.
            if (!result.HasValue || !result.Value)
            {
                this.Result.IsSuccessful = false;
                this.Result.MessageTitle = "User Cancelled";
                this.Result.MessageText = "The user cancelled the operation.";
                this.Result.MessageDetails = "Even more details can go here.";
                return;
            }

            // Now we'll create a new StudyUnit with the same name of that
            // file. Of course, if the file contained some interesting
            // information, we could process the file and set that information
            // as part of our new object.
            var myStudy = new StudyUnit();
            myStudy.DublinCoreMetadata.Title.Current =
                Path.GetFileNameWithoutExtension(dlg.FileName);

            // Add any new items to a collection, and use the Api object
            // to tell Designer about them.
            var newItems = new Collection<IVersionable>();
            newItems.Add(myStudy);
            this.Api.Import(newItems, true);

            // Add the new item to the ModifiedItems of the Result property,
            // to let Colectica know that you created something new.
            this.Result.ModifiedItems.Add(myStudy);
        }
Beispiel #20
0
        private void NewOutputFormatMenuItem_Click(object sender, RoutedEventArgs e)
        {
            ClearCanvas();

            var newOutputFormatOpenFileDialog = new OpenFileDialog
            {
                Filter = "dll files (*.dll)|*.dll",
                DefaultExt = ".dll",
                Title = "Please select dll file"
            };

            if (newOutputFormatOpenFileDialog.ShowDialog() == true)
            {
                string pathToCopy = Path.Combine(AssemblyPath, @"Printers\",
                    Path.GetFileName(newOutputFormatOpenFileDialog.FileName));

                try
                {
                    File.Copy(newOutputFormatOpenFileDialog.FileName, pathToCopy, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                MessageBox.Show("Printer added successfully!", "Information", MessageBoxButton.OK,
                    MessageBoxImage.Information);
            }
        }
        private void BtnImportClick(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                Filter = "Text files (*.txt)|*.txt"
            };

            var result = ofd.ShowDialog();

            if (result == true)
            {
                if (!File.Exists(ofd.FileName))
                {
                    return;
                }

                var accounts = Utils.GetLogins(ofd.FileName);
                var num = 0;

                foreach (var account in accounts)
                {
                    if (!Checker.Accounts.Exists(a => a.Username == account.Username))
                    {
                        Checker.Accounts.Add(account);
                        num++;
                    }
                }

                this.ShowMessageAsync(
                    "Import", num > 0 ? string.Format("Imported {0} accounts.", num) : "No new accounts found.");

                RefreshAccounts();
                MainWindow.Instance.UpdateControls();
            }
        }
        public static OpenFileDialog GetNewImageFileDialog()
        {
            // Configure open file dialog box
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "";

            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
            string sep = string.Empty;
            string allCodecs = string.Empty;
            foreach (var c in codecs)
            {
                string codecName = c.CodecName.Substring(8).Replace("Codec", "Files").Trim();
                dlg.Filter = String.Format("{0}{1}{2} ({3})|{3}", dlg.Filter, sep, codecName, c.FilenameExtension);
                allCodecs += c.FilenameExtension + ";";
                sep = "|";
            }

            dlg.Filter = String.Format("{0}{1}{2} ({3})|{3}", dlg.Filter, sep, "All Image Files", allCodecs.Remove(allCodecs.Length-1));

            dlg.Filter = String.Format("{0}{1}{2} ({3})|{3}", dlg.Filter, sep, "All Files", "*.*");

            dlg.FilterIndex = 6;

            return dlg;
        }
		public void Merge()
		{
			var openDialog = new OpenFileDialog()
			{
				Filter = "firesec2 files|*.fscp",
				DefaultExt = "firesec2 files|*.fscp"
			};
			if (openDialog.ShowDialog().Value)
			{
				ServiceFactory.Events.GetEvent<ConfigurationClosedEvent>().Publish(null);
				ZipConfigActualizeHelper.Actualize(openDialog.FileName, false);
				var folderName = AppDataFolderHelper.GetLocalFolder("Administrator/MergeConfiguration");
				var configFileName = Path.Combine(folderName, "Config.fscp");
				if (Directory.Exists(folderName))
					Directory.Delete(folderName, true);
				Directory.CreateDirectory(folderName);
				File.Copy(openDialog.FileName, configFileName);
				LoadFromZipFile(configFileName);
				ServiceFactory.ContentService.Invalidate();

				FiresecManager.UpdateConfiguration();

				ServiceFactory.Events.GetEvent<ConfigurationChangedEvent>().Publish(null);
				ServiceFactory.Layout.Close();
				if (ApplicationService.Modules.Any(x => x.Name == "Устройства, Зоны, Направления"))
					ServiceFactory.Events.GetEvent<ShowDeviceEvent>().Publish(Guid.Empty);
				else if (ApplicationService.Modules.Any(x => x.Name == "Групповой контроллер"))
					ServiceFactory.Events.GetEvent<ShowXDeviceEvent>().Publish(Guid.Empty);

				ServiceFactory.SaveService.FSChanged = true;
				ServiceFactory.SaveService.PlansChanged = true;
				ServiceFactory.SaveService.GKChanged = true;
				ServiceFactory.Layout.ShowFooter(null);
			}
		}
        public void ExecuteOpenFileDialog()
        {
            var dialog = new OpenFileDialog { InitialDirectory = _defaultPath };
            dialog.ShowDialog();

            SelectedPath = dialog.FileName;
        }
        public override InteriorField[,] GetLayout()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.DefaultExt = "txt";
            DirectoryInfo currentDir = new DirectoryInfo(Environment.CurrentDirectory);
            openFileDialog.InitialDirectory = (currentDir.EnumerateDirectories().FirstOrDefault(d => d.Name == DataSubdirName) ?? currentDir).FullName;
            if (openFileDialog.ShowDialog().GetValueOrDefault())
            {
                this.LayoutIdentifier = openFileDialog.FileName;
                using (StreamReader readLines = new StreamReader(openFileDialog.OpenFile()))
                {
                    List<List<InteriorField>> layout = readLines
                        .ReadToEnd()
                        .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(s => s
                            .Select(c => this.CreateField(c)).ToList()).ToList();

                    int columnsCount = layout.Max(l => l.Count);
                    InteriorField[,] result = new InteriorField[layout.Count, columnsCount];
                    for (int row = 0; row < layout.Count; row++)
                    {
                        for (int col = 0; col < layout[row].Count; col++)
                        {
                            result[row, col] = layout[row][col];
                        }
                    }
                    return result;
                }
            }
            else
            {
                return null;
            }
        }
        public void LoadImage()
        {
            var filedialog = new OpenFileDialog()
            {
                Multiselect = false
            };

            if (filedialog.ShowDialog() == true)
            {
                var temp = File.ReadAllBytes(filedialog.FileName);
                var newtemp = new ushort[0x10000];

                for (int i = 0; i < temp.Length; i++)
                {
                    if (i % 2 == 0)
                    {
                        newtemp[i / 2] |= (ushort)(temp[i] << 8);
                    }
                    else
                    {
                        newtemp[i / 2] |= (ushort)(temp[i]);
                    }
                }

                App.CPU.SetMemory(newtemp);
            }
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            Nullable<bool> result = dialog.ShowDialog();

            if (result != true)
            {
                Shutdown();
                return;
            }

            MachineType machineType;

            FileInfo fileInfo = new FileInfo(dialog.FileName);

            try
            {
                using (FileStream filestream = fileInfo.Open(FileMode.Open, FileAccess.Read))
                {
                    machineType = ReadMachineType(filestream);
                }
            }
            catch (PEHeaderNotFoundException error)
            {
                MessageBox.Show(error.Message);
                Shutdown();
                return;
            }

            DisplayMachineType(machineType);

            Shutdown();
        }
Beispiel #28
0
        public static string OpenTest(string courseName_copy, string groupName_copy, string testName_copy)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "TST Files (*.tst) |*.tst";
            Nullable<bool> resultOfDialog = openFileDialog.ShowDialog();
            string resultOfParsing;
            _courseName = courseName_copy;
            _groupName = groupName_copy;
            _testName = testName_copy;

            if (resultOfDialog == true)
            {
                string pathOfTest = openFileDialog.FileName;
                SelectDirectoryPath(pathOfTest);
                try
                {
                    resultOfParsing = TestParser.Instance.ParseTest(pathOfTest, folderPath);
                }
                catch(Exception)
                {
                    resultOfParsing = "Wystąpił problem podczas odczytu plik";
                }

                if(resultOfParsing == "Ok")
                {
                    ZipDirectory(folderPath, fileName);
                    if(IS_OK == true)
                        unzipTest();
                }
                return resultOfParsing;
            }
            return "";
        }
        public void Run()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Zip Files (*.zip)|*.zip|" + Utility.AllFilesFilter;
            if (openFileDialog.ShowDialog() == true)
            {
                WaitWindow waitWindow = new WaitWindow("Importing collection...");
                waitWindow.ShowDialog(this.ParentWindow, () =>
                {
                    try
                    {
                        using (CollectionImporterBase importer = new ArchivedCollectionImporter(openFileDialog.FileName, this.CollectionManager))
                        {
                            importer.Import();
                        }
                    }
                    catch (Exception ex)
                    {
                        Utility.WriteToErrorLog("Error importing: " + ex.ToString());
                        MessageBox.Show("Error importing backup: " + ex.Message);
                    }

                    this.ParentWindow.Dispatcher.BeginInvokeAction(() =>
                    {
                        CollectionManagerGlobal.OnCollectionChanged();
                    });
                });
            }
        }
Beispiel #30
0
        /// <inheritdoc/>
        public async Task<string> GetImageKeyAsync()
        {
            try
            {
                var dlg = new OpenFileDialog()
                {
                    Filter = "All (*.*)|*.*",
                    FilterIndex = 0,
                    FileName = ""
                };

                if (dlg.ShowDialog(_serviceProvider.GetService<MainWindow>()) == true)
                {
                    var path = dlg.FileName;
                    var bytes = System.IO.File.ReadAllBytes(path);
                    var key = _serviceProvider.GetService<ProjectEditor>().Project.AddImageFromFile(path, bytes);
                    return await Task.Run(() => key);
                }
            }
            catch (Exception ex)
            {
                _serviceProvider.GetService<ILog>().LogError($"{ex.Message}{Environment.NewLine}{ex.StackTrace}");
            }

            return null;
        }
Beispiel #31
0
        private string fileSelect_dialog()
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".vhdx";
            dlg.Filter     = "VHDX Files (*.vhdx)|*.vhdx|All Files (*.*)|*.*";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and return the value
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                return(filename);
            }
            return("No file selected");
        }
Beispiel #32
0
        public void OpenFile()
        {
            // ofd to open a file. Regex checks if file is a png or text file and treats it accordingly.
            OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();

            ofd.Filter = "Text Files (*.txt)|*.txt|PNG(*.png)|*.png|All Files (*.*)|*.*";
            if (ofd.ShowDialog() == true)
            {
                filePath = ofd.FileName;
                Regex regex = new Regex(@"\.png\s$", RegexOptions.IgnoreCase);
                Match match = regex.Match(filePath);
                if (match.Success)
                {
                    OpenPNGImage();
                }
                else
                {
                    textBox1.Text = File.ReadAllText(filePath);
                }
            }
        }
        private string OpenFileDialog()
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            //dialog.InitialDirectory = @"C:";
            dialog.InitialDirectory = @"E:\Download\rvl-cdip";
            dialog.DefaultExt       = ".txt";
            dialog.Filter           = ".TXT Files (*.txt)|*.txt";

            Nullable <bool> result = dialog.ShowDialog();

            if (result == true)
            {
                return(dialog.FileName);
            }
            else
            {
                SetStatusImage(imgPathLabels, "img/alert.png");
                return("Error browsing for file!");
            }
        }
Beispiel #34
0
        /**
         * Permite abrir un nuevo texto
         */
        private void Open_Click(object sender, EventArgs e)
        {
            OpenFiles = new Microsoft.Win32.OpenFileDialog();

            //Preparo el openFile con las opciones necesarias
            OpenFiles.InitialDirectory = "c:\\";                                                                //Primer directorio
            OpenFiles.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*|rtf files (*.rtf)|*.rtf"; //Filtra ficheros de texto y rtf
            OpenFiles.FilterIndex      = 2;
            OpenFiles.RestoreDirectory = true;

            if (OpenFiles.ShowDialog() == true)
            {
                //Get the path of specified file
                filePath = OpenFiles.FileName;

                rutas.Items.Add(filePath);
                selectedPath = filePath.ToString();
                System.Windows.MessageBox.Show("Fichero cargado con exito");
                leeArchivo();
            }
        }
Beispiel #35
0
        // Load File Dialog
        private void mnu_LOAD(object sender, RoutedEventArgs e)
        {
            //configure save file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "config";                     //default file name
            dlg.DefaultExt = ".xml";                       //default file extension
            dlg.Filter     = "XML documents (.xml)|*.xml"; //filter files by extension

            // Show save file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                Stream load_stream = dlg.OpenFile();
                RSS_LogicEngine.Component_View component_view;
                component_view = RSS_LogicEngine.Component_View.Get_Instance();
                component_view.Load_Components(load_stream);
                load_stream.Close();
            }
        }
        //檔案->開啟舊檔 功能
        private void Loading_Click(object sender, RoutedEventArgs e)
        {
            Doing.Content = "開啟舊檔....";
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            OpenFileDialog openfile = new OpenFileDialog();

            openfile.DefaultExt = ".txt";
            openfile.Filter     = "文字文件|*.txt|全部文件|*.*";
            if (openfile.ShowDialog() == true)
            {
                string path   = openfile.FileName;
                var    reader = new StreamReader(path, Encoding.GetEncoding("big5"));//var不明確的宣告

                Text_in.Text = File.ReadAllText(path);

                Save_path    = path;
                is_Save      = true;
                window.Title = openfile.SafeFileName + " - 記事本";
            }
            Doing.Content = "就緒....";
        }
Beispiel #37
0
        private void AddNewFileToModelList()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Obj files (*.obj)|*.obj";
            Nullable <bool> result = fileDialog.ShowDialog();
            string          newModel;

            if (result == true)
            {
                newModel = fileDialog.FileName;
                string directoryPath = System.IO.Path.GetDirectoryName(fileDialog.FileName);
                string newModelName  = Path.GetFileNameWithoutExtension(newModel);

                File.Copy(newModel, $"C:/Users/Anastasiia/source/repos/My_3d_WFP_App/furniture/{Path.GetFileName(newModel)}");
                modelList.Add($"C:/Users/Anastasiia/source/repos/My_3d_WFP_App/furniture/{Path.GetFileName(newModel)}");
                myScene.AddElement(newModel);
                lvScene.ItemsSource = myScene.Names;
            }
            lvScene.Items.Refresh();
        }
Beispiel #38
0
        //*************************************Reutilisation******************************************
        #region Réeutilisation
        private void TextBlock_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".xaml";                    // Default file extension
            dlg.Filter     = "Xaml File (.xaml)|*.xaml"; // Filter files by extension
            // Show open file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                string filename = dlg.FileName;
                String nom      = dlg.SafeFileName.Replace(".xaml", " ");
                CircuitPersonnalise personnalise = Reutilisation(filename); personnalise.setLabel(nom);
                CircuitComplet      gate         = new CircuitComplet(personnalise);

                this.circuit.AddComponent(personnalise);
                gate.added = true;
                Grille.Children.Add(gate);
            }
        }
Beispiel #39
0
        private void ButtonChooseFile_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog();

            string fileName;
            // Launch OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = openFileDlg.ShowDialog();

            // Get the selected file name and display in a TextBox.
            // Load content of file in a TextBlock
            if (result == true)
            {
                fileName = openFileDlg.FileName;

                if (bt.choosenDevice != null)
                {
                    bt.SendTempFile(fileName);
                }
            }
        }
Beispiel #40
0
        private void bt_Load_Click(object sender, RoutedEventArgs e)
        {
            while (dsData.Tables.Count > 0)
            {
                DataTable table = dsData.Tables[0];
                if (dsData.Tables.CanRemove(table))
                {
                    dsData.Tables.Remove(table);
                }
            }

            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "";                           // Default file name
            dlg.DefaultExt = ".xml";                       // Default file extension
            dlg.Filter     = "Xml documents (.xml)|*.xml"; // Filter files by extension

            // Show open file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                dsData.ReadXml(dlg.FileName);

                dtComponents = dsData.Tables["Components"];

                dtBoardInfo = dsData.Tables["BoardInfo"];


                ItemTitle.Text = dsData.Tables["BoardInfo"].Rows[0][0].ToString();
                csfeeder.Text  = dsData.Tables["BoardInfo"].Rows[0][2].ToString();
            }



            _dgComponents.ItemsSource = dtComponents.DefaultView;
        }
        private void btnImage_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".png";
            dlg.Filter     = "PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|JPG Files (*.jpg)" +
                             "|*.jpg|JPEG Files (*.jpeg)|*.jpeg";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a title of the form
            if (result == true)
            {
                // Open document
                if (dlg.FileName == "")
                {
                    return;
                }
                try
                {
                    BitmapImage bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource   = new Uri(dlg.FileName);
                    bitmap.CacheOption = BitmapCacheOption.OnLoad;
                    bitmap.EndInit();
                    Image image = new Image();
                    image.Source = bitmap;
                    Paragraph para = new Paragraph();
                    para.Inlines.Add(image);
                    Text_Field.Document.Blocks.Add(para);
                }
                catch
                {
                    MessageBox.Show("Unable to insert the image format selected.", "RTE - Paste");
                }
            }
        }
Beispiel #42
0
        /// <summary>
        /// 从清单比较
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_CompareFromList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var ofd = new OpenFileDialog();
                ofd.Title  = "请选择一个清单文件...";
                ofd.Filter = "清单文件|*.txt";
                ofd.ShowDialog();

                if (ofd.FileName == null || ofd.FileName == "" || Tbx_FolderPath.Text == "")
                {
                    return;
                }

                var currTime = DateTime.Now;

                var arr   = File.ReadAllLines(ofd.FileName);
                var dict2 = new Dictionary <string, string>();
                foreach (var line in arr)
                {
                    var _arr = line.Split(',');
                    dict2.Add(_arr[0], _arr[1]);
                }

                FileList.Clear();
                GetFolderFileList(Tbx_FolderPath.Text);
                var dict1 = CalcFileList(Tbx_FolderPath.Text);

                var dt = CompareTwoSource(dict1, dict2, Tbx_FolderPath.Text, $@"清单文件:{ofd.FileName}");

                var endTime = DateTime.Now;

                dataGrid_Main.ItemsSource = dt.DefaultView;
                MessageBox.Show($@"目录比对完成,共计比对{dict1.Count + dict2.Count}个文件,耗时{Math.Round((endTime - currTime).TotalSeconds)}秒!");
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"从清单比较异常,{ex.Message}");
            }
        }
Beispiel #43
0
        protected override void MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (Drawing != null)
            {
                Point ptPhy = Coordinates(e);

                Microsoft.Win32.OpenFileDialog ofDialog = new Microsoft.Win32.OpenFileDialog()
                {
                    Title  = "Insert Background",
                    Filter = Webb.Playbook.Data.Extensions.ImageFileFilter,
                };

                if (ofDialog.ShowDialog().Value)
                {
                    ImageBrush imgBrush = new ImageBrush()
                    {
                        Stretch     = Stretch.None,
                        AlignmentX  = AlignmentX.Center,
                        AlignmentY  = AlignmentY.Center,
                        ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(ofDialog.FileName, UriKind.RelativeOrAbsolute)),
                    };

                    System.Drawing.Image image = System.Drawing.Image.FromFile(ofDialog.FileName);

                    PBImage pbImg = new PBImage()
                    {
                        Coordinates = ptPhy,
                        File        = ofDialog.FileName,

                        Width  = ToLogical(image.Width),
                        Height = ToLogical(image.Height),
                    };

                    Drawing.Add(pbImg);
                    pbImg.MoveTo(pbImg.Coordinates);
                }

                Drawing.SetDefaultBehavior();
            }
        }
        private void SendFileButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();

            ofd.Filter      = "All Files (*.*)|*.*";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == true)
            {
                FileInfo file = new FileInfo(ofd.FileName);
                if (file.Length > 2000000)
                {
                    MessageBox.Show("文件太大,无法传输!");
                    return;
                }
                if (file.Length <= 0)
                {
                    MessageBox.Show("请不要传输空文件!");
                    return;
                }
                String   url = (String)ofd.FileName;
                object[] obj = (object[])mw.getFriendItemById[this.key].DataContext;
                if (((String)obj[4]).Equals("  在线"))                                                                                         //在线
                {
                    if (MessageBox.Show("是否使用离线传送功能?", "消息", MessageBoxButton.YesNo, MessageBoxImage.Question).Equals(MessageBoxResult.Yes)) //离线发送
                    {
                        //离线发送
                        mw.SendMessage("offlnfile", new String[] { this.key, url });
                    }
                    else//在线传送
                    {
                        mw.SendMessage("onlnfile", new String[] { this.key, url });
                    }
                }
                else//离线
                {
                    //离线传送
                    mw.SendMessage("offlnfile", new String[] { this.key, url });
                }
            }
        }
        /// <summary>
        /// Is used to smooth the given pcd file.
        /// </summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event arguments</param>
        private void SmootherButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension

            dialog.DefaultExt = "*.pcd";
            dialog.Filter     = "PCD File(*.pcd)|*.*";
            dialog.FileName   = "PointCloudToSmooth.pcd";
            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result    = dialog.ShowDialog();
            string          extension = Path.GetExtension(dialog.FileName).ToLowerInvariant();
            string          filePath  = dialog.FileName;

            var dialog2 = new SaveFileDialog
            {
                Title       = "Save Smoothed PCD",
                Filter      = "PCD File(*.pcd)|*.*",
                FilterIndex = 0,
                DefaultExt  = ".pcd"
            };

            if (extension == ".pcd")
            {
                dialog2.FileName = Path.GetFileNameWithoutExtension(filePath) + "_smoothed";;
            }

            // Get the selected file name and display in a TextBox
            if (result == true && dialog2.ShowDialog() == true)
            {
                string filePath2 = dialog2.FileName;

                if (extension == ".pcd")
                {
                    string strCmdText;
                    strCmdText = "/C " + Directory.GetCurrentDirectory() + "\\SubPrograms s " + filePath + " " + filePath2;
                    System.Diagnostics.Process.Start("CMD.exe", strCmdText);
                }
            }
        }
Beispiel #46
0
        private void EditConfig(string path = null)
        {
            ConfigFile file = new ConfigFile();

            if (path != null)
            {
                if (!string.IsNullOrEmpty(path) && File.Exists(path))
                {
                    file.File = path;
                }
                else
                {
                    Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
                    {
                        Multiselect = false,
                        Filter      = l.Resources.ConfigFileDialogFilterDescription + "|*.config"
                    };

                    if (openFileDialog.ShowDialog() == true)
                    {
                        file.File = openFileDialog.FileName;
                    }
                    else
                    {
                        return;
                    }
                }
                if (file.File is null)
                {
                    return;
                }
                file.LoadConfigFile();
            }

            ConfigEditor configWindow = new ConfigEditor();

            configWindow.Owner       = this;
            configWindow.DataContext = file;
            configWindow.ShowDialog();
        }
 private void select_apk_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.OpenFileDialog apkselect = new Microsoft.Win32.OpenFileDialog();
     apkselect.Title            = "Select .APK";
     apkselect.CheckFileExists  = true;
     apkselect.CheckPathExists  = true;
     apkselect.Filter           = "Android Package Kit | *.APK";
     apkselect.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     apkselect.ShowDialog();
     if (apkselect.CheckPathExists == true && apkselect.ValidateNames == true)
     {
         ProcessStartInfo process = new ProcessStartInfo();
         process.CreateNoWindow         = false;
         process.FileName               = "adb.exe";
         process.Arguments              = "install " + apkselect.FileName;
         process.RedirectStandardError  = true;
         process.RedirectStandardOutput = true;
         process.UseShellExecute        = false;
         var install = Process.Start(process);
         installed.Visibility = System.Windows.Visibility.Visible;
     }
 }
Beispiel #48
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Directory.SetCurrentDirectory("C:/tmp/soundpcker/assets/minecraft/sounds/records");
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
            {
                DefaultExt  = ".ogg",
                Filter      = "OGG Audio |*.ogg",
                Multiselect = false,
                Title       = "Choose an Audio OGG"
            };
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                tomodifyoggorigin = dlg.FileName;
            }
            if (result == false)
            {
                MessageBox.Show("You Must Select a File!.", "Cancelled", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
        }
Beispiel #49
0
 ///-------------------------------------------------------------------------------------------------
 /// \fn private void BtnSave_Click(object sender, RoutedEventArgs e)
 ///
 /// \brief  Event handler. Called by BtnSave for click events
 ///
 /// \author Arie
 /// \date   2019-04-12
 ///
 /// \param  sender  Source of the event.
 /// \param  e       Routed event information.
 ///-------------------------------------------------------------------------------------------------
 private void BtnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
         openFileDialog.FileName   = "New Text Document";           // The default name of the file
         openFileDialog.DefaultExt = ".txt";                        // The default extension
         openFileDialog.Filter     = "Text documents (.txt)|*.txt"; // Filter files by extension
         if (openFileDialog.ShowDialog() == true)
         {
             MainWindow.billing.ParseBillFile(openFileDialog.FileName);
         }
     }
     catch (Exception expt)
     {
         Logging.Write(expt.Message);
         System.Windows.MessageBox.Show("Exception: " + expt.Message);
     }
     finally
     {
     }
 }
        // ------------------------------ OnOpen ------------------------------
        /// <summary>
        ///   Handles the user "File | Open" menu operation.</summary>
        private void OnOpen(object target, ExecutedRoutedEventArgs args)
        {
            // If a document is currently open, check with the user
            // if it's ok to close it before opening a new one.
            if (_xpsPackage != null)
            {
                string msg =
                    "The currently open document needs to be closed before\n" +
                    "opening a new document.  Ok to close '" + _xpsDocumentName + "'?";
                MessageBoxResult result =
                    MessageBox.Show(msg, "Close Current Document?",
                                    MessageBoxButton.OKCancel, MessageBoxImage.Question);

                // If the user did not click OK to close current
                // document, cancel the File | Open request.
                if ((result != MessageBoxResult.OK))
                {
                    return;
                }

                // The user clicked OK, close the current document and continue.
                CloseDocument();
                CloseXrML();
            }

            // Create a "File Open" dialog positioned to the
            // "Content\" folder containing the sample fixed document.
            WinForms.OpenFileDialog dialog = new WinForms.OpenFileDialog();
            dialog.InitialDirectory = GetContentFolder();
            dialog.CheckFileExists  = true;
            dialog.Filter           = "XPS Document files (*.xps)|*.xps";

            // Show the "File Open" dialog.  If the user picks a file and
            // clicks "OK", load and display the specified XPS document.
            if (dialog.ShowDialog() == true)
            {
                OpenDocument(dialog.FileName);
            }
        }// end:OnOpen()
        }// end:CloseDocument

        #endregion File|Close


        #region File|Rights...
        // ----------------------------- OnRights -----------------------------
        /// <summary>
        ///   Handles the user File|Rights... menu option to
        ///   select and load a digital rights .xrml file.</summary>
        private void OnRights(object sender, EventArgs e)
        {
            // If an XrML is currently open, check with the user
            // if it's ok to close it before opening a new one.
            if (_xrmlFilepath != null)
            {
                string msg =
                    "The currently open eXtensible Rights Markup Language (XrML)\n" +
                    "document needs to be closed before opening a new document.\n" +
                    "Ok to close '" + _xrmlFilename + "'?";
                MessageBoxResult result =
                    MessageBox.Show(msg, "Close Current XrML?",
                                    MessageBoxButton.OKCancel, MessageBoxImage.Question);

                // If the user did not click OK to close current
                // document, cancel the File | Open request.
                if ((result != MessageBoxResult.OK))
                {
                    return;
                }

                // The user clicked OK, close the current XrML file and continue.
                CloseXrML();
            }

            // Create a "File Open" dialog positioned to the
            // "Content\" folder containing the sample fixed document.
            WinForms.OpenFileDialog dialog = new WinForms.OpenFileDialog();
            dialog.InitialDirectory = GetContentFolder();
            dialog.CheckFileExists  = true;
            dialog.Filter           = "XrML Rights markup files (*.xrml)|*.xrml";

            // Show the "File Open" dialog.  If the user picks a file and
            // clicks "OK", load and display the specified XPS document.
            if (dialog.ShowDialog() == true)
            {
                OpenXrML(dialog.FileName);
            }
        }// end:OnRights()
Beispiel #52
0
        private void buttonOpenRVT_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
                openFileDialog.Title            = "Open a Revit Project File";
                openFileDialog.RestoreDirectory = true;
                openFileDialog.DefaultExt       = ".rvt";
                openFileDialog.Filter           = "Revit Project File (.rvt)|*.rvt";

                Nullable <bool> result = openFileDialog.ShowDialog();
                if (result == true)
                {
                    rvtFileName           = openFileDialog.FileName;
                    textBoxRevitFile.Text = rvtFileName;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Cannot open the selected Revit file.\n" + ex.Message, "Open Revit File", MessageBoxButton.OK);
            }
        }
Beispiel #53
0
        // Open file
        private void btnOpenImage_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Filter     = "Png Image|*.png|Jpg Image|*.jpg|Bitmap Image|*.bmp";
            openFileDialog.FileName   = "MyPaint";
            openFileDialog.DefaultExt = ".png";

            if ((bool)openFileDialog.ShowDialog())
            {
                ImageBrush image = new ImageBrush();
                image.ImageSource = new BitmapImage(new Uri(@openFileDialog.FileName, UriKind.Relative));

                shape = ShapeCreator.CreateNewShape("TRectangle");
                shape.FillColorBrush   = image;
                shape.StrokeColorBrush = System.Windows.Media.Brushes.Transparent;
                shape.StartPoint       = new Point(0, 0);
                shape.EndPoint         = new Point(image.ImageSource.Width, image.ImageSource.Height);

                shape.draw(isShiftKeyDown, PaintCanvas.Children);
                ShapeCommand cmd = new ShapeCommand(PaintCanvas.Children, PaintCanvas.Children[PaintCanvas.Children.Count - 1]);
            }
        }
Beispiel #54
0
        private Boolean getOpenFilename(string initDir, string title, string filter, out string newfilename,
                                        Boolean mustExist)
        {
            var fileChooser = new OpenFileDialog
            {
                Title            = title,
                InitialDirectory = initDir,
                Filter           = filter,
                CheckFileExists  = mustExist
            };

            if ((Boolean)fileChooser.ShowDialog(this))
            {
                newfilename = fileChooser.FileName;
                return(true);
            }
            else
            {
                newfilename = "";
                return(false);
            }
        }
Beispiel #55
0
        public void button_export(object sender, RoutedEventArgs e)
        {
            string path           = string.Empty;
            var    openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Files (*.xlsx*)|*.xls*"//如果需要筛选txt文件("Files (*.txt)|*.txt")
            };
            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                path = openFileDialog.FileName;
            }
            if (path.Length > 0)
            {
                OtherDAL dAL = new OtherDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dAL.getOtherData(), path, "Other");
                MessageBox.Show("导出完成");
            }
        }
Beispiel #56
0
        private void MenuItem_Click_Open(object sender, RoutedEventArgs e)
        {
            // open a filedialog with option ".wav"
            var ofd = new OpenFileDialog();

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".wav";
            dlg.Filter     = "WAV files (.wav)|*.wav";

            Nullable <bool> result = dlg.ShowDialog();

            if (dlg.ShowDialog() == false)
            {
                return;
            }


            wave   = new NAudio.Wave.WaveFileReader(dlg.FileName);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
        private void Selected3dsFile()
        {
            // Ab3d.PowerToys samples by default does not have reference to Ab3d.Reader3ds
            // If you want to use this sample with custom 3ds mode, uncomment the content of the next method (Read3dsFile)

            MessageBox.Show("To read 3ds file, please add reference to Ab3d.Reader3ds\r\nand than uncomment the code in Read3dsFile method.");
            return;

            Microsoft.Win32.OpenFileDialog openFileDialog;

            openFileDialog               = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.DefaultExt    = "3ds";
            openFileDialog.Filter        = "3ds files (*.3ds)|*.3ds";
            openFileDialog.Multiselect   = false;
            openFileDialog.Title         = "Select 3ds file to open";
            openFileDialog.ValidateNames = true;

            if (openFileDialog.ShowDialog() ?? false)
            {
                Read3dsFile(openFileDialog.FileName);
            }
        }
Beispiel #58
0
        private void btnChooseSourceFile_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new OpenFileDialog
            {
                DefaultExt       = ".txt",
                InitialDirectory = @"C:\"
            };

            var result = dlg.ShowDialog();

            if (result.HasValue && result.Value)
            {
                txtSourceFile.Text = dlg.FileName;
                var extension = System.IO.Path.GetExtension(txtSourceFile.Text); // pobieram rozszerzenie, że ścieżki pliku

                if (extension != ".serpent")                                     // aktualizuję pole rozszerzenia pliku
                {
                    var key = serpent.RandomizeKey();                            // wywołuję metodę losującą klucze, jeżli użytkownik dodał plik.
                    UpdateGuiWithRandomizedKeys(key);
                }
            }
        }
Beispiel #59
0
        private void LoadImage()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() == false)
            {
                return;
            }

            BitmapImage     bitmapImage              = new BitmapImage(new Uri(dlg.FileName));
            WriteableBitmap writeableBitmap          = new WriteableBitmap(bitmapImage);
            WriteableBitmap originalWriteableBitamap = new WriteableBitmap(bitmapImage);

            if (writeableBitmap.Format != PixelFormats.Bgra32)
            {
                writeableBitmap          = new WriteableBitmap(new FormatConvertedBitmap(writeableBitmap, PixelFormats.Bgra32, null, 0));
                originalWriteableBitamap = new WriteableBitmap(new FormatConvertedBitmap(writeableBitmap, PixelFormats.Bgra32, null, 0));
            }

            Images.Add(new ImageAbstraction(writeableBitmap, bitmapImage.UriSource.Segments.Last()));
            OriginalImages.Add(new ImageAbstraction(originalWriteableBitamap, bitmapImage.UriSource.Segments.Last()));
        }
Beispiel #60
0
        public static string BrowseForImage()
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            dialog.Filter =
                "JPEG File(*.jpg)|*.jpg|" +
                "PNG File(*.png)|*.png|" +
                "All Files (*.)|*.";

            dialog.CheckPathExists = true;
            dialog.CheckFileExists = true;
            dialog.Multiselect     = false;

            if (dialog.ShowDialog() == true)
            {
                return(dialog.FileName);
            }
            else
            {
                return("");
            }
        }