Esempio n. 1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            try
            {
                m_Delegate = new runDelegate(Run);
                var       selStr  = Selector.Get(context);
                UiElement element = null;
                element = Common.GetValueOrDefault(context, this.Element, null);
                if (element == null && selStr != null)
                {
                    element = UiElement.FromSelector(selStr);
                }
                else
                {
                    PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope];
                    element = property.GetValue(context.DataContext) as UiElement;
                }

                UiElement relativeEle = element.FindRelativeElement((int)Position, OffSetX.Get(context), OffSetY.Get(context));
                FoundElement.Set(context, relativeEle);
                //relativeEle.DrawHighlight(System.Drawing.Color.Red, TimeSpan.FromSeconds(2), true);

                return(m_Delegate.BeginInvoke(callback, state));
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取偏移相对元素失败", e.Message);
                if (ContinueOnError.Get(context))
                {
                    return(m_Delegate.BeginInvoke(callback, state));
                }
                else
                {
                    throw e;
                }
            }
        }
Esempio n. 2
0
        protected override void Render(HtmlTextWriter writer)
        {
            EnsureChildControls();

            var jsEventCode = "";

            if (!CodeMirrorEnabled)
            {
                CodeTextBox.RenderControl(writer);
                jsEventCode = RenderBasicEditor();
            }
            else
            {
                writer.WriteBeginTag("div");
                writer.WriteAttribute("id", this.ClientID);
                writer.WriteAttribute("class", this.CssClass);
                this.ControlStyle.AddAttributesToRender(writer);
                writer.Write(HtmlTextWriter.TagRightChar);
                CodeTextBox.RenderControl(writer);
                writer.WriteEndTag("div");

                jsEventCode = RenderCodeEditor();
            }



            if (this.AutoResize)
            {
                if (CodeMirrorEnabled)
                {
                    //reduce the width if using code mirror because of the line numbers
                    OffSetX += 20;
                }

                jsEventCode += @"                    

                    //create the editor
                   var UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (!CodeMirrorEnabled).ToString().ToLower() + @", '" + this.ClientID + @"');


                    var m_textEditor = jQuery('#" + this.ClientID + @"');
                    //with codemirror adding divs for line numbers, we need to target a different element
                    m_textEditor = m_textEditor.find('iframe').length > 0 ? m_textEditor.children('div').get(0) : m_textEditor.get(0);
                    jQuery(window).resize(function(){  resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); });
                    jQuery(document).ready(function(){  resizeTextArea(m_textEditor, "     + OffSetX.ToString() + "," + OffSetY.ToString() + @"); });
                    ";

                if (!UmbracoSettings.ScriptDisableEditor && HttpContext.Current.Request.Browser.Browser == "IE")
                {
                    jsEventCode += "jQuery('<p style=\"color:#999\">" + ui.Text("codemirroriewarning").Replace("'", "\\'") + "</p>').insertAfter('#" + this.ClientID + "');";
                }
            }

            jsEventCode = string.Format(@"<script type=""text/javascript"">{0}</script>", jsEventCode);
            writer.WriteLine(jsEventCode);
        }
Esempio n. 3
0
        protected override void Render(HtmlTextWriter writer)
        {
            EnsureChildControls();

            var jsEventCode = "";


            if (CodeMirrorEnabled == false)
            {
                CodeTextBox.RenderControl(writer);
                jsEventCode = RenderBasicEditor();
            }
            else
            {
                writer.WriteBeginTag("div");
                writer.WriteAttribute("id", this.ClientID);
                writer.WriteAttribute("class", this.CssClass);
                this.ControlStyle.AddAttributesToRender(writer);
                writer.Write(HtmlTextWriter.TagRightChar);
                CodeTextBox.RenderControl(writer);
                writer.WriteEndTag("div");

                jsEventCode = RenderCodeEditor();
            }



            if (this.AutoResize)
            {
                if (CodeMirrorEnabled)
                {
                    //reduce the width if using code mirror because of the line numbers
                    OffSetX += 20;
                }

                jsEventCode += @"   
					//TODO: for now this is a global var, need to refactor all this so that is using proper js standards
					//with correct objects, and proper accessors to these objects.
					var UmbEditor;                 
                    $(document).ready(function () {
                        //create the editor
                       UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (CodeMirrorEnabled == false).ToString().ToLower() + @", '" + this.ClientID + @"');
                       var m_textEditor = jQuery('#" + this.ClientID + @"');
                   
                       //with codemirror adding divs for line numbers, we need to target a different element
                       m_textEditor = m_textEditor.find('iframe').length > 0 ? m_textEditor.children('div').get(0) : m_textEditor.get(0);
                   
                       jQuery(window).resize(function(){  resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); });
                       jQuery(document).ready(function(){  resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); });
                    });";
            }

            jsEventCode = string.Format(@"<script type=""text/javascript"">{0}</script>", jsEventCode);
            writer.WriteLine(jsEventCode);
        }