[PT] #PGGD16 – 16º Portugal Girl Geek Dinner – Lisboa

pddg
Aproveitamos o lançamento do Windows 8 para reunirmos novamente as nossas geeks em Lisboa!

O #PGGD16 vai realizar-se no próximo dia 8 de Novembro, a partir das 19:00, nas instalações da Microsoft (no Parque Expo).

Vem conhecer o novo Windows 8 e preparar-te para começar a publicar apps na Windows 8 Store.

Para participar basta inscrever-se gratuitamente.
Agenda:

19:00 Registo / Snacks & Drinks

19:30 Tiago Andrade e Silva – Windows 8

20:15 Sara Silva – Windows 8 Store Apps – Do sonho à realidade

21:00 Encerramento

 

Apoios: Microsoft Portugal

 

Nota: Homens podem também participar desde que sejam acompanhantes de uma geek girl.

 

Sobre os Girl Geek Dinners…

Os Girl Geek Dinners nasceram em Londres há 7 anos. Este conceito reside em organizar eventos temáticos para mulheres apaixonadas por tecnologia, sejam elas, programadoras, investigadoras, empreendedoras, designers ou simplesmente interessadas por tópicos relacionados com tecnologia.

A ideia por detrás destes jantares é simples: num ambiente relaxado e informal proporcionar um ambiente para networking e ao mesmo tempo ouvir uma ou duas apresentações dedicadas a um tema tecnológico ou de negócio. Mais do que isso é também o espaço ideal para dar a conhecer o que se anda a fazer no mundo da tecnologia e new media em Portugal.

Website | Facebook | Twitter | hashtag oficial: #PGGD16

Telerik Windows 8 RadControls are available

RadControls for Windows 8 are native XAML and HTML components for creating Windows 8 apps. Built from the ground up for Windows 8, RadControls offer the same intuitive UI and UX no matter if you are developing in XAML or HTML environment. The suite offers functionalities such as DatePicker and Chart to complement the stock UI toolbox and shorten your app time to market.

RadControls for Windows 8 launches at an introductory price of $99. If you have a certified app using the product, let Telerik know so that your app can get featured in the showcase gallery.

Overview video:

Some images:

Diplaying DateTime objects in a localized application [Windows 8 Store Apps]

Introduction
This sample shows how to display DateTime object in application that was localized, exponsing four ways to convert a datatime object to a string value.

Get it from here

Building the Sample
You only need Visual Studio 2012 and Windows 8, both the RTM version. 

Description

Before start, let’s prepare the application for localization:

1.      Define the Neutral Language in Assembly Information

2.      Create a Culture folder in solution and inside create one folder for each language the application supports, at the end add the Resources.resw file for each language folder. 

 .   


If you have doubts for this, you can see the following topic:

Creating resource files in Creating and retrieving resources in Windows Store apps

Note: To change the languages, move the language to the top like in the following image:

 

 

 

Now, let’s create string values for display the datetime objects.

 

1. Using ToString() and the following formats:

“d”, “D”, “f”, “F”, “g”, “G”, “m”, “r”, “s”, “t”, “T”, “u”, “U”, “y”,
“dddd, MMMM dd yyyy”, “ddd, MMM d \”‘\”yy”, “dddd, MMMM dd”, “M/yy”, “dd-MM-yy”

C#
var format ="d";  
var stringValue = currentDateTime.ToString(format);

2. Using ToString(), DateTimeFormatInfo.InvariantInfo and the following formats:
“d”, “D”, “f”, “F”, “g”, “G”, “m”, “r”, “s”, “t”, “T”, “u”, “U”, “y”,
“dddd, MMMM dd yyyy”, “ddd, MMM d \”‘\”yy”, “dddd, MMMM dd”, “M/yy”, “dd-MM-yy”

The result for the “G” format is:

*  G Format Specifier      de-DE Culture       12.10.2012 22:04:32 
*  G Format Specifier      en-US Culture       12/10/2012 10:04:32 PM 
*  G Format Specifier      pt-PT Culture       12/10/2008 22:04:32
C#
var format ="d";  
var stringValue = currentDateTime.ToString(format, 
                                  DateTimeFormatInfo.InvariantInfo);
The result is:
   * G Format Specifier  10/12/2000 22:32:32
3. Using CultureInfo.CurrentCulture.DateTimeFormat

C#
var dateTimeUsingFullDateTimePattern= currentDateTime.ToString(dateTimeFormatter.FullDateTimePattern) 

var dateTimeUsingLongDatePattern= currentDateTime.ToString(dateTimeFormatter.LongDatePattern); 

 var dateTimeUsingLongTimePattern= currentDateTime.ToString(dateTimeFormatter.LongTimePattern) 

 var dataTimeUsingMonthDayPatternValue= currentDateTime.ToString(dateTimeFormatter.MonthDayPattern) 

var dateTimeUsingShortDatePattern= currentDateTime.ToString(dateTimeFormatter.ShortDatePattern)) 

var dateTimeUsingShortTimePattern=currentDateTime.ToString(dateTimeFormatter.ShortTimePattern)
The result for the “ShortTimePattern” format is:
*  ShortTimePattern Format Specifier      de-DE Culture   22:04
*  ShortTimePattern  Format Specifier     en-US Culture   10:04:32 PM 
*  ShortTimePattern Format Specifier      pt-PT Culture   22:04

4. Using DateTimeFormatter

C#
var dateTimeFormatter1 = new DateTimeFormatter("month day dayofweek year"); 

var dateTime1 = dateTimeFormatter.Format(currentDateTime) 

var dateTimeFormatter2 =new DateTimeFormatter(
YearFormat.Default, 
MonthFormat.Default,
DayFormat.Default, 
DayOfWeekFormat.Default,
HourFormat.None, 
MinuteFormat.None, 
SecondFormat.None,
languages) 

var dateTime2 = dateTimeFormatter2.Format(currentDateTime);
The result for "month day dayofweek year" is

 *  "month day dayofweek year" Format Specifier    
    de-DE Culture Freitag‎, ‎12‎. ‎Oktober‎ ‎2011
*  "month day dayofweek year" Format Specifier    
    en-US Culture   Friday‎, ‎October‎ ‎12‎, ‎2011

*  "month day dayofweek year" Format Specifier      
    pt-PT Culture   sexta-feira, 12 de Outubro de 2012

Note:
The DateTimeFormatter has more constructors.

Related Samples

Application resources and localization sample

Localization for Images and Assets


Related Topics

Windows.Globalization.DateTimeFormatting

CultureInfo

InvariantCulture

DateTimeFormat

Build the sample

  1. Start Visual Studio Express 2012 for Windows 8 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express 2012 for Windows 8 Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

 Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without   debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

 

More Information

Ask me on twitter @saramgsilva

My simple log manager [Windows 8 Store Apps]

Sometime happens errors in development that needs to catch. For this i create a simple Log Manager class:

 public static class LogManager
    {
        /// <summary>
        /// The write log.
        /// </summary>
        /// <param name="exception">
        /// The exception.
        /// </param>
        /// <returns>
        /// The System.Threading.Tasks.Task.
        /// </returns>
        public static async Task WriteLog(Exception exception)
        {
            var errorMessage = new StringBuilder();
            errorMessage.Append("_________\n");
            errorMessage.Append(exception.Message);
            errorMessage.Append(" - ");
            errorMessage.Append(exception.Source);
            errorMessage.Append(" - ");
            errorMessage.Append(DateTime.Now);
            errorMessage.Append("\n");
            errorMessage.Append(exception.StackTrace);
            await WriteLog(errorMessage.ToString());
        }

        /// <summary>
        /// The write log.
        /// </summary>
        /// <param name="error">
        /// The error.
        /// </param>
        /// <returns>
        /// The System.Threading.Tasks.Task.
        /// </returns>
        public static async Task WriteLog(string error)
        {
            var applicationData = ApplicationData.Current;
            var storageFolder = applicationData.LocalFolder;
            var file = await storageFolder.CreateFileAsync("log.txt", CreationCollisionOption.OpenIfExists);
            var fileContent = await FileIO.ReadTextAsync(file);
            await FileIO.WriteTextAsync(file, fileContent + error);
        }
    }

and then i use it in App.xaml.cs like this:

 private void AppUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            LogManager.WriteLog(e.Exception);
            e.Handled = true;
        }

Note: I write to the LocalFolder but can be other thing place.

This project WinRT Xaml Toolkit has:
Debug/DebugConsole/DebugConsoleOverlay/DC.Trace() – enables tracing and displaying traced information right in the application on a collapsible panel

Convert Canvas or UIElement to Image [Windows 8 Store Apps]

There is no way to convert an UIElement to an Image. There are so many topics about it:

 

I recommend to see this project  WriteableBitmapEx or something in   C++ or DirectX 2D

Toolkits for Windows 8 Store Apps

 

Invoke charm programatically [Windows 8 Store Apps]

For settings is the

SettingsPane class > Show | show method Displays the Settings Charm pane to the user.

 

For share is the

DataTransferManager class > ShowShareUI | showShareUI method Programmatically initiates the user interface for sharing content with another app.

 

For search is the

SearchPane class > Show | show methods  Shows the search pane.

 


NavigationService for Windows 8 Store Apps using XAML / C#

Because i’m using MVVM Light and its Ioc, i created my own NavigationService:

 

using System;

    using Common.Windows8.Interfaces;

    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Navigation;

    /// <summary>
    /// Defines the NavigationService type.
    /// </summary>
    public class NavigationService : INavigationService
    {
        /// <summary>
        /// The frame
        /// </summary>
        private Frame _mainFrame;

        /// <summary>
        /// Occurs when [navigating].
        /// </summary>
        public event NavigatingCancelEventHandler Navigating;

        /// <summary>
        /// Gets a value indicating whether this instance can go back.
        /// </summary>
        /// <value><c>true</c> if this instance can go back; otherwise, <c>false</c>.</value>
        public bool CanGoBack
        {
            get
            {
                return this.EnsureMainFrame() && this._mainFrame.CanGoBack;
            }
        }

        /// <summary>
        /// Gets the current source.
        /// </summary>
        /// <value>The current source.</value>
        public object CurrentSource
        {
            get
            {
                if (this.EnsureMainFrame())
                {
                    return this._mainFrame.Content;
                }

                return null;
            }
        }

        /// <summary>
        /// Goes the back.
        /// </summary>
        public void GoBack()
        {
            if (this.EnsureMainFrame() && this._mainFrame.CanGoBack)
            {
                this._mainFrame.GoBack();
            }
        }

        /// <summary>
        /// Navigates to.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns><c>true</c> if navigate to type page; otherwise, <c>false</c>.</returns>
        public bool NavigateTo(Type type)
        {
            if (this.EnsureMainFrame())
            {
                return this._mainFrame.Navigate(type);
            }

            return false;
        }

        /// <summary>
        /// Navigates to.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns>If navigate to</returns>
        public bool NavigateTo(Type type, object parameter)
        {
            if (this.EnsureMainFrame())
            {
                return this._mainFrame.Navigate(type, parameter);
            }

            return false;
        }

        /// <summary>
        /// Ensures the main frame.
        /// </summary>
        /// <returns><c>true</c> if main frame is not null; otherwise, <c>false</c>.</returns>
        private bool EnsureMainFrame()
        {
            if (this._mainFrame != null)
            {
                return true;
            }

            this._mainFrame = Windows.UI.Xaml.Window.Current.Content as Frame;

            if (this._mainFrame != null)
            {
                // Could be null if the app runs inside a design tool
                this._mainFrame.Navigating += (s, e) =>
                {
                    var eventHandler = this.Navigating;

                    if (eventHandler != null)
                    {
                        eventHandler(s, e);
                    }
                };

                return true;
            }

            return false;
        }
    }

Youtube Sample for Windows 8 Store Apps using XAML/C#

Introduction
This sample shows how to display a movie from youtube in XAML/C# project.

Get it from here

Building the Sample
You only need Visual Studio 2012 and Windows 8, both the RTM version.

Description

First start to create a class YoutbeItem that contains properties for define the layout of the player and the source (url for the movie) and next create a view model for set in page’s DataContext .

For display the movie i will use the WebView and i will call the NavigateToString method. This method allow to add a string which content can be HTML and/or Javascript. In this case i will add a Iframe with some properties defined.

 

Then add to a WebView the sizes and NavigateToString for to see the movie.

C#
webView.Height = youtubeViewModel.YoutubeItem.Height + 20; 
 
webView.Width = youtubeViewModel.YoutubeItem.Width + 20; 
 
webView.NavigateToString(youtubeViewModel.YoutubeItem.Content);

The string value added in NavigationToString wiil be

 

C#
public string Content 
        { 
          get 
          { 
              return 
                  string.Format( 
                      @"<iframe width='{0}' height='{1}' src='{2}' frameborder='{3}'></iframe>", 
                      this.Width, 
                      this.Height, 
                      this.Source, 
                      this.FrameBorder); 
          } 
        }

Result

 
Source Code Files

  • YoutubeItem.cs contrains the YoutubeItem class that represent all definition to display the movie. 
  • YoutubeViewModel.cs contains the YoutubeViewModel class that represent the view model to set in page.

 
Build the Sample

  1. Start Visual Studio Express 2012 for Windows 8 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express 2012 for Windows 8 Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

 
 Run the sample
To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without   debugging, press Ctrl+F5 or use Debug > Start Without Debugging.