public bool ExtractFile(string from, string to, OpenFile dwSearchScope) { var dir = Path.GetDirectoryName(to); if (!Directory.Exists(dir) && !String.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir); return StormLibNet.SFileExtractFile(handle, from, to, dwSearchScope); }
public ServerViewModel() { isBadFilename = true; logStreamOutput = new DataLogger(); OpenFileCmd = new OpenFile(this.OpenFileAction); StartCmd = new StartVirtualHardware(this.StartVirtualHardwareAction); StopCmd = new StopVirtualHardware(this.StopVirtualHardwareAction); portModel = new PortModel(); portModel.IsEditable = true; }
private void btnBrowse_Click(object sender, EventArgs e) { OpenFile.Title = "Ханшийн файл сонгох"; OpenFile.FileName = ""; OpenFile.Filter = "Excel Worksheets|*.xls"; OpenFile.ShowDialog(); if (OpenFile.FileName != "") { txtFileName.Text = OpenFile.FileName; Browse(txtFileName.Text); } }
internal void DisplayMenu(string path) { //Options for various tasks a user can perform Console.WriteLine("\nExit: x\tInsert Line: i\tUpdate Line: u\tNew File: n\tOpen: o"); Console.Write("\nOption: "); string choice = Console.ReadLine(); switch (choice) { case "x": //User pressed x { Environment.Exit(0); break; } case "i": //User pressed i { InsertFileLine file = new InsertFileLine(path); file.InsertLine(); break; } case "u": //User pressed u { UpdateFile file = new UpdateFile(path); file.UpdateLine(); break; } case "n": //User pressed n { NewFile file = new NewFile(); file.createNewFile(); break; } case "o": //User pressed o { OpenFile file = new OpenFile(); file.displayFile(); break; } default: { Console.WriteLine("\nInvalid Input"); DisplayMenu(path); break; } } }
public CodingMathRequest() { ConsoleTextBox.AddColor1(); HowSaveFile.AddColor1(); OpenFile.AddColor1(); ButtonCopy.AddColor1(); ButtonPaste.AddColor1(); ButtonDelete.AddColor1(); ButtonEnter.AddColor1(); SaveFile.AddColor1(); CloseFile.AddColor1(); ButtonDelete.Click += new EventHandler(delegate(object sender, EventArgs e){ TextArea.Clear(); }); ButtonCopy.Click += new EventHandler(Copy); ButtonPaste.Click += new EventHandler(Paste); ButtonEnter.Click += new EventHandler(StartScript); Console.SuspendLayout(); TBLayout.SuspendLayout(); Console.ResumeLayout(false); Console.PerformLayout(); TBLayout.ResumeLayout(false); // CodingMathRequest Controls.Add(Console); Controls.Add(TBLayout); Controls.Add(TextArea); Name = "CodingMathRequest"; OpenFile.Click += new EventHandler(OpenFiles); SaveFile.Click += new EventHandler(SaveFiles); CloseFile.Click += new EventHandler(CloseFiles); HowSaveFile.Click += new EventHandler(HowSaveFiles); TextArea.DragEnter += new DragEventHandler(DragEnterFile); TextArea.DragDrop += new DragEventHandler(DragDropFile); ConsoleTitle.DoubleClick += new EventHandler(OpenConsole); // Console Console.Controls.Add(ConsoleTextBox); Console.Controls.Add(ConsoleTitle); Console.Dock = DockStyle.Bottom; Console.Location = new Point(0, 479); Console.Margin = new Padding(0); Console.MaximumSize = new Size(487, 250); Console.MinimumSize = new Size(487, 44); Console.Name = "Console"; Console.Size = new Size(487, 44); Console.TabIndex = 0; TBLayout.Controls.AddRange(new Control[] { OpenFile, SaveFile, HowSaveFile, CloseFile, ButtonPaste, ButtonCopy, ButtonDelete, ButtonEnter }); }
private void button1_Click(object sender, EventArgs e) { if (OpenFile.ShowDialog() == DialogResult.Cancel) { return; } //OpenFileDialog dialog = new OpenFileDialog(); //if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ // name = dialog.FileName; //} label1.Text = OpenFile.FileName; }
private void ButtonAddReskins_Click(object sender, EventArgs e) { OpenFile.Title = "Select Reskin Files"; if (OpenFile.ShowDialog() != DialogResult.OK) { return; } foreach (var file in OpenFile.FileNames) { AddFile(file); } RefreshList(); }
private void ButtonChooseFile_Click(object sender, EventArgs e) { OpenFile.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG"; if (OpenFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //var img = Image.FromFile(OpenFile.FileName); //var bmp = new Bitmap(img.Width, img.Height); //var graphics = Graphics.FromImage(bmp); //graphics.DrawImage(img,0,0); //graphics.Dispose(); SetImage(new Bitmap(Image.FromFile(OpenFile.FileName))); } }
public void SetImage(string name, UnityEngine.Object panel) { Sprite sp = OpenFile.GetInstance().GetSpriteByName(name); if (sp != null) { m_img.sprite = sp; m_imgName = name; } if (panel != null) { m_Panel = panel; } }
private void cmdFindImage_Click(object sender, EventArgs e) { OpenFile.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "\\Resources\\Backgrounds"); OpenFile.FileName = string.Empty; DialogResult result = OpenFile.ShowDialog(); if (result == DialogResult.OK) { string Test = OpenFile.FileName.Replace(Directory.GetCurrentDirectory(), string.Empty); //txtBackgroundImage.Text = Test; } //DrawEnvironment(); }
private void OpenFileFunc() { if (OpenFile.ShowDialog() == DialogResult.OK) { BinaryFormatter binFormatOpen = new BinaryFormatter(); using (Stream fstream = File.OpenRead(OpenFile.FileName)) { ViewObject = (ViewController)binFormatOpen.Deserialize(fstream); } // ViewObject.Draw(this.CreateGraphics()); ViewObject.SetWindowRect(RectWindow); Invalidate(); } }
public void MakeTem(Tem model) { for (int i = 0; i < 2; i++) { //1.读取文本流 string str = File.ReadAllText(GetTem((ListHtmlModel)i)); //2.替换文本流 str = ReplaceTem(str, model); //3.生成文本流 //3.生成文本流 string path = System.Web.HttpContext.Current.Server.MapPath("/test/TwoPositions.Ent.Web/Areas/" + model.module + "/Views/" + model.menu + "/" + ((ListHtmlModel)i).ToString() + ".cshtml"); OpenFile.WriteFile(str, path); } }
/*Выбор файла*/ private void ToChooseFile_Click(object sender, EventArgs e) { if (OpenFile.ShowDialog() == DialogResult.Cancel) { return; } filePath = OpenFile.FileName; ReadFile(ref textFile); richTextBox1.Text = textFile; statusStrip1.Visible = true; toolStripStatusLabel1.Visible = true; toolStripStatusLabel1.Text = filePath; }
private void открытьСценуToolStripMenuItem_Click(object sender, EventArgs e) { OpenFile.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath); OpenFile.Filter = "Rays проект (*.ray)|*.ray|XML файлы (*.xml)|*.xml|Все файлы|*.*"; OpenFile.FileName = ""; if (OpenFile.ShowDialog() == DialogResult.OK) { LoadProject(OpenFile.FileName); Canvas_Resize(sender, null); Canvas.Invalidate(); UpdateWindowTitle(); UpdateFileHistory(OpenFile.FileName); } }
public Start() { InitializeComponent(); SizeToContent = SizeToContent.Manual; MaxHeight = SystemParameters.WorkArea.Height; // Button Events MinimizeButton.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(MinimizeButtonUp), true); CloseButton.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(CloseButtonUp), true); CreateNewFile.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(CreateNewFileButtonUp), true); OpenPhoto.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(OpenPhotoButtonUp), true); OpenFile.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(OpenFileButtonUp), true); }
/// <summary> /// Открывает и читает выбранный XML файл, и строит по нему список книг /// </summary> void openFile() { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.InitialDirectory = Path.GetDirectoryName(Environment.CurrentDirectory); ofd.Filter = "xml files (*.xml)|*.xml"; if (ofd.ShowDialog() == DialogResult.OK) { books = OpenFile.read(ofd.FileName); //открытие и чтение файла Scripts.outputBooksStore(MainDGV, books); //вывод информации на экран } } }
/// <summary> /// Called when double clicking an item /// </summary> void Open(string name, string extension, string filePath) { //It's a directory -> open filepath if (extension == string.Empty) { _inputfield.text = filePath; PressedGo(); } //It's a file else { //send event further out and let them deal with it OpenFile?.Invoke(name, extension, filePath); } }
public void OnAddImageClick() { OpenFile.GetInstance().OpenDialogAndCopyImage(ConfigMgr.GetInstance().V_MaxImageIndex.ToString(), (obj) => { if (obj == null) { return; } Sprite sp = obj as Sprite; //创建图片cell AddImg(ConfigMgr.GetInstance().V_MaxImageIndex.ToString()); //图片加载成功了,索引也需要增加 ConfigMgr.GetInstance().V_MaxImageIndex++; }); }
private void FindButton_Click(object sender, EventArgs e) { if (OpenFile.ShowDialog() == DialogResult.OK) { try { TextBoxPath.Text = OpenFile.FileName; } catch (SecurityException ex) { MessageBox.Show($"Security error.\n\nError message: {ex.Message}\n\n" + $"Details:\n\n{ex.StackTrace}"); } } }
void Start() { //初始化配置 ConfigMgr.GetInstance().InitData(); DontDestroyOnLoad(this); //初始化数据 UIManager.GetInstance().Init(); OutFoodMgr.GetInstance().Model.Init(); HomeFoodMgr.GetInstance().Model.Init(); OpenFile.GetInstance().Init(); //打开主页 UIManager.GetInstance().ShowUIForm(EM_WinType.MainUIPanel); }
private void fireOpen() { if (allowOpen && fileDataGrid.hasItemSelected()) { allowOpen = false; loadingWidget.Visible = true; OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget.update(); currentFile = (PatientDataFile)fileDataGrid.getItemDataAt(fileDataGrid.getIndexSelected()); if (OpenFile != null) { OpenFile.Invoke(this, EventArgs.Empty); } this.hide(); } }
private void OpenToolStripMenuItem_Click(object sender, EventArgs e) { // Open the search file dialog DialogResult Result = OpenFile.ShowDialog(); // If the user cancelled the operation, return if (Result != DialogResult.OK) { return; } // Then, open the file stream using (Stream FileStream = OpenFile.OpenFile()) using (BinaryReader Reader = new BinaryReader(FileStream)) { // Detect and get the correct type of game Format Type = Format.Detect(Reader); // If there is no game, notify the user and return if (Type == null) { MessageBox.Show("We checked the file that you provided and is not a valid rom.\nMake sure that the rom is valid and works."); return; } // Otherwise, fill the spaces for the basic info ResetFields(); NameLabel.Text = Type.Title; DeveloperLabel.Text = Type.Developer; IdentifierLabel.Text = Type.Identifier; ConsoleLabel.Text = Type.Console; RegionLabel.Text = Type.Region; // The localized titles foreach (KeyValuePair <string, string> locale in Type.LocalizedTitles) { ListViewItem item = LocalizedListView.Items.Add(locale.Key); item.SubItems.Add(locale.Value.ToString()); } // And the advanced info foreach (KeyValuePair <string, object> prop in Type.GetAdvancedInformation()) { ListViewItem item = AdvancedListView.Items.Add(prop.Key); item.SubItems.Add(prop.Value.ToString()); } } }
/// <summary> /// /// </summary> /// <param name="e"></param> /// <returns></returns> protected virtual bool OnLoad(DataFileEventArgs e) { try { OpenFile?.Invoke(this, e); FileName = e.FileName; IsModified = false; FileChanged?.Invoke(this, e); return(true); } catch (Exception ex) { MessageBox.Show($"Error loading '{FileName}' : {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } }
private void btLoad_Click(object sender, EventArgs e) //кнопка загрузки { DialogResult result = MessageBox.Show("Вы уверены, что хотите загрузить объекты из файла?", "Загрузка", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { if (OpenFile.ShowDialog() == DialogResult.OK) { readFile = OpenFile.FileName; LoadCommand load = (LoadCommand)commands["Load"].clon(); load.execute(readFile, storage); history.Push(load); } } this.Refresh(); }
public void SetImage() { OpenFile.GetInstance().OpenDialogAndCopyImage("2", (obj) => { if (this == null) { return; } if (obj == null) { return; } Sprite sp = obj as Sprite; m_img.sprite = sp; }); }
public void MakeTem(Tem model) { foreach (var i in model.ListTableValue) { //1.读取文本流 string str = File.ReadAllText(GetTem()); //2.替换文本流 str = str.Replace("@PB.NAME_SPACE@", model.nameSpace); str = str.Replace("@PB.MODUAL@", model.module); str = str.Replace("@PB.MENU@", model.menu); str = str.Replace("@PB.HEAD@", i); //3.生成文本流 string path = System.Web.HttpContext.Current.Server.MapPath("/test/TwoPositions.Biz/DAO/" + model.module + "/" + i + "Dao.cs"); OpenFile.WriteFile(str, path); } }
//открытие файла private void toolStripMenuItemOpen_Click(object sender, EventArgs e) { if ((CanClose() && OpenFile.ShowDialog() == DialogResult.OK)) { textBoxText.Clear(); StreamReader read = new StreamReader(OpenFile.FileName); while (!read.EndOfStream) { string line = read.ReadLine(); textBoxText.Text += line + Environment.NewLine; } read.Close(); isChanged = false; currentFile = OpenFile.FileName; } }
private void btnLerArquivo_Click(object sender, EventArgs e) { if (OpenFile.ShowDialog() == DialogResult.OK) { rchTxtBxScrambled.Clear(); rchTxtBxUnscrambled.Clear(); threadRead = new Thread(() => ReadFileThread(rchTxtBxScrambled, lblStatus, OpenFile.FileName)); threadRead.Start(); lblStatus.Text = "Carregando..."; lblStatus.ForeColor = Color.DodgerBlue; Application.DoEvents(); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { string OpenedFilePath = openFileDialog1.FileName; OpenFile newFile = new OpenFile(); string[] FileData = newFile.GetFile(OpenedFilePath); FileDataBox.Text = ""; foreach (string line in FileData) { FileDataBox.Text += (line + "\r\n"); } } }
public EditorViewModel() { IncreaseText = new DelegateCommand(_ => { ++FontSize; OnPropertyChanged(); }); DecreaseText = new DelegateCommand(_ => { if (FontSize > 1) { --FontSize; OnPropertyChanged(); } }); New = new DelegateCommand(_ => { if (IsDirty) { string messageBoxText = "You have unsaved changes. Do you want to save?"; string caption = "Unsaved changes"; System.Windows.MessageBoxButton button = System.Windows.MessageBoxButton.YesNoCancel; System.Windows.MessageBoxImage icon = System.Windows.MessageBoxImage.Warning; System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); if (result == System.Windows.MessageBoxResult.Yes) { SaveFile?.Invoke(this, new FileOperationEventArgs(null, CurrentText, IsDirty)); IsDirty = false; CurrentText = ""; LineNumbers = ""; } else if (result == System.Windows.MessageBoxResult.No) { NewFile?.Invoke(this, null); } } }); Save = new DelegateCommand(_ => { if (IsDirty) { SaveFile?.Invoke(this, new FileOperationEventArgs(null, CurrentText, IsDirty)); IsDirty = false; } }); Open = new DelegateCommand(_ => { OpenFile?.Invoke(this, new FileOperationEventArgs(null, null, IsDirty)); }); }
/// <summary> /// Load XML serialized file on data grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadFileItem_Click(object sender, EventArgs e) { if (OpenFile.ShowDialog() == DialogResult.Cancel) { return; } if (FigureAreaDataGrid.Rows.Count > 0) { DialogResult cleanTable = MessageBox.Show("Clear table?", "Table isn't empty", MessageBoxButtons.YesNoCancel); if (cleanTable == DialogResult.Yes) { CleanDataGrid(FigureAreaDataGrid); } else if (cleanTable == DialogResult.Cancel) { return; } } string filename = OpenFile.FileName; var writer = new FileStream(filename, FileMode.Open); if (!OpenFile.CheckFileExists) { MessageBox.Show("File not exists."); return; } DataSet ds = new DataSet(); ds.ReadXml(writer); writer.Close(); if (ds.Tables["FigureAreas"] == null) { MessageBox.Show("XML Reader error: table \"FigureAreas\" doesn't exist in file"); return; } foreach (DataRow Row in ds.Tables["FigureAreas"].Rows) { int n = FigureAreaDataGrid.Rows.Add(); FigureAreaDataGrid.Rows[n].Cells[0].Value = Row["Figure"]; FigureAreaDataGrid.Rows[n].Cells[1].Value = Row["Area"]; } MessageBox.Show("File was loaded successfully."); }
public MainWindow() { this.InitializeComponent(); this.WhenActivated(disposables => { this.WhenAnyValue(v => v.ViewModel) .BindTo(this, v => v.DataContext) .DisposeWith(disposables); this.InitializeMainTabControl(disposables); this.InitializeMenu(disposables); this.ViewModel !.OpenFile .WhereNotNull() .Where(model => model.IsExternal) .Discard() .ObserveOnDispatcher() .Subscribe(this.OnOpenFileExternally) .DisposeWith(disposables); this.Events().Drop .Where(e => e.Data.GetDataPresent(DataFormats.FileDrop)) .SelectMany(e => (string[])e.Data.GetData(DataFormats.FileDrop)) .Select(file => new OpenFileModel(file) { IsExternal = true }) .InvokeCommand(this.ViewModel.OpenFile) .DisposeWith(disposables); this.Events().Closing .Do(e => e.Cancel = true) .Discard() .InvokeCommand(this.ViewModel.Shutdown) .DisposeWith(disposables); this.ViewModel.Shutdown .Subscribe(() => { disposables.Dispose(); this.Close(); }) .DisposeWith(disposables); }); }
public static IntPtr OpenFile(string filename, OpenFile dwSearchScope) { return archive.OpenFile(filename, dwSearchScope); }
private void SwitchToFile(OpenFile newFile) { EnableChangeDetection = false; if (CurrentFile != null) CurrentFile.Text = scintilla1.Text; CurrentFile = newFile; scintilla1.Text = CurrentFile.Text; this.Text = CurrentFile.Filename; foreach (var file in OpenFiles) file.TabButton.CurrentTab = false; CurrentFile.TabButton.CurrentTab = true; EnableChangeDetection = true; }
internal void ParseFileUpdateDB() { form.buttonDownload.Enabled = false; form.button1.Enabled = false; OpenFile of = new OpenFile("vo.xml"); List<OkPneuTire> lt = of.OpenXml(); Dictionary<string, OkPneuTire> DictData = new Dictionary<string, OkPneuTire>(); OkPneuTire MatchTire = new OkPneuTire(); foreach (var i in lt) { if (i.EAN.Length > 14) i.EAN = i.EAN.Substring(0, 13); if (i.Manufacturer.Length > 10) i.Manufacturer = i.Manufacturer.Substring(0, 9); if (i.code.Length > 15) i.code = i.code.Substring(0, 14); if (i.Name.Length > 50) i.Name = i.Name.Substring(0, 49); if (i.Description.Length > 2000) i.Description = i.Description.Substring(0, 1999); i.ImageURL = i.ImageURL.Trim(); if (i.ImageURL.Length > 200) i.ImageURL = i.ImageURL.Substring(0, 199); if (i.EAN == "" || i.EAN == null) continue; if (DictData.TryGetValue(i.EAN, out MatchTire)) { DictData.Remove(i.EAN); MatchTire = ChoseRightTire(i, MatchTire); DictData.Add(MatchTire.EAN, MatchTire); } else { DictData.Add(i.EAN, i); } } UpdateDB(DictData.Values.ToList()); form.buttonDownload.Enabled = true; form.button1.Enabled = true; }
public bool ExtractFile(string from, string to, OpenFile dwSearchScope) { foreach (MpqArchive a in archives) { var r = a.ExtractFile(from, to, dwSearchScope); if (r) return true; } return false; }
public IntPtr OpenFile(string FileName, OpenFile dwSearchScope) { IntPtr s; StormLibNet.SFileOpenFileEx(this.handle, "Actor\\A1_BlackMushroom.acr", dwSearchScope, out s); return s; }
private OpenFile PrepareFileTab(String Filename, String Text) { var tab = new FileTab(); tab.Filename = System.IO.Path.GetFileName(Filename); tab.Font = scintilla1.Font; openFilesBar.Items.Add(tab); var openFile = new OpenFile { Filename = Filename, Text = Text, Changes = false, TabButton = tab }; OpenFiles.Add(openFile); tab.Tag = openFile; tab.FilenameClick += (s, args) => { SwitchToFile(openFile); }; tab.FileClosing += (s, args) => { var file = ((s as FileTab).Tag as OpenFile); if (file.Changes) { SwitchToFile(file); var r = MessageBox.Show(file.Filename + " has some unsaved changes. Save?", "Save", MessageBoxButtons.YesNoCancel); if (r == System.Windows.Forms.DialogResult.Cancel) return; if (r == System.Windows.Forms.DialogResult.Yes) { if (!Save()) return; } } OpenFiles.Remove(file); openFilesBar.Items.Remove(s as ToolStripItem); if (OpenFiles.Count > 0) SwitchToFile(OpenFiles[0]); else OpenNewFile(); openFilesBar.Invalidate(true); }; return openFile; }
public IntPtr OpenFile(string file, OpenFile dwSearchScope) { return archives[0].OpenFile(file, dwSearchScope); }
public static bool ExtractFile(string from, string to, OpenFile dwSearchScope) { return archive.ExtractFile(from, to, dwSearchScope); }