Exemple #1
0
 void InitializeWindow()
 {
     Width  = SystemParameters.WorkArea.Width - 96;
     Height = SystemParameters.WorkArea.Height - 96;
     Left   = (SystemParameters.WorkArea.Width - Width) / 2 + SystemParameters.WorkArea.Left;
     Top    = (SystemParameters.WorkArea.Height - Height) / 2 + SystemParameters.WorkArea.Top;
     Title  = TwAssembly.CompanyAndTitle();
 }
Exemple #2
0
        void WriteHeader(StringBuilder text, LogMeter log)
        {
            AppendKeyValuePair(text, "Format", "TraceWizardLog");
            AppendKeyValuePair(text, "Version", TwAssembly.Version().ToString());

            WriteCustomerInfo(text, log.Customer);
            WriteMeterInfo(text, log.Meter);
        }
Exemple #3
0
 bool KeyFound(string filename)
 {
     if (File.Exists(Path.GetDirectoryName(TwAssembly.Path()) + "\\" + filename))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #4
0
        private bool IsOldVersion(string[] lines)
        {
            Version fileVersion = GetCurrentFileVersion(lines);
            Version appVersion  = MinimumFileVersion();;

            if (fileVersion == appVersion || TwAssembly.IsVersionNewer(appVersion, fileVersion))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #5
0
        void ExportLogToTwdbExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var files = TwFile.GetLogFilesIncludingZipped(Properties.Settings.Default.DirectoryLog);

            if (files != null && files.Count > 0)
            {
                var list = new List <string>();
                for (int i = 0; i < files.Count; i++)
                {
                    list.Add(files[i]);
                }
                var countFilesSaved = TwServices.ExportLogToTwdb(list, new Tw4PostTrickleMergeMidnightSplitDisaggregator());
                MessageBox.Show(countFilesSaved + " TWDB file(s) were created.", TwAssembly.TitleTraceWizard());
            }
        }
Exemple #6
0
        void ExportMdbToCsvExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var files = TwFile.GetMdbLogFiles(Properties.Settings.Default.DirectoryLog);

            if (files != null && files.Length > 0)
            {
                var list = new List <string>();
                for (int i = 0; i < files.Length; i++)
                {
                    list.Add(files[i]);
                }
                var countFilesSaved = TwServices.ExportMdbToCsv(list);
                MessageBox.Show(countFilesSaved + " CSV file(s) were created.", TwAssembly.TitleTraceWizard());
            }
        }
        public void SplitHorizontally(Point point)
        {
            if (!Event.CanSplitHorizontally(point.X, point.Y,
                                            eventsCanvas.WidthMultiplier, eventsCanvas.HeightMultiplier))
            {
                MessageBox.Show(
                    "Cannot split into contiguous events",
                    TwAssembly.Title(),
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return;
            }

            SplitHorizontally(Event, point);
            MousePosition = null;
        }
Exemple #8
0
        void Initialize(FeatureLevel featureLevel)
        {
            Title = "About " + TwAssembly.CompanyAndTitle();

            ImageIcon.Source = TwGui.GetIcon32();

            LabelTitle.Text     = TwAssembly.CompanyAndTitle();
            LabelVersion.Text   = TwAssembly.CompleteVersion() + " " + featureLevel.Text;
            LabelCopyright.Text = TwAssembly.Copyright();

            var hyperlink = new Hyperlink();

            hyperlink.NavigateUri      = new System.Uri(TwEnvironment.WebSite);
            hyperlink.RequestNavigate += new RequestNavigateEventHandler(HyperlinkAbout_RequestNavigate);
            hyperlink.Inlines.Add(TwEnvironment.WebSite);
            LabelHyperlink.Inlines.Add(hyperlink);
        }
Exemple #9
0
        private Version GetCurrentFileVersion(string[] lines)
        {
            Version version = TwAssembly.Version();

            foreach (string line in lines)
            {
                if (line.Contains("@DATA"))
                {
                    break;
                }

                if (line.Contains("% Version: "))
                {
                    version = new Version(line.Split(':')[1].Trim());
                }
            }
            return(version);
        }
Exemple #10
0
        public static void DeleteExtractedDirectory()
        {
            if (!Directory.Exists(extractedDirectoryWithPath()))
            {
                return;
            }

            try {
                foreach (string file in Directory.GetFiles(extractedDirectoryWithPath()))
                {
                    File.SetAttributes(file, ~FileAttributes.ReadOnly);
                }
                Directory.Delete(extractedDirectoryWithPath(), true);
            } catch (Exception ex) {
                string message = "Unable to delete " + extractedDirectoryWithPath() + " folder. ";
                message += System.Environment.NewLine + System.Environment.NewLine + ex.Message;
                MessageBox.Show(message, TwAssembly.Title());
            }
        }
        void DispatchDrop(Polygon polygonSource, DragEventArgs e)
        {
            Event eventTarget = Event;
            Event eventSource = polygonSource.Tag as Event;

            if (eventSource == eventTarget)
            {
                return;
            }

            if (!Merge(eventSource, eventTarget, e))
            {
                MessageBox.Show(
                    "Cannot merge",
                    TwAssembly.Title(),
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }
        }
        public void Initialize()
        {
            InitializeControls();

            if (!FeatureLevel.IsPro)
            {
                ButtonTools.Visibility = Visibility.Collapsed;

                foreach (Control item in ButtonHelp.ContextMenu.Items)
                {
                    if (item.Name != "AboutHelpMenu")
                    {
                        item.Visibility = Visibility.Collapsed;
                    }
                }
            }

            AboutHelpMenu.Header = "About " + TwAssembly.CompanyAndTitle();

            InitializeMouse();
        }
Exemple #13
0
        bool ShouldCancelClose(string keyCode)
        {
            string message = "You have made unsaved changes";

            if (!string.IsNullOrEmpty(keyCode))
            {
                message += " to " + keyCode;
            }
            message += ".\r\n\r\n To close and lose these changes, press OK.\r\n\r\n To cancel the close, press Cancel.";
            MessageBoxResult messageBoxResult = MessageBox.Show(
                message,
                TwAssembly.Title(),
                MessageBoxButton.OKCancel,
                MessageBoxImage.Warning,
                MessageBoxResult.Cancel);

            if (messageBoxResult == MessageBoxResult.Cancel)
            {
                return(true);
            }
            return(false);
        }
        public void SplitVertically(Polygon polygon, Point point)
        {
            if (!Events.CanSplitVertically(Event))
            {
                MessageBox.Show(
                    "Cannot split into simultaneous events",
                    TwAssembly.Title(),
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return;
            }

            DateTime dateTime = Event.GetSplitDate(point.X, EventsCanvas.WidthMultiplier);
            double   rate     = Event.GetSplitRate(point.Y, EventsCanvas.HeightMultiplier);

            if (!Event.IsLegal(dateTime, rate))
            {
                return;
            }

            SplitVertically(Event, point, eventsCanvas.WidthMultiplier, eventsCanvas.HeightMultiplier);
            MousePosition = null;
        }
        void DispatchDrop(List <Polygon> polygons, DragEventArgs e)
        {
            Event eventTarget = Event;

            var events = new List <Event>();

            foreach (Polygon polygon in polygons)
            {
                events.Add((Event)polygon.Tag);
            }

            if (Events.CanMergeAllVerticallyIntoBase(eventTarget, events))
            {
                MergeAllVerticallyIntoBase(eventTarget, events);
            }
            else
            {
                MessageBox.Show(
                    "Cannot merge all",
                    TwAssembly.Title(),
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }
        }
Exemple #16
0
        void DoFullScreen(bool enterFullScreen)
        {
            if (enterFullScreen)
            {
                Title = TwAssembly.CompanyAndTitle() + " - " + "Press Escape key to exit Full Screen mode";
            }
            else
            {
                Title = TwAssembly.CompanyAndTitle();
            }

            MainToolBar.Visibility = BoolToVisibility(enterFullScreen);

            foreach (TabItem tabItem in TabControl.Items)
            {
                var analysisPanel = tabItem.Content as AnalysisPanel;

                if (analysisPanel != null)
                {
                    DoFullScreen(enterFullScreen, analysisPanel);
                }
            }
            WindowState = BoolToWindowState(enterFullScreen);
        }
Exemple #17
0
        public Analysis Load(string dataSource)
        {
            string[] lines = System.IO.File.ReadAllLines(dataSource);

            if (IsOldVersion(lines))
            {
                throw new Exception("Please migrate the analysis file " + dataSource + " to version " + TwAssembly.Version() + " or later.");
            }

            double twConversionFactor = GetTwConversionFactor(lines);

            Attributes = LoadAttributes(lines);

            LogMeter log = LoadLog(lines);

            FixtureProfiles fixtureProfiles = LoadFixtureProfiles(lines);

            Events events = LoadEvents(lines);

            LoadFlows(lines, events);

            events.UpdateVolume();

            var analysis = new AnalysisDatabase(dataSource, events, log, fixtureProfiles);

            analysis.Events.ConversionFactor = twConversionFactor;
            analysis.Events.UpdateChannel();
            analysis.Events.UpdateSuperPeak();
            analysis.Events.UpdateLinkedList();
            analysis.Events.UpdateOriginalVolume();

            return(analysis);
        }
Exemple #18
0
        void WriteHeader(System.Text.StringBuilder text, string dataSource, double conversionFactor)
        {
            text.AppendLine("% Format: Trace Wizard Analysis");
            text.AppendLine("% Version: " + TwAssembly.Version());
            text.AppendLine("% TwConversionFactor: " + conversionFactor.ToString("0.000000"));
            text.AppendLine("%");
            text.AppendLine("@RELATION event");
            text.AppendLine();

            if (Attributes.IsKeyCodeEnabled)
            {
                text.AppendLine("@ATTRIBUTE keycode           STRING");
            }

            if (Attributes.IsEventIdEnabled)
            {
                text.AppendLine("@ATTRIBUTE eventid           NUMERIC");
            }

            if (Attributes.IsStartTimeEnabled)
            {
                text.AppendLine("@ATTRIBUTE starttime         DATE \"yyyy-MM-dd HH:mm:ss\"");
            }

            if (Attributes.IsEndTimeEnabled)
            {
                text.AppendLine("@ATTRIBUTE endtime           DATE \"yyyy-MM-dd HH:mm:ss\"");
            }

            if (Attributes.IsDurationEnabled)
            {
                text.AppendLine("@ATTRIBUTE duration          NUMERIC");
            }

            if (Attributes.IsFirstCycleEnabled)
            {
                text.AppendLine("@ATTRIBUTE firstcycle        {True,False}");
            }

            if (Attributes.IsManuallyClassifiedEnabled)
            {
                text.AppendLine("@ATTRIBUTE preserved         {True,False}");
            }

            if (Attributes.IsChannelEnabled)
            {
                text.AppendLine("@ATTRIBUTE channel           {None,Runt,Trickle,Base,Super}");
            }

            if (Attributes.IsVolumeEnabled)
            {
                text.AppendLine("@ATTRIBUTE volume            NUMERIC");
            }

            if (Attributes.IsPeakEnabled)
            {
                text.AppendLine("@ATTRIBUTE peak              NUMERIC");
            }

            if (Attributes.IsModeEnabled)
            {
                text.AppendLine("@ATTRIBUTE mode              NUMERIC");
            }

            if (Attributes.IsModeFrequencyEnabled)
            {
                text.AppendLine("@ATTRIBUTE modefrequency     NUMERIC");
            }

            if (Attributes.IsHourEnabled)
            {
                text.AppendLine("@ATTRIBUTE hour              NUMERIC");
            }

            if (Attributes.IsIsWeekendEnabled)
            {
                text.AppendLine("@ATTRIBUTE isweekend         {True,False}");
            }

            if (Attributes.IsTimeToLongerEventEnabled)
            {
                text.AppendLine("@ATTRIBUTE timetolongerevent NUMERIC");
            }

            if (Attributes.IsUserNotesEnabled)
            {
                text.AppendLine("@ATTRIBUTE notes             STRING");
            }

            if (Attributes.IsFixtureClassEnabled)
            {
                text.AppendLine("@ATTRIBUTE class             {" + BuildFixtureClasses() + "}");
            }

            if (Attributes.IsClassifiedUsingFixtureListEnabled)
            {
                text.AppendLine("@ATTRIBUTE classifiedusingfixturelist {True,False}");
            }

            if (Attributes.IsManuallyApprovedEnabled)
            {
                text.AppendLine("@ATTRIBUTE manuallyapproved  {True,False}");
            }

            if (Attributes.IsManuallyClassifiedFirstCycleEnabled)
            {
                text.AppendLine("@ATTRIBUTE manuallyclassifiedfirstcycle  {True,False}");
            }

            text.AppendLine();
        }
Exemple #19
0
        public override Log Load(string dataSource)
        {
            //dataSource = ConvertFromAccess97(dataSource);

            var log = new LogMeter(dataSource);

            try {
                using (OleDbConnection connection = new OleDbConnection(DataServices.BuildJetConnectionString(dataSource, true))) {
                    connection.Open();
                    using (OleDbCommand command = new OleDbCommand()) {
                        command.Connection = connection;

                        log.FileName = dataSource;
                        log.Customer = AddCustomer(command);
                        log.Meter    = AddMeter(command);
                        log.Flows    = AddFlows(command, TimeSpan.FromSeconds(log.Meter.StorageInterval.GetValueOrDefault()), log);

                        if (log.Flows.Count > 0)
                        {
                            log.StartTime = log.Flows[0].StartTime;
                            log.EndTime   = log.Flows[log.Flows.Count - 1].EndTime;
                        }
                    }

                    log.Update();
                    return(log);
                }
            } catch (System.Data.OleDb.OleDbException ex) {
                if (ex.Message.Contains("Could not find file"))
                {
                    throw new Exception("Could not find file");
                }
                else if (ex.Message.Contains("Unrecognized database format"))
                {
                    throw new Exception("Unrecognized logger format");
                }
                else if (ex.Message.Contains("Cannot open a database created with a previous version of your application"))
                {
                    throw new Exception("The Microsoft Access 2007 Runtime is not properly installed on this system. Historically, this error has occured when Access 2010 or later has been run on this system.\r\n\r\nPlease review the " + TwAssembly.Title() + " System Requirements and reinstall/repair the Access 2007 Runtime.\r\n\r\n The original error message was: " + ex.Message);
                }
                else
                {
                    throw;
                }
            } catch (InvalidOperationException ex) {
                if (ex.Message.Contains("provider is not registered"))
                {
                    throw new Exception("The Microsoft Access 2007 Runtime is not installed on this system.\r\n\r\nPlease review the " + TwAssembly.Title() + " System Requirements and install the Access 2007 Runtime.\r\n\r\n(" + ex.Message + ")");
                }
                else
                {
                    throw;
                }
            }
        }
Exemple #20
0
 void InitializeVersionDisplay()
 {
     LabelVersion.Content = (MenuBarNag != null ? MenuBarNag + " | " : "") + "Ver " + TwAssembly.CompleteVersion() + " " + featureLevel.Text;
     LabelVersion.ToolTip = "Trace Wizard version: " + TwAssembly.CompleteVersion() + "\r\n" + "Feature level: " + featureLevel.Text;
 }
Exemple #21
0
        void ButtonAppend_Click(object sender, RoutedEventArgs e)
        {
            double percentElapsed = (StyledEventsViewerUpper.EventsViewer.ScrollViewer.HorizontalOffset / StyledEventsViewerUpper.EventsViewer.LinedEventsCanvas.Width);
            int    secondsOffset  = (int)(percentElapsed * AnalysisUpper.Events.Duration.TotalSeconds);
            var    dateTimeUpperToStartCopyingAt = GetEndTimeView(StyledEventsViewerUpper, AnalysisUpper);
            var    dateTimeLowerToEndCopyingAt   = GetEndTimeView(StyledEventsViewerLower, AnalysisLower);

            if (Events.HasEventInProgress(AnalysisUpper.Events, dateTimeUpperToStartCopyingAt) ||
                Events.HasEventInProgress(AnalysisLower.Events, dateTimeLowerToEndCopyingAt))
            {
                MessageBox.Show("In order to append, please scroll the upper and lower graphs such that no event is in progress at the end of the view shown.", TwAssembly.TitleTraceWizard(), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                var analysisAppended = Analysis.Append(AnalysisLower, AnalysisUpper, dateTimeLowerToEndCopyingAt, dateTimeUpperToStartCopyingAt);

                string fileName = analysisAppended.KeyCode;

                Mouse.OverrideCursor = Cursors.Wait;

                MainTwWindow mainWindow = (MainTwWindow)Application.Current.MainWindow;

                var analysisPanel = mainWindow.CreateAnalysisPanel(analysisAppended, fileName, false);
                mainWindow.AddTab(analysisPanel, fileName);

                Mouse.OverrideCursor = null;
            }
        }
Exemple #22
0
        void ExportLow()
        {
            var analysisAdapterTarget = new ArffAnalysisAdapter();

            analysisAdapterTarget.Attributes = attributes;

            this.Total = analysisFiles.Count;

            foreach (string analysisFile in analysisFiles)
            {
                if (this._isCancelationPending == true)
                {
                    break;
                }

                ++this.Current;
                this.KeyCode = GetKeyCode(analysisFile);

                Analysis analysis = Services.TwServices.CreateAnalysis(analysisFile);

                EventsArff events = analysisAdapterTarget.Load(analysis.Events);
                analysisAdapterTarget.Save(arffFile, new Analysis(events, analysis.KeyCode), false);
            }

            if (launchTextEditor)
            {
                TwFile.LaunchNotepad(arffFile);
            }
            else
            {
                MessageBox.Show("Export file successfully created: \r\n\r\n" + arffFile, TwAssembly.TitleTraceWizard());
            }
        }
Exemple #23
0
 void ShowMessageBox(string message)
 {
     MessageBox.Show(message, TwAssembly.Title());
     Mouse.OverrideCursor = null;
 }