private void SetVariantCombinations(WindowMacro windowMacro) { _previewControl.VariantsCombinations = new ObservableCollection <VariantCombination>(); _previewControl.PreviewType = PreviewType.WindowMacro; foreach (var representationType in windowMacro.RepresentationTypes) { VariantCombination variantCombination = new VariantCombination(PreviewType.WindowMacro); variantCombination.PreviewObject = windowMacro; variantCombination.RepresentationType = representationType; foreach (int variantIndex in windowMacro.GetVariants(representationType)) { windowMacro.ChangeCurrentVariant(representationType, variantIndex); Variant variant = new Variant(variantCombination); variant.Index = variantIndex; variant.Description = windowMacro.Description .GetStringToDisplay(MultiLanguage.GuiLanguage); variant.Description = Regex.Replace(variant.Description, @"\r\n?|\n", " "); variantCombination.Variants.Add(variant); } _previewControl.VariantsCombinations.Add(variantCombination); } _previewControl.SelectedVariantCombination = _previewControl.VariantsCombinations.FirstOrDefault(); _previewControl.CheckControls(); }
/// <summary> /// Display a file /// </summary> /// <param name="path">Full filename</param> /// <param name="previewType">Type of file</param> public void Display(string path, PreviewType previewType) { if (path == null) { return; } if (!File.Exists(path)) { throw new FileNotFoundException(path); } switch (previewType) { case PreviewType.WindowMacro: WindowMacro = new WindowMacro(); WindowMacro.Open(path, EplanProject); SetVariantCombinations(WindowMacro); break; case PreviewType.SymbolMacro: SymbolMacro = new SymbolMacro(); SymbolMacro.Open(path, EplanProject); SetVariantCombinations(SymbolMacro); break; case PreviewType.PageMacro: PageMacro = new PageMacro(); PageMacro.Open(path, EplanProject); SetVariantCombinations(PageMacro); break; default: throw new ArgumentOutOfRangeException(nameof(previewType), previewType, null); } }
private void Draw() { if (SelectedVariant != null) { switch (PreviewType) { case PreviewType.WindowMacro: WindowMacro windowMacro = (WindowMacro)SelectedVariantCombination.PreviewObject; windowMacro.ChangeCurrentVariant(SelectedVariantCombination.RepresentationType, SelectedVariant.Index); Preview.DrawingService.CreateDisplayList(windowMacro); Preview.DrawEplan(); break; case PreviewType.SymbolMacro: SymbolMacro symbolMacro = (SymbolMacro)SelectedVariantCombination.PreviewObject; symbolMacro.ChangeCurrentVariant(SelectedVariantCombination.RepresentationType, SelectedVariant.Index); Preview.DrawingService.CreateDisplayList(symbolMacro); Preview.DrawEplan(); symbolMacro.Dispose(); break; case PreviewType.PageMacro: PageMacro pageMacro = (PageMacro)SelectedVariantCombination.PreviewObject; Preview.DrawingService.CreateDisplayList(pageMacro.Pages[SelectedVariant.Index]); Preview.DrawEplan(); break; default: throw new ArgumentOutOfRangeException(); } } }
public static string InsertWindowMacro(ref Page refPage, EplWindowMacroProperties windowMacroProperties) { string msg = EplDefinition.EPL_INSERT_WINDOW_MCR.ToString(); Logger.WriteLine(JsonConvert.SerializeObject(windowMacroProperties)); try { Insert insert = new Insert(); WindowMacro windowMacro = new WindowMacro(); windowMacro.Open(windowMacroProperties.FilePath, refPage.Project); Insert oInsert = new Insert(); StorableObject[] oInsertedObjects = insert.WindowMacro( windowMacroProperties.FilePath, windowMacroProperties.Variant, refPage, windowMacroProperties.Position, windowMacroProperties.MoveKind); } catch (Exception ex) { EplException("Insert window macro error.", ex); msg = EplError.EPL_ERROR.ToString(); } return(msg); }
private void panel_Symbol_Paint(object sender, PaintEventArgs e) { if (this.MvProject.Project == null) { return; } if (dataGridView2.CurrentRow == null || dataGridView2.CurrentRow.Cells["PartNr"].Value == null) { return; } string partNr = dataGridView2.CurrentRow.Cells["PartNr"].Value.ToString(); MDPartsDatabase mdb = Util.eplan.GetPartMaster(); MDPart part = mdb.GetPart(partNr); if (part == null) { return; } string filePath = PathMap.SubstitutePath(part.Properties.ARTICLE_GROUPSYMBOLMACRO.ToString()); if (!File.Exists(filePath)) { return; } int variant = 0; if (panel_Symbol.Tag != null) { variant = (int)panel_Symbol.Tag; } try { WindowMacro wm = new WindowMacro(); wm.Open(filePath, this.MvProject.Project); wm.RepresentationType = WindowMacro.Enums.RepresentationType.SingleLine; if (wm.ExistVariant(WindowMacro.Enums.RepresentationType.SingleLine, variant)) { wm.Variant = variant; } else { panel_Symbol.Tag = wm.Variant = 0; } DrawingService ds = new DrawingService(); ds.MacroPreview = false; ds.CenterView = true; ds.CreateDisplayList(wm); ds.DrawDisplayList(e); } catch { //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
private void Open_Click(object sender, EventArgs e) { baseapp.app.OpenProjectDlg(); currentProject = baseapp.Manager.GetCurrentProjectWithDialog(); wmacro = new WindowMacro(); wmacro.Open(@"J:\库、宏、标准\窗口宏\123.ema", currentProject); }
public bool PreFilterMessage(ref Message m) { switch (m.Msg) { case WM.MOUSEMOVE: if (MouseMoved != null) { MouseMoved(CursorPosition.GetCursorPosition()); } break; case WM.XBUTTONDOWN: if (XButtonDown != null) { var button = WindowMacro.HighWord(m.WParam.ToInt32()); if (button == 0x0001) { XButtonDown(MouseButtons.XButton1); } if (button == 0x0002) { XButtonDown(MouseButtons.XButton2); } } break; } // always allow message to continue to the next filter control return(false); }
private System.Drawing.Rectangle GetDrawingRegion(WindowMacro wm) { System.Drawing.Rectangle r = new System.Drawing.Rectangle(); r.X = (int)_origin.X; r.Y = (int)_origin.Y; try { r.Width = (int)(wm.Size.X * _zoomFactor); r.Height = (int)(wm.Size.Y * _zoomFactor); } catch { } return(r); }
private void PreView_Load(object sender, EventArgs e) { if (!File.Exists(this.MacroPath)) { MessageBox.Show("ERROR: File not found: " + this.MacroPath); return; } _windowMacro = new WindowMacro(); _windowMacro.Open(this.MacroPath, this.Project); _drawingService = new DrawingService(); _drawingService.DrawConnections = true; _drawingService.MacroPreview = true; _drawingService.CreateDisplayList(_windowMacro); panel1.MouseWheel += new MouseEventHandler(panel1_MouseWheel); }
/// <summary> /// Init Preview object for WPF /// </summary> /// <param name="border">Border which should inhert the UserControl</param> /// <param name="projectFile">EPLAN project file to preview (*.elk)</param> public Preview(Border border, string projectFile) { // Clean WindowMacro = null; SymbolMacro = null; PageMacro = null; if (!File.Exists(projectFile)) { throw new FileNotFoundException(projectFile); } // Check if project is open var projectManager = new ProjectManager(); projectManager.LockProjectByDefault = false; //EplanProject = ProjectUtility.OpenProject(projectFile); foreach (var openProject in projectManager.OpenProjects) { if (openProject.ProjectLinkFilePath.Equals(projectFile)) { EplanProject = openProject; break; } } if (EplanProject == null) { EplanProject = projectManager.OpenProject(projectFile, ProjectManager.OpenMode.Exclusive); } DrawingService = new DrawingService(); DrawingService.DrawConnections = true; border.Child = _previewControl; _previewControl.Preview = this; }
/// <summary> /// Displays the given WindowMacro /// </summary> /// <param name="windowMacro">EPLAN WindowMacro</param> public void Display(WindowMacro windowMacro) { WindowMacro = windowMacro; SetVariantCombinations(WindowMacro); }