private void CreateXmlFile(DocumentXML document, string path) { XmlSerializer format = new XmlSerializer(typeof(DocumentXML)); using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)) { format.Serialize(fs, document); } }
public OpenKMAddIn() { // Initialize vars; configXML = new ConfigXML(); docXML = new DocumentXML(); fileUtil = new FileUtil(); // Initialize forms configurationForm = new ConfigurationForm(); }
public ExplorerForm(Object application, String formType, ConfigXML configXML, DocumentXML docXML) { try { resources = new ComponentResourceManager(typeof(ExplorerForm)); this.application = application; this.formType = formType; imageList = new ImageUtil(); this.configXML = configXML; this.documentXML = docXML; // Initialize component InitializeComponent(); // Centering form this.CenterToParent(); // Column translations dataGridView.Columns[0].HeaderText = ""; dataGridView.Columns[1].HeaderText = ""; dataGridView.Columns[2].HeaderText = ""; dataGridView.Columns[3].HeaderText = resources.GetString("name"); dataGridView.Columns[4].HeaderText = resources.GetString("author"); dataGridView.Columns[5].HeaderText = resources.GetString("version"); dataGridView.Columns[6].HeaderText = resources.GetString("date"); // Translations edit.Text = resources.GetString("edit"); cancel.Text = resources.GetString("cancel"); this.Text = resources.GetString("documentexplorer"); // By default edit button is always disabled edit.Enabled = false; // Setting the image list tree.ImageList = imageList.get(); // Grid user properties dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToDeleteRows = false; dataGridView.AllowUserToOrderColumns = false; dataGridView.MultiSelect = false; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; // Adding click handlers tree.NodeMouseClick += new TreeNodeMouseClickEventHandler(nodeMouseClick); dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick); } catch (Exception e) { String errorMsg = "ExplorerForm - (ExplorerForm)\n" + e.Message + "\n\n" + e.StackTrace; MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void CreateXmlFile(DocumentXML document) { System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog(); dialog.Filter = "xml file|*.xml"; dialog.Title = "Сохранить xml файл"; dialog.DefaultExt = "*.xml"; dialog.FileName = DateTime.Now.ToString("D"); dialog.ShowDialog(); if (dialog.FileName != "") { XmlSerializer format = new XmlSerializer(typeof(DocumentXML)); using (FileStream fs = new FileStream(dialog.FileName, FileMode.OpenOrCreate)) { format.Serialize(fs, document); } } }
public static DocumentXML Reasons(this List <IDataObject> source, int personId, Guid id) { var documentXML = new DocumentXML() { Resource = id, FromUser = _repository.GetCurrentPerson().ActualName }; var items = source.Where(x => x.ObjectStateInfo.State == ObjectState.Alive && x.Files.Any()); if (items.Any()) { foreach (var item in items) { documentXML.Documents.Add(item.GetDocument(personId)); } } return(documentXML); }
// Refreshing icons private void refreshIcons(String localFileName) { try { DocumentXML docXML = openkmAddIn.getDocXML(); docXML.refresh(); // Refresh document list if (localFileName != null && ExcelApp.Workbooks.Count > 0) { if (docXML.isOpenKMDocument(localFileName)) { commandBarOption.setAdd(false); commandBarOption.setEdit(false); commandBarOption.setCheckin(true); commandBarOption.setCancelCheckin(true); } else { commandBarOption.setAdd(true); commandBarOption.setEdit(true); commandBarOption.setCheckin(false); commandBarOption.setCancelCheckin(false); } } else { commandBarOption.setAdd(false); commandBarOption.setEdit(true); commandBarOption.setCheckin(false); commandBarOption.setCancelCheckin(false); } // Evaluate add icon if (commandBarOption.isAdd()) { addButton.Image = ImageToolBar.IMG_TOOLBAR_ADD; addRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_ADD; addRibbonButton.Enabled = true; } else { addButton.Image = ImageToolBar.IMG_TOOLBAR_ADD_DISABLED; addRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_ADD_DISABLED; addRibbonButton.Enabled = false; } // Evaluate edit icon if (commandBarOption.isEdit()) { editButton.Image = ImageToolBar.IMG_TOOLBAR_EDIT; editRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_EDIT; editRibbonButton.Enabled = true; } else { editButton.Image = ImageToolBar.IMG_TOOLBAR_EDIT_DISABLED; editRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_EDIT_DISABLED; editRibbonButton.Enabled = false; } // Evaluate checkin icon if (commandBarOption.isCheckin()) { checkinButton.Image = ImageToolBar.IMG_TOOLBAR_CHECKIN; checkinRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_CHECKIN; checkinRibbonButton.Enabled = true; } else { checkinButton.Image = ImageToolBar.IMG_TOOLBAR_CHECKIN_DISABLED; checkinRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_CHECKIN_DISABLED; checkinRibbonButton.Enabled = false; } // Evaluate cancelcheckin icon if (commandBarOption.isCancelCheckin()) { cancelCheckoutButton.Image = ImageToolBar.IMG_TOOLBAR_CANCELCHECKOUT; cancelCheckoutRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_CANCELCHECKOUT; cancelCheckoutRibbonButton.Enabled = true; } else { cancelCheckoutButton.Image = ImageToolBar.IMG_TOOLBAR_CANCELCHECKOUT_DISABLED; cancelCheckoutRibbonButton.Image = ImageToolBar.IMG_TOOLBAR_CANCELCHECKOUT_DISABLED; cancelCheckoutRibbonButton.Enabled = false; } } catch (COMException) { // Not trowed } catch (Exception e) { throw e; } }