示例#1
0
文件: Import.cs 项目: RH-Code/GAPP
 public override bool Action(string action)
 {
     bool result = base.Action(action);
     if (result)
     {
         if (action == ACTION_IMPORT)
         {
             using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
             {
                 dlg.FileName = "";
                 dlg.Filter = "*.gcc|*.gcc|*.*|*.*";
                 if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     _errormessage = "";
                     _filename = dlg.FileName;
                     _importMissing = System.Windows.Forms.MessageBox.Show(string.Concat(Utils.LanguageSupport.Instance.GetTranslation(STR_IMPORTMISSING),"?"), Utils.LanguageSupport.Instance.GetTranslation(ACTION_IMPORT), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes;
                     PerformImport();
                     if (!string.IsNullOrEmpty(_errormessage))
                     {
                         System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                     }
                 }
             }
         }
     }
     return result;
 }
        private void AddProjectClick(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Filter = "C# Project files (*.csproj)|*.csproj|VS Project files (*.vcproj)|*.vcproj|Android Project (*.project)|*.project";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                var newProject = ProjectManager.AddSyncedProject(openFileDialog.FileName);

                // If newProject is null, then no project was added
                if (newProject != null)
                {
                    ViewModel.Refresh();
                }
                else
                {
                    GlueGui.ShowMessageBox("The selected project is already a synced project.");
                }

                GluxCommands.Self.SaveGlux();

                ProjectManager.SaveProjects();

            }
        }
示例#3
0
        /// <summary>
        /// ABRINDO A NOR
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbAbrirNor_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();

            openFile.Filter = "BIN Files (.bin)|*.bin|All Files (*.*)|*.*";
            openFile.FilterIndex = 1;
            openFile.Title = ("Abrir arquivo dump.bin");
            openFile.FileName = ("dump.bin");

            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                tbNor.Text = openFile.FileName;

                try
                {
                    BinaryReader read = new BinaryReader(new FileStream(openFile.FileName, FileMode.Open));

                    //Posição da Leitura
                    read.BaseStream.Position = 0x840;

                    //Lendo os offset
                    //metldr = BitConverter.ToString(read.ReadBytes(59680)).Replace("-", null); //reader.ReadBytes(12)
                    metldr = read.ReadBytes(59680);
                    ByteArrayToFile("data\\clone\\dump", metldr);


                }
                catch
                {
                    MessageBox.Show("Sorry the application seems to have encountered a problem", "Error");
                }
            }
        }
示例#4
0
        private void loadJobsButton_Click(object sender, RoutedEventArgs e)
        {
            using (var dialog = new System.Windows.Forms.OpenFileDialog())
            {
                dialog.Filter = "|*.xml";
                dialog.InitialDirectory = DataController.AppDataFolderPath;
                dialog.Multiselect = false;

                dialog.FileOk += (dialogSender, dialogEventArgs) =>
                    {
                        try
                        {
                            this.mainWindowViewModel.LoadJobSettings(dialog.FileName);
                        }
                        catch (CorruptSaveFileException)
                        {
                            MessageBox.Show
                            (
                                Properties.Resources.LoadSettingsErrorMessage,
                                Properties.Resources.ErrorString,
                                MessageBoxButton.OK,
                                MessageBoxImage.Error
                            );
                        }

                        catch (ITunesNotOpenedException)
                        {
                            ShowITunesErrorMessageBox();
                        }
                    };

                dialog.ShowDialog();
            }
        }
        public UIElement CreateContent(string fileName)
        {
            Grid grid_main = new Grid();
            grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) });
            grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            m_textBox_fileName = new TextBox();
            m_textBox_fileName.TextChanged += (sender, args) => { FileName = m_textBox_fileName.Text; };
            m_textBox_fileName.Text = fileName;
            grid_main.SetGridRowColumn(m_textBox_fileName, 0, 0);

            Button button_openFile = new Button() { Content = "Select file ..." };
            button_openFile.Click += (x, y) =>
                {
                    System.Windows.Forms.OpenFileDialog openFileDialog =
                        new System.Windows.Forms.OpenFileDialog()
                        {
                            CheckFileExists = false,
                            CheckPathExists = true
                        };
                    if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        m_textBox_fileName.Text = openFileDialog.FileName;
                };
            grid_main.SetGridRowColumn(button_openFile, 0, 1);

            return grid_main;
        }
        private void Browse_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Multiselect = true;

            ofd.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"; //Should change the limit of data type

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string[] filePath = ofd.FileNames;
                string[] safeFilePath = ofd.SafeFileNames;

                for (int i = 0; i < safeFilePath.Length; i++)
                {
                    BitmapImage myBitmapImage = new BitmapImage();
                    myBitmapImage.BeginInit();
                    myBitmapImage.UriSource = new Uri(@filePath[i]);
                    myBitmapImage.EndInit();

                    //set image source
                    image1.Source = myBitmapImage;
                    title_tag.Text = safeFilePath[i];
                }

            }
        }
 /// <summary> 
 /// Required method for Designer support - do not modify 
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.WebBrowserExcel=new System.Windows.Forms.WebBrowser();
     this.OpenExcelFileDialog=new System.Windows.Forms.OpenFileDialog();
     this.SuspendLayout();
     //
     // WebBrowserExcel
     //
     this.WebBrowserExcel.Dock=System.Windows.Forms.DockStyle.Fill;
     this.WebBrowserExcel.Location=new System.Drawing.Point(0,0);
     this.WebBrowserExcel.MinimumSize=new System.Drawing.Size(20,20);
     this.WebBrowserExcel.Name="WebBrowserExcel";
     this.WebBrowserExcel.Size=new System.Drawing.Size(420,400);
     this.WebBrowserExcel.TabIndex=0;
     this.WebBrowserExcel.Navigated+=new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.OnWebBrowserExcelNavigated);
     //
     // OpenExcelFileDialog
     //
     this.OpenExcelFileDialog.FileName="\"* Excel files | *.xls\"";
     //
     // ExcelWrapper
     //
     this.AutoScaleDimensions=new System.Drawing.SizeF(6F,13F);
     this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
     this.Controls.Add(this.WebBrowserExcel);
     this.Name="ExcelWrapper";
     this.Size=new System.Drawing.Size(420,400);
     this.ResumeLayout(false);
 }
        private async void bLearn_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.CheckFileExists = true;
            dialog.CheckPathExists = true;
            dialog.Multiselect = true;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dialog.FileNames.Length >= 2)
                {
                    string mimeType = getMimeType();
                    var infoOne = new FileInfo(dialog.FileNames[0]);
                    var infoTwo = new FileInfo(dialog.FileNames[1]);
                    var fileType = MimeDetective.LearnMimeType(infoOne, infoTwo, mimeType);
                    if (fileType != null)
                    {
                        //Detective.types.Add(fileType);
                        await animateLearnSuccess();
                    }
                    else
                        await animateLearnFailure();
                }
            }
            else
                await animateLearnFailure();
        }
示例#9
0
 private void select_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
     dialog.Title = "选择图片";
     dialog.Filter = "图片文件(*.jpg;*.png)|*.jpg;*.png";
     dialog.Multiselect = false;
     if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             BitmapImage bitmap = new BitmapImage();
             bitmap.BeginInit();
             bitmap.StreamSource = System.IO.File.OpenRead(dialog.FileName);
             bitmap.EndInit();
             byte[] data = new byte[bitmap.StreamSource.Length];
             bitmap.StreamSource.Position = 0;
             bitmap.StreamSource.Read(data, 0, (int)bitmap.StreamSource.Length);
             Value = data;
         }
         catch
         {
             MessageBox.Show("选择的图片格式错误。", "打开失败", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
示例#10
0
文件: Game1.cs 项目: Daminvar/Euphor
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            var dialog = new System.Windows.Forms.OpenFileDialog();

            dialog.Filter = "Map file|*.js";

            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                Environment.Exit(0);
            }

            map = new Map(this);
            map.setMapFolder(dialog.FileName.Replace(dialog.SafeFileName, ""));
            map.LoadMap(dialog.SafeFileName);

            //shows the windows.forms layout design
            new Layout(map).Show();

            //allows the mouse to show over the game
            this.IsMouseVisible = true;
            base.Initialize();
        }
示例#11
0
        public void bt_browse_Click(object sender, EventArgs e)
        {
            if ((tabControl_modType.SelectedItem as TabItem).Tag.ToString() == "zip")
            {
                System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
                dialog.Filter = "Zipped mod|*.zip";
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    tb_path.Text = dialog.FileName;
                }
            }
            else
            {
                FolderSelectDialog fsd = new FolderSelectDialog();
                fsd.ShowDialog();
                if (fsd.ShowDialog())
                {
                    tb_path.Text = fsd.FileName;
                }
            }
            /*
            string path = null;

            if ((((tabControl.SelectedItem as TabItem).Tag) as string) == "zip")
            {
                System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
                dialog.Filter = "Zipped mod|*.zip";
                if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
                else
                    path = dialog.FileName;
            }
            */
        }
示例#12
0
        public LoginDoor()
        {
            InitializeComponent();
            var ass = System.Reflection.Assembly.GetExecutingAssembly().GetName();
            Title = (ass.Name + " v" + ass.Version) + " 登陆界面";
            DataContext = this;

            //portTextBox.Text = TextBox_TextChanged_1"0";
            //new Window1().Show();
            IsHallMode = true;
            ResetOptions();
            IsRoomGained = false;

            voiceEntry = new Voice.VoiceEntry();
            voiceEntry.Play("voiceFmxy");

            md_openDialog = new System.Windows.Forms.OpenFileDialog()
            {
                Multiselect = false, RestoreDirectory = true,
                Filter = "PSG|*.psg"
            };

            SetSelTrigger();
            SetLvTrigger();
            //SetTeamTrigger();
            LoadFromConfig();
        }
示例#13
0
		void menuitem_Click(object sender, EventArgs e)
		{

			System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
			of.DefaultExt = ".xml";
			of.Filter = "XMLファイル(*.xml)|*.xml";
			if (of.ShowDialog((System.Windows.Forms.IWin32Window)_host.Win32WindowOwner) == System.Windows.Forms.DialogResult.OK) {
				try {
					System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
					xdoc.Load(of.FileName);

					// 擬似的に放送に接続した状態にする
					_host.StartMockLive("lv0", System.IO.Path.GetFileNameWithoutExtension(of.FileName), DateTime.Now);
					
					// ファイル内のコメントをホストに登録する
					foreach (System.Xml.XmlNode node in xdoc.SelectNodes("packet/chat")) {
						Hal.OpenCommentViewer.Control.OcvChat chat = new Hal.OpenCommentViewer.Control.OcvChat(node);
						_host.InsertPluginChat(chat);
					}
					_host.ShowStatusMessage("インポートに成功しました。");

				}catch(Exception ex){
					NicoApiSharp.Logger.Default.LogException(ex);
					_host.ShowStatusMessage("インポートに失敗しました。");

				}
			}
			
		}
        public void LoadBenchmark()
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.ShowDialog();
            string pathToLoad = dialog.FileName;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Benchmark));
                FileStream filestream = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read, FileShare.Read);

                Benchmark benchmark = (Benchmark)serializer.Deserialize(filestream);
                filestream.Close();

                // before setting benchmark, clear the screen
                // clear screen
                global.Verschnittoptimierung.display.Invalidate();

                global.benchmark = benchmark;

                // also create a basic solution
                SolutionManagement solutionManagement = new SolutionManagement();
                solutionManagement.CreateBasicSolution(global, global.benchmark);

                // show benchmark
                Show show = new Show(global);
                show.ShowBenchmark(global.benchmark);

                System.Windows.Forms.MessageBox.Show("Benchmark was loaded successfully.");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Benchmark could not be loaded. Please make sure to select the correct file path.");
            }
        }
示例#15
0
        public void AddFilm()
        {
            var ofd = new System.Windows.Forms.OpenFileDialog
                          {

                          };
            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            var fileInfo = new FileInfo(ofd.FileName);
            var closeableTabItem = new CloseableTabItem
                                       {
                                           Header = fileInfo.Name,
                                           HorizontalAlignment = HorizontalAlignment.Stretch,
                                           VerticalAlignment = VerticalAlignment.Stretch,
                                           Content = new FilmEditor(ofd.FileName)
                                       };

            if ((string) closeableTabItem.Header == "swag") return;

            foreach (var tabb in homeTabControl.Items.Cast<TabItem>().Where(tabb => tabb.Header == closeableTabItem.Header))
            {
                homeTabControl.SelectedItem = tabb;
                return;
            }
            homeTabControl.Items.Add(closeableTabItem);
            homeTabControl.SelectedItem = closeableTabItem;
        }
示例#16
0
        private void OnClickFindBtn2(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox2.Text = ofd.SafeFileName;

                try
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(ofd.OpenFile());
                    string content = sr.ReadToEnd();
                    sr.Close();

                    selectTextBeforeValue.Text = content;
                    content = System.Text.RegularExpressions.Regex.Replace(content, "a", "QQQ");

                    System.IO.StreamWriter writer = new System.IO.StreamWriter(ofd.FileName);
                    writer.Write(content);
                    writer.Close();

                    sr = new System.IO.StreamReader(ofd.OpenFile());
                    content = sr.ReadToEnd();
                    sr.Close();

                    selectTextAfterValue.Text = content;
                }
                catch(Exception ex)
                {
                    Console.WriteLine("=-=-=-=Exception : " + ex);
                }
            }
        }
示例#17
0
        private void btnSelectHex_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openHexFileDialog = new System.Windows.Forms.OpenFileDialog();
            openHexFileDialog.Filter = "Hex Files (.hex)|*.hex";
            openHexFileDialog.FilterIndex = 1;

            openHexFileDialog.Multiselect = false;

            openHexFileDialog.ShowDialog();

            if (openHexFileDialog.FileName != "")
            {
                HexFileName = openHexFileDialog.FileName;
                if (ConnectedToBootloader == true)
                {
                    string s = "Upload: " + System.IO.Path.GetFileNameWithoutExtension(HexFileName);
                    Console.WriteLine(s);
                }
                else
                {
                    Console.WriteLine("You must select to connect to the bootloader");
                }

                btnUploadHex.IsEnabled = false;
                FileSelected = true;
            }
        }
示例#18
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!AddNetModuleToAssemblyCommand.CanExecute(nodes))
                return;

            var dialog = new System.Windows.Forms.OpenFileDialog() {
                Filter = ".NET NetModules (*.netmodule)|*.netmodule|All files (*.*)|*.*",
                RestoreDirectory = true,
            };
            if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                return;
            if (string.IsNullOrEmpty(dialog.FileName))
                return;

            var asm = new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, dialog.FileName);
            if (asm.ModuleDefinition == null || asm.AssemblyDefinition != null) {
                MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.FileName), System.Windows.MessageBoxButton.OK);
                asm.TheLoadedFile.Dispose();
                return;
            }

            var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm);
            UndoCommandManager.Instance.Add(cmd);
            MainWindow.Instance.JumpToReference(cmd.modNode);
        }
示例#19
0
 public override bool PrepareInsertFromDatabase()
 {
     bool result = false;
     using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
     {
         if (string.Compare(PluginSettings.Instance.ActiveDataFile, dlg.FileName, true) != 0)
         {
             if (string.IsNullOrEmpty(_lastInsertFromFolder))
             {
                 _lastInsertFromFolder = System.IO.Path.GetDirectoryName(PluginSettings.Instance.ActiveDataFile);
             }
             dlg.InitialDirectory = _lastInsertFromFolder;
             dlg.Filter = "*.gpp|*.gpp";
             dlg.FileName = "";
             if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 if (string.Compare(PluginSettings.Instance.ActiveDataFile, dlg.FileName, true) != 0)
                 {
                     _selectedInsertFromFilename = dlg.FileName;
                     result = true;
                 }
             }
         }
     }
     return result;
 }
        public UIElement CreateContent(string fileName, IEnumerable<Filter> filters)
        {
            Grid grid_main = new Grid();
            grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) });
            grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            m_textBox_fileName = new TextBox();
            m_textBox_fileName.TextChanged += (sender, args) => { FileName = m_textBox_fileName.Text; };
            m_textBox_fileName.Text = fileName;
            grid_main.SetRowColumn(m_textBox_fileName, 0, 0);

            Button button_openFile = new Button() { Content = "Open file ..." };
            button_openFile.Click += (x, y) =>
            {
                System.Windows.Forms.OpenFileDialog openFileDialog =
                    new System.Windows.Forms.OpenFileDialog()
                    {
                        Filter = (filters != null) ? filters.Select(f => f.ToString()).Aggregate((a,b) => string.Format("{0}|{1}", a, b)) : string.Empty,
                        CheckFileExists = true,
                        CheckPathExists = true
                    };
                if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    m_textBox_fileName.Text = openFileDialog.FileName;
            };
            grid_main.SetRowColumn(button_openFile, 0, 1);

            return grid_main;
        }
示例#21
0
        private async void UploadNewAvatar(object sender, MouseButtonEventArgs e)
        {
            var dialog = new System.Windows.Forms.OpenFileDialog
                             {
                                 DefaultExt = ".png",
                                 InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(),
                                 Title = "Select a new avatar",
                                 Filter = "Image files | *.png; *.jpg; *.bmp"
                             };
            dialog.ShowDialog();

            var mimeType = "image/";

            if (String.IsNullOrEmpty(dialog.FileName)) return;
            if (dialog.SafeFileName == null) return;

            if (dialog.SafeFileName.EndsWith(".png")) mimeType += "png";
            else if (dialog.SafeFileName.ToLower().EndsWith(".jpg")) mimeType += "jpg";
            else if (dialog.SafeFileName.EndsWith(".bmp")) mimeType += "bmp";
            else
            {
                dialog.Dispose();
                App.Connection.NotificationController.Notification.Notify("That's not a supported file type! Please try again.");
                return;
            }

            await App.Connection.SessionController.CurrentSession.UploadAvatar(
                new FileStream(dialog.FileName, FileMode.Open), mimeType);
            dialog.Dispose();
            
        }
 public override FrameworkElement GetProperyField()
 {
     var pan = new DockPanel();
     t = (new TextBox());
     try
     {
         t.Text = GetVaueAsType<ImageSource>().ToString();
     }
     catch { }//Null value
     t.TextChanged += delegate(object sender, TextChangedEventArgs e) { SetString(t.Text); };
     var btn = new Button();
     btn.Content = "...";
     btn.Click += delegate
     {
         var fpd = new System.Windows.Forms.OpenFileDialog();
         fpd.Filter = "Images|*.jpg;*.jpeg;*.png;*.gif;*.tif;*.bmp";
         if (fpd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             t.Text = fpd.FileName;
         }
     };
     DockPanel.SetDock(btn, Dock.Right);
     pan.Children.Add(btn);
     pan.Children.Add(t);
     return pan;
 }
 private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (track != null)
         {
             var dialog = new System.Windows.Forms.OpenFileDialog();
             dialog.Filter = "Image Files (*.jpg,*.jpeg,*.png,*.gif)|*.jpg;*.jpeg;*.png;*.gif|All Files (*.*)|*.*";
             if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 if (track.Path.EndsWith(".mp3"))
                 {
                     tagController.AddPicture(track, dialog.FileName);
                 }
                 else
                 {
                     track.ImagePath = dialog.FileName;
                     trackController.Save(track);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("MediaPropertyView.ChangePictureButton_Click", ex);
         MessageBox.Show("There was an error trying to add a picture to this track.\n\n" + ex.Message, "Could Not Add Picture To Track");
     }
 }
示例#24
0
 private void btn_filedb_Click(object sender, RoutedEventArgs e)
 {
     string path = System.Environment.CurrentDirectory + "\\filepath.txt";
     string filepath_db = System.Environment.CurrentDirectory + "\\bd4.mdf";
     FileInfo fi1;
     if (System.IO.File.Exists(path))//проверка на существование файла настроек
     {
         fi1 = new FileInfo(path);
         using (StreamReader sr = fi1.OpenText())
         {
             string s = sr.ReadLine();
             if (System.IO.File.Exists(s))//проверка на путь в нем
             {
                 filepath_db = s;
             }
         }
     }
     if (!System.IO.File.Exists(filepath_db))
     {
         filepath_db = @"C:\";
     }
     System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
     dialog.InitialDirectory = filepath_db;
     dialog.Filter = "DB File |*.mdf";
     if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         filepath_db = dialog.FileName;
     }
     else filepath_db = System.Environment.CurrentDirectory + "\\bd4.mdf";
     fi1 = new FileInfo(path);
     using (StreamWriter sr = fi1.CreateText())
     {
         sr.WriteLine(filepath_db);
     }
 }
示例#25
0
 public void loadExisting()
 {
     var open = new System.Windows.Forms.OpenFileDialog();
     open.SupportMultiDottedExtensions = true;
     open.DefaultExt = ".9.png";
     open.Filter = "Ninepatch files|*.9.png|All files|*";
     open.ShowDialog();
 }
示例#26
0
 public void createNew()
 {
     var open = new System.Windows.Forms.OpenFileDialog();
     open.SupportMultiDottedExtensions = true;
     open.DefaultExt = ".png";
     open.Filter = "PNG files|*.png|All files|*";
     open.ShowDialog();
 }
 private void btnOldBrowse_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog fileBrowseDlg = new System.Windows.Forms.OpenFileDialog();
     if (fileBrowseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         txtOldLocation.Text = fileBrowseDlg.FileName;
     }
 }
示例#28
0
 private void ChooseFile(TextBox tb)
 {
     System.Windows.Forms.OpenFileDialog choose = new System.Windows.Forms.OpenFileDialog();
     if (choose.ShowDialog() == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(choose.FileName))
     {
         tb.Text = choose.FileName;
     }
 }
 private void MenuFileOpen_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog oOpenFileDialog = new System.Windows.Forms.OpenFileDialog();
     if (oOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this.filec.FileName = oOpenFileDialog.FileName;
     }
 }
        private void xBrowseImageLoadButton_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog op = new System.Windows.Forms.OpenFileDialog();
            op.Title  = "Select a picture";
            op.Filter = "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg";
            if (op.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var fileLength = new FileInfo(op.FileName).Length;
                if (fileLength <= 30000)
                {
                    if ((op.FileName != null) && (op.FileName != string.Empty))
                    {
                        using (var ms = new MemoryStream())
                        {
                            BitmapImage      bi    = new BitmapImage(new Uri(op.FileName));
                            Tuple <int, int> sizes = Ginger.General.RecalculatingSizeWithKeptRatio(bi, Ginger.Reports.GingerExecutionReport.GingerExecutionReport.logoWidth, Ginger.Reports.GingerExecutionReport.GingerExecutionReport.logoHight);

                            BitmapImage bi_resized = new BitmapImage();
                            bi_resized.BeginInit();
                            bi_resized.UriSource         = new Uri(op.FileName);
                            bi_resized.DecodePixelHeight = sizes.Item2;
                            bi_resized.DecodePixelWidth  = sizes.Item1;
                            bi_resized.EndInit();
                            mWizard.ScreenShot          = Ginger.General.BitmapImage2Bitmap(bi_resized);
                            mWizard.POM.ScreenShotImage = Ginger.General.BitmapToBase64(mWizard.ScreenShot);
                            mScreenshotPage             = new ScreenShotViewPage(mWizard.POM.Name, mWizard.ScreenShot);
                            xScreenShotFrame.Content    = mScreenshotPage;
                        }
                    }
                }
                else
                {
                    Reporter.ToUser(eUserMsgKeys.ImageSize);
                }
            }
        }
示例#31
0
 private void btImportCad_Click(object sender, RoutedEventArgs e)
 {
     if (mModel.Gerber is GerberFile)
     {
         System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
         if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             int r = mModel.GetNewCad(ofd.FileName);
             if (r == 0)
             {
                 UpdateListImportedFile();
                 ShowAllLayerImb(ActionMode.Draw_Cad);
             }
             else
             {
                 MessageBox.Show("Input string was not in a correct format!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     else
     {
         MessageBox.Show("Please select gerber file before select cad files!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
示例#32
0
        private void SelectFile()
        {
            var fileDialog = new System.Windows.Forms.OpenFileDialog();

            fileDialog.Multiselect = false;
            fileDialog.Filter      = "RPi, Qualcom|*.zip;";
            if (Location != "Path not set.")
            {
                fileDialog.FileName = Location;
            }
            var result = fileDialog.ShowDialog();

            switch (result)
            {
            case System.Windows.Forms.DialogResult.OK:
                var file = fileDialog.FileName;
                Location = file;
                break;

            case System.Windows.Forms.DialogResult.Cancel:
            default:
                break;
            }
        }
示例#33
0
 private void CertificatePathBrowseButton_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
     dlg.Filter      = "All Files (*.*)|*.*";
     dlg.FilterIndex = 1;
     System.Windows.Forms.DialogResult result = dlg.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK)
     {
         if (DoNotCertificateImportFile.IsChecked == true)
         {
             string NewPath = Path.Combine(WorkSpace.Instance.SolutionRepository.SolutionFolder, "Documents", Path.GetFileName(dlg.FileName));
             if (!Directory.Exists(Path.GetDirectoryName(NewPath)))
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(NewPath));
             }
             File.Copy(dlg.FileName, NewPath, true);
             CertificatePath.Text = NewPath.Replace(WorkSpace.Instance.SolutionRepository.SolutionFolder, "~\\");
         }
         else
         {
             CertificatePath.Text = dlg.FileName;
         }
     }
 }
示例#34
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!AddNetModuleToAssemblyCommand.CanExecute(nodes))
            {
                return;
            }

            var dialog = new System.Windows.Forms.OpenFileDialog()
            {
                Filter           = ".NET NetModules (*.netmodule)|*.netmodule|All files (*.*)|*.*",
                RestoreDirectory = true,
            };

            if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            if (string.IsNullOrEmpty(dialog.FileName))
            {
                return;
            }

            var asm = new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, dialog.FileName);

            if (asm.ModuleDefinition == null || asm.AssemblyDefinition != null)
            {
                MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.FileName), System.Windows.MessageBoxButton.OK);
                if (asm.ModuleDefinition != null)
                {
                    asm.ModuleDefinition.Dispose();
                }
                return;
            }

            UndoCommandManager.Instance.Add(new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm));
        }
示例#35
0
        public static string BrowseForFile(string fileFilter, string initialFileOrFolder)
        {
            System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
            // Set file filter
            if (fileDialog.Filter != null)
            {
                fileDialog.Filter = fileFilter;
            }
            // Set initial directory
            string initialDirectory = GetDirectoryFromPath(initialFileOrFolder);

            if (initialDirectory != null)
            {
                fileDialog.InitialDirectory = initialDirectory;
            }
            // Open dialog and prompt for file
            string chosenFile = null;

            if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                chosenFile = fileDialog.FileName;
            }
            return(chosenFile);
        }
示例#36
0
        private void SaveLayout()
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            if (dialog == null)
            {
                return;
            }

            dialog.Filter          = "Layout Files (*.xml)|*.xml";
            dialog.CheckFileExists = false;
            if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            try
            {
                _layoutManager.SaveLayoutToFile(dialog.FileName);
            }
            catch (Exception exception)
            {
                System.Windows.Forms.MessageBox.Show("Unable to save layout: " + exception.Message);
            }
        }
 private void Button_Path_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
     if (File.Exists(TextBox_Path.Text))
     {
         fileDialog.InitialDirectory = new FileInfo(TextBox_Path.Text).DirectoryName;
     }
     else
     {
         fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
     }
     fileDialog.Filter           = "文本文件|*.txt";
     fileDialog.Multiselect      = false;
     fileDialog.RestoreDirectory = true;
     fileDialog.Title            = "选择Game.dll汇编代码文件";
     if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         TextBox_Path.Text = fileDialog.FileName;
     }
     else
     {
         TextBox_Path.Text = "";
     }
 }
        private void Open_Dialogue_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            System.Windows.Forms.OpenFileDialog ofld = new System.Windows.Forms.OpenFileDialog();
            ofld.Filter      = "文档|*.doc;*.docx;*.xps;*.pdf";
            ofld.Multiselect = false;
            if (ofld.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                String filename = ofld.FileName;
                if (filename != "" || filename != null)
                {
                    String      url         = uploadWord(btn, filename);
                    StorageFile storageWord = storageFileBll.insert(filename, url, folderId);
                    //this.currDControl.url = url;
                    //this.currDControl.imgs = jpgPath;

                    //插入一个视频到列表
                    Canvas newImage = initOneFile(storageWord);
                    imageListWrap.Children.Insert(0, newImage);
                    selectButton(newImage);
                }
            }
        }
示例#39
0
 private void ImportSSCOMButton_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
     OpenFileDialog.Filter = TryFindResource("QuickSendSSCOMFile") as string ?? "?!";
     if (OpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this.Dispatcher.Invoke(new Action(delegate
         {
             canSaveSendList = false;
             foreach (var i in Tools.Global.ImportFromSSCOM(OpenFileDialog.FileName))
             {
                 toSendListItems.Add(new ToSendData()
                 {
                     id     = toSendListItems.Count + 1,
                     text   = i.text,
                     hex    = i.hex,
                     commit = i.commit
                 });
             }
             canSaveSendList = true;
             SaveSendList(0, EventArgs.Empty);//保存并刷新数据列表
         }));
     }
 }
        private void AddXmlObjects(object sender, RoutedEventArgs e)
        {
            int index = (sender as MyButton).Index;

            if (index == 0)
            {
                System.Windows.Forms.OpenFileDialog opf = new System.Windows.Forms.OpenFileDialog();
                opf.Filter      = "xml-files (*.xml)| *.xml";
                opf.Multiselect = true;

                if (opf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    AddXmlFiles(opf.FileNames);
                }
            }
            if (index == 1)
            {
                System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    AddXmlFiles(System.IO.Directory.GetFiles(fbd.SelectedPath));
                }
            }
        }
示例#41
0
        //////////////////////////////////////////////////////////////////////////////////////////
        private void Btn_SelectIniXML_Click(object sender, RoutedEventArgs e)
        {
            using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog())
            {
                //if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
                //tb_IniXmlPath.Text = IniRecipe.XmlName;

                ofd.Multiselect = false;
                if ((bool)ckb_ChangeProductDirectory.IsChecked && Directory.Exists(tb_ProductDirectory.Text))
                {
                    ofd.InitialDirectory = tb_ProductDirectory.Text;
                }
                else
                {
                    ofd.InitialDirectory = FilePath.ProductDirectory;
                }
                if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                tb_IniXmlPath.Text = ofd.FileName;
            }
        }
示例#42
0
        /// <summary>
        /// Ask user for a filename to open on Windows.
        /// </summary>
        /// <param name="prompt">String to use as dialog heading.</param>
        /// <param name="fileSpec">The file specification used to filter the files.</param>
        /// <param name="Action">Action to perform (currently either "Open" or "Save").</param>
        /// <param name="InitialPath">Optional Initial starting filename or directory.</param>
        private string[] WindowsFileDialog(bool selectMultiple)
        {
            System.Windows.Forms.FileDialog dialog = null;
            if (Action == FileActionType.Open)
            {
                dialog = new System.Windows.Forms.OpenFileDialog();
                (dialog as System.Windows.Forms.OpenFileDialog).Multiselect = selectMultiple;
            }
            else if (Action == FileActionType.Save)
            {
                dialog = new System.Windows.Forms.SaveFileDialog();
            }
            else if (Action == FileActionType.SelectFolder)
            {
                return(WindowsDirectoryDialog(selectMultiple));
            }

            dialog.Title = Prompt;
            if (!String.IsNullOrEmpty(FileType))
            {
                dialog.Filter = FileType + "|All files (*.*)|*.*";
            }

            // This almost works, but Windows is buggy.
            // If the file name is long, it doesn't display in a sensible way. ¯\_(ツ)_/¯
            dialog.InitialDirectory = InitialDirectory;
            dialog.FileName         = null;

            string[] fileNames = null;
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fileNames = dialog.FileNames;
            }
            dialog = null;
            return(fileNames);
        }
示例#43
0
        private void menu_load_table(object sender, RoutedEventArgs e)
        {
            sp_table_main.Children.RemoveAt(0);

            var fileDialog = new System.Windows.Forms.OpenFileDialog();
            var result     = fileDialog.ShowDialog();

            switch (result)
            {
            case System.Windows.Forms.DialogResult.OK:
            {
                PathToSavedData = fileDialog.FileName;
                TableSerializableData tsd = BinarySerializator.Read <TableSerializableData>(PathToSavedData);
                MainTable = null;
                MainTable = tsd.Deserialize();
                break;
            }

            case System.Windows.Forms.DialogResult.Cancel:
            default:
                break;
            }
            sp_table_main.Children.Add(MainTable);
        }
示例#44
0
        /// <summary>
        /// Permet de faire afficher une boîte de dialogue pour sélectionner un fichier image.
        /// Notez bien l'utilisation du mot "out" devant le type du paramètre.
        /// </summary>
        /// <param name="cheminFichier">Chemin complet du fichier image sélectionné ou bien null si l'opération a été annulée.</param>
        /// <returns>true si un fichier image a été sélectionné; false, autrement.</returns>
        public static bool DemanderSelectionnerFichierImage(out String cheminFichier)
        {
            // Création de la boîte de dialogue permettant de sélectionner un fichier image.
            // Vous pouvez utiliser la directive "System.Windows.Forms;" ci-dessus au lieu de mettre le nom complet de la classe "OpenFileDialog".
            System.Windows.Forms.OpenFileDialog dialogueOuvrirFichier = new System.Windows.Forms.OpenFileDialog();
            // Filtre permettant de restreindre la sélection à des fichiers images.
            dialogueOuvrirFichier.Filter = "Images (*.png, *.jpg, *.gif, *.bmp)|*.png;*.jpg;*.gif;*.bmp";
            // Titre de la boîte de dialogue.
            dialogueOuvrirFichier.Title = "Sélectionnez un fichier image";

            // Ouverture de la boîte de dialogue pour la sélection d'un fichier et traitement en fonction de la réponse.
            if (dialogueOuvrirFichier.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Chemin complet du fichier image sélectionné.
                cheminFichier = dialogueOuvrirFichier.FileName;
                return(true);
            }
            else
            {
                // Il est obligatoire de mettre une valeur dans le paramètre en sortie "cheminFichier" même si non utilisé.
                cheminFichier = null;
                return(false);
            }
        }
示例#45
0
        private void OpenScene_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new System.Windows.Forms.OpenFileDialog()
            {
                Filter = "pliki *.sl|*.sl|wszystkie pliki|*.*"
            };

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ISceneParser sceneParser = null;
                if (System.IO.Path.GetExtension(ofd.FileName) == ".sl")
                {
                    sceneParser = new SphereScriptParser();
                }
                else
                {
                    sceneParser = new TextSceneParser();
                }

                _rayCaster.Root = sceneParser.ParseScene(ofd.FileName);
            }

            Render();
        }
示例#46
0
        private void btnAddApp_Click(object sender, RoutedEventArgs e)
        {
            string path;

            using (OpenFileDialog ofd = new OpenFileDialog()) {
                if (System.Windows.Forms.DialogResult.OK != ofd.ShowDialog())
                {
                    return;
                }
                path = ofd.FileName;
            }
            AppEntry sel   = tvwApps.SelectedItem as AppEntry;
            IList    list  = sel == null ? CurrentApps : sel.IsFolder ? sel.Children : sel.ParentList;
            int      idx   = sel == null ? 0 : list.IndexOf(sel) + 1;
            AppEntry entry = new AppEntry(System.IO.Path.GetFileName(path), path);

            list.Insert(idx, entry);
            if (sel != null && sel.IsFolder)
            {
                sel.IsExpanded = true;
            }
            tvwApps.Focus();
            entry.IsSelected = true;
        }
示例#47
0
        public static void ImportAcres(ref WorldAcre[] Acres, SaveGeneration Save_Generation)
        {
            using (var openDialog = new System.Windows.Forms.OpenFileDialog())
            {
                openDialog.Filter   = "ACSE Acre Save (*.aas)|*.aas";
                openDialog.FileName = "";

                if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        using (var Stream = new FileStream(openDialog.FileName, FileMode.Open))
                        {
                            using (var Reader = new BinaryReader(Stream))
                            {
                                if (System.Text.Encoding.ASCII.GetString(Reader.ReadBytes(3)).Equals("AAS") && Reader.ReadByte() == Acres.Length &&
                                    (SaveGeneration)Reader.ReadByte() == Save_Generation)
                                {
                                    Reader.BaseStream.Seek(8, SeekOrigin.Begin);
                                    for (int i = 0; i < Acres.Length; i++)
                                    {
                                        Acres[i].AcreID     = Reader.ReadUInt16();
                                        Acres[i].BaseAcreID = (ushort)(Acres[i].AcreID & 0xFFFC);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        System.Windows.Forms.MessageBox.Show("Acre importation failed!", "Acre Import Error", System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.Error);
                    }
                }
            }
        }
示例#48
0
        // Assembly required: System.Windows.Forms
        public void GetFilePath()
        {
            //get Filepath
            string filePath = "";
            var    ofd      = new System.Windows.Forms.OpenFileDialog()
            {
                //TODO Filter
                //Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
                //TODO Title
                // Title = "Please select the required File."
            };
            var dialogResult = ofd.ShowDialog();

            if (dialogResult != System.Windows.Forms.DialogResult.OK)
            {
                //Aborted.
                //TODO Do handling
                // MessageBox.Show("aborted!");
            }
            else
            {
                filePath = ofd.FileName;
            }
        }
示例#49
0
        /// <summary>
        /// 本地视频
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_play_click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)//注意,此处一定要手动引入System.Window.Forms空间,否则你如果使用默认的DialogResult会发现没有OK属性
            {
                _currentFile = openFileDialog.FileName;
                //Image做载体播放

                FileInfo fileInfo = new FileInfo(_currentFile);
                this.sourceProvider.MediaPlayer.SetMedia(fileInfo);
                this.sourceProvider.MediaPlayer.LengthChanged += new EventHandler <VlcMediaPlayerLengthChangedEventArgs>(Events_LengthChanged);
                this.sourceProvider.MediaPlayer.Play();

                PlayerTitle.Text = fileInfo.Name;

                //this.BackgroundVideo.SetBinding(System.Windows.Controls.Image.SourceProperty,
                //    new Binding(nameof(VlcVideoSourceProvider.VideoSource)) { Source = sourceProvider });


                //控件做载体播放

                // this.myVlcPlayer.SourceProvider.MediaPlayer.Play(fileInfo);
            }
        }
示例#50
0
 private void btn_open_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
         ofd.Filter = "所有文件 (*.*)|*.*";
         if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             tbx_path.Text = ofd.FileName;
             foreach (Thread item in threadlist)
             {
                 item.Abort();
             }
             Thread thread = new Thread(openfile);
             thread.IsBackground = true;
             threadlist.Add(thread);
             thread.Start(ofd.FileName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "CodeViewer");
     }
 }
示例#51
0
        /// <summary>
        /// Add a new topic from an existing file
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cmdAddExistingFile_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            FileNode thisNode    = this.FileNode;
            Topic    t           = base.UIControl.CurrentTopic;
            string   projectPath = Path.GetDirectoryName(contentLayoutFile.Project.Filename);

            using (WinFormsOpenFileDialog dlg = new WinFormsOpenFileDialog())
            {
                dlg.Title            = "Select the conceptual topic file(s)";
                dlg.Filter           = "Conceptual Topics (*.aml)|*.aml|All files (*.*)|*.*";
                dlg.DefaultExt       = "aml";
                dlg.InitialDirectory = (t != null && t.TopicFile != null) ?
                                       Path.GetDirectoryName(t.TopicFile.FullPath) : projectPath;
                dlg.Multiselect = true;

                // If selected, add the new file(s).  Filenames that are
                // already in the collection are ignored.
                if (dlg.ShowDialog() == WinFormsDialogResult.OK)
                {
                    foreach (string filename in dlg.FileNames)
                    {
                        this.AddTopicFile(filename, e.Parameter != null);

                        if (t != null)
                        {
                            t.IsSelected = true;
                        }
                    }

                    if (thisNode != null)
                    {
                        thisNode.ProjectMgr.RefreshProject();
                    }
                }
            }
        }
        private void selectPathBttn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            using (var filePicker = new System.Windows.Forms.OpenFileDialog())
            {
                Button source = (Button)sender;

                filePicker.Filter = "Executable|MonsterHunterWorld.exe";
                System.Windows.Forms.DialogResult result = filePicker.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    fullGamePath = filePicker.FileName;
                    if (filePicker.FileName.Length > 15)
                    {
                        int i = (fullGamePath.Length / 2) - 10;
                        source.Content   = "..." + fullGamePath.Substring(i);
                        source.Focusable = false;
                        return;
                    }
                    source.Content = fullGamePath;
                }
                source.Focusable = false;
            }
        }
示例#53
0
        private void btnFileOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Windows.Forms.OpenFileDialog saveXlsxDialog = new System.Windows.Forms.OpenFileDialog
                {
                    DefaultExt       = ".*",
                    AddExtension     = true,
                    RestoreDirectory = true
                };

                bool?result = Convert.ToBoolean(saveXlsxDialog.ShowDialog());

                if (result == true)
                {
                    FileInfo xlsxFile = new FileInfo(saveXlsxDialog.FileName);
                    this.tbFileName.Text = xlsxFile.Name;
                    fname = xlsxFile.FullName;
                }
            }
            catch
            {
            }
        }
示例#54
0
        /// <summary>
        /// Ask for the file names.
        /// </summary>
        protected string[] _askForFileNames(string title)
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.AddExtension     = true;
            dialog.CheckFileExists  = true;
            dialog.CheckPathExists  = true;
            dialog.DereferenceLinks = true;
            dialog.RestoreDirectory = false;
            dialog.Title            = System.String.Format("{0} -- {1}", CadKit.Helios.Application.Instance.Name, title);
            dialog.Multiselect      = true;

            // Set filter string.
            string filterIndexKey = "filter_index";

            this._setFilterString(filterIndexKey, dialog);

            // Get initial directory.
            string initialDirectoryKey = "initial_directory";

            dialog.InitialDirectory = CadKit.Persistence.Registry.Instance.getString(this.PersistentName, initialDirectoryKey, CadKit.Helios.Application.Instance.Directory);

            // Show dialog and get names.
            dialog.ShowDialog();
            string[] names = dialog.FileNames;

            // Save final directory and filter index.
            if (null != names && names.Length > 0)
            {
                System.IO.FileInfo info = new System.IO.FileInfo(names[0]);
                CadKit.Persistence.Registry.Instance.setString(this.PersistentName, initialDirectoryKey, info.DirectoryName);
                CadKit.Persistence.Registry.Instance.setInt(this.PersistentName, filterIndexKey, dialog.FilterIndex);
            }

            // Return names.
            return(names);
        }
示例#55
0
文件: Room.cs 项目: mrwappa/AI-AStar
 public Room(float x, float y) : base(x, y)
 {
     fileDialog        = new System.Windows.Forms.OpenFileDialog();
     fileDialog.Filter = "Data Files (*.png)|*.png";
     CreateInstances();
 }
示例#56
0
        private void BrowseButtonClicked(object sender, RoutedEventArgs e)
        {
            AddAPIModelWizard.IsParsingWasDone = false;
            if (APITypeComboBox.SelectedValue.ToString() == eAPIType.WSDL.ToString())
            {
                if (FileRadioButton.IsChecked == true)
                {
                    if (string.IsNullOrEmpty(xURLTextBox.Text))
                    {
                        System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();

                        dlg.Filter = "WSDL Files (*.wsdl)|*.wsdl" + "|XML Files (*.xml)|*.xml" + "|All Files (*.*)|*.*";

                        System.Windows.Forms.DialogResult result = dlg.ShowDialog();

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            xURLTextBox.Text = dlg.FileName;
                            LoadFileValidation();
                        }
                    }
                    else
                    {
                        LoadFileValidation();
                    }
                }
                else
                {
                    LoadFileValidation();
                }
            }
            else if (APITypeComboBox.SelectedValue.ToString() == eAPIType.Swagger.ToString())
            {
                AddAPIModelWizard.APIType = eAPIType.Swagger;
                if (FileRadioButton.IsChecked == true)
                {
                    System.Windows.Forms.OpenFileDialog dlg2 = new System.Windows.Forms.OpenFileDialog();

                    dlg2.Filter = "Json Files (*.json)|*.json" + "|YAML Files (*.yaml)|*.yaml;*.yml" + "|All Files (*.*)|*.*";

                    System.Windows.Forms.DialogResult result = dlg2.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        xURLTextBox.Text = dlg2.FileName;
                        AddAPIModelWizard.XTFList.Add(new TemplateFile()
                        {
                            FilePath = dlg2.FileName
                        });
                    }
                }
                else
                {
                    string tempfile    = System.IO.Path.GetTempFileName();
                    string filecontent = Amdocs.Ginger.Common.GeneralLib.HttpUtilities.Download(new System.Uri(xURLTextBox.Text));
                    System.IO.File.WriteAllText(tempfile, filecontent);
                    AddAPIModelWizard.XTFList.Add(new TemplateFile()
                    {
                        FilePath = tempfile
                    });
                }
            }

            else
            {
                BrowseForTemplateFiles();
            }
        }
        private void btn_addfile_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.Multiselect = true;//该值确定是否可以选择多个文件
            dialog.Title       = "Select File";
            dialog.Filter      = "TXT File(*.TXT)|*.TXT";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                btn_addfile.IsEnabled    = false;
                btn_delfile.IsEnabled    = false;
                btn_cleanfile.IsEnabled  = false;
                btn_start.IsEnabled      = false;
                btn_selectPATH.IsEnabled = false;
                cmb_list.IsEnabled       = false;
                datagrid_list.IsEnabled  = false;
                Thread t = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        int i          = 0, count = dialog.FileNames.Length;
                        string pathArr = StringUtil.changeArrayToString(list.Select(x => x.filepath).ToArray(), ",");

                        for (i = 0; i < count; i++)
                        {
                            App.TxtToExcelPage.Dispatcher.BeginInvoke((Action) delegate()
                            {
                                btn_start.Content = "Loading:" + (i + 1) + "/" + count;
                            });
                            Thread.Sleep(5);
                            if (pathArr.IndexOf(dialog.FileNames[i]) >= 0)
                            {
                                continue;
                            }
                            nFile item    = new nFile();
                            item.filepath = dialog.FileNames[i];
                            pathArr      += (dialog.FileNames[i] + ",");
                            item.filename = dialog.FileNames[i].Substring(dialog.FileNames[i].LastIndexOf('\\') + 1, dialog.FileNames[i].LastIndexOf(".") - dialog.FileNames[i].LastIndexOf('\\') - 1);
                            item.state    = "Unconverted";
                            App.TxtToExcelPage.Dispatcher.BeginInvoke((Action) delegate()
                            {
                                list.Add(item);
                            });
                        }
                        GC.Collect();
                        App.TxtToExcelPage.Dispatcher.BeginInvoke((Action) delegate()
                        {
                            btn_start.Content         = "Start TXT To Excel";
                            datagrid_list.ItemsSource = list;
                            btn_addfile.IsEnabled     = true;
                            btn_delfile.IsEnabled     = true;
                            btn_cleanfile.IsEnabled   = true;
                            btn_start.IsEnabled       = true;
                            btn_selectPATH.IsEnabled  = true;
                            cmb_list.IsEnabled        = true;
                            datagrid_list.IsEnabled   = true;
                        });
                    }
                    catch (Exception ex)
                    {
                        App.MainWindow.ShowModalMessageExternal("Exception", ex.ToString());
                    }
                }));
                t.IsBackground = true;
                t.Start();
                GC.Collect();
            }
        }
示例#58
0
 /// <summary>
 /// This method is required for Windows Forms designer support.
 /// Do not change the method contents inside the source code editor. The Forms designer might
 /// not be able to load this method if it was changed manually.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormDatabase));
     this.panel1               = new System.Windows.Forms.Panel();
     this.buttonSave           = new System.Windows.Forms.Button();
     this.buttonClose          = new System.Windows.Forms.Button();
     this.panel2               = new System.Windows.Forms.Panel();
     this.groupBox2            = new System.Windows.Forms.GroupBox();
     this.button5              = new System.Windows.Forms.Button();
     this.button3              = new System.Windows.Forms.Button();
     this.testConnectButton    = new System.Windows.Forms.Button();
     this.serverTextBox        = new System.Windows.Forms.TextBox();
     this.label3               = new System.Windows.Forms.Label();
     this.serverRadioButton    = new System.Windows.Forms.RadioButton();
     this.localRadioButton     = new System.Windows.Forms.RadioButton();
     this.groupBox1            = new System.Windows.Forms.GroupBox();
     this.button4              = new System.Windows.Forms.Button();
     this.button2              = new System.Windows.Forms.Button();
     this.button1              = new System.Windows.Forms.Button();
     this.localDatabaseTextBox = new System.Windows.Forms.TextBox();
     this.label1               = new System.Windows.Forms.Label();
     this.openFileDialog1      = new System.Windows.Forms.OpenFileDialog();
     this.panel1.SuspendLayout();
     this.panel2.SuspendLayout();
     this.groupBox2.SuspendLayout();
     this.groupBox1.SuspendLayout();
     this.SuspendLayout();
     //
     // panel1
     //
     this.panel1.Controls.Add(this.buttonSave);
     this.panel1.Controls.Add(this.buttonClose);
     this.panel1.Dock     = System.Windows.Forms.DockStyle.Bottom;
     this.panel1.Location = new System.Drawing.Point(0, 308);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(456, 45);
     this.panel1.TabIndex = 1;
     //
     // buttonSave
     //
     this.buttonSave.Anchor     = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonSave.Image      = ((System.Drawing.Image)(resources.GetObject("buttonSave.Image")));
     this.buttonSave.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.buttonSave.Location   = new System.Drawing.Point(268, 10);
     this.buttonSave.Name       = "buttonSave";
     this.buttonSave.Size       = new System.Drawing.Size(85, 23);
     this.buttonSave.TabIndex   = 1;
     this.buttonSave.Text       = "Сохранить";
     this.buttonSave.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
     this.buttonSave.UseVisualStyleBackColor = true;
     this.buttonSave.Click += new System.EventHandler(this.ButtonSaveClick);
     //
     // buttonClose
     //
     this.buttonClose.Anchor     = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonClose.Image      = ((System.Drawing.Image)(resources.GetObject("buttonClose.Image")));
     this.buttonClose.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.buttonClose.Location   = new System.Drawing.Point(359, 10);
     this.buttonClose.Name       = "buttonClose";
     this.buttonClose.Size       = new System.Drawing.Size(85, 23);
     this.buttonClose.TabIndex   = 0;
     this.buttonClose.Text       = "Отменить";
     this.buttonClose.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
     this.buttonClose.UseVisualStyleBackColor = true;
     this.buttonClose.Click += new System.EventHandler(this.ButtonCloseClick);
     //
     // panel2
     //
     this.panel2.Controls.Add(this.groupBox2);
     this.panel2.Controls.Add(this.serverRadioButton);
     this.panel2.Controls.Add(this.localRadioButton);
     this.panel2.Controls.Add(this.groupBox1);
     this.panel2.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.panel2.Location = new System.Drawing.Point(0, 0);
     this.panel2.Name     = "panel2";
     this.panel2.Size     = new System.Drawing.Size(456, 308);
     this.panel2.TabIndex = 2;
     //
     // groupBox2
     //
     this.groupBox2.Controls.Add(this.button5);
     this.groupBox2.Controls.Add(this.button3);
     this.groupBox2.Controls.Add(this.testConnectButton);
     this.groupBox2.Controls.Add(this.serverTextBox);
     this.groupBox2.Controls.Add(this.label3);
     this.groupBox2.Location = new System.Drawing.Point(12, 165);
     this.groupBox2.Name     = "groupBox2";
     this.groupBox2.Size     = new System.Drawing.Size(432, 121);
     this.groupBox2.TabIndex = 3;
     this.groupBox2.TabStop  = false;
     //
     // button5
     //
     this.button5.Location = new System.Drawing.Point(80, 59);
     this.button5.Name     = "button5";
     this.button5.Size     = new System.Drawing.Size(341, 23);
     this.button5.TabIndex = 8;
     this.button5.Text     = "Создать таблицы в пустой базе данных";
     this.button5.UseVisualStyleBackColor = true;
     this.button5.Click += new System.EventHandler(this.Button5Click);
     //
     // button3
     //
     this.button3.Location = new System.Drawing.Point(80, 88);
     this.button3.Name     = "button3";
     this.button3.Size     = new System.Drawing.Size(170, 23);
     this.button3.TabIndex = 7;
     this.button3.Text     = "Создать новую базу данных";
     this.button3.UseVisualStyleBackColor = true;
     this.button3.Click += new System.EventHandler(this.Button3Click);
     //
     // testConnectButton
     //
     this.testConnectButton.Font     = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.testConnectButton.Location = new System.Drawing.Point(256, 88);
     this.testConnectButton.Name     = "testConnectButton";
     this.testConnectButton.Size     = new System.Drawing.Size(165, 23);
     this.testConnectButton.TabIndex = 5;
     this.testConnectButton.Text     = "Проверить соединение";
     this.testConnectButton.UseVisualStyleBackColor = true;
     this.testConnectButton.Click += new System.EventHandler(this.TestConnectButtonClick);
     //
     // serverTextBox
     //
     this.serverTextBox.Font     = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.serverTextBox.Location = new System.Drawing.Point(8, 33);
     this.serverTextBox.Name     = "serverTextBox";
     this.serverTextBox.Size     = new System.Drawing.Size(418, 20);
     this.serverTextBox.TabIndex = 4;
     //
     // label3
     //
     this.label3.Font     = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.label3.Location = new System.Drawing.Point(8, 16);
     this.label3.Name     = "label3";
     this.label3.Size     = new System.Drawing.Size(242, 23);
     this.label3.TabIndex = 3;
     this.label3.Text     = "Строка подключения к базе данных:";
     //
     // serverRadioButton
     //
     this.serverRadioButton.Location = new System.Drawing.Point(12, 144);
     this.serverRadioButton.Name     = "serverRadioButton";
     this.serverRadioButton.Size     = new System.Drawing.Size(426, 24);
     this.serverRadioButton.TabIndex = 2;
     this.serverRadioButton.TabStop  = true;
     this.serverRadioButton.Text     = "Microsoft SQL Server";
     this.serverRadioButton.UseVisualStyleBackColor = true;
     this.serverRadioButton.CheckedChanged         += new System.EventHandler(this.RadioButtonsCheckedChanged);
     //
     // localRadioButton
     //
     this.localRadioButton.Location = new System.Drawing.Point(12, 12);
     this.localRadioButton.Name     = "localRadioButton";
     this.localRadioButton.Size     = new System.Drawing.Size(426, 24);
     this.localRadioButton.TabIndex = 1;
     this.localRadioButton.TabStop  = true;
     this.localRadioButton.Text     = "Microsoft Access";
     this.localRadioButton.UseVisualStyleBackColor = true;
     this.localRadioButton.CheckedChanged         += new System.EventHandler(this.RadioButtonsCheckedChanged);
     //
     // groupBox1
     //
     this.groupBox1.Controls.Add(this.button4);
     this.groupBox1.Controls.Add(this.button2);
     this.groupBox1.Controls.Add(this.button1);
     this.groupBox1.Controls.Add(this.localDatabaseTextBox);
     this.groupBox1.Controls.Add(this.label1);
     this.groupBox1.Location = new System.Drawing.Point(12, 37);
     this.groupBox1.Name     = "groupBox1";
     this.groupBox1.Size     = new System.Drawing.Size(432, 92);
     this.groupBox1.TabIndex = 0;
     this.groupBox1.TabStop  = false;
     //
     // button4
     //
     this.button4.Font     = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.button4.Location = new System.Drawing.Point(261, 58);
     this.button4.Name     = "button4";
     this.button4.Size     = new System.Drawing.Size(165, 23);
     this.button4.TabIndex = 7;
     this.button4.Text     = "Проверить соединение";
     this.button4.UseVisualStyleBackColor = true;
     this.button4.Click += new System.EventHandler(this.Button4Click);
     //
     // button2
     //
     this.button2.Location = new System.Drawing.Point(80, 58);
     this.button2.Name     = "button2";
     this.button2.Size     = new System.Drawing.Size(170, 23);
     this.button2.TabIndex = 6;
     this.button2.Text     = "Создать новую базу данных";
     this.button2.UseVisualStyleBackColor = true;
     this.button2.Click += new System.EventHandler(this.Button2Click);
     //
     // button1
     //
     this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
     this.button1.Location  = new System.Drawing.Point(398, 32);
     this.button1.Name      = "button1";
     this.button1.Size      = new System.Drawing.Size(28, 20);
     this.button1.TabIndex  = 5;
     this.button1.Text      = "...";
     this.button1.UseVisualStyleBackColor = true;
     this.button1.Click += new System.EventHandler(this.Button1Click);
     //
     // localDatabaseTextBox
     //
     this.localDatabaseTextBox.Font     = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.localDatabaseTextBox.Location = new System.Drawing.Point(8, 32);
     this.localDatabaseTextBox.Name     = "localDatabaseTextBox";
     this.localDatabaseTextBox.ReadOnly = true;
     this.localDatabaseTextBox.Size     = new System.Drawing.Size(388, 20);
     this.localDatabaseTextBox.TabIndex = 4;
     //
     // label1
     //
     this.label1.Font     = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.label1.Location = new System.Drawing.Point(6, 16);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(207, 23);
     this.label1.TabIndex = 3;
     this.label1.Text     = "Путь к базе данных:";
     //
     // openFileDialog1
     //
     this.openFileDialog1.FileName = "database.mdb";
     this.openFileDialog1.Filter   = "Файл базы данных *.mdb|*.mdb";
     //
     // FormDatabase
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(456, 353);
     this.Controls.Add(this.panel2);
     this.Controls.Add(this.panel1);
     this.Icon        = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name        = "FormDatabase";
     this.Text        = "Настройка базы данных";
     this.Activated  += new System.EventHandler(this.FormDatabaseActivated);
     this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormDatabaseFormClosed);
     this.Load       += new System.EventHandler(this.FormDatabaseLoad);
     this.panel1.ResumeLayout(false);
     this.panel2.ResumeLayout(false);
     this.groupBox2.ResumeLayout(false);
     this.groupBox2.PerformLayout();
     this.groupBox1.ResumeLayout(false);
     this.groupBox1.PerformLayout();
     this.ResumeLayout(false);
 }
示例#59
0
        public void LoadContent()
        {
            background = gameRef.Content.Load <Texture2D>(@"Images/HUD/gradient");

            var color = 210;

            controlColor = new Color(color, color, color);

            controls = new ControlManager(gameRef, gameRef.Content.Load <SpriteFont>(@"fonts\kootenay9"));

            layer1 = new Button()
            {
                Name  = "btnLayer1",
                Text  = "Layer 1",
                Value = 0
            };

            layer2 = new Button()
            {
                Name  = "btnLayer2",
                Text  = "Layer 2",
                Value = 1
            };

            layer3 = new Button()
            {
                Name  = "btnLayer3",
                Text  = "Layer 3",
                Value = 2
            };

            collisionLayer = new Button()
            {
                Name  = "btnCollisionLayer",
                Text  = "Collision Layer",
                Value = -1
            };

            controls.Add(layer1);
            controls.Add(layer2);
            controls.Add(layer3);
            controls.Add(collisionLayer);

            Vector2 startPos = new Vector2(0, 35);

            foreach (Button b in controls)
            {
                b.OnClick += LayerButtonClick;
                b.Position = startPos;
                startPos  += new Vector2(0, b.Height + 10);
            }

            Button toggleShowCollision = new Button()
            {
                Name = "btnToggleShowCollision",
                Text = "Show Collision"
            };

            toggleShowCollision.OnClick += (o, e) => { showCollisionMap = !showCollisionMap; };
            toggleShowCollision.Position = controls[3].Position + new Vector2(0, collisionLayer.Height + 10);
            controls.Add(toggleShowCollision);

            Button selectTileSheet = new Button()
            {
                Name = "btnSelectTileSheet",
                Text = "Select Tile Sheet"
            };

            selectTileSheet.OnClick += (o, e) =>
            {
                gameRef.State = State.Freeze;

                frmGetTileSheet frm = new frmGetTileSheet(gameRef);
                frm.ShowDialog();

                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    selectedTileSetIndex = frm.SelectedTileSheetId;
                    gameRef.level.CurrentTileSetIndex = selectedTileSetIndex;
                }

                gameRef.State = State.Playing;
            };
            selectTileSheet.Position = controls[4].Position + new Vector2(0, collisionLayer.Height + 10);
            controls.Add(selectTileSheet);

            Button saveMap = new Button()
            {
                Name = "btnSaveMap",
                Text = "Save Map"
            };

            saveMap.OnClick += (o, e) =>
            {
                gameRef.State = State.Freeze;

                System.Windows.Forms.SaveFileDialog saveFileDlg = new System.Windows.Forms.SaveFileDialog();
                saveFileDlg.FileName = "level1.slf";
                saveFileDlg.Filter   = "SLF level (.slf)|*.slf";

                if (saveFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    // TODO: Save map with method Level.Save(@"File/path/here");
                    gameRef.level.Save(saveFileDlg.FileName);
                }

                gameRef.State = State.Playing;
            };
            saveMap.Position = controls[5].Position + new Vector2(0, collisionLayer.Height + 10);
            controls.Add(saveMap);

            Button loadMap = new Button()
            {
                Name     = "btnLoadMap",
                Text     = "Load Map",
                Position = saveMap.Position + new Vector2(0, saveMap.Height + 10)
            };

            loadMap.OnClick += (o, e) =>
            {
                gameRef.State = State.Freeze;

                var openFileDlg = new System.Windows.Forms.OpenFileDialog();
                openFileDlg.FileName = "";
                openFileDlg.Filter   = "SLF Level (.slf)|*.slf";
                if (openFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    // TODO: Load map with method level.Load(@"File/path/here");
                    gameRef.level.Load(openFileDlg.FileName);
                }

                Camera.MaxClamp = new Vector2(gameRef.level.WidthInPixels - Canvas.CANVAS_WIDTH,
                                              gameRef.level.HeightInPixels - Canvas.CANVAS_HEIGHT);

                gameRef.State = State.Playing;
            };
            controls.Add(loadMap);

            // Button to turn on the pencil tool
            Button pencil = new Button()
            {
                Name     = "btnPencil",
                Text     = "Pencil",
                Position = loadMap.Position + new Vector2(0, loadMap.Height + 10)
            };

            pencil.OnClick += (o, e) => { selectedTool = Tool.Pencil; };
            controls.Add(pencil);

            // Button to turn on the fill tool
            Button fill = new Button()
            {
                Name     = "btnFill",
                Text     = "Fill",
                Position = pencil.Position + new Vector2(0, loadMap.Height + 10)
            };

            fill.OnClick += (o, e) => { selectedTool = Tool.Fill; };
            controls.Add(fill);

            Label lblTileIndex = new Label()
            {
                Color = Color.Black,
                Name  = "lblTileIndex",
                Text  = "{X: " + gameRef.level.CurrentTileSet.SourceRectangles[SelectedTileIndex].X / Engine.TileWidth + ", " +
                        "Y: " + gameRef.level.CurrentTileSet.SourceRectangles[SelectedTileIndex].Y / Engine.TileHeight + "}"
            };

            lblTileIndex.Position = fill.Position + new Vector2(0, fill.Height + 10);
            controls.Add(lblTileIndex);

            Button newMap = new Button()
            {
                Name     = "btnNewMap",
                Text     = "New Map",
                Position = lblTileIndex.Position + new Vector2(0, lblTileIndex.Height + 10)
            };

            newMap.OnClick += (o, e) =>
            {
                gameRef.State = State.Freeze;
                new frmNewMap(gameRef).ShowDialog();
                gameRef.State = State.Playing;
            };
            controls.Add(newMap);

            Button playerSpawn = new Button()
            {
                Name     = "btnPlayerSpawn",
                Text     = "Set Player Spawn",
                Position = newMap.Position + new Vector2(0, newMap.Height + 10)
            };

            playerSpawn.OnClick += (o, e) =>
            {
                selectedTool = Tool.PlayerSpawn;
            };
            controls.Add(playerSpawn);

            //selector = new TileSelector(gameRef, lblTileIndex.Position + new Vector2(0, lblTileIndex.Height + 10));
            //selector.Width = HUD_WIDTH;
        }
示例#60
-1
        public static SharpMap.Map InitializeMap(float angle)
        {
            using (var ofn = new System.Windows.Forms.OpenFileDialog())
            {
                ofn.Filter = "All files|*.*";
                ofn.FilterIndex = 0;

                if (ofn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var m = new SharpMap.Map();
                    var l = new SharpMap.Layers.GdiImageLayer(ofn.FileName);
                    m.Layers.Add(l);

                    m.ZoomToExtents();

                    var mat = new System.Drawing.Drawing2D.Matrix();
                    mat.RotateAt(angle, m.WorldToImage(m.Center));
                    m.MapTransform = mat;
                    m.MaximumExtents = m.GetExtents();
                    m.EnforceMaximumExtents = true;
                    return m;
                }
            }
            return null;

        }