private void InitToolBarCommands()
        {
            #region Первый этап
            #region Добавление рёбер
            var phase1AddEdgeCommand = new ToolBarToggleCommand(
                () =>
            {
                IsMouseVerticesMovingEnabled = false;
                IsEgesAddingEnabled          = true;
                _state = State.EdgesAdding;
            },
                () =>
            {
                IsMouseVerticesMovingEnabled = true;
                IsEgesAddingEnabled          = false;
                _state = State.Nothing;
            },
                () => _state == State.Nothing,
                () => true
                )
            {
                Image       = new BitmapImage(GetImageUri("Arrow.png")),
                Description = Strings.Strings_RU.buttonEdges
            };
            #endregion

            #region Завершить этап
            var allSubgraphs = new ObservableCollection <IGraph>();

            var phase1Command = new ToolBarInstantCommand(
                () =>
            {
                var solve = true;
                var gp    = new GraphPrinter();
                UserActionsManager.RegisterInfo(Strings.Strings_RU.stage1Check + gp.GraphToString(CurrentGraph));
                CurrentGraph.Vertices.ForEach(v1 =>
                                              CurrentGraph.Vertices.ForEach(v2 =>
                {
                    solve = solve && (v1.Equals(v2) || (CurrentGraph[v1, v2] == null ^
                                                        GivenGraph[
                                                            GivenGraph.Vertices.Single(v1.Equals),
                                                            GivenGraph.Vertices.Single(v2.Equals)] == null
                                                        ));
                }
                                                                            ));
                if (solve)
                {
                    UserActionsManager.RegisterInfo(Strings.Strings_RU.stage1Done);
                    GivenGraph   = CurrentGraph;
                    CurrentGraph = new UndirectedGraph();

                    Phase1ToolBarVisibility = Visibility.Collapsed;
                    Phase2ToolBarVisibility = Visibility.Visible;
                    L1 = Strings.Strings_RU.subgraph;

                    FindAllSubgraphs(GivenGraph, 0, GivenGraph.Vertices.ToList(), allSubgraphs);

                    new SimpleDialog("Справка", Strings.Strings_RU.stage2Help).Show();
                }
                else
                {
                    UserActionsManager.RegisterMistake(Strings.Strings_RU.stage1Mistake1, 10);
                }
            },
                () => _state == State.Nothing
                )
            {
                Image       = new BitmapImage(GetImageUri("Check.png")),
                Description = Strings.Strings_RU.stage1DoneButtonDisc
            };
            #endregion

            #region Справка
            var phase1HelpCommand = new ToolBarInstantCommand(
                () =>
            {
                new SimpleDialog("Справка", Strings.Strings_RU.stage1Help).Show();
            },
                () => _state == State.Nothing
                )
            {
                Description = Strings.Strings_RU.buttonHelp,
                Image       = new BitmapImage(GetImageUri("Info.png"))
            };
            #endregion

            #region Молния
            var thunderbolt1 = new ToolBarInstantCommand(
                () =>
            {
                UserActionsManager.RegisterInfo(Strings.Strings_RU.stage1ThunderCall);
                CurrentGraph.Vertices.ForEach(v1 =>
                                              CurrentGraph.Vertices.ForEach(v2 =>
                {
                    if (!v1.Equals(v2) && CurrentGraph[v1, v2] == null && GivenGraph[
                            GivenGraph.Vertices.Single(v1.Equals),
                            GivenGraph.Vertices.Single(v2.Equals)] == null)
                    {
                        CurrentGraph.AddEdge(new UndirectedEdge((Vertex)v1, (Vertex)v2));
                    }
                    if (!v1.Equals(v2) && CurrentGraph[v1, v2] != null && GivenGraph[
                            GivenGraph.Vertices.Single(v1.Equals),
                            GivenGraph.Vertices.Single(v2.Equals)] != null)
                    {
                        CurrentGraph.RemoveEdge(CurrentGraph[v1, v2]);
                    }
                }
                                                                            ));
            },
                () => _state == State.Nothing
                )
            {
                Description = "Молния",
                Image       = new BitmapImage(GetImageUri("thunder.png"))
            };
            #endregion
            #endregion

            #region Второй этап
            #region Добавление вершин

            var vertexDialogCommand = new ToolBarInstantCommand(
                () =>
            {
                var dialog = new VertexDialog((UndirectedGraph)CurrentGraph, GivenGraph.Vertices);
                dialog.Show();
                dialog.Closed += (sender, args) =>
                {
                    var buf      = CurrentGraph;
                    CurrentGraph = null;
                    CurrentGraph = buf;
                };
            },
                () => _state == State.Nothing)
            {
                Image       = new BitmapImage(GetImageUri("Vertexes.png")),
                Description = Strings.Strings_RU.buttonVertexDialog
            };
            #endregion

            #region Добавление рёбер
            var phase2AddEdgeCommand = new ToolBarToggleCommand(
                () =>
            {
                IsMouseVerticesMovingEnabled = false;
                IsEgesAddingEnabled          = true;
                _state = State.EdgesAdding;
            },
                () =>
            {
                IsMouseVerticesMovingEnabled = true;
                IsEgesAddingEnabled          = false;
                _state = State.Nothing;
            },
                () => _state == State.Nothing,
                () => true
                )
            {
                Image       = new BitmapImage(GetImageUri("Arrow.png")),
                Description = Strings.Strings_RU.buttonEdges
            };
            #endregion

            #region Добавление подграфов
            var subgraphCommand = new ToolBarInstantCommand(
                () =>
            {
                var subgraph = true;
                var unique   = Unique((UndirectedGraph)CurrentGraph, GraphLib.Lib);
                var gp       = new GraphPrinter();
                UserActionsManager.RegisterInfo(Strings.Strings_RU.stage2Check + gp.GraphToString(CurrentGraph));
                CurrentGraph.Vertices.ForEach(v1 =>
                {
                    CurrentGraph.Vertices.ForEach(v2 =>
                    {
                        subgraph &= v1.Equals(v2) || (CurrentGraph[v1, v2] == null ^ GivenGraph[
                                                          GivenGraph.Vertices.Single(v1.Equals),
                                                          GivenGraph.Vertices.Single(v2.Equals)] != null);
                    }
                                                  );
                }
                                              );
                if (CurrentGraph.VerticesCount == 0)
                {
                    return;
                }
                if (!subgraph)
                {
                    UserActionsManager.RegisterMistake(Strings.Strings_RU.stage2Mistake1, 10);
                    return;
                }

                if (!unique)
                {
                    UserActionsManager.RegisterMistake(Strings.Strings_RU.stage2Mistake2, 10);
                    return;
                }

                var newGraph = UndirectedGraph.CreateEmpty(CurrentGraph.VerticesCount);
                for (var i = 0; i < CurrentGraph.VerticesCount; i++)
                {
                    for (var j = i + 1; j < CurrentGraph.VerticesCount; j++)
                    {
                        if (CurrentGraph[CurrentGraph.Vertices[i], CurrentGraph.Vertices[j]] != null)
                        {
                            newGraph.AddEdge(new UndirectedEdge(newGraph.Vertices[i], newGraph.Vertices[j]));
                        }
                    }
                }
                UserActionsManager.RegisterInfo(Strings.Strings_RU.stage2Subgraph);

                GraphLib.Lib.Add(newGraph);
            },
                () => _state == State.Nothing
                )
            {
                Image       = new BitmapImage(GetImageUri("Collection.png")),
                Description = Strings.Strings_RU.buttonCheckSubgraph
            };
            #endregion

            #region Справка
            var phase2HelpCommand = new ToolBarInstantCommand(
                () =>
            {
                new SimpleDialog("Справка", Strings.Strings_RU.stage2Help).Show();
            },
                () => _state == State.Nothing
                )
            {
                Description = Strings.Strings_RU.buttonHelp,
                Image       = new BitmapImage(GetImageUri("Info.png"))
            };
            #endregion

            #region Молния
            var thunderbolt2 = new ToolBarInstantCommand(
                () =>
            {
                UserActionsManager.RegisterInfo(Strings.Strings_RU.stage2ThunderCall);
                allSubgraphs.ForEach(s =>
                {
                    if (Unique(s, GraphLib.Lib))
                    {
                        GraphLib.Lib.Add(s);
                    }
                });
                var g = UndirectedGraph.CreateEmpty(GivenGraph.VerticesCount);
                for (var i = 0; i < g.VerticesCount; i++)
                {
                    for (var j = i + 1; j < g.VerticesCount; j++)
                    {
                        if (GivenGraph[GivenGraph.Vertices[i], GivenGraph.Vertices[j]] != null)
                        {
                            g.AddEdge(new UndirectedEdge(g.Vertices[i], g.Vertices[j]));
                        }
                    }
                }
                GraphLib.Lib.Add(g);
            },
                () => _state == State.Nothing
                )
            {
                Description = "Молния",
                Image       = new BitmapImage(GetImageUri("thunder.png"))
            };
            #endregion

            #region Завершить этап
            var phase2Command = new ToolBarInstantCommand(
                () =>
            {
                if (GraphLib.Lib.Count > allSubgraphs.Count)
                {
                    UserActionsManager.RegisterInfo(Strings.Strings_RU.stage2Done);
                    UserActionsManager.ReportThatTaskFinished();
                }
                else
                {
                    UserActionsManager.RegisterMistake(Strings.Strings_RU.stage2Mistake3, 10);
                }
            },
                () => _state == State.Nothing
                )
            {
                Image       = new BitmapImage(GetImageUri("Check.png")),
                Description = Strings.Strings_RU.stage2DoneButtonDisc
            };
            #endregion
            #endregion

            Phase1ToolBarCommands = new ObservableCollection <ToolBarCommandBase>
            {
                phase1AddEdgeCommand,
                phase1Command,
                phase1HelpCommand
                #if DEBUG
                ,
                thunderbolt1
                #endif
            };
            Phase2ToolBarCommands = new ObservableCollection <ToolBarCommandBase>
            {
                vertexDialogCommand,
                phase2AddEdgeCommand,
                subgraphCommand,
                phase2Command,
                phase2HelpCommand
                #if DEBUG
                ,
                thunderbolt2
                #endif
            };
        }