Exemplo n.º 1
0
        private void ReloadLicenses()
        {
            lsvLicenses.Items.Clear();
            foreach (var lic in LicenseTool.ValidLicenses)
            {
                AddLincese(lic, 1);
            }
            foreach (var lic in LicenseTool.InvalidLicenses)
            {
                AddLincese(lic, 0);
            }

            lsvFeatures.Items.Clear();
            foreach (var holder in FeatureAddonType.Instance.CommonSpace.GetAllAddons())
            {
                var item = lsvFeatures.Items.Add(holder.Title);
                item.ImageIndex = LicenseTool.FeatureAllowed(holder.Name) ? 1 : 0;
                item.SubItems.Add(holder.GetDefiner());
                var lst = new List <string>();
                foreach (var lic in LicenseTool.ValidLicenses)
                {
                    if (lic.FeatureAllowed(holder.Name))
                    {
                        lst.Add(lic.LongText);
                    }
                }
                item.SubItems.Add(lst.CreateDelimitedText(","));
            }
        }
Exemplo n.º 2
0
        public void AddObject(object obj)
        {
            Dictionary <string, bool> enabled = new Dictionary <string, bool>();
            Dictionary <string, bool> visible = new Dictionary <string, bool>();

            foreach (MethodInfo mtd in obj.GetType().GetMethods())
            {
                foreach (PopupMenuEnabledAttribute attr in mtd.GetCustomAttributes(typeof(PopupMenuEnabledAttribute), true))
                {
                    enabled[attr.Path] = (bool)mtd.Invoke(obj, null);
                }
                foreach (PopupMenuVisibleAttribute attr in mtd.GetCustomAttributes(typeof(PopupMenuVisibleAttribute), true))
                {
                    visible[attr.Path] = (bool)mtd.Invoke(obj, null);
                }
            }

            foreach (MethodAttribute <PopupMenuAttribute> rec in ReflTools.GetMethods <PopupMenuAttribute>(obj))
            {
                if (!LicenseTool.FeatureAllowed(rec.Attribute.RequiredFeature))
                {
                    continue;
                }
                bool v = FindBoolValue(rec.Attribute.Path, visible);
                if (!v)
                {
                    continue;
                }

                bool e = FindBoolValue(rec.Attribute.Path, enabled);

                Bitmap image = Framework.Instance.ImageFromName(rec.Attribute.ImageName, null);
                if (image != null && Framework.IsMono)
                {
                    if (!m_transparencyCache.ContainsKey(image))
                    {
                        m_transparencyCache[image] = image.FixTransparency(SystemColors.ButtonFace);
                    }
                    image = m_transparencyCache[image];
                }

                var data = new MenuItemData();
                data.Image    = image;
                data.Weight   = rec.Attribute.Weight;
                data.Shortcut = rec.Attribute.Shortcut;
                data.ShortcutDisplayString = rec.Attribute.ShortcutDisplayString;
                data.MultiMode             = rec.Attribute.MultiMode;
                data.HideIfNoChildren      = rec.Attribute.HideIfNoChildren;
                data.GroupName             = rec.Attribute.GroupName;
                data.Callable = new MethodCallable(rec.Method);
                data.Enabled  = e;
                AddItem(obj, rec.Attribute.Path, data);
            }
        }
Exemplo n.º 3
0
 private void ProcessOperation(object baseObject, AppObject[] draggedObjs, MethodInfo mtd, DragDropOperationAttribute attr)
 {
     if (!LicenseTool.FeatureAllowed(attr.RequiredFeature))
     {
         return;
     }
     if (attr.MultiMode == MultipleMode.NativeMulti)
     {
         var okobjs = new List <AppObject>(draggedObjs);
         foreach (MethodInfo vmtd in baseObject.GetType().GetMethods())
         {
             foreach (DragDropOperationFilterMultiAttribute fattr in vmtd.GetCustomAttributes(typeof(DragDropOperationFilterMultiAttribute), true))
             {
                 if (fattr.Name == attr.Name)
                 {
                     vmtd.Invoke(baseObject, new object[] { okobjs });
                 }
             }
         }
         var op = new MethodDragDropOperation(mtd, attr, baseObject, okobjs);
         if (op.Acceptable())
         {
             Operations.Add(op);
         }
         return;
     }
     else
     {
         var okobjs = new List <AppObject>(draggedObjs);
         foreach (MethodInfo vmtd in baseObject.GetType().GetMethods())
         {
             foreach (DragDropOperationVisibleAttribute vattr in vmtd.GetCustomAttributes(typeof(DragDropOperationVisibleAttribute), true))
             {
                 if (vattr.Name == attr.Name)
                 {
                     okobjs.Clear();
                     foreach (var appobj in draggedObjs)
                     {
                         if ((bool)vmtd.Invoke(baseObject, new object[] { appobj }))
                         {
                             okobjs.Add(appobj);
                         }
                     }
                 }
             }
         }
         var op = new MethodDragDropOperation(mtd, attr, baseObject, okobjs);
         if (op.Acceptable())
         {
             Operations.Add(op);
         }
         return;
     }
 }
Exemplo n.º 4
0
 public static DXDriver GetDXDriver(this IPhysicalConnection conn, string dbname)
 {
     if (conn.SystemConnection == null)
     {
         return(null);
     }
     if (!LicenseTool.FeatureAllowed(DxDriverFeature.Test))
     {
         return(null);
     }
     return((DXDriver)conn.Cache.Database(dbname).Get("dxdriver", () => new DXDriver(conn)));
 }
Exemplo n.º 5
0
        public override void GetThisAddons(List <AddonHolder> res)
        {
            foreach (var h in m_holders.Values)
            {
                // test whether addon is for this edition
                if (!LicenseTool.FeatureAllowed(h.Attrib.RequiredFeature))
                {
                    continue;
                }

                res.Add(h);
            }
        }
Exemplo n.º 6
0
        public static ITreeNode[] GetChildren(IDatabaseSource dbconn, ITreeNode parent, string dbname)
        {
            List <ITreeNode> res = new List <ITreeNode>();

            if (!dbconn.DatabaseCaps.IsPhantom)
            {
                res.Add(new Tables_TreeNode(dbconn, parent, false));
                if (dbconn.DatabaseCaps.MultipleSchema)
                {
                    res.Add(new Schemas_TreeNode(dbconn, parent));
                }
                if (dbconn.DatabaseCaps.Domains)
                {
                    res.Add(new Domains_TreeNode(dbconn, parent));
                }
            }
            parent.GetDbObjectNodes(dbconn, res, DbObjectParent.Database, new ObjectPath(dbname), false);
            if (dbconn.DatabaseCaps.IsPhantom)
            {
                if (LicenseTool.FeatureAllowed(DatabaseBackupFeature.Test))
                {
                    res.Add(new Backups_TreeNode(dbconn, parent));
                }
            }
            else
            {
                if (dbconn.IsFullAvailable())
                {
                    res.Add(new SystemDbObjectsNode(dbconn, parent, dbname));
                    if (LicenseTool.FeatureAllowed(DatabaseBackupFeature.Test) && dbconn.GetAnyDialect().DialectCaps.SupportBackup)
                    {
                        res.Add(new Backups_TreeNode(dbconn, parent));
                    }
                }
            }
            if (dbconn.GetPrivateSubFolder("sqlscripts") != null)
            {
                TreeNodeExtension.AddFolderNodes(res, "sqlscripts", (folder, postfix, namePostfix) => new SqlScripts_TreeNode(dbconn, folder, parent, postfix, namePostfix), dbconn);
            }
            return(res.ToArray());
        }
Exemplo n.º 7
0
        public StaticAddonHolder FindHolder(string name)
        {
            //StringBuilder sb = new StringBuilder();
            //var stackTrace = new System.Diagnostics.StackTrace();
            //foreach (var frame in stackTrace.GetFrames())
            //{
            //    sb.AppendLine(frame.GetMethod().Name);   // write method name
            //}
            //MessageBox.Show(sb.ToString());
            StaticAddonHolder res;

            if (m_holders.TryGetValue(name, out res))
            {
                if (LicenseTool.FeatureAllowed(res.Attrib.RequiredFeature))
                {
                    return(res);
                }
                throw new InternalError(String.Format("DAE-00072 License for addon {0}({1}) not found", name, AddonType.Name));
            }
            throw new InternalError("DAE-00073 Addon " + AddonType.Name + " has not type " + name);
        }
Exemplo n.º 8
0
 public bool BackupVisible()
 {
     return(LicenseTool.FeatureAllowed(DatabaseBackupFeature.Test) && this.FindPhysicalConnection().GetAnyDialect().DialectCaps.SupportBackup);
 }