public MainWindow(Parameters parameters) { Console.WriteLine("Initializing graphics and user interface..."); InitializeComponent(); Text = title; this.parameters = parameters; this.drawer = new Drawer(viewport); this.timer = new Data.Timer(); this.diagram = CreateDiagram(viewport, drawer, timer, parameters); this.zoomSelector = new RectangleSelector(drawer, viewport); this.zoomSelector.Button = MouseButtons.Left; this.zoomSelector.Color = System.Drawing.Color.White; this.zoomSelector.EndSelect += zoomSelector_Select; this.unZoomSelector = new RectangleSelector(drawer, viewport); this.unZoomSelector.Button = MouseButtons.Middle; this.unZoomSelector.Color = System.Drawing.Color.Blue; this.unZoomSelector.EndSelect += unZoomSelector_Select; this.panDragger = new Dragger(viewport); this.panDragger.Button = MouseButtons.Right; this.panDragger.Drag += panDragger_Drag; this.panDragger.EndDrag += panDragger_EndDrag; this.frameCounter = new VisibleFrameCounter(drawer); this.frameCounter.Color = System.Drawing.Color.Yellow; this.frameCounter.Alignment = TextAlignment.Far; this.coordinateLabel = new CoordinateLabel(coordinateStatusLabel, viewport, diagram); NewSession(parameters.PortStrings); if (parameters.MinimalMode != null) MinimalMode = parameters.MinimalMode.Value; this.settings = new Settings(properties, this, viewport, drawer, timer, diagram, zoomSelector, unZoomSelector, panDragger, frameCounter); if (System.IO.File.Exists(SettingsPath)) this.settings.XElement = XElement.Load(SettingsPath); properties.SelectedObject = settings; viewport.AddComponent(diagram); viewport.AddComponent(zoomSelector); viewport.AddComponent(unZoomSelector); viewport.AddComponent(frameCounter); viewport.AddComponent(coordinateLabel); }
static void Main(string[] args) { if (args.Contains("--help")) { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Visualizer.Text.Help Message.xml")) using (TextReader reader = new StreamReader(stream)) { XElement helpMessage = XElement.Load(reader); IDictionary<string, int> columns = ( from column in helpMessage.Element("Columns").Elements() select new { Name = (string)column.Element("Name"), Value = (int)column.Element("Value") } ) .ToDictionary(column => column.Name, column => column.Value); foreach (XElement textElement in helpMessage.Element("Data").Elements()) { if (textElement.Name == "Text") Terminal.Write(columns[(string)textElement.Attribute("Column")], (string)textElement); if (textElement.Name == "NewLine") Console.WriteLine(); } } return; } Console.WriteLine("Initializing..."); Parameters parameters; try { parameters = new Parameters(args); } catch (InvalidOperationException e) { Console.WriteLine(e.Message); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainWindow(parameters)); }
static Diagram CreateDiagram(Viewport viewport, Drawer drawer, Data.Timer timer, Parameters parameters) { Diagram diagram = new Diagram(); diagram.Graphs = new List<Graph>(); diagram.GraphSettings = new GraphSettings(); if (parameters.ExtendGraphs != null) diagram.GraphSettings.ExtendGraphs = parameters.ExtendGraphs.Value; if (parameters.LineWidth != null) diagram.GraphSettings.LineWidth = parameters.LineWidth.Value; switch (parameters.TimeManagerType) { case TimeManagerType.Continuous: diagram.TimeManager = new ContinuousTimeManager(timer); break; case TimeManagerType.Shiftting: diagram.TimeManager = new ShiftingTimeManager(timer); if (parameters.TimeManagerParameter != null) ((ShiftingTimeManager)diagram.TimeManager).ShiftLength = parameters.TimeManagerParameter.Value; break; case TimeManagerType.Wrapping: diagram.TimeManager = new WrappingTimeManager(timer); if (parameters.TimeManagerParameter != null) ((WrappingTimeManager)diagram.TimeManager).GapLength = parameters.TimeManagerParameter.Value; break; default: throw new InvalidOperationException(); } if (parameters.DiagramWidth != null) diagram.TimeManager.Width = parameters.DiagramWidth.Value; switch (parameters.ValueManagerType) { case ValueManagerType.Fitting: diagram.ValueManager = new FittingValueManager(diagram); break; case ValueManagerType.Fixed: diagram.ValueManager = new FixedValueManager(); if (parameters.ValueRange != null) ((FixedValueManager)diagram.ValueManager).FixedRange = parameters.ValueRange.Value; break; default: throw new InvalidOperationException(); } diagram.DataManager = new PerPixelDataManager(diagram); if (parameters.ClearData != null) diagram.DataManager.ClearData = parameters.ClearData.Value; diagram.AxisX = new AxisX(drawer, diagram); if (parameters.MarkerCountX != null) diagram.AxisX.MarkerCount = parameters.MarkerCountX.Value; if (parameters.DiagramColor != null) diagram.AxisX.Color = parameters.DiagramColor.Value; diagram.AxisY = new AxisY(drawer, diagram); if (parameters.MarkerCountY != null) diagram.AxisY.MarkerCount = parameters.MarkerCountY.Value; if (parameters.DiagramColor != null) diagram.AxisY.Color = parameters.DiagramColor.Value; diagram.Layouter = new Layouter(viewport, diagram.AxisX, diagram.AxisY); return diagram; }