public XmlWriterTraceListener(string applicationName, string customLogPath = null, int historyDayCount = 2, bool isDelayedWrite = true)
        {
            CustomLogPath = customLogPath;
            IsDelayedWrite = isDelayedWrite;
            HistoryDayCount = historyDayCount;
            ApplicationName = applicationName;
            _lastCreationLogDate = DateTime.MinValue;

            _logFileManager = new LogFileManager(ApplicationName, BaseRootPath, historyDayCount);

            if (!IsDelayedWrite)
            {
                _taskAppendLogsToDiskWithoutDelayed = Task.Factory.StartNew(token =>
                    {

                        var cancellationToken = (CancellationToken) token;

                        while (true)
                        {
                            if (_lines.Count > 0)
                                WriteLogsToDisk();
                            else
                            {
                                if (cancellationToken.IsCancellationRequested)
                                    break;

                                Thread.Sleep(WaitingBeforeWritingLogs);
                            }
                        }
                    }, _cancellationToken.Token, _cancellationToken.Token/*, TaskCreationOptions.LongRunning, TaskScheduler.Default*/);
            }
            else
                _timer = new Timer(OnTimerCallback, null, TimerSaveFrequency, TimerSaveFrequency);
        }
예제 #2
0
        private bool CheckValidation()
        {
            bool result = true;

            try
            {
                foreach (DataGridViewRow row in dataGridViewElement.Rows)
                {
                    int massId = int.Parse(row.Cells["MassId"].Value.ToString());
                    if (massId == 0)
                    {
                        row.Cells["ColumnSelection"].Selected = true;
                        //result = false;
                    }
                }

                if (!result)
                {
                    MessageBox.Show("Please select a mass that will cut the intersecting element.", "Missing Mass Selection", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to check validation.\n" + ex.Message, "Form_OverlapMass:CheckValidation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("CheckValidation", ex.Message);
                result = false;
            }
            return(result);
        }
예제 #3
0
        private void FindSelectedMass()
        {
            try
            {
                UIDocument uidoc     = m_app.ActiveUIDocument;
                Selection  selection = uidoc.Selection;

                foreach (ElementId elementId in selection.GetElementIds())
                {
                    Element element = m_doc.GetElement(elementId);
                    if (null != element)
                    {
                        if (null != element.Category)
                        {
                            if (element.Category.Name == "Mass")
                            {
                                selectedMass.Add(element);
                            }
                        }
                    }
                }

                if (selectedMass.Count > 0)
                {
                    radioButtonSelectedMass.Enabled = true;
                    radioButtonSelectedMass.Checked = true;
                    labelSelectedMass.Text          = selectedMass.Count.ToString() + " mass selected.";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to find selected mass elements.\n" + ex.Message, "Form_LinkedFiles:FindSelectedMass", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("FindSelectedMass", ex.Message);
            }
        }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        btn1.onClick.AddListener(OnClickBtn1);
        btn2.onClick.AddListener(OnClickBtn2);

        LogFileManager.Start();
    }
예제 #5
0
        public void LogFileDateCutoverBeforeArchiveTest()
        {
            TestFileSystem            FileSystem         = CreateDefaultFileSystem();
            TestSystemTime            SystemTime         = new TestSystemTime(2020, 1, 18, 23, 59, 59, DateTimeKind.Local);
            LogFileManagementSchedule ManagementSchedule = LogFileManagementSchedule.Build(SystemTime, s_DefaultOptions);

            using LogFileManager Manager = new LogFileManager(FileSystem, SystemTime);

            LogFile LogFile = Manager.FindLogFile(
                "AppName",
                "Group",
                () => s_DefaultOptions,
                FileLoggerOptions.DefaultLogFileNamePattern,
                null,
                ManagementSchedule);

            Assert.IsNotNull(LogFile);
            Assert.AreEqual($"{Environment.MachineName}.20200118.log", LogFile.FinalFileName);

            SystemTime.UtcNow = new DateTime(2020, 1, 19, 0, 0, 0, DateTimeKind.Local).ToUniversalTime();

            LogFile = Manager.FindLogFile(
                "AppName",
                "Group",
                () => s_DefaultOptions,
                FileLoggerOptions.DefaultLogFileNamePattern,
                null,
                ManagementSchedule);

            Assert.IsNotNull(LogFile);
            Assert.AreEqual($"{Environment.MachineName}.20200119.log", LogFile.FinalFileName);

            Assert.AreEqual(2, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileDirectory).Count());
            Assert.AreEqual(0, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileArchiveDirectory).Count());
        }
예제 #6
0
        private bool disposedValue = false; // 要检测冗余调用

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    try
                    {
                        bConnectOk = false;
                        if (Image != null)
                        {
                            Image.Dispose();
                        }

                        if (latestFrameAddress != null)
                        {
                            Marshal.FreeHGlobal(latestFrameAddress);
                            latestFrameAddress = IntPtr.Zero;
                        }
                    }
                    catch (Exception e)
                    {
                        LogFileManager.Error("Camera", e.ToString());
                    }
                    // TODO: 释放托管状态(托管对象)。
                }

                // TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器。
                // TODO: 将大型字段设置为 null。

                disposedValue = true;
            }
        }
예제 #7
0
        private void Form_Parameters_Load(object sender, EventArgs e)
        {
            try
            {
                int index = 0;
                foreach (string paramName in parameters)
                {
                    index = dataGridViewParam.Rows.Add();
                    dataGridViewParam.Rows[index].Cells[0].Value = false;
                    dataGridViewParam.Rows[index].Cells[1].Value = paramName;
                    dataGridViewParam.Rows[index].Cells[2].Value = paramName;

                    if (selectedParam.ContainsKey(paramName))
                    {
                        dataGridViewParam.Rows[index].Cells[0].Value = true;
                        dataGridViewParam.Rows[index].Cells[2].Value = selectedParam[paramName];
                    }
                }
                dataGridViewParam.Sort(dataGridViewParam.Columns[1], ListSortDirection.Ascending);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to display parameters lists.\n" + ex.Message, "Form_Parameters:Form_Parameters_Load", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("Form_Parameters_Load", ex.Message);
            }
        }
예제 #8
0
파일: Menu.cs 프로젝트: milenbubi/Tetris
        private static void BestScores()
        {
            ScoreManager.DisplayScores();
            Console.ForegroundColor = ConsoleColor.Red;

            int currentScore = GameData.points;

            Console.WriteLine("  Current score: {0} pts.\n", currentScore);

            IEnumerable <string> scoreTable = LogFileManager.Read();

            if (scoreTable.Count() == 0)
            {
                Console.WriteLine("  Score table is empty!\n");
            }
            else
            {
                int lowestBestScore = int.Parse(scoreTable
                                                .Last()
                                                .Split()
                                                .First());

                if (currentScore >= lowestBestScore || scoreTable.Count() < 10)
                {
                    Console.WriteLine("  You already reached");
                    Console.WriteLine("  the top 10 results.\n");
                    Console.WriteLine("  Just finish the game!");
                }
            }

            Console.ForegroundColor = FieldData.MessageColor;

            Print(backMessage);
        }
예제 #9
0
        public void AppendToFirstNonFullLogFileTest()
        {
            TestFileSystem FileSystem = CreateDefaultFileSystem();

            using LogFileManager Manager = new LogFileManager(FileSystem, s_DefaultSystemTime);

            string BaseFileName = $"{FileLoggerOptions.DefaultLogFileDirectory}{Environment.MachineName}.20200119";

            for (int i = 0; i < 10; i++)
            {
                string FileName = i == 0
                                        ? BaseFileName + ".log"
                                        : BaseFileName + $".{i}.log";

                using Stream File = FileSystem.OpenFile(FileName, FileMode.CreateNew, FileAccess.Write, FileShare.None);

                if (i < 9)
                {
                    File.Write(new byte[1024], 0, 1024);
                }
            }

            Assert.AreEqual(10, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileDirectory).Count());

            LogFile LogFile = Manager.FindLogFile(
                "AppName",
                "Group",
                () => s_DefaultOptions,
                FileLoggerOptions.DefaultLogFileNamePattern,
                1,
                s_DefaultManagementSchedule);

            Assert.IsNotNull(LogFile);
            Assert.AreEqual($"{Environment.MachineName}.20200119.9.log", LogFile.FinalFileName);
        }
예제 #10
0
        public void ToxicLogFileTest()
        {
            using LogFileManager Manager = new LogFileManager(
                      CreateDefaultFileSystem(),
                      s_DefaultSystemTime);

            LogFile LogFile = Manager.FindLogFile(
                "AppName",
                "Group",
                () => s_DefaultOptions,
                FileLoggerOptions.DefaultLogFileNamePattern,
                null,
                s_DefaultManagementSchedule);

            LogFile.Toxic = true;

            LogFile = Manager.FindLogFile(
                "AppName",
                "Group",
                () => s_DefaultOptions,
                FileLoggerOptions.DefaultLogFileNamePattern,
                null,
                s_DefaultManagementSchedule);

            Assert.IsNotNull(LogFile);
            Assert.AreEqual($"{Environment.MachineName}.20200119.1.log", LogFile.FinalFileName);
        }
예제 #11
0
        public void AppendINI(ElementProperties ep)
        {
            try
            {
                SplitINIData splitData = new SplitINIData();
                splitData.CategoryName = ep.CategoryName;
                splitData.ElementId    = ep.ElementId;

                List <int> primaryElementIds = new List <int>();
                foreach (Element element in ep.PrimaryElements)
                {
                    primaryElementIds.Add(element.Id.IntegerValue);
                }
                splitData.PrimaryElementIds = primaryElementIds;

                List <int> secondaryElementIds = new List <int>();
                foreach (Element element in ep.SecondaryElements)
                {
                    secondaryElementIds.Add(element.Id.IntegerValue);
                }
                splitData.SecondaryElementIds = secondaryElementIds;

                if (!splitDictionary.ContainsKey(splitData.ElementId))
                {
                    splitDictionary.Add(splitData.ElementId, splitData);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to append line." + ex.Message, "Form_Assigner:AppendINI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("AppendINI", ex.Message);
            }
        }
예제 #12
0
 private void CreateHostMap()
 {
     try
     {
         foreach (DataGridViewRow row in dataGridViewElement.Rows)
         {
             if (null != row.Tag)
             {
                 ElementProperties ep = row.Tag as ElementProperties;
                 if (ep.HostElementId != 0)
                 {
                     if (hostMaps.ContainsKey(ep.HostElementId))
                     {
                         hostMaps[ep.HostElementId].Add(ep.ElementId, row.Index);
                     }
                     else
                     {
                         Dictionary <int, int> elementMap = new Dictionary <int, int>();
                         elementMap.Add(ep.ElementId, row.Index);
                         hostMaps.Add(ep.HostElementId, elementMap);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to create a host map.\n" + ex.Message, "Form_OverlapMass:CreateHostMap", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         LogFileManager.AppendLog("CreateHostMap", ex.Message);
     }
 }
예제 #13
0
        public void OpenLogFile(string path)
        {
            LogFileManager file      = new LogFileManager(path, ref vars);
            Grapher        graphform = new Grapher(file);

            graphform.Show();
            graphform.BringToFront();
        }
예제 #14
0
 /// <summary>Construct an instance.</summary>
 /// <param name="writeToConsole">Whether to output log messages to the console.</param>
 /// <param name="logPath">The full file path to which to write log messages.</param>
 public Program(bool writeToConsole, string logPath)
 {
     this.LogFile = new LogFileManager(logPath);
     this.Monitor = new Monitor("SMAPI", this.ConsoleManager, this.LogFile, this.CancellationTokenSource)
     {
         WriteToConsole = writeToConsole
     };
 }
        public void InitializeLoggingTestWithLogFilePath()
        {
            Assert.IsTrue(File.Exists(AppConfigPath));

            LogFileManager.InitializeLogging(false,
                                             true, AppConfigPath);

            AssertLogFileInitialized();
        }
예제 #16
0
 public MomentDetail(LogFileManager manager)
 {
     filemanager = manager;
     InitializeComponent();
     chart1.Series[0].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.String;
     ReadCache(0f);
     data = CacheData2[0];
     PlotGraph(data);
     CacheData = CacheData2;
 }
예제 #17
0
        private void ReadINI()
        {
            try
            {
                //CategoryName##OriginalElementId##PrimaryElementIds##SecondaryElementIds
                if (File.Exists(iniPath))
                {
                    using (StreamReader sr = new StreamReader(iniPath))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            string[] strSplitInfo = line.Split(splitter, StringSplitOptions.None);
                            if (strSplitInfo.Length == 4)
                            {
                                SplitINIData splitData = new SplitINIData();
                                splitData.CategoryName = strSplitInfo[0];
                                splitData.ElementId    = int.Parse(strSplitInfo[1]);

                                string[]   strPrimary      = strSplitInfo[2].Split(',');
                                List <int> primaryElements = new List <int>();
                                foreach (string primary in strPrimary)
                                {
                                    int elementId = int.Parse(primary);
                                    primaryElements.Add(elementId);
                                }
                                splitData.PrimaryElementIds = primaryElements;

                                string[]   strSecondary      = strSplitInfo[3].Split(',');
                                List <int> secondaryElements = new List <int>();
                                foreach (string secondary in strSecondary)
                                {
                                    int elementId = int.Parse(secondary);
                                    secondaryElements.Add(elementId);
                                }
                                splitData.SecondaryElementIds = secondaryElements;

                                if (!splitDictionary.ContainsKey(splitData.ElementId))
                                {
                                    splitDictionary.Add(splitData.ElementId, splitData);
                                }
                            }
                        }
                        sr.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to read INI file.\n" + ex.Message, "SplitINIDataManager:ReadINI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("ReadINI", ex.Message);
            }
        }
예제 #18
0
        private void InitWindow(UILoadState uiState, UIController uiBase, bool open, params object[] args)
        {
            if (AppConfig.IsLogFuncCost || AppConfig.IsSaveCostToFile)
            {
                KProfiler.BeginWatch("UI.Init");
            }
            uiBase.OnInit();
            KWatchResult profilerData = null;

            if (AppConfig.IsLogFuncCost)
            {
                profilerData = KProfiler.EndWatch("UI.Init", string.Concat(uiState.InstanceName, ".OnInit"));
            }
            if (AppConfig.IsSaveCostToFile)
            {
                if (profilerData == null)
                {
                    profilerData = KProfiler.EndWatch("UI.Init", string.Concat(uiState.InstanceName, ".OnInit"));
                }
                LogFileManager.WriteUILog(uiState.InstanceName, LogState.OnInit, profilerData.costTime);
            }
            if (OnInitEvent != null)
            {
                OnInitEvent(uiBase);
            }
            if (open)
            {
                OnOpen(uiState, args);
            }

            if (!open)
            {
                if (!uiState.IsStaticUI)
                {
                    CloseWindow(uiBase.UIName); // Destroy
                    return;
                }
                else
                {
                    if (uiBase.Canvas != null)
                    {
                        uiBase.Canvas.enabled = false;
                    }
                    else
                    {
                        uiBase.gameObject.SetActiveX(false);
                    }
                }
            }

            uiState.OnUIWindowLoadedCallbacks(uiState, uiBase);
        }
예제 #19
0
        public void TestProcessDirectoryFailsNonExistentDirectory()
        {
            string nonExistantPath = System.IO.Path.Combine(
                System.IO.Path.GetTempPath(),
                System.IO.Path.GetRandomFileName());

            Assert.IsFalse(System.IO.Directory.Exists(nonExistantPath));

            var atcsLogFileManager = new LogFileManager(nonExistantPath);

            Assert.ThrowsException <System.IO.DirectoryNotFoundException>(
                () => atcsLogFileManager.ProcessDirectory());
        }
예제 #20
0
파일: Program.cs 프로젝트: Shanksyue/SMAPI
        /// <summary>Construct an instance.</summary>
        /// <param name="writeToConsole">Whether to output log messages to the console.</param>
        /// <param name="logPath">The full file path to which to write log messages.</param>
        internal Program(bool writeToConsole, string logPath)
        {
            // load settings
            this.Settings = JsonConvert.DeserializeObject <SConfig>(File.ReadAllText(Constants.ApiConfigPath));

            // initialise
            this.LogFile = new LogFileManager(logPath);
            this.Monitor = new Monitor("SMAPI", this.ConsoleManager, this.LogFile, this.ExitGameImmediately)
            {
                WriteToConsole = writeToConsole
            };
            this.ModRegistry        = new ModRegistry(this.Settings.ModCompatibility);
            this.DeprecationManager = new DeprecationManager(this.Monitor, this.ModRegistry);
        }
예제 #21
0
        private void OnOpen(UILoadState uiState, params object[] args)
        {
            if (uiState.IsLoading)
            {
                uiState.OpenWhenFinish = true;
                uiState.OpenArgs       = args;
                return;
            }

            UIController uiBase = uiState.UIWindow;

            if (uiBase.Canvas != null && uiBase.Canvas.enabled)
            {
                //已经打开无需再次打开
                return;
            }

            uiBase.BeforeOpen(args);
            //TODO 播放界面出现动画
            uiBase.gameObject.SetActiveX(true);
            SetUIOrder(uiBase);
            string watchKey = null;

            if (AppConfig.IsLogFuncCost || AppConfig.IsSaveCostToFile)
            {
                watchKey = string.Concat(uiBase.UIName, ".OnOpen");
                KProfiler.BeginWatch(watchKey);
            }
            uiBase.OnOpen(args);
            KWatchResult profilerData = null;

            if (AppConfig.IsLogFuncCost)
            {
                profilerData = KProfiler.EndWatch(watchKey);
            }
            if (AppConfig.IsSaveCostToFile)
            {
                if (profilerData == null)
                {
                    profilerData = KProfiler.EndWatch(watchKey, null, false);
                }
                LogFileManager.WriteUILog(uiBase.UIName, LogState.OnOpen, profilerData.costTime);
            }

            if (OnOpenEvent != null)
            {
                OnOpenEvent(uiBase);
            }
        }
예제 #22
0
        public void TestProcessDirectorySucceeds()
        {
            var atcsLogFileManager = new LogFileManager(testDirectory.FullName);

            atcsLogFileManager.ProcessDirectory();

            // After execution of ProcessDirectory on our testDirectory, we
            // should have 1 log file and 3 zip files.

            var logFiles = testDirectory.GetFiles("*.log");
            var zipFiles = testDirectory.GetFiles("*.zip");

            Assert.AreEqual(1, logFiles.Length);
            Assert.AreEqual(3, zipFiles.Length);
        }
예제 #23
0
        public void ArchiveLogFilesTest()
        {
            TestFileSystem FileSystem = CreateDefaultFileSystem();
            TestSystemTime SystemTime = new TestSystemTime(2020, 1, 19, 1, 0, 0, DateTimeKind.Local);

            using LogFileManager Manager = new LogFileManager(FileSystem, SystemTime);

            string BaseFileName = $"{FileLoggerOptions.DefaultLogFileDirectory}{Environment.MachineName}.20200118";

            for (int i = 0; i <= 10; i++)
            {
                string FileName = i == 0
                                        ? BaseFileName + ".log"
                                        : BaseFileName + $".{i}.log";

                TestFileSystem.TestFile?TestFile = FileSystem.FindFile(FileName, true);

                TestFile !.CreatedAtUtc = SystemTime.UtcNow.AddDays(-1);
            }

            FileSystem.FindFile($"{FileLoggerOptions.DefaultLogFileDirectory}SomeRandomFile.txt", true);
            FileSystem.FindFile($"{FileLoggerOptions.DefaultLogFileDirectory}SomeRandomLogFile.log", true);
            FileSystem.FindFile($"{FileLoggerOptions.DefaultLogFileDirectory}SomeOtherMachineName.20200118.log", true);

            using (Stream FullFile = FileSystem.OpenFile($"{FileLoggerOptions.DefaultLogFileDirectory}{Environment.MachineName}.20200119.log", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                FullFile.Write(new byte[1024], 0, 1024);
            }

            LogFile?LogFile = Manager.FindLogFile(
                "AppName",
                "Group",
                () => s_DefaultOptions,
                FileLoggerOptions.DefaultLogFileNamePattern,
                1,
                s_DefaultManagementSchedule);

            Assert.IsNotNull(LogFile);
            Assert.AreEqual($"{Environment.MachineName}.20200119.1.log", LogFile.FinalFileName);

            Assert.AreEqual(16, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileDirectory).Count());
            Assert.AreEqual(0, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileArchiveDirectory).Count());

            Manager.ArchiveLogFiles("AppName", s_DefaultOptions, FileLoggerOptions.DefaultLogFileNamePattern);

            Assert.AreEqual(5, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileDirectory).Count());
            Assert.AreEqual(11, FileSystem.EnumerateFiles(FileLoggerOptions.DefaultLogFileArchiveDirectory).Count());
        }
예제 #24
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (this.fileListBox.SelectedValue == null)
            {
                return;
            }

            this.sCurrentPageKey = this.fileListBox.SelectedValue.ToString();

            if (this.sCurrentPageKey == "")
            {
                return;
            }

            LogFileManager.ExportFile(this.sCurrentPageKey);
        }
예제 #25
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="source">The name of the module which logs messages using this instance.</param>
        /// <param name="ignoreChar">A character which indicates the message should not be intercepted if it appears as the first character of a string written to the console. The character itself is not logged in that case.</param>
        /// <param name="logFile">The log file to which to write messages.</param>
        /// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param>
        /// <param name="isVerbose">Whether verbose logging is enabled. This enables more detailed diagnostic messages than are normally needed.</param>
        /// <param name="getScreenIdForLog">Get the screen ID that should be logged to distinguish between players in split-screen mode, if any.</param>
        public Monitor(string source, char ignoreChar, LogFileManager logFile, ColorSchemeConfig colorConfig, bool isVerbose, Func <int?> getScreenIdForLog)
        {
            // validate
            if (string.IsNullOrWhiteSpace(source))
            {
                throw new ArgumentException("The log source cannot be empty.");
            }

            // initialize
            this.Source            = source;
            this.LogFile           = logFile ?? throw new ArgumentNullException(nameof(logFile), "The log file manager cannot be null.");
            this.ConsoleWriter     = new ColorfulConsoleWriter(Constants.Platform, colorConfig);
            this.IgnoreChar        = ignoreChar;
            this.IsVerbose         = isVerbose;
            this.GetScreenIdForLog = getScreenIdForLog;
        }
예제 #26
0
 public Grapher(LogFileManager Filemanager)
 {
     filemanager = Filemanager;
     DetailForm  = new MomentDetail(filemanager);
     DetailForm.Show();
     DetailForm.BringToFront();
     InitializeComponent();
     Chart1.MouseMove               += new MouseEventHandler(Chart1_MouseMove);
     Chart1.MouseClick              += new MouseEventHandler(Chart1_MouseClick);
     rangecontrol.ValueChanged      += new EventHandler(rangecontrol_ValueChanged);
     textBox1.TextChanged           += new EventHandler(text_Changed);
     textBox2.TextChanged           += new EventHandler(text_Changed);
     rangecontrol.Properties.Maximum = 1000;
     rangecontrol.Properties.Minimum = 0;
     rangecontrol.Value              = new DevExpress.XtraEditors.Repository.TrackBarRange(0, 1000);
 }
예제 #27
0
 private void dataGridViewElement_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
 {
     try
     {
         System.Windows.Forms.ComboBox combo = e.Control as System.Windows.Forms.ComboBox;
         if (null != combo)
         {
             combo.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
             combo.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to create eventhandler for comboboxcell.\n" + ex.Message, "Form_OverlapMass:dataGridViewElement_EditingControlShowing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         LogFileManager.AppendLog("dataGridViewElement_EditingControlShowing", ex.Message);
     }
 }
예제 #28
0
        private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                var currentCell = dataGridViewElement.CurrentCellAddress;
                var sendingCB   = sender as DataGridViewComboBoxEditingControl;
                DataGridViewTextBoxCell cell = (DataGridViewTextBoxCell)dataGridViewElement.Rows[currentCell.Y].Cells["MassId"];
                int selectedIndex            = ((System.Windows.Forms.ComboBox)sender).SelectedIndex;

                int selectedMassId = 0;
                if (null != dataGridViewElement.Rows[currentCell.Y].Tag && selectedIndex != -1)
                {
                    if (selectedIndex == 0) //mass name: <None>
                    {
                        cell.Value = selectedMassId;
                    }
                    else if (selectedIndex > 0)
                    {
                        ElementProperties ep = dataGridViewElement.Rows[currentCell.Y].Tag as ElementProperties;
                        selectedMassId = ep.MassContainers.Keys.ToList()[selectedIndex - 1];
                        cell.Value     = selectedMassId;

                        if (checkBoxHost.Checked)
                        {
                            if (hostMaps.ContainsKey(ep.ElementId))
                            {
                                foreach (int elementId in hostMaps[ep.ElementId].Keys)
                                {
                                    int rowIndex = hostMaps[ep.ElementId][elementId];
                                    DataGridViewCell textCell = dataGridViewElement.Rows[rowIndex].Cells["MassId"];
                                    textCell.Value = selectedMassId;
                                    DataGridViewComboBoxCell comboCell = dataGridViewElement.Rows[rowIndex].Cells["ColumnSelection"] as DataGridViewComboBoxCell;
                                    comboCell.Value = massDictionary[selectedMassId].MassName;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to tag massId on the cell.\n" + ex.Message, "Form_OverlapMass:ComboBox_SelectedIndexChanged", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("ComboBox_SelectedIndexChanged", ex.Message);
            }
        }
예제 #29
0
        private void showElementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                UIDocument       uidoc      = m_app.ActiveUIDocument;
                Document         m_doc      = uidoc.Document;
                List <ElementId> elementIds = new List <ElementId>();

#if RELEASE2013 || RELEASE2014
                SelElementSet newSelection = SelElementSet.Create();

                foreach (DataGridViewRow row in dataGridViewElement.SelectedRows)
                {
                    if (null != row.Tag)
                    {
                        ElementProperties ep        = row.Tag as ElementProperties;
                        ElementId         elementId = new ElementId(ep.ElementId);
                        elementIds.Add(elementId);
                        newSelection.Add(ep.ElementObj);
                    }
                }
                uidoc.ShowElements(elementIds);
                uidoc.Selection.Elements = newSelection;
#elif RELEASE2015 || RELEASE2016
                Selection selection = uidoc.Selection;

                foreach (DataGridViewRow row in dataGridViewElement.SelectedRows)
                {
                    if (null != row.Tag)
                    {
                        ElementProperties ep        = row.Tag as ElementProperties;
                        ElementId         elementId = new ElementId(ep.ElementId);
                        elementIds.Add(elementId);
                    }
                }
                uidoc.ShowElements(elementIds);
                selection.SetElementIds(elementIds);
#endif
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to show elements.\n" + ex.Message, "Form_OverlapMass:buttonDetermine_Click", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogFileManager.AppendLog("showElementToolStripMenuItem_Click", ex.Message);
            }
        }
예제 #30
0
        /// <summary>
        /// 巴斯勒相机
        /// </summary>
        /// <returns></returns>
        public static List <string> GetBaslerCameraListInfo()
        {
            List <string> cameralist = new List <string>();

            try
            {
                List <ICameraInfo> allCameraInfos = CameraFinder.Enumerate();
                foreach (ICameraInfo cameraInfo in allCameraInfos)
                {
                    cameralist.Add(cameraInfo[CameraInfoKey.UserDefinedName]);
                }
            }
            catch (Exception e)
            {
                LogFileManager.Error("Camera", e.ToString());
            }
            return(cameralist);
        }
        public XmlWriterTraceListener(string applicationName, string customLogPath = null, int historyDayCount = 2, bool isDelayedWrite = true, long maxFileSizeInByte = 0)
        {
            CustomLogPath        = customLogPath;
            IsDelayedWrite       = isDelayedWrite;
            HistoryDayCount      = historyDayCount;
            ApplicationName      = applicationName;
            _lastCreationLogDate = DateTime.MinValue;
            MaxFileSizeInByte    = maxFileSizeInByte;


            _logFileManager = new LogFileManager(ApplicationName, BaseRootPath, historyDayCount);

            _logFileManager.CreateNewLogFile(false);
            _lastCreationLogDate = DateTime.Today;

            if (!IsDelayedWrite)
            {
                _taskAppendLogsToDiskWithoutDelayed = Task.Factory.StartNew(token =>
                {
                    var cancellationToken = (CancellationToken)token;

                    while (true)
                    {
                        if (_lines.Count > 0)
                        {
                            WriteLogsToDisk();
                        }
                        else
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                break;
                            }

                            Thread.Sleep(WaitingBeforeWritingLogs);
                        }
                    }
                }, _cancellationToken.Token, _cancellationToken.Token /*, TaskCreationOptions.LongRunning, TaskScheduler.Default*/);
            }
            else
            {
                _timer = new Timer(OnTimerCallback, null, TimerSaveFrequency, TimerSaveFrequency);
            }
        }