Beispiel #1
0
        private void Form_Dialog_Assoc_Load(object sender, EventArgs e)
        {
            IconExtractor ie = new IconExtractor("Lib\\IconSet.dll");

            ie.GetIcon((int)FileAssociation.IconIndex.Icon_PCV).ToBitmap();

            ChLB = new CheckedImageListBox()
            {
                Location  = new Point(12, 12),
                Size      = new Size(404, 124),
                ImageSize = new Size(15, 15),
                Font      = new Font("Arial", 11, FontStyle.Regular),
                BackColor = Color.White
            };

            ChLB.AddItem(".PCV", ie.GetIcon((int)FileAssociation.IconIndex.Icon_PCV).ToBitmap());
            ChLB.AddItem(".PCVDOC", ie.GetIcon((int)FileAssociation.IconIndex.Icon_PCVDOC).ToBitmap());
            ChLB.AddItem(".PRRES", ie.GetIcon((int)FileAssociation.IconIndex.Icon_PRRES).ToBitmap());
            ChLB.AddItem(".PCMACROS", ie.GetIcon((int)FileAssociation.IconIndex.Icon_Macros).ToBitmap());
            ChLB.AddItem(".PCMPACK", ie.GetIcon((int)FileAssociation.IconIndex.Icon_MacroPack).ToBitmap());
            ChLB.AddItem(".PCGRAPH", ie.GetIcon((int)FileAssociation.IconIndex.Icon_PCGraph).ToBitmap());

            Controls.Add(ChLB);

            ChLB.ItemCheck            += checkedListBox_ItemCheck;
            ChLB.SelectedIndexChanged += checkedListBox1_SelectedIndexChanged;

            startStatus = FileAssociation.GetUnidentifiedAssoc();
            current     = FileAssociation.GetUnidentifiedAssoc();
            for (int i = 0; i <= ChLB.Items.Count - 1; i++)
            {
                ChLB.SetItemChecked(i, !startStatus[i]);
            }
            button_save.Enabled = false;
            if (!current.Contains(true))
            {
                selectStatus          = true;
                button_selectAll.Text = TB.L.Phrase["Form_Dialog_Assoc.DeSelectAll"];
            }
            else
            {
                selectStatus          = false;
                button_selectAll.Text = TB.L.Phrase["Form_Dialog_Assoc.SelectAll"];
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           diff = 0;
            List <string> log  = new List <string>();

            for (int i = 0; i <= ChLB.Items.Count - 1; i++)
            {
                if (current[i] != startStatus[i])
                {
                    diff++;
                    if (current[i])
                    {
                        if (!FileAssociation.DeleteAssociation((FileAssociation.FileFormats)(i), out FileAssociation.AssocDeleteFailReason err))
                        {
                            log.Add(string.Format(TB.L.Phrase["Form_Dialog_Assoc.UnableToDelAssoc"], ((FileAssociation.FileFormats)i).ToString(), err.ToString()));
                        }
                    }
                    else if (!FileAssociation.RegisterAssociation((FileAssociation.FileFormats)(i)))
                    {
                        log.Add(string.Format(TB.L.Phrase["Form_Dialog_Assoc.UnableToAssoc"], ((FileAssociation.FileFormats)i).ToString()));
                    }
                }
            }
            if (log.Count != 0)
            {
                MessageBox.Show(string.Join("\n", log),
                                TB.L.Phrase["Form_Dialog_Assoc.Assoc"],
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show(
                    string.Format(TB.L.Phrase["Form_Dialog_Assoc.Success"]),
                    TB.L.Phrase["Form_Dialog_Assoc.Assoc"],
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Form_Dialog_Assoc_Load(null, null);
        }
Beispiel #3
0
        static void Main()
        {
            string execDirectory = new FileInfo(Application.ExecutablePath).DirectoryName;

            // ---====  CREATING NECESSARY DIRECTORIES  ===---
            foreach (string s in NecessaryDirectrories.Select(p => p = execDirectory + p))
            {
                if (!Directory.Exists(s))
                {
                    Directory.CreateDirectory(s);
                }
            }

            // ---====  SETUP APPLICATION  ===---

            //    ==GlobalOptions==
            GlobalOptions.Filename      = execDirectory + "\\Options\\Options.xml";
            GlobalOptions.BuildFilename = execDirectory + "\\Options\\Build";
            GlobalOptions.Load();

            //    ==TranslateBase==
            TranslateBase.LangDirectory = execDirectory + "\\Options\\";
            TranslateBase.Init();
            TranslateBase.CurrentLangName = GlobalOptions.Lang;
            TranslateBase.ProceedLang();

            //    ==GlobalOptionsLogPolitics==
            GlobalOptionsLogPolitics.Filename  = execDirectory + "\\Options\\logPolitics.xml";
            GlobalOptionsLogPolitics.OutPutDir = execDirectory + "\\Logs\\";
            GlobalOptionsLogPolitics.Load();

            //    ==CommandLineParser==
            CommandLineParser.CommamndsFileName = execDirectory + "\\Options\\Commands.xml";
            CommandLineParser.Init();

            //    ==CurvePluginHandler==
            CurvePluginHandler.PluginDir = execDirectory + "\\Plugins\\";
            if (GlobalOptions.PreloadPlugins)
            {
                CurvePluginHandler.Init();
            }

            //    ==Association==
            //FileAssociation.DeleteAllAssociations();
            FileAssociation.PathToIcons   = execDirectory + "\\Lib\\IconSet.dll";
            FileAssociation.PathToProgram = execDirectory + "\\Plotter Control.exe";
            FileAssociation.DiscoverRegistryAccessibility();
            if (!GlobalOptions.IgnoreRegisterExtentions)
            {
                FileAssociation.AssociateAll();
            }

            //    ==Application==
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            // ---====  STARTING APPLICATION  ===---
            CommandLineParser.Parse(Environment.GetCommandLineArgs());


            // ---====  DELETING TEMPORARY DIRECTORY ===---
            try
            {
                foreach (string s in Directory.GetFiles(new FileInfo(Application.ExecutablePath).DirectoryName + "\\Temp"))
                {
                    File.Delete(s);
                }
                Directory.Delete(new FileInfo(Application.ExecutablePath).DirectoryName + "\\Temp");
            }
            catch { };
        }