2015년 5월 12일 화요일

League of legends. Rek'Sai Jungle play movie. chalanger rank korean gamer.

C# string.format example. focus printing numeric.

//Hexacode
String.Format("{0:X}", Convert.ToInt32(letter));

String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"

String.Format("{0:0.##}", 123.4567);      // "123.46"
String.Format("{0:0.##}", 123.4);         // "123.4"
String.Format("{0:0.##}", 123.0);         // "123"

String.Format("{0:00.0}", 123.4567);      // "123.5"
String.Format("{0:00.0}", 23.4567);       // "23.5"
String.Format("{0:00.0}", 3.4567);        // "03.5"
String.Format("{0:00.0}", -3.4567);       // "-03.5"

//thousand ,
String.Format("{0:0,0.0}", 12345.67);     // "12,345.7"
String.Format("{0:0,0}", 12345.67);       // "12,346"

//case by case 0
String.Format("{0:0.0}", 0.0);            // "0.0"
String.Format("{0:0.#}", 0.0);            // "0"
String.Format("{0:#.0}", 0.0);            // ".0"
String.Format("{0:#.#}", 0.0);            // ""

//text include blank
String.Format("{0,10:0.0}", 123.4567);    // "     123.5"
String.Format("{0,-10:0.0}", 123.4567);   // "123.5     "
String.Format("{0,10:0.0}", -123.4567);   // "    -123.5"
String.Format("{0,-10:0.0}", -123.4567);  // "-123.5    "

//{0: 0<; 0>; 0==}
String.Format("{0:0.00;minus 0.00;zero}", 123.4567);   // "123.46"
String.Format("{0:0.00;minus 0.00;zero}", -123.4567);  // "minus 123.46"
String.Format("{0:0.00;minus 0.00;zero}", 0.0);        // "zero"

String.Format("{0:my number is 0.0}", 12.3);   // "my number is 12.3"
String.Format("{0:0aaa.bbb0}", 12.3);          // "12aaa.bbb3"

Mario Kart 7, All character, Kart, Item

Character


Kart

Items

Example for excel document with using C#

1. Excel document creation
2. Cells of A1 ~ G1 merge
3. wrtie text "C# Excel Creation"
4. set bold font
5. draw the box line

IDE : Microsoft Visual Studio 2005

At first, include Excel Library.


full source
=================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Runtime.InteropServices;

namespace ExcelExample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
//create Excel application
Excel.Application oXL = new Excel.Application();

//if set true, can see excel doc during creating
oXL.Visible = true;    

//must option. if set ture, it is possible to break from user's action
oXL.Interactive = false;  

Excel._Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
Excel._Worksheet oSheet = (Excel._Worksheet)oWB.ActiveSheet;
Excel.Range oRng = null;  

//get cells
oRng = oSheet.get_Range("B2", "H2");

oRng.MergeCells = true;

//set text
oRng.Value2 = "C# Excel Creation";  
oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
oRng.Font.Bold = true;
oRng.Font.Color = -16776961;

//box line
oRng.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous;
oRng.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous;
oRng.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous;
oRng.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;

oXL.Interactive = true;

//clear object
Marshal.ReleaseComObject(oXL);
Marshal.ReleaseComObject(oWB);
Marshal.ReleaseComObject(oSheet);

//excute GC
GC.Collect();
}
catch (Exception eExcep)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, eExcep.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, eExcep.Source);
MessageBox.Show(errorMessage.ToString());
}
}
}
}

using json on php

PHP5.3 , JSON

Example.php
================================================================
<?
require_once('inc/connect.php'); // your connect information

//sample query
$query = "SELECT * FROM TABLE1 WHERE 1 ";
$result = mysqli_query($link,$query);

$result_array = array();

while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) ){
$result_array[] = $row;
};

// encode to json
$result_array = json_encode( $result_array );

// print result
echo $_GET['callback'] . '(' .$result_array. ')';

mysqli_free_result($result);
mysqli_close($link);
?>

C#, using ini file example

IDE : Microsoft Visual Studio 2005


Full source
=================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;

namespace IniFileExample
{
public partial class Form1 : Form
{
[DllImport("kernel32")]
public static extern bool WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

public Form1()
{
InitializeComponent();
}

public string GetIniValue(string section, string key, string filePath)
{
StringBuilder temp = new StringBuilder(255);
GetPrivateProfileString(section, key, "", temp, 255, filePath);
return temp.ToString();
}

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
string sIniPath =
System.Reflection.Assembly.GetExecutingAssembly().Location.ToLower().Replace(".exe", ".ini");
WritePrivateProfileString(this.Name, textBox1.Name, textBox1.Text, sIniPath);
WritePrivateProfileString(this.Name, textBox2.Name, textBox2.Text, sIniPath);
WritePrivateProfileString(this.Name, checkBox1.Name, checkBox1.Checked.ToString(), sIniPath);
}

private void Form1_Shown(object sender, EventArgs e)
{
string sIniPath =
System.Reflection.Assembly.GetExecutingAssembly().Location.ToLower().Replace(".exe", ".ini");
textBox1.Text = GetIniValue(this.Name, textBox1.Name, sIniPath);
textBox2.Text = GetIniValue(this.Name, textBox2.Name, sIniPath);
checkBox1.Checked =
GetIniValue(this.Name, checkBox1.Name, sIniPath).ToLower() == "true" ? true : false;
}

}
}

angularjs example source. call php service.

PHP5.3 , angular.js

index.html
================================================================
<!doctype html>

<head>
    <title>TEST</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-COMPATIBLE" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <script src="angular.js"></script>
    <script src="myService.js"></script>

    <link rel="stylesheet" href="angul.css">
</head>


    <div class="mainContainer" data-ng-app="myApp">
        <h1>Example</h1>

        <div data-ng-controller="search_ctrl">
       
            <input type="text" data-ng-model="val1">
           
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>name</th>
                        <th>phone</th>
                        <th>note</th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="row in rows | filter:val1 | orderBy:'DEV_NAME' | limitTo: 10">
                        <td>{{row.DEV_NAME}}</td>
                        <td>{{row.DEV_TEL}}</td>
                        <td>{{row.DEV_MEMO}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div data-ng-controller="insert_ctrl">
            <input type="text" data-ng-model="key_name">
            <input type="text" data-ng-model="key_tel">
            <input type="text" data-ng-model="key_memo">
            <hidden type="text" data-ng-model="message">
            <button data-ng-click="insertValue()">insert</button>
            <hr>
            {{message}}
        </div>
    </div>
==================================================================


myService.js
==================================================================
/* use strict */
var app = angular.module("myApp", []);

app.controller("search_ctrl", function ($scope, $http)
{
    var request = $http({
        method: "post",
        url: "http://yours php url",
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    });

    /* Check whether the HTTP Request is successful or not. */
    request.success(function (data) {
        $scope.rows = data;
    });
})

app.controller("insert_ctrl", function ($scope, $http){
   
    $scope.insertValue = function () {
        var request = $http({
            method: "post",
            url: "http://yours php url" + $scope.key_name + "&" + $scope.key_tel,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });

        /* Check whether the HTTP Request is successful or not. */
        request.success(function (data) {
            $scope.message = data;
        });
    }
})
==================================================================