示例#1
0
        static void Main(string[] args)
        {
            Console.Title         = "FOUpdater v" + FOUpdaterClient.VersionString;
            Console.CursorVisible = false;
            Console.Clear();

            string cmdSource = null;
            string cmdConfig = null;

            foreach (string arg in args)
            {
                if (arg == "/autoclose" || arg == "--autoclose")
                {
                    AutoClose = true;
                }

                else if (arg.StartsWith("/source:") || arg.StartsWith("--source:"))
                {
                    cmdSource = arg.Substring((arg.StartsWith("/source:") ? 8 : 9));
                }

                else if (arg.StartsWith("/config:") || arg.StartsWith("--config:"))
                {
                    cmdConfig = arg.Substring((arg.StartsWith("/config:") ? 8 : 9));
                }
            }

            FOUpdaterClient updater = new FOUpdaterClient(cmdConfig);

            FOUpdaterResult result = updater.Update(consoleMessage, null, cmdSource);

            if (result == FOUpdaterResult.InvalidConfig)
            {
                consoleMessage(FOUpdaterMessage.General, "Invalid configuration");
            }

            if (!AutoClose)
            {
                Console.SetCursorPosition(0, textAnyKey);
                Console.CursorVisible = true;
                if (showAnyKey)
                {
                    Console.Write("Press any key to exit...");
                    Console.ReadKey(true);;
                    Console.WriteLine();
                }
            }
        }
示例#2
0
        public UpdateInfo(FOUpdaterClient parent, FOUpdateType type)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            if (type == FOUpdateType.Unknown)
            {
                throw new ArgumentException("type");
            }

            this.Parent             = parent;
            this.Type               = type;
            this.MinimumInfoVersion = this.MaximumInfoVersion = this.InfoVersion = 0;
            this.Content            = "";
            this.Files              = new List <UpdateFile>();
        }
        static void Main( string[] args )
        {
            Console.Title = "FOUpdater v" + FOUpdaterClient.VersionString;
            Console.CursorVisible = false;
            Console.Clear();

            string cmdSource = null;
            string cmdConfig = null;

            foreach( string arg in args )
            {
                if( arg == "/autoclose" || arg == "--autoclose" )
                    AutoClose = true;

                else if( arg.StartsWith( "/source:" ) || arg.StartsWith( "--source:" ) )
                    cmdSource = arg.Substring( (arg.StartsWith( "/source:" ) ? 8 : 9) );

                else if( arg.StartsWith( "/config:" ) || arg.StartsWith( "--config:" ) )
                    cmdConfig = arg.Substring( (arg.StartsWith( "/config:" ) ? 8 : 9) );
            }

            FOUpdaterClient updater = new FOUpdaterClient( cmdConfig );

            FOUpdaterResult result = updater.Update( consoleMessage, null, cmdSource );

            if( result == FOUpdaterResult.InvalidConfig )
            {
                consoleMessage( FOUpdaterMessage.General, "Invalid configuration" );
            }

            if( !AutoClose )
            {
                Console.SetCursorPosition( 0, textAnyKey );
                Console.CursorVisible = true;
                if( showAnyKey )
                {
                    Console.Write( "Press any key to exit..." );
                    Console.ReadKey( true ); ;
                    Console.WriteLine();
                }
            }
        }
示例#4
0
        public UpdateInfo( FOUpdaterClient parent, FOUpdateType type )
        {
            if( parent == null )
                throw new ArgumentNullException( "parent" );

            if( type == FOUpdateType.Unknown )
                throw new ArgumentException( "type" );

            this.Parent = parent;
            this.Type = type;
            this.MinimumInfoVersion = this.MaximumInfoVersion = this.InfoVersion = 0;
            this.Content = "";
            this.Files = new List<UpdateFile>();
        }
示例#5
0
 public UpdateInfoStream( FOUpdaterClient parent )
     : base(parent, FOUpdateType.Stream)
 {
     this.MinimumInfoVersion = 1;
     this.MaximumInfoVersion = 2;
 }
示例#6
0
 public UpdateInfoHTTP( FOUpdaterClient parent )
     : base(parent, FOUpdateType.HTTP)
 {
     this.MinimumInfoVersion = this.MaximumInfoVersion = 1;
 }
示例#7
0
 public UpdateInfoFTP( FOUpdaterClient parent )
     : base(parent, FOUpdateType.FTP)
 {
     throw new NotImplementedException();
 }
示例#8
0
        static void Main(string[] args)
        {
            string cmdSource = null;
            string cmdConfig = null;

            foreach (string arg in args)
            {
                if (arg == "/autoclose" || arg == "--autoclose")
                {
                    AutoClose = true;
                }

                else if (arg.StartsWith("/source:") || arg.StartsWith("--source:"))
                {
                    cmdSource = arg.Substring((arg.StartsWith("/source:") ? 8 : 9));
                }

                else if (arg.StartsWith("/config:") || arg.StartsWith("--config:"))
                {
                    cmdConfig = arg.Substring((arg.StartsWith("/config:") ? 8 : 9));
                }
            }

            FOUpdaterClient updater = new FOUpdaterClient(cmdConfig);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            WindowUpdater       = new frmMain(cmdSource);
            WindowUpdater.Text += " v" + FOUpdaterClient.VersionString;

            if (updater.FOnlineCfg == null && cmdSource == null)
            {
                MessageBox.Show(
                    "Cannot find FOnline configuration file in current directory:\n" +
                    Path.GetDirectoryName(Application.ExecutablePath) + "\n",
                    "FOUpdater",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                Environment.Exit(0);
            }

            Application.Run(WindowUpdater);

            /*
             * if( Installer && File.Exists( ".\\FOConfig.exe" ) )
             * {
             *  DialogResult result = MessageBox.Show(
             *      "To finish installation process, you have to\n" +
             *      "pleple\n" +
             *      "\n" +
             *      "Do you wish to run configuration tool?",
             *      "Updater",
             *      MessageBoxButtons.YesNo,
             *      MessageBoxIcon.Information
             *  );
             *
             *  if( result == DialogResult.No )
             *      Environment.Exit( 0 );
             *  else
             *      Process.Start( ".\\FOConfig.exe" );
             * }
             */
        }
示例#9
0
        private void backgroundWorker_DoWork( object sender, DoWorkEventArgs e )
        {
            this.CancelButton = this.buttonCancel;

            updater = new FOUpdaterClient();
            FOUpdaterResult result = updater.Update( winformMessage, winformProgress, DefaultSource );

            this.AcceptButton = this.buttonCancel;
            this.CancelButton = this.buttonExit;

            if( result == FOUpdaterResult.OK || result == FOUpdaterResult.Cancel )
            {
                string run = null;
                if( updater.FOnlineCfg != null )
                    run = updater.FOnlineCfg.IniReadValue( FOUpdaterClient.Strings.Section, FOUpdaterClient.Strings.Run );

                if( run != null && run.Length > 0 )
                {
                    string[] runOption = run.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries );
                    if( runOption.Length == 2 &&
                        File.Exists( runOption[0] ) &&
                        runOption[1].Length > 0 )
                    {
                        buttonCancel.SetEnabled( true );
                        buttonCancel.SetText( runOption[1] );
                        buttonCancel.SetTag( new string[] { runOption[0], null } );
                    }
                }
                else // FOConfigEx support
                {
                    string[] program = { "FOnline", "FOnlineGL" };

                    if( updater.FOnlineCfg != null )
                        run = updater.FOnlineCfg.IniReadValue( "FOConfig", "PlayProgram" );
                    byte tmp = byte.MaxValue;
                    if( run != null && run.Length > 0 &&
                        byte.TryParse( run, out tmp ) &&
                        tmp < program.Length &&
                        File.Exists( program[tmp] + ".exe" ) )
                    {
                        this.buttonCancel.Enabled = true;
                        this.buttonCancel.Text = "Run " + program[tmp];
                        if( updater.FOnlineCfg.IniReadValueBool( "FOConfig", "SkipLogin" ) )
                            this.buttonCancel.Tag = new string[] { program[tmp], "-Start" };
                        else
                            this.buttonCancel.Tag = new string[] { program[tmp], null };
                    }
                    else
                    {
                        this.buttonCancel.SetEnabled( false );
                    }
                }
            }
            else if( result == FOUpdaterResult.InvalidConfig )
            {
                this.buttonCancel.SetEnabled( false );
                this.buttonCancel.SetVisible( false );
            }
            else if( result == FOUpdaterResult.NoSource )
            {
                this.buttonCancel.SetEnabled( false );
                this.buttonCancel.SetVisible( false );
            }
            else
                throw new NotImplementedException( Enum.GetName( typeof( FOUpdaterResult ), result ) );

            this.buttonExit.SetEnabled( true );
        }
示例#10
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            this.CancelButton = this.buttonCancel;

            updater = new FOUpdaterClient();
            FOUpdaterResult result = updater.Update(winformMessage, winformProgress, DefaultSource);

            this.AcceptButton = this.buttonCancel;
            this.CancelButton = this.buttonExit;

            if (result == FOUpdaterResult.OK || result == FOUpdaterResult.Cancel)
            {
                string run = null;
                if (updater.FOnlineCfg != null)
                {
                    run = updater.FOnlineCfg.GetValue(FOUpdaterClient.Strings.Section, FOUpdaterClient.Strings.Run, (string)null);
                }

                if (run != null && run.Length > 0)
                {
                    string[] runOption = run.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (runOption.Length == 2 &&
                        File.Exists(runOption[0]) &&
                        runOption[1].Length > 0)
                    {
                        buttonCancel.SetEnabled(true);
                        buttonCancel.SetText(runOption[1]);
                        buttonCancel.SetTag(new string[] { runOption[0], null });
                    }
                }
                else // FOConfigEx support
                {
                    string[] program = { "FOnline", "FOnlineGL" };

                    if (updater.FOnlineCfg != null)
                    {
                        run = updater.FOnlineCfg.GetValue("FOConfig", "PlayProgram", (string)null);
                    }
                    byte tmp = byte.MaxValue;
                    if (run != null && run.Length > 0 &&
                        byte.TryParse(run, out tmp) &&
                        tmp < program.Length &&
                        File.Exists(program[tmp] + ".exe"))
                    {
                        this.buttonCancel.Enabled = true;
                        this.buttonCancel.Text    = "Run " + program[tmp];
                        if (updater.FOnlineCfg.GetValue("FOConfig", "SkipLogin", false))
                        {
                            this.buttonCancel.Tag = new string[] { program[tmp], "-Start" }
                        }
                        ;
                        else
                        {
                            this.buttonCancel.Tag = new string[] { program[tmp], null }
                        };
                    }
                    else
                    {
                        this.buttonCancel.SetEnabled(false);
                    }
                }
            }
            else if (result == FOUpdaterResult.InvalidConfig)
            {
                this.buttonCancel.SetEnabled(false);
                this.buttonCancel.SetVisible(false);
            }
            else if (result == FOUpdaterResult.NoSource)
            {
                this.buttonCancel.SetEnabled(false);
                this.buttonCancel.SetVisible(false);
            }
            else
            {
                throw new NotImplementedException(Enum.GetName(typeof(FOUpdaterResult), result));
            }

            this.buttonExit.SetEnabled(true);
        }
示例#11
0
 public UpdateInfoStream(FOUpdaterClient parent)
     : base(parent, FOUpdateType.Stream)
 {
     this.MinimumInfoVersion = 1;
     this.MaximumInfoVersion = 2;
 }
示例#12
0
 public UpdateInfoFTP(FOUpdaterClient parent)
     : base(parent, FOUpdateType.FTP)
 {
     throw new NotImplementedException();
 }
示例#13
0
 public UpdateInfoHTTP(FOUpdaterClient parent)
     : base(parent, FOUpdateType.HTTP)
 {
     this.MinimumInfoVersion = this.MaximumInfoVersion = 1;
 }