public void LoadLocators() { this.cmbLocators.Items.Clear(); ISecureContext secureContext = _context as ISecureContext; if (secureContext.YutaiProject == null) { return; } XmlPlugin plugCfg = secureContext.YutaiProject.FindPlugin("2b81c89a-ee45-4276-9dc1-72bbbf07f53f"); if (plugCfg == null) { return; } //修改为从配置文件里面读取 string locatorXml = FileHelper.GetFullPath(plugCfg.ConfigXML); FileInfo fileInfo = new FileInfo(locatorXml); if (!fileInfo.Exists) { return; } using (var reader = new StreamReader(locatorXml)) { string state = reader.ReadToEnd(); var config = state.Deserialize <PluginConfig>(); _locators = config.Locators; foreach (XmlLocator locator in config.Locators) { this.cmbLocators.Items.Add(locator.Name); } _map = _context.MapControl.ActiveView as IMap; } }
public override void OnClick(object sender, EventArgs args) { if (_plugin.DataCheckConfig == null) { Guid dllGuid = new Guid("c58d568b-9dee-4a35-b29b-dad2c92f0188"); XmlPlugin plugin = ((ISecureContext)_context).YutaiProject.Plugins.FirstOrDefault(c => c.Guid == dllGuid); if (plugin != null) { if (string.IsNullOrWhiteSpace(plugin.ConfigXML)) { _plugin.DataCheckConfig = new FrmDataCheckConfig(null); } else { _plugin.DataCheckConfig = new FrmDataCheckConfig(FileHelper.GetFullPath(plugin.ConfigXML)); } } else { _plugin.DataCheckConfig = new FrmDataCheckConfig(null); } } _plugin.DataCheckConfig.ShowDialog(); }
private void InitMenu() { XmlDocument doc = new XmlDocument(); //检测项目文档里面是否有插件的界面配置,如果没有,则使用默认配置,如果有,则使用配置文件里面的配置 Guid dllGuid = new Guid("f9bff4cd-5840-48c1-9a7b-2385c554d95b"); XmlPlugin plugin = ((ISecureContext)_context).YutaiProject.Plugins.FirstOrDefault(c => c.Guid == dllGuid); if (plugin != null) { if (string.IsNullOrEmpty(plugin.MenuXML)) { doc.Load(base.GetType().Assembly.GetManifestResourceStream("Yutai.Test.Menu.MenuLayout.xml")); } else { FileInfo info = new FileInfo(FileHelper.GetFullPath(plugin.MenuXML)); if (info.Exists) { doc.Load(FileHelper.GetFullPath(plugin.MenuXML)); } else { doc.Load(base.GetType().Assembly.GetManifestResourceStream("Yutai.Test.Menu.MenuLayout.xml")); } } } else { doc.Load(base.GetType().Assembly.GetManifestResourceStream("Yutai.Test.Menu.MenuLayout.xml")); } RibbonFactory.CreateMenus(_commands.GetCommands(), (RibbonControl)_menuManager, _context.MainView.RibbonStatusBar as RibbonStatusBar, doc); }
public void SignDocument() { var xsdUri = @"https://github.com/Daetrax/sipvs/blob/master/Xml_data/sipvt.xsd"; var xsdNSUri = @"https://github.com/Daetrax/sipvs/blob/master/Xml_data/sipvt"; var xslUri = @"https://github.com/Daetrax/sipvs/blob/master/Xml_data/sipvt.xsl"; string schemaString = File.ReadAllText(@"../../../../Xml_data/sipvt.xsd"); string transformString = File.ReadAllText(@"../../../../Xml_data/sipvt.xsl"); // this implementation uses file explorer to locate xml file to sign XmlDocument doc = new XmlDocument(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); openFileDialog.Filter = "xml files (*.xml)|*.xml"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; // Process open file dialog box results if (openFileDialog.ShowDialog() == true) { // Open document doc.Load(openFileDialog.FileName); } else { return; } var signer = new XadesSig(); // first we need to create object to be signed var objectToSign = new XmlPlugin().CreateObject2("objectId", "Objednanie knih", doc.InnerXml, schemaString, xsdNSUri, xsdUri, transformString, xslUri, "HTML"); // we can add multiple objects to sign signer.AddObject(objectToSign); // certificates can be changed, check documentation of xades if (signer.Sign("signatureId10", "sha256", "urn:oid:1.3.158.36061701.1.2.2") == 0) { Console.WriteLine(signer.SignedXmlWithEnvelope); File.WriteAllText($"{System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}/signedDocument.xml", signer.SignedXmlWithEnvelope); } else { Console.WriteLine(signer.ErrorMessage); MessageBox.Show($"Error occurred during signing {Environment.NewLine}{signer.ErrorMessage}", "", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public override void Initialize(IAppContext context) { _context = context; _menuGenerator = context.Container.GetInstance <MenuGenerator>(); ISecureContext secureContext = context as ISecureContext; if (secureContext.YutaiProject != null) { XmlPlugin xmlPlugin = secureContext.YutaiProject.FindPlugin("2fd39cff-e0d7-44cb-a6f7-b5e90499124c"); if (xmlPlugin != null) { string fileName = xmlPlugin.ConfigXML; //if (string.IsNullOrEmpty(fileName)) //{ // _printConfig.TemplateConnectionString = BuildDefaultConnectionString(); //} //else //{ // fileName = FileHelper.GetFullPath(fileName); // _printConfig.LoadFromXml(fileName); //} } } //if (string.IsNullOrEmpty(_printConfig.TemplateConnectionString)) //{ // _printConfig.TemplateConnectionString = BuildDefaultConnectionString(); //} //_templateGallery =new MapTemplateGallery(); //_templateGallery.SetWorkspace(_printConfig.TemplateConnectionString); //_menuListener = context.Container.GetInstance<MenuListener>(); //_mapListener = context.Container.GetInstance<MapListener>(); //_dockPanelService = context.Container.GetInstance<TemplateDockPanelService>(); //获取配置对象 // _pipelineConfig = context.Container.GetSingleton<PipelineConfig>(); //if (string.IsNullOrEmpty(_pipelineConfig.XmlFile)) //{ // string fileName = ((ISecureContext) _context).YutaiProject.FindPlugin("4a3bcaab-9d3e-4ca7-a19d-7ee08fb0629e").ConfigXML; // if (string.IsNullOrEmpty(fileName)) return; // //fileName = FileHelper.GetFullPath(fileName); // //_pipelineConfig.LoadFromXml(fileName); //} }
public override void Initialize(IAppContext context) { _context = context; _menuGenerator = context.Container.GetInstance <MenuGenerator>(); ISecureContext secureContext = context as ISecureContext; _drawFence = true; _isDeign = false; _isLayout = false; if (secureContext.YutaiProject != null) { XmlPlugin xmlPlugin = secureContext.YutaiProject.FindPlugin("5e933989-b5a4-4a45-a5b7-2d9ded61df0f"); if (xmlPlugin != null) { string fileName = xmlPlugin.ConfigXML; if (string.IsNullOrEmpty(fileName)) { _printConfig.TemplateConnectionString = BuildDefaultConnectionString(); } else { fileName = FileHelper.GetFullPath(fileName); _printConfig.LoadFromXml(fileName); } } } if (string.IsNullOrEmpty(_printConfig.TemplateConnectionString)) { _printConfig.TemplateConnectionString = BuildDefaultConnectionString(); } _templateGallery = new MapTemplateGallery(); _templateGallery.SetWorkspace(_printConfig.TemplateConnectionString); ((IAppContextEvents)_context).OnActiveHookChanged += OnOnActiveHookChanged; _activeViewEvents = ((IActiveViewEvents_Event)_context.FocusMap); _activeViewEvents.AfterDraw += ActiveViewEventsOnAfterDraw; if (_fillSymbol == null) { _fillSymbol = SymbolHelper.CreateTransparentFillSymbol(Color.Blue) as ISymbol; _lineSymbol = SymbolHelper.CreateSimpleLineSymbol(Color.Blue, 1.5) as ISymbol; } }
private void InitMenus() { XmlDocument doc = new XmlDocument(); //检测项目文档里面是否有插件的界面配置,如果没有,则使用默认配置,如果有,则使用配置文件里面的配置 Guid dllGuid = new Guid("5e933989-b5a4-4a45-a5b7-2d9ded61df0f"); string resString = "Yutai.Plugins.Template.Menu.MenuLayout.xml"; XmlPlugin plugin = ((ISecureContext)_context).YutaiProject?.Plugins.FirstOrDefault( c => c.Guid == dllGuid); if (plugin != null) { if (string.IsNullOrEmpty(plugin.MenuXML)) { doc.Load(base.GetType().Assembly.GetManifestResourceStream(resString)); } else { FileInfo info = new FileInfo(FileHelper.GetFullPath(plugin.MenuXML)); if (info.Exists) { doc.Load(FileHelper.GetFullPath(plugin.MenuXML)); } else { doc.Load(base.GetType().Assembly.GetManifestResourceStream(resString)); } } } else { doc.Load(base.GetType().Assembly.GetManifestResourceStream(resString)); } RibbonFactory.CreateMenus(_commands.GetCommands(), (RibbonControl)_menuManager, _context.MainView.RibbonStatusBar as RibbonStatusBar, doc); }
public static void saveConfig(XmlPlugin[] Plugin) { string filename = @".\plugins.config.xml"; XmlTricksterRoot XmlRoot = new XmlTricksterRoot(); XmlTools Tools = new XmlTools(); Tools.Plugin = Plugin; XmlRoot.Tools = Tools; string filepath = ""; if (Path.IsPathRooted(filename)) { filepath = filename; filename = Path.GetFileName(filename); } else { filepath = Path.GetFullPath(Environment.CurrentDirectory + @"\" + filename); } if (!File.Exists(filepath)) { // �t�@�C�����Ȃ���쐬 FileStream fs = new FileStream(filepath, FileMode.Create); fs.Close(); } try { XmlSerializer serializer = new XmlSerializer(typeof(XmlTricksterRoot)); FileStream fs = new FileStream(filepath, FileMode.Create); serializer.Serialize(fs, XmlRoot); fs.Close(); } catch (System.Security.SecurityException se) { SimpleLogger.WriteLine(se.Message); //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�Z�L�����e�B�G���[�ł��B", "SecurityException error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw se; } catch (System.IO.IOException ioe) { SimpleLogger.WriteLine(ioe.Message); //MessageBox.Show("��O�G���[:" + Environment.NewLine + "���o�͎��ɃG���[���������܂����B", "IOException error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw ioe; } catch (System.Xml.XmlException xe) { SimpleLogger.WriteLine(xe.Message); //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�ݒ�ǂݍ��݃G���[", "XmlException error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw xe; } catch (System.Exception e) { SimpleLogger.WriteLine(e.Message); //MessageBox.Show("��O�G���[:" + Environment.NewLine + "�����̓��肪�ł��܂���ł����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw e; } }