/// <summary> /// JS Callback /// </summary> public void Pull() { Javascript.Run("getSelectedFiles();", files => { ProjectManager.Instance.Pull(); }); }
/// <summary> /// Quit application. /// </summary> public static void Quit() { // don't show shutdown question message _continueQuitting = true; // show shutdown notify Javascript.Run("showShutdownMessage();"); // save configuration SMCConfiguration.Save(); // shutdown application from thread var wait = new Thread(() => { // shutdown working downloader Instance.SMCDownloader.ShutDownDownloader(); // wait Thread.Sleep(800); // shutdown application Instance.Invoke((MethodInvoker) delegate { Instance.Hide(); Browser.Dispose(); Cef.Shutdown(); Process.GetCurrentProcess().Kill(); }); }); wait.Start(); }
/// <summary> /// Draws processing message on window. /// </summary> /// <param name="title">Title of window.</param> /// <param name="message">Message of window.</param> public static void DrawProcessingMessage(string title, string message) { ResetProcessingMessage(); Javascript.Run( $"setActiveProcessingWindow({(string.IsNullOrEmpty(title) || string.IsNullOrEmpty(message) ? "false" : "true")}," + $" '{title}', '{message}');"); }
public void onOptions() { MainWindow.Instance.Invoke((MethodInvoker) delegate { // show options window Javascript.Run("showOptionsWindow();"); }); }
public void onQuitRequest() { MainWindow.Instance.Invoke((MethodInvoker) delegate { // show shutdown question Javascript.Run("showQuitQuestionMessage();"); }); }
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { if (!_continueQuitting) { e.Cancel = true; // show shutdown question Javascript.Run("showQuitQuestionMessage();"); } }
// private private void UpdateView() { Javascript.Run("selectProject('" + CurrentProject.ProjectName + "', false);"); var diff = CurrentProject.BuildDiff(); var filesJs = diff.Aggregate("", (current, file) => current + ("addFileChange('" + file.FileName + "', " + (int)file.DiffType) + ");"); Javascript.Run(filesJs); Javascript.Run("setChangeCount('" + CurrentProject.ProjectName + "', " + diff.Length + ");"); }
/// <summary> /// JS Callback /// </summary> public void Push() { Javascript.Run("getSelectedFiles();", files => { var data = files as List <object>; if (data == null) { ProjectManager.Instance.Push(new string[] { }); return; } ProjectManager.Instance.Push(data.Select(file => file as string).ToArray()); }); }
private static void InternalUpdateProgress() { if (_lastInternalCurrentText == InternalCurrentText && _lastInternalCurrentValue == InternalCurrentValue && _lastInternalGlobalText == InternalGlobalText && _lastInternalGlobalValue == InternalGlobalValue) { return; } _lastInternalCurrentText = InternalCurrentText; _lastInternalCurrentValue = InternalCurrentValue; _lastInternalGlobalText = InternalGlobalText; _lastInternalGlobalValue = InternalGlobalValue; Javascript.Run( $"updateProgress('{InternalCurrentText}', {InternalCurrentValue}, '{InternalGlobalText}', {InternalGlobalValue});"); }
/// <summary> /// Loads all available projects and selects last opened project. /// </summary> public void LoadAll() { ClientUI.ShowProgress("Loading..."); if (File.Exists("client.json")) { var config = JsonConvert.DeserializeObject <ClientSettings>(File.ReadAllText("client.json")); var done = 0; foreach (var project in config.Projects) { var projInst = Project.OpenWorkingCopy(project.Address, project.Name, project.RootDir); projInst.Authority = new ProjectAuthority { ProjectName = project.Name, Username = project.Username, AccessToken = PasswordHasher.Hash(project.Username, project.Password) }; Javascript.Run("addProject('" + project.Name + "');"); projInst.Refresh(delegate { var diff = projInst.BuildDiff(); Javascript.Run("setChangeCount('" + project.Name + "', " + diff.Length + ");"); AllProjects.Add(projInst); done++; if (done == config.Projects.Length) { // select if (!string.IsNullOrEmpty(config.Selected)) { Select(config.Selected); // this will also hide the progress } else { ClientUI.HideProgress(); } } }); } } }
/// <summary> /// Selects project by name, also refreshes the files changes. /// </summary> /// <param name="projectName">The project name.</param> /// <param name="callback">Is this javascript callback?</param> /// <param name="refresh">Refresh the project?</param> public void Select(string projectName, bool callback = false, bool refresh = true) { try { ClientUI.ShowProgress("Loading..."); // select CurrentProject = AllProjects.FirstOrDefault(project => project.ProjectName == projectName); if (CurrentProject == null) { ClientUI.ShowMessage("Failed to select project '" + projectName + "', invalid project name!", true); return; } if (!callback) { Javascript.Run("selectProject('" + projectName + "', false);"); } if (refresh) { CurrentProject.Refresh(delegate { var diff = CurrentProject.BuildDiff(); var filesJs = diff.Aggregate("", (current, file) => current + ("addFileChange('" + file.FileName + "', " + (int)file.DiffType) + ");"); Javascript.Run(filesJs); Javascript.Run("setChangeCount('" + CurrentProject.ProjectName + "', " + diff.Length + ");"); ClientUI.HideProgress(); }); } } catch { if (refresh) { ClientUI.HideProgress(); } ClientUI.ShowMessage("Failed to select project '" + projectName + "'!", true); } }
/// <summary> /// Draws fatal message with quit button. /// </summary> /// <param name="title">Title of window.</param> /// <param name="message">Message of window.</param> public static void DrawFatalMessage(string title, string message) { Javascript.Run($"setFatalWindow('{title}', '{message}');"); }
/// <summary> /// Restarts processing message. (hide) /// </summary> public static void ResetProcessingMessage() { Javascript.Run("setActiveProcessingWindow(false, \'\', \'\');"); }
/// <summary> /// Sets progress window message. /// </summary> /// <param name="message">The progress message.</param> public static void SetProgress(string message) { Javascript.Run("setProgressMesssage('" + message + "');"); }
/// <summary> /// Shows message overaly. /// </summary> /// <param name="message">The message.</param> /// <param name="isError">Is this message an error?</param> public static void ShowMessage(string message, bool isError = false) { Javascript.Run("showMessage('" + message + "', " + isError.ToString().ToLower() + ");"); }
/// <summary> /// Shows progress window. /// </summary> /// <param name="message">The progress message.</param> public static void ShowProgress(string message) { SetProgress(message); Javascript.Run("showProgress();"); }
public static void UpdateButtons(bool activeState) { Javascript.Run($"setActiveButtons('{activeState}', '{activeState}');"); }
/// <summary> /// Closes progress window. /// </summary> public static void HideProgress() { Javascript.Run("hideProgress();"); }
/// <summary> /// Dispose all displayed modals. /// </summary> public static void DisposeAllModals() { Javascript.Run("disposeAllModals();"); }