Weil Jimmer's BlogWeil Jimmer's Blog


Android Java 程式設計「設定/保存數據」

No Comments
-
發布於 2015-05-17 14:14:56

使用 getSharedPreferences 函數儲存數據。

APP_NAME 改成 想設計的名稱,如:org.twgogo.wbf.Code_.web_browser

    public boolean set_config(String str,String name_){
        SharedPreferences sharedPref = getSharedPreferences("APP_NAME", MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putString(name_, str);
        editor.apply();
        return true;
    }
   public String read_config(String name_){
        SharedPreferences sharedPref = getSharedPreferences("APP_NAME", MODE_PRIVATE);
        return sharedPref.getString(name_,"NULL");
    }

 


This entry was posted in Experience, Functions, Java By Weil Jimmer.

RichTextbox Scroll Smooth 平滑滾動 VB.NET

No Comments
-
發布於 2015-05-13 19:22:04

簡言之,RichTextBox 若裡面包含圖片的話(比如用剪貼簿的方法貼上RTF格式圖片),滾動就會顯得很有問題,不管是用右邊的滾動條上鍵、下鍵移動,或是用滑鼠滾輪滾動,都會「快速跳躍圖片」,意指:把圖片當成「一行文字」看待,尤其是當圖片很長(Height大於RichTextBox的高)的時候,而且又多張圖片,快速滾動就有可能發生,但問題是,我去網路上查很多資料都沒查到有什麼方法可以修正,當然是希望能用一行Code,就解決這個問題,不然滾動圖片「咻」一下就不見了,已經滾到最下面了,根本爛透了。

本方法以Vb.net Code為例,原代碼從網路上查到是 C#.Net,但是原代碼是按下按鈕自動平滑滾到最下面,而我這個是依照滑鼠滾輪而去做上下正常平滑滾動,意思是指修正滑鼠的快速滾動問題,稍微修改了原代碼,原本想貼上引用的地址,不過都關掉網頁,懶得查記錄了,好吧,也算是原創,因為有些還是我自己再添加的。

要先創建一個 Timer,代碼中 ID 為「Scroll_timer」。其餘不解釋,看代碼就明白。

    Private min, max As Integer
    Private pos As Integer = 0
    Private endPos As Integer = 0
    Private Const SB_HORZ As Integer = &H0
    Private Const SB_VERT As Integer = &H1
    Private Const WM_HSCROLL As Integer = &H114
    Private Const WM_VSCROLL As Integer = &H115
    Private Const SB_THUMBPOSITION As Integer = 4
    Private Const WM_SETREDRAW As Int32 = &HB
    Private scroll_speed As Integer = 20

    Private Declare Function SetScrollPos Lib "user32" (hwnd As IntPtr, nBar As Integer, nPos As Integer, bRedraw As Boolean) As Integer
    Private Declare Function GetScrollPos Lib "user32" (hwnd As IntPtr, nBar As Integer) As Integer
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (hwnd As IntPtr, nBar As Integer, wParam As Integer, lParam As Integer) As Integer
    Private Declare Function GetScrollRange Lib "user32" (hwnd As IntPtr, nBar As Integer, ByRef lpMinPos As Integer, ByRef lpMaxPos As Integer) As Boolean
    Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr


    Private Sub Scroll_timer_Tick(sender As Object, e As EventArgs) Handles Scroll_timer.Tick

        GetScrollRange(RichTextBox1.Handle, SB_VERT, min, max)
        max = max - RichTextBox1.ClientSize.Height
        pos = GetScrollPos(RichTextBox1.Handle, SB_VERT)
        Debug.WriteLine("Max=" & max & "--Min=" & min & "--Current=" & pos)
        If Scroll_timer.Tag = "down" Then
            If (pos >= endPos) Then
                Me.Scroll_timer.Enabled = False
                Exit Sub
            End If
            If endPos >= max Then
                endPos = max
            End If
            pos = pos + scroll_speed
            SetScrollPos(RichTextBox1.Handle, SB_VERT, pos, True)
            PostMessage(RichTextBox1.Handle, WM_VSCROLL, SB_THUMBPOSITION + &H10000 * pos, 0)
        Else
            If endPos <= 1 Then
                endPos = 1
            End If
            If (pos <= endPos) Then
                Me.Scroll_timer.Enabled = False
                Exit Sub
            End If
            If (pos - scroll_speed) < 1 Then
                pos = 0
            Else
                pos = pos - scroll_speed
            End If
            SetScrollPos(RichTextBox1.Handle, SB_VERT, pos, True)
            PostMessage(RichTextBox1.Handle, WM_VSCROLL, SB_THUMBPOSITION + &H10000 * pos, 0)
        End If
    End Sub

    Private Sub RichTextBox1_MouseWheel_Click(sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseWheel
        Dim temp As HandledMouseEventArgs = e
        temp.Handled = True
        Dim temp_pos = GetScrollPos(RichTextBox1.Handle, SB_VERT)
        If Scroll_timer.Enabled = True Then
            temp_pos = endPos
        Else
        End If
        If e.Delta > 0 Then
            Debug.WriteLine("Scrolled up!" & e.Delta)
            GetScrollRange(RichTextBox1.Handle, SB_VERT, min, max)
            endPos = temp_pos - e.Delta
            If endPos <= 1 Then
                endPos = 1
            End If
            Debug.WriteLine(endPos)
            Scroll_timer.Tag = "up"
            Me.Scroll_timer.Enabled = True
        Else
            Debug.WriteLine("Scrolled down!" & e.Delta & "--Current: " & temp_pos)
            GetScrollRange(RichTextBox1.Handle, SB_VERT, min, max)
            max = max - RichTextBox1.ClientSize.Height
            If temp_pos + Math.Abs(e.Delta) >= max Then
                endPos = max - 1
            Else
                endPos = temp_pos + Math.Abs(e.Delta) - 1
            End If
            Debug.WriteLine(endPos)
            Scroll_timer.Tag = "down"
            Me.Scroll_timer.Enabled = True
        End If
    End Sub

 


This entry was posted in Functions, VB.NET By Weil Jimmer.

我好…討…厭…家政課

No Comments
-
更新於 2015-05-13 19:11:01

我就直接說白了,不管別人怎麼想。

第一,要自己準備食材,很麻煩!要就學校準備準備就好啊,大不了,學生交材料費。這樣我也可以接受,但是要自己準備?學校就已經夠多考試了,還哪來的時間去幹這種無意義的事情。我寧願寫程式也不想去買食材。尤其是我更不想,向家人討錢,更不想向別人託付去購買什麼跟什麼。

第二,我感覺,有沒有我的存在也沒多大差別。

第三,結束後,又是正課,主科,被家政給拖到,很討厭,還經常遲到!要嫌因為動作慢嗎?我想:如果沒有家政課,就沒有這些鳥事。

跟,體育課差不多,但我還可以容忍體育課。只要不是被老師操就還好。

哀,即使是在班上前幾名也不免引來不少傷感,一點都不因此而感到太多的愉快,也許會因為成績的好而感到開心,不過也只有一下下而已,甚至幾分鐘不到就結束了。

我憂的是將來…憂的是現實……


This entry was posted in Mood By Weil Jimmer.

檔案批量重命名工具

No Comments
-
更新於 2017-04-24 22:44:55

主要功能:

一、可過濾檔案名稱並以資料夾或檔案型式快速取得列表。

二、支援正規表示式語句或一般字串替換成新字串。

三、可複製移動檔案名稱於任意位置插入。

四、可插入/清除任意合法字串於任意位置。

五、可清除全、半形、中英文大小寫、數字、符號。

六、可插入檔案存取、變更、創立時間於任意位置,時間格式自訂。

七、可使檔案名稱數字化,目前支援:a-z、A-Z、a-zA-Z、A-Za-z、羅馬數字、國字(一、二…)、大寫國字(壹、貳…)、2~62進位法,可設定開始數字(可為負數)、與遞增數(可為負數),與支援補滿位數至任意位,本數字化系統支援大數快速運算,不會溢位!

八、可變更副檔名為英文大小寫、題題、反轉、附加設定、轉繁體、轉簡體……等,並可以設定不分開進行命名設置動作。

九、可插入目錄資料夾名稱級數,以,包含插入第一級,第二級…或第一級與第二級,第一級與第二級與第三級……目錄名稱,可以分隔符號分開。

十、包含Mp3文件頭的解析,可以在列表中依TrackNum、Title、Artist、Album、Genre、Year、Duration排序。

更新 - 2015.12.22:

為了Windows XP加入x86版本。

更新 - 2016.08.06:

修復重命名子資料夾下檔案的Bug所造成的錯誤。

更新 - 2017.04.24:

加入新功能,現在可以批量變更檔案名稱由GBK轉BIG。

最新版本:1.0.0.3

下載地址【一】64位元電腦:https://url.weils.net/o

下載地址【一】32位元電腦:https://url.weils.net/j

下載地址【二】64位元電腦:https://my.pcloud.com/publink/show?code=XZp1rAZRmC9fntTQSuzGI00G5mUjLvM4R5X

下載地址【二】32位元電腦:https://my.pcloud.com/publink/show?code=XZW1rAZ0xTdErds0h8HPvfp6pxmvYbzzbdk


This entry was posted in Product, Tools By Weil Jimmer.

檔案分割器

No Comments
-
更新於 2017-01-20 19:48:50

一個檔案切割器,用來切割檔案,支援大小為:GB、MB、KB、B等,選取檔案後,自動創建同名目錄,並在該目錄下進行檔案分割動作,可以選擇分割數量(2~999)或選擇分割大小!

如果估計被分割檔案為1個檔案則不予以分割,並提示用戶該檔過小而不必分割,或檔案過小以致於生成0Byte檔案,則提示無法切割。(0Byte或1Byte將無法分割)本程式會估算切割後大小以及未切割前的原始大小,並估算切割後會生成多少檔案,以及,是否創建Windows批次檔,進行合併,若,不創建,也可以使用本程式的組合功能!

下載地址【一】:https://url.weils.net/e

下載地址【二】:http://cht.tw/h/013pl

產品頁面:http://web.wbftw.org/product/danganfengeqi

By Weil Jimmer


This entry was posted in Product, Tools By Weil Jimmer.

最前頁 上一頁  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /28 頁)下一頁 最終頁

Visitor Count

pop
nonenonenone

Note

台灣假新聞橫行,沒一家霉體能信的,網軍側翼到處洗風向,堪憂。

毋忘初心,
絕不利慾薰心。

支持網路中立性.
Support Net Neutrality.

飽暖思淫欲,
饑寒起盜心。

支持臺灣實施無條件基本收入

歡迎前來本站。

Words Quiz


Search

Music

Blogging Journey

4465days

since our first blog post.

The strong do what they can and the weak suffer what they must.

Privacy is your right and ability to be yourself and express yourself without the fear that someone is looking over your shoulder and that you might be punished for being yourself, whatever that may be.

It is quality rather than quantity that matters.

I WANT Internet Freedom.

Reality made most of people lost their childishness.

Justice,Freedom,Knowledge.

Without music life would be a mistake.

Support/Donate

This site also need a little money to maintain operations, not entirely without any cost in the Internet. Your donations will be the best support and power of the site.
MethodBitcoin Address
bitcoin1gtuwCjjVVrNUHPGvW6nsuWGxSwygUv4x
buymeacoffee
Register in linode via invitation link and stay active for three months.Linode

Support The Zeitgeist Movement

The Zeitgeist Movement

The Lie We Live

The Lie We Live

The Questions We Never Ask

The Questions We Never Ask

Man

Man

THE EMPLOYMENT

Man

In The Fall

In The Fall

Facebook is EATING the Internet

Facebook

Categories

Android (7)

Announcement (4)

Arduino (2)

Bash (2)

C (3)

C# (5)

C++ (1)

Experience (52)

Flash (2)

Free (13)

Functions (36)

Games (13)

General (60)

Git (2)

HTML (7)

Java (13)

JS (7)

Mood (24)

NAS (2)

Note (32)

Office (1)

OpenWrt (6)

PHP (9)

Privacy (4)

Product (12)

Python (4)

Software (11)

The Internet (25)

Tools (16)

VB.NET (8)

WebHosting (7)

Wi-Fi (5)

XML (4)