示例#1
0
 /// <summary>
 /// Nạp các cài đặt dạng XMLNode vào Plugin
 /// </summary>
 /// <param name="SettingNode">XMLNode: Node chức các cài đặt</param>
 /// <param name="_IPlug">IPlug: Plugin cần cài đặt</param>
 public static void LoadSettings(XmlNode SettingNode, IPlug _IPlug)
 {
     if (SettingNode == null) throw new Exception("Xml cài đặt chưa có giá trị");
     _IPlug.PluginId = SettingNode.Attributes["ID"].Value;
     _IPlug.PluginClientId = SettingNode.Attributes["PluginClientId"].Value;
     _IPlug.PluginIndex = SettingNode.Attributes["PluginIndex"].Value;
     _IPlug.ZoneIndex = SettingNode.Attributes["ZoneIndex"].Value;
     _IPlug.Title = SettingNode.Attributes["Title"].Value;
     _IPlug.PluginIcon = SettingNode.Attributes["PluginIcon"].Value;
     _IPlug.Display = Convert.ToBoolean(SettingNode.Attributes["Display"].Value);
     _IPlug.ShowBorder = Convert.ToBoolean(SettingNode.Attributes["ShowBorder"].Value);
     _IPlug.ShowHeader = Convert.ToBoolean(SettingNode.Attributes["ShowHeader"].Value);
     _IPlug.ShowFoot = Convert.ToBoolean(SettingNode.Attributes["ShowFoot"].Value);
     _IPlug.Public = Convert.ToBoolean(SettingNode.Attributes["Public"].Value);
     _IPlug.PluginType = SettingNode.Attributes["PluginType"].Value;
     _IPlug.XmlSourcePath = SettingNode.Attributes["XmlSourcePath"].Value;
     _IPlug.IsCached = Convert.ToBoolean(SettingNode.Attributes["IsCached"].Value);
     _IPlug.IsCp = Convert.ToBoolean(SettingNode.Attributes["IsCp"].Value);
     _IPlug.IsInvisible = Convert.ToBoolean(SettingNode.Attributes["IsInvisible"].Value);
     _IPlug.IsShared = Convert.ToBoolean(SettingNode.Attributes["IsShared"].Value);
     if (SettingNode.Attributes["PluginCss"] != null)
     {
         _IPlug.PluginCss = SettingNode.Attributes["PluginCss"].Value;
     }
 }
示例#2
0
        /// <summary>
        /// Nạp các cài đặt dạng Object[] vào Plugin
        /// </summary>
        /// <param name="obj">Object[]: Mảng các cài đặt</param>
        /// <param name="_IPlug">IPlug: Plugin cần cài đặt</param>
        public static void LoadSettings(object[] obj, IPlug _IPlug)
        {
            if (obj != null)
            {
                if (obj.Length > 0)
                {
                    Type type = _IPlug.GetType();
                    for (int i = 0; i < (obj.Length - 1); i += 2)
                    {
                        PropertyInfo property = type.GetProperty(obj[i].ToString());
                        if (property != null && obj[i + 1] != null)
                        {
                            if (obj[i + 1].ToString() != "")
                            {
                                if (property.PropertyType.Name.ToLower() == "boolean")
                                {
                                    property.SetValue(_IPlug, Convert.ToBoolean(obj[i + 1]), null);

                                }
                                else
                                {
                                    property.SetValue(_IPlug, obj[i + 1], null);

                                }
                            }
                        }
                    }

                }
            }
        }
示例#3
0
        // load in our dlls
        private void LoadPlugins()
        {
            try
            {
                Type pluginType = typeof(IPlug);                                       // what type to look for from assembly types
                Dictionary <string, IPlug> plugins = new Dictionary <string, IPlug>(); // list of plugins

                // Paths
                string   pluginPath = Directory.GetCurrentDirectory() + @"\Plugins\"; // get path for our plugin directory
                string[] files      = Directory.GetFiles(pluginPath, "*.dll");        // get paths to every .dll file.

                foreach (string s in files)
                {
                    AssemblyName an       = AssemblyName.GetAssemblyName(s); // get assemblyname from dll paths string
                    Assembly     assembly = Assembly.Load(an);               // load in the assembly

                    Type[] types = assembly.GetTypes();                      //list all types the assembly has
                    foreach (Type type in types)
                    {
                        // check that the type we are looking at is a class that implements our interface and not an abstract class or interface file
                        if (type.GetInterface(pluginType.FullName) != null && !type.IsAbstract && !type.IsInterface)
                        {
                            IPlug plug = (IPlug)Activator.CreateInstance(type); // run the plugin
                            plugins.Add(plug.Name, plug);                       // store the plugin in dictionary with a keyword, for later use.
                            plug.Update();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
 /// <summary>
 /// 使用插件
 /// </summary>
 /// <param name="plug">插件</param>
 /// <exception cref="ArgumentNullException"></exception>
 public void Use(IPlug plug)
 {
     if (plug == null)
     {
         throw new ArgumentNullException();
     }
     this.plugs.Add(plug);
 }
        private void menuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
            //从菜单项中取出对应的插件对象
            IPlug iplug = menuItem.Tag as IPlug;

            //调用对象的处理文字方法,并重新设置给文本框
            doc.TxtSource.Text = iplug.ProcessText(doc.TxtSource.Text);
        }
示例#6
0
 //3. Connect a plug to the adapter (using dependency injection).
 //(Optional: using interface in the dependency injection is like a blind man trying to connect a plug.
 //We can't know if the plug is compatible or not with the adapter unless we enforce it to be compatible (using TypeCasting or using a base class instead of an interface as the ctor argument).
 public FourSocketAdapter(IPlug plug)
 {
     try
     {
         //4. If using interface in the dependency injection instead of base class, then ensure to force a specific plug type that will be compatible with the adapter.
         //In our case, only a three-plug is compatible with the ThreeSocketAdapter. So we force/typecast the plug to a three-plug.
         FourPlug = (FourPlug)plug;
     }
     catch (TypeInitializationException ex)
     {
         throw ex;
     }
 }
示例#7
0
 public string buildModule(IPlug _IPlug, int id, int zone)
 {
     return string.Format(@"
     <div id=""{2}"" class=""mdl"" zone=""{3}"">
     <div class=""mdl-head"">
     <span class=""mdl-tool"">
         <a href=""javascript:;"" _type=""{4}"" _id=""{2}"" class=""mdl-tool-btn mdl-tool-edit"">sửa</a>
         <a href=""javascript:;"" _id=""{2}"" class=""mdl-tool-btn mdl-tool-del"">xóa</a>
     </span>
     <span class=""mdl-move-icon""></span>
     <span class=""mdl-title"">{0}</span>
     </div>
     <div class=""mdl-body"">{1}</div>
     </div>", _IPlug.Title, _IPlug.Html, id, zone, _IPlug.PluginType);
 }
示例#8
0
        static void Main(string[] args)
        {
            // Setup an 8k inputBuffer because really long UCI strings were getting truncated
            Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);

            Console.SetIn(new StreamReader(inputStream, Encoding.ASCII, false, inputBuffer.Length));

            IPlug cp = (IPlug) new ConsolePlug();

            Plug.Init(cp);

            Engine e = new Engine();

            System.Threading.Thread t = new System.Threading.Thread(e.Run);
            t.Start(args);
        }
        //初始化插件程序
        private void MakeBtnByDll()
        {
            //1. 加载正在运行的程序集的物理路径
            string assPath = this.GetType().Assembly.Location;
            // 2. 获取程序集所在的文件夹,并转换成程序及文件夹的路径
            string strDirPath = Path.GetDirectoryName(assPath) + "\\plug";

            // 3.扫描文件夹里面的所有程序及文件
            string[] strDllPaths = Directory.GetFiles(strDirPath);
            //4. 边里所有的程序集文件路径,并加载程序集到内存中
            foreach (string strDll in strDllPaths)
            {
                //4.1 根据路径加载程序集文件到内存中
                Assembly ass = Assembly.LoadFrom(strDll);
                // 4.2 判断程序集中是否有插件类,
                // 4.2.1 获得插件程序集里面共有得类
                Type[] types = ass.GetExportedTypes();
                //重要:获取插件接口类型对象
                Type plugType = typeof(IPlug);
                //4.2.2 循环遍历插件程序集里面的类型,判断是否实现了插件记事本接口
                foreach (Type t in types)
                {
                    //判断t是否实现了Iplug接口
                    if (plugType.IsAssignableFrom(t))
                    {
                        //4.3 创建插件按钮
                        ToolStripMenuItem menuItem = new ToolStripMenuItem(t.Name);
                        this.menuPlug.DropDownItems.Add(menuItem);
                        //为所有的按钮点击事件绑定同一个方法
                        menuItem.Click += menuItem_Click;

                        //重要:根据插件类型,创建插件类对象,并转换成接口对象统一调用
                        IPlug plugObj = Activator.CreateInstance(t) as IPlug;
                        //将接口对象存入按钮的tag属性
                        menuItem.Tag = plugObj;
                    }
                }
            }
        }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();

        string imgSaveLoc    = Server.MapPath("~/lib/up/i/");
        string imgSaveTintuc = Server.MapPath("~/lib/up/tintuc/");
        string imgTemp       = Server.MapPath("~/lib/up/temp/");
        string docTemp       = Server.MapPath("~/lib/up/d/");
        bool   loggedIn      = Security.IsAuthenticated();

        insertLog("0", Security.Username, Request.UserHostAddress, Request.Url.PathAndQuery);
        switch (act)
        {
        case "loadPlug":
            if (rqPlug != null)
            {
                sb.Append(PlugHelper.RenderHtml(rqPlug));
            }
            rendertext(sb);
            break;

        case "upload":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(730, 600);
                    img.Save(imgSaveLoc + imgten + "730x600" + img.Ext);
                    img.Crop(420, 280);
                    img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                    img.Crop(130, 100);
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadTintuc":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(730, 600);
                    img.Save(imgSaveTintuc + imgten + "730x600" + img.Ext);
                    img.Crop(420, 280);
                    img.Save(imgSaveTintuc + imgten + "420x280" + img.Ext);
                    img.Crop(130, 100);
                    img.Save(imgSaveTintuc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadFull":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadfileDkLuong":
            #region upload tài liệu
            if (!loggedIn)
            {
                rendertext("403");
            }
            if (Request.Files[0] != null)
            {
                string foldername = Guid.NewGuid().ToString().Replace("-", "");
                string filename   = Path.GetFileNameWithoutExtension(Request.Files[0].FileName);
                string fileType   = Path.GetExtension(Request.Files[0].FileName);
                Directory.CreateDirectory(docTemp + foldername);
                Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                Files item = new Files();
                item.Download = 0;
                item.MimeType = fileType;
                item.NgayTao  = DateTime.Now;
                item.NguoiTao = Security.Username;
                item.Path     = filename;
                item.PID      = Guid.NewGuid();
                item.RowId    = Guid.NewGuid();
                item.Size     = Request.Files[0].ContentLength;
                item.Ten      = filename;
                item.ThuMuc   = foldername;
                item.VB_ID    = 0;
                item          = FilesDal.Insert(item);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "download":
            string _F_ID = Request["ID"];
            if (!string.IsNullOrEmpty(_F_ID))
            {
                Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                Response.Buffer = true;
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                Response.ContentType = "octet/stream";
                //Response.ContentType = "application/ms-word";
                Response.WriteFile(Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
            }
            break;

        case "loadPlugDirect":
            if (!string.IsNullOrEmpty(rqPlug))
            {
                string _IPlugType = rqPlug;
                Type   type       = Type.GetType(_IPlugType);
                IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                _IPlug.ImportPlugin();
                Page        pageHolder = new Page();
                UserControl uc         = (UserControl)(_IPlug);
                this.Controls.Add(uc);
            }
            break;

        case "uploadvideo":

            break;

        default:
            string d = "12/9/2010";
            //DateTime da = Convert.ToDateTime(d, new System.Globalization.CultureInfo("vi-Vn"));
            //Response.Write(da.Month.ToString());
            Response.Write(maHoa.EncryptString("111", "phatcd"));
            break;
        }
    }
示例#11
0
 public ServiceWithPlug(IPlug <T> plug)
 {
     _plug = plug;
 }
示例#12
0
文件: Plug.cs 项目: timvw74/Portfish
 public static void Init(IPlug iFace)
 {
     Interface = iFace;
 }
示例#13
0
文件: Plug.cs 项目: torfranz/Portfish
 public static void Init(IPlug iFace)
 {
     Interface = iFace;
 }
示例#14
0
 /// <summary>
 /// Trả Plugin về dạng HTML  với các thiết lập đã có sẵn
 /// </summary>
 /// <param name="_IPlug">IPlug: Plugin đã được cài đặt sẵn các thuộc tính</param>
 /// <returns>Dữ liệu dạng HTML</returns>
 public static string RenderHtml(IPlug _IPlug)
 {
     if (_IPlug == null) return string.Empty;
     Page pageHolder = new Page();
     UserControl uc = (UserControl)(_IPlug);
     pageHolder.Controls.Add(uc);
     StringWriter sw = new StringWriter();
     HttpContext.Current.Server.Execute(pageHolder, sw, true);
     return sw.ToString();
 }
示例#15
0
        /// <summary>
        /// Trả về dạng XML với một Plugin có sẵn cài đặt mặc định (Thường khi Import Plugin từ DLL)
        /// </summary>
        /// <param name="_IPlug">IPlug: Plugin</param>
        /// <returns>XMLNode</returns>
        public static XmlNode RenderXml(IPlug _IPlug)
        {
            XmlDocument doc = new XmlDocument();

            XmlNode root = doc.CreateNode(XmlNodeType.XmlDeclaration, null, null);
            doc.AppendChild(root);
            // Root element: PluginNode
            XmlElement PluginNode = doc.CreateElement("Plugin");
            doc.AppendChild(PluginNode);

            #region Thuộc tính của Plugin
            XmlAttribute PluginNodePluginType = doc.CreateAttribute("PluginType");
            PluginNodePluginType.Value = _IPlug.PluginType;
            PluginNode.Attributes.Append(PluginNodePluginType);

            XmlAttribute PluginNodeID = doc.CreateAttribute("ID");
            PluginNodeID.Value = _IPlug.PluginId;
            PluginNode.Attributes.Append(PluginNodeID);

            XmlAttribute PluginNodePluginClientId = doc.CreateAttribute("PluginClientId");
            PluginNodePluginClientId.Value = _IPlug.PluginClientId;
            PluginNode.Attributes.Append(PluginNodePluginClientId);

            XmlAttribute PluginNodePluginIndex = doc.CreateAttribute("PluginIndex");
            PluginNodePluginIndex.Value = _IPlug.PluginIndex;
            PluginNode.Attributes.Append(PluginNodePluginIndex);

            XmlAttribute PluginNodeZoneIndex = doc.CreateAttribute("ZoneIndex");
            PluginNodeZoneIndex.Value = _IPlug.ZoneIndex;
            PluginNode.Attributes.Append(PluginNodeZoneIndex);

            XmlAttribute PluginNodeTitle = doc.CreateAttribute("Title");
            PluginNodeTitle.Value = _IPlug.Title;
            PluginNode.Attributes.Append(PluginNodeTitle);

            XmlAttribute PluginNodePluginIcon = doc.CreateAttribute("PluginIcon");
            PluginNodePluginIcon.Value = _IPlug.PluginIcon;
            PluginNode.Attributes.Append(PluginNodePluginIcon);

            XmlAttribute PluginNodeDisplay = doc.CreateAttribute("Display");
            PluginNodeDisplay.Value = _IPlug.Display.ToString();
            PluginNode.Attributes.Append(PluginNodeDisplay);

            XmlAttribute PluginNodeShowBorder = doc.CreateAttribute("ShowBorder");
            PluginNodeShowBorder.Value = _IPlug.ShowBorder.ToString();
            PluginNode.Attributes.Append(PluginNodeShowBorder);

            XmlAttribute PluginNodeShowHeader = doc.CreateAttribute("ShowHeader");
            PluginNodeShowHeader.Value = _IPlug.ShowHeader.ToString();
            PluginNode.Attributes.Append(PluginNodeShowHeader);

            XmlAttribute PluginNodeShowFoot = doc.CreateAttribute("ShowFoot");
            PluginNodeShowFoot.Value = _IPlug.ShowFoot.ToString();
            PluginNode.Attributes.Append(PluginNodeShowFoot);

            XmlAttribute PluginNodePublic = doc.CreateAttribute("Public");
            PluginNodePublic.Value = _IPlug.Public.ToString();
            PluginNode.Attributes.Append(PluginNodePublic);

            XmlAttribute PluginNodeXmlSourcePath = doc.CreateAttribute("XmlSourcePath");
            PluginNodeXmlSourcePath.Value = _IPlug.XmlSourcePath;
            PluginNode.Attributes.Append(PluginNodeXmlSourcePath);

            XmlAttribute PluginNodeIsCached = doc.CreateAttribute("IsCached");
            PluginNodeIsCached.Value = _IPlug.IsCached.ToString();
            PluginNode.Attributes.Append(PluginNodeIsCached);

            XmlAttribute PluginNodeIsCp = doc.CreateAttribute("IsCp");
            PluginNodeIsCp.Value = _IPlug.IsCp.ToString();
            PluginNode.Attributes.Append(PluginNodeIsCp);

            XmlAttribute PluginNodeIsInvisible = doc.CreateAttribute("IsInvisible");
            PluginNodeIsInvisible.Value = _IPlug.IsInvisible.ToString();
            PluginNode.Attributes.Append(PluginNodeIsInvisible);

            XmlAttribute PluginNodeIsShared = doc.CreateAttribute("IsShared");
            PluginNodeIsShared.Value = _IPlug.IsShared.ToString();
            PluginNode.Attributes.Append(PluginNodeIsShared);
            #endregion

            #region Thuộc tính khác
            XmlElement PluginSettings = doc.CreateElement("ModuleSettings");
            PluginNode.AppendChild(PluginSettings);
            foreach (ModuleSetingTab Tab in _IPlug.Tabs)
            {

                #region Thuộc tính cơ bản của SettingTab
                XmlElement TabElement = doc.CreateElement("ModuleSettingTabs");
                PluginSettings.AppendChild(TabElement);

                XmlAttribute TabID = doc.CreateAttribute("ID");
                TabID.Value = Tab.TabId.ToString();
                TabElement.Attributes.Append(TabID);

                XmlAttribute TabName = doc.CreateAttribute("Name");
                TabName.Value = Tab.Name;
                TabElement.Attributes.Append(TabName);

                XmlAttribute TabIndex = doc.CreateAttribute("Index");
                TabIndex.Value = Tab.Index.ToString();
                TabElement.Attributes.Append(TabIndex);
                #endregion

                #region Setting
                foreach (ModuleSetting Setting in Tab.Settings)
                {
                    XmlElement SettingElement = doc.CreateElement("ModuleSetting");
                    TabElement.AppendChild(SettingElement);

                    XmlAttribute SettingKey = doc.CreateAttribute("Key");
                    SettingKey.Value = Setting.Key;
                    SettingElement.Attributes.Append(SettingKey);

                    XmlAttribute SettingTitle = doc.CreateAttribute("Title");
                    SettingTitle.Value = Setting.Title;
                    SettingElement.Attributes.Append(SettingTitle);

                    XmlAttribute SettingType = doc.CreateAttribute("Type");
                    SettingType.Value = Setting.Type;
                    SettingElement.Attributes.Append(SettingType);
                    #region Value
                    if (Setting.Childrens != null) // Kiểm tra xem giá trị này có nhiều lựa chọn không
                    {
                        foreach (ModuleSettingItem SettingItem in Setting.Childrens)
                        {
                            XmlElement SettingItemElement = doc.CreateElement("ModuleSettingItem");
                            SettingElement.AppendChild(SettingItemElement);

                            XmlAttribute SettingItemElementSelect = doc.CreateAttribute("Select");
                            SettingItemElementSelect.Value = SettingItem.Value == Setting.Value ? "True" : "False";
                            SettingItemElement.Attributes.Append(SettingItemElementSelect);

                            XmlAttribute SettingItemElementValue = doc.CreateAttribute("Value");
                            SettingItemElementValue.Value = SettingItem.Value;
                            SettingItemElement.Attributes.Append(SettingItemElementValue);

                            XmlNode SettingItemElementHtml = doc.CreateCDataSection(SettingItem.Html);
                            SettingItemElement.AppendChild(SettingItemElementHtml);
                        }
                    }
                    else
                    {
                        XmlNode SettingValue = doc.CreateCDataSection(Setting.Value);
                        SettingElement.AppendChild(SettingValue);

                    }
                    #endregion

                }
                #endregion

            }
            #endregion

            #region ModuleSercurity

            if (_IPlug.Users != null)
            {
                XmlElement PluginSercurity = doc.CreateElement("Sercurity");
                PluginNode.AppendChild(PluginSercurity);
                foreach (ModuleSercurityUser User in _IPlug.Users)
                {
                    XmlElement PluginSercurityUser = doc.CreateElement("User");
                    PluginSercurity.AppendChild(PluginSercurityUser);

                    XmlAttribute PluginSercurityUserName = doc.CreateAttribute("Name");
                    PluginSercurityUserName.Value = User.Username;
                    PluginSercurityUser.Attributes.Append(PluginSercurityUserName);

                    XmlAttribute PluginSercurityPermision = doc.CreateAttribute("Permision");
                    PluginSercurityPermision.Value = User.Permision.ToString();
                    PluginSercurityUser.Attributes.Append(PluginSercurityPermision);
                }
            }

            #endregion

            return PluginNode;
        }
        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb              = new StringBuilder();
            string        act             = context.Request["act"];
            string        rqPlug          = context.Request["rqPlug"];
            string        imgSaveLoc      = context.Server.MapPath("~/lib/up/i/");
            string        imgTemp         = context.Server.MapPath("~/lib/up/temp/");
            string        docTemp         = context.Server.MapPath("~/lib/up/d/");
            string        imgSaveTintuc   = context.Server.MapPath("~/lib/up/tintuc/");
            string        imgSaveSanPham  = context.Server.MapPath("~/lib/up/sanpham/");
            string        imgSaveQuangCao = context.Server.MapPath("~/lib/up/quangcao/");
            string        imgSaveKTNN     = context.Server.MapPath("~/lib/up/KTNN/");

            string _height   = context.Request["height"];
            string _width    = context.Request["width"];
            string _PRowIdSP = context.Request["PRowIdSP"];

            switch (act)
            {
            case "loadPlug":
                #region loadPlug: nap plug
                if (rqPlug != null)
                {
                    sb.Append(PlugHelper.RenderHtml(rqPlug));
                }
                rendertext(sb);
                break;

                #endregion
            case "upload":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, imgten);
                    context.Request.Files[0].SaveAs(imgSaveLoc + imgten + "full" + img.Ext);

                    img.Crop(420, 560);
                    img.Save(imgSaveLoc + imgten + "420x560" + img.Ext);

                    img.Crop(240, 180);
                    img.Save(imgSaveLoc + imgten + "240x180" + img.Ext);

                    img.Crop(100, 100);
                    img.Save(imgSaveLoc + imgten + "100x100" + img.Ext);

                    img.Crop(50, 50);
                    img.Save(imgSaveLoc + imgten + img.Ext);

                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadQuangCao":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveQuangCao + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveQuangCao + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveQuangCao + imgten + "source" + img.Ext);
                    img.Crop(int.Parse(_width), int.Parse(_height));
                    img.Save(imgSaveQuangCao + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadSanPham":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveSanPham + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveSanPham + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(400, 400);
                    img.Save(imgSaveSanPham + imgten + "400x400" + img.Ext);
                    img.Crop(400, 300);
                    img.Save(imgSaveSanPham + imgten + "400x300" + img.Ext);
                    img.Crop(200, 200);
                    img.Save(imgSaveSanPham + imgten + "200x200" + img.Ext);
                    img.Crop(90, 90);
                    img.Save(imgSaveSanPham + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadTintuc":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveTintuc + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveTintuc + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        context.Request.Files[0].SaveAs(imgSaveTintuc + imgten + "full" + img.Ext);
                        img.Crop(180, 120);
                        img.Save(imgSaveTintuc + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadKTNN":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveKTNN + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveKTNN + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(730, 600);
                        img.Save(imgSaveKTNN + imgten + "730x600" + img.Ext);
                        img.Crop(420, 280);
                        img.Save(imgSaveKTNN + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveKTNN + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadFlash":
                #region upload flash
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".swf")
                    {
                        string flash = Guid.NewGuid().ToString();

                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + flash + Path.GetExtension(context.Request.Files[0].FileName));
                        rendertext(flash + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                    else
                    {
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(420, 280);
                        img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveLoc + imgten + img.Ext);
                        img.Crop(370, 90);
                        img.Save(imgSaveLoc + imgten + "370x90" + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }

                break;

                #endregion
            case "uploadFull":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
                break;

                #endregion
            case "uploadfileDkLuong":
                #region upload tài li?u
                //if (!loggedIn) rendertext("403");
                if (context.Request.Files[0] != null)
                {
                    string foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string filename   = Path.GetFileNameWithoutExtension(context.Request.Files[0].FileName);
                    string fileType   = Path.GetExtension(context.Request.Files[0].FileName);
                    Directory.CreateDirectory(docTemp + foldername);
                    context.Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                    //context.Request.Files[0].SaveAs(docTemp +  filename + fileType);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = fileType;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = filename;
                    item.PID      = Guid.NewGuid();
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = filename;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(item.ID.ToString());
                }
                break;

                #endregion
            case "download":
                string _F_ID = context.Request["ID"];
                if (!string.IsNullOrEmpty(_F_ID))
                {
                    Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                    context.Response.Buffer = true;
                    context.Response.Clear();
                    context.Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                    context.Response.ContentType = "octet/stream";
                    //Response.ContentType = "application/ms-word";
                    context.Response.WriteFile(context.Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
                }
                break;

            case "uploadvideo":
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten         = Guid.NewGuid().ToString();
                        string strVideoRender = "";
                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        string _hinhanh = "";
                        string fWmv     = "";
                        if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".flv")
                        {
                            fWmv = WMV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");
                            context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + fWmv);
                            _hinhanh = CreatImg(context, fWmv, imgten + Path.GetExtension(context.Request.Files[0].FileName));
                            System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + fWmv);
                        }
                        else
                        {
                            fWmv = FLV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");

                            fWmv     = context.Request.Files[0].FileName;
                            _hinhanh = CreatImg(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        }
                        rendertext(_hinhanh + ";" + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                }

                break;

            case "DelOldFlash":
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + Path.GetExtension(context.Request.Files[0].FileName));
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/i/") + Path.GetExtension(context.Request.Files[0].FileName));
                break;

            case "MultiuploadImg":
                #region UploadAnh
                if (context.Request.Files[0] != null)
                {
                    ImageProcess img        = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    string       foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string       imgten     = Guid.NewGuid().ToString();
                    Directory.CreateDirectory(imgSaveSanPham + foldername);

                    context.Request.Files[0].SaveAs(imgSaveSanPham + foldername + "/" + imgten + "full" + img.Ext);
                    img.Crop(400, 400);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + "400x400" + img.Ext);
                    img.Crop(75, 75);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + img.Ext);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = img.Ext;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = imgten + img.Ext;
                    item.PID      = new Guid(_PRowIdSP);
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = imgten;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item)));
                }
                break;

                #endregion
            case "loadPlugDirect":
                if (!string.IsNullOrEmpty(rqPlug))
                {
                    string _IPlugType = rqPlug;
                    Type   type       = Type.GetType(_IPlugType);
                    IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                    _IPlug.ImportPlugin();
                    UserControl uc   = (UserControl)(_IPlug);
                    Page        page = new Page();
                    page.EnableViewState = false;
                    HtmlForm form = new HtmlForm();
                    form.ID = "__t";
                    page.Controls.Add(form);
                    form.Controls.Add(uc);
                    StringWriter tw = new StringWriter();
                    HttpContext.Current.Server.Execute(page, tw, true);
                }
                break;

            case "capcha":
                #region capcha
                string _capchaCode = CaptchaImage.GenerateRandomCode(CaptchaType.AlphaNumeric, 3);
                context.Session["capcha"] = _capchaCode;
                CaptchaImage c = new CaptchaImage(_capchaCode, 200, 50, "Tahoma", Color.White, Color.Orange);
                context.Response.ClearContent();
                context.Response.ContentType = "image/jpeg";
                MemoryStream ms = new MemoryStream();
                c.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                context.Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length));
                ms.Close();
                context.Response.End();
                break;

                #endregion
            default:
                #region macdinh
                context.Response.Write(DateTime.Now.ToString("hh:mm"));
                break;
                #endregion
            }
        }
示例#17
0
 /// <summary>
 /// 使用插件
 /// </summary>
 /// <param name="plug">插件</param>
 /// <exception cref="ArgumentNullException"></exception>
 public void UsePlug(IPlug plug)
 {
     this.plugManager.Use(plug);
 }
示例#18
0
        public void EDITOR_DrawNode()
        {
            if (!is_ready)
            {
                return;
            }
            gui_color         = GUI.color;
            gui_back_color    = GUI.backgroundColor;
            gui_content_color = GUI.contentColor;

            if (is_active || is_selected || GraphEditor.hover_node == this || (GraphEditor.drag_port && GraphEditor.drag_port.node == this))
            {
            }
            else
            {
                GUI.color = new Color(gui_color.r, gui_color.g, gui_color.b, 0.5f);
            }

            // for better performance
            if (is_occluded)
            {
                foreach (Port port in portValues)
                {
                    if (!port.display_port)
                    {
                        continue;
                    }
                    IPlugIn plug_in = port as IPlugIn;
                    if (plug_in == null || !plug_in.IsPlugged())
                    {
                        continue;
                    }
                    port.node = this;

                    Vector2 start = GetPortPoint(port).center;
                    Vector2 end   = GetPortPoint((Port)plug_in.GetPluggedPort()).center;
                    if (port is ActionPort)
                    {
                        end   = GetPortPoint(port).center;
                        start = GetPortPoint((Port)plug_in.GetPluggedPort()).center;
                    }

                    Node.DrawConnection(start, end, GetPortColor(port), false);
                    if (Application.isPlaying)
                    {
                        if (port.flow_state == FlowState.Active)
                        {
                            port.unit_delta_size = 1.0f;
                            port.flow_state      = FlowState.Idle;
                        }
                        else
                        {
                            port.unit_delta_size = Mathf.MoveTowards(port.unit_delta_size, 0.0f, EditorTime.deltaTime / 2.0f);
                        }

                        GUI.backgroundColor = GetPortColor(port);
                        float distance = FPMath.SnapValue(Vector3.Distance(start, end) / 100.0f, 1);
                        for (int id = 0; id < Mathf.RoundToInt(distance); id++)
                        {
                            float   t         = 1.0f - (((EditorTime.time / distance) + (1.0f / distance) * id) % 1.0f);
                            Vector2 unit_size = V2x16y16 * port.unit_delta_size;
                            GUI.Box(new Rect(LerpUnit(start, end, t) - V2x0y2 - unit_size / 2.0f, unit_size), "", styles.unit);
                        }
                        GUI.backgroundColor = gui_back_color;
                    }
                    else
                    {
                        if (GUI.Button(new Rect(MiddleOfConnection(end, start) - V2x8y9, V2x16y16), "x", styles.unplug_button))
                        {
                            GraphEditor.UnplugPort(port);
                        }
                    }
                }
            }
            else
            {
                if (is_selected)
                {
                    GUI.Box(nodeRect, string.Empty, styles.highlight_node);
                }

                is_active = GraphEditor.makeAllNodesActive || this is EventNode || this is InputNode || this is OutputNode;
                //Draw Node with custom color
                GUI.backgroundColor = node_color;
                if (slim)
                {
                    DrawSlimNode();
                }
                else
                {
                    DrawNode();
                }
                GUI.backgroundColor = gui_back_color;

                // Color gui_color = GUI.color;
                foreach (Port input in inputValues)
                {
                    input.node = this;
                    if (!input.display_port)
                    {
                        continue;
                    }
                    IPlug       plug        = input as IPlug;
                    IPlugIn     plug_in     = input as IPlugIn;
                    bool        on          = plug != null && plug.IsPlugged();
                    IInputValue input_value = input as IInputValue;
                    Rect        port_rect   = GetPortPoint(input);

                    if (plug_in != null)
                    {
                        if (plug_in.IsPlugged())
                        {
                            Vector2 start = port_rect.center;
                            Vector2 end   = GetPortPoint((Port)plug_in.GetPluggedPort()).center;

                            Node.DrawConnection(start, end, GetPortColor(input), false);

                            if (Application.isPlaying)
                            {
                                if (input.flow_state == FlowState.Active)
                                {
                                    input.unit_delta_size = 1.0f;
                                    input.flow_state      = FlowState.Idle;
                                }
                                else
                                {
                                    input.unit_delta_size = Mathf.MoveTowards(input.unit_delta_size, 0.0f, EditorTime.deltaTime / 2.0f);
                                }

                                GUI.backgroundColor = GetPortColor(input);
                                float distance = FPMath.SnapValue(Vector3.Distance(start, end) / 100.0f, 1);
                                for (int id = 0; id < Mathf.RoundToInt(distance); id++)
                                {
                                    float   t         = 1.0f - (((EditorTime.time / distance) + (1.0f / distance) * id) % 1.0f);
                                    Vector2 unit_size = V2x16y16 * input.unit_delta_size;
                                    GUI.Box(new Rect(LerpUnit(start, end, t) - V2x0y2 - unit_size / 2.0f, unit_size), "", styles.unit);
                                }
                                GUI.backgroundColor = gui_back_color;
                            }
                            else
                            {
                                if (GUI.Button(new Rect(MiddleOfConnection(start, end) - V2x8y9, V2x16y16), "x", styles.unplug_button))
                                {
                                    GraphEditor.UnplugPort(input);
                                }
                            }
                        }
                        else if (input_value != null)
                        {
                            if (GraphEditor.showPortValues)
                            {
                                object value = input_value.GetDefaultValue();
                                Rect   value_label_rect;
                                string value_content     = "NO INFO";
                                float  value_label_width = 0.0f;
                                if (value == null)
                                {
                                    if (typeof(UnityEngine.Component).IsAssignableFrom(input_value.valueType) || typeof(Graph).IsAssignableFrom(input_value.valueType) || typeof(UnityEngine.GameObject).IsAssignableFrom(input_value.valueType))
                                    {
                                        if (EditorGUIUtility.isProSkin)
                                        {
                                            value_content = string.Format("<b><color=#0667FF>SELF: {0}</color></b>", input_value.valueType.GetTypeName());
                                        }
                                        else
                                        {
                                            value_content = string.Format("<b><color=#458fff>SELF: {0}</color></b>", input_value.valueType.GetTypeName());
                                        }
                                    }
                                    else
                                    {
                                        value_content = input_value.valueType.GetTypeName(true);
                                    }
                                }
                                else
                                {
                                    if (typeof(string).IsAssignableFrom(input_value.valueType))
                                    {
                                        value_content = string.Format("<color=#FFA06396>\"{0}\"</color>", value);
                                    }
                                    else if (typeof(UnityEngine.Component).IsAssignableFrom(input_value.valueType) || typeof(UnityEngine.GameObject).IsAssignableFrom(input_value.valueType) || typeof(Graph).IsAssignableFrom(input_value.valueType))
                                    {
                                        value_content = string.Format("<b><color=#0667FF>{0}</color></b>", value);
                                    }
                                    else if (typeof(Type).IsAssignableFrom(input_value.valueType))
                                    {
                                        value_content = ReflectionUtils.GetTypeName((Type)value, true);
                                    }
                                    else
                                    {
                                        if (input_value.valueType.IsGenericType)
                                        {
                                            value_content = input_value.valueType.GetTypeName(true);
                                        }
                                        else
                                        {
                                            value_content = value.ToString();
                                        }
                                    }
                                }
                                value_label_width = GUIUtils.GetTextWidth(value_content, styles.input_label);
                                value_label_rect  = new Rect(port_rect.x - (value_label_width + 15.0f), port_rect.y, value_label_width, 18.0f);
                                GUI.Label(value_label_rect, value_content, styles.input_label);
                            }
                        }
                    }

                    port_rect = GraphEditor.ZoomedRect(GetPortPoint(input));
                    if (port_rect.Contains(GraphEditor.mouse_position))
                    {
                        GraphEditor.hover_port = input;
                    }
                    else
                    {
                        GUI.backgroundColor = GetPortColor(input);
                    }
                    port_rect = GetPortPoint(input);

                    if (input is ActionPort)
                    {
                        if (!is_active && ((IPlug)input).IsPlugged())
                        {
                            List <IPlugIn> list = ((IPlugOut)input).GetPluggedPorts();
                            if (list != null && list.Any(p => ((Port)p).node && ((Port)p).node.is_active))
                            {
                                is_active = true;
                            }
                        }
                        GUI.Box(port_rect, slim ? string.Empty : input.name, on ? styles.on_input_action : styles.input_action);
                    }
                    else
                    {
                        GUI.Box(port_rect, slim ? string.Empty : input.name, on ? styles.on_input_port : styles.input_port);
                    }

                    GUI.backgroundColor = gui_back_color;
                }

                foreach (Port output in outputValues)
                {
                    output.node = this;
                    if (!output.display_port)
                    {
                        continue;
                    }
                    IPlug   plug      = output as IPlug;
                    IPlugIn plug_in   = output as IPlugIn;
                    bool    on        = plug != null && plug.IsPlugged();
                    Rect    port_rect = GetPortPoint(output);

                    if (plug_in != null)
                    {
                        if (plug_in.IsPlugged())
                        {
                            Vector2 start = port_rect.center;
                            Vector2 end   = GetPortPoint((Port)plug_in.GetPluggedPort()).center;

                            Node.DrawConnection(end, start, GetPortColor(output), false);

                            if (Application.isPlaying)
                            {
                                if (output.flow_state == FlowState.Active)
                                {
                                    output.unit_delta_size = 1.0f;
                                    output.flow_state      = FlowState.Idle;
                                }
                                else
                                {
                                    output.unit_delta_size = Mathf.MoveTowards(output.unit_delta_size, 0.0f, EditorTime.deltaTime / 2.0f);
                                }

                                float distance = FPMath.SnapValue(Vector3.Distance(start, end) / 100.0f, 1);
                                GUI.backgroundColor = GetPortColor(output);
                                for (int id = 0; id < Mathf.RoundToInt(distance); id++)
                                {
                                    float   t         = 1.0f - (((EditorTime.time / distance) + (1.0f / distance) * id) % 1.0f);
                                    Vector2 unit_size = V2x16y16 * output.unit_delta_size;
                                    GUI.Box(new Rect(LerpUnit(end, start, t) - V2x0y2 - unit_size / 2.0f, unit_size), "", styles.unit);
                                }
                                GUI.backgroundColor = gui_back_color;
                            }
                            else
                            {
                                if (GUI.Button(new Rect(MiddleOfConnection(start, end) - V2x8y9, V2x16y16), "x", styles.unplug_button))
                                {
                                    GraphEditor.UnplugPort(output);
                                }
                            }
                        }
                    }
                    port_rect = GraphEditor.ZoomedRect(GetPortPoint(output));
                    if (port_rect.Contains(GraphEditor.mouse_position))
                    {
                        GraphEditor.hover_port = output;
                    }
                    else
                    {
                        GUI.backgroundColor = GetPortColor(output);
                    }
                    port_rect = GetPortPoint(output);

                    if (output is ActionPort)
                    {
                        GUI.Box(port_rect, slim ? string.Empty : output.name, on ? styles.on_output_action : styles.output_action);
                    }
                    else
                    {
                        if (!is_active && ((IPlug)output).IsPlugged() && ((IPlugOut)output).GetPluggedPorts().Any(p => ((Port)p).node.is_active))
                        {
                            is_active = true;
                        }
                        GUI.Box(port_rect, slim ? string.Empty : output.name, on ? styles.on_output_port : styles.output_port);
                    }
                    GUI.backgroundColor = gui_back_color;
                }
                GUI.backgroundColor = gui_back_color;
            }
            GUI.color           = gui_color;
            GUI.backgroundColor = gui_back_color;
            GUI.contentColor    = gui_content_color;
        }