Наследование: AbstractApplicationController
Пример #1
0
        public static void Main(string[] args)
        {
            Controller = new Controller();
            UI = UIManager.GetInstance();
            GreenQloud.Core.Program.Run(Controller, UI);
            Application.Run(UI);
#if !__MonoCS__
            // Suppress assertion messages in debug mode
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();
#endif
        }
Пример #2
0
        public static void Main(string[] args)
        {
            try
            {
                Controller = new Controller();                
                UI = UIManager.GetInstance();
                GreenQloud.Core.Program.Run(Controller, UI);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                Logger.LogInfo("Init", e);
                Environment.Exit(-1);
            }

#if !__MonoCS__
            // Suppress assertion messages in debug mode
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();
#endif
        }
Пример #3
0
        public static void Main (string [] args)
        {
            NSApplication.CheckForIllegalCrossThreadCalls = false;
            Mono.Data.Sqlite.SqliteConnection.SetConfig (Mono.Data.Sqlite.SQLiteConfig.Serialized);
            NSApplication.Init ();
            Controller = new Controller ();
            UI = new SparkleUI ();

            if (!program_mutex.WaitOne (0, false)) {
                Logger.LogInfo ("ERROR ON INIT", "QloudSync is already running.");
                Environment.Exit (-1);
            }
            try {
                GreenQloud.Core.Program.Run(Controller, UI);
            } catch (Exception e){
                Logger.LogInfo ("ERROR ON INIT", e);
                Environment.Exit (-1);
            }
            #if !__MonoCS__
            // Suppress assertion messages in debug mode
            GC.Collect (GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers ();
            #endif
        }
Пример #4
0
        public void ShowPage(Controller.PageType type, string [] warnings)
        {
            EventHandler WillCloseDelegate = delegate {
                if(currentWindowCloseApplication){
                    Program.Controller.Quit();
                } else {
                    SparkleSetupController.FinishPageCompleted ();
                }
            };
            this.WillClose += WillCloseDelegate;

            if (type == Controller.PageType.Login) {
                currentWindowCloseApplication = true;

                background_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "loginScreen.png");

                FullNameTextField = new NSTextField () {
                    Frame       = new RectangleF (90, Frame.Height - 337, 270, 25),
                    Delegate    = new SparkleTextFieldDelegate (),
                    Bordered = false,
                    Bezeled = false,
                    FocusRingType = NSFocusRingType.None,
                    Alignment = NSTextAlignment.Center
                };

                NSSecureTextField PasswordTextField = new NSSecureTextField(){
                    Frame       = new RectangleF (90, Frame.Height - 397, 270, 25),
                    Delegate    = new SparkleTextFieldDelegate (),
                    Bordered = false,
                    Bezeled = false,
                    FocusRingType = NSFocusRingType.None,
                    Alignment = NSTextAlignment.Center
                };
                NSTextField MessageLabel = new NSTextField () {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.Clear,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (88, 70 , Frame.Width, 60),
                    StringValue     = "The username or password you entered is incorrect.\n",
                    Font            = NSFontManager.SharedFontManager.FontWithFamily (
                        "Lucida Grande", NSFontTraitMask.Bold, 0, 10),
                    TextColor = NSColor.Red
                };

                RegisterButton = new NSButton () {
                    Frame = new RectangleF (49, 18, 137, 40),
                    Image = new NSImage(Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "CreateButton159.png")),
                    Transparent = false,
                    Bordered = false,
                    Enabled  = true
                };
                ContinueButton = new NSButton () {
                    Frame = new RectangleF (264, 18, 137, 40),
                    Image = new NSImage(Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "LoginButton242.png")),
                    Transparent = false,
                    Bordered = false,
                    Enabled  = true
                };

                RegisterButton.Activated += delegate {
                    Program.Controller.OpenWebsite("https://my.greenqloud.com/registration/qloudsync");
                };

                ContinueButton.Activated += delegate {
                    try{
                        S3Connection.Authenticate (FullNameTextField.StringValue, PasswordTextField.StringValue);
                        Credential.Username = FullNameTextField.StringValue;
                        SparkleSetupController.LoginDone();
                    }
                    catch (System.Net.WebException)
                    {
                        ContentView.AddSubview (MessageLabel);
                    }
                };

                ContentView.AddSubview (FullNameTextField);
                ContentView.AddSubview (PasswordTextField);

                Buttons.Add (ContinueButton);
                Buttons.Add (RegisterButton);
            }

            if (type == Controller.PageType.ConfigureFolders) {
                try {
                    currentWindowCloseApplication = true;

                    this.background_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "SelectSync1.png");

                    NSTextField SQFolderTextLabel = new NSTextField () {
                        Alignment       = NSTextAlignment.Center,
                        BackgroundColor = NSColor.Clear,
                        Bordered        = false,
                        Editable        = false,
                        Frame           = new RectangleF (0, 75 , Frame.Width, 60),
                        StringValue     = "Current StorageQloud Path:",
                        Font            = NSFontManager.SharedFontManager.FontWithFamily (
                            "Lucida Grande", NSFontTraitMask.Unbold, 0, 9),
                        TextColor = NSColor.White
                    };

                    if(SQFolderText == null) {
                        SQFolderText = new NSTextField () {
                            Alignment       = NSTextAlignment.Center,
                            BackgroundColor = NSColor.Clear,
                            Bordered        = false,
                            Editable        = false,
                            Frame           = new RectangleF (0, 60 , Frame.Width, 60),
                            StringValue     = RuntimeSettings.DefaultHomePath,
                            Font            = NSFontManager.SharedFontManager.FontWithFamily (
                                "Lucida Grande", NSFontTraitMask.Unbold, 0, 9),
                            TextColor = NSColor.White
                        };
                    }

                    ChangeSQFolder = new NSButton () {
                        Frame = new RectangleF (49, 18, 137, 40),
                        Image = new NSImage(Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "Changeit220.png")),
                        Transparent = false,
                        Bordered = false,
                        Enabled  = true
                    };

                    ChangeSQFolder.Activated += delegate {
                        SQFolderText.StringValue = SparkleSetupController.ChangeSQFolder ();
                        Reset ();
                        ShowPage(AbstractApplicationController.PageType.ConfigureFolders, null);
                        ShowAll();
                    };

                    FinishButton = new NSButton () {
                        Frame = new RectangleF (264, 18, 137, 40),
                        Image = new NSImage(Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "Continue159.png")),
                        Transparent = false,
                        Bordered = false,
                        Enabled  = true
                    };
                    FinishButton.Activated += delegate {
                        DirectoryInfo dir = new DirectoryInfo(SQFolderText.StringValue);
                        bool proceed = true;
                        if(dir.Exists && (dir.GetDirectories().Length > 0 || dir.GetFiles().Length > 0) ){
                            if(!Program.Controller.Confirm("This folder is not empty, do you want to proceed? QloudSync will merge all files with your account.") ){
                                proceed = false;
                            }
                        }
                        if(proceed){
                            SparkleSetupController.Finish (SQFolderText.StringValue, remoteFoldersCheckboxes);
                        } else {
                            Reset ();
                            ShowPage(AbstractApplicationController.PageType.ConfigureFolders, null);
                            ShowAll();
                        }

                    };

                    InitializeCheckboxesFolders ();
                    ContentView.AddSubview (SQFolderTextLabel);
                    ContentView.AddSubview (SQFolderText);
                    Buttons.Add (ChangeSQFolder);
                    Buttons.Add (FinishButton);
                    NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest);
                } catch (Exception e) {
                    Logger.LogInfo ("ERROR ON LOADING CONFIG FOLDERS", e);
                    Reset ();
                    ShowPage(AbstractApplicationController.PageType.Login, null);
                    ShowAll ();
                    NSTextField MessageLabel = new NSTextField () {
                        Alignment       = NSTextAlignment.Left,
                        BackgroundColor = NSColor.Clear,
                        Bordered        = false,
                        Editable        = false,
                        Frame           = new RectangleF (88, 55 , Frame.Width, 60),
                        StringValue     = "An unexpected error occurred, please try again later.\n",
                        Font            = NSFontManager.SharedFontManager.FontWithFamily (
                            "Lucida Grande", NSFontTraitMask.Bold, 0, 10),
                        TextColor = NSColor.Red
                    };
                    ContentView.AddSubview (MessageLabel);
                }
            }

            if (type == Controller.PageType.Finished) {
                currentWindowCloseApplication = false;
                this.background_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "getStarted.png");
                OpenFolderButton = new NSButton () {
                    Frame = new RectangleF (157, 18, 137, 40),
                    Image = new NSImage(Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "getstartedbutton.png")),
                    Transparent = false,
                    Bordered = false,
                    Enabled  = true
                };
                OpenFolderButton.Activated += delegate {
                    SparkleSetupController.FinishPageCompleted ();
                    SparkleSetupController.GetStartedClicked ();
                };
                Buttons.Add (OpenFolderButton);
                NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest);
            }
        }