示例#1
0
 /// <summary>
 /// JS Callback
 /// </summary>
 public void Pull()
 {
     Javascript.Run("getSelectedFiles();", files =>
     {
         ProjectManager.Instance.Pull();
     });
 }
示例#2
0
        /// <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();
        }
示例#3
0
 /// <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();");
     });
 }
示例#6
0
        private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!_continueQuitting)
            {
                e.Cancel = true;

                // show shutdown question
                Javascript.Run("showQuitQuestionMessage();");
            }
        }
示例#7
0
        // 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 + ");");
        }
示例#8
0
        /// <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());
            });
        }
示例#9
0
        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});");
        }
示例#10
0
        /// <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();
                            }
                        }
                    });
                }
            }
        }
示例#11
0
        /// <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);
            }
        }
示例#12
0
 /// <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}');");
 }
示例#13
0
 /// <summary>
 /// Restarts processing message. (hide)
 /// </summary>
 public static void ResetProcessingMessage()
 {
     Javascript.Run("setActiveProcessingWindow(false, \'\', \'\');");
 }
示例#14
0
 /// <summary>
 /// Sets progress window message.
 /// </summary>
 /// <param name="message">The progress message.</param>
 public static void SetProgress(string message)
 {
     Javascript.Run("setProgressMesssage('" + message + "');");
 }
示例#15
0
 /// <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() + ");");
 }
示例#16
0
 /// <summary>
 /// Shows progress window.
 /// </summary>
 /// <param name="message">The progress message.</param>
 public static void ShowProgress(string message)
 {
     SetProgress(message);
     Javascript.Run("showProgress();");
 }
示例#17
0
 public static void UpdateButtons(bool activeState)
 {
     Javascript.Run($"setActiveButtons('{activeState}', '{activeState}');");
 }
示例#18
0
 /// <summary>
 /// Closes progress window.
 /// </summary>
 public static void HideProgress()
 {
     Javascript.Run("hideProgress();");
 }
示例#19
0
 /// <summary>
 /// Dispose all displayed modals.
 /// </summary>
 public static void DisposeAllModals()
 {
     Javascript.Run("disposeAllModals();");
 }