Exemplo n.º 1
0
        public CockpitPanel(CockpitForm form, ControlManager manager, IImageCache imageCache, CockpitXML.CockpitLayoutPanel layout)
        {
            this.name = layout.Name;
            this.form = form;

            if (layout.ControlLayout != null)
            {
                // Now construct the list of controls that are actually used in the layout
                foreach (CockpitXML.CockpitLayoutPanelControlLayout controlLayout in layout.ControlLayout)
                {
                    if (manager.HasControl(controlLayout.ControlName))
                    {
                        ICockpitControl        control  = manager.GetControl(controlLayout.ControlName);
                        CockpitControlInstance formItem = new CockpitControlInstance(this, control, new Point(controlLayout.X, controlLayout.Y));
                        controlInstances.Add(formItem);
                        control.AddInstance(formItem);
                    }
                }
            }

            this.Location        = new Point(layout.X, layout.Y);
            this.Size            = new Size(layout.Width, layout.Height);
            this.backgroundImage = imageCache.getImage(layout.BackgroundImage);
            if (layout.VisibleSpecified)
            {
                this.Visible = layout.Visible;
            }
            else
            {
                this.Visible = true;
            }
        }
Exemplo n.º 2
0
 public void AddForm(CockpitForm form)
 {
     if (!forms.Contains(form))
     {
         forms.Add(form);
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            int forceX = -1;
            int forceY = -1;

            string profile = "TouchPal.xml";

            foreach (string argument in args)
            {
                if (argument.StartsWith("-log="))
                {
                    string level = argument.Substring(5).ToLower();
                    if (logLevels.ContainsKey(level))
                    {
                        logLevel = logLevels[level];
                    }
                }

                if (argument.StartsWith("-profile="))
                {
                    profile = argument.Substring(9);
                }

                if (argument.StartsWith("-homedir="))
                {
                    touchPalDirectory = argument.Substring(9);
                }

                if (argument.StartsWith("-tcp"))
                {
                    udp = false;
                }

                if (argument.StartsWith("-udp"))
                {
                    udp = true;
                }

                if (argument.StartsWith("-x="))
                {
                    forceX = Convert.ToInt32(argument.Substring(3));
                    TouchPal.Debug("Forceing window x to " + argument.Substring(3));
                }

                if (argument.StartsWith("-y="))
                {
                    forceY = Convert.ToInt32(argument.Substring(3));
                    TouchPal.Debug("Forceing window y to " + argument.Substring(3));
                }
            }

            ResetEnvironment();

            INetConnection connection = null;

            if (udp)
            {
                connection = new UDPNetConnection();
            }
            else
            {
                connection = new TCPNetConnection();
            }

            IImageCache cache = new BasicImageCache();

            try {
                TouchPal.Debug("Parsing profile " + profile);
                CockpitXML.Cockpit co = ReadConfig(profile);

                TouchPal.Debug("Loading controls");
                ControlManager manager = new ControlManager(connection, cache, co.StartAction, co.ResetAction, co.Controls);

                connection.StartConnection();

                TouchPal.Debug("Setting up form");
                CockpitForm form = new CockpitForm(manager, cache, co.Layout, forceX, forceY);

                Application.Run(form);
            }
            catch (XmlSchemaException e)
            {
                TouchPal.Log(LOG_LEVEL.ERROR, "Error parsing profile at position " + e.LinePosition + " on line " + e.LineNumber + " {" + e.Message + "}");
            }
        }