private void Canvas_ClientSizeChanged(object sender, EventArgs e) { #if look_at_font_families FontFamily[] families = FontFamily.Families; foreach (FontFamily f in families) { //Log.log( f.Name ); } #endif font_scale_x = new Fraction(Width, 1024); font_scale_y = new Fraction(Height, 768); if (ScaleChanged != null) { ScaleChanged(); } font_tracker default_font = Xperdex.GetFontTracker("Default"); // some 3/4 aspect ratio... the font scale is based against this... so we'd have double applied scaling // to the default font. SizeF target_size = new SizeF(1024 / 40, 768 / 20); int height = (int)target_size.Height; Font NewFont; Graphics g = this.CreateGraphics(); if (current_page != null) { g.Clear(current_page.background_color); } NewFont = new Font("Lucida Console", height, GraphicsUnit.Pixel); default_font.f = NewFont; }
public TextLabel(string name) { Name = name; font = FontEditor.GetFontTracker("Default"); textColor = Color.DarkKhaki; updated = true; }
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; }
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); }
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); }
protected override void OnPaintBackground(PaintEventArgs e) { // do nothing if (BackgroundImage != null) // guess we can let it paint the image... { e.Graphics.DrawImage(this.BackgroundImage, this.ClientRectangle , new RectangleF(0, 0, this.BackgroundImage.Size.Width, this.BackgroundImage.Size.Height), GraphicsUnit.Pixel ); base.OnPaintBackground(e); } if (current_page == null) { current_page = new page(this); } if (current_page.Count == 0) { font_tracker ft = Xperdex.GetFontTracker("Default"); ft.DrawString(e.Graphics, "No Objects\nALT-V to Configure\nLeft click drag region\nRight click in region to add control" , new SolidBrush(Color.Azure) , new Point(0, 0) , font_scale_x, font_scale_y //, StringFormat.GenericTypographic ); } if (flags.editing) { // hazy green edit... Brush b = new SolidBrush(Color.FromArgb(32, 0, 84, 84)); Pen p = new Pen(Color.FromArgb(43, 255, 255, 255)); Pen p2 = new Pen(Color.FromArgb(43, 0, 0, 0)); // r is a global variable that determines scaling for parts. current_page.rect = this.ClientRectangle; e.Graphics.FillRectangle(b, this.ClientRectangle); { int x, y; for (x = 0; x <= current_page.partsX; x++) { e.Graphics.DrawLine(p , current_page.PARTX(x), 0 , current_page.PARTX(x), current_page.PARTY(current_page.partsY)); e.Graphics.DrawLine(p2, current_page.PARTX(x) + 1, 0 , current_page.PARTX(x) + 1, current_page.PARTY(current_page.partsY)); } for (y = 0; y <= current_page.partsY; y++) { e.Graphics.DrawLine(p, 0, current_page.PARTY(y) , current_page.PARTX(current_page.partsX), current_page.PARTY(y)); e.Graphics.DrawLine(p2, 0, current_page.PARTY(y) + 1 , current_page.PARTX(current_page.partsX), current_page.PARTY(y) + 1); } Font c_label = Xperdex.GetFontTracker("Default Fixed(Fixed)", "Lucida Console", 10); foreach (ControlTracker c in current_page) { Brush selected_brush = new SolidBrush(Color.FromArgb(80, 0, 128, 0)); //lprintf( WIDE("Our fancy coords could be %d,%d %d,%d"), PARTX( selection.x ), PARTY( selection.y ) // , PARTW( selection.x, selection.w ) // , PARTH( selection.y, selection.h )); // and to look really pretty select the outer edge on the bottom, also //e.Graphics.FillRectangle(selected_brush, rect); e.Graphics.FillRectangle(selected_brush, current_page.PARTX(c.grid_rect.X), current_page.PARTY(c.grid_rect.Y) , current_page.PARTW(c.grid_rect.X, c.grid_rect.Width) + 1 , current_page.PARTH(c.grid_rect.Y, c.grid_rect.Height) + 1 ); { selected_brush = new SolidBrush(Color.FromArgb(84, 128, 0, 0)); e.Graphics.FillRectangle(selected_brush , current_page.PARTX(c.grid_rect.X) , current_page.PARTY(c.grid_rect.Y) , current_page.PARTW(c.grid_rect.X, 1) + 1 , current_page.PARTH(c.grid_rect.Y, 1) + 1 ); e.Graphics.FillRectangle(selected_brush , current_page.PARTX(c.grid_rect.Right - 1) , current_page.PARTY(c.grid_rect.Top) , current_page.PARTW(c.grid_rect.Right - 1, 1) + 1 , current_page.PARTH(c.grid_rect.Top, 1) + 1 ); e.Graphics.FillRectangle(selected_brush , current_page.PARTX(c.grid_rect.X) , current_page.PARTY(c.grid_rect.Bottom - 1) , current_page.PARTW(c.grid_rect.X, 1) + 1 , current_page.PARTH(c.grid_rect.Bottom - 1, 1) + 1 ); e.Graphics.FillRectangle(selected_brush , current_page.PARTX(c.grid_rect.Right - 1) , current_page.PARTY(c.grid_rect.Bottom - 1) , current_page.PARTW(c.grid_rect.Right - 1, 1) + 1 , current_page.PARTH(c.grid_rect.Bottom - 1, 1) + 1 ); e.Graphics.DrawString(c.o.ToString(), c_label, Brushes.White, new PointF(c.c.Location.X, c.c.Location.Y)); } } if (flags.selecting) { Brush selected_brush = new SolidBrush(Color.FromArgb(170, 0, 0, Color.Blue.B)); //lprintf( WIDE("Our fancy coords could be %d,%d %d,%d"), PARTX( selection.x ), PARTY( selection.y ) // , PARTW( selection.x, selection.w ) // , PARTH( selection.y, selection.h )); // and to look really pretty select the outer edge on the bottom, also e.Graphics.FillRectangle(selected_brush, current_page.PARTX(selection.X), current_page.PARTY(selection.Y) , current_page.PARTW(selection.X, selection.Width) + 1 , current_page.PARTH(selection.Y, selection.Height) + 1 ); } } } }
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"); }
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); }