コード例 #1
0
        private void MenuItemModuleInfo_Click(object sender, RoutedEventArgs e)
        {
            ModuleDescriptionDlg md = new ModuleDescriptionDlg("");

            md.ShowDialog();
        }
コード例 #2
0
 private static void Mi_Click(object sender, RoutedEventArgs e)
 {
     //Handle delete  & initialize commands
     if (sender is MenuItem mi)
     {
         if (mi.Header is StackPanel sp && sp.Children[0] is Label l && l.Content.ToString().StartsWith("Random"))
         {
             if (sp.Children[1] is TextBox tb0)
             {
                 if (int.TryParse(tb0.Text, out int count))
                 {
                     MainWindow.arrayView.CreateRandomSynapses(count);
                     MainWindow.theNeuronArray.ShowSynapses = true;
                     MainWindow.thisWindow.SetShowSynapsesCheckBox(true);
                     MainWindow.Update();
                 }
             }
             return;
         }
         if ((string)mi.Header == "Cut")
         {
             MainWindow.arrayView.CutNeurons();
             MainWindow.Update();
         }
         if ((string)mi.Header == "Copy")
         {
             MainWindow.arrayView.CopyNeurons();
         }
         if ((string)mi.Header == "Clear Selection")
         {
             MainWindow.arrayView.ClearSelection();
             MainWindow.Update();
         }
         if ((string)mi.Header == "Mutual Suppression")
         {
             MainWindow.arrayView.MutualSuppression();
             MainWindow.theNeuronArray.ShowSynapses = true;
             MainWindow.thisWindow.SetShowSynapsesCheckBox(true);
             MainWindow.Update();
         }
         if ((string)mi.Header == "Delete")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
                 MainWindow.arrayView.DeleteSelection();
             }
             else
             {
                 MainWindow.theNeuronArray.SetUndoPoint();
                 MainWindow.theNeuronArray.AddModuleUndo(-1, MainWindow.theNeuronArray.modules[i]);
                 DeleteModule(i);
                 deleted = true;
             }
         }
         if ((string)mi.Header == "Initialize")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
             }
             else
             {
                 {
                     try
                     {
                         MainWindow.theNeuronArray.Modules[i].TheModule.Initialize();
                     }
                     catch (Exception e1)
                     {
                         MessageBox.Show("Initialize failed on module " + MainWindow.theNeuronArray.Modules[i].Label + ".   Message: " + e1.Message);
                     }
                 }
             }
         }
         if ((string)mi.Header == "Show Dialog")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
             }
             else
             {
                 MainWindow.theNeuronArray.Modules[i].TheModule.ShowDialog();
             }
         }
         if ((string)mi.Header == "Info...")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
             }
             else
             {
                 ModuleView           m             = MainWindow.theNeuronArray.Modules[i];
                 ModuleBase           m1            = m.TheModule;
                 string               theModuleType = m1.GetType().Name.ToString();
                 ModuleDescriptionDlg md            = new ModuleDescriptionDlg(theModuleType);
                 md.ShowDialog();
             }
         }
         if ((string)mi.Header == "Reset Hebbian Weights")
         {
             MainWindow.theNeuronArray.SetUndoPoint();
             foreach (SelectionRectangle sr in MainWindow.arrayView.theSelection.selectedRectangles)
             {
                 foreach (int Id in sr.NeuronInRectangle())
                 {
                     Neuron n = MainWindow.theNeuronArray.GetNeuron(Id);
                     foreach (Synapse s in n.Synapses)
                     {
                         if (s.model != Synapse.modelType.Fixed)
                         {
                             //TODO: Add some UI for this:
                             //s.model = Synapse.modelType.Hebbian2;
                             n.AddSynapseWithUndo(s.targetNeuron, 0, s.model);
                             s.Weight = 0;
                         }
                     }
                 }
             }
             MainWindow.Update();
         }
     }
 }