Beispiel #1
0
 public TextLabel(string name)
 {
     Name      = name;
     font      = FontEditor.GetFontTracker("Default");
     textColor = Color.DarkKhaki;
     updated   = true;
 }
Beispiel #2
0
 public TextLabel(string name, int x, int y, AnchorPoint anchor, String fontname, Color color)
 {
     this._orig_x   = x;
     this._orig_y   = y;
     this.anchor    = anchor;
     this.font      = FontEditor.GetFontTracker(fontname);
     this.textColor = color;             // use accessor to get brush set...
     this.Name      = name;
     this.updated   = true;
 }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            FontEditor fe = new FontEditor(FontEditor.GetFontTracker(control.Font));

            fe.ShowDialog();
            if (fe.DialogResult == DialogResult.OK)
            {
                control.Font = fe.GetFontResult();
            }
            fe.Dispose();
        }
Beispiel #4
0
        bool IReflectorPersistance.Load(System.Xml.XPath.XPathNavigator r)
        {
            switch (r.Name)
            {
            case "TextLabel":
                for (bool okay = r.MoveToFirstAttribute(); okay; okay = r.MoveToNextAttribute())
                {
                    switch (r.Name)
                    {
                    case "Font":
                        font = FontEditor.GetFontTracker(r.Value);
                        break;

                    case "Color":
                        textcolor = Color.FromArgb(Convert.ToInt32(r.Value));
                        break;

                    case "BackColor":
                        BackColor = Color.FromArgb(Convert.ToInt32(r.Value));
                        break;

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

                    case "Align":
                        switch (r.Value)
                        {
                        case "Center":
                            centered   = true;
                            right_just = false;
                            break;

                        case "Right":
                            right_just = true;
                            centered   = false;
                            break;

                        case "Left":
                            centered   = false;
                            right_just = false;
                            break;
                        }
                        break;
                    }
                }
                r.MoveToParent();
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        void Init(Canvas canvas, IReflectorButton click_interface)
        {
            AllowShowUsers = new List <string>();
            AllowShow      = new List <string>();
            DisallowShow   = new List <string>();
            this.canvas    = canvas;
            buttons        = new buttons_class();
            gs             = new GlareSet("default", "default");

            FontTracker       = FontEditor.GetFontTracker("Default");
            allowed_on_system = true;

            InitializeComponent();
            if (click_interface == null)
            {
                _click = this as IReflectorButton;
            }
            else
            {
                _click = click_interface;
            }
#if no_PSI_Base_class
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            //SetStyle(ControlStyles.Opaque, false);  // no background
            //SetStyle(ControlStyles.UserPaint, true); // generate paint
            //SetStyle(ControlStyles.AllPaintingInWmPaint, true); // skip paintbackground
            this.SetStyle(ControlStyles.Opaque, false);
            this.BackColor      = Color.Transparent;
            this.DoubleBuffered = true;
#endif
            this.security_tags = new List <object>();
            this.MouseUp      += new System.Windows.Forms.MouseEventHandler(this.CanvasButtonUp);
            this.MouseMove    += new System.Windows.Forms.MouseEventHandler(this.CanvasClick);
            this.MouseDown    += new System.Windows.Forms.MouseEventHandler(this.CanvasButtonDown);

            this.Paint += new PaintEventHandler(PSI_Button_Paint);
            //SetStyle(ControlStyles.
            //this.SetStyle(ControlStyles.
            //BackColor = Color.Transparent; // Color.FromArgb(0, 1, 0, 0);
        }
Beispiel #6
0
        internal void LabelEditor_Apply()
        {
            editing.text = textBox1.Text;

            editing.textcolor = colorWellText.color;
            if (editing.textcolor.ToArgb() == 0)
            {
                editing.textcolor = Color.White;
            }

            editing.BackColor = colorWellBackground.color;
            if (editing.BackColor.ToArgb() == 0)
            {
                editing.BackColor = Color.Black;
            }

            editing.font = listBoxFonts.SelectedItem as font_tracker;
            if (editing.font == null)
            {
                editing.font = FontEditor.GetFontTracker("Default");
            }
            if (radioButton1.Checked)
            {
                editing.centered   = false;
                editing.right_just = false;
            }
            else if (radioButton2.Checked)
            {
                editing.centered   = true;
                editing.right_just = false;
            }
            else if (radioButton3.Checked)
            {
                editing.centered   = false;
                editing.right_just = true;
            }
        }
Beispiel #7
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");
        }
Beispiel #8
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);
        }