//Изменяет текущий тип ссылки public void GetLinkType(string linkType) { if (linkType.IsEmpty() || CurLinkType == linkType) { return; } var f = (FormPutLinks)Forms[ReporterCommand.PutLinks]; var p = Forms.ContainsKey(ReporterCommand.LinkProperties) ? ((FormLinkProperties)Forms[ReporterCommand.LinkProperties]).PropsPanel : null; if (p != null) { string s = p.PropsString(); if (p.LinkPropsError.IsEmpty()) { SysPage.PutValue(CurLinkType, s); } } CurLinkType = linkType; CurLinkProps = SysPage.GetValue(linkType); if (f.CellLinkType.Text != CurLinkType) { f.CellLinkType.Text = CurLinkType; } if (p != null && p.CellLinkType.Text != CurLinkType) { //p.PropsFromDic(CurLinkProps.ToPropertyDictionary()); p.CellLinkType.Text = CurLinkType; } }
protected override void ViewProcent(double procent) { Form f = null; ProgressBar ind = null; if (Forms.ContainsKey(ReporterCommand.Report)) { f = Forms[ReporterCommand.Report]; ind = ((FormReport)f).progressReport; } if (Forms.ContainsKey(ReporterCommand.Intervals)) { f = Forms[ReporterCommand.Intervals]; ind = ((FormIntervals)f).progressReport; } if (f != null) { ind.Invoke(new StatusDelegate(() => { ind.Value = Convert.ToInt32(Convert.ToInt32(procent)); ind.Refresh(); f.Refresh(); })); } }
private void ConfigsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { SelectedProcessFile = ConfigsListBox.SelectedItem as ProcessConfigurationFile; ExtraCriteriaPanel.Children.Clear(); ProcessOperationsPanel.Children.Clear(); if (SelectedProcessFile == null) { ProcessNameTextBox.Text = null; MatchPropertyTextBox.Text = null; MatchValueTextBox.Text = null; PriorityTextBox.Text = null; ExtraCriteriaPanel.Children.Clear(); CreateCopyPanel.Visibility = Visibility.Collapsed; ShowUpdatedPreviewImage(); DisableEditing(); return; } ProcessNameTextBox.Text = SelectedProcessFile.Id; MatchPropertyTextBox.Text = SelectedProcessFile.MatchProperty; MatchValueTextBox.Text = SelectedProcessFile.MatchValue; PriorityTextBox.Text = SelectedProcessFile.Priority.ToString(); if (SelectedProcessFile.ExtraMatchCriteria != null) { foreach (var extraRule in SelectedProcessFile.ExtraMatchCriteria) { AddRuleToPanel(new MatchCriterionForm(extraRule)); } } foreach (var step in SelectedProcessFile.Steps) { if (Forms.ContainsKey(step.Id)) { var control = Forms[step.Id].Build(step.Parameters); ProcessOperationsPanel.Children.Add(control); RegisterSubFormsEvents(control); } } CreateCopyPanel.Visibility = Visibility.Visible; ShowUpdatedPreviewImage(); EnableEditing(); }
//Вызывается при закрытии заданной формы form, close - закрывать форму прямо здесь в процедуре public void CloseForm(ReporterCommand form, bool close = false) { if (Forms.ContainsKey(form)) { var fform = Forms[form]; Forms.Remove(form); var list = (from f in Forms where f.Key.IsChildOf(form) select f.Key).ToList(); foreach (var ff in list) { CloseForm(ff, true); } using (StartAtom("Закрытие формы " + form)) { try { if (close) { fform.Close(); } switch (form) { case ReporterCommand.PutLinks: UpdateDataFile(false, true); Workbook.Save(); break; case ReporterCommand.Setup: SysPage.PutValue("LastSetup", DateTime.Now.ToString()); Workbook.Save(); UpdateDataFile(true); LoadSetup(); break; case ReporterCommand.AbsoluteEdit: AddEvent("Запись абсолютных значений в архив"); foreach (var project in UsedProjects.Values) { project.Archive.WriteAbsoluteEdit(project.AbsoluteEditValues.Values.Where(hip => !hip.Value.IsEmpty()).ToList()); } break; } } catch (Exception ex) { AddError("Ошибка при закрытии формы", ex, form.ToString()); } } } }
public Form GetForm(string name) { if (!Forms.ContainsKey(name)) { Invoke(() => GetForm(name)); if (!Main.InvokeRequired) { CreateForm(name); } } var ans = Forms[name]; return(ans); }
//Загружает свойства из выделенной ячейки public void GetLinkProps(Dictionary <string, string> props) { var f = (FormPutLinks)Forms[ReporterCommand.PutLinks]; var p = Forms.ContainsKey(ReporterCommand.LinkProperties) ? ((FormLinkProperties)Forms[ReporterCommand.LinkProperties]).PropsPanel : null; var dic = props.Where(t => t.Key != "Project" && t.Key != "Code" && t.Key != "Field" && t.Key != "CellComment").ToDictionary(t => t.Key, t => t.Value); string lt = dic["LinkType"].ToLinkType().ToRussian(); if (CurLinkType != lt) { string s = CurLinkProps; if (p != null) { string ss = p.PropsString(); if (p.LinkPropsError.IsEmpty()) { s = ss; } } SysPage.PutValue(CurLinkType, s); CurLinkType = lt; } CurLinkProps = dic.ToPropertyString(); if (f.CellLinkType.Text != CurLinkType) { f.CellLinkType.Text = CurLinkType; } if (f.CellComment.Text != dic.Get("CellComment")) { f.CellComment.Text = dic.Get("CellComment"); } if (p != null) { if (p.CellLinkType.Text != CurLinkType) { p.CellLinkType.Text = CurLinkType; } p.PropsFromDic(dic); } }
//Открывает новую заданную форму public Form RunCommandReporter(ReporterCommand c) { if (Forms.ContainsKey(c) && Forms[c] != null) { var fm = Forms[c]; if (!fm.Visible) { fm.Show(); } if (fm.WindowState == FormWindowState.Minimized) { fm.WindowState = FormWindowState.Normal; } fm.Focus(); return(fm); } if (!c.OneForAllBooks() && IsReportForming) { return(null); } if (c.NeedCheckReport() && !SysPage.IsInfoTask()) { MessageReportError("Да запуска команды необходимо открыть отчет InfoTask"); return(null); } Form f = null; using (StartAtom(c)) { try { AddEvent("Закрытие лишних форм"); var less = new Dictionary <ReporterCommand, Form>(); var great = new Dictionary <ReporterCommand, Form>(); foreach (var k in Forms) { if (c.Greater(k.Key)) { less.Add(k.Key, k.Value); } if (c.Less(k.Key)) { great.Add(k.Key, k.Value); } } var cForms = GeneralRep.CommonBook.Forms; foreach (var k in cForms) { if (c.Less(k.Key)) { great.Add(k.Key, k.Value); } } if (great.Count > 0) { string smess = ""; foreach (var g in great) { smess += (smess != "" ? "," : "") + " Форма " + g.Key.ToFormName(); } smess = "Команда не может быть выполнена, пока открыты:" + smess + ". Закрыть формы?"; if (!MessageReportQuestion(smess)) { return(null); } } foreach (var k in less) { k.Value.Close(); if (Forms.ContainsKey(k.Key)) { Forms.Remove(k.Key); } if (cForms.ContainsKey(k.Key)) { cForms.Remove(k.Key); } } foreach (var k in great) { GeneralRep.CloseForm(k.Key, true); } if (c == ReporterCommand.PutLinks || c == ReporterCommand.ShapeLibrary || c == ReporterCommand.Report || c == ReporterCommand.LiveReport || c == ReporterCommand.Intervals || c == ReporterCommand.AbsoluteEdit || c == ReporterCommand.LinksList) { UpdateDataFile(false); } System.Windows.Forms.Application.EnableVisualStyles(); switch (c) { case ReporterCommand.GroupReports: f = new FormGroupReports(); break; case ReporterCommand.GroupReportEdit: f = new FormGroupReportEdit(); break; case ReporterCommand.Create: f = new FormCreate(); break; case ReporterCommand.Setup: f = new FormSetup(); break; case ReporterCommand.CopyServerReport: CopyServerReport(); break; case ReporterCommand.PutLinks: using (Start()) LoadCurTemplate(); LastChangeLinks = DateTime.Now; f = new FormPutLinks(); break; case ReporterCommand.FilterParams: f = new FormFiltersParams(); break; case ReporterCommand.LinkProperties: f = new FormLinkProperties(); break; case ReporterCommand.FindLinks: f = new FormFindLinks(); break; case ReporterCommand.LinksTemplate: f = new FormLinksTemplate(); break; case ReporterCommand.DeleteLinks: DeleteLinks(); LastChangeLinks = DateTime.Now; break; case ReporterCommand.ClearCells: Forms.Add(ReporterCommand.ClearCells, null); UsedFileToMemory(); ClearAllCells(); Forms.Remove(ReporterCommand.ClearCells); break; case ReporterCommand.ShapeLibrary: f = new FormShapeLibrary(); break; case ReporterCommand.Report: UsedFileToMemory(); PrepareController(); f = new FormReport(); break; case ReporterCommand.LiveReport: UsedFileToMemory(); PrepareController(); f = new FormLiveReport(); break; case ReporterCommand.Video: UsedFileToMemory(); PrepareController(); f = new FormVideo(); break; case ReporterCommand.ArchivesRanges: f = new FormArchivesRanges(); break; case ReporterCommand.Intervals: UsedFileToMemory(); if (FormInf == null || FormToDir || FormToFile) { MessageReportError("Сохранение в журнал возможно только при формировании отчета непосредственно в бланк отчета (задается в настройках)"); } else { PrepareArchive(); f = new FormIntervals(); } break; case ReporterCommand.FilterIntervals: f = new FormFiltersIntervals(); break; case ReporterCommand.SaveReport: if (CanSaveReport()) { f = new FormSaveReport(); } break; case ReporterCommand.AbsoluteEdit: UsedFileToMemory(); AddEvent("Чтение абсолютных значений из архива"); foreach (var project in UsedProjects.Values) { project.AbsoluteEditValues = project.Archive.ReadAbsoluteEdit(project.Code, false); } f = new FormAbsoluteEdit(); break; case ReporterCommand.Update: UpdateDataFile(true); if (!Command.IsError) { MessageReport("Ссылки были обновлены"); } break; case ReporterCommand.LinksList: f = new FormLinksList(); break; case ReporterCommand.AppInfo: f = new FormAppInfo(); break; } if (f != null) { if (!c.OneForAllBooks()) { f.Text += " (" + Code + ")"; } Forms.Add(c, f); f.Show(); } } catch (Exception ex) { AddError("Ошибка при открытии формы", ex, c.ToString()); } if (Command != null && Command.IsError) { foreach (var ff in Forms) { if (ff.Key != ReporterCommand.LinkProperties && ff.Value != null && ff.Value.Visible) { ff.Value.Activate(); break; } } ShowError(); } } return(f); }