public App() { var w = new ProjectWindow(); w.DataContext = new ProjectViewModel(new Project("Test project", "D:/Test project")); w.Show(); }
static void Init() { ProjectWindow window = (ProjectWindow)EditorWindow.GetWindow(typeof(ProjectWindow)); window.title = "BuildConfig"; window.autoRepaintOnSceneChange = true; window.InitProjects(); window.Show(); }
public static bool Open(Widget parent) { var file = string.Empty; if (!IsUnix) { using (var openDialog = new OpenFileDialog()) { // check file exists openDialog.CheckFileExists = true; // If the previously browsed directory exists, then direct the user to it, otherwise direct to home directory. openDialog.InitialDirectory = Directory.Exists(Settings.Default.PreviousBrowseFolder) ? Settings.Default.PreviousBrowseFolder : Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); // Set the filter to show only 'prf' files openDialog.Filter = "Projects file (*.prj)|*.prj|Lock file (*.prj.lk) |*.prj.lk|All Files (*.*)|*.*"; openDialog.FilterIndex = 1; //RestoreDirectory = true, openDialog.ShowReadOnly = false; openDialog.ShowDialog(); file = openDialog.FileName; openDialog.Reset(); } } else { using (var openDialog = new FileChooserDialog("Open File", parent as Window, FileChooserAction.Open)) { openDialog.AddButton("Open", ResponseType.Ok); openDialog.AddButton("Cancel", ResponseType.Close); SetCurrentFolder(Directory.Exists(Settings.Default.PreviousBrowseFolder) ? Settings.Default.PreviousBrowseFolder : Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), openDialog.Handle); using (var openFilter = new FileFilter()) { openFilter.Name = "Projects File"; openFilter.AddMimeType("Projects File"); openFilter.AddPattern("*.prj"); openDialog.AddFilter(openFilter); } using (var openFilter = new FileFilter()) { openFilter.Name = "Projects Lock File"; openFilter.AddMimeType("Projects Lock File"); openFilter.AddPattern("*.prj.lk"); openDialog.AddFilter(openFilter); } using (var openFilter = new FileFilter()) { openFilter.Name = "All files"; openFilter.AddMimeType("All"); openFilter.AddPattern("*.*"); openDialog.AddFilter(openFilter); } if (openDialog.Run() == (int)ResponseType.Ok) { file = openDialog.File.ParsedName; } openDialog.Destroy(); } } // if no file has been provided / the file does not exist - do not continue if (string.IsNullOrEmpty(file) || !File.Exists(file)) { return(false); } //Console.WriteLine(Path.GetExtension(file)); // ensure that the correct file extension is being used if (Path.GetExtension(file) != ".prj") { using (var md = new MessageDialog(parent as Window, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "The selected file is not recognized by Projects.")) { md.Run(); md.Destroy(); } return(false); } // get the path from the selected file, by finding the last occurrence of a directory separator and save it into // the "PreviousBrowseFolder" Setting Settings.Default.PreviousBrowseFolder = file.Substring(0, file.LastIndexOf(Path.DirectorySeparatorChar)); // save settings Settings.Default.Save(); if (File.Exists(file + ".lk")) { using ( var dialog = new MessageDialog(parent as Window, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, $"The file is currently in use. If you're sure that this isn't the case, please delete the following file:\n {file}.lk") ) { dialog.Run(); dialog.Destroy(); } return(false); } var window = new ProjectWindow(file); window.Show(); parent.Destroy(); return(true); }
public void ShowCmdWindow(string cmd, int lscId, string projId) { try { WLscsComboBox.Disabled = false; ProjectIdField.Disabled = false; ProjectIdField.Clear(); ProjNameField.Clear(); StartTimeField.Clear(); EndTimeField.Clear(); ResponsibleField.Clear(); PhoneField.Clear(); CompanyField.Clear(); CommentField.Clear(); EnabledCheckbox.Checked = true; TipsStatusBar.ClearStatus(); switch (cmd) { case "Add": ProjectWindow.Title = "新增工程"; ProjectWindow.Icon = Icon.TagBlueAdd; WLscsComboBox.GetStore().DataBind(); ProjectIdField.Text = Guid.NewGuid().ToString("D").ToUpper(); StartTimeField.Text = WebUtility.GetDateString(DateTime.Today); EndTimeField.Text = WebUtility.GetDateString(DateTime.Today.AddMonths(1).AddSeconds(-1)); OperationWindowHF.Text = "Add"; ProjectWindow.Show(); break; case "Edit": ProjectWindow.Title = "编辑工程"; ProjectWindow.Icon = Icon.TagBlueEdit; WLscsComboBox.Disabled = true; ProjectIdField.Disabled = true; OperationWindowHF.Text = "Edit"; var lsc = new BLsc().GetLsc(lscId); if (lsc == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取Lsc信息"); return; } var connectionString = WebUtility.CreateLscConnectionString(lsc); var project = new BAppointment().GetProject(lsc.LscID, lsc.LscName, projId, connectionString); if (project == null) { WebUtility.ShowMessage(EnmErrType.Warning, "无法获取工程信息"); return; } WLscsComboBox.SetValueAndFireSelect(lsc.LscID); ProjectIdField.Text = project.ProjectId; ProjNameField.Text = project.ProjectName; StartTimeField.Text = WebUtility.GetDateString(project.BeginTime); EndTimeField.Text = WebUtility.GetDateString(project.EndTime); ResponsibleField.Text = project.Responsible; PhoneField.Text = project.ContactPhone; CompanyField.Text = project.Company; CommentField.Text = project.Comment; EnabledCheckbox.Checked = project.Enabled; ProjectWindow.Show(); break; case "Del": X.Msg.Confirm("确认对话框", "您确定要删除吗?", new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { Handler = String.Format(@" X.ProjectManager.Delete({0},'{1}',{{ success: function(result) {{ MainGridPagingToolbar.doRefresh(); }}, eventMask: {{ showMask: true, target: 'customtarget', msg: '正在删除中...', customTarget: MainGridPanel.body.up('div') }}}});", lscId, projId), Text = "确定" }, No = new MessageBoxButtonConfig { Text = "取消" } }).Show(); break; default: break; } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }