Beispiel #1
0
        public void Oauth(CloudType type)
        {
            CheckThread(true);
            Type type_oauthUI;

            switch (type)
            {
            case CloudType.Dropbox:
                DropboxOauthv2 oauth_dropbox = new DropboxOauthv2();
                oauth_dropbox.TokenCallBack += Oauth_dropbox_TokenCallBack;

                type_oauthUI       = LoadDllUI.GetTypeInterface(typeof(UIinterfaceDB));
                AppSetting.UIOauth = (OauthUI)Activator.CreateInstance(type_oauthUI);

                oauth_dropbox.GetCode(AppSetting.UIOauth, AppSetting.UIMain);
                break;


            case CloudType.GoogleDrive:
                GoogleAPIOauth2 oauth_gd = new GoogleAPIOauth2();
                oauth_gd.TokenCallBack += Oauth_gd_TokenCallBack;

                type_oauthUI       = LoadDllUI.GetTypeInterface(typeof(UIinterfaceGD));
                AppSetting.UIOauth = (OauthUI)Activator.CreateInstance(type_oauthUI);

                oauth_gd.GetCode(AppSetting.UIOauth, AppSetting.UIMain);
                break;


            case CloudType.Mega:
                type_oauthUI = LoadDllUI.GetTypeInterface(typeof(UIinterfaceMegaNz));
                UIinterfaceMegaNz mega = (UIinterfaceMegaNz)Activator.CreateInstance(type_oauthUI);
                bool error             = false;
reoauthMega:
                if (!error)
                {
                    mega.ShowDialog_();
                }
                else
                {
                    mega.ShowError("Wrong email or password.");
                }
                if (mega.Success)
                {
                    MegaApiClient.AuthInfos oauthinfo = MegaApiClient.GenerateAuthInfos(mega.Email, mega.Pass);
                    MegaApiClient           client    = new MegaApiClient();
                    try
                    {
                        client.Login(oauthinfo);
                    }
                    catch (Exception) { error = true; goto reoauthMega; }
                    SaveToken(mega.Email, JsonConvert.SerializeObject(oauthinfo), CloudType.Mega);
                }
                break;


            default: throw new Exception("Not support");
            }
        }
Beispiel #2
0
        //long task (need thread)
        public void Delete(DeleteItems items)
        {
            CheckThread(true);
            Type       type_deleteform = LoadDllUI.GetTypeInterface(typeof(CloudManagerGeneralLib.UiInheritance.UIDelete));
            DeleteTask dw = new DeleteTask(items.Items, AppSetting.UIMain.CreateUI <CloudManagerGeneralLib.UiInheritance.UIDelete>(type_deleteform), items.PernamentDelete);

            dw.Start();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Assembly      assembly  = typeof(Program).Assembly;
            GuidAttribute attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];

            guid  = attribute.Value;
            mutex = new Mutex(true, "{" + guid + "}");

            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                AppSetting.MainThread = Thread.CurrentThread;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
#if DEBUG
                DeleteFile_dev();// dev mode
#endif
                //load instance class
                AppSetting.LoadAPIKey();
                ReadWriteData.CreateFolderSaveData();                    // create folder %appdata%\\CloudManager
                Get_mimeType.Load();                                     //mimeType (google drive upload)
                AppSetting.ManageCloud     = new CloudManager();         //explorer
                AppSetting.TransferManager = new ItemsTransferManager(); //transfer file
                AppSetting.login           = new Core.Class.Login();     //load login

                //load core
                AppSetting.settings = new Settings();                                                       //load settings
                AppSetting.settings.ReadSettings();
                AppSetting.lang = new Languages(AppSetting.settings.GetSettingsAsString(SettingsKey.lang)); //load language

                if (!LoadDllUI.Load())
                {
                    return;                             //load dll UI
                }
                AddEventHandleUI.CreateInstanceLogin(); //Create Login UI
                AddEventHandleUI.Load_Setting_UI();     //Load Setting_UI and event

                AppSetting.login.Load(args);            // load login form
                AppSetting.UILogin.ShowDialog_();
                if (!string.IsNullOrEmpty(AppSetting.Pass))
                {
#if DEBUG && TESTCLASS
                    Core.TestClass.Test();
#endif
                    AppSetting.TransferManager.Start(typeof(Program));
                    AddEventHandleUI.Load_UIMain();
                    AppSetting.UIMain.ItemsTransfer = AppSetting.TransferManager.ItemsTransfer;
showMainForm:
                    AppSetting.TransferManager.Status = StatusUpDownApp.Start;
                    AppSetting.UIMain.ShowDialog_();
                    if (AppSetting.UIMain.AreReloadUI)//if reload ui
                    {
                        AppSetting.CloseOauthUI();
                        AppSetting.TransferManager.Status = StatusUpDownApp.Pause;
                        //clean memory
                        AppSetting.UIMain = null;
                        //reload dll ui
                        if (!LoadDllUI.Load())
                        {
                            return;       //reload dll
                        }
                        //Reflection_UI.Load_Setting_UI();//Load Setting_UI and event
                        AddEventHandleUI.Load_UIMain();//create instance main and LV_ud
                        AppSetting.settings.SaveSettings();
                        GC.Collect();
                        goto showMainForm;
                    }
                    // close all thread
                    AppSetting.UIclose = (UIClosing)Activator.CreateInstance(LoadDllUI.GetTypeInterface(typeof(UIClosing)));
                    AppSetting.TransferManager.Eventupdateclosingform += AppSetting.UIclose.updatedata;
                    AppSetting.TransferManager.Eventcloseapp          += AppSetting.UIclose.Close_;
                    AppSetting.TransferManager.Status = StatusUpDownApp.StopForClosingApp;
                    AppSetting.UIclose.ShowDialog_();
                }
                mutex.ReleaseMutex();
            }
            else
            {
                MessageBox.Show("false");
            }
        }