Example #1
0
        private void AppendConsoleMsg(object sender, SocStatusEventArgs e, string msg)
        {
            if (this.RichTextBoxLog.InvokeRequired)
            {
                SetThreadSocMsgConsoleCallback d = new SetThreadSocMsgConsoleCallback(AppendConsoleMsg);
                this.Invoke(d, new object[] { sender, e, msg });
            }
            else
            {
                if (e.Status.socMessage != null && e.Status.socMessage.Trim() != "")
                {
                    RichTextBoxLog.AppendText(">" + e.Status.socMessage + "\n");
                }
                if (msg != null && msg.Trim() != "")
                {
                    RichTextBoxLog.AppendText(">" + msg + "\n");
                }

                if (e.Status.exception != null)
                {
                    if (e.Status.exception is SocketException)
                    {
                        RichTextBoxLog.AppendText(string.Format(">Error: {0} : {1}",
                                                                ((SocketException)e.Status.exception).ErrorCode,
                                                                ((SocketException)e.Status.exception).Message));
                    }
                    else
                    {
                        RichTextBoxLog.AppendText(string.Format(">Error: {0}", e.Status.exception.Message));
                    }
                }
                RichTextBoxLog.ScrollToCaret();
            }
        }
Example #2
0
 private void RichTextBoxLogChanged(object sender, SocStatusEventArgs e, string strStatus)
 {
     if (this.RichTextBoxLog.InvokeRequired)
     {
         CallbackRichTextBoxLog d = new CallbackRichTextBoxLog(RichTextBoxLogChanged);
         this.Invoke(d, new object[] { sender, e, strStatus });
     }
     else
     {
         this.RichTextBoxLog.AppendText(">" + strStatus + ":" + e.Status.socMessage + "\n");
         if (e.Status.exception != null)
         {
             if (e.Status.exception is SocketException)
             {
                 RichTextBoxLog.AppendText(string.Format(">Error: {0} : {1}",
                                                         ((SocketException)e.Status.exception).ErrorCode,
                                                         ((SocketException)e.Status.exception).Message) + "\n");
             }
             else
             {
                 this.RichTextBoxLog.AppendText(string.Format(">Error: {0}", e.Status.exception.Message) + "\n");
             }
         }
         this.RichTextBoxLog.ScrollToCaret();
     }
 }
Example #3
0
        private void BuildDecisionTree_Click(object sender, RoutedEventArgs e)
        {
            var dateTimeStart = DateTime.Now;

            ListBoxLog.Items.Add($"{dateTimeStart} Build Starting");
            RichTextBoxLog.AppendText("Build Starting");

            Task.Run(() =>
            {
                Console.WriteLine("build 1");
                decisionTreeController.BuildDecisionTree(DecisionTreeController.DecisionTreeModel, dataController.Samples);
                Console.WriteLine("build 2");
                Dispatcher.Invoke(new Action(() =>
                {
                    var dateTimeEnd = DateTime.Now;

                    ListBoxLog.Items.Add($"{dateTimeEnd} Build Finished: {dateTimeEnd - dateTimeStart}");
                    RichTextBoxLog.AppendText("Build Finished");

                    ListBoxLog.SelectedIndex = ListBoxLog.Items.Count - 1;
                    ListBoxLog.ScrollIntoView(ListBoxLog.SelectedItem);
                }));
            });

            //var program = new ConsoleApp1.Program();
            //Console.WriteLine(program.Run(dataController.Samples, dataController.TestSamples));
            //ListBoxLog.Items.Add(program.Run(dataController.Samples, dataController.TestSamples));
        }
Example #4
0
        //!自动觉醒
        private void ButtonAwake_Click(object sender, EventArgs e)
        {
            //!改变命令状态
            mExcuteState = false;

            //!显示日志
            RichTextBoxLog.Text = RichTextBoxLog.Text + "自动觉醒开始..." + Environment.NewLine;

            //!进入觉醒界面
            Win32API.MouseClick(85, 670, 5);

            //!No.1
            Win32API.MouseClick(250, 350, 5);

            //!觉醒
            int nAwakeTimes = 1; //!统计觉醒次数

            while (!mExcuteState)
            {
                //!显示日志
                RichTextBoxLog.Text = RichTextBoxLog.Text + "第" + nAwakeTimes++.ToString() + "次觉醒..." + Environment.NewLine;

                //!设置滚动位置
                RichTextBoxLog.SelectionStart = RichTextBoxLog.Text.Length;
                RichTextBoxLog.ScrollToCaret();

                //!刷新
                Update();

                //!点击挑战
                Win32API.MouseClick(0950, 500, 10);
                Win32API.MouseClick(1100, 600, 60);

                //!获取奖励
                Win32API.MouseClick(1100, 600, 01);
                Win32API.MouseClick(1100, 600, 01);
                Win32API.MouseClick(1100, 600, 01);
                Win32API.MouseClick(1100, 600, 01);
                Win32API.MouseClick(1100, 600, 10);

                //!停止
                if (Control.MousePosition.X != 1100 && Control.MousePosition.Y != 600)
                {
                    //!停止
                    mExcuteState = true;

                    //!显示日志
                    RichTextBoxLog.Text = RichTextBoxLog.Text + "自动觉醒停止..." + Environment.NewLine;
                    break;
                }
            }

            //!显示日志
            RichTextBoxLog.Text = RichTextBoxLog.Text + "自动觉醒结束..." + Environment.NewLine + Environment.NewLine;
        }
Example #5
0
 private void Log(string text)
 {
     if (RichTextBoxLog.InvokeRequired)
     {
         RichTextBoxLog.Invoke(new LogDel(Log), new object[] { text });
     }
     else
     {
         RichTextBoxLog.AppendText(text + "\n");
     }
 }
Example #6
0
 private void LogInfo(String message, Boolean clear = false)
 {
     if (clear)
     {
         RichTextBoxLog.Text = "";
     }
     RichTextBoxLog.Text           = String.Format("{0}{1} {2}{3}", RichTextBoxLog.Text, DateTime.Now, message, Environment.NewLine);
     RichTextBoxLog.SelectionStart = RichTextBoxLog.Text.Length;
     RichTextBoxLog.ScrollToCaret();
     Update();
 }
Example #7
0
 private void ButtonStart_Click(object sender, EventArgs e)
 {
     try
     {
         RichTextBoxLog.Clear();
         SearchAndReplaceManager.SearchAndReplace(TextBoxFolder.Text, TextBoxFilter.Text, TextBoxSearch.Text, TextBoxReplace.Text, LogAction);
     }
     catch (Exception exception)
     {
         ExceptionDisplayer.ShowException(this, exception);
     }
 }
        private void _log(string what, string message)
        {
            string logString = DateTime.Now.ToString("[yyyy-MM-dd hh:mm:ss::fff]") + " " + what.ToUpper() + ": " + message + "\n";

            System.IO.File.AppendAllText(_loggingName, logString);
            RichTextBoxLog.AppendText(logString);

            RichTextBoxLog.SelectionStart = RichTextBoxLog.Text.Length;
            RichTextBoxLog.ScrollToCaret();

            if (RichTextBoxLog.Text.Length > 40960)
            {
                RichTextBoxLog.Clear();
            }
        }
Example #9
0
 private void LogPacket(byte[] buffer)
 {
     if (RichTextBoxLog.InvokeRequired)
     {
         RichTextBoxLog.Invoke(new LogBufferDel(LogPacket), new object[] { buffer });
     }
     else
     {
         RichTextBoxLog.AppendText("Log Packet: ");
         for (int i = 0; i < buffer.Length; i++)
         {
             RichTextBoxLog.AppendText(buffer[i].ToString("X2") + " ");
         }
         RichTextBoxLog.AppendText("\n");
     }
 }
Example #10
0
 private void LogBuffer(byte[] buffer)
 {
     if (RichTextBoxLog.InvokeRequired)
     {
         RichTextBoxLog.Invoke(new LogBufferDel(LogBuffer), new object[] { buffer });
     }
     else
     {
         if (RichTextBoxLog.Text.Length >= 10000)
             RichTextBoxLog.Clear();
         RichTextBoxLog.AppendText("Unknown Packet: ");
         for (int i = 0; i < buffer.Length; i++)
         {
             RichTextBoxLog.AppendText(buffer[i].ToString("X2") + " ");
         }
         RichTextBoxLog.AppendText("\n");
     }
 }
Example #11
0
        private void PrintLog(LogEventArgs e)
        {
            if (!Dispatcher.CheckAccess()) // CheckAccess returns true if you're on the dispatcher thread
            {
                Dispatcher.Invoke(new PrintLogInvoker(PrintLog), e);
                return;
            }

            BrushConverter bc = new BrushConverter();
            TextRange      tr = new TextRange(RichTextBoxLog.Document.ContentEnd, RichTextBoxLog.Document.ContentEnd);

            tr.Text = string.Format("{0} - {1}\r", DateTime.Now.ToString("HH:mm:ss.fff"), e.Text);
            object value = null;

            switch (e.Type)
            {
            case LogType.Info:
                value = bc.ConvertFromString(Colors.White.ToString());
                break;

            case LogType.Error:
                value = bc.ConvertFromString(Colors.Red.ToString());
                break;

            case LogType.Warning:
                value = bc.ConvertFromString(Colors.Orange.ToString());
                break;

            case LogType.Debug:
                value = bc.ConvertFromString(Colors.LightGreen.ToString());
                break;

            default:
                break;
            }
            try
            {
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, value);
            }
            catch (FormatException) { }
            RichTextBoxLog.ScrollToEnd();
        }
Example #12
0
 private void ButtonStart_Click(object sender, EventArgs e)
 {
     try
     {
         if (String.IsNullOrWhiteSpace(TextBoxFile.Text))
         {
             return;
         }
         RichTextBoxLog.Clear();
         XDocument document = Parser.ParseReference(LogAction);
         if (File.Exists(TextBoxFile.Text))
         {
             File.Delete(TextBoxFile.Text);
         }
         document.Save(TextBoxFile.Text);
     }
     catch (Exception exception)
     {
         ExceptionDisplayer.ShowException(this, exception);
     }
 }
Example #13
0
 private void RichTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     RichTextBoxLog.ScrollToEnd();
 }
 private void _logLn()
 {
     RichTextBoxLog.AppendText("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
     RichTextBoxLog.SelectionStart = RichTextBoxLog.Text.Length;
     RichTextBoxLog.ScrollToCaret();
 }
        private void AddTab(Int64 taskID, string taskName, string taskTempName)
        {
            if (tabTaskRunLog.TabPages.ContainsKey(taskTempName))
            {
                this.tabTaskRunLog.SelectedTab = tabTaskRunLog.TabPages[taskTempName];
                return;
            }
            TabPage tabPage = new TabPage();

            tabPage.Name = taskTempName;
            tabPage.Tag  = taskTempName;
            tabPage.Text = taskName;

            SplitContainer sc = new SplitContainer();

            sc.Name        = "sCon" + taskID.ToString();
            sc.Orientation = Orientation.Horizontal;
            sc.Dock        = DockStyle.Fill;

            dgvRunTaskList = new DataGridView();
            dgvRunTaskList.AllowUserToAddRows  = false;
            dgvRunTaskList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            dgvRunTaskList.Dock = DockStyle.Fill;

            ContextMenuStrip menu = new ContextMenuStrip();

            menu.Items.Add("读取数据");
            menu.Items.Add("导出文本数据");
            menu.Items.Add("导出Excel");
            menu.ItemClicked += new ToolStripItemClickedEventHandler(delegate(object sender, ToolStripItemClickedEventArgs e)
            {
                if (e.ClickedItem.Text == "读取数据")
                {
                    if (taskEntity.GaterherState != EnumGloabParas.EnumThreadState.Run)
                    {
                        ReadDataSource();
                    }
                    return;
                }
                if (taskEntity.GaterherState != EnumGloabParas.EnumThreadState.Suspended)
                {
                    if (e_ExportData != null)
                    {
                        e_ExportData(e.ClickedItem.Text == "导出文本数据" ? 1 : 2, m_DataTable);
                    }
                }
                else
                {
                    MessageBoxHelper.ShowError("请先暂停任务后才能进导出!");
                }
            });
            dgvRunTaskList.ContextMenuStrip = menu;
            sc.Panel1.Controls.Add(dgvRunTaskList);
            txtLog             = new RichTextBoxLog();
            txtLog.Name        = "tLog" + taskID.ToString();
            txtLog.ReadOnly    = true;
            txtLog.BorderStyle = BorderStyle.FixedSingle;
            txtLog.BackColor   = Color.White;
            txtLog.DetectUrls  = false;
            txtLog.WordWrap    = false;
            txtLog.Dock        = DockStyle.Fill;
            sc.Panel2.Controls.Add(txtLog);
            tabPage.Controls.Add(sc);
            tabTaskRunLog.TabPages.Add(tabPage);
            this.tabTaskRunLog.SelectedTab = tabPage;
        }
Example #16
0
 private void BottonLogErase_Click(object sender, EventArgs e)
 {
     RichTextBoxLog.Clear();
 }
Example #17
0
        private void Plot2()
        {
            belaGraphControl2.ClearDataBuffer();

            Font myFont = new Font(ComboBoxFonts.SelectedValue.ToString(), (float)DoubleUpDownFontSize.Value);

            belaGraphControl2.Plot(BelaGraph.BackgroundOption.None, false, true, myFont);

            //Lets clone our sparse matrix
            SparseMatrix vennSparseMatrixCache = PatternTools.ObjectCopier.Clone(plp.MySparseMatrix);


            List <IntersectionResultAnalysis> VennProbabilityDictionary = new List <IntersectionResultAnalysis>();

            //Qaulity filterS
            if ((bool)RadioButtonMinNoReplicates.IsChecked)
            {
                //BY NUMBER OF REPLICATES
                vennSparseMatrixCache.EliminateIDsThatAreNotPresentAtLeastInXReplicates((int)IntegerUpDownMinNoReplicates.Value, (bool)RadioButtonAllClasses.IsChecked);
            }
            else
            {
                //by Probability
                PatternTools.VennProbability.VennProbabilityCalculator vpc = new PatternTools.VennProbability.VennProbabilityCalculator(plp.MySparseMatrix);
                VennProbabilityDictionary = vpc.GenerateProbabilisticDictionary(4);

                string report = PatternTools.VennProbability.ResultPrinter.PrintReport(VennProbabilityDictionary, new List <string> {
                    "Low", "Medium", "High", "Very High"
                });
                RichTextBoxLog.Document.Blocks.Clear();
                RichTextBoxLog.AppendText(report);
            }

            venn = new BelaGraph.VennManager(vennSparseMatrixCache);

            //--------------------------------


            //If we are working with probabilities, we should apply a correction
            //The venn diagram with probability only works for two classes

            if ((bool)RadioButtonFilteringProbability.IsChecked)
            {
                //We need to find the ones unique for class 1 and the ones unique for class 2.
                //If they are below the probability scores, we need to include them in the other class
                //this needs to be done using the dvs

                //Step 1, the uniques from each group
                List <List <int> > inLabel = new List <List <int> >();
                inLabel.Add(new List <int>());
                inLabel.Add(new List <int>());

                inLabel[0].AddRange(venn.VennDic[1]);
                inLabel[1].AddRange(venn.VennDic[2]);


                List <int> intersection = inLabel[0].Intersect(inLabel[1]).ToList();
                inLabel[0].RemoveAll(a => intersection.Contains(a));
                inLabel[1].RemoveAll(a => intersection.Contains(a));


                //Find the ones that fail the probability

                for (int i = 1; i <= 2; i++)
                {
                    List <int> newIntersectionClass = new List <int>();   //We will put all the new unique guys in here
                    foreach (int dim in inLabel[i - 1])
                    {
                        if (!checkConfidence(dim, i, (double)DoubleUpDownProbability.Value, VennProbabilityDictionary))
                        {
                            newIntersectionClass.Add(dim);
                        }
                    }

                    foreach (int k in newIntersectionClass)
                    {
                        venn.VennDic[i].Remove(k);
                        vennSparseMatrixCache.eliminateDim(k, 0, true);
                    }
                }
            }

            //This is where we find the unique proteins
            List <BelaGraph.DataVector> dvs = venn.GetDataVectors();


            //Plot
            ButtonPlot.Content = "Please wait...";

            belaGraphControl2.ClearDataBuffer();

            //Lets save this matrix so we can do reports latter
            belaGraphControl2.vennSparseMatrixCache = vennSparseMatrixCache;

            belaGraphControl2.Title = TextBoxTitle.Text;
            belaGraphControl2.VennRadiusOfLargestCircleCorrectionFactor = (double)DoubleUpDownScaleFactor.Value;

            if (lables.Count <= 3)
            {
                for (int i = 0; i < dvs.Count; i++)
                {
                    System.Windows.Media.Color c1 = new System.Windows.Media.Color();

                    if (i == 0)
                    {
                        c1 = Colors.Green;
                    }
                    else if (i == 1)
                    {
                        c1 = Colors.Yellow;
                    }
                    else if (i == 2)
                    {
                        c1 = Colors.Blue;
                    }
                    System.Windows.Media.Color           c2 = System.Windows.Media.Color.FromArgb(c1.A, c1.R, c1.G, c1.B);
                    System.Windows.Media.SolidColorBrush sb = new System.Windows.Media.SolidColorBrush(c2);
                    sb.Opacity     = double.Parse(DoubleUpDownTransparency.Value.ToString());
                    dvs[i].MyBrush = sb;
                    belaGraphControl2.AddDataVector(dvs[i]);
                }
                BelaGraph.BackgroundOption bg = BelaGraph.BackgroundOption.None;
                belaGraphControl2.Plot(bg, false, true, myFont);
            }

            //Fill out our table;
            DataGridPairWise.Columns.Clear();

            DataTable dt = new DataTable();

            //Add the columns

            //Add the info


            for (int i = 0; i < dvs.Count; i++)
            {
                dt.Columns.Add(plp.MySparseMatrix.ClassDescriptionDictionary[int.Parse(dvs[i].Name)]);
            }

            for (int i = 0; i < dvs.Count; i++)
            {
                dt.Rows.Add(dvs[i].ThePoints.Select(a => a.Y.ToString()).ToArray());
            }

            DataGridPairWise.ItemsSource = dt.DefaultView;

            if ((bool)CheckBoxPlotLabels.IsChecked && lables.Count <= 3)
            {
                try
                {
                    belaGraphControl2.PlotVennLabels(venn.VennDic, TextBoxC1Name.Text, TextBoxC2Name.Text, TextBoxC3Name.Text, true, (bool)CheckBoxDetailed.IsChecked, plp.MyIndex, myFont);
                }
                catch (Exception e2)
                {
                    MessageBox.Show("Make sure your sparse matrix file is labeled correctly.  It should contain class 1, 2, and, 3" + "\n" + e2.Message);
                }
            }

            ButtonPlot.Content = "Plot";
        }
Example #18
0
 private void LogText(string text)
 {
     RichTextBoxLog.AppendText(String.Format(DateTime.Now.ToString() + " {0}" + Environment.NewLine, text));
 }
Example #19
0
        /**
         * 1. Cli A Send File Noti , Wait for Ack
         * 2. Svr B Run FTPListener
         * 3. Svr B Send Info | Nack
         * 6. Cli A Run FTPClient
         * 7. Cli A Done
         * 8. Cli A BYE
         */

        private void AppendConsoleMsg(string msg)
        {
            RichTextBoxLog.AppendText(msg + "\n");
            RichTextBoxLog.ScrollToCaret();
        }