예제 #1
0
        private void SaveFile()
        {
            try
            {
                // Save the necessary data for the serialization
                LudoFileClass ludoFile = new LudoFileClass(m_slotsPanels.Length);

                ludoFile.m_panelIndex = m_panelsIndex;

                // IMAGE LIBRARY
                ludoFile.m_imagesPaths = m_imagesLibrary.ImagesPaths;

                // PANELS
                for (int i = 0; i < m_slotsPanels.Length; i++)
                {
                    // SLOTS PANELS
                    ludoFile.m_sourceRectangles[i] = m_slotsPanels[i].SourceRectangles;
                    ludoFile.m_rectangleColors[i]  = m_slotsPanels[i].RectanglesColors;
                    ludoFile.m_bitmaps[i]          = m_slotsPanels[i].Bitmaps;
                    ludoFile.m_slotInd[i]          = m_slotsPanels[i].SlotIndex;
                    ludoFile.m_approvedSlots[i]    = m_slotsPanels[i].ApprovedSlots;
                    ludoFile.m_rightButtonMode[i]  = m_slotsPanels[i].RightButtonMode;
                }

                // Serialize
                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new FileStream(m_currFilename, FileMode.Create, FileAccess.Write, FileShare.None);
                formatter.Serialize(stream, ludoFile);
                stream.Close();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, m_langDictionary["Save"], MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #2
0
        private void OpenFile()
        {
            try
            {
                // Get data from the saved file
                IFormatter    formatter = new BinaryFormatter();
                Stream        stream    = new FileStream(m_currFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
                LudoFileClass ludoFile  = (LudoFileClass)formatter.Deserialize(stream);
                stream.Close();

                // Pass the index of the focused panel
                m_panelsIndex = ludoFile.m_panelIndex;
                PositionPanels();

                // Pass the data to the side bar
                m_imagesLibrary.ImportFromFile(ludoFile.m_imagesPaths);

                for (int i = 0; i < m_slotsPanels.Length; i++)
                {
                    // SLOTS PANEL
                    m_slotsPanels[i].ImportFromFile(
                        ludoFile.m_sourceRectangles[i],
                        ludoFile.m_rectangleColors[i],
                        ludoFile.m_bitmaps[i],
                        ludoFile.m_slotInd[i],
                        ludoFile.m_approvedSlots[i], i);

                    m_slotsPanels[i].ChangeRightButtonMode(ludoFile.m_rightButtonMode[i]);

                    // CROP PANELS
                    m_cropPanels[i].DisplayImage(
                        ludoFile.m_bitmaps[i][ludoFile.m_slotInd[i]],
                        ludoFile.m_sourceRectangles[i][ludoFile.m_slotInd[i]]);

                    m_cropPanels[i].ChangeArrowMode(ludoFile.m_rightButtonMode[i]);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, m_langDictionary["Open"], MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }