Example #1
0
        public WebReply(string sHTML, string sJavascript, string SectionName, bool DoAppend)
        {
            WebReplyPackage wrp = new WebReplyPackage();

            wrp.HTML        = sHTML;
            wrp.Javascript  = sJavascript;
            wrp.doappend    = DoAppend ? "true" : "false";
            wrp.SectionName = SectionName;
            Packages.Add(wrp);
        }
Example #2
0
        public WebReply btnLogin_Click()
        {
            Sys.SetObjectValue("Login", "Caption1", "Enter Username and Password and click Login.");
            // Authenticate User
            bool bAuth = VerifyUser(Sys.GetObjectValue("Login", "Username"), Sys.GetObjectValue("Login", "Password"), ref Sys, false);


            Sys.SetObjectValue("Login", "Caption1", String.Empty);
            if (bAuth)
            {
                //Log in to First System Page
                WebReply        wr   = Sys.Redirect("Home", this);
                WebReplyPackage wrp1 = wr.Packages[0];
                wrp1.Javascript = "location.reload();";
                return(wr);
            }
            // Present Log in Screen
            return(LoginSection());
        }
Example #3
0
 public void AddWebPackage(WebReplyPackage p)
 {
     Packages.Add(p);
 }
Example #4
0
        public WebReply Render(object caller, bool ClearScreen)
        {
            string     myClass    = caller.GetType().ToString();
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames  = stackTrace.GetFrames();
            StackFrame   callingFrame = stackFrames[1];
            MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
            string       sMyMethod    = method.Name;
            // Button for Expand-Collapse
            string sExpandedClass = Expanded ? "icon-minus" : "icon-plus";

            sExpandedClass = Expanded ? "icon-chevron-up" : "icon-chevron-down";
            string sExpandButton = GetHeaderButton("expand", myClass, sMyMethod, sExpandedClass);
            string sEditButton   = "";

            if (SecMode == SystemObject.SectionMode.View)
            {
                sEditButton = GetHeaderButton("edit", myClass, sMyMethod + "_EditClick", "icon-pencil");
            }

            string sButtons = sExpandButton + sEditButton;
            // Button for Edit
            string divname      = this.Name;
            string sNarrative   = "";
            string sBorderStyle = "";
            string sFrameStyle  = "";

            if (SecMode == SystemObject.SectionMode.View)
            {
                sNarrative = "View";
            }
            else if (SecMode == SystemObject.SectionMode.Add)
            {
                sNarrative = "Add";
            }
            else if (SecMode == SystemObject.SectionMode.Edit)
            {
                sNarrative = "Edit";
            }
            else if (SecMode == SystemObject.SectionMode.Customize)
            {
                sNarrative = "Customize";
            }
            string FriendlyName = this.Name;

            if (!this.MaskSectionMode)
            {
                FriendlyName += " <font size=1>[" + sNarrative + "]</font>";
            }


            string sDivClass = "class='dragContent'";

            if (SecMode == SystemObject.SectionMode.Customize)
            {
                sBorderStyle = "style='border-top: solid 1px; border-bottom:solid 1px; border-left: solid 1px; border-right:solid 1px;'";
            }
            else
            {
                sFrameStyle = "frame=box";
            }


            // CONTEXT MENU
            AddContextMenuitem("Customize", "Customize", "Customize");


            string htmlCMI = "";

            foreach (Weblist.ContextMenuItem cm1 in listContextMenuItems)
            {
                string sRow = "";
                sRow     = "   \"" + cm1.Name + "\": {name: \"" + cm1.Caption + "\", icon: \"" + cm1.Caption + "\"},";
                htmlCMI += sRow;
            }

            string sContextMenuCssClass = "context-menu-" + CleanName(divname);



            string sOut = "<div id='" + divname + "' " + sDivClass + " name='" + divname + "'><table " + sBorderStyle + " class='" + sContextMenuCssClass + "' " + sFrameStyle + " cellspacing=5 cellpadding=5 width=100%>"
                          + "<tr><th colspan=10 cellpadding=0 cellspacing=0 style='border-bottom: grey thin solid' class='ui-dialog-titlebar ui-corner-all ui-widget-header'>"
                          + "<span class='ui-dialog-title'>" + FriendlyName + "</span>" + sButtons + "</th></tr>";

            string javascript = "";

            if (htmlCMI.Length > 0)
            {
                htmlCMI = htmlCMI.Substring(0, htmlCMI.Length - 1);
            }
            string sContextEvent = " onclick=postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,'');";
            string sContextMenu  = "  $(function() {   $.contextMenu({     selector: '." + sContextMenuCssClass + "',        callback: function(key, options) { " +
                                   "       " + sContextEvent + "            },"
                                   + "       items: {  " + htmlCMI + "                     }                    });"
                                   + "       $('." + sContextMenuCssClass + "').on('click', function(e){      console.log('clicked', this);        })        });";



            javascript += sContextMenu;

            int iCurCol       = 0;
            int iCurCellCount = 0;
            int iCurRowCount  = 0;

            if (Expanded)
            {
                foreach (KeyValuePair <string, object> entry in _controls)
                {
                    GodEdit ge = (GodEdit)entry.Value;
                    if (iCurCol == 0)
                    {
                        sOut += "<TR>";
                    }

                    WebReply wr          = ge.Render(caller);
                    string   sDivWrapper = "divWrapper" + Guid.NewGuid().ToString();

                    if (SecMode == SystemObject.SectionMode.Customize)
                    {
                        string sObject = ge.CaptionText + ": " + ge.TextBoxValue;
                        string susgdid = Guid.NewGuid().ToString();
                        string sCoords = "coords" + iCurCol.ToString() + "-" + iCurRowCount.ToString();
                        sOut += "<td " + sBorderStyle + "><span usgdid='z" + susgdid + "' usgdname='" + sCoords + "' usgdcaption='" + sCoords + "'></span><div class='drag1'>"
                                + "<span usgdcaption='" + ge.CaptionText + "' usgdname='" + ge.Name + "' usgdid='" + susgdid
                                + "' usgdvalue='" + ge.TextBoxValue + "' >" + sObject + "&nbsp;</span></div></td>";
                    }
                    else
                    {
                        sOut += "<td>" + wr.Packages[0].HTML + "</td>";
                    }
                    javascript += wr.Packages[0].Javascript;
                    iCurCol++;
                    iCurCellCount++;
                    if (iCurCol == ColumnCount)
                    {
                        if (iCurRowCount == 0)
                        {
                            if (DisplayPictureHTML != null)
                            {
                                sOut += "<td rowspan=5>" + DisplayPictureHTML + "</TD>";
                            }
                        }

                        iCurRowCount++;
                        sOut   += "</TR>";
                        iCurCol = 0;
                    }
                }
            }

            sOut += "</TR>";
            sOut += "</table></div><p>";
            WebReply wr1 = new WebReply();

            string sIdentifier         = "USGDrag";
            string sEvent              = "alert('test');";
            string sJavaEventAfterDrop = "  var sOut=''; $(this).closest('table').find('span').each(function (index) "
                                         + "        {        var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                         + "                 var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                         + "                 var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                         + "                 var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                         + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                         + "      if (sUSGDID != null) {  if (sUSGDID.length > 0)   sOut += s;  }  }); ";

            string sDropEvent = sJavaEventAfterDrop + "postdiv(this,'dropevent','" + myClass + "','" + sMyMethod + "','[DROPPABLE]"
                                + divname + "[/DROPPABLE][DATA]' + sOut + '[/DATA]');";


            string DraggableJavascript = "     $('.drag1').draggable({  "
                                         + "    helper: 'clone',        start: function(event, ui)"
                                         + "    {            c.tr = this;                c.helper = ui.helper;            }    });"
                                         + "   $('.drag1').droppable({     drop: function(event, ui) {     "
                                         + "  "
                                         + "   $(c.helper).remove();        }     });";

            DraggableJavascript = " var myDraggedObject = null; $(function() { $( '.drag1' ).draggable({containment:parent});  }); ";
            DraggableJavascript = "var myDraggedObject = null; var myOriginalHTML = null; $('.drag1').draggable(  "
                                  + "{ revert: function(droppableContainer) {         if(droppableContainer) { var thisisvalid='valid';    }       else {        myDraggedObject.innerHTML=myOriginalHTML;     } } ,"
                                  + "      helper: 'clone', "
                                  + "      containment: '.dragContent', cursor:'move', snap: true, snapMode: 'inner',"
                                  + "     start: function(event, ui)   {  myDraggedObject = this; this.setAttribute('usgdname','test'); "
                                  + "       myOriginalHTML = myDraggedObject.innerHTML; myDraggedObject.setAttribute('usgdname','bye3');  "
                                  + "       myDraggedObject.innerHTML ='&nbsp;';      }   });  "
                                  + "                $('.drag1').droppable(  {drop: function(event, ui) { ui.helper[0].innerHTML='bye'; myDraggedObject.innerHTML = myOriginalHTML; ui.draggable.detach().appendTo($(this));   " + sDropEvent + "  }     }); ";

            if (SecMode == SystemObject.SectionMode.Customize)
            {
                javascript += DraggableJavascript;
            }
            wr1.AddWebReply(sOut, javascript, Name, false);
            WebReplyPackage wrp1 = wr1.Packages[0];

            wrp1.ClearScreen = ClearScreen;
            wr1.Packages[0]  = wrp1;
            return(wr1);
        }