コード例 #1
0
        public void Start()
        {
            if (systemManager == null)
            {
                throw new NullReferenceException("Error: BarcodeSystemController has not been assigned to BarCodeSystemUI instance!");
            }

            isRunning = true;

            systemManager.UserBalanceWarning += DisplayUserBalanceWarning;

            do
            {
                ShowProducts(systemManager.ActiveProducts);

                Console.Write("> ");

                string command = Console.ReadLine();
                CommandEntered?.Invoke(command);

                DisplayMessage("\nPress any key to continue.");

                Console.ReadKey();
                Console.Clear();
            } while (isRunning);
        }
コード例 #2
0
        private void tsmiKruskalAlgorithm_Click(object sender, EventArgs e)
        {
            if (_field.Status == false)
            {
                return;
            }
            var args = new MSTCommandArgs(500);

            new Thread(() =>
            {
                CommandEntered?.Invoke(this, args);
                if (args.SuccsessOut)
                {
                    StringBuilder mst = new StringBuilder();
                    args.MstOut.ForEach(str => mst.AppendLine(str));
                    mst.AppendLine($"Суммарный вес: {args.SummWeightOut}");
                    ResultForm result = new ResultForm(args.TaskNameOut, args.AlgorithmNameOut, mst.ToString());
                    BeginInvoke((MethodInvoker)(() =>
                    {
                        result.Owner = this;
                        result.ShowDialog();
                        if (result.Stream != null)
                        {
                            mst.Clear();
                            mst.AppendLine(result.TaskName);
                            mst.AppendLine(result.AlgorithmName);
                            mst.AppendLine(result.ResultText);
                            CommandEntered?.Invoke(this, new SaveAlgorithmResultCommandArgs(result.Stream, mst.ToString()));
                        }
                    }));
                }
            }).Start();
        }
コード例 #3
0
        public void Interactive()
        {
            string lastline = null;
            bool   quit;

            do
            {
                Console.Write(">");
                string line = Console.ReadLine().Trim();
                if (line.Length == 0)
                {
                    line = lastline;
                }
                bool processed = false;
                quit = false;
                if (CommandEntered != null)
                {
                    CommandEntered.Invoke(line, ref processed, ref quit);
                }
                if (processed)
                {
                    lastline = line;
                }
                else
                {
                    lastline = "";
                }
            } while (!quit);
        }
コード例 #4
0
        private void tsBtnAddEdge_Click(object sender, EventArgs e)
        {
            if (sourceModel == null || stockModel == null ||
                sourceModel.Key == stockModel.Key)
            {
                return;
            }

            string weight = null;

            if (_field.IsWeighted)
            {
                SetWeightForm window = new SetWeightForm();
                window.Owner = this;
                window.ShowDialog();
                if (window.Ok)
                {
                    weight = window.Weight;
                }
            }
            AEdgeModel edgeModel;

            if (_field.IsOrgraph)
            {
                edgeModel = new OrientEdgeModel(sourceModel, stockModel, weight);
            }
            else
            {
                edgeModel = new NonOrientEdgeModel(sourceModel, stockModel, weight);
            }

            CommandEntered?.Invoke(this, new AddModelCommandArgs(edgeModel));
            _field.UnmarkGraphModels();
        }
コード例 #5
0
ファイル: StregsystemCLI.cs プロジェクト: FlunkyHD/sem3
        private void HandleInput()
        {
            string command = Console.ReadLine();

            Console.Clear();
            CommandEntered?.Invoke(command);
        }
コード例 #6
0
 private void subDetoursBtnDFS_Click(object sender, EventArgs e)
 {
     toolStripStatusLabel.Text = "Выполяется алгоритм обхода в глубину";
     _field.UnmarkGraphModels();
     new Thread(() =>
                CommandEntered?.Invoke(this, new DFScommandArgs(sourceModel))).Start();
 }
コード例 #7
0
ファイル: CLI.cs プロジェクト: NatalieMark/RecommendingSystem
        public void ShutDown()
        {
            _running = false;
            string command = Console.ReadLine();

            CommandEntered?.Invoke(command);
            Console.ReadLine();
        }
コード例 #8
0
 private void subShortcutBtnBFS_Click(object sender, EventArgs e)
 {
     Text += " - Выполяется алгоритм нахождение кратчайшего пути с помошью построение родительского дерева";
     new Thread(() =>
     {
         CommandEntered?.Invoke(this, new ShortcutBFSCommandArgs(sourceModel, stockModel));
     }).Start();
 }
コード例 #9
0
        private void HandleInput()
        {
            Console.WriteLine("Enter Command:");
            string command = Console.ReadLine();

            Console.Clear();
            CommandEntered?.Invoke(command);
        }
コード例 #10
0
 private void tsmiFordBellmanAlgorithm_Click(object sender, EventArgs e)
 {
     if (_field.Status == false)
     {
         return;
     }
     if (_field.MarkedVertexModelCount == 2)
     {
         SetWeightForm form = new SetWeightForm("Укажите макс длину L", "Найти");
         form.Owner = this;
         form.ShowDialog();
         if (!form.Ok)
         {
             return;
         }
         bool succsess = int.TryParse(form.Weight, out var l);
         if (!succsess)
         {
             PostErrorMessage("Некорректное число L");
             return;
         }
         new Thread(() =>
         {
             var args = new WayNoMoreThenLCommandArgs(sourceModel, stockModel, l);
             CommandEntered.Invoke(this, args);
             if (args.SuccsessOut)
             {
                 if (!args.Exist)
                 {
                     PostMessage($"Пути не больше {l} не существуют!!");
                 }
                 else
                 {
                     StringBuilder sb = new StringBuilder();
                     args.OutWays.ForEach(w => sb.AppendLine(w));
                     ResultForm resform = new ResultForm(args.TaskNameOut, args.AlgorithmNameOut, sb.ToString());
                     BeginInvoke((MethodInvoker)(() =>
                     {
                         resform.Owner = this;
                         resform.ShowDialog();
                         if (resform.Stream != null)
                         {
                             sb.Clear();
                             sb.AppendLine(resform.TaskName);
                             sb.AppendLine(resform.AlgorithmName);
                             sb.AppendLine(resform.ResultText);
                             CommandEntered?.Invoke(this, new SaveAlgorithmResultCommandArgs(resform.Stream, sb.ToString()));
                         }
                     }));
                 }
             }
         }).Start();
     }
     else
     {
         PostWarningMessage("Надо вбрать две вершини!!!");
     }
 }
コード例 #11
0
ファイル: CLI.cs プロジェクト: NatalieMark/RecommendingSystem
 public void Start()
 {
     while (_running)
     {
         PrintHello();
         string command = Console.ReadLine();
         CommandEntered?.Invoke(command);
     }
 }
コード例 #12
0
        private void tsBtnDeleteGraph_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(this, "Вы действительно хотите безвозвратно удалить этот граф?", "Удаление Графа", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                CommandEntered?.Invoke(null, new ACommandArgs(nameof(RemoveGraphCommand)));
            }
        }
コード例 #13
0
        private void btnSaveAdjList_Click(object sender, EventArgs e)
        {
            var window = new StoredGraphNameForm();

            window.Owner = this;
            window.ShowDialog();
            if (window.Ok)
            {
                CommandEntered?.Invoke(this, new AddCurrentGraphInStoredGraphsCommandArgs(window.ListName));
            }
        }
コード例 #14
0
        private void tsBtnCrtGraph_Click(object sender, EventArgs e)
        {
            CreateGraphForm window = new CreateGraphForm();

            window.Owner = this;
            window.ShowDialog();
            if (window.Ok)
            {
                oriented = window.Oriented;
                weighted = window.Weighted;
                CommandEntered?.Invoke(this, new CreateGraphCommandArgs(oriented, weighted));
            }
        }
コード例 #15
0
 private void tsmiNPeriohery_Click(object sender, EventArgs e)
 {
     if (_field.Status == false)
     {
         return;
     }
     if (_field.MarkedVertexModelCount == 1)
     {
         SetWeightForm form = new SetWeightForm("Укажите N", "Найти");
         form.Owner = this;
         form.ShowDialog();
         if (!form.Ok)
         {
             return;
         }
         bool succsess = int.TryParse(form.Weight, out var N);
         if (!succsess)
         {
             PostErrorMessage("Некорректное число N");
             return;
         }
         new Thread(() =>
         {
             var args = new NPeripheryCommandArgs(sourceModel, N);
             CommandEntered.Invoke(this, args);
             if (args.SuccsessOut)
             {
                 StringBuilder sb = new StringBuilder();
                 args.NPeripheryOut.ForEach(w => sb.AppendLine(w));
                 ResultForm resform = new ResultForm(args.TaskNameOut, args.AlgorithmNameOut, sb.ToString());
                 BeginInvoke((MethodInvoker)(() =>
                 {
                     resform.Owner = this;
                     resform.ShowDialog();
                     if (resform.Stream != null)
                     {
                         sb.Clear();
                         sb.AppendLine(resform.TaskName);
                         sb.AppendLine(resform.AlgorithmName);
                         sb.AppendLine(resform.ResultText);
                         CommandEntered?.Invoke(this, new SaveAlgorithmResultCommandArgs(resform.Stream, sb.ToString()));
                     }
                 }));
             }
         }).Start();
     }
     else
     {
         PostWarningMessage("Надо вбрать одну вершину!!!");
     }
 }
コード例 #16
0
 private void tsmiPowVertex_Click(object sender, EventArgs e)
 {
     if (_field.MarkedVertexModelCount == 1)
     {
         HalfLifeDegreeCommandArgs args = new HalfLifeDegreeCommandArgs(sourceModel);
         CommandEntered?.Invoke(this, args);
         string halfWay = _field.IsOrgraph ? "полуисхода" : "";
         PostMessage($"Степень {halfWay} вершины {sourceModel.VertexStr} равно {args.OutHalfLifeDegree}");
     }
     else
     {
         PostWarningMessage("Отметьте одну и только одну вершину !!!");
     }
 }
コード例 #17
0
        public void Start()
        {
            while (running)
            {
                Stregsystem.UserBalanceWarning += DisplayBalanceWarning;
                DisplayProducts(Stregsystem.ActiveProducts);
                var command = Console.ReadLine();
                CommandEntered?.Invoke(command);


                Console.ReadKey();
                Console.Clear();
            }
        }
コード例 #18
0
        protected override bool ProcessCmdKey(ref Message m, Keys keyData)
        {
            if (keyData == Keys.Enter && Text.Trim().Length > 0)
            {
                string cmd = Text.Trim();
                mCommandHistory.Add(cmd);
                Clear();
                mHistoryIndex = mCommandHistory.Count;

                CommandEntered?.Invoke(cmd);

                return(true);
            }

            if (keyData == Keys.Up)
            {
                if (mHistoryIndex > 0)
                {
                    mHistoryIndex--;
                }

                if (mHistoryIndex >= 0 && mHistoryIndex < mCommandHistory.Count)
                {
                    Text            = mCommandHistory[mHistoryIndex];
                    SelectionStart  = Text.Length;
                    SelectionLength = 0;
                }

                return(true);
            }
            if (keyData == Keys.Down)
            {
                if (mHistoryIndex < mCommandHistory.Count)
                {
                    mHistoryIndex++;
                }

                if (mHistoryIndex >= 0 && mHistoryIndex < mCommandHistory.Count)
                {
                    Text            = mCommandHistory[mHistoryIndex];
                    SelectionStart  = Text.Length;
                    SelectionLength = 0;
                }

                return(true);
            }

            return(base.ProcessCmdKey(ref m, keyData));
        }
コード例 #19
0
ファイル: MainForm.cs プロジェクト: geg-antonyan/VisualGraph
        private void MainForm_MouseUp(object sender, MouseEventArgs e)
        {
            vec2 pos = new vec2(e.X, e.Y);

            if (mouseDownFL && lastVertexPos != null && middlePos != null)
            {
                vec2 helpVector = new vec2(min);
                Clip.RectangleClip(ref helpVector, ref pos, min, max);
                CommandEntered?.Invoke(this, new MoveVertexModelCommandArgs(middlePos, lastVertexPos, selectedKey));
                selectedKey   = null;
                lastVertexPos = null;
                _field.UnmarkGraphModels();
            }
            mouseDownFL = false;
        }
コード例 #20
0
 private void DrawCLI()
 {
     Console.Clear();
     Console.WriteLine("┌────┬─────────────────────────────────────┬──────────┐");
     foreach (var product in _lineSystem.ActiveProducts)
     {
         Console.WriteLine(product);
     }
     Console.WriteLine("└────┴─────────────────────────────────────┴──────────┘");
     Console.WriteLine();
     Console.WriteLine(_cliInfoMessage + _userBalanceWarning);
     Console.Write("Quickbuy: ");
     string enteredCommand = Console.ReadLine();
     _userBalanceWarning = string.Empty;
     if (enteredCommand != string.Empty) CommandEntered?.Invoke(this, enteredCommand.Trim());
 }
コード例 #21
0
 private void tsbtnOpen_Click(object sender, EventArgs e)
 {
     try
     {
         if (openGraphFileDialog.ShowDialog() == DialogResult.OK)
         {
             using (Stream stream = openGraphFileDialog.OpenFile())
             {
                 CommandEntered?.Invoke(this, new OpenGraphInFileCommandArgs(stream));
             }
         }
     }
     catch (Exception ex)
     {
         PostErrorMessage(ex.Message);
     }
 }
コード例 #22
0
        private void btnRemoveAdjList_Click(object sender, EventArgs e)
        {
            int count;

            if ((count = listBoxAdjList.SelectedItems.Count) == 0)
            {
                return;
            }
            string[] names = new string[count];
            int      i     = 0;

            foreach (var elem in listBoxAdjList.SelectedItems)
            {
                names[i++] = (string)elem;
            }
            CommandEntered?.Invoke(this, new RemoveStoredGraphCommandArgs(names));
        }
コード例 #23
0
 private void tsmiDijkstraAlgorithm_Click(object sender, EventArgs e)
 {
     if (_field.Status == false)
     {
         return;
     }
     new Thread(() =>
     {
         DijkstraCommandArgs args = null;
         if (_field.MarkedVertexModelCount == 1)
         {
             args = new DijkstraCommandArgs(sourceModel);
             CommandEntered.Invoke(this, args);
             if (args.SuccsessOut)
             {
                 if (args.OutWays.Count == 0)
                 {
                     PostMessage("Пути к данной вершини отсутсвуют!!!");
                 }
                 else
                 {
                     StringBuilder sb = new StringBuilder();
                     args.OutWays.ForEach(w => sb.AppendLine(w));
                     ResultForm resform = new ResultForm(args.TaskNameOut, args.AlgorithmNameOut, sb.ToString());
                     BeginInvoke((MethodInvoker)(() =>
                     {
                         resform.Owner = this;
                         resform.ShowDialog();
                         if (resform.Stream != null)
                         {
                             sb.Clear();
                             sb.AppendLine(resform.TaskName);
                             sb.AppendLine(resform.AlgorithmName);
                             sb.AppendLine(resform.ResultText);
                             CommandEntered?.Invoke(this, new SaveAlgorithmResultCommandArgs(resform.Stream, sb.ToString()));
                         }
                     }));
                 }
             }
         }
         else
         {
             PostWarningMessage("Надо вбрать одну вершину!!!");
         }
     }).Start();
 }
コード例 #24
0
 private void tsbtnSaveGraph_Click(object sender, EventArgs e)
 {
     try
     {
         if (saveGraphFileDialog.ShowDialog() == DialogResult.OK)
         {
             using (Stream stream = saveGraphFileDialog.OpenFile())
             {
                 CommandEntered?.Invoke(this, new SaveGraphToFileCommandArgs(stream));
                 PostMessage("Граф успешно сохранен");
             }
         }
     }
     catch (Exception ex)
     {
         PostErrorMessage(ex.Message);
     }
 }
コード例 #25
0
        public void Start()
        {
            Console.SetWindowSize(idStrLength + productStrLength + priceStrLength + 10, windowHeight);
            DrawMenu();
            stayAlive = true;

            while (stayAlive)
            {
                try
                {
                    CommandEntered?.Invoke(Console.ReadLine());
                }
                catch (Exception ex)
                {
                    DrawMenu();
                    Debug.WriteLine(ex);
                }
            }
        }
コード例 #26
0
 private void tsmiEdmondsKarp_Click(object sender, EventArgs e)
 {
     if (_field.Status == false)
     {
         return;
     }
     if (_field.MarkedVertexModelCount == 2)
     {
         new Thread(() =>
         {
             try
             {
                 var args = new EdmondsKarpCommandArgs(sourceModel, stockModel);
                 CommandEntered.Invoke(this, args);
                 if (args.SuccsessOut)
                 {
                     ResultForm resform = new ResultForm(args.TaskNameOut, args.AlgorithmNameOut, args.MaxFlowOut.ToString());
                     BeginInvoke((MethodInvoker)(() =>
                     {
                         resform.Owner = this;
                         resform.ShowDialog();
                         if (resform.Stream != null)
                         {
                             StringBuilder sb = new StringBuilder();
                             sb.AppendLine(resform.TaskName);
                             sb.AppendLine(resform.AlgorithmName);
                             sb.AppendLine(resform.ResultText);
                             CommandEntered?.Invoke(this, new SaveAlgorithmResultCommandArgs(resform.Stream, sb.ToString()));
                         }
                     }));
                 }
             }
             catch (Exception ex)
             {
                 PostErrorMessage(ex.Message);
             }
         }).Start();
     }
     else
     {
         PostWarningMessage("Надо вбрать две вершини!!!");
     }
 }
コード例 #27
0
        private void tsmiConnectedComponents_Click(object sender, EventArgs e)
        {
            if (_field.Status == false)
            {
                return;
            }
            new Thread(() =>
            {
                var args = new ConnectedComponentsCommandArgs();
                CommandEntered?.Invoke(this, args);
                StringBuilder components = new StringBuilder();
                components.AppendLine($"Алгоритм: \"{args.AlgorithmNameOut}\"");
                for (int i = 0; i < args.ComponentsOut.Count; i++)
                {
                    components.Append($"Компонента {i + 1}: ");
                    args.ComponentsOut[i].ForEach(v => components.Append($"{v}, "));
                    components.Append("\r\n");
                }

                MessageBox.Show(components.ToString(), args.ConnectedTypeOut, MessageBoxButtons.OK, MessageBoxIcon.None);
            }).Start();
        }
コード例 #28
0
        private void btnUnion_Click(object sender, EventArgs e)
        {
            int count;

            if ((count = listBoxAdjList.SelectedItems.Count) == 0)
            {
                return;
            }
            string[] names = new string[count];
            int      i     = 0;

            foreach (var elem in listBoxAdjList.SelectedItems)
            {
                names[i++] = (string)elem;
            }
            var window = new StoredGraphNameForm();

            window.Owner = this;
            window.ShowDialog();
            if (window.Ok)
            {
                CommandEntered?.Invoke(this, new GraphUnionCommandArgs(names, window.ListName));
            }
        }
コード例 #29
0
ファイル: ShellCLI.cs プロジェクト: CasperKjaerhus/SAL
 private void GetInput()
 {
     CommandEntered?.Invoke(Console.ReadLine());
 }
コード例 #30
0
 protected virtual void OnCommandEntered(string command)
 {
     CommandEntered?.Invoke(this, command);
 }