コード例 #1
0
        private void addImage(Point place)
        {
            PictureBox pic = createPictureBox();

            pic.Location = place;
            pic.Image    = Clipboard.GetImage();
            pic.Size     = pic.Image.Size;
            BoxInfo info = new BoxInfo()
            {
                filename = savefilename("png"),
                size     = pic.Size,
                visible  = true,
                location = pic.Location,
                page     = getCurrentPage()
            };

            pic.Tag = info.filename;
            mediaBoxInfos.Add(info.filename, new MediaBoxsInfo {
                boxinfo = info, controlbox = pic
            });
            workingpanel.Controls.Add(pic);
            pic.Image.Save(Path.Combine(getWorkSubDir(), info.filename));
            // クリップボードをクリア
            Clipboard.Clear();
            return;
        }
コード例 #2
0
        private Panel createWebBrowser(string html, BoxInfo boxinfo)
        {
            Panel pan = new Panel()
            {
                BackColor = Color.White, Width = boxinfo.size.Width, Height = boxinfo.size.Height
            };
            WebBrowser web = new WebBrowser();

            addMouseEvent(pan);
            pan.ContextMenuStrip = this.contextHTMLMenuStrip; // 右ボタンクリックで表示されるポップアップメニュー
            pan.Location         = boxinfo.location;
            pan.Tag  = boxinfo.filename;
            pan.Size = boxinfo.size;

            web.Location          = new Point(30, 30);
            web.Size              = new Size(pan.Width - 60, pan.Height - 60);
            web.AllowNavigation   = false;
            web.ScrollBarsEnabled = false;
            web.IsWebBrowserContextMenuEnabled = false;
            web.ContextMenuStrip = this.contextHTMLMenuStrip;
            web.DocumentText     = html.Substring(html.IndexOf("<html>"));
            web.Tag = boxinfo.filename;

            pan.Controls.Add(web);
            return(pan);
        }
コード例 #3
0
        private List <Point> DrawBoxToBoxLine(BoxInfo box1, BoxInfo box2)
        {
            List <Point> edge1   = box1.edges();
            List <Point> edge2   = box2.edges();
            int          min1    = 0;
            int          min2    = 0;
            double       mindist = double.MaxValue;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    double cdist = Math.Pow(edge1[i].X - edge2[j].X, 2) + Math.Pow(edge1[i].Y - edge2[j].Y, 2);
                    if (cdist < mindist)
                    {
                        mindist = cdist;
                        min1    = i;
                        min2    = j;
                    }
                }
            }
            // min1とmin2間でラインを引く
            return(new List <Point>()
            {
                edge1[min1], edge2[min2]
            });
        }
コード例 #4
0
        private void addHTML(Point place, string html)
        {
            BoxInfo info = new BoxInfo()
            {
                filename = savefilename("html"),
                size     = new Size(400, 400),
                visible  = true,
                location = place,
                page     = getCurrentPage()
            };
            Panel web = createWebBrowser(html, info);

            mediaBoxInfos.Add(info.filename, new MediaBoxsInfo {
                boxinfo = info, controlbox = web
            });
            workingpanel.Controls.Add(web);
            File.WriteAllText(Path.Combine(getWorkSubDir(), info.filename), html);
            // クリップボードをクリア
            Clipboard.Clear();
            return;
        }
コード例 #5
0
        // Workingpanelにコントロールを追加

        #region 独自コントロールの追加
        // Workingpanelのダブルクリックで呼ばれる
        private void addControlToWorkingpanel()
        {
            if (!editstart)
            {
                return;
            }
            // shiftキーをチェック
            if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift)
            {
                // クリップボードの内容をチェック
                IDataObject data = Clipboard.GetDataObject();
                if (data != null)
                {
                    //関連付けられているすべての形式を列挙する
                    foreach (string fmt in data.GetFormats())
                    {
                        if (fmt.Contains("HTML"))
                        {
                            //invokeApp("wordpad.exe");
                            var    meta = data.GetData("HTML Format", true);
                            string html = Clipboard.GetData("HTML Format") as string;
                            addHTML(CursorPosition(), html);
                            return;
                        }

                        if (fmt.Contains("Rich") || fmt.Contains("Text") || fmt.Contains("String"))
                        {
                            // RichTextBoxの作成 tagはBoxInfoと同じ内容
                            RichTextBox rbox = createRichBox();
                            BoxInfo     info = new BoxInfo()
                            {
                                filename = savefilename("rtf"),
                                size     = new Size(200, 200),
                                visible  = true,
                                location = CursorPosition(),
                                page     = getCurrentPage()
                            };
                            rbox.Size     = info.size;
                            rbox.Location = info.location;
                            rbox.Tag      = info.filename;
                            rbox.Paste();
                            info.text     = rbox.Text;
                            rbox.ReadOnly = true; // 必ずPaste後に行うこと

                            // 1秒以内にダブルクリックされていないことを確認し、ファイル名が重複しないようにする
                            if (!mediaBoxInfos.ContainsKey(info.filename))
                            {
                                mediaBoxInfos.Add(info.filename, new MediaBoxsInfo {
                                    boxinfo = info, controlbox = rbox
                                });
                                workingpanel.Controls.Add(rbox);
                                rbox.SaveFile(Path.Combine(getWorkSubDir(), info.filename));
                            }
                            break;
                        }
                        else if (fmt.Contains("Bitmap"))
                        {
                            // Imageの追加
                            addImage(CursorPosition());
                            break;
                        }
                        Console.WriteLine(fmt);
                    }
                }
            }
        }