Example #1
0
        //────────────────────────────────────────

        private void Usercontrol_Canvas_DragDrop(object sender, DragEventArgs e)
        {
            Log_Method  log_Method  = new Log_MethodImpl();
            Log_Reports log_Reports = new Log_ReportsImpl(log_Method);

            log_Method.BeginMethod(Info_SpeedCoder.Name_Library, this, "Usercontrol_Canvas_DragDrop", log_Reports);

            Point locationMouse = this.PointToClient(new Point(e.X, e.Y));

            bool isDropped = false;

            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // ファイルドロップ
                TextdropareaImpl droppedArea = null;
                string[]         fileNames   = (string[])e.Data.GetData(DataFormats.FileDrop, false);

                if (this.Textdroparea1.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea1;
                }

                if (this.Textdroparea2.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea2;
                }

                if (null != droppedArea)
                {
                    droppedArea.IsDropped = true;
                    droppedArea.Clear();
                    //log_Method.WriteDebug_ToConsole("ファイルをドロップした。 fileNames.length=[" + fileNames.Length + "]");
                    foreach (string fileName in fileNames)
                    {
                        droppedArea.ListFilepath.Add(fileName);
                        //log_Method.WriteDebug_ToConsole("fileName=[" + fileName + "]");
                    }

                    isDropped = true;
                }
                else
                {
                    //log_Method.WriteDebug_ToConsole("ファイルをドロップしたが、枠には入っていない。 fileNames.length=[" + fileNames.Length + "]");
                }
            }
            else if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                // 文字列として読み取れる形式のデータがドロップされた場合、
                // テキストボックスに、その文字列データを表示します。
                string droppedText = (string)e.Data.GetData(typeof(string));


                TextdropareaImpl droppedArea = null;
                if (this.Textdroparea1.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea1;
                }

                if (this.Textdroparea2.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea2;
                }

                if (null != droppedArea)
                {
                    droppedArea.IsDropped = true;
                    droppedArea.Clear();

                    droppedArea.DroppedText = droppedText;

                    isDropped = true;
                }
            }
            else
            {
                //log_Method.WriteDebug_ToConsole("ファイル以外のものをドロップした。");
            }

            if (isDropped)
            {
                //log_Method.WriteDebug_ToConsole("ドロップがあったとき。");

                SpeedCodingImpl speedCoding = new SpeedCodingImpl();
                bool            isError;
                string          result = speedCoding.Perform(out isError, this.Textdroparea1, this.Textdroparea2, log_Reports);
                this.textBox1.Text = result;
                if (isError)
                {
                    this.textBox1.ForeColor = Color.Red;
                }
                else
                {
                    this.textBox1.ForeColor = SystemColors.ControlText;
                }

                this.Refresh();
            }

            //log_Method.WriteDebug_ToConsole("locationMouse.X=[" + locationMouse.X + "] .Y=[" + locationMouse.Y + "]");
            //log_Method.WriteDebug_ToConsole("this.Textdroparea1.Bounds=[" + this.Textdroparea1.Bounds.X + "][" + this.Textdroparea1.Bounds.Y + "][" + this.Textdroparea1.Bounds.Width + "][" + this.Textdroparea1.Bounds.Height + "]");
            //log_Method.WriteDebug_ToConsole("this.Textdroparea2.Bounds=[" + this.Textdroparea2.Bounds.X + "][" + this.Textdroparea2.Bounds.Y + "][" + this.Textdroparea2.Bounds.Width + "][" + this.Textdroparea2.Bounds.Height + "]");

            log_Method.EndMethod(log_Reports);
        }
Example #2
0
        //────────────────────────────────────────
        private void Usercontrol_Canvas_DragDrop(object sender, DragEventArgs e)
        {
            Log_Method log_Method = new Log_MethodImpl();
            Log_Reports log_Reports = new Log_ReportsImpl(log_Method);
            log_Method.BeginMethod(Info_SpeedCoder.Name_Library, this, "Usercontrol_Canvas_DragDrop", log_Reports);

            Point locationMouse = this.PointToClient(new Point(e.X, e.Y));

            bool isDropped=false;
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // ファイルドロップ
                TextdropareaImpl droppedArea = null;
                string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop, false);

                if (this.Textdroparea1.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea1;
                }

                if (this.Textdroparea2.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea2;
                }

                if (null!=droppedArea)
                {
                    droppedArea.IsDropped = true;
                    droppedArea.Clear();
                    //log_Method.WriteDebug_ToConsole("ファイルをドロップした。 fileNames.length=[" + fileNames.Length + "]");
                    foreach (string fileName in fileNames)
                    {
                        droppedArea.ListFilepath.Add(fileName);
                        //log_Method.WriteDebug_ToConsole("fileName=[" + fileName + "]");
                    }

                    isDropped = true;
                }
                else
                {
                    //log_Method.WriteDebug_ToConsole("ファイルをドロップしたが、枠には入っていない。 fileNames.length=[" + fileNames.Length + "]");
                }
            }
            else if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                // 文字列として読み取れる形式のデータがドロップされた場合、
                // テキストボックスに、その文字列データを表示します。
                string droppedText = (string)e.Data.GetData(typeof(string));

                TextdropareaImpl droppedArea = null;
                if (this.Textdroparea1.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea1;
                }

                if (this.Textdroparea2.Bounds.Contains(locationMouse.X, locationMouse.Y))
                {
                    droppedArea = this.Textdroparea2;
                }

                if (null != droppedArea)
                {
                    droppedArea.IsDropped = true;
                    droppedArea.Clear();

                    droppedArea.DroppedText = droppedText;

                    isDropped = true;
                }
            }
            else
            {
                //log_Method.WriteDebug_ToConsole("ファイル以外のものをドロップした。");
            }

            if (isDropped)
            {
                //log_Method.WriteDebug_ToConsole("ドロップがあったとき。");

                SpeedCodingImpl speedCoding = new SpeedCodingImpl();
                bool isError;
                string result = speedCoding.Perform(out isError, this.Textdroparea1, this.Textdroparea2, log_Reports);
                this.textBox1.Text = result;
                if (isError)
                {
                    this.textBox1.ForeColor = Color.Red;
                }
                else
                {
                    this.textBox1.ForeColor = SystemColors.ControlText;
                }

                this.Refresh();
            }

            //log_Method.WriteDebug_ToConsole("locationMouse.X=[" + locationMouse.X + "] .Y=[" + locationMouse.Y + "]");
            //log_Method.WriteDebug_ToConsole("this.Textdroparea1.Bounds=[" + this.Textdroparea1.Bounds.X + "][" + this.Textdroparea1.Bounds.Y + "][" + this.Textdroparea1.Bounds.Width + "][" + this.Textdroparea1.Bounds.Height + "]");
            //log_Method.WriteDebug_ToConsole("this.Textdroparea2.Bounds=[" + this.Textdroparea2.Bounds.X + "][" + this.Textdroparea2.Bounds.Y + "][" + this.Textdroparea2.Bounds.Width + "][" + this.Textdroparea2.Bounds.Height + "]");

            log_Method.EndMethod(log_Reports);
        }