2013年3月16日土曜日

Pictures Slide Viewer + Un Zip を公開


指定したフォルダ内の画像ファイルを閲覧、スライドショー表示するソフトです。
Zip ファイルを解凍する機能を追加しました。

使い方
追加 : フォルダーを指定すると、指定したフォルダーとそのサブフォルダー内の
      画像ファイル(JPG,GIF,BMP,PNG)が再生リストに追加せれます。
全削除 : 再生リストから全項目が削除されます。ファイル自体は削除されません。
再生リストの項目クリック : クリックした項目が選択され、画像が表示されます。
再生リストの項目ダブルクリック : 選択された項目を再生リストから削除します。
Un Zip : フォルダーを指定すると、指定したフォルダーとそのサブフォルダー内の
       Zip ファイルをファイル名と同じフォルダーを作成しそこに解凍
       解凍した画像ファイルを再生リストに追加します。
再生 : 再生リストの項目をエンドレスに、スライドショーで表示します。
      表示間隔を、500ミリ秒間隔で指定できます。
停止 : スライドショーを停止します。
次へ : 再生リストの次の項目を表示します。
前へ : 再生リストの前の項目を表示します。
画像表示領域をクリック : 全画面表示に切り替えます。
                  もう一度クリックで通常表示に戻ります。
全画面表示時にマウスカーソル(非表示になっています)を下まで持っていくと
再生ボタンなどが表示されます。
終了 : Pictures Slide Viewer + Un Zip を終了します。
      再生リストとスライドショー表示間隔は保存され
      次回起動時に読み込まれます。



Pictures Slide Viewer + Un Zip (PSVPUZ.exe)
Windows8 Desktop Application ( C# )

SkyDrive を使って公開します。

このリンクから >>> http://sdrv.ms/RZaKds

SkyDrive の公開フォルダが開くので
PSVPUZ.zip を適当なフォルダにダウンロード後、ファイルを展開、setup.exe を実行し
インストーラの指示に従って、インストールしてください。
インストーラは、ClickOnce を使用しています。

[Windows によって PC が保護されました] が表示された場合
[詳細情報] をクリック、つづいて [実行] をクリックしてください。

インストールが成功すれば、Win8 の場合 スタート の画面に Pictures Slide Viewer 
のタイルがピン留めされますので、そこから起動できます。

デスクトップにショートカットを置きたい場合は、スタート の画面で右クリック
すべてのアプリ をクリックし、Pictures Slide Viewer を右クリックで選択
ファイルの場所を開く をクリック、エクスプローラーが開くので、Pictures Slide Viewer
を右クリック、ショートカットメニューから、送る > デスクトップ(ショートカット作成)を
選択してください。

アンインストールは、コントロールパネルのプログラムのアンインストールから
Pictures Slide Viewer をアンインストールしてください。

2013年3月14日木曜日

Visual Basic PowerPacks 10.0 が ClickOnce でインストールできない件



以前公開した Copy text to clipboard ( CopyTtCb.exe ) は
インストーラーとして Visual Studio の 発行 ( ClickOnce ) を使用しました。

ところが、これをインストールしようとすると、Microsoft Visual Basic PowerPacks 10.0 が
予めインストールされていないと、途中で VB PowerPacks をインストールしようとし
そこでエラーが発生し、インストールに失敗してしまうことが分かりました。

MS Visual Studio がインストールされていると、一緒に VB PowerPacks もインストール
されているので、気が付きませんでした。

エラーは VB PowerPacks を、必須コンポーネントとしてインストールするのではなく
アプリケーション ファイル で Microsoft.VisualBasic.PowerPacks.VS.dll の 
発行の状況 を 含む にしてやれば回避できるようです。・・・たぶん。



インストラーを修正したものを、SkyDrive を使って公開します。中身は以前のままです。

このリンクから >>> http://sdrv.ms/RZaKds

SkyDrive の公開フォルダが開くので
CopyTtCb.zip を適当なフォルダにダウンロード後、ファイルを展開、setup.exe を実行し
インストーラーの指示に従って、インストールしてください。


[Windows によって PC が保護されました] が表示された場合
[詳細情報] をクリック、つづいて [実行] をクリックしてください。

インストールが成功すれば、Win8 の スタート の画面に CopyTtCb.exe のタイルが
ピン留めされているので、右クリックし、タスクバーにもピン留めし、それを利用してください。
 

アンインストールは、コントロールパネルのプログラムのアンインストールから
CopyTtCb.exe をアンインストールしてください。

2013年3月8日金曜日

Pictures Slide Viewer に機能追加

前回作成した Pictures Slide Viewer に
リストの項目ごとの削除機能
リスト項目とスライド時間を終了時保存し、次回起動時に呼び出す機能
を追加しました。

リスト項目の保存、呼び出しは Properties.Settings を利用し
リスト項目をカンマ区切りのベタテキストで保存し、
読み込み時にカンマで分割し直しています。




PicturesSlideViewer.exe  C#  WinDesktop

前回から、終了方法を変更
リストから項目ごとに削除、設定読み込み、設定保存、を追加

Form1.cs
=====================================================================




        // 終了
        private void button2_Click(object sender, EventArgs e)
        {
            // Environment.Exit(0);
            this.Close();
        }
 

        // リストから項目ごとに削除
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            if ((listBox1.Items.Count > 0) && (listBox1.SelectedIndex >= 0))
            {
                DialogResult result = MessageBox.Show(listBox1.Text, "リストから削除します", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    int selInd = listBox1.SelectedIndex;
                    // リストの中から削除します
                    listBox1.Items.RemoveAt(selInd);

                    // リスト選択項目指定
                    if (listBox1.Items.Count > 0)
                    {
                        if (listBox1.Items.Count > selInd)
                        {
                            listBox1.SetSelected(selInd, true);
                        }
                        else
                        {
                            listBox1.SetSelected(selInd -1 , true);
                        }
                    }
                }
            }
        }

        // 設定読み込み
        private void Form1_Load(object sender, EventArgs e)
        {
            numericUpDown1.Value = Properties.Settings.Default.SetNum;

            String StrSett = Properties.Settings.Default.Setting;
 
            // 分割して配列に格納する
            string[] stArrayData = StrSett.Split(',');
            // データを追加する
            foreach (string stData in stArrayData)
            {
                if (stData != "")
                {
                    listBox1.Items.Add(stData);
                }
            }
            // リストの1番を選択
            if (listBox1.Items.Count > 0)
            {
                // ListSet();
                listBox1.SetSelected(0, true);
            }

        }

        // 設定保存
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            // スライド時間設定保存
            int Setnum = Convert.ToInt32(numericUpDown1.Value);
            Properties.Settings.Default.SetNum = Setnum;
            // リスト保存
            if (listBox1.Items.Count > 0)
            {
                string StrSett = string.Empty;
             
                for (int i = 0; i < listBox1.Items.Count; ++i)
                {
                    listBox1.SetSelected(i, true);
                    StrSett = StrSett + listBox1.Text + ",";
                }

                Properties.Settings.Default.Setting = StrSett;          
            }
            else
            {
                Properties.Settings.Default.Setting = null;
            }

            Properties.Settings.Default.Save();
         
        }
=====================================================================




2013年3月3日日曜日

フォルダ内の画像を表示スライドショーするプログラム

Pictures Slide Viewer
選択したフォルダー内(サブフォルダー内を含む)の画像ファイルをリストにし
スライドショー表示(全画面表示対応)するプログラムです。
スライドショーの再生間隔を、0.5秒から1時間まで、0.5秒単位で変更できます。



PicturesSlideViewer.exe  C#  WinDesktop
Form1 に button1 ~ 6 、 label1 ~ 3 、pictureBox1、listBox1、numericUpDown1 を配置
コンポーネント timer1、 ダイアログ folderBrowserDialog1 を追加

Form1.cs
=====================================================================
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 PicturesSlideViewer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        // ListBox1に追加する
        private void button1_Click(object sender, EventArgs e)
        {
            // 初期選択するパスを設定する
            // RootFolder以下にあるフォルダである必要がある
            folderBrowserDialog1.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // ダイアログを表示し、戻り値が [OK] の場合は、選択したディレクトリを表示する
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // 選択したフォルダ以下のファイルをすべて取得、ListBox1に結果を追加する
                    string[] filesjpg = System.IO.Directory.GetFiles(
                        folderBrowserDialog1.SelectedPath, "*.jp*g" , System.IO.SearchOption.AllDirectories);
                    listBox1.Items.AddRange(filesjpg);

                    string[] filesgif = System.IO.Directory.GetFiles(
                        folderBrowserDialog1.SelectedPath, "*.gif", System.IO.SearchOption.AllDirectories);                    
                    listBox1.Items.AddRange(filesgif);

                    string[] filesbmp = System.IO.Directory.GetFiles(
                        folderBrowserDialog1.SelectedPath, "*.bmp", System.IO.SearchOption.AllDirectories);
                    listBox1.Items.AddRange(filesbmp);

                    string[] filespng = System.IO.Directory.GetFiles(
                        folderBrowserDialog1.SelectedPath, "*.png", System.IO.SearchOption.AllDirectories);
                    listBox1.Items.AddRange(filespng);

                    // リストの1番を選択
                    listBox1.SetSelected(0, true);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        // 終了
        private void button2_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            pictureBox1.ImageLocation = listBox1.Text;
            label1.Text = "ファイル名:" + listBox1.Text;
        }

        // 次へ
        private void button3_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count > 0)
            {
                if (listBox1.SelectedIndex == listBox1.Items.Count - 1)
                {
                    listBox1.SetSelected(0, true);
                }
                else
                {
                    int i = listBox1.SelectedIndex + 1;
                    listBox1.SetSelected(i, true);
                }
            }

        }

        // 前へ
        private void button4_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count > 0)
            {
                if (listBox1.SelectedIndex == 0)
                {
                    listBox1.SetSelected(listBox1.Items.Count - 1, true);
                }
                else
                {
                    int i = listBox1.SelectedIndex - 1;
                    listBox1.SetSelected(i, true);
                }
            }
        }

        // ListBox1をクリアにする
        private void button6_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            label1.Text = "ファイル名:";
            if (pictureBox1.Image != null)
            {
                pictureBox1.Image.Dispose();
                pictureBox1.Image = null;
            }
        }
        
        // スライドショー再生・停止
        private void button5_Click(object sender, EventArgs e)
        {
            if (button5.Text == "再生 >")
            {
                button5.Text = "停止 ■";
                // button3.PerformClick();
                timer1.Interval = Convert.ToInt32(numericUpDown1.Value);
                timer1.Start();
            }
            else
            {
                button5.Text = "再生 >";
                timer1.Stop();
            }
        }

        // スライドショーの切り替え間隔変更
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            timer1.Interval = Convert.ToInt32(numericUpDown1.Value);
        }

        // タイマーイベント
        private void timer1_Tick(object sender, EventArgs e)
        {
            button3.PerformClick();
        }

        // フルスクリーンモード

        // フルスクリーン・モードかどうかのフラグ
        private bool _bScreenMode;
        // フルスクリーン表示前のウィンドウの状態を保存する
        private FormWindowState prevFormState;
        // 通常表示時のフォームの境界線スタイルを保存する
        private FormBorderStyle prevFormStyle;
        // 通常表示時のウィンドウのサイズを保存する
        private Size prevFormSize;
        // 通常表示時のピクチャーボックスのサイズを保存する
        private Size prevPictureBoxSize;

        // フルスクリーンに切り替え
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (_bScreenMode == false)
            {
                // <フルスクリーン表示への切り替え処理>

                // ウィンドウの状態を保存する
                prevFormState = this.WindowState;
                // 境界線スタイルを保存する
                prevFormStyle = this.FormBorderStyle;
                // ピクチャーボックスのサイズを保存
                prevPictureBoxSize = pictureBox1.Size;

                // 「最大化表示」→「フルスクリーン表示」では
                // タスク・バーが消えないので、いったん「通常表示」を行う
                if (this.WindowState == FormWindowState.Maximized)
                {
                    this.WindowState = FormWindowState.Normal;
                }

                // フォームのサイズを保存する
                prevFormSize = this.Size;
                // フォームの境界線スタイルを「None」にする
                this.FormBorderStyle = FormBorderStyle.None;
                // フォームのウィンドウ状態を「最大化」する
                this.WindowState = FormWindowState.Maximized;
                // ピクチャーボックスを最大化
                pictureBox1.Size = this.ClientSize;

                // フルスクリーン表示フラグをONにする
                _bScreenMode = true;
            }
            else
            {
                // 既にフルスクリーンの場合は、次へ
                button3.PerformClick();
            }
        }

        // フルスクリーン解除
        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            if (_bScreenMode == true)
            {
                // 次に進んでしまうので前に戻す
                button4.PerformClick();

                // <通常表示/最大化表示への切り替え処理>

                // フォームのウィンドウのサイズを元に戻す
                this.ClientSize = prevFormSize;

                // 最大化表示に戻す場合にはいったん通常表示を行う
                // (フルスクリーン表示の処理とのバランスと取るため)
                if (prevFormState == FormWindowState.Maximized)
                {
                    this.WindowState = FormWindowState.Normal;
                }
                // フォームの境界線スタイルを元に戻す
                this.FormBorderStyle = prevFormStyle;

                // フォームのウィンドウ状態を元に戻す
                this.WindowState = prevFormState;

                // ピクチャーボックスを戻す
                pictureBox1.Size = prevPictureBoxSize;

                // フルスクリーン表示フラグをOFFにする
                _bScreenMode = false;
            }
        }
    }
}
=====================================================================


今回は追加したコントロールが多いのでこちらも掲載
Form1.Designer.cs

=====================================================================

namespace PicturesSlideViewer
{
    partial class Form1
    {
        /// <summary>
        /// 必要なデザイナー変数です。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 使用中のリソースをすべてクリーンアップします。
        /// </summary>
        /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows フォーム デザイナーで生成されたコード

        /// <summary>
        /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
        /// コード エディターで変更しないでください。
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.label1 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.button5 = new System.Windows.Forms.Button();
            this.listBox1 = new System.Windows.Forms.ListBox();
            this.label2 = new System.Windows.Forms.Label();
            this.button6 = new System.Windows.Forms.Button();
            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
            this.label3 = new System.Windows.Forms.Label();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
            this.SuspendLayout();
            //
            // pictureBox1
            //
            this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.pictureBox1.Location = new System.Drawing.Point(0, 0);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(823, 567);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.pictureBox1.TabIndex = 0;
            this.pictureBox1.TabStop = false;
            this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
            this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick);
            //
            // label1
            //
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 570);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(57, 12);
            this.label1.TabIndex = 1;
            this.label1.Text = "ファイル名:";
            //
            // button1
            //
            this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button1.Location = new System.Drawing.Point(829, 596);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 2;
            this.button1.Text = "追加";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // button2
            //
            this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.button2.Location = new System.Drawing.Point(12, 596);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(75, 23);
            this.button2.TabIndex = 3;
            this.button2.Text = "終了";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // button3
            //
            this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.button3.Location = new System.Drawing.Point(373, 596);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(75, 23);
            this.button3.TabIndex = 4;
            this.button3.Text = "次へ >>";
            this.button3.UseVisualStyleBackColor = true;
            this.button3.Click += new System.EventHandler(this.button3_Click);
            //
            // button4
            //
            this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.button4.Location = new System.Drawing.Point(183, 596);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(75, 23);
            this.button4.TabIndex = 5;
            this.button4.Text = "<< 前へ";
            this.button4.UseVisualStyleBackColor = true;
            this.button4.Click += new System.EventHandler(this.button4_Click);
            //
            // button5
            //
            this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.button5.Location = new System.Drawing.Point(277, 596);
            this.button5.Name = "button5";
            this.button5.Size = new System.Drawing.Size(75, 23);
            this.button5.TabIndex = 6;
            this.button5.Text = "再生 >";
            this.button5.UseVisualStyleBackColor = true;
            this.button5.Click += new System.EventHandler(this.button5_Click);
            //
            // listBox1
            //
            this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.listBox1.FormattingEnabled = true;
            this.listBox1.HorizontalScrollbar = true;
            this.listBox1.ItemHeight = 12;
            this.listBox1.Location = new System.Drawing.Point(829, 26);
            this.listBox1.Name = "listBox1";
            this.listBox1.Size = new System.Drawing.Size(160, 556);
            this.listBox1.TabIndex = 7;
            this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
            //
            // label2
            //
            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(840, 9);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(29, 12);
            this.label2.TabIndex = 8;
            this.label2.Text = "リスト";
            //
            // button6
            //
            this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button6.Location = new System.Drawing.Point(914, 596);
            this.button6.Name = "button6";
            this.button6.Size = new System.Drawing.Size(75, 23);
            this.button6.TabIndex = 9;
            this.button6.Text = "全削除";
            this.button6.UseVisualStyleBackColor = true;
            this.button6.Click += new System.EventHandler(this.button6_Click);
            //
            // numericUpDown1
            //
            this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.numericUpDown1.Increment = new decimal(new int[] {
            500,
            0,
            0,
            0});
            this.numericUpDown1.Location = new System.Drawing.Point(534, 596);
            this.numericUpDown1.Maximum = new decimal(new int[] {
            360000,
            0,
            0,
            0});
            this.numericUpDown1.Minimum = new decimal(new int[] {
            500,
            0,
            0,
            0});
            this.numericUpDown1.Name = "numericUpDown1";
            this.numericUpDown1.ReadOnly = true;
            this.numericUpDown1.Size = new System.Drawing.Size(81, 19);
            this.numericUpDown1.TabIndex = 10;
            this.numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.numericUpDown1.ThousandsSeparator = true;
            this.numericUpDown1.Value = new decimal(new int[] {
            2000,
            0,
            0,
            0});
            this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
            //
            // label3
            //
            this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(621, 598);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(31, 12);
            this.label3.TabIndex = 11;
            this.label3.Text = "ミリ秒";
            //
            // timer1
            //
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            //
            // folderBrowserDialog1
            //
            this.folderBrowserDialog1.Description = "フォルダを選択";
            this.folderBrowserDialog1.ShowNewFolderButton = false;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(994, 631);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.numericUpDown1);
            this.Controls.Add(this.button6);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.listBox1);
            this.Controls.Add(this.button5);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label1);
            this.Name = "Form1";
            this.Text = "Pictures Slide Viewer";
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.Button button4;
        private System.Windows.Forms.Button button5;
        private System.Windows.Forms.ListBox listBox1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Button button6;
        private System.Windows.Forms.NumericUpDown numericUpDown1;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
    }
}
=====================================================================




2013年2月28日木曜日

Zip を一括で解凍するプログラム

指定したフォルダ内の Zip ファイルをすべて解凍するプログラムです。
解凍するファイルと同じ名前のフォルダを、ファイルがあるフォルダー内に作成し、
そこへ解凍します。

Zip の解凍には、DotNetZip を使用しました。
MS Visual Studio に Ionic.Zip.dll を 参照の追加 しています。

DotNetZip - Zip and Unzip in C#, VB, any .NET language
http://dotnetzip.codeplex.com/

DotNetZip の Ver.1.9 を利用したのですが、日本語対応の部分で、
Ver.1.8 のサンプルがそのまま使えませんでした。
オプションの指定を、予め ReadOptions 変数(options)に用意しておいてから
指定することでうまくいきました。(プログラムの青字部分)


AllUnZip.exe  C#  WinDesktop
Form1 に button1 button2 と label1 を配置


Form1.cs

=====================================================================

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;
using System.IO;
using Ionic.Zip;

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

        private void button1_Click(object sender, EventArgs e)
        {
            string selectPath = null;

            try
            {
                // string selectPath = string.Empty;
                selectPath = string.Empty;
                label1.Text = "フォルダを選択 解凍実行";
                label1.Update();
                // FolderBrowserDialog の新しいインスタンスを生成する (デザイナから追加している場合は必要ない)
                FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();

                // ダイアログの説明を設定する
                folderBrowserDialog1.Description = "フォルダを選択";

                // ルートになる特殊フォルダを設定する (初期値 SpecialFolder.Desktop)
                // folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyDocuments;

                // 初期選択するパスを設定する
                // RootFolder以下にあるフォルダである必要がある
                // folderBrowserDialog1.SelectedPath = @"C:\Program Files\";
                folderBrowserDialog1.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                // [新しいフォルダ] ボタンを表示する (初期値 true)
                folderBrowserDialog1.ShowNewFolderButton = false;

                // ダイアログを表示し、戻り値が [OK] の場合は、選択したディレクトリをする
                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {

                    if (Directory.Exists(folderBrowserDialog1.SelectedPath))
                    {
                        selectPath = folderBrowserDialog1.SelectedPath;
                    }
                    else
                    {
                        label1.Text = "フォルダが実在しません";
                        return;
                    }
                }
                else
                {
                    label1.Text = "解凍中止";
                    return;
                }
               
                if (!string.IsNullOrEmpty(selectPath))
                {
                    // 提出モードの処理を実行する
                    this.UnCompress(selectPath);
                }
                // 不要になった時点で破棄する
                folderBrowserDialog1.Dispose();
               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                label1.Text = "解凍失敗!";
            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);

        }

        /// <summary>
        /// 解凍処理を実行する
        /// </summary>
        /// <param name="path">ユーザが選択したフォルダまでのパス</param>
        /// <param name="extention">解凍対象の拡張子(例:"*.gz")。デフォルトは"*.zip"</param>
        ///
        private void UnCompress(string path, string extention = "*.zip")
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(path);
            string savePath = directoryInfo.FullName;

            // ディレクトリ内にある解凍対象を解凍する
            foreach (FileInfo fileInfo in directoryInfo.GetFiles(extention))
            {
                using (FileStream inFile = fileInfo.OpenRead())
                {
                    string currentFile = fileInfo.FullName;
                    string stBaseName = System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name);

                    var options = new ReadOptions
                    {
                        StatusMessageWriter = System.Console.Out,
                        Encoding = System.Text.Encoding.GetEncoding("shift_jis")
                    };

                    using (ZipFile zip = ZipFile.Read(currentFile, options))
                    {
                        if (System.IO.Directory.Exists(savePath + @"\" + stBaseName))
                        {
                            label1.Text = "同名のフォルダが存在する";
                            DialogResult result = MessageBox.Show
                                ("同名のフォルダが存在するためスキップします。
                                   \r\n処理を終了する場合はキャンセル"
                                , "エラー"
                                , MessageBoxButtons.OKCancel
                                , MessageBoxIcon.Hand);
                            if (result == DialogResult.Cancel)
                            {
                                label1.Text = "解凍中断";
                                return;
                            }
                        }
                        else
                        {
                            // 全て解凍する
                            // zip.ExtractAll(savePath + @"\" + stBaseName);

                            // 個別に解凍する
                            foreach (ZipEntry entry in zip)
                            {
                                label1.Text = entry.FileName;
                                label1.Update();
                                // 解凍処理
                                entry.Extract(savePath + @"\" + stBaseName);
                            }
                        }
                    }
                }
            }
            label1.Text = "解凍終了";
        }
    }
}


=====================================================================





2013年2月27日水曜日

フォルダを参照するプログラム


フォルダ参照ダイアログボックスを表示し、選択したフォルダにある
サブフォルダをリストに表示するプログラムです。

なぜか、マイ ドキュメントのフォルダを選択すると
サブフォルダのリストを表示するところ( GetDirectories )で
My Music フォルダへのアクセス権が無いとエラーが出ます。
ちなみに OS は Win8です。

下のプログラムではエラーが出た時点で処理を中止していますが
エラーをスキップしてリスト表示を続ける、簡単な方法はないものだろうか。

FolderBrowser.exe  C#  WinDesktop
Form1 に button1 と listBox1 を配置

Form1.cs
=====================================================================
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 FolderBrowser
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // FolderBrowserDialog の新しいインスタンスを生成する
            FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();

            // ダイアログの説明を設定する
            folderBrowserDialog1.Description = "フォルダを選択";

            // ルートになる特殊フォルダを設定する (初期値 SpecialFolder.Desktop)
            // folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyDocuments;

            // 初期選択するパスを設定する
            // RootFolder以下にあるフォルダである必要がある
            folderBrowserDialog1.SelectedPath =
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // [新しいフォルダ] ボタンを表示する (初期値 true)
            folderBrowserDialog1.ShowNewFolderButton = false;

            // ダイアログを表示し、戻り値が [OK] の場合は、選択したディレクトリを表示する
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show(folderBrowserDialog1.SelectedPath);

                // 選択したフォルダ以下のサブフォルダをすべて取得する
                // ワイルドカード"*"は、すべてのフォルダを意味する
                try
                {
                    string[] subFolders = System.IO.Directory.GetDirectories(
                        folderBrowserDialog1.SelectedPath, "*",
                        System.IO.SearchOption.AllDirectories);

                    // ListBox1をクリアにする
                    listBox1.Items.Clear();

                    //ListBox1に結果を表示する
                    listBox1.Items.AddRange(subFolders);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            // 不要になった時点で破棄する
            folderBrowserDialog1.Dispose();
        }
    }
}
=======================================================================


2013年2月8日金曜日

次期 Office 無償 アップグレード プログラムダウンロード開始

Microsoft Office 2013 の一般販売が平成25年2月7日に開始されましたが
「次期 Office 無償 アップグレード プログラム」については、
昨日の時点ではまだ、ダウンロードの準備ができていませんでした。

本日、平成25年2月8日、メールの案内はまだ来ていませんが
ダウンロードが、とりあえずできるようになったようです。

http://www.microsoft.com/ja-jp/office/2013offer/default.aspx


平成25年5月31日までに、プロダクト キーを入手する必要があります。
該当する人は忘れないようにしましょう。


2013年1月7日月曜日

Win8 における WACOM Bamboo のタッチ機能について

Windows8 用タッチパットとして WACOM Bamboo CTH-470/K0 を購入したので
CTH-470 の Win8 におけるタッチジェスチャー機能についてレポートする。
なお、タブレットのドライバは、2012-11-16 更新 V5.3.0-3Jwdf を使用した。

エッジスワイプ(このドライバーから対応)
     1本指で、右端から、左にスワイプ :チャームの表示
     1本指で、左端から、右にスワイプ :アプリケーションの切り替え
     1本指で、下端から、上にスワイプ :アプリケーションメニューの表示
     1本指で、上端から、下にスワイプ :アプリケーションメニューの表示
     1本指で、上端から、下に長くスワイプ :アプリケーションの終了

左端から、右にスワイプは、そのまま左に戻しても、
最近使ったアプリの一覧は表示されない。また、スナップにもできない。
アプリの切り替えが、ただちに行なわれる。

1本指での操作
     スワイプ:マウスポインターの移動
     タップ:クリック
     ダブルタップ:ダブルクリック
     ダブルタップ ホールド スワイプ:ドラッグ

タッチ機能によるポインタの移動はマウスモードのみで、ペンモード(絶対座標)にはできない。
この点はちょっと不便、Win8 の場合絶対座標指定を選べた方が便利だと思う。
とりあえず、ポインタの速度を速い方に設定して対応。
  
2本指での操作
     スワイプ:スクロール
     タップ:右クリック
     ピンチ:ズーム
     ツイスト:回転
     左にフリップ:戻る  右にフリップ:進む

Win8 アプリでは、横にスクロールするアプリが多い。ところが、現段階では
横にスクロールさせるのに、上下にスワイプしなければならない。
これが分かるまでにだいぶ苦労した。どうにかしてもらいたいものである。

3本指での操作
     スワイプ:ドラッグ

取説には、左右スワイプによるページ移動、「進む」「戻る」となっているが
Win8 の場合、実際にはドラッグとなっている。
個人的には、スナップの切り替えに、3本指のタップやダブルタップを割り当ててもらいたい。
ちなみに、スナップを切り替えるには、スナップの境界線上にマウスポインタを移動し
サイズ変更のマークになったら、3本指で右か左までスワイプ(ドラッグ)する。
追加:スナップの左右切り替えだけなら、境界線上でダブルタップ:ダブルクリックでもOK

4本指での操作
     上にスワイプ:ディスクトップの表示
     下にスワイプ:最近使ったアプリの一覧(Win8 アプリの切り替え、左端に縦一覧)
     左右にスワイプ:アプリケーションの切り替え(起動中全アプリ、中央に横一覧)

最近使ったアプリの一覧を表示後、4本指左右スワイプで選択中のアプリを切り替えられる。

ちなみに、ファンクションキーの上から2番目に、Windowsキー が割り当てられている。



2013年1月6日日曜日

Win8 用にタッチパッドを買ってみた

せっかく Windows8 にしたのに、最近ではデスクトップしか使わず
ほとんど Win7 と変わらない状態、いや、むしろ Win95 にちかいかも。

タッチ操作ができれば Win8 らしく使えるかと思い
タッチパネルのディスプレイを検討してみましたが
Win8 対応のものは、まだ品数も少なく、価格も高い状態です。
次善案としてタッチパッドを検討、こちらも今のところ
Win8 対応のものは、まだ品数も少なく、価格も安くはありません。
それでも、ディスプレイよりはお手頃なので、
タッチパッドを購入してみることにしました。

候補に挙げたのは次の3つ
     WACOM Bamboo CTH-470
          ワコムストア価格 10,980円
     最新ドライバ V5.3.0-3Jwdf で Win8 のタッチジェスチャー対応
          ワイヤレスキット別売り(3,675円、充電式)       
     Logicool Wireless Rechargeable Touchpad t650
          ロジクール オンラインストア価格 7,980円
          ワイヤレス、充電式
     エレコム M-TP01DS
          定価 10,657円
          2013年1月下旬発売
          ワイヤレス、単3形乾電池
          連続動作時間 約74時間、想定使用可能時間 約181日間(目安)

結局、ペンタブレットとしてお絵描きにも使えることもあり
(ペンタブだけどタッチパネルとしても使える、が正確)
近所のパソコン専門店にて
 WACOM Bamboo CTH-470/K0 を日替わり特価 8,970円で購入しました。

使用レポートは次回

[PR]