public static string GetDescription(string moduleName)
        {
            if (theModuleDescriptions == null)
            {
                Load();
            }
            ModuleDescription desc = theModuleDescriptions.Find(t => t.moduleName == moduleName);

            if (desc != null)
            {
                return(desc.description);
            }
            return("");
        }
        public static string GetToolTip(string moduleName)
        {
            if (theModuleDescriptions == null)
            {
                Load();
            }
            //if (theModuleDescriptions.Count == 0) GetLegacyDescriptions();
            ModuleDescription desc = theModuleDescriptions.Find(t => t.moduleName == moduleName);

            if (desc != null)
            {
                return(desc.toolTip);
            }
            return("");
        }
        //for backward compatibility;
        //private static void GetLegacyDescriptions()
        //{
        //    var modules = Utils.GetArrayOfModuleTypes();

        //    foreach (var v in modules)
        //    {
        //        //get the tooltip
        //        Type t = Type.GetType("BrainSimulator.Modules." + v.Name);
        //        Modules.ModuleBase aModule = (Modules.ModuleBase)Activator.CreateInstance(t);
        //        string toolTip = aModule.ShortDescription;
        //        string description = aModule.LongDescription;
        //        ModuleDescription desc = new ModuleDescription { moduleName = t.Name, description = description, toolTip = toolTip, };
        //        theModuleDescriptions.Add(desc);
        //    }
        //}

        public static void SetToolTip(string moduleName, string theDescription)
        {
            ModuleDescription desc = theModuleDescriptions.Find(t => t.moduleName == moduleName);

            if (desc != null)
            {
                desc.toolTip = theDescription;
            }
            else
            {
                desc = new ModuleDescription {
                    moduleName = moduleName, toolTip = theDescription, description = "",
                };
                theModuleDescriptions.Add(desc);
            }
        }
示例#4
0
 private static void Mi_Click(object sender, RoutedEventArgs e)
 {
     //Handle delete  & initialize commands
     if (sender is MenuItem mi)
     {
         if ((string)mi.Header == "Delete")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
                 i = -i - 1;
                 MainWindow.arrayView.theSelection.selectedRectangles.RemoveAt(i);
                 deleted = true;
             }
             else
             {
                 ModuleView mv = MainWindow.theNeuronArray.Modules[i];
                 foreach (Neuron n in mv.Neurons())
                 {
                     n.Reset();
                     n.DeleteAllSynapes();
                 }
                 MainWindow.theNeuronArray.Modules.RemoveAt(i);
                 deleted = true;
             }
         }
         if ((string)mi.Header == "Initialize")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
             }
             else
             {
                 MainWindow.theNeuronArray.Modules[i].TheModule.Initialize();
             }
         }
         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;
                 ModuleDescription md = new ModuleDescription(m1.ShortDescription, m1.LongDescription);
                 md.ShowDialog();
             }
         }
         if ((string)mi.Header == "Reset Hebbian Weights")
         {
             foreach (NeuronSelectionRectangle 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.IsHebbian)
                         {
                             s.Weight = 0;
                         }
                     }
                 }
             }
             MainWindow.Update();
         }
     }
 }
示例#5
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;
                 ModuleDescription md = new ModuleDescription(m1.ShortDescription, m1.LongDescription);
                 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();
         }
     }
 }
示例#6
0
 private static void Mi_Click(object sender, RoutedEventArgs e)
 {
     //Handle delete  & initialize commands
     if (sender is MenuItem mi)
     {
         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.Update();
         }
         if ((string)mi.Header == "Delete")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
                 MainWindow.arrayView.DeleteSelection();
             }
             else
             {
                 ModuleView mv = MainWindow.theNeuronArray.Modules[i];
                 foreach (Neuron n in mv.Neurons())
                 {
                     n.Reset();
                     n.DeleteAllSynapes();
                 }
                 MainWindow.theNeuronArray.Modules.RemoveAt(i);
                 deleted = true;
             }
         }
         if ((string)mi.Header == "Initialize")
         {
             int i = (int)mi.Parent.GetValue(AreaNumberProperty);
             if (i < 0)
             {
             }
             else
             {
                 MainWindow.theNeuronArray.Modules[i].TheModule.Initialize();
             }
         }
         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;
                 ModuleDescription md = new ModuleDescription(m1.ShortDescription, m1.LongDescription);
                 md.ShowDialog();
             }
         }
         if ((string)mi.Header == "Reset Hebbian Weights")
         {
             MainWindow.theNeuronArray.SetUndoPoint();
             foreach (NeuronSelectionRectangle 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();
         }
     }
 }