Esempio n. 1
0
        private void EditSecurity_Click(object sender, EventArgs e)
        {
            bool found = false;

            if (Security.SelectedItem == null)
            {
                MessageBox.Show("Must Select a security module to configure...");
                return;
            }
            Type t = (Security.SelectedItem as TypeName).Type;

            foreach (object s in that.security_tags)
            {
                if (s.GetType() == t)
                {
                    IReflectorPersistance persis = s as IReflectorPersistance;
                    if (persis != null)
                    {
                        // maybe mark this security module as using this ?
                        persis.Properties();
                    }
                    found = true;
                }
            }
            if (!found)
            {
                object o = Activator.CreateInstance(t);
                that.security_tags.Add(o);
                IReflectorPersistance persis = o as IReflectorPersistance;
                if (persis != null)
                {
                    persis.Properties();
                }
            }
        }
Esempio n. 2
0
        internal static void item_Click(object sender, EventArgs e)
        {
            object plugin = (sender as TypeMenuItem).o;
            IReflectorPersistance persis = plugin as IReflectorPersistance;

            persis.Properties();
        }
Esempio n. 3
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            osalot.AssemblyObject o = Actions.SelectedItem as osalot.AssemblyObject;
            if (o == null)
            {
                MessageBox.Show("Bad element selection");
                return;
            }
            IReflectorPersistance persis = o.o as IReflectorPersistance;

            if (persis != null)
            {
                persis.Properties();
            }
            // content of the data source (the action item text for instance) may have changed...
            Actions.DataSource = null;
            Actions.DataSource = editing_macro.buttons;
        }
Esempio n. 4
0
        void IReflectorPersistance.Save(XmlWriter w)
        {
            if (gs != null)
            {
                gs.Save(w);
            }
            w.WriteStartElement("PSI_Button");
            if (NextPage != null)
            {
                w.WriteAttributeString("page", NextPage);
            }
            w.WriteAttributeString("text", Text);
            if (decal_name != null)
            {
                w.WriteAttributeString("decal", decal_name);
                w.WriteAttributeString("decal_Scale", DecalScale.ToString());
            }
            //if( _FontTracker != null )
            //	w.WriteAttributeString( "font", _FontTracker.Name );
            foreach (String system in AllowShow)
            {
                w.WriteElementString("allow", system);
            }
            foreach (String system in DisallowShow)
            {
                w.WriteElementString("disallow", system);
            }

            foreach (Object o in security_tags)
            {
                w.WriteStartElement("security");
                w.WriteAttributeString("type", o.ToString());
                IReflectorPersistance p = o as IReflectorPersistance;
                if (p != null)
                {
                    p.Save(w);
                }
                w.WriteEndElement();
                w.WriteRaw("\r\n");
            }

            w.WriteEndElement();
            w.WriteRaw("\r\n");
        }
Esempio n. 5
0
        void PropertyClickBypass(Object s, EventArgs e)
        {
            bool did_property = false;

            if (current_control != null)
            {
                IReflectorPersistance pc = current_control.c as IReflectorPersistance;
                if (pc != null)
                {
                    pc.Properties();
                    did_property = true;
                }
            }
            if (!did_property)
            {
                current_page.PropertyClick();
                Refresh();
                this.BackgroundImage = current_page.background_image;
            }
        }
Esempio n. 6
0
 void IReflectorPersistance.Save(XmlWriter w)
 {
     w.WriteStartElement("Macro");
     //w.WriteAttributeString( "Text", (Text!=null)?Text:"" );
     foreach (osalot.AssemblyObject button in buttons)
     {
         w.WriteStartElement("Element");
         w.WriteAttributeString("Assembly", core_common.GetRelativePath(button.t.Assembly.Location));
         w.WriteAttributeString("Type", button.t.FullName);
         IReflectorPersistance persis = button.o as IReflectorPersistance;
         if (persis != null)
         {
             persis.Save(w);
         }
         w.WriteEndElement();
         w.WriteRaw("\r\n");
     }
     w.WriteEndElement();
     w.WriteRaw("\r\n");
 }
Esempio n. 7
0
 internal static void Save(XmlWriter w)
 {
     // but if read comes in from a certain place
     // then why doesn't write?
     //   how is it on one side we have an object
     //   and the other side we're creating objects...
     foreach (GlareSetData gsd in glaresets)
     {
         gsd.Save(w);
     }
     foreach (GlareSetAttributes gsa in glare_attribs)
     {
         gsa.Save(w);
     }
     foreach (object plugin in persistant_plugins)
     {
         // for all plugins that were loaded, if they have peristance
         // allow them to load...
         GlareSetData gsd = plugin as GlareSetData;
         if (gsd != null)                  // skip glare set:plugin save.
         {
             continue;
         }
         IReflectorPersistance persis = plugin as IReflectorPersistance;
         if (persis != null)
         {
             try
             {
                 persis.Save(w);
             }
             catch
             {
                 // might be 'not implemented'
             }
         }
     }
     foreach (String system in systems)
     {
         w.WriteElementString("systemname", system);
     }
 }
Esempio n. 8
0
        static void PropertyClick(Object s, EventArgs e)
        {
            bool did_property = false;

            if (local.current_mouse_control != null)
            {
                IReflectorPersistance pc = local.current_mouse_control.o as IReflectorPersistance;
                if (pc != null)
                {
                    pc.Properties();
                    did_property = true;
                }
                if (!did_property)
                {
                    pc = local.current_mouse_control.c as IReflectorPersistance;
                    if (pc != null)
                    {
                        pc.Properties();
                        did_property = true;
                    }
                }
            }
            if (!did_property)
            {
                Control c = local.current_mouse_control.o as Control;
                if (c != null)
                {
                    new EditControl(c).ShowDialog();
                    did_property = true;
                }
            }
            if (!did_property)
            {
                if (local.current_mouse_page != null)
                {
                    local.current_mouse_page.PropertyClick();
                }
            }
        }
Esempio n. 9
0
        private void buttonConfigureSecurity_Click(object sender, EventArgs e)
        {
            bool found = false;

            if (listBoxSecurity.SelectedItem == null)
            {
                MessageBox.Show("Must Select a security module to configure...");
                return;
            }
            Type t = (listBoxSecurity.SelectedItem as TypeName).Type;

            foreach (object s in that.security_tags)
            {
                if (s.GetType() == t)
                {
                    // already have that tag created, so edit it.
                    IReflectorPersistance persis = s as IReflectorPersistance;
                    if (persis != null)
                    {
                        // maybe mark this security module as using this ?
                        persis.Properties();
                    }
                    found = true;
                }
            }
            if (!found)
            {
                // didn't have that tag associated with the page yet, so create one
                object o = Activator.CreateInstance(t);
                that.security_tags.Add(o as IReflectorSecurity);
                IReflectorPersistance persis = o as IReflectorPersistance;
                if (persis != null)
                {
                    // and configure its properties
                    persis.Properties();
                }
            }
        }
Esempio n. 10
0
        public void LoadConfig(String file)
        {
            flags.loading        = true;
            local.loading_canvas = this;
            try
            {
                XmlDocument xd = new XmlDocument();
                if (!System.IO.File.Exists(local.ConfigName))
                {
                    return;
                }
                xd.Load(local.ConfigName);
                // the xd loader ends up with a full pathname with successful load
                // grab this so we can save to the same file.
                local.ConfigName = xd.BaseURI.Substring(8);

                XPathNavigator xn = xd.CreateNavigator();
                //XPathNavigator xn2 = xn.CreateNavigator();
                xn.MoveToFirst();
                xn.MoveToFirstChild();
                if (xn.NodeType == XPathNodeType.Element)
                {
                    if (String.Compare(xn.Name, "xperdex") == 0)
                    {
                        bool okay;
                        pages.Clear();
                        current_page = new page(this);
                        first_page   = true;


                        //xn.MoveToFirstChild();
                        for (okay = xn.MoveToFirstChild(); okay; okay = xn.MoveToNext())
                        {
                            // local, being static cannot implement persistance...
                            bool loaded = local.Load(xn);
                            if (!loaded)
                            {
                                foreach (object plugin in local.persistant_plugins)
                                {
                                    // for all plugins that were loaded, if they have peristance
                                    // allow them to load...
                                    IReflectorPersistance persis = plugin as IReflectorPersistance;
                                    if (persis != null)
                                    {
                                        loaded = persis.Load(xn);
                                        if (loaded)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!loaded)
                            {
                                // should be at a place to handle canvas here...
                                loaded = ((IReflectorPersistance)this).Load(xn);
                            }
                            if (!loaded)
                            {
                                Console.WriteLine("Attribute ignored...");
                            }
                        }

                        // parsing might totally fail, causing no data...
                        // create a default page if one doesn't exist.
                        if (pages.Count == 0)
                        {
                            page new_page;
                            pages.Add(new_page = new page(this));
                            change_page_context_menu.Items.Add(new ToolStripMenuItem(new_page.Name));
                        }
                        current_page = pages[0];

                        // all pages should be loaded from the XML from here..
                        xn.MoveToParent();
                        // should be at xperdex again.
                    }
                }
            }
            catch (Exception e)
            {
                //e.Data.Values
                //System.Environment.StackTrace;
                //e.StackTrace;
                //Process.GetCurrentProcess().
                //Thread.CurrentContext
                //Thread.CurrentThread.
                Log.log("XML Parsing faulted... " + e.Message);
            }
            local.loading_canvas = null;

            flags.loading = false;
            if (pages.Count == 0)
            {
                current_page = new page(this);
            }
            else
            {
                current_page = pages[0];
            }

            foreach (IReflectorPlugin irp in local.persistant_plugins)
            {
                try
                {
                    irp.FinishInit();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Esempio n. 11
0
        static bool InvokePreload(AssemblyTracker tracker, Type[] assembly_types, EventHandler handler)
        {
            int previous_assemblies = tracker.objects.Count;
            int previous            = core_common.persistant_plugins.Count;

            foreach (Type t in assembly_types)
            {
                Type[] interfaces;
                interfaces = t.FindInterfaces(MyInterfaceFilter, "IReflectorPlugin");
                if (interfaces.Length > 0)
                {
                    AssemblyObject ao;
                    object         o = Activator.CreateInstance(t);
                    tracker.objects.Add(ao = new AssemblyObject(t, o));
                    try
                    {
                        IReflectorPlugin plugin = o as IReflectorPlugin;
                        if (plugin != null)
                        {
                            plugin.Preload();
                            ao.plugin = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.log("Invoke preload threw exception... " + t.ToString() + ":" + ex.Message);
                    }

                    IReflectorPersistance persis = o as IReflectorPersistance;
                    if (persis != null)                      // it's a plugin, and has properties
                    {
                        object[] tags = t.GetCustomAttributes(true);
                        String   name = null;
                        foreach (object tag in tags)
                        {
                            PluginAttribute attr = tag as PluginAttribute;
                            if (attr != null)
                            {
                                name = attr.Name;
                            }
                        }
                        if (name == null)
                        {
                            name = o.ToString();
                        }
                        core_common.persistant_plugins.Add(o);
                        TypeMenuItem tmi = new TypeMenuItem(o, name);
                        InsertMenuItem(core_common.other_drop.DropDown, tmi);
                        tmi.Click += handler;
                    }

                    IReflectorPluginModule module_acceptor = o as IReflectorPluginModule;
                    if (module_acceptor != null)                      // it's a plugin, and has properties
                    {
                        core_common.plugin_module_acceptors.Add(module_acceptor);
                    }
                }
            }
            if (core_common.persistant_plugins.Count > previous ||
                tracker.objects.Count > previous_assemblies)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
        bool IReflectorPersistance.Load(XPathNavigator r)
        {
            if (String.Compare(r.Name, "Macro") == 0)
            {
                Object   o;
                Assembly a        = null;
                bool     everokay = false;
                {
                    // total violation of logic so far... but this is text...
                    if (r.MoveToFirstAttribute())
                    {
                        if (String.Compare(r.Name, "Text") == 0)
                        {
                            // ignore this, don't save it, would be redundant with button text...
                            //	Text = r.Value;
                        }
                        r.MoveToParent();
                    }
                }
                for (bool okay2 = r.MoveToFirstChild(); okay2; okay2 = r.MoveToNext())
                {
                    everokay = true;
                    switch (r.Name)
                    {
                    case "Element":
                        for (bool okay = r.MoveToFirstAttribute(); okay; okay = r.MoveToNextAttribute())
                        {
                            switch (r.Name)
                            {
                            case "Assembly":
                                a = osalot.LoadAssembly(r.Value);
                                break;

                            case "Type":
                                Type t = osalot.findtype(a, r.Value);

                                o = Activator.CreateInstance(t);

                                IReflectorPersistance persis = o as IReflectorPersistance;
                                r.MoveToParent();                                 // out of attributes...
                                if (persis != null)
                                {
                                    r.MoveToFirstChild();
                                    if (persis.Load(r))
                                    {
                                        // return from my move to child...
                                        r.MoveToParent();
                                    }
                                    // return from my move to attribute
                                }
                                osalot.AssemblyObject ao = new osalot.AssemblyObject(t, o);
                                buttons.Add(ao);
                                //r.MoveToParent();
                                break;
                            }
                        }
                        break;
                    }
                }
                // return from my move to child....
                if (everokay)
                {
                    r.MoveToParent();
                }
                return(true);
            }
            return(false);
        }
Esempio n. 13
0
        bool IReflectorPersistance.Load(XPathNavigator r)
        {
            // okay so the glareset attributes of a PSI_Button are
            // saved before PSI Button information.
            gs.Load(r);               // just give this a chance...

            {
                // glareset will result in the same position as it started (almost)
                //r.MoveToNext();
                if (r.NodeType == XPathNodeType.Element)
                {
                    if (String.Compare(r.Name, "PSI_Button", true) == 0)
                    {
                        bool ever_okay = false;
                        bool okay;
                        for (okay = r.MoveToFirstAttribute(); okay; okay = r.MoveToNextAttribute())
                        {
                            ever_okay = true;
                            switch (r.Name.ToLower())
                            {
                            case "decal":
                                SetDecalName(r.Value);
                                break;

                            case "decal_scale":
                                DecalScale = Convert.ToInt32(r.Value);
                                break;

                            case "text":
                                Text = r.Value;
                                break;

                            //case "font":
                            //	FontTracker = FontEditor.GetFontTracker( r.Value );
                            //	break;
                            case "page":
                                if (canvas != null)
                                {
                                    NextPage = r.Value;
                                }
                                break;
                            }
                        }
                        if (ever_okay)
                        {
                            r.MoveToParent();
                        }
                        // child elements within PSI_Button tag...
                        bool everokay2 = false;
                        for (okay = r.MoveToFirstChild(); okay; okay = r.MoveToNext())
                        {
                            everokay2 = true;
                            switch (r.Name.ToLower())
                            {
                            case "allow":
                                AllowShow.Add(r.Value);
                                break;

                            case "disallow":
                                DisallowShow.Add(r.Value);
                                break;

                            case "security":
                            {
                                bool okay3;
                                bool everokay3 = false;
                                for (okay3 = r.MoveToFirstAttribute(); okay3; okay3 = r.MoveToNext())
                                {
                                    everokay3 = true;
                                    switch (r.Name.ToLower())
                                    {
                                    case "type":
                                        foreach (TypeName n in core_common.security_modules)
                                        {
                                            if (String.Compare(n.Name, r.Value) == 0)
                                            {
                                                object o = Activator.CreateInstance(n.Type);
                                                this.security_tags.Add(o);
                                                IReflectorPersistance p = o as IReflectorPersistance;
                                                if (p != null)
                                                {
                                                    XPathNavigator tmp = r.CreateNavigator();
                                                    tmp.MoveToParent();
                                                    tmp.MoveToFirstChild();
                                                    p.Load(tmp);
                                                    break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                                if (everokay3)
                                {
                                    r.MoveToParent();
                                }
                            }
                            break;
                            }
                        }
                        CheckAllowedShow();
                        if (everokay2)
                        {
                            r.MoveToParent();
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 14
0
        internal void save(XmlWriter w)
        {
            w.WriteStartElement("page");
            w.WriteAttributeString("background", background_name);
            w.WriteAttributeString("title", Name);
            w.WriteAttributeString("color", background_color.ToArgb().ToString());
            w.WriteAttributeString("x", this.partsX.ToString());
            w.WriteAttributeString("y", this.partsY.ToString());
            w.WriteRaw("\r\n");
            foreach (ControlTracker c in this)
            {
                w.WriteStartElement("control");
                w.WriteAttributeString("X", Convert.ToString(c.grid_rect.X));
                w.WriteAttributeString("Y", Convert.ToString(c.grid_rect.Y));
                w.WriteAttributeString("width", Convert.ToString(c.grid_rect.Width));
                w.WriteAttributeString("height", Convert.ToString(c.grid_rect.Height));
                String s;
                if (String.Compare(s = c.Type.Assembly.FullName, Assembly.GetCallingAssembly().FullName) == 0)
                {
                    w.WriteAttributeString("assembly", "");
                }
                else
                {
                    w.WriteAttributeString("assembly", core.core_common.GetRelativePath(c.Type.Assembly.Location));
                }
                w.WriteAttributeString("type", c.Type.FullName);
                font_tracker ft = FontEditor.GetFontTracker(c.c.Font);
                if (ft != null)
                {
                    w.WriteAttributeString("font", ft.ToString());
                }
                else
                {
                    w.WriteAttributeString("font", "default");
                }
                if (c.i != null)
                {
                    string s2 = c.i.FullName;
                    w.WriteAttributeString("interface", s2);
                }

                w.WriteRaw("\r\n");

                IReflectorPersistance persis = c.o as IReflectorPersistance;
                if (persis != null)
                {
                    persis.Save(w);
                }
                if (!c.real)
                {
                    persis = c.c as IReflectorPersistance;
                    if (persis != null)
                    {
                        persis.Save(w);
                    }
                }
                w.WriteEndElement();
                w.WriteRaw("\r\n");
            }


            foreach (IReflectorSecurity s in this.security_tags)
            {
                IReflectorPersistance p = s as IReflectorPersistance;
                if (p != null)
                {
                    w.WriteStartElement("Security");
                    p.Save(w);
                    w.WriteEndElement();
                }
            }

            w.WriteEndElement();
            w.WriteRaw("\r\n");
        }
Esempio n. 15
0
        internal bool Load(XPathNavigator r)
        {
            if (r.NodeType == XPathNodeType.Element)
            {
                if (String.Compare(r.Name, "page", true) == 0)
                {
                    bool everokay;
                    bool okay;
                    //page p = new page(canvas);
                    for (okay = r.MoveToFirstAttribute(); okay; okay = r.MoveToNextAttribute())
                    {
                        switch (r.Name)
                        {
                        case "background":
                            background_name = r.Value;
                            try
                            {
                                if (background_name.Length > 0 && System.IO.File.Exists(background_name))
                                {
                                    background_image = Image.FromFile(background_name);
                                }
                                else
                                {
                                    background_image = null;
                                }
                            }
                            catch
                            {
                                background_name = null;
                            }
                            break;

                        case "title":
                            title = r.Value;
                            break;

                        case "color":
                        {
                            try
                            {
                                background_color = Color.FromArgb(Convert.ToInt32(r.Value));
                            }
                            catch
                            {
                                // probably alright, just bad...
                                // background was already defaulted...
                            }
                        }
                        break;

                        case "x":
                            partsX = r.ValueAsInt;
                            break;

                        case "y":
                            partsY = r.ValueAsInt;
                            break;
                        }
                    }
                    r.MoveToParent();

                    //return true;
                    //r.ReadEndElement();
                    everokay = false;
                    for (okay = r.MoveToFirstChild(); okay; okay = r.MoveToNext())
                    {
                        everokay = true;
                        if (r.NodeType == XPathNodeType.Element)
                        {
                            switch (r.Name)
                            {
                            case "Security":
                                foreach (TypeName module in core_common.security_modules)
                                {
                                    IReflectorSecurity    o = Activator.CreateInstance(module.Type) as IReflectorSecurity;
                                    IReflectorPersistance p = o as IReflectorPersistance;
                                    r.MoveToFirstChild();
                                    if (p != null)
                                    {
                                        if (p.Load(r))
                                        {
                                            security_tags.Add(o);
                                        }
                                    }
                                    r.MoveToParent();
                                }
                                break;

                            case "control":
                                //page p = new page();
                                Rectangle    rect = new Rectangle();
                                Assembly     a;
                                String       a_name = null;
                                Type         t;
                                font_tracker font   = null;
                                String       t_name = null;
                                String       i_name = null;
                                bool         okay2;
                                //page p = new page(canvas);
                                for (okay2 = r.MoveToFirstAttribute(); okay2; okay2 = r.MoveToNextAttribute())
                                {
                                    switch (r.Name)
                                    {
                                    case "font":
                                        font = FontEditor.GetFontTracker(r.Value);
                                        break;

                                    case "X":
                                        rect.X = Convert.ToInt32(r.Value);
                                        break;

                                    case "Y":
                                        rect.Y = Convert.ToInt32(r.Value);
                                        break;

                                    case "width":
                                        rect.Width = Convert.ToInt32(r.Value);
                                        break;

                                    case "height":
                                        rect.Height = Convert.ToInt32(r.Value);
                                        break;

                                    case "assembly":
                                        if (r.Value.Length != 0)
                                        {
                                            a_name = r.Value;
                                        }
                                        break;

                                    case "type":
                                        t_name = r.Value;
                                        break;

                                    case "interface":
                                        if (string.Compare(r.Value, "System.RuntimeType") == 0)
                                        {
                                            break;
                                        }
                                        i_name = r.Value;
                                        break;
                                    }
                                }
                                // go back to element from attributes...
                                r.MoveToParent();
                                {
                                    a = osalot.LoadAssembly(a_name);
                                    if (t_name != null && a != null)
                                    {
                                        t = osalot.findtype(a, t_name);
                                        Type[] i_list;
                                        Type   i = t;
                                        if (i_name != null)
                                        {
                                            if (t == null)
                                            {
                                                continue;
                                            }
                                            else
                                            {
                                                i_list = t.FindInterfaces(osalot.MyInterfaceFilter, i_name);
                                                if (i_list.Length > 0)
                                                {
                                                    i = i_list[0];
                                                }
                                            }
                                        }
                                        ControlTracker created_control = MakeControl(t, i, rect);

                                        if (font != null && created_control.c != null)
                                        {
                                            font.Controls.Add(created_control.c);
                                            created_control.c.Font = font;
                                        }
                                        bool success = false;
                                        IReflectorPersistance persis;
                                        bool okay3;
                                        bool everokay3 = false;
                                        for (okay3 = r.MoveToFirstChild(); okay3; okay3 = r.MoveToNext())
                                        {
                                            everokay3 = true;
                                            success   = false;
                                            persis    = created_control.o as IReflectorPersistance;
                                            if (persis != null)
                                            {
                                                try
                                                {
                                                    success = persis.Load(r);
                                                }
                                                catch (Exception e)
                                                {
                                                    Console.WriteLine(e);
                                                }
                                            }
                                            if (!success)
                                            {
                                                persis = created_control.c as IReflectorPersistance;
                                                if (persis != null)
                                                {
                                                    try
                                                    {
                                                        success = persis.Load(r);
                                                    }
                                                    catch (Exception e)
                                                    {
                                                        Console.WriteLine(e);
                                                    }
                                                }
                                            }
                                            if (!success)
                                            {
                                                Console.WriteLine("Ignored Element...");
                                            }
                                        }
                                        if (everokay3)
                                        {
                                            r.MoveToParent();
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                    if (everokay)
                    {
                        r.MoveToParent();
                    }
                    return(true);
                }
            }
            return(false);
        }