private void SaveAppConfiguration() { var xmlWriter = new XmlTextWriter(AppConfigFile, Encoding.Unicode) { Formatting = Formatting.Indented }; try { xmlWriter.WriteStartDocument(); xmlWriter.WriteComment("!!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!"); xmlWriter.WriteStartElement("ApplicationDocks"); xmlWriter.WriteAttributeString("FormatVersion", PersistorExt.AppConfigFileVersion); MainDockPanel.Save(xmlWriter); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); } finally { xmlWriter.Flush(); xmlWriter.Close(); } }
private void LoadLayout(string path) { try { using (var stream = File.OpenRead(path)) { using (var archive = new ZipArchive(stream, ZipArchiveMode.Read)) { MainDockPanel.SuspendLayout(true); WindowPlacementManager.LoadWindowPlacement(this, archive.GetEntry("WindowPlacement.xml").Open()); LoadSubWindowsLayout(archive.GetEntry("SubWindowLayout.xml").Open()); } } Utility.Logger.Add(2, string.Format(Resources.LayoutLoaded, path)); } catch (FileNotFoundException) { Utility.Logger.Add(3, string.Format(Resources.NoLayoutFound)); MessageBox.Show(Resources.InitLayout, Resources.NoLayoutFound, MessageBoxButtons.OK, MessageBoxIcon.Information); fBrowser.Show(MainDockPanel); } catch (DirectoryNotFoundException) { Utility.Logger.Add(3, string.Format(Resources.NoLayoutFound)); MessageBox.Show(Resources.InitLayout, Resources.NoLayoutFound, MessageBoxButtons.OK, MessageBoxIcon.Information); fBrowser.Show(MainDockPanel); } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, LoggerRes.FailedLoadLayout); } finally { MainDockPanel.ResumeLayout(true, true); } }
private void Events_ProcPrint(object sender, ProcPrintEvent e) { // Wait until it is safe to enter. mut.WaitOne(); OutputControl Tab = (OutputControl)MainDockPanel.GetDocuments().Find(x => x.DockText == e.Sender); if (Tab != null) { Invoke((MethodInvoker) delegate { Tab.Append(e.Type, e.Data); }); } else { Invoke((MethodInvoker) delegate { OutputControl NewDocument = new OutputControl(PS4, e.Sender); MainDockPanel.AddContent(NewDocument); NewDocument.Append(e.Type, e.Data); }); } // Release the Mutex. mut.ReleaseMutex(); }
private void toolStripButton2_Click(object sender, EventArgs e) { foreach (OutputControl Content in MainDockPanel.GetDocuments()) { Content.Clear(); } }
private void LoadLayout(string path) { try { using (var stream = File.OpenRead(path)) { using (var archive = new ZipArchive(stream, ZipArchiveMode.Read)) { MainDockPanel.SuspendLayout(true); WindowPlacementManager.LoadWindowPlacement(this, archive.GetEntry("WindowPlacement.xml").Open()); LoadSubWindowsLayout(archive.GetEntry("SubWindowLayout.xml").Open()); } } Utility.Logger.Add(2, path + " からウィンドウ レイアウトを復元しました。"); } catch (FileNotFoundException) { Utility.Logger.Add(3, string.Format("ウィンドウ レイアウト ファイルは存在しません。")); MessageBox.Show("レイアウトが初期化されました。\r\n「表示」メニューからお好みのウィンドウを追加してください。", "ウィンドウ レイアウト ファイルが存在しません", MessageBoxButtons.OK, MessageBoxIcon.Information); fBrowser.Show(MainDockPanel); } catch (DirectoryNotFoundException) { Utility.Logger.Add(3, string.Format("ウィンドウ レイアウト ファイルは存在しません。")); MessageBox.Show("レイアウトが初期化されました。\r\n「表示」メニューからお好みのウィンドウを追加してください。", "ウィンドウ レイアウト ファイルが存在しません", MessageBoxButtons.OK, MessageBoxIcon.Information); fBrowser.Show(MainDockPanel); } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, "ウィンドウ レイアウトの復元に失敗しました。"); } finally { MainDockPanel.ResumeLayout(true, true); } }
private void LoadDockContentConfiguration() { var deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); var dockConfigFileName = _startupPath + DOCK_CONFIG_FILE; if (!File.Exists(dockConfigFileName)) { return; } try { MainDockPanel.LoadFromXml(dockConfigFileName, deserializeDockContent); } catch (Exception) { try { File.Delete(dockConfigFileName); } catch { } } }
private void RestoreDefaultConfig() { using (var memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(Properties.Resources.ApplicationDefaultDocks))) { MainDockPanel.Restore(memoryStream, m_DeserializeDockContent); memoryStream.Close(); } }
private void SaveSubWindowsLayout(Stream stream) { try { MainDockPanel.SaveAsXml(stream, Encoding.UTF8); } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, "サブウィンドウ レイアウトの保存に失敗しました。"); } }
private void SaveSubWindowsLayout(Stream stream) { try { MainDockPanel.SaveAsXml(stream, Encoding.UTF8); } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, LoggerRes.FailedSaveLayout); } }
public MainWindow() { ViewModel = new MainWindowViewModel(world); InitializeComponent(); keyboardHandler = new KeyboardHandler(tickInterval); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Left, (duration) => World.Instance.ControlledCar.X -= 5, null)); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Right, (duration) => World.Instance.ControlledCar.X += 5, null)); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Up, (duration) => World.Instance.ControlledCar.Y -= 5, null)); keyboardHandler.HoldableKeys.Add(new HoldableKey(Key.Down, (duration) => World.Instance.ControlledCar.Y += 5, null)); hmiDebug = new HMIDebug(); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D1, () => hmiDebug.OnDebugAction(1))); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D2, () => hmiDebug.OnDebugAction(2))); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D3, () => hmiDebug.OnDebugAction(3))); keyboardHandler.PressableKeys.Add(new PressableKey(Key.D4, () => hmiDebug.OnDebugAction(4))); timer.Interval = TimeSpan.FromMilliseconds(tickInterval); timer.Tick += logic; timer.Start(); // make my dockpanel focus of this game MainDockPanel.Focus(); world.Width = 2000; world.Height = 1000; var circle = new Circle(400, 200, "circle.png", 20); circle.Width = 40; circle.Height = 40; circle.ZIndex = 2; world.AddObject(circle); var controlledCar = new Models.AutomatedCar(50, 50, "car_1_white.png"); controlledCar.Width = 108; controlledCar.Height = 240; // read the world object polygons, get the one for the car in a primitive way // this is just a sample, the proecssing shold be much more general string json_text = System.IO.File.ReadAllText($"Assets/worldobject_polygons.json"); dynamic stuff = JObject.Parse(json_text); var geom = new Polyline(); // get the points from the json and add to the polyline foreach (var i in stuff["objects"][0]["polys"][0]["points"]) { geom.Points.Add(new Point(i[0].ToObject <int>(), i[1].ToObject <int>())); } // add polyline to the car controlledCar.Geometry = geom; world.AddObject(controlledCar); world.ControlledCar = controlledCar; controlledCar.Start(); }
private void LoadSubWindowsLayout(Stream stream) { try { if (stream != null) { // 取り込んだウィンドウは一旦デタッチして閉じる fWindowCapture.CloseAll(); foreach (var f in SubForms) { f.Show(MainDockPanel, DockState.Document); f.DockPanel = null; } MainDockPanel.LoadFromXml(stream, new DeserializeDockContent(GetDockContentFromPersistString)); //一度全ウィンドウを読み込むことでフォームを初期化する foreach (var x in MainDockPanel.Contents) { if (x.DockHandler.DockState == DockState.Hidden) { x.DockHandler.Show(MainDockPanel); x.DockHandler.Hide(); } else { x.DockHandler.Activate(); } } // checkme: このコードの存在意義 /*/ * if ( MainDockPanel.Contents.Count > 0 ) * MainDockPanel.Contents.First().DockHandler.Activate(); * //*/ fWindowCapture.AttachAll(); } else { foreach (var f in SubForms) { f.Show(MainDockPanel); } foreach (var x in MainDockPanel.Contents) { x.DockHandler.Hide(); } } } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, "サブウィンドウ レイアウトの復元に失敗しました。"); } }
private bool Shutdown(bool allowPrevent) { var shutdown = true; try { string dockConfigFileName = _startupPath + DOCK_CONFIG_FILE; IMyGenContent mygenContent = null; DockContentCollection dockContentCollection = MainDockPanel.Contents; var canClose = true; if (allowPrevent && !ZeusProcessManager.IsDormant) { return(false); } foreach (IDockContent dockContent in dockContentCollection) { mygenContent = dockContent as IMyGenContent; // We need the MetaDataBrowser window to be closed last // because it houses the UserMetaData if (!(mygenContent is MetaDataBrowser)) { canClose = mygenContent.CanClose(allowPrevent); if (allowPrevent && !canClose) { shutdown = false; break; } } if (dockContent.DockHandler.IsHidden) { dockContent.DockHandler.Close(); } } if (shutdown) { MainDockPanel.SaveAsXml(dockConfigFileName); } } catch { shutdown = true; } return(shutdown); }
private void OnActivity(object s, MouseEventArgs e) { _inactivityTimer.Stop(); var animation = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.3))); animation.EasingFunction = new SineEase { EasingMode = EasingMode.EaseInOut }; MainDockPanel.BeginAnimation(OpacityProperty, animation); this.Cursor = _defaultCursor; _inactivityTimer.Start(); }
private void OnInactivity(object s, EventArgs e) { if (MainDockPanel.IsMouseOver) { return; } var animation = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.3))); animation.EasingFunction = new SineEase { EasingMode = EasingMode.EaseInOut }; MainDockPanel.BeginAnimation(OpacityProperty, animation); this.Cursor = Cursors.None; }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (ClosingControl == "ToolStripMenuItem") { CloseAllTab(); var fi = new FileInfo(Config.DockSettingFileName); if (fi.Directory != null && !fi.Directory.Exists) { fi.Directory.Create(); } if (!_hasDockSettingExceptioin) { MainDockPanel.SaveAsXml(Config.DockSettingFileName); } if (!_hasViewSettingException) { SaveViewSetting(); } var ph = new ProxyHelper(); ph.SetIEProxy("", 0); try { XmlHelper.XmlSerialize(Config.LastProxyFileName, ProxyData.ProxyList, typeof(List <ProxyServer>)); //设置最后的列表 } catch { } notifyIconMain.Dispose(); Process.GetCurrentProcess().Kill(); } else { WindowState = FormWindowState.Minimized; e.Cancel = true; } } catch (Exception ex) { MsgBox.ShowExceptionMessage(ex); } }
public MainWindow() { ViewModel = new MainWindowViewModel(world); InitializeComponent(); timer.Interval = TimeSpan.FromMilliseconds(20); timer.Tick += logic; timer.Start(); // make my dockpanel focus of this game MainDockPanel.Focus(); world.Width = 2000; world.Height = 1000; var circle = new Circle(400, 200, "circle.png", 20); circle.Width = 40; circle.Height = 40; circle.ZIndex = 2; world.AddObject(circle); var controlledCar = new Models.AutomatedCar(50, 50, "car_1_white.png"); controlledCar.Width = 108; controlledCar.Height = 240; // read the world object polygons, get the one for the car in a primitive way // this is just a sample, the proecssing shold be much more general string json_text = System.IO.File.ReadAllText($"src/AutomatedCar/Assets/worldobject_polygons.json"); dynamic stuff = JObject.Parse(json_text); var geom = new Polyline(); // get the points from the json and add to the polyline foreach (var i in stuff["objects"][0]["polys"][0]["points"]) { geom.Points.Add(new Point(i[0].ToObject <int>(), i[1].ToObject <int>())); } // add polyline to the car controlledCar.Geometry = geom; world.AddObject(controlledCar); world.ControlledCar = controlledCar; controlledCar.Start(); }
private void RestoreAppConfiguration() { if (!File.Exists(AppConfigFile)) { RestoreDefaultConfig(); return; } var fs = new FileStream(AppConfigFile, FileMode.Open, FileAccess.Read); try { MainDockPanel.Restore(fs, m_DeserializeDockContent); } finally { fs.Close(); } }
private void MainFrame_Load(object sender, EventArgs e) { mEngine = new Wrapper.GameEngine(); MainDockPanel.DocumentStyle = DocumentStyle.DockingWindow; if (!File.Exists(LAYOUT_FILE)) { RestoreDefaultLayout(); } else { MainDockPanel.LoadFromXml(LAYOUT_FILE, new DeserializeDockContent(LayoutLoadCallback)); } mEngine.InitializeEngine((int)mViewwindow.Handle); mPropertyWindow.Initialize(); }
private void LoadSubWindowsLayout(Stream stream) { try { if (stream != null) { // 取り込んだウィンドウは一旦デタッチして閉じる fWindowCapture.CloseAll(); foreach (var f in SubForms) { f.Show(MainDockPanel, DockState.Document); f.DockPanel = null; } MainDockPanel.LoadFromXml(stream, new DeserializeDockContent(GetDockContentFromPersistString)); fWindowCapture.AttachAll(); } else { foreach (var f in SubForms) { f.Show(MainDockPanel); } foreach (var x in MainDockPanel.Contents) { x.DockHandler.Hide(); } } } catch (Exception ex) { Utility.ErrorReporter.SendErrorReport(ex, "サブウィンドウ レイアウトの復元に失敗しました。"); } }
private void saveLayoutToolStripMenuItem_Click(object sender, EventArgs e) { MainDockPanel.SaveAsXml(LAYOUT_FILE); }
private void MainForm_Load(object sender, EventArgs e) { try { #region 测试版 #if DEBUG try { var apiHelper = new ApiHelper(); DateTime now = apiHelper.GetDate(DateType.SysDate); if (now > AboutBox.PublishDate.AddMonths(1)) //发布一个月失效 { SplashScreen.CloseSplashScreen(); MsgBox.ShowErrorMessage("该测试版已失效,请下在最新版!"); OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl); Exit_Click(Exit, new EventArgs()); } } catch (WebException) { Config.InitErrorInfo = Config.LocalLanguage.Messages.InitializeFailed + "," + Config.LocalLanguage.Messages.PleaseCheckNetworkSettingsAreCorrect; } #endif #endregion #region _languageLoader = new LanguageLoader(); TimerAutoSwitchingProxy = new Timer(); TimerAutoChangeIcon = new Timer(); //SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDatabase); //Config.InitDatabase(); _deserializeDockContent = GetContentFromPersistString; SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingLanguages); Config.LanguageFileName = Config.LocalSetting.LanguageFileName; if (System.IO.File.Exists(Config.LanguageFileName)) { Config.LocalLanguage = XmlHelper.XmlDeserialize( Config.LanguageFileName, typeof(Language)) as Language; } LoadLanguage(); #endregion #region 初始化配置 GetNetConfigAndCheckVersion(); #endregion #region 连接云引擎 try { DelegateVoid dv = ConnectCloud; var thred = new Thread(new ThreadStart(dv)); thred.Start(); } catch { if (Config.LocalLanguage != null) { CloudStatus.Text = Config.LocalLanguage.Messages.ConnectCloudEngineFailed; } CloudStatus.Image = Resources.cloudno; } #endregion #region Hotkey //Hotkey hotkey = new Hotkey(this.Handle); //Hotkey1 = hotkey.RegisterHotkey(System.Windows.Forms.Keys.T, Hotkey.KeyFlags.MOD_CONTROL); //hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey); #endregion #region UI MainToolbar.Visible = false; MainStatusBar.Items.Insert(2, new ToolStripSeparator()); MainStatusBar.Items.Insert(4, new ToolStripSeparator()); MainStatusBar.Items.Insert(6, new ToolStripSeparator()); MainStatusBar.Items.Insert(8, new ToolStripSeparator()); MainStatusBar.Items.Insert(10, new ToolStripSeparator()); tsslVersion.Text = @"Version:" + Assembly.GetExecutingAssembly().GetName().Version; if (Config.LocalLanguage != null) { CloudStatus.Text = Config.LocalLanguage.Messages.ConnectingCloudEngine; } _httpHelper.HttpOption.Timeout = 60 * 1000; SetProxyStatusLabel(); if (Config.LocalLanguage != null) { AutoSwitchProxyStatus.Text = Config.LocalLanguage.Messages.AutomaticSwitchingOff; } Status.Text = Config.InitErrorInfo; Status.Spring = true; #endregion #region timer TimerAutoSwitchingProxy.Enabled = false; TimerAutoSwitchingProxy.Interval = 1000; TimerAutoSwitchingProxy.Elapsed += timerAutoSwitchingProxy_Elapsed; TimerAutoChangeIcon.Enabled = false; TimerAutoChangeIcon.Interval = 1000; TimerAutoChangeIcon.Elapsed += timerAutoChangeIcon_Elapsed; #endregion #region DockPanel if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDockPanel); if (System.IO.File.Exists(Config.DockSettingFileName)) { try { MainDockPanel.LoadFromXml(Config.DockSettingFileName, _deserializeDockContent); } catch { _hasDockSettingExceptioin = true; if (System.IO.File.Exists(Config.DockSettingFileName)) { SplashScreen.CloseSplashScreen(); System.IO.File.Delete(Config.DockSettingFileName); MsgBox.ShowErrorMessage(Config.LocalLanguage.Messages.InitializeFailed); Application.Exit(); } } } else { #region dock StartPage.Show(MainDockPanel, DockState.Document); InfoPage.Show(MainDockPanel, DockState.DockBottomAutoHide); InfoPage.Hide(); ProxyPage.Show(MainDockPanel, DockState.Document); #endregion } } #endregion #region LoadViewSetting(); if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.CheckUpdate); } CheckVersionAndDownLoad(); #region 读取上次代理 if (System.IO.File.Exists(Config.LastProxyFileName)) { ProxyData.ProxyList = (List <ProxyServer>) XmlHelper.XmlDeserialize(Config.LastProxyFileName, typeof(List <ProxyServer>)); ProxyPage.BindData(); } #endregion if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingPlugins); } PluginManager.LoadAllPlugins(); //如果没有获取代理网页列表,则禁止使用 #if !DEBUG if (Config.ProxySiteUrlList.Count == 0) { this.ProxyPage.Enabled = false; } #endif SplashScreen.CloseSplashScreen(); StartPage.Activate(); Activate(); if (Config.ProxyHeroCloudSetting.EnableCommercialPage == "1") //如果显示弹出广告 { #if !DEBUG if (Config.IsChineseOs) { this.OpenNewTab(Config.ProxyHeroCloudSetting.CommercialUrl); } else { this.OpenNewTab(Config.ProxyHeroCloudSetting.EnglishCommercialUrl); } #else OpenNewTab(Config.IsChineseLanguage ? Config.ProxyHeroCloudSetting.CommercialUrl : Config.ProxyHeroCloudSetting.EnglishCommercialUrl); #endif } #endregion } catch (Exception ex) { SplashScreen.CloseSplashScreen(); MsgBox.ShowExceptionMessage(ex); } }