private void Save(bool isSaveAs) { //TEMP: only launcher tab is available return; if (currentConfig.Validate()) { try { string currentFileName = RegistrySaver.ReadStringFromRegistry(RegistrySaver.configName); if (!isSaveAs && File.Exists(currentFileName)) { File.WriteAllText(currentFileName, currentConfig.CreateConfig()); } else { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = configFileExtention; if (saveFileDialog.ShowDialog() == true) { currentFileName = saveFileDialog.FileName; currentConfig.name = Path.GetFileNameWithoutExtension(currentFileName); RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName); RegistrySaver.AddRegistryValue(RegistrySaver.configName, currentFileName); File.WriteAllText(currentFileName, currentConfig.CreateConfig()); } } SetTitle(); AppLogger.Add("Config saved to " + currentFileName); } catch (Exception exception) { InfoDialog errorDialog = new InfoDialog("Error! \nCan not save configuration file. \nSee exception message in Log"); errorDialog.Owner = this; errorDialog.Width = 350; errorDialog.Height = 200; errorDialog.Show(); AppLogger.Add("ERROR! Can not save config to file. EXCEPTION: " + exception.Message); } } else { InfoDialog errorDialog = new InfoDialog("Error! \nCan not save configuration file. \nWrong config. See errors in Log"); errorDialog.Owner = this; errorDialog.Width = 350; errorDialog.Height = 200; errorDialog.Show(); AppLogger.Add("ERROR! Can not save config to file. Errors in configuration"); } }
private void CopyItem(SceneNodeView _sourceItem, SceneNodeView _targetItem) { //Alert if node sets as child of it's own child node if (_targetItem != null && _sourceItem.FindNodeInChildren(_targetItem) != null) { InfoDialog alertDialog = new InfoDialog("Scene node can not be a child node of own children!"); alertDialog.Owner = this; alertDialog.Show(); } else { //Asking user wether he want to drop the dragged TreeViewItem here or not YesNoDialog dialogResult = new YesNoDialog("Would you like to drop " + _sourceItem.node.id + " into " + _targetItem.node.id + ""); dialogResult.Owner = this; if ((bool)dialogResult.ShowDialog()) { try { //finding Parent TreeViewItem of dragged TreeViewItem SceneNodeView ParentItem = currentConfig.FindParentNode(_sourceItem); if (ParentItem == null) { ((List <SceneNodeView>)sceneNodesTreeView.ItemsSource).Remove(_sourceItem); } else { ParentItem.children.Remove(_sourceItem); } //adding dragged TreeViewItem in target TreeViewItem if (_targetItem == null) { ((List <SceneNodeView>)sceneNodesTreeView.ItemsSource).Add(_sourceItem); _sourceItem.node.parent = null; } else { _targetItem.children.Add(_sourceItem); _sourceItem.node.parent = _targetItem.node; } //Set SceneNode of _targetItem as parent node for _sourceItem Scene Node } catch { } sceneNodesTreeView.Items.Refresh(); } } }