コード例 #1
0
ファイル: Form1.cs プロジェクト: magicgis/PassioneBrowserKit
        /// <summary>
        /// htmlの#div2クリック時のイベント
        /// </summary>
        /// <returns></returns>
        private Action <PassioneWebBrowser, PWBrowserEventArgs> div2_Click()
        {
            return((sender, e) =>
            {
                try
                {
                    // マウスボタンの右/左を判定したい場合はキャストすれば参照可能
                    PWBrowserClickEventArgs _e = (PWBrowserClickEventArgs)e;
                    if (_e.MouseButton != PWBrowserClickEventArgs.PWBClickEventArgsMouseButton.Left)
                    {
                        StringBuilder strtmp = new StringBuilder();
                        strtmp.AppendLine("右クリックは受け付けません");
                        txtInfo.Text = strtmp.ToString() + Environment.NewLine + txtInfo.Text;
                        return;
                    }

                    StringBuilder str = new StringBuilder();
                    str.AppendFormat("evt   : {0}", _e.EvtName).AppendLine("");
                    str.AppendFormat("id    : {0}", _e.ElementID).AppendLine("");

                    str.Append("class : ");
                    for (int i = 0; i < _e.ElementClassName.Count; i++)
                    {
                        str.Append(_e.ElementClassName[i]);
                        if (i != _e.ElementClassName.Count - 1)
                        {
                            str.Append(", ");
                        }
                    }
                    str.AppendLine("");

                    str.AppendFormat("text  : {0}", _e.ElementText).AppendLine("");
                    str.AppendFormat("val   : {0}", _e.ElementValue).AppendLine("");
                    str.AppendFormat("trig  : {0}", _e.EventTriggerClassName).AppendLine("");
                    str.AppendFormat("button: {0}", _e.MouseButton).AppendLine("");
                    str.AppendFormat("ctrlKey: {0}", _e.ICtrlKey.ToString()).AppendLine("");
                    str.AppendFormat("shiftKey: {0}", _e.IsShiftKey.ToString()).AppendLine("");
                    str.AppendFormat("altKey: {0}", _e.IsAltKey.ToString()).AppendLine("");

                    txtInfo.Text = str.ToString() + Environment.NewLine + txtInfo.Text;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            });
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: magicgis/PassioneBrowserKit
        /// <summary>
        /// htmlの#div2クリック時のイベント
        /// </summary>
        /// <returns></returns>
        private Action <PassioneWebBrowser, PWBrowserEventArgs> showEditFrm()
        {
            return((sender, e) =>
            {
                try
                {
                    // マウスボタンの右/左を判定したい場合はキャストすれば参照可能
                    PWBrowserClickEventArgs _e = (PWBrowserClickEventArgs)e;
                    if (_e.MouseButton != PWBrowserClickEventArgs.PWBClickEventArgsMouseButton.Left)
                    {
                        return;
                    }

                    using (frmEdit frm = new frmEdit())
                    {
                        frm.StartPosition = FormStartPosition.CenterParent;
                        frm.strTargetName = e.ElementID;

                        if (e.ElementID == "#edForGetText")
                        {
                            frm.strTargetValue = sender.GetText("#divGetSet");
                            frm.ShowDialog(this);

                            if (frm.DialogResult == DialogResult.OK)
                            {
                                sender.SetText("#divGetSet", frm.strTargetValue);
                            }
                        }
                        else if (e.ElementID == "#edForGetVal")
                        {
                            frm.strTargetValue = sender.GetVal("#selectGetSet");
                            frm.ShowDialog(this);

                            if (frm.DialogResult == DialogResult.OK)
                            {
                                sender.SetVal("#selectGetSet", frm.strTargetValue);
                            }
                        }
                        else if (e.ElementID == "#edForGetCss")
                        {
                            frm.strTargetValue = sender.GetCssVal("#divGetCss", "width") + "," + sender.GetCssVal("#divGetCss", "height");
                            frm.ShowDialog(this);

                            if (frm.DialogResult == DialogResult.OK)
                            {
                                sender.SetCssVal("#divGetCss", "width", frm.strTargetValue.Split(',')[0].Trim() + "px");
                                sender.SetCssVal("#divGetCss", "height", frm.strTargetValue.Split(',')[1].Trim() + "px");
                            }
                        }
                        else if (e.ElementID == "#edForGetHtml")
                        {
                            frm.strTargetValue = sender.GetHtml("#divGetHtml");
                            frm.ShowDialog(this);

                            if (frm.DialogResult == DialogResult.OK)
                            {
                                sender.SetHtml("#divGetHtml", frm.strTargetValue);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            });
        }