Creating a Notepad- Windows forms - windows

New in the business. Iam creating a windows form Notepad. How do I do the Button Open to open a file and a specific compatible file?

KInd off. I am creating a Notepad with Visual Studio. In the Menu strip, I created a buttion save and another open. De form design its ok, now I need to lear the code c#, to put in the event "Open file" in the notepad that I am creating.

public MeuBloco()
{
InitializeComponent();
}
private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog();
}
private void SalvarOK(object sender, CancelEventArgs e)
{
string caminho = saveFileDialog1.FileName;
File.WriteAllText(caminho, txbJanela.Text);
}
private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}
private void OpenOk(object sender, CancelEventArgs e)
{
}
}
}
// Now I need to code the event to open the file I want.

Related

xamarin forms audio recording and upload to a server

Is there any possible way to record an audio and upload to a server using xamarin forms.
The best result I got after searching was this
https://github.com/HoussemDellai/UploadFileToServer
The library used in the solution supports only Image and Video.
Thanks in advance
Is there any possible way to record an audio and upload to a server using xamarin forms.
There are many ways realizing this feature. For recording an audio within Xamarin.Forms, you could use Plugin.AudioRecorder to realize. Fore more you could refer the following code.
private AudioRecorderService _recoder;
protected override void OnAppearing()
{
_recoder = new AudioRecorderService
{
StopRecordingOnSilence = true,
StopRecordingAfterTimeout = true,
AudioSilenceTimeout = TimeSpan.FromSeconds(60)
};
_recoder.AudioInputReceived += _recoder_AudioInputReceived;
}
private void _recoder_AudioInputReceived(object sender, string e)
{
// do some stuff
}
private async void Button_Clicked(object sender, EventArgs e)
{
await RecodAudio();
}
private async Task RecodAudio()
{
try
{
if (!_recoder.IsRecording)
{
await _recoder.StartRecording();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
private async void StopButton_Clicked(object sender, EventArgs e)
{
if (_recoder.IsRecording)
{
await _recoder.StopRecording();
}
}
For uploading file, you could use the UploadFileToServer that mentioned in your case. And you will get the audio file path in the AudioInputReceived event args.
private void _recoder_AudioInputReceived(object sender, string e)
{
var path = e;
}

C# MySql - data does not appear after insert new data

First of all, I'm new to C# and also programming. So, my situation is after I insert data from a textbox to MySql database, the new data does not appear. FYI, I have the navigation (next previous) button. I have to re-run the apps in order for the new data to be displayed. Here's part of the codes:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//MySql codes to display in textbox
showData(pos);
}
public void showData(int index)
{
txtDisplay.Text = table.Rows[index][0].ToString();
}
private void btnPrevious_Click(object sender, EventArgs e)
{
}
private void btnNext_Click(object sender, EventArgs e)
{
}
private void btnGenNext_Click(object sender, EventArgs e)
{
//codes to generate new data and also insert into db
}
}
Here's my full codes:

Call MarkerClick Method

I wonder how I could able to call MMap_MarkerClick from MMap_InfoWindowClick?
private void MMap_InfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
//call MMap_MarkerClick
}
private void MMap_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
{
ViewModel.MapMarkerSelected(e.Marker.Title);
}
I am trying to achive it, because MMap_InfoWindowClick does not open new ViewModel, but MMap_MarkerClick does. MarkerClick works but InfoWindowClick does not open ViewModel

Visual Studio 2015 How to run a .wsf with a button. Possible?

Okay I have been trying to figure this out if anyone can help me I would be more then grateful.
The code is below im having an issue where it does not execute the .wsf
1. Does anyone see anything that im missing?
2. Am I approaching this correctly?
3.**The script is opening **cmd.exe and connecting to telnet and running commands.
namespace CamSwitch_V1._3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(#"cscript //B //Nologo c:\scripts\Cam1.wsf");
}
}
}
Let me know if you need any more information.

unable to create and event handler for workbook/sheet event in a Addd-in

Im I'm using VS2008 Addin and im trying to write and event handler for a workbook inside the addin but unfortuantly it isn't getting fired can you help
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
FinalWorkbook = ExcelApplication.Workbooks.Add(missing);
FinalWorkbook.SheetActivate +=
new Excel.WorkbookEvents_SheetActivateEventHandler(
FinalWorkbook_ActivateSheet);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
// MessageBox.Show("The addin has shutdown");
}
public void FinalWorkbook_ActivateSheet(object odjSheet)
{
sheet.BeforeRightClick += Worksheet_BeforeRightClick;
MessageBox.Show(sheet.Name + " Activated2");
}
void Worksheet_BeforeRightClick(Excel.Range Target, ref bool Cancel)
{
Cancel = true;
MessageBox.Show("Right-clicking in this sheet" +
" is not allowed.");
}
}
}
SheetActivate is only fired when you switch between sheets in the workbook, i.e. you click on Sheet2, then Sheet1 and so on.
If you Alt-Tab to a different application and come back to Excel, SheetActivate won't be fired.
You should look at Application.WorkbookActivate, Workbook.Activate or another event.

Resources