Working on a basic Windows Universal app and currently have the issue where upon pressing back on the details page of my lists it doesn't take me back to the main page but instead closes the app entirely.
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.Phone.UI;
using Windows.UI.Xaml.Navigation;
namespace MoreUniversalAppWork
{
public sealed partial class MainPage : Page
{
public QuoteReader qr = new QuoteReader();
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
qr.DownloadQuotes();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void Hardware_Back(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
if (Frame.Content is ViewQuote)
{
Frame.Navigate(typeof(MainPage));
e.Handled = true;
}
}
private void LoadQuotes(object sender, RoutedEventArgs e)
{
FillList();
}
private void FillList()
{
// Downloads the JSON file with the quotes and filles List //
qr.DownloadQuotes();
var quotes = qr.quotes_dictionary();
list_quotes.Items.Clear();
foreach (var q in quotes)
{
list_quotes.Items.Add(q.Value);
}
if (list_quotes.Items.Count > 0)
{
list_quotes.ScrollIntoView(list_quotes.Items[0]);
}
}
private void ViewQuote(object sender, SelectionChangedEventArgs e)
{
// Upon clicking quote in list, details page is opened //
Frame.Navigate(typeof(ViewQuote), list_quotes.SelectedValue);
}
}
}
ViewQuote.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ComponentModel;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Phone.UI.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
namespace MoreUniversalAppWork
{
public sealed partial class ViewQuote : Page
{
string quote;
public ViewQuote()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
quote = e.Parameter as string;
quote_display.Text = quote;
}
}
}
This is normal in Windows Phone 8.1. You may want to have a workaround in App.xaml.cs file.
public App()
{
this.InitializeComponent();
HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame != null && rootFrame.CanGoBack)
{
e.Handled = true;
rootFrame.GoBack();
}
}
WP8.1 back button quits the app
Related
So today I tried dll injection to game (assult cube) to test my experience with my job.
But I got problems with Win32 Exception: 0xc0000005.
My code looks like:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Memory;
namespace AssultCube_Cheat
{
public partial class Form1 : Form
{
Mem assultcube = new Mem();
public static string RifleAmmo = "ac_client.exe+0x0017E0A8";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int PID = assultcube.GetProcIdFromName("ac_client");
if (PID > 0)
{
assultcube.OpenProcess(PID);
Thread WA = new Thread(writeAmmo) { IsBackground = true };
WA.Start();
}
}
private void writeAmmo()
{
while (true)
{
if (checkBox1.Checked)
{
assultcube.WriteMemory(RifleAmmo, "int", "80");
Thread.Sleep(2);
}
Thread.Sleep(2);
}
}
}
}
I tried updating my computer drivers, upgrading my system to Windows 11 but problem didnt fix.
How to display the Hyperlink, Thumbnail, and Publish Date from the following RSS.XML Feed: https://www.economist.com/europe/rss.xml
I am trying to have the Hyperlink, Thumbnail and Publish Date from the feed above. How to go about this?
Below is my code that is displaying only the Title and Description:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.ServiceModel.Syndication;
namespace RSS_Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
XmlReader FD_readxml = XmlReader.Create(textBox1.Text);
SyndicationFeed FD_feed = SyndicationFeed.Load(FD_readxml);
TabPage FD_tab = new TabPage(FD_feed.Title.Text);
tabControl1.TabPages.Add(FD_tab);
ListBox FD_list = new ListBox();
FD_tab.Controls.Add(FD_list);
FD_list.Dock = DockStyle.Fill;
FD_list.HorizontalScrollbar = true;
foreach(SyndicationItem FD_item in FD_feed.Items)
{
FD_list.Items.Add(FD_item.Title.Text);
FD_list.Items.Add(FD_item.Summary.Text);
FD_list.Items.Add("---------");
}
}
catch { }
}
}
}
i am new to .net i am having trouble playing videos automatically. I would be showing different textboxes here but i want the video to autplay without any buttons
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WMPLib;
namespace ThinkQDisplay
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
AxWindowsMediaPlayer1.URL = "C:\Users\Ramrod\Documents\Visual Studio 2012\Projects\ThinkQDisplay\ThinkQDisplay\sample.avi";
}
}
}
It keeps telling it is an unrecognized escape sequence. Also I would like to have a separate form (form2). Where I can choose what to play here on form 1. Is it also possible to have it looped?
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = #"C:\Users\Ramrod\Documents\Visual Studio 2012\Projects\ThinkQDisplay\ThinkQDisplay\sampler.avi";
}
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.settings.autoStart = true;
}
}
}
I want to make stream application for RTSP cam to open VLC
when I press the button show to me the stream in the application but it doesn't show to me anything I want the program to display the stream in VLC
this the code of the application using c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace vlc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void axVLCPlugin21_Enter(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
axVLCPlugin21.playlist.add("rtsp://192.168.0.209:554/mpeg4", "live", "network-caching=75");
//pictureBox1.Visible = false;
axVLCPlugin21.playlist.play();
}
}
}
So im pretty much just starting out with c# and i'm just trying to get the text out of a .txt file and display it on my App. I've tried looking everywhere that I can think of but i've only found people doing this for console Apps and when I try apply the same solution to mine it will just gives errors. This is what i'm trying to use at the moment but I just keep getting the error: "cannot convert 'string' to 'System.IO.Stream'" for the path after StreamReader(path). Ive tried it as an console app(changing the output code) and works fine
namespace FileOpenApp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void inputSubmitButton_Click(object sender, RoutedEventArgs e)
{
outputBox.Text = "Testing";
processFile();
}
private void processFile()
{
try
{
string path = #"C:\Users\Fabian\Dropbox\test.txt";
using (StreamReader sr = new StreamReader(path)) //errors here
{
string line;
while ((line = sr.ReadLine()) != null)
{
outputBox.Text = line;
currentProcess.Text = "Done";
}
}
}
catch (Exception e)
{
currentProcess.Text = "Something went wrong";
}
}
}
}
Edit: trying to use this code I am getting the error that File does not exist in the namespace System.IO
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace FileOpenApp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void inputSubmitButton_Click(object sender, RoutedEventArgs e)
{
outputBox.Text = "Testing";
processFile();
}
private void processFile()
{
string path = #"C:\Users\Fabian\Dropbox\test.txt";
string contents = "";
System.IO.File.ReadAllText(path, contents);
outputBox.Text = contents;
}
}
}
Also tried;
string path = #"C:\Users\Fabian\Dropbox\test.txt";
outputBox.Text = File.ReadAllText(path);
You should call File.ReadAllText(), which does all of this for you and returns a string.