locked
Newbie questions on LightSwitch RRS feed

  • Question

  • 1. VS2013,  project LightSwitch. I would like to select a file and write it location in a string database field. Made a button and wrote the code to call file open dialog:

    using System.Collections.Generic;
    using Microsoft.LightSwitch;
    using Microsoft.LightSwitch.Framework.Client;
    using Microsoft.LightSwitch.Presentation;
    using Microsoft.LightSwitch.Presentation.Extensions;
    using System.Windows.Controls;
    namespace LightSwitchApplication
    {
      public partial class voyages_tableListDetail
      {
        partial void Method_Execute()
        {
          OpenFileDialog dlgopen = new OpenFileDialog();
          dlgopen.Filter = "All file|*.*|Files jpeg|*.jpg|Files png|*.png";
        }
      }
    }
    

    Get the error: "This action can only be performed on the UI thread." Can you please tell how to fix the error.
    2.Pressing the "+" create a form for data entry and editing images_voyage_AddAndEditNew. As I understand it, this form created by default. I would like to place on the form for adding and editing data button. Please show me how to do it.
    3.LightSwitch project is quite large (for my test project more than 55mb). Do I have a problem placing the project on the forums, but the project of this size will not be able to place. What elements of the project necessary and which can be removed?
    4.String fields in the database file paths are PDF and JPEG. How can I call these files viewer, which are used in the system by default?

    The project can be downloaded from https://yadi.sk/d/10QTAJokX3gip


    Alex

    Monday, July 21, 2014 3:40 PM

Answers

  • Monday, July 21, 2014 9:59 PM
  • 4. To open files in their default applications, call this function, passing the full path and name of the file as the command.

    Friend Sub ShellExecute(ByVal strCommand As String)
        Try
            If AutomationFactory.IsAvailable Then
                Dim shell = AutomationFactory.CreateObject("Shell.Application")
                shell.ShellExecute(strCommand)
            End If
        Catch ex As Exception
            'ignore exceptions
        End Try
    End Sub

    Here's the same code in C#. (How do you cope with all the braces? They drive me nuts.)

    internal void ShellExecute(string strCommand)
        { try 
            {  if (AutomationFactory.IsAvailable) 
                {   dynamic shell = AutomationFactory.CreateObject("Shell.Application");   
                    shell.ShellExecute(strCommand);  
                } 
          } 
         catch (Exception ex) 
             {  //ignore exceptions
             }
        }


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.


    • Edited by Simon Jones [MSDL] Tuesday, July 22, 2014 8:46 AM Added C# translation
    • Marked as answer by tumanovalex Tuesday, July 22, 2014 4:58 PM
    Tuesday, July 22, 2014 8:23 AM
  • 3. If you click the Show All Files button on each project in the Solution Explorer, you'll see all the files that are required for your application to build. The folders on disk will contain more files that are the intermediate and final output of your project as well as the source files. That's why it can appear large.

    When you publish your project it gets compiled and packaged into a XAP file and a few supporting files which are actually quite small.

    It would be unusual to have to post all your code into these forums to get help. More often a description of the problem and a small snippet of code will suffice.


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    • Marked as answer by tumanovalex Tuesday, July 22, 2014 4:58 PM
    Tuesday, July 22, 2014 8:40 AM

All replies

  • Monday, July 21, 2014 9:59 PM
  • 4. To open files in their default applications, call this function, passing the full path and name of the file as the command.

    Friend Sub ShellExecute(ByVal strCommand As String)
        Try
            If AutomationFactory.IsAvailable Then
                Dim shell = AutomationFactory.CreateObject("Shell.Application")
                shell.ShellExecute(strCommand)
            End If
        Catch ex As Exception
            'ignore exceptions
        End Try
    End Sub

    Here's the same code in C#. (How do you cope with all the braces? They drive me nuts.)

    internal void ShellExecute(string strCommand)
        { try 
            {  if (AutomationFactory.IsAvailable) 
                {   dynamic shell = AutomationFactory.CreateObject("Shell.Application");   
                    shell.ShellExecute(strCommand);  
                } 
          } 
         catch (Exception ex) 
             {  //ignore exceptions
             }
        }


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.


    • Edited by Simon Jones [MSDL] Tuesday, July 22, 2014 8:46 AM Added C# translation
    • Marked as answer by tumanovalex Tuesday, July 22, 2014 4:58 PM
    Tuesday, July 22, 2014 8:23 AM
  • 3. If you click the Show All Files button on each project in the Solution Explorer, you'll see all the files that are required for your application to build. The folders on disk will contain more files that are the intermediate and final output of your project as well as the source files. That's why it can appear large.

    When you publish your project it gets compiled and packaged into a XAP file and a few supporting files which are actually quite small.

    It would be unusual to have to post all your code into these forums to get help. More often a description of the problem and a small snippet of code will suffice.


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    • Marked as answer by tumanovalex Tuesday, July 22, 2014 4:58 PM
    Tuesday, July 22, 2014 8:40 AM