public bool PromptModified() { if (!SolutionCollection.Modified) { return(true); } MessageBoxResult result = MessageBox.Show( R.modifiedPrompt, R.appTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.No); // ReSharper disable once SwitchStatementMissingSomeCases switch (result) { case MessageBoxResult.Cancel: return(false); case MessageBoxResult.Yes: return(SolutionCollection.Save()); case MessageBoxResult.No: return(true); default: throw new ArgumentOutOfRangeException(); } }
private void OnOpenCollection(object obj) { if (!PromptModified()) { return; } string filename = obj as string; SolutionCollection.OpenExisting(ref filename); AddRecentFile(filename); }
private void OnNewCollection(object obj) { if (!PromptModified()) { return; } if (SolutionCollection.Filename != null) { SolutionCollection.CreateNew(); } }
private void OnAddSolution(object obj) { VistaOpenFileDialog ofd = new VistaOpenFileDialog(); ofd.AddFilter("sln"); bool?result = ofd.ShowDialog(_mainWindow); if (!result.HasValue || !result.Value) { return; } Solution solution = Solution.OpenSolution(ofd.FileName); SolutionCollection.AddSolution(solution); }
public MainViewModel() { _output = new Output(); _dispatcher = Dispatcher.CurrentDispatcher; _solutions = new SolutionCollection(); _solutions.LoadFrom(AppDomain.CurrentDomain.BaseDirectory); _solutions.Sort(); BuildCommand = new Command(Build); RebuildCommand = new Command(Rebuild); CleanCommand = new Command(Clean); StopCommand = new Command(Stop); StopCommand.Disable(); ShowHideConsoleCommand = new Command(ShowHideConsole); CurrentConfiguration = Configuration.Debug; Configurations = new[] { Configuration.Debug, Configuration.Release }; _requestStopOperation = false; }
public MainWindowViewModel() { InitCommands(); SolutionCollection.CreateNew(); SolutionCollection.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(SolutionCollection.Modified)) { OnPropertyChanged(nameof(Title)); } if (args.PropertyName == nameof(SolutionCollection.Title)) { OnPropertyChanged(nameof(Title)); } }; if (Settings.Default.MRU == null) { Settings.Default.MRU = new StringCollection(); } }
private void buttonOK_Click(object sender, EventArgs e) { SolutionCollection solutions = new SolutionCollection(); for (int i = 0; i < dataGridViewSolution.Rows.Count; i++) { if (!dataGridViewSolution.Rows[i].IsNewRow) { DataGridViewRow row = dataGridViewSolution.Rows[i]; string name = (string)GetCellValue("ColumnName", row); string text = (string)GetCellValue("ColumnText", row); string ip = (string)GetCellValue("ColumnIP", row); int port = (int)GetCellValue("ColumnPort", row); if (name != null && text != null && ip != null) { string logindatabase = (string)row.Cells["ColumnLoginDataBase"].FormattedValue; string loginsolution = (string)row.Cells["ColumnLoginSolution"].FormattedValue; Solution.LanguageType language = (Solution.LanguageType)Enum.Parse(typeof(Solution.LanguageType), (string)row.Cells["ColumnLanguage"].FormattedValue); Solution sol = new Solution(name, text, ip,port, 8989, logindatabase, loginsolution, language); solutions.Add(sol); } else { DialogResult = DialogResult.None; return; } } } XmlDocument xml = solutions.Save(); try { xml.Save(string.Format("{0}\\{1}", Application.StartupPath, Config.SolutionFile)); } catch { MessageBox.Show(this, "Can not save solution.xml, check it's property not readonly","Error" , MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; } }
public MainViewModel() { _output = new Output(); _dispatcher = Dispatcher.CurrentDispatcher; _solutions = new SolutionCollection(); _solutions.LoadFrom(AppDomain.CurrentDomain.BaseDirectory); _solutions.Sort(); BuildCommand = new Command(Build); RebuildCommand = new Command(Rebuild); CleanCommand = new Command(Clean); StopCommand = new Command(Stop); StopCommand.Disable(); ShowHideConsoleCommand = new Command(ShowHideConsole); CurrentConfiguration = Configuration.Debug; Configurations = new[] { Configuration.Debug, Configuration.Release }; _requestStopOperation = false; _avalableBuilders = new ObservableCollection <string>(); Task.Factory.StartNew(() => { Builders = BuilderLocator.GetAvailableBuilders(); CurrentBuilder = Builders.FirstOrDefault(); }); }
public void RefreshTreeView() { if (!this.Disposing) { XmlDocument xml = new XmlDocument(); try { xml.Load(Config.SolutionFile); if (treeViewSolution.InvokeRequired) { //SolutionCollection solutions = new SolutionCollection(xml, ""); //RefreshMethod call = delegate() //{ // treeViewSolution.Nodes[0].Nodes.Clear(); // for (int i = 0; i < solutions.Count; i++) // { // TreeNode node = treeViewSolution.Nodes[0].Nodes.Add(solutions[i].Name, solutions[i].Text, "solution", "solution"); // node.Tag = solutions[i]; // node.ToolTipText = string.Format("{0}:{1}", solutions[i].IP, solutions[i].Port); // } // treeViewSolution.ExpandAll(); //}; //RefreshMethod call = delegate() RefreshMethod call = delegate() { treeViewSolution.Nodes.Clear(); XmlNode SolutionNode = null; foreach (XmlNode aNode in xml.ChildNodes) if (aNode.Name.CompareTo("Solutions") == 0) { SolutionNode = aNode; break; } foreach (XmlNode GroupXmlNode in SolutionNode) { TreeNode GroupTreeNode = treeViewSolution.Nodes.Add(GroupXmlNode.Attributes["Text"].Value); foreach (XmlNode DeptXmlNode in GroupXmlNode.ChildNodes) { TreeNode DeptTreeNode = GroupTreeNode.Nodes.Add(DeptXmlNode.Attributes["Text"].Value); SolutionCollection solutions = new SolutionCollection(xml, String.Format("Solutions/{0}/{1}/Solution", GroupXmlNode.Name, DeptXmlNode.Name)); for (int i = 0; i < solutions.Count; i++) { TreeNode node = DeptTreeNode.Nodes.Add(solutions[i].Name, solutions[i].Text, "solution", "solution"); node.Tag = solutions[i]; node.ToolTipText = string.Format("{0}:{1}", solutions[i].IP, solutions[i].Port); } } } treeViewSolution.ExpandAll(); }; treeViewSolution.Invoke(call, null); } else { treeViewSolution.Nodes.Clear(); XmlNode SolutionNode = null; foreach (XmlNode aNode in xml.ChildNodes) if (aNode.Name.CompareTo("Solutions") == 0) { SolutionNode = aNode; break; } foreach (XmlNode GroupXmlNode in SolutionNode) { TreeNode GroupTreeNode = treeViewSolution.Nodes.Add(GroupXmlNode.Attributes["Text"].Value); foreach (XmlNode DeptXmlNode in GroupXmlNode.ChildNodes) { TreeNode DeptTreeNode = GroupTreeNode.Nodes.Add(DeptXmlNode.Attributes["Text"].Value); SolutionCollection solutions = new SolutionCollection(xml, String.Format("Solutions/{0}/{1}/Solution", GroupXmlNode.Name, DeptXmlNode.Name)); for (int i = 0; i < solutions.Count; i++) { TreeNode node = DeptTreeNode.Nodes.Add(solutions[i].Name, solutions[i].Text, "solution", "solution"); node.Tag = solutions[i]; node.ToolTipText = string.Format("{0}:{1}", solutions[i].IP, solutions[i].Port); } } } treeViewSolution.ExpandAll(); } } catch { //MessageBox.Show("RefreshTreeView=" + E.Message); } } }
private void OnSaveCollection(object obj) { SolutionCollection.Save(); }
private void frmSolution_Load(object sender, EventArgs e) { XmlDocument xml = new XmlDocument(); try { xml.Load(Config.SolutionFile); SolutionCollection solutions = new SolutionCollection(xml, "Solutions"); if(solutions.Count > 0) { dataGridViewSolution.Rows.Add(solutions.Count); for (int i = 0; i < solutions.Count; i++) { Solution sol = solutions[i]; dataGridViewSolution.Rows[i].Cells["ColumnName"].Value = sol.Name; dataGridViewSolution.Rows[i].Cells["ColumnText"].Value = sol.Text; dataGridViewSolution.Rows[i].Cells["ColumnIP"].Value = sol.IP; dataGridViewSolution.Rows[i].Cells["ColumnPort"].Value = sol.Port; dataGridViewSolution.Rows[i].Cells["ColumnLoginDataBase"].Value = sol.LoginDataBase; dataGridViewSolution.Rows[i].Cells["ColumnLoginSolution"].Value = sol.LoginSolution; dataGridViewSolution.Rows[i].Cells["ColumnLanguage"].Value = sol.Language.ToString(); } } } catch { } }