Exemplo n.º 1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter           = "Mutilayer *.ml|*.ml";
            dialog.Title            = "Multilayer Open File";
            dialog.InitialDirectory = Path.GetFullPath(Settings.MultilayerFolder);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            try
            {
                EffectClasses.BitmapCollection collection = EffectClasses.BitmapCollection.Load(dialog.FileName);
                pcbBG1.Image     = collection.BG1;
                pcbBG2.Image     = collection.BG2;
                pcbBG3.Image     = collection.BG3;
                pcbBG4.Image     = collection.BG4;
                pcbOBJ.Image     = collection.OBJ;
                pcbCol.BackColor = collection.FixedColor;

                _colMath.Collection = collection;
                _colMath.FixedColor = EffectClasses.BitmapEffects.FromColor(
                    collection.FixedColor, Settings.DefaultSize);
                txtName.Text  = collection.Name;
                pcbMain.Image = _colMath.GetScreen();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Couldn't open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DirectoryInfo directory = new DirectoryInfo(Settings.MultilayerFolder);

            FileInfo[] files = directory.GetFiles("*.ml");
            if (files.Any(f => f.Name.ToLower() == txtName.Text.ToLower() + ".ml"))
            {
                if (MessageBox.Show("A Multilayer with the given name already exists.\nDo you want to overwrite it?", "Conflict", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
                Edit = true;
            }

            try
            {
                GeneratedCollection            = _colMath.Collection;
                GeneratedCollection.FixedColor = pcbCol.BackColor;
                GeneratedCollection.Name       = txtName.Text;
                EffectClasses.BitmapCollection.Save(GeneratedCollection, directory.Name + "\\" + txtName.Text + ".ml");
                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Couldn't save file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Asign the Bitmaps to a ColorMath object from a ComboBox.
        /// </summary>
        /// <param name="tab">The gui calling this</param>
        /// <param name="layer"></param>Which layer the screenshot will be used on.
        /// <param name="math">The ColorMath that will get the images assigned to it.</param>
        /// <param name="Selector">The ComboBox containing BitmapCollection objects.</param>
        /// <param name="setColor"><c>True</c> will overwrite the FixedColor property of the ColorMath with the one from the BitmapCollection.</param>
        public static void AsignLayers(ITab tab, int layer, EffectClasses.ColorMath math, object Selector, bool setColor)
        {
            //remove image of current tab from screenshot collection.
            int index   = tab.GetTabControl().SelectedIndex;
            var tabAsSS = tab as IScreenshotUser;

            if (tabAsSS != null)
            {
                if (tabAsSS.ScreenshotsImages[index] != null)
                {
                    tabAsSS.ScreenshotsImages[index].Dispose();
                }
                tabAsSS.ScreenshotsImages[index] = null;
            }

            //The first Object is the option to use a screenshot.
            if (((ComboBox)Selector).SelectedIndex == 0)
            {
                if (tab is IScreenshotUser)
                {
                    var screenshot = FetchScreenshot();
                    if (screenshot == null)
                    {
                        ((ComboBox)Selector).SelectedIndex = 1;
                    }
                    else
                    {
                        tabAsSS.ScreenshotsImages[index] = screenshot;
                        math.OBJ = new Bitmap(256, 224);

                        math.BG1 = (layer == 1) ? screenshot : new Bitmap(256, 224);
                        math.BG2 = (layer == 2) ? screenshot : new Bitmap(256, 224);
                        math.BG3 = (layer == 3) ? screenshot : new Bitmap(256, 224);
                        math.BG4 = (layer == 4) ? screenshot : new Bitmap(256, 224);
                    }
                }
                else
                {
                    MessageBox.Show("This tab is not supporting the use of screenshots.", "Not Implemented", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ((ComboBox)Selector).SelectedIndex = 1;
                }
            }
            else
            {
                EffectClasses.BitmapCollection bc = (EffectClasses.BitmapCollection)((ComboBox)Selector).SelectedItem;
                math.Collection = bc;
                if (setColor)
                {
                    if (bc.FixedColor == null)
                    {
                        bc.FixedColor = Color.Transparent;
                    }
                    math.FixedColor = EffectClasses.BitmapEffects.FromColor(bc.FixedColor, bc.BG1.Size);
                }
            }
        }
Exemplo n.º 4
0
        public static void AsignLayers(EffectClasses.ColorMath Math, object Selector, bool setColor)
        {
            //The first Object is the option to use a screenshot.
            if (((ComboBox)Selector).SelectedIndex == 0)
            {
                MessageBox.Show("This feature is currently not available.", "Not Implemented", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ((ComboBox)Selector).SelectedIndex = 1;
            }

            EffectClasses.BitmapCollection bc = (EffectClasses.BitmapCollection)((ComboBox)Selector).SelectedItem;
            Math.Collection = bc;
            if (setColor)
            {
                if (bc.FixedColor == null)
                {
                    bc.FixedColor = Color.Transparent;
                }
                Math.FixedColor = EffectClasses.BitmapEffects.FromColor(bc.FixedColor, bc.BG1.Size);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// (Re)Loads the multilayer files inside the ComboBoxes.
        /// </summary>
        private void SetupMulitlayerComboBoxes()
        {
            //empty Screens
            if (Screens == null)
            {
                Screens = new List <EffectClasses.BitmapCollection>();
            }
            else
            {
                Screens.Clear();
            }


            if (!Directory.Exists(Settings.MultilayerFolder))
            {
                MessageBox.Show(Settings.MultilayerFolder + " folder doesn't exist.\nNo multilayers could be loaded", "Folder Missing",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //get all the multilayer files in the .\Multilayer folder
                FileInfo[] files = new DirectoryInfo(Settings.MultilayerFolder).GetFiles("*.ml");

                foreach (FileInfo fi in files)
                {
                    try
                    {
                        //load Layers and use filename as name to appear.
                        EffectClasses.BitmapCollection collection = EffectClasses.BitmapCollection.Load(fi.FullName);
                        collection.Name = Path.GetFileNameWithoutExtension(fi.Name);
                        Screens.Add(collection);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Couldn't open/load multilayer file: " + fi.FullName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }

            //set screens on overy tab
            foreach (ITab IT in Tabs.Values)
            {
                if (IT.ScreenSelectors != null)
                {
                    foreach (ComboBox cb in IT.ScreenSelectors)
                    {
                        //if an index has been selected, preserve it, otherwise start with 1
                        int index = (cb.SelectedIndex == ListBox.NoMatches ? 1 : cb.SelectedIndex);

                        //clear ComboBoxes and add <Load Screenshot> text, default multilayer and the loaded ones.
                        cb.Items.Clear();
                        cb.Items.Add(Settings.UseScreenshot);
                        cb.Items.Add(EffectClasses.BitmapCollection.Load(Properties.Resources.Default));
                        foreach (EffectClasses.BitmapCollection col in Screens)
                        {
                            cb.Items.Add(col);
                        }

                        //(re)set selected index
                        cb.SelectedIndex = index;
                    }
                }
            }
        }