Пример #1
0
        void ChangePage(object sender, EventArgs args)
        {
            ToolStripMenuItem tsmi = (sender as ToolStripMenuItem);
            page newpage           = canvas.FindPage(tsmi.Text);

            if (newpage != null)
            {
                canvas.current_page = newpage;
            }
        }
Пример #2
0
 bool FindPageThing(page p)
 {
     if (findpage == null)
     {
         return(false);
     }
     if (String.Compare(p.Name, findpage, true) == 0)
     {
         return(true);
     }
     return(false);
 }
Пример #3
0
        bool IReflectorPersistance.Load(XPathNavigator r)
        {
            //XmlDocument xd = new XmlDocument();
            //XmlNode xn = xd.ReadNode(r);
            //r.ReadEl


            if (r.NodeType == XPathNodeType.Element)
            //if (r.IsStartElement())
            {
                switch (r.Name)
                {
                case "page":
                    //bool okay;
                    page p;
                    if (first_page)
                    {
                        first_page = false;
                        p          = pages[0];
                    }
                    else
                    {
                        p = new page(this);
                    }
                    if (!p.Load(r))
                    {
                        p = null;
                    }
                    else
                    {
                        p.Hide();
                        current_page = p;
                    }
                    //}
                    return(true);
                }
            }
            return(false);
        }
Пример #4
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);
                }
            }
        }
Пример #5
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
                                                 );
                    }
                }
            }
        }
Пример #6
0
 void MakeAPage(Object s, EventArgs e)
 {
     // add the page to pages list
     // also adds page to change page menu
     current_page = new page(this);
 }
Пример #7
0
 public PageProperties(page edit_page)
 {
     that = edit_page;
     InitializeComponent();
 }
Пример #8
0
        private void CanvasButtonUp(object sender, MouseEventArgs e)
        {
            //Log.log( "  --- CLICK UP ----- " );
            if (disable_changes)
            {
                return;
            }
            buttons.Location = e.Location;
            switch (e.Button)
            {
            case MouseButtons.Left:
                if (buttons.l)
                {
                    buttons.want_click = false;
                    if (buttons.clicked)
                    {
                        buttons.l          = false;
                        buttons.l_delta_up = true;
                        buttons.clicked    = false;
                        Refresh();

                        foreach (IReflectorSecurity security in this.security_tags)
                        {
                            if (!security.Open())
                            {
                                //foreach( IReflectorSecurity upto in local.security_modules )
                                {
                                    //if( upto == security )
                                    //	break;
                                    security.Close();
                                }
                                return;
                            }
                        }

                        foreach (IReflectorSecurity security in security_tags)
                        {
                            if (!security.Test())
                            {
                                return;
                            }
                        }


                        // if button success (failure will fail from macro, which will fail to here.)
                        // consider multiple failure conditions, perhaps set a failure mode
                        // so we can maybe unwind what has already been done?
                        if (_click.OnClick())
                        {
                            if (this.NextPage != null)
                            {
                                page page = canvas.FindPage(this.NextPage);
                                page.Select();
                            }
                        }

                        foreach (IReflectorSecurity security in security_tags)
                        {
                            // if it closes...
                            security.Close();
                        }
                    }
                }

                break;

            case MouseButtons.Right:
                if (buttons.r)
                {
                    buttons.r          = false;
                    buttons.r_delta_up = true;
                    Refresh();
                }
                break;

            case MouseButtons.Middle:
                buttons.m = false;
                break;
            }
        }