private void UpdateLearningTaskDescription()
 {
     if (learningTaskList.SelectedItem == null)
     {
         learningTaskDescription.Url = null;
     }
     else
     {
         const string HTML_DIRECTORY = @"Resources\html";
         string       htmlFileName   = (learningTaskList.SelectedItem as LearningTaskListItem).HTMLFileName;
         string       fullPath       = MyResources.GetMyAssemblyPath() + "\\" + HTML_DIRECTORY + "\\" + htmlFileName;
         learningTaskDescription.Navigate(fullPath);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Loads a bitmap from a file and stores it in a dictionary. Checks for ARGB color format (e.g. 32bit png).
        /// Implementation same as in MyMastermindWorld (TODO: refactor once TetrisWorld gets moved to BasicNodes).
        /// </summary>
        /// <param name="path"></param>
        /// <param name="textureType"></param>
        protected void LoadBitmap(TextureType textureType, string path)
        {
            if (!m_bitmapTable.ContainsKey(textureType))
            {
                try
                {
                    Bitmap bitmap = (Bitmap)Image.FromFile(MyResources.GetMyAssemblyPath() + "\\" + path, true);
                    m_bitmapTable[textureType] = bitmap;

                    if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
                    {
                        throw new ArgumentException("The specified image is not in the required RGBA format."); // note: alpha must not be premultiplied
                    }
                }
                catch (Exception ex)
                {
                    MyLog.WARNING.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
 private int LoadAndGetBitmapSize(string path)
 {
     if (!m_bitmapTable.ContainsKey(path))
     {
         try
         {
             Bitmap bitmap = (Bitmap)Image.FromFile(MyResources.GetMyAssemblyPath() + "\\" + path, true);
             m_bitmapTable[path] = bitmap;
             return(bitmap.Width * bitmap.Height);
         }
         catch (Exception ex)
         {
             m_errorMessage = ex.Message;
             return(0);
         }
     }
     else
     {
         return(m_bitmapTable[path].Width * m_bitmapTable[path].Height);
     }
 }
Exemplo n.º 4
0
 public override void Init(int nGPU)
 {
     Owner.MNISTManager = new MyMNISTManager(MyResources.GetMyAssemblyPath() + @"\res\",
                                             TrainingExamplesPerDigit, TestExamplesPerDigit, false, AfterLastImage);
 }
 public MyMovingObjectsWorld()
 {
     m_MNISTManager = new MyMNISTManager(MyResources.GetMyAssemblyPath() + @"\res\", 1000);
     m_MNISTManager.RandomEnumerate = true;
 }
Exemplo n.º 6
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            Invoke((MethodInvoker)(() =>
            {
                LearningTaskNode ltNode = SelectedLearningTask;

                // if no selection, clear table and return
                if (ltNode == null)
                {
                    tabControlLevels.TabPages.Clear();
                    prevGridViewSelection = null;
                    return;
                }
                // if there is no change, do nothing
                if (ltNode.Equals(prevGridViewSelection))
                {
                    return;
                }
                prevGridViewSelection = ltNode;

                //
                // LT text hint
                //

                richTextBoxLTInfo.Clear();

                const string HTML_DIRECTORY = @"Resources\html";
                string htmlFileName = (ltNode as LearningTaskNode).TaskType.Name + ".html";
                string fullPath = MyResources.GetMyAssemblyPath() + "\\" + HTML_DIRECTORY + "\\" + htmlFileName;


                if (File.Exists(fullPath))
                {
                    // Create a file to write to.
                    string htmlPage = File.ReadAllText(fullPath);

                    string name = System.Text.RegularExpressions.Regex.Match(htmlPage, "<title>.*</title>").ToString();
                    if (name.Length > 0)
                    {
                        name = name.Split('>', '<')[2];
                    }
                    richTextBoxLTInfo.AppendText(name + "\r\n\r\n");
                    richTextBoxLTInfo.SelectAll();
                    richTextBoxLTInfo.SelectionFont = new Font(richTextBoxLTInfo.Font, FontStyle.Bold);

                    string description = System.Text.RegularExpressions.Regex.Match(htmlPage,
                                                                                    "Description(.*?)<td(.*?)</td>", System.Text.RegularExpressions.RegexOptions.Singleline).ToString();
                    if (description.Length > 0)
                    {
                        description = description.Split('>', '<')[4];
                    }
                    description = description.Replace(System.Environment.NewLine, "");
                    richTextBoxLTInfo.AppendText(description);
                }

                //
                // LVL tab
                //
                tabControlLevels.TabPages.Clear();

                Type ltType = ltNode.TaskType;
                ILearningTask lt = LearningTaskFactory.CreateLearningTask(ltType);
                TrainingSetHints hints = lt.TSProgression[0];

                Levels = new List <LevelNode>();
                LevelGrids = new List <DataGridView>();
                Attributes = new List <List <AttributeNode> >();
                AttributesChange = new List <List <int> >();

                for (int i = 0; i < lt.TSProgression.Count; i++)
                {
                    // create tab
                    LevelNode ln = new LevelNode(i + 1);
                    Levels.Add(ln);
                    TabPage tp = new TabPage(ln.Text);
                    tabControlLevels.TabPages.Add(tp);

                    // create grid
                    DataGridView dgv = new DataGridView();

                    dgv.Parent = tp;
                    dgv.Margin = new Padding(3);
                    dgv.Dock = DockStyle.Fill;
                    dgv.RowHeadersVisible = false;
                    dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                    dgv.AllowUserToResizeRows = false;
                    // create attributes
                    Attributes.Add(new List <AttributeNode>());
                    if (i > 0)
                    {
                        hints.Set(lt.TSProgression[i]);
                    }
                    foreach (var attribute in hints)
                    {
                        AttributeNode an = new AttributeNode(attribute.Key, attribute.Value);
                        Attributes[i].Add(an);
                        // create tooltips
                    }

                    Attributes[i].Sort(Comparer <AttributeNode> .Create((x, y) => x.Name.CompareTo(y.Name)));
                    dgv.DataSource = Attributes[i];

                    dgv.Columns[0].Width = 249;
                    dgv.Columns[0].ReadOnly = true;
                    dgv.Columns[1].ReadOnly = true;

                    AttributesChange.Add(new List <int>());
                    if (i > 0)
                    {
                        foreach (var attribute in lt.TSProgression[i])
                        {
                            int attributeIdx = Attributes[i].IndexOf(new AttributeNode(attribute.Key.Name));
                            AttributesChange[i].Add(attributeIdx);
                        }
                    }

                    LevelGrids.Add(dgv);
                    dgv.ColumnWidthChanged += levelGridColumnSizeChanged;
                    dgv.CellFormatting += levelGrid_CellFormatting;
                    dgv.SelectionChanged += levelGrid_SelectionChanged;
                    dgv.ClearSelection();

                    tabControlLevels.Update();
                }
            }
                                   ));
        }
Exemplo n.º 7
0
 public override void Init(int nGPU)
 {
     Owner.MNISTManager = new MyMNISTManager(MyResources.GetMyAssemblyPath() + @"\res\", ImagesCnt, false, AfterLastImage);
 }