CSS overwrite not working in WP8 - c#

I am just getting started with WP8 development and I have already stumbled into my first problem: I have followed the How to create your first app for Windows Phone tutorial and now I have followed another tutorial to try and overwrite the CSS of the browser. When I run the app, the CSS is not changed and I just see the original web page.
The CSS file is called mobile.css and is found in the Resources folder. Its contents are simply
body {
background-color: blue;
}
and these are its properties:
The (very simple) app code so far is this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using MiniBrowser.Resources;
using System.IO;
using System.Windows.Resources;
namespace MiniBrowser
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
}
private void Go_Click(object sender, RoutedEventArgs e)
{
string site = URL.Text;
MiniBrowser.Navigate(new Uri(site, UriKind.Absolute));
}
private void BrowserLoadCompleted(object sender, NavigationEventArgs e)
{
ApplyStyleSheet("mobile.css");
VisualStateManager.GoToState(this, "Loaded", true);
}
private void ApplyStyleSheet(string cssFilename)
{
//var sr = Application.GetResourceStream(new Uri(cssFilename, UriKind.Relative));
StreamResourceInfo sr = Application.GetResourceStream(new Uri("/MiniBrowser;component/Resources/mobile.css", UriKind.Relative));
using (var strm = sr.Stream)
using (var reader = new StreamReader(strm))
{
string css = reader.ReadToEnd().Replace("\r", "").Replace("\n", "");
var scriptToRun =
"(function() {" +
" var pa= document.getElementsByTagName('head')[0] ; " +
" var el= document.createElement('style'); " +
" el.type= 'text/css'; " +
" el.media= 'screen'; " +
" el.styleSheet.cssText= '" + css + "'; " +
" pa.appendChild(el); " +
"})();";
MiniBrowser.InvokeScript("eval", scriptToRun);
}
}
}
}
Everything else works: the browser is displayed and correctly loads pages. The only thing is that the mobile.css file seems to be ignored.

Add the css file as Resource:
Use the following piece of code to get the content:
StreamResourceInfo sr = Application.GetResourceStream(new Uri("/YourAppName;component/Resources/Custom.css", UriKind.Relative));

Related

Access to file denied in C# .NET 3.1 forms

Hello I was writing a basic text editor in C# on visual studio windows form using the .NET framework 3.1 long term support version everything worked fine until I wrote the save file script
Here's the code for "Form1.cs" which is where the open and save file functions reside
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.IO;
using System.Security.Principal;
namespace Text_Editor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string locsave;
private void openbtn_Click(object sender, EventArgs e)
{
var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
if (principal.IsInRole(WindowsBuiltInRole.Administrator) != true)
{
MessageBox.Show("Run as Admin");
System.Windows.Forms.Application.ExitThread();
}
else
{
OpenFileDialog openfile = new OpenFileDialog();
if (openfile.ShowDialog() == DialogResult.OK)
{
var locationArray = openfile.FileName;
string location = "";
locsave = locationArray;
foreach (char peice in locationArray)
{
location = location + peice;
}
var contentArray = File.ReadAllText(location);
string content = "";
label4.Text = location;
foreach (char peice in contentArray)
{
content = content + peice;
}
richTextBox1.Text = content;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
Console.WriteLine("Test");
}
private void savebtn_Click(object sender, EventArgs e)
{
if (#label4.Text == "")
{
MessageBox.Show("Open a text file first");
}
else
{
StreamWriter outputfile = new StreamWriter(locsave);
outputfile.Write(richTextBox1.Text); //this is where the error occures and it throws the error of access denyed
outputfile.Close();
}
}
}
}
Does anyone have a suggestion about what to do I looked around on google for a solution but it seemed most did not work and some others I did not understand.

Memory Leak In WP8 pages

I have created a sample app in which there are two pages.
1st page contains button, on tapping it takes to second page. In second page there is a list of 100 elements.
In this sample I have navigated to and fro from this second page.
So why is this memory increasing and why is not going down completely on going back to first page and why page destructor never gets called?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using System.IO;
using System.Diagnostics;
namespace PhoneApp1
{
public partial class Page1 : PhoneApplicationPage
{
public Page1()
{
InitializeComponent();
for (int i = 0; i < 100; i++)
{
listBitmapImage.Add(new Test(i));
}
}
List<Test> listBitmapImage = new List<Test>();
protected override void OnRemovedFromJournal(JournalEntryRemovedEventArgs e)
{
base.OnRemovedFromJournal(e);
}
~Page1()
{
Debug.WriteLine("IN DESTRUCTOR");
}
}
public class Test
{
int _a;
string img = "iVBORw0KGgoAAAANSUhEUgAAALEAAACzCAMAAADxPw38AAADAFBMVEXCwsI9P0DGxsYiIVQiIVUjIlje39/W1tbQ0NDPz8+Wl5jLy8tQUVWPkJEiIVeCg4Pf4ODW1tYkI1kkI1mJiouDhYW5urri4uLY2dnX19ckJFEwMjKen5+6u7uoqKiCg4O+v7/b3NwrLEeur6+xsbKcnZ2+v784OUDj4+PY2Njg4eHf4ODGx8c0NEmoqanR0dLMzMw5OkNhYmK6u7vc3d3T09TQ0NHc3d0MDg8GCQkjIlfh4eF9fn/BwsKQkZLi4uJcXl7V1dUSFBQGCQkFBwgFCAkHCQkEBwcFBwgGCAkGCAkFCAoGCAoGCAgEBwcGCAoQEhIGCAkFCAk9PkAAAAC+tq4qKkKDa1T6xL2KZkSae3H70875vLXTtZbCzM76/P37ysTJnmwTDwq2gUrSr4f5sqmXVCOuuLrYupq+i07w5NWRWiPiy7Ovdjz06+Hcwabi7vEUFhaAfHnq2cb38eqRk5TKoH9RNxnX4+YbHB3519xtb3DAkF8hIyRRSkY3MSwvIBGoqKlfYGCPYyqBUCBaPhz54+ebYCVMMBaWXSRpamoHCQr+8O6IXig6NTGgby6eWiUrJSMOEBFxTiJwRR1hQh0wHxCwr69pQBtMRkKIhYSpdTBpSCBJSUtdWFYyLClbOBinaCt4Sx6QjYuLVSJGQT1wbGuzsrEmIiM+ODSYaSx4UyRLMxgLDAzPzs759/evcjBVVVWDgoMwKSQhGhY5ODhYU098eXhVOBmveTI+Pj8oIh2BWSY6JhNgXFutq6p/f350cnEpHA9lYWCfnp25gDRFREUeF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CsnDGRL8dcdHf3RXNwfm3KBOrfB0XMfgmkj7fHnIXzVj09fcmo6asWjfGAk4IK9htcPBcufmnVXLdXvE3fovfgv7nSH86ziCVwHIjng82PL+JeeDihw/fj+fGFYvzXD75fwTnPIpDJsclkAoW1dmQyGd2AfeDfXDnC9r8dks5B15XK3QAAAABJRU5ErkJggg==";
string img_1, img_2, img3, img4;
public Test(int a)
{
_a = a;
img = a + img;
img_1 = a + "1" + img;
img_2 = a + "2" + img;
img3 = a + "3" + img;
img4 = a + "4" + img;
Debug.WriteLine("CONSTRUCTOR:{0}", _a);
}
~Test()
{
Debug.WriteLine("DESTRUCTOR:{0}", _a);
}
}
}
Here's a link to download sample project.
If yo are using BitmapImage, It had memory issue in windows phone 8 already. That may be the reason you are getting memory issue. Please find a similar issue here
Also this link give you more idea about the issue

Compress Audio upon writing to file

I am trying to create a recorder from audio coming out from soundcard and this is my progress so far, the problem is the recorded audio when saving to file is so large like a song can reach up to hundreds of megabyte.
here's my code
using NAudio.CoreAudioApi;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Record_From_Soundcard
{
public partial class frmMain : Form
{
private WaveFileWriter writer;
private WasapiLoopbackCapture waveInSel;
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
MMDeviceEnumerator deviceEnum = new MMDeviceEnumerator();
MMDeviceCollection deviceCol = deviceEnum.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
cboAudioDrivers.DataSource = deviceCol.ToList();
}
private void btnStopRecord_Click(object sender, EventArgs e)
{
waveInSel.StopRecording();
writer.Close();
}
private void btnStartRecord_Click(object sender, EventArgs e)
{
using (SaveFileDialog _sfd = new SaveFileDialog())
{
_sfd.Filter = "Mp3 File (*.mp3)|*.mp3";
if (_sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
MMDevice _device = (MMDevice)cboAudioDrivers.SelectedItem;
waveInSel = new WasapiLoopbackCapture(_device);
writer = new WaveFileWriter(_sfd.FileName, waveInSel.WaveFormat);
waveInSel.DataAvailable += (n, m) =>
{
writer.Write(m.Buffer, 0, m.BytesRecorded);
};
waveInSel.StartRecording();
}
}
}
}
}
can anyone help me on how to compress audio upon saving?
maybe it will be added on this part
waveInSel.DataAvailable += (n, m) =>
{
writer.Write(m.Buffer, 0, m.BytesRecorded);
};
Thanks in advance.. ;)
Try this using naudio dll
Using NAudio.Wave; Using NAudio.Wave.SampleProviders;Using NAudio.Lame
Private void WaveToMP3(int bitRate = 128){
String waveFileName = Application.StartupPath + #"\Temporal\mix.wav";
String mp3FileName = Application.StartupPath + #"\Grabaciones\ " + Strings.Format(DateTime.Now, "dd-MM-yyyy.HH.mm.ss") + ".mp3";
Using (var reader = New AudioFileReader(waveFileName))
{
Using (var writer = New LameMP3FileWriter(mp3FileName, reader.WaveFormat, bitRate))
{
reader.CopyTo(writer);
}
reader.Close();
}
}
You can't make an MP3 file by saving a WAV file with a .MP3 extension (which is what you are doing here). You will need to select an encoder available on your machine, and pass the audio through that. I go into some detail about how to do this with NAudio in this article.

How to get the properties of an .ai or .eps file?

How can I get the properties of ai (Adobe Illustrator) or eps file i.e resolution in dpi etc.
I need to check this properties when uploading file to server.
Also is there any DLL to convert ai/eps to standards image format(jpg, gif, png etc.)?
use ImageMagickNET.dll through this you can convert the .ai or .eps files into .jpg format..
c# code:
public partial class Form1 : Form
{
Process ffmpeg;
string video;
string thumb;
public Form1()
{
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
ffmpeg = new Process();
ffmpeg.StartInfo.Arguments = "convert \"" + .ai file path + "\" -background white -flatten -density 300 -colors 512 -antialias -normalize -units PixelsPerInch -quality 100 -colorspace RGB -resize 3425x3425 \"D:\\GRAPHICS SEARCH ENGINE\\GRAPHICS IMAGES\\AI\\" convert.jpg\"";
ffmpeg.StartInfo.FileName = ("C:\\Program Files (x86)\\ImageMagick-6.5.3-Q16\\convert.exe");
ffmpeg.Start();
}
}
To get the ai files properties like width, height,number of pages and title,
use itextsharp.dll
code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace pdfreared { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
PdfReader reader = new PdfReader(#"D:\Files Formats\Icon.ai");
int n = reader.NumberOfPages;
label4.Text = n.ToString();
// size of the first page
Rectangle psize = reader.GetPageSize(1);
float width = psize.Width;
label1.Text ="Width= " + Convert.ToString(width);
float height = psize.Height;
label2.Text = "Height = " + Convert.ToString(height);
// reader.Metadata.
Console.WriteLine("Size of page 1 of {0} => {1} × {2}", n, width, height);
// file properties
Dictionary<string, string> infodict = reader.Info;
foreach (KeyValuePair<string, string> kvp in infodict)
{
Console.WriteLine(kvp.Key + " => " + kvp.Value);
label3.Text = kvp.Key + " => " + kvp.Value;
}
}
}
use "identify -verbose image.eps" to give the metadata information of EPS file and AI file.

How can i check if a text file contain more then one line of text inside?

I have this code:
BeginInvoke(new Action(() => tempNamesAndTexts.ForEach(Item => textBox1.AppendText(DateTime.Now + "===> " + Item + Environment.NewLine))));
foreach (string items in tempNamesAndTexts)
{
Logger.Write(items);
}
Once im running the program it will do: Logger.Write(items);
Then the text file will look like:
Danie hello
Ron hi
Yael bye
Josh everyone ok
Next time im running the program it will write to the text file the same strings.
I want to check if this string already exist in the text file dont write them again else do write so the result will be that each time im running the program it will write to the logger(text file) only new strings if there are any.
This is the string variable of the logger text file:
full_path_log_file_name
This variable inside have:
C:\\Users\\Chocolade\\AppData\\Local\\ChatrollLogger\\ChatrollLogger\\log\\logger.txt
This is the complete code untill this part wich is the part that DoWork always do one time when im running the program:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using DannyGeneral;
namespace ChatrollLogger
{
public partial class Form1 : Form
{
string log_file_name = #"\logger.txt";
string full_path_log_file_name;
string path_log;
bool result;
List<string> namesAndTexts;
WebResponse response;
StreamReader reader;
string profileName;
string profileNameText;
string url;
string testingUrl;
int index;
List<string> names;
List<string> texts;
WebClient wc;
public Form1()
{
InitializeComponent();
Logger.exist();
wc = new WebClient();
result = true;
url = "http://chatroll.com/rotternet";
testingUrl = "http://chatroll.com/testings";
backgroundWorker1.RunWorkerAsync();
path_log = Path.GetDirectoryName(Application.LocalUserAppDataPath) + #"\log";
full_path_log_file_name = path_log + log_file_name;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
List<string> tempNamesAndTexts = new List<string>();
string tempDownload = downloadContent();
GetProfileNames(tempDownload);
GetTextFromProfile(tempDownload);
for (int i = 0; i < names.Count; i++)
{
tempNamesAndTexts.Add(names[i] + " " + texts[i]);
}
if (InvokeRequired)
{
BeginInvoke(new Action(() => tempNamesAndTexts.ForEach(Item => textBox1.AppendText(DateTime.Now + "===> " + Item + Environment.NewLine))));
foreach (string items in tempNamesAndTexts)
{
Logger.Write(items);
string t = full_path_log_file_name;
}
}
Something like this?
string path = "test.txt";
string valueToWrite = "....";
//only write to the file, if the specified string is not already there
if(!File.ReadLines(path).Any(l => string.Equals(l, valueToWrite)))
{
File.AppendAllText(path, valueToWrite);
}
Use File.ReadAllLines
string[] array = File.ReadAllLines("test.txt");
if(array.Length > 0)
{
// lines exist
}

Categories

Resources