コード例 #1
0
ファイル: frmMain.cs プロジェクト: choldi/WindowsMenu
        private PictureBox setEmptyPicture(int posicio)
        {
            Logger.Info("Añadiendo elemento vacio en posicion {0}", posicio);
            PictureBox pic = CreatePicture(posicio);

            pic.Image = Properties.Resources.no_program;
            ToolTip tt = new ToolTip();

            tt.SetToolTip(pic, $"Posicion {posicio}: Sin programa");
            pic.Tag         = new { posicio = posicio, commandLine = "", id = 0 };
            pic.MouseClick += new MouseEventHandler((s, ev) => {
                MessageBox.Show("Hola " + (ev.Button == MouseButtons.Left ? "Left" : "Right"));
                if (ev.Button == MouseButtons.Right)
                {
                    PictureBox picx = s as PictureBox;
                    dynamic tag     = picx.Tag;
                    Logger.Info("Pulsado boton derecho en {0}", tag.posicio);
                    frmPrograma prg = new frmPrograma(configMenu, tag.posicio);
                    Logger.Info("Iniciando dialogo para añadir elemento");
                    if (prg.ShowDialog() == DialogResult.OK)
                    {
                        Logger.Info("Grabando configuracion");
                        configMenu.Save(this.fileName);
                        OpcioMenu omx = configMenu.getProgram(tag.posicio);
                        this.setPicture(omx, (int)tag.posicio);
//                        this.Refresh();
//                        refreshPictures();
                    }
                }
            });

            return(pic);
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: choldi/WindowsMenu
        private void loadConfig()
        {
            string[] args = Environment.GetCommandLineArgs();
            string   fileConfig;

            Logger.Info("Numero de parametros: {0}", (args.Length - 1).ToString());
            if (args.Length < 2)
            {
                fileConfig = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(args[0]), System.IO.Path.GetFileNameWithoutExtension(args[0]) + ".xml");
                Logger.Info("Sin parámetros ({0}) : {1}", args.Length, fileConfig);
            }
            else
            {
                fileConfig = args[2];
            }
            ConfigMenu cfMenu;
            FileInfo   fi = new FileInfo(fileConfig);

            if (fi.Exists)
            {
                Logger.Info("Cargando fichero {0}", fileConfig);
                cfMenu = new ConfigMenu(fileConfig);
            }
            else
            {
                Logger.Info("Creando fichero {0}", fileConfig);
                Properties.Settings settings = Properties.Settings.Default;
                cfMenu = new ConfigMenu();
                cfMenu.SetMatrix(settings.Rows, settings.Columns);
                cfMenu.Save(fileConfig);
            }
            this.configMenu = cfMenu;
            this.fileName   = fileConfig;
        }