Tuesday, June 24, 2014

VS2013 finally brought back setup project

http://blogs.msdn.com/b/visualstudio/archive/2014/04/17/visual-studio-installer-projects-extension.aspx

Friday, June 20, 2014

If you move VS2013 project to VS2010 to use the setup project in VS2010

I used VS2013 to do all new projects because the UI for coding has improved a lot. Easier to code.

Then come to the time to create a MSI. I move source code to VS2010.

Create a form on VS2010 and have VS2013 open, select all controls of the form from VS2013 and paste to VS2010 form. Then everything will be copied.

The copy the code over, but all the listbox item selected event code you have to deleted it from the VS2013 code (save it to notepad) then create on VS2010 that event to generate the header code for the item selected event, then paste the code back. Then it will work.

Tuesday, June 17, 2014

HTML5 certification

http://www.microsoft.com/learning/en-us/exam-70-480.aspx

http://thinketg.com/how-to-pass-microsoft-exam-70-480-programming-in-html5-with-javascript-and-css3/

http://www.microsoftvirtualacademy.com/training-courses/learn-html5-with-javascript-css3-jumpstart-training

http://www.microsoftvirtualacademy.com/training-courses/html5-css3-fundamentals-development-for-absolute-beginners#?fbid=pEsRsfL-eIc

http://palermo4.com/

Have you scheduled your exam yet?
Using the DOMjQuery DOM manipulation
Canvas element
Browser storage APIs
Object and variable scope
Prototype functions
Program FlowAJAX
Wiring up events
Exception handling
Web workers
Working with DataConsuming JSON, XML
XMLHttpRequest
Serializing data
JavaScript validation
HTML input type validation
Regular Expressions
CSS FeaturesFlexible layouts and adaptive UI
Screen size targeting
2D and 3D Transforms
Ways to show/hide controls
Inheritance
Pseudo-classes

Strip double quotes from a string in .NET

I think your first line would actually work but I think you need four quotation marks for a string containing a single one (in VB at least):
s = s.Replace("""", "")
for C# you'd have to escape the quotation mark using a backslash:
s = s.Replace("\"", "");

http://stackoverflow.com/questions/1177872/strip-double-quotes-from-a-string-in-net

Run task scheduler with admin right

Navigate to Start -> Administrative Tools -> Task Scheduler, hold down the Shift key and do a right mouse click 

Angular js tutorial

AngularJS Fundamentals In 60-ish Minutes: http://youtu.be/i9MHigUZKEM

Monday, June 16, 2014

C# debugger attached

if(System.Diagnostics.Debugger.IsAttached)
{
    // ...
}

Pluralsight Web front end development



add msn for search




control shift I to open browser console (or just use F12)






Shift enter to continue a line


Saturday, June 14, 2014

Android Activity step by step

#9 Android Activity Lifecycle Part 1












How to import picture or image to blogger - use Google doc way

I need to do lots of picture shots and put on blogger. So I use Snagit to take to picture the save to the hard drive, then get in blogger editor, click on insert image, then choose file, then save it.

It really takes to much time.....need to find a better way.

Did a little research
one links says save to Word doc and upload to Google doc, but still too many steps.

Easier step is

1. Set up a profile in Snagit to have image captured to clipboard, the paste to a open Google doc, then from Google doc copy and paste to Blogger compose editor.

Easy and fast.

Android Hello World step by step
















#7 Hello World Android Example Explained Part 3: 














Android Color definitions



http://developer.android.com/reference/android/graphics/Color.html#BLACK

Android RelativLayout - below


Friday, June 13, 2014

Android Add viewserver

download ViewServer.java from below


click on Raw and copy whole thing

add java to project, fix the package

add internet permission to project
add  ViewServer in activity

In sample project get the 3 code section below



Android add internet permission to project


Visual studio 2013 change setup project install directory

It is hard to find where to change the install direcotory. You do it in General information.


Add setup project to visual studio 2013


C# run DOS command prompt

 Util myUtil = new Util();
         myUtil.ExecTask("ping", "10.99.10.101");
         string sOut = myUtil.SOutput.ToString();
         string sErr = myUtil.SErrOutput.ToString();  


   public class Util
   {
      StringBuilder m_sOutput;

      public StringBuilder SOutput
      {
         get { return m_sOutput; }
         set { m_sOutput = value; }
      }
      StringBuilder m_sErrOutput;

      public StringBuilder SErrOutput
      {
         get { return m_sErrOutput; }
         set { m_sErrOutput = value; }
      }
      Process mProcess;

      public void ExecTask(string sCmd, string sArgs)
      {
         m_sOutput = new StringBuilder();
         m_sErrOutput = new StringBuilder();
         // Setup the process start info
         var processStartInfo = new ProcessStartInfo(sCmd, sArgs)
         {
            UseShellExecute = false,
            RedirectStandardOutput = true,
            RedirectStandardError = true
         };

         // Setup the process
         mProcess = new Process { StartInfo = processStartInfo, EnableRaisingEvents = true };

         // Register event
         mProcess.OutputDataReceived += OnOutputDataReceived;
         mProcess.ErrorDataReceived += OnErrorDataReceived;

         // Start process
         mProcess.Start();
         mProcess.BeginOutputReadLine();
         mProcess.BeginErrorReadLine();
         mProcess.WaitForExit();
      }

      void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
      {
         m_sOutput.AppendLine(e.Data);
      }

      void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
      {
         m_sErrOutput.AppendLine(e.Data);
      }
   }

C# Delegates, Actions, Funcs, Lambdas

http://blogs.msdn.com/b/brunoterkaly/archive/2012/03/02/c-delegates-actions-lambdas-keeping-it-super-simple.aspx

Visual studio Ultimate modeling

http://s.ch9.ms/Series/Visual-Studio-2012-Premium-and-Ultimate-Overview/Visual-Studio-Ultimate-2012-Improving-architecture-through-modeling

http://blogs.msdn.com/b/jennifer/archive/2010/05/13/visual-studio-2010-how-to-maintain-control-of-your-code-using-layer-diagrams-custom-msbuild-tasks-and-work-item-integration.aspx

Android viewpager adpator step by step Slidenerd video





Thursday, June 12, 2014

delete team project from visual studio online

http://social.msdn.microsoft.com/Forums/en-US/12ebeee4-e6d1-4b1c-bc01-2887f3b477b1/how-do-i-delete-a-project-created-in-visualstudio-online?forum=TFService

You have to right click to see the "delete" showing up.

Monday, June 9, 2014

Android Fragment communication


1. create interface
2. implement in main activity
3. add respond method
4. in respond method call fragment 2
5. in fragment B do change data
6. in fragment A define Communicator
7 initiate Communicator
8 onclick call respond, which pass data to Mainactivity because Main Activity implement Communicator
9 call fragment B respond
10 call fragment  change data
11. in fragment B do change data

TFS command line to display who checked out files, find file

tf status to show who checked out

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>
tf status $/ /user:* /recursive > e:\MyPendingCheckouts.txt /s:"http://YourTFSServerName:8080/tfs/YourCollectionName"

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC> you have to open and VS command line

/user:*   you need * to show all users

 e:\MyPendingCheckouts.txt is the file to contain all outputs.

/s:"http://YourTFSServerName:8080/tfs/YourCollectionName" showing the source of TFS

tf dir /recursive $/
you can pass in the item you are searching for also e.g.
tf dir /recursive $/*.cs
gets all the .cs files in all team projects


if you see error below:
http://stackoverflow.com/questions/13358244/tf-exe-history-getting-unable-to-determine-the-source-control-server

You need to add yellow highight to your command
/s:"http://YourTFSServerName:8080/tfs/YourCollectionName"



C# Send text to a open command prompt

http://stackoverflow.com/questions/5929152/send-string-to-command-prompt-cmd-from-windows-form-application-using-sendmess

 [DllImport("user32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr i);

        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        IntPtr hWnd = FindWindow(null, "Untitled - Notepad");

        [DllImport("user32.dll", SetLastError = true)]
        static extern bool PostMessage(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] uint Msg, IntPtr wParam, IntPtr lParam);


        [DllImport("user32.dll", SetLastError = true)]
        static extern bool PostMessage(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] uint Msg, int wParam, int lParam);

        const int WM_KEYDOWN = 0x0100;
        const int WM_KEYUP = 0x0101;
        const int WM_CHAR = 0x0102;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll")]
        static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);

        private const UInt32 WM_CLOSE = 0x0010;

        //public static IntPtr cmdHwnd = IntPtr.Zero;
        public static List<IntPtr> cmdHwnd = new List<IntPtr>();
     


// get all command prompt window handles to a listbox1
 public void GetWindowHandles()
        {
            listBox1.Items.Clear();
            cmdHwnd.Clear();
            foreach (IntPtr child in GetChildWindows(FindWindow(null, "WinPlusConsole")))
            {
                StringBuilder sb = new StringBuilder(100);
                GetClassName(child, sb, sb.Capacity);

                if (sb.ToString() == "ConsoleWindowClass")
                {
                    cmdHwnd.Add(child);
                    listBox1.Items.Add(child);
                }
            }
            m_iCnt = cmdHwnd.Count;
        }

//send command to a open command prompt window, cmdHwnd[0] has the window's handle
  private void btnCommand_Click(object sender, EventArgs e)
        {
            uint wparam = 0 << 29 | 0;
            string msg = textBox1.Text;
            int i = 0;
            for (i = 0; i < msg.Length; i++)
            {
                //PostMessage(child, WM_KEYDOWN, (IntPtr)Keys.Enter, (IntPtr)wparam);
                PostMessage(cmdHwnd[0], WM_CHAR, (int)msg[i], 0);
            }
            PostMessage(cmdHwnd[0], WM_KEYDOWN, (IntPtr)Keys.Enter, (IntPtr)wparam);
        }

      /// <summary>
        /// Returns a list of child windows
        /// </summary>
        /// <param name="parent">Parent of the windows to return</param>
        /// <returns>List of child windows</returns>
        public static List<IntPtr> GetChildWindows(IntPtr parent)
        {
            List<IntPtr> result = new List<IntPtr>();
            GCHandle listHandle = GCHandle.Alloc(result);
            try
            {
                EnumWindowProc childProc = new EnumWindowProc(EnumWindow);
                EnumChildWindows(parent, childProc, GCHandle.ToIntPtr(listHandle));
            }
            finally
            {
                if (listHandle.IsAllocated)
                    listHandle.Free();
            }
            return result;
        }

        /// <summary>
        /// Callback method to be used when enumerating windows.
        /// </summary>
        /// <param name="handle">Handle of the next window</param>
        /// <param name="pointer">Pointer to a GCHandle that holds a reference to the list to fill</param>
        /// <returns>True to continue the enumeration, false to bail</returns>

        private static bool EnumWindow(IntPtr handle, IntPtr pointer)
        {
            GCHandle gch = GCHandle.FromIntPtr(pointer);
            List<IntPtr> list = gch.Target as List<IntPtr>;
            if (list == null)
            {
                throw new InvalidCastException("GCHandle Target could not be cast as List<IntPtr>");
            }
            list.Add(handle);
            // You can modify this to check to see if you want to cancel the operation, then return a null here
            return true;
        }

        /// <summary>
        /// Delegate for the EnumChildWindows method
        /// </summary>
        /// <param name="hWnd">Window handle</param>
        /// <param name="parameter">Caller-defined variable; we use it for a pointer to our list</param>
        /// <returns>True to continue enumerating, false to bail.</returns>
        public delegate bool EnumWindowProc(IntPtr hWnd, IntPtr parameter);


  private void btnOponWindow_Click(object sender, EventArgs e)
        {
            try
            {
                int iNo = 0;
                iNoOfWindows = iNoOfBatCmds;
                GetWindowHandles();
                if (m_iCnt > 0)
                {
                    if (iNoOfWindows > m_iCnt)
                    {
                        iNo = iNoOfWindows - m_iCnt;
                    }
                }
                else
                {
                    iNo = iNoOfWindows;
                }

                for (int i = 0; i < iNo; i++)
                {

                    // create the ProcessStartInfo using "cmd" as the program to be run,
                    // and "/c " as the parameters.
                    // Incidentally, /c tells cmd that we want it to execute the command that follows,
                    // and then exit.
                    System.Diagnostics.ProcessStartInfo procStartInfo =
                    new System.Diagnostics.ProcessStartInfo("cmd", "/K ");

                    // The following commands are needed to redirect the standard output.
                    // This means that it will be redirected to the Process.StandardOutput StreamReader.
                    //procStartInfo.RedirectStandardOutput = true;
                    procStartInfo.UseShellExecute = true;
                    // Do not create the black window.
                    procStartInfo.CreateNoWindow = false;
                    // Now we create a process, assign its ProcessStartInfo and start it
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo = procStartInfo;
                    //ThreadStart ths = new ThreadStart(delegate() { proc.Start(); });
                    proc.Start();
                    //proc.WaitForExit();
                }
            }
            catch (Exception objException)
            {
                Console.WriteLine(objException);
            }
            finally
            {
                GetWindowHandles();
            }
        }


   private void btnHello_Click(object sender, EventArgs e)
        {
            uint wparam = 0 << 29 | 0;
            string msg = "Hello";
            int i = 0;
            for (i = 0; i < msg.Length; i++)
            {
                //PostMessage(child, WM_KEYDOWN, (IntPtr)Keys.Enter, (IntPtr)wparam);
                //PostMessage(cmdHwnd[0], WM_CHAR, (int)msg[i], 0);
                PostMessage((IntPtr)listBox1.Items[0], WM_CHAR, (int)msg[i], 0);
            }
            PostMessage((IntPtr)listBox1.Items[0], WM_KEYDOWN, (IntPtr)Keys.Enter, (IntPtr)wparam);
        }