Пример #1
0
 private static void CheckForUpdate()
 {
     try {
         ProgramUpdateElement updateElement = Current.RdcManSection.ProgramUpdate;
         if (!string.IsNullOrEmpty(updateElement.VersionPath) && !string.IsNullOrEmpty(updateElement.UpdateUrl))
         {
             if (!DateTime.TryParse(Preferences.LastUpdateCheckTimeUtc, out DateTime result) || DateTime.UtcNow.Subtract(result).TotalDays < 1.0)
             {
                 Log.Write("上次检查更新于 {0}, 明天之前不再检查", result.ToString("s"));
             }
             else
             {
                 Preferences.LastUpdateCheckTimeUtc = DateTime.UtcNow.ToString("u");
                 string input = File.ReadAllText(updateElement.VersionPath);
                 if (Version.TryParse(input, out Version result2))
                 {
                     Assembly     executingAssembly = Assembly.GetExecutingAssembly();
                     AssemblyName name = executingAssembly.GetName();
                     Log.Write("最新版本 = {0}", result2);
                     if (name.Version < result2)
                     {
                         TheForm.Invoke((MethodInvoker) delegate {
                             FormTools.InformationDialog("有一个新版本的RDCMan可从此处下载: {0}".InvariantFormat(updateElement.UpdateUrl));
                         });
                     }
                 }
             }
         }
     }
     catch (Exception) {
     }
 }
Пример #2
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="AFormName"></param>
        /// <returns></returns>
        public Boolean ShowForm(String AFormName)
        {
            Boolean ReturnValue;

            System.Windows.Forms.Form TheForm;

            // MessageBox.Show('TFormsList.ShowForm called for Form named ''' + AFormName + '''');
            TheForm = this[AFormName];

            if (TheForm != null)
            {
                // MessageBox.Show('TFormsList.ShowForm: found Form, now activing it.');
                TheForm.Visible     = true;
                TheForm.WindowState = FormWindowState.Normal;
                TheForm.Activate();
                ReturnValue = true;
            }
            else
            {
                // MessageBox.Show('TFormsList.ShowForm: Form NOT found!');
                ReturnValue = false;
            }

            return(ReturnValue);
        }
 private void MinimizeForm()
 {
     if (TheForm.WindowState == FormWindowState.Normal)
     {
         TheForm.Hide();
         TheForm.WindowState = FormWindowState.Minimized;
     }
 }
 private void MaximizeForm()
 {
     if (TheForm.WindowState == FormWindowState.Minimized)
     {
         TheForm.Show();
         TheForm.Activate();
         TheForm.WindowState   = FormWindowState.Normal;
         TheForm.ShowInTaskbar = true;
     }
 }
Пример #5
0
        private static void CompleteInitialization()
        {
            InstantiatePlugins();
            if (_filesToOpen.Count > 0)
            {
                Preferences.FilesToOpen = _filesToOpen;
            }
            else if (!_openFiles)
            {
                Preferences.FilesToOpen = null;
            }
            List <ServerBase> connectedServers = new List <ServerBase>();

            ServerTree.Instance.Operation(OperationBehavior.SuspendSort, delegate {
                foreach (IBuiltInVirtualGroup item in BuiltInVirtualGroups.Where((IBuiltInVirtualGroup group) => group.IsVisibilityConfigurable))
                {
                    item.IsInTree = Preferences.GetBuiltInGroupVisibility(item);
                }
            });
            OpenFiles();
            ServerTree.Instance.Operation(OperationBehavior.SuspendGroupChanged, delegate {
                Preferences.LoadBuiltInGroups();
                ConnectedGroup.Instance.Nodes.ForEach(delegate(TreeNode n) {
                    connectedServers.Add(((ServerRef)n).ServerNode);
                });
                ConnectedGroup.Instance.RemoveChildren();
                ServerTree.Instance.SortBuiltinGroups();
            });
            ServerTree.Instance.Show();
            ServerTree.Instance.Focus();
            bool isFirstConnection = ReconnectAtStartup(connectedServers);

            if (_serversToConnect != null)
            {
                ConnectNamedServers(_serversToConnect, isFirstConnection);
            }
            if (Preferences.ServerTreeVisibility != 0)
            {
                ServerTree.Instance.Hide();
            }
            PluginAction(delegate(IPlugin p) {
                p.PostLoad(PluginContext);
            });
            Preferences.NeedToSave = false;
            TheForm.UpdateAutoSaveTimer();
            ThreadPool.QueueUserWorkItem(delegate {
                CheckForUpdate();
            });
            Log.Write("启动完成");
        }
Пример #6
0
 private void MainForm_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
 {
     if (MetroMessageBox.Show(this, "정말 종료하시겠습니까?", "종료", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         foreach (Form TheForm in this.MdiChildren)
         {
             TheForm.Close();
         }
         e.Cancel = false;
     }
     else
     {
         e.Cancel = true;
     }
 }
Пример #7
0
        internal static void Main(params string[] args)
        {
            //防止工作目录不是文件所在目录
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            Application.EnableVisualStyles();
            Policies.Read();
            using (Helpers.Timer("解析命令行")) {
                ParseCommandLine();
            }
            try {
                Current.Read();
            }
            catch (Exception ex) {
                FormTools.ErrorDialog("读取RDCMan配置文件时出错:{0}程序可能不稳定或功能不完全。".InvariantFormat(ex.Message));
            }
            using (CompositionContainer compositionContainer = new CompositionContainer(new AssemblyCatalog(Assembly.GetCallingAssembly()))) {
                _builtInVirtualGroups.AddRange(compositionContainer.GetExportedValues <IBuiltInVirtualGroup>());
                _builtInVirtualGroups.Sort((IBuiltInVirtualGroup a, IBuiltInVirtualGroup b) => a.Text.CompareTo(b.Text));
            }
            using (Helpers.Timer("读取个性设置")) {
                Preferences = Preferences.Load();
                if (Preferences == null)
                {
                    Environment.Exit(1);
                }
            }
            Thread thread2;

            using (Helpers.Timer("启动消息循环线程")) {
                InitializedEvent = new ManualResetEvent(initialState: false);
                Thread thread = new Thread(StartMessageLoop);
                thread.IsBackground = true;
                thread2             = thread;
                thread2.SetApartmentState(ApartmentState.STA);
                thread2.Start();
                InitializedEvent.WaitOne();
            }
            if (TheForm == null)
            {
                Environment.Exit(1);
            }
            TheForm.Invoke(new MethodInvoker(CompleteInitialization));
            thread2.Join();
            Log.Write("正在退出");
        }
Пример #8
0
        public ValidationResult ValidateTheForm(TheForm submittedForm)
        {
            var result = new ValidationResult();

            if (submittedForm == null)
            {
                result.IsValid           = false;
                result.ValidationMessage = "Ups, the model is null";
                return(result);
            }

            if (string.IsNullOrWhiteSpace(submittedForm.SimpleInput))
            {
                result.IsValid           = false;
                result.ValidationMessage = "You naughty boi, put something into the field!";
                return(result);
            }

            result.IsValid           = true;
            result.ValidationMessage = $"Grrrrrrrate success! You put in {submittedForm.SimpleInput}";
            return(result);
        }
Пример #9
0
 protected override OnFormClose(EventArgs e)
 {
     Instance = null;
     base.OnFormClose(e);
 }