달력

42025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
반응형

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
 
namespace App11BackButton
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }
 
        protected override bool OnBackButtonPressed()
        {
            Device.BeginInvokeOnMainThread(async () =>
            {                
                if (await this.DisplayAlert("알림!""닫을래?""Yes""No"))
                {                    
                    System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow();
                }
            });            
            return true;
        }
    }
}
 
cs


실행

 


참조 : http://ionemind.com/content/exit-ios-and-android-mobile-app-xamarin


다른데는 Dependency써서 하라고 되어있는데 간단하게 되네....자마린은 역시 머가 먼지 모르겠다.


'프로그래밍 > xamarin' 카테고리의 다른 글

[xamarin]팝업창-AbsoluteLayout  (0) 2018.07.08
[xamarin]Lottie Animation  (0) 2018.06.10
[xamarin]CustomRenderers  (0) 2018.06.03
[xamarin]Alert Dialog  (0) 2018.05.27
[xamarin] Profile UI Design  (0) 2018.05.20
Posted by 유령회사
|
반응형


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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;
 
namespace App2StringImage
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(this.pictureBox1.Width
                                     , this.pictureBox1.Height);
 
            using(Graphics gr = Graphics.FromImage(bitmap))
            {
                gr.Clear(this.pictureBox1.BackColor);
 
                if(textBox1.Text.Trim().Length > 0
                { 
                    using(Brush brush = new SolidBrush(this.textBox1.ForeColor))
                    {                    
                        SizeF size = gr.MeasureString(this.textBox1.Text
                                                    , this.textBox1.Font);
                        for (float y = 0; y < bitmap.Height; y += size.Height * 1.5f)
                        {
                            float x = y;
                            while(x > 0) x -= size.Width;
 
                            while (x <= bitmap.Width)
                            {
                                gr.DrawString(this.textBox1.Text
                                            , this.textBox1.Font
                                            , brush, x, y);
                                x += size.Width;
                            }
                        }
                    }
                }
                pictureBox1.Image = bitmap;
            }            
        }
    }
}
 
cs

실행


'프로그래밍 > C#' 카테고리의 다른 글

[C#]동그란 이미지 만들기  (0) 2018.07.01
[C#] 유닉스시간 <> 윈도우시간 변환 함수  (0) 2018.06.27
[C#]투명한 버튼  (0) 2018.06.16
[C#]AnimateWindow  (0) 2018.06.13
[C#]폼을 투명하게  (0) 2018.04.14
Posted by 유령회사
|
반응형

자바스크립트에 trim이 없다는 사실을 첨 알았다 ㅠ


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        function trim(str) 
        {
            return str.replace(/(^\s*)|(\s*$)/gi, '');
        }
 
        String.prototype.trim = function()
        {
            return this.replace(/(^\s*)|(\s*$)/gi, '');
        };
  </script>
</head>
<body>
    <script>    
        document.write("@" + trim("  method  "+"@");
  </script>
    <br/>
    <br/>
    <script>        
        document.write("@" + "  prototype  ".trim() + "@");
  </script>
</body>
</html>
cs

실행


'프로그래밍 > Web' 카테고리의 다른 글

[Jquery]dom 선택자  (0) 2018.08.01
[Jquery]선택자 - 속성  (0) 2018.07.26
[Jquery]선택자  (0) 2018.07.25
[Jquery]ready, load  (0) 2018.07.17
[Web]ScrollIndicator  (0) 2018.07.13
Posted by 유령회사
|
반응형



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
 
namespace App1ButtonImage
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            SetButtonBackImage(button1);
            SetButtonBackImage(button2);
            SetButtonBackImage(button3);
            SetButtonBackImage(button4);
            SetButtonBackImage(button5);
            SetButtonBackImage(button6);            
        }
 
        private void SetButtonBackImage(Button button)
        {
            Point ptImg = new Point(00);
            ptImg = this.PointToScreen(ptImg);
 
            Point ptBtn = new Point(00);
            ptBtn = button.PointToScreen(ptBtn);
 
            int intXOffset = ptBtn.X - ptImg.X;
            int intYOffset = ptBtn.Y - ptImg.Y;
 
            Bitmap bitmap = new Bitmap(button.ClientSize.Width
                                               , button.ClientSize.Height);
            using (Graphics gr = Graphics.FromImage(bitmap))
            {
                Rectangle btn_rect = new Rectangle(00, button.ClientSize.Width
                                                      , button.ClientSize.Height);
                Rectangle src_rect = new Rectangle(intXOffset, intYOffset
                                                 , button.ClientSize.Width
                                                 , button.ClientSize.Height);
 
                gr.DrawImage(this.BackgroundImage, btn_rect, src_rect, GraphicsUnit.Pixel);
            }
 
            button.BackgroundImage = bitmap;
        }
    }
}
 
cs

몇 픽셀 정도 차이나는데 어차피 이런 코딩할일이 없으니 패스

실행



Posted by 유령회사
|
반응형

오라클이 설치하기 싫어서 실행장면은 스샷 없음 ㅠ


1
2
3
4
5
6
SELECT 
regexp_replace(LISTAGG( 필드 || ',' ) 
                            WITHIN GROUP ( ORDER BY 정렬기준 필드)
                          ,  '([^,]+)(,\1)+''\1')
FROM T
 
cs


Posted by 유령회사
|
반응형

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
 
namespace AnimateWindow
{
    class WinAPI
    {
        public const int AW_ACTIVATE = 0x20000//창을 활성화 AW_HIDE와 함께 사용하지 마십시오.
        public const int AW_BLEND = 0X80000;    // 페이드 효과
        public const int AW_CENTER = 0X10// AW_HIDE 가 사용 되면 윈도우가 안쪽으로 축소 되거나 AW_HIDE 가 사용 되지 않으면 바깥 쪽으로 펼쳐지 도록 만듭니다 .
        public const int AW_HIDE = 0x10000// 창을 숨 깁니다.기본적으로 창이 표시됩니다.
        public const int AW_HOR_POSITIVE = 0X1//윈도우를 왼쪽에서 오른쪽으로 애니메이션
        public const int AW_HOR_NEGATIVE = 0X2//창을 오른쪽에서 왼쪽으로 애니메이션
        public const int AW_SLIDE = 0x40000//창을 오른쪽에서 왼쪽으로 애니메이션
        public const int AW_VER_POSITIVE = 0X4//창을 위에서 아래로 애니메이션
        public const int AW_VER_NEGATIVE = 0X8//창을 아래에서 위로 애니메이션화
 
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int AnimateWindow(IntPtr hwand, int dwTime, int dwFlag);
 
        //BOOL WINAPI AnimateWindow (_In_HWND hwnd,_In_ DWORD dwTime,_In_ DWORD dwFlags);
        
        //매개 변수
        //hwnd[in]
        //유형 : HWND
        //애니메이션을 적용 할 창의 핸들.호출 스레드가이 윈도우를 소유하고 있어야합니다.
        
        //dwTime[in]
        //형식 : DWORD
        //밀리 초 단위로 애니메이션을 재생하는 데 걸리는 시간입니다.일반적으로 애니메이션은 재생할 때 200 밀리 초가 걸립니다.
 
        //dwFlags[in]
        //형식 : DWORD
        //애니메이션의 유형.이 매개 변수는 다음 값 중 하나 이상일 수 있습니다. 
        //기본적으로이 플래그는 창을 표시 할 때 적용됩니다.
        //창을 숨길 때 적용하려면 적절한 플래그와 함께 AW_HIDE 와 논리 OR 연산자를 사용하십시오.
    }
}
 
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
 
namespace AnimateWindow
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;            
        }
 
        private void btnAW_ACTIVATE_Click(object sender, EventArgs e)
        {
            WinAPI.AnimateWindow(this.Handle, 2000, WinAPI.AW_CENTER | WinAPI.AW_HIDE);
            this.Close();
        }
    }
}
 
cs



실행

 

 


Posted by 유령회사
|
반응형


파일구조

Nuget설치해주시고
Install-Package Com.Airbnb.Xamarin.Forms.Lottie

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App9Animation"
             xmlns:forms="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
             x:Class="App9Animation.MainPage">
 
    <StackLayout Padding="30">
        <Button x:Name="BtnLogin" 
                Text="Login" 
                BorderColor="#CB9600" 
                BackgroundColor="#F4B400" />
        <forms:AnimationView 
                x:Name="AnimationView"
                Animation="LottieLogo1.json"
                Loop="True"
                AutoPlay="True"
                VerticalOptions="FillAndExpand"
                HorizontalOptions="FillAndExpand"/>
    </StackLayout>
 
</ContentPage>
 
cs

MainPage.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
 
namespace App9Animation
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
 
            this.AnimationView.IsVisible = false;
            this.BtnLogin.Clicked += BtnLogin_Clicked;
        }
 
        private void BtnLogin_Clicked(object sender, EventArgs e)
        {
            this.AnimationView.IsVisible = true;
        }
    }
}
 
cs


MainActivity.cs

using System;
 
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Lottie.Forms.Droid;
 
namespace App9Animation.Droid
{
    [Activity(Label = "App9Animation", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {            
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;
 
            base.OnCreate(bundle);
 
            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
 
            AnimationViewRenderer.Init();
        }
    }
}
 
cs


안드로이드에 AnimationViewRenderer.Init();추가

IOS도 추가해야 한다고 하는데 맥이 없는 관계로 ㅠ


사용한 애니메이션 파일

LottieLogo1.json



실행

  


참조

https://github.com/martijn00/LottieXamarin


https://www.lottiefiles.com/



Lottie는 iOS 및 Android 용 Airbnb에서 만든 모바일 애니메이션 라이브러리로 Adobe After Effects 애니메이션 (JSON으로 내 보낸)을 파싱하고 기본 애니메이션 API를 사용하여 렌더링한다고 한다.


'프로그래밍 > xamarin' 카테고리의 다른 글

[xamarin]팝업창-AbsoluteLayout  (0) 2018.07.08
[xamarin]어플 닫기 전에 물어보고 닫기  (0) 2018.06.24
[xamarin]CustomRenderers  (0) 2018.06.03
[xamarin]Alert Dialog  (0) 2018.05.27
[xamarin] Profile UI Design  (0) 2018.05.20
Posted by 유령회사
|
반응형

파일구조


MainPage.xaml 작성 해주고
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
             xmlns:local="clr-namespace:App8CustomRenderers;assembly=App8CustomRenderers"
             x:Class="App8CustomRenderers.MainPage">
 
    <StackLayout VerticalOptions="CenterAndExpand" 
                              HorizontalOptions="CenterAndExpand">
        <Label Text="Hello, Custom Renderer!" />
        <local:MyEntry Text="In Shared Code" />
    </StackLayout>
 
</ContentPage>
 
cs


Forms에 커스텀 할 Entry 적어줌

1
2
3
4
5
6
7
8
9
10
11
12
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
 
namespace App8CustomRenderers
{
    public class MyEntry : Entry
    {
    }
}
 
cs

IOS 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App8CustomRenderers;
using App8CustomRenderers.iOS;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
 
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace App8CustomRenderers.iOS
{
    public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
 
            if (Control != null)
            {
                // do whatever you want to the UITextField here!
                Control.BackgroundColor = UIColor.FromRGB(204153255);
                Control.BorderStyle = UITextBorderStyle.Line;
            }
        }
    }
}
cs

안드로이드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using App8CustomRenderers;
using App8CustomRenderers.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
 
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace App8CustomRenderers.Droid
{
    class MyEntryRenderer : EntryRenderer
    {
        public MyEntryRenderer(Context context) : base(context)
        {
        }
 
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
 
            if (Control != null)
            {
                Control.SetBackgroundColor(global::Android.Graphics.Color.LightGreen);
            }
        }
    }
}
cs


각각 플랫폼에 ExportRenderer를 이용하서 각 플렛폼에 해당하는 프로젝트들이 동작한다.


실행



따라한 소스는 https://developer.xamarin.com/samples/xamarin-forms/CustomRenderers/Entry/


'프로그래밍 > xamarin' 카테고리의 다른 글

[xamarin]어플 닫기 전에 물어보고 닫기  (0) 2018.06.24
[xamarin]Lottie Animation  (0) 2018.06.10
[xamarin]Alert Dialog  (0) 2018.05.27
[xamarin] Profile UI Design  (0) 2018.05.20
[xamarin]로그인화면  (0) 2018.05.13
Posted by 유령회사
|
반응형

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
public class TestToString {
 
    public static void main(String[] args) 
    {
        String str = null;
        Integer intValue = null;
        
        // null을 대입하면 null이란 문자열을 준다.        
        System.out.println(String.valueOf(str));             
           
        // null을 대입하면 null이란 문자열을 준다.
        System.out.println(String.valueOf(intValue)); 
        
        try 
        {
            // toString()은 NullPointerException발생
            System.out.println(str.toString());
        }
        catch (NullPointerException e) 
        {
            System.out.println("NullPointerException발생");
        }
        
        // 이런식으로 쓰면 null을 스페이스로 돌려받을 수 있겠군...
        //(개인적으로 null을 싫어함)
        System.out.println("ToStringEx : " + ToStringEx(str)); 
    }
    
    private static String ToStringEx(Object str)
    {                
        return String.valueOf(str == null ? "" : str);
    }
}
 
cs


출력

null

null

NullPointerException발생

ToStringEx : 


'프로그래밍 > Java' 카테고리의 다른 글

[Java]BigDecimal 올림 반올림 버림  (0) 2018.08.04
[Java]Spring 한글설정  (0) 2018.07.09
[Java]String, StringBuffer, StringBuilder  (0) 2018.07.07
[Java] Calendar  (0) 2018.05.23
[Java]SimpleDateFormat  (0) 2018.05.20
Posted by 유령회사
|
반응형

 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App4AlertDialog"
             x:Class="App4AlertDialog.MainPage">
 
    <ContentPage.Content>
        <StackLayout HorizontalOptions="CenterAndExpand"
                     VerticalOptions="CenterAndExpand">
            <Entry Placeholder="School Home-Ground"/>
            <Button x:Name="myBtn"
                    Text="Click To Enter"
                    BackgroundColor="White"
                    Image="clicking.png"/>
        </StackLayout>
    </ContentPage.Content>
 
</ContentPage>
 
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
 
namespace App4AlertDialog
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            this.myBtn.Clicked += MyBtn_Clicked;
        }
 
        private void MyBtn_Clicked(object sender, EventArgs e)
        {
            DisplayAlert("타이틀""메세지""Yes""No");
        }
    }
}
 
cs


http://xamaringuyhome.blogspot.kr/2017/10/xamarin-forms-alert-dialog-tutorial-23.html

'프로그래밍 > xamarin' 카테고리의 다른 글

[xamarin]어플 닫기 전에 물어보고 닫기  (0) 2018.06.24
[xamarin]Lottie Animation  (0) 2018.06.10
[xamarin]CustomRenderers  (0) 2018.06.03
[xamarin] Profile UI Design  (0) 2018.05.20
[xamarin]로그인화면  (0) 2018.05.13
Posted by 유령회사
|