Ejemplo n.º 1
0
        private void NavigateFile(string file)
        {
            if (!Path.IsPathRooted(file))
            {
                file = Path.GetFullPath(Path.Combine(App.CurrentRootPath,
                                                     this.ViewModel.Profile.ProjectName,
                                                     "Config",
                                                     file));
            }

            Helpers.NavigateFile(file);
        }
Ejemplo n.º 2
0
        private static Tuple <string, TempDirectoryHelper> BuildXnb(IServiceLocator services, string applicationName, string fileName, bool createModelNode, bool recreateModelAndMaterialFiles)
        {
            Debug.Assert(services != null);
            Debug.Assert(applicationName != null);
            Debug.Assert(applicationName.Length > 0);
            Debug.Assert(fileName != null);
            Debug.Assert(fileName.Length > 0);

            var tempDirectoryHelper = new TempDirectoryHelper(applicationName, "ModelDocument");

            try
            {
                var contentBuilder = new GameContentBuilder(services)
                {
                    IntermediateFolder = tempDirectoryHelper.TempDirectoryName + "\\obj",
                    OutputFolder       = tempDirectoryHelper.TempDirectoryName + "\\bin",
                };

                string processorName;
                var    processorParams = new OpaqueDataDictionary();
                if (createModelNode)
                {
                    processorName = "GameModelProcessor";
                    processorParams.Add("RecreateModelDescriptionFile", recreateModelAndMaterialFiles);
                    processorParams.Add("RecreateMaterialDefinitionFiles", recreateModelAndMaterialFiles);
                }
                else
                {
                    processorName = "ModelProcessor";
                }

                string errorMessage;
                bool   success = contentBuilder.Build(Path.GetFullPath(fileName), null, processorName, processorParams, out errorMessage);
                if (!success)
                {
                    throw new EditorException(Invariant($"Could not process 3d model: {fileName}.\n See output window for details."));
                }

                // Return output folder into which we built the XNB.
                var outputFolder = contentBuilder.OutputFolder;
                if (!Path.IsPathRooted(outputFolder))
                {
                    outputFolder = Path.GetFullPath(Path.Combine(contentBuilder.ExecutableFolder, contentBuilder.OutputFolder));
                }

                return(Tuple.Create(outputFolder, tempDirectoryHelper));
            }
            catch
            {
                tempDirectoryHelper.Dispose();
                throw;
            }
        }
Ejemplo n.º 3
0
        private void xmlDocLoc_btn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog {
                Multiselect = false, Filter = "XML Documents (*.xml)|*.xml", Title = "Select XML Document", FilterIndex = 1
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string pathOfXMLFile = Path.GetFullPath(openFileDialog.FileName);
                xmlDocLoc_txtBox.Text = pathOfXMLFile.ToString();
            }
            ;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="exe"></param>
        /// <param name="arguments"></param>
        /// <param name="workingDirectory">是否等待退出</param>
        /// <param name="waitExit"></param>
        /// <returns></returns>
        public static Process Run(string exe, string arguments, string workingDirectory = ".", bool waitExit = false)
        {
            try
            {
                bool redirectStandardOutput = true;
                bool redirectStandardError  = true;
                bool useShellExecute        = false;
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    redirectStandardOutput = false;
                    redirectStandardError  = false;
                    useShellExecute        = true;
                }

                if (waitExit)
                {
                    redirectStandardOutput = true;
                    redirectStandardError  = true;
                    useShellExecute        = false;
                }

                ProcessStartInfo info = new ProcessStartInfo
                {
                    FileName               = exe,
                    Arguments              = arguments,
                    CreateNoWindow         = true,
                    UseShellExecute        = useShellExecute,
                    WorkingDirectory       = workingDirectory,
                    RedirectStandardOutput = redirectStandardOutput,
                    RedirectStandardError  = redirectStandardError,
                };

                Log.Debug("Web运行的路径:" + workingDirectory);
                Process process = Process.Start(info);

                if (waitExit)
                {
                    process.WaitForExit();
                    if (process.ExitCode != 0)
                    {
                        throw new Exception($"{process.StandardOutput.ReadToEnd()} {process.StandardError.ReadToEnd()}");
                    }
                }

                return(process);
            }
            catch (Exception e)
            {
                throw new Exception($"dir: {Path.GetFullPath(workingDirectory)}, command: {exe} {arguments}", e);
            }
        }
Ejemplo n.º 5
0
        protected virtual void setUpImpl()
        {
            // Ideally we wanted en-US, but invariant provides a suitable default for testing.
#if NETSTANDARD
            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
#else
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#endif
            TemplateGroup.DefaultGroup        = new TemplateGroup();
            TemplateCompiler.subtemplateCount = 0;

            // new output dir for each test
            tmpdir = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "st4-" + currentTimeMillis()));
        }
Ejemplo n.º 6
0
        public static string GetSourceFilePath()
        {
            string filePath = Path.GetFullPath
                              (
                Path.Combine
                (
                    Environment.GetFolderPath(Environment.SpecialFolder.Personal),

                    SourceFileName
                )
                              );

            return(filePath);
        }
Ejemplo n.º 7
0
        private void LoadFileBtn_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "Text files (*.tsp)|*.tsp",
                InitialDirectory = Environment.CurrentDirectory
            };

            if (openFileDialog.ShowDialog() == true)
            {
                var fileName = openFileDialog.FileName;
                FileTb.Text = Path.GetFullPath(fileName);
            }
        }
        /**
         * Return a list of File objects that name files ANTLR will read
         * to process T.g; This can only be .tokens files and only
         * if they use the tokenVocab option.
         *
         * @return List of dependencies other than imported grammars
         */
        public virtual List <string> GetNonImportDependenciesFileList()
        {
            List <string> files = new List <string>();

            // handle token vocabulary loads
            tokenVocab = (string)grammar.GetOption("tokenVocab");
            if (tokenVocab != null)
            {
                string vocabFile = tool.GetImportedVocabFile(tokenVocab);
                files.Add(Path.GetFullPath(vocabFile));
            }

            return(files);
        }
Ejemplo n.º 9
0
        public static Process Run(string exe, string arguments, string workingDirectory = ".", bool waitExit = false)
        {
            //Log.Debug($"Process Run exe:{exe} ,arguments:{arguments} ,workingDirectory:{workingDirectory}");
            try
            {
                bool redirectStandardOutput = true;
                bool redirectStandardError  = true;
                bool useShellExecute        = false;
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    redirectStandardOutput = false;
                    redirectStandardError  = false;
                    useShellExecute        = true;
                }

                if (waitExit)
                {
                    redirectStandardOutput = true;
                    redirectStandardError  = true;
                    useShellExecute        = false;
                }

                //Log.Debug($"1111111111111111111111111aaaa: {redirectStandardError} {redirectStandardOutput} {useShellExecute}");

                ProcessStartInfo info = new ProcessStartInfo
                {
                    FileName               = exe,
                    Arguments              = arguments,
                    CreateNoWindow         = true,
                    UseShellExecute        = useShellExecute,
                    WorkingDirectory       = workingDirectory,
                    RedirectStandardOutput = redirectStandardOutput,
                    RedirectStandardError  = redirectStandardError,
                };

                Process process = Process.Start(info);

                if (waitExit)
                {
                    WaitExitAsync(process).Coroutine();
                }

                return(process);
            }
            catch (Exception e)
            {
                throw new Exception($"dir: {Path.GetFullPath(workingDirectory)}, command: {exe} {arguments}", e);
            }
        }
Ejemplo n.º 10
0
 public override object Run(Scope scope)
 {
     if (_compiledLambda == null)
     {
         _compiledLambda = _lambda.Compile();
     }
     if (this.SourceUnit.Kind == SourceCodeKind.File)
     {
         // Simple way to convey script rundir for RuntimeHelpers.SymplImport
         // to load .sympl files relative to the current script file.
         DynamicObjectHelpers.SetMember(scope, "__file__",
                                        Path.GetFullPath(this.SourceUnit.Path));
     }
     return(_compiledLambda(_sympl, scope));
 }
Ejemplo n.º 11
0
        private static string GetRootedPath(string rootPath, string?inputPath)
        {
            if (!string.IsNullOrEmpty(inputPath))
            {
                if (Path.IsPathRooted(inputPath))
                {
                    rootPath = inputPath;
                }
                else
                {
                    rootPath = Path.GetFullPath(inputPath, rootPath);
                }
            }

            return(rootPath);
        }
Ejemplo n.º 12
0
        private static string GetTemporaryDirectory(out bool removeDirectory)
        {
            string packagesPath = Path.GetFullPath(@"..\..\..");

            if (Directory.Exists(Path.Combine(packagesPath, "packages")))
            {
                removeDirectory = false;
                return(Path.Combine(packagesPath, "packages"));
            }

            string path = Path.Combine(Path.GetTempPath(), "CompatibilityChecker-" + Path.GetRandomFileName());

            Directory.CreateDirectory(path);
            removeDirectory = true;
            return(path);
        }
Ejemplo n.º 13
0
        /** This method is used by all code generators to create new output
         *  files. If the outputDir set by -o is not present it will be created.
         *  The final filename is sensitive to the output directory and
         *  the directory where the grammar file was found.  If -o is /tmp
         *  and the original grammar file was foo/t.g4 then output files
         *  go in /tmp/foo.
         *
         *  The output dir -o spec takes precedence if it's absolute.
         *  E.g., if the grammar file dir is absolute the output dir is given
         *  precedence. "-o /tmp /usr/lib/t.g4" results in "/tmp/T.java" as
         *  output (assuming t.g4 holds T.java).
         *
         *  If no -o is specified, then just write to the directory where the
         *  grammar file was found.
         *
         *  If outputDirectory==null then write a String.
         */
        public virtual TextWriter GetOutputFileWriter(Grammar g, string fileName)
        {
            if (outputDirectory == null)
            {
                return new StringWriter();
            }

            // output directory is a function of where the grammar file lives
            // for subdir/T.g4, you get subdir here.  Well, depends on -o etc...
            string outputDir = GetOutputDirectory(g.fileName);
            string outputFile = Path.Combine(outputDir, fileName);
            ConsoleOut.WriteLine($"Generating file '{Path.GetFullPath(outputFile)}' for grammar '{g.fileName}'");

            Directory.CreateDirectory(outputDir);

            return new StreamWriter(File.OpenWrite(outputFile), Encoding.GetEncoding(grammarEncoding));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Check if the given path is a well-formed absolute path.
        /// If not, throw and <see cref="AxeWindowsAutomationException"/>.
        /// </summary>
        /// <param name="path"></param>
        /// <exception cref="AxeWindowsAutomationException"/>
        private void VerifyPathOrThrow(string path)
        {
            try
            {
                // the following throws various exceptions if the given path is invalid
                Path.GetFullPath(path);

                if (!Path.IsPathRooted(path))
                {
                    throw new Exception(DisplayStrings.ErrorIsNotFullPath);
                }
            }
            catch (Exception ex)
            {
                throw new AxeWindowsAutomationException(string.Format(CultureInfo.InvariantCulture, DisplayStrings.ErrorDirectoryInvalid, path), ex);
            }
        }
Ejemplo n.º 15
0
        public void Run(Document placeholder)
        {
            LogTrace("Creating Drawing from iLogic rule...");
            string currDir = Directory.GetCurrentDirectory();

            LogTrace("currDir: " + currDir);
            // For local debugging
            //string inputPath = System.IO.Path.Combine(currDir, @"../../inputFiles", "params.json");
            //Dictionary<string, string> options = JsonConvert.DeserializeObject<Dictionary<string, string>>(System.IO.File.ReadAllText(inputPath));

            Dictionary <string, string> options = JsonConvert.DeserializeObject <Dictionary <string, string> >(System.IO.File.ReadAllText("inputParams.json"));
            string inputFile      = options["inputFile"];
            string projectFile    = options["projectFile"];
            string rule           = options["runRule"];
            string drawingDocName = "result";

            string assemblyPath = Path.GetFullPath(Path.Combine(currDir, inputFile));

            string fullProjectPath = Path.GetFullPath(Path.Combine(currDir, projectFile));


            Console.WriteLine("fullProjectPath = " + fullProjectPath);

            DesignProject dp = inventorApplication.DesignProjectManager.DesignProjects.AddExisting(fullProjectPath);

            dp.Activate();

            Console.WriteLine("assemblyPath = " + assemblyPath);
            Document doc = inventorApplication.Documents.Open(assemblyPath);

            //RunRule(doc, rule);
            CreateDrawing(doc);

            // Drawing will be the last one created
            int      docCount = inventorApplication.Documents.Count;
            Document lastDoc  = inventorApplication.Documents[docCount];

            LogTrace("lastDoc: " + lastDoc.DisplayName);

            string drawingPath = Directory.GetCurrentDirectory() + "/result.idw";

            LogTrace("saving drawing: " + drawingPath);
            lastDoc.SaveAs(drawingPath, false);
            LogTrace("saving as pdf: " + drawingDocName);
            SaveAsPdf(lastDoc, drawingDocName);
        }
Ejemplo n.º 16
0
        public static void writeFile(string dir, string fileName, string content)
        {
            if (Path.IsPathRooted(fileName))
            {
                throw new ArgumentException();
            }

            string fullPath = Path.GetFullPath(Path.Combine(dir, fileName));

            dir = Path.GetDirectoryName(fullPath);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            File.WriteAllText(fullPath, content);
        }
Ejemplo n.º 17
0
        public static IEnumerable <IContent> Wrap(TarInput input)
        {
            var baseDir = input.BaseDir == null ? null : SysPath.GetFullPath(input.BaseDir);

            foreach (var file in input.Files)
            {
                var relative = baseDir == null?SysPath.GetFileName(file)
                                   : SysPath.GetFullPath(file).Replace(baseDir, string.Empty)
                                   .TrimStart(SysPath.DirectorySeparatorChar);

                yield return(new RpmContent
                {
                    Source = file,
                    Path = SysPath.Combine(input.InstallDir, relative),
                    User = "******",
                    Group = "root"
                });
            }
        }
Ejemplo n.º 18
0
        public TemplateGroupFile(string fileName, char delimiterStartChar, char delimiterStopChar)
            : base(delimiterStartChar, delimiterStopChar)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            try
            {
                if (!fileName.EndsWith(GroupFileExtension))
                {
                    throw new ArgumentException("Group file names must end in .stg: " + fileName);
                }

                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException(string.Format("No such group file: {0}", fileName));
                }

                if (!Uri.TryCreate(Path.GetFullPath(fileName), UriKind.Absolute, out _url))
                {
                    _url = new Uri("file://" + fileName.Replace('\\', '/'));
                }

                this._fileName = fileName;

                if (Verbose)
                {
                    Console.WriteLine("STGroupFile({0}) == file {1}", fileName, Path.GetFullPath(fileName));
                }
            }
            catch (Exception e)
            {
                e.PreserveStackTrace();
                if (!e.IsCritical())
                {
                    ErrorManager.InternalError(null, "can't Load group file " + fileName, e);
                }

                throw;
            }
        }
Ejemplo n.º 19
0
        /**
         * Try current dir then dir of g then lib dir
         * @param g
         * @param nameNode The node associated with the imported grammar name.
         */
        public virtual Grammar LoadImportedGrammar(Grammar g, GrammarAST nameNode)
        {
            string  name = nameNode.Text;
            Grammar imported;

            if (!importedGrammars.TryGetValue(name, out imported) || imported == null)
            {
                g.tool.Log("grammar", "load " + name + " from " + g.fileName);
                string importedFile = null;
                foreach (string extension in ALL_GRAMMAR_EXTENSIONS)
                {
                    importedFile = GetImportedGrammarFile(g, name + extension);
                    if (importedFile != null)
                    {
                        break;
                    }
                }

                if (importedFile == null)
                {
                    errMgr.GrammarError(ErrorType.CANNOT_FIND_IMPORTED_GRAMMAR, g.fileName, nameNode.Token, name);
                    return(null);
                }

                string            absolutePath = Path.GetFullPath(importedFile);
                string            fileContent  = File.ReadAllText(absolutePath, Encoding.GetEncoding(grammarEncoding));
                char[]            fileChars    = fileContent.ToCharArray();
                ANTLRStringStream @in          = new ANTLRStringStream(fileChars, fileChars.Length, importedFile);
                GrammarRootAST    root         = Parse(g.fileName, @in);
                if (root == null)
                {
                    return(null);
                }

                imported          = CreateGrammar(root);
                imported.fileName = absolutePath;
                importedGrammars[root.GetGrammarName()] = imported;
            }

            return(imported);
        }
Ejemplo n.º 20
0
        public static SD.Process LaunchFileFromProject(VisualStudioApp app, EnvDTE.Project project, string filename, string interpreterArgs, string programArgs)
        {
            var item   = project.ProjectItems.Item(filename);
            var window = item.Open();

            window.Activate();
            var    doc          = item.Document;
            var    docFN        = doc.FullName;
            string fullFilename = Path.GetFullPath(docFN);

            string cmdlineArgs = String.Format("{0} \"{1}\" {2}", interpreterArgs, fullFilename, programArgs);

            var uiThread           = app.GetService <UIThreadBase>();
            var projectInterpreter = uiThread.Invoke(() => project.GetPythonProject().GetLaunchConfigurationOrThrow().GetInterpreterPath());

            var psi = new SD.ProcessStartInfo(projectInterpreter, cmdlineArgs);

            psi.RedirectStandardError  = true;
            psi.RedirectStandardOutput = true;
            psi.UseShellExecute        = false;
            var p = SD.Process.Start(psi);

            p.EnableRaisingEvents = true;
            string output = "";

            p.OutputDataReceived += (sender, args) => {
                output += args.Data;
            };
            p.ErrorDataReceived += (sender, args) => {
                output += args.Data;
            };
            p.BeginErrorReadLine();
            p.BeginOutputReadLine();
            p.Exited += (sender, args) => {
                SD.Debug.WriteLine("Process Id ({0}) exited with ExitCode: {1}", p.Id, p.ExitCode);
                SD.Debug.WriteLine(String.Format("Output: {0}", output));
            };

            Assert.IsNotNull(p, "Failure to start process, {0} {1} ", projectInterpreter, cmdlineArgs);
            return(p);
        }
Ejemplo n.º 21
0
        public FakeCakeContext()
        {
            testsDir = new DirectoryPath(Path.GetFullPath(AppContext.BaseDirectory));

            var environment = FakeEnvironment.CreateUnixEnvironment(false);

            var fileSystem = new FakeFileSystem(environment);
            var globber    = new Globber(fileSystem, environment);

            log = new FakeLog();
            var args     = new FakeCakeArguments();
            var registry = new WindowsRegistry();

            var config        = new FakeConfiguration();
            var tools         = new ToolLocator(environment, new ToolRepository(environment), new ToolResolutionStrategy(fileSystem, environment, globber, config));
            var processRunner = new ProcessRunner(fileSystem, environment, log, tools, config);
            var data          = Substitute.For <ICakeDataService>();

            context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry, tools, data, config);
            context.Environment.WorkingDirectory = testsDir;
        }
Ejemplo n.º 22
0
        public static ExtendedModuleInfo?GetModuleInfo(Type type)
        {
            if (!typeof(MBSubModuleBase).IsAssignableFrom(type) || string.IsNullOrWhiteSpace(type.Assembly.Location))
            {
                return(null);
            }

            var fullAssemblyPath = Path.GetFullPath(type.Assembly.Location);

            foreach (var loadedModule in GetExtendedLoadedModules())
            {
                var loadedModuleDirectory = Path.GetFullPath(Path.Combine(Utilities.GetBasePath(), "Modules", loadedModule.Id));
                var relativePath          = new Uri(GetFullPathWithEndingSlashes(loadedModuleDirectory)).MakeRelativeUri(new Uri(fullAssemblyPath));
                if (!relativePath.OriginalString.StartsWith("../"))
                {
                    return(loadedModule);
                }
            }

            return(null);
        }
Ejemplo n.º 23
0
 private void LstProduk_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     // this.ClearForm();
     if (LstService.SelectedItem != null)
     {
         this.listprodukSelected = (produk)LstService.SelectedItem;
         if (this.listprodukSelected != null)
         {
             using (var uow = new UnitOfWork(AppConfig.Current.ContextName))
             {
                 this.produk             = uow.produk.Get(this.listprodukSelected.IdProduk);
                 txtservice.Text         = this.produk.NamaProduk;
                 txtCategory.Text        = this.produk.ProdukKategori;
                 txtSKU.Text             = this.produk.SKU;
                 txtProductGroup.Text    = this.produk.NamaGroupProduk;
                 txtCogs.Text            = this.produk.HargaPokokAverage.GetValueOrDefault(0).ToString();
                 txtPurchasingprice.Text = this.produk.HargaBeli.GetValueOrDefault(0).ToString();
                 txtSellingprice.Text    = this.produk.HargaJual.GetValueOrDefault(0).ToString();
                 txtBaseUnit.Text        = this.produk.SatuanDasar;
                 txtCurrency.Text        = this.produk.MataUang;
                 if (this.produk.CheckboxDiskonProduk == true)
                 {
                     txtDiscountyes.Text = "Yes";
                 }
                 else if (this.produk.CheckboxDiskonProduk == false)
                 {
                     txtDiscountyes.Text = "No";
                 }
                 txtDiscount.Text = this.produk.DiskonProdukPersen;
                 txtPeriode.Text  = this.produk.TanggalMulaiDiskonProduk.GetValueOrDefault().ToShortDateString();
                 txtPeriode1.Text = this.produk.TanggalBerakhirDiskonProduk.GetValueOrDefault().ToShortDateString();
                 txtRemarks.Text  = this.produk.Keterangan;
                 if (!string.IsNullOrEmpty(this.produk.UploadImage0))
                 {
                     Image1.Source = new BitmapImage(new Uri(Path.GetFullPath(this.produk.UploadImage0)));
                 }
             }
         }
     }
 }
        private void Select_btn_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = string.Format("{0}|*{1}", FileTypeName, FileType);
            if (openFileDialog.ShowDialog() == true)
            {
                FileName        = Path.GetFileNameWithoutExtension(openFileDialog.FileName);
                Directory       = Path.GetDirectoryName(openFileDialog.FileName);
                FullPathAndFile = Path.GetFullPath(openFileDialog.FileName);

                if (ShowFullPath)
                {
                    PathBox_L.Content = FullPathAndFile;
                }
                else
                {
                    PathBox_L.Content = ShowFileExtension ? Path.GetFileName(FullPathAndFile) : FileName;
                }
                Select_btn.Content = "Change";
            }
        }
Ejemplo n.º 25
0
        void UpdateImageDirectory(FileImageSource fileSource)
        {
            if (fileSource == null || fileSource.File == null)
            {
                return;
            }

            var imageDirectory = Application.Current.OnThisPlatform().GetImageDirectory();

            if (!string.IsNullOrEmpty(imageDirectory))
            {
                var filePath = fileSource.File;

                var directory = IOPath.GetDirectoryName(filePath);

                if (string.IsNullOrEmpty(directory) || !IOPath.GetFullPath(directory).Equals(IOPath.GetFullPath(imageDirectory)))
                {
                    filePath        = IOPath.Combine(imageDirectory, filePath);
                    fileSource.File = filePath;
                }
            }
        }
        //--------------------------------
        #region Settings

        private void OnExeBrowse(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Title           = "Find Terraria Executable";
            fileDialog.AddExtension    = true;
            fileDialog.DefaultExt      = ".exe";
            fileDialog.Filter          = "Executables (*.exe)|*.exe|All Files (*.*)|*.*";
            fileDialog.FilterIndex     = 0;
            fileDialog.CheckFileExists = true;
            try {
                fileDialog.InitialDirectory = Path.GetFullPath(Patcher.ExeDirectory);
            }
            catch { }
            var result = fileDialog.ShowDialog(this);

            if (result.HasValue && result.Value)
            {
                Patcher.ExePath = fileDialog.FileName;
                textBoxExe.Text = fileDialog.FileName;
                SaveSettings();
            }
        }
Ejemplo n.º 27
0
        public override bool IsAlreadyAdded(out ReferenceNode existingEquivalentNode)
        {
            string fullPath = Path.GetFullPath(InstalledFilePath).Replace('\\', '/');

            ReferenceContainerNode referencesFolder = this.ProjectManager.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            for (HierarchyNode node = referencesFolder.FirstChild; node != null; node = node.NextSibling)
            {
                JarReferenceNode referenceNode = node as JarReferenceNode;
                if (referenceNode != null)
                {
                    string otherFullPath = Path.GetFullPath(referenceNode.InstalledFilePath).Replace('\\', '/');
                    if (string.Equals(fullPath, otherFullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        existingEquivalentNode = referenceNode;
                        return(true);
                    }
                }
            }

            existingEquivalentNode = null;
            return(false);
        }
Ejemplo n.º 28
0
        public static void SaveImage(this IPathCollection shape, int width, int height, params string[] path)
        {
            string fullPath = IOPath.GetFullPath(IOPath.Combine("Output", IOPath.Combine(path)));

            using (var img = new Image <Rgba32>(width, height))
            {
                img.Mutate(i => i.Fill(Color.DarkBlue));

                // In ImageSharp.Drawing.Paths there is an extension method that takes in an IShape directly.
                foreach (IPath s in shape)
                {
                    // In ImageSharp.Drawing.Paths there is an extension method that takes in an IShape directly.
                    img.Mutate(i => i.Fill(Color.HotPink, s));
                }

                // img.Draw(Color.LawnGreen, 1, new ShapePath(shape));

                // Ensure directory exists
                IODirectory.CreateDirectory(IOPath.GetDirectoryName(fullPath));

                img.Save(fullPath);
            }
        }
Ejemplo n.º 29
0
        protected IMarginCore TryGetMarginCore(IWpfTextViewHost textViewHost)
        {
            MarginCore marginCore;

            if (textViewHost.TextView.Properties.TryGetProperty(typeof(MarginCore), out marginCore))
            {
                return(marginCore);
            }

            // play nice with other source control providers
            ITextView      textView       = textViewHost.TextView;
            ITextDataModel textDataModel  = textView != null ? textView.TextDataModel : null;
            ITextBuffer    documentBuffer = textDataModel != null ? textDataModel.DocumentBuffer : null;

            if (documentBuffer == null)
            {
                return(null);
            }

            ITextDocument textDocument;

            if (!TextDocumentFactoryService.TryGetTextDocument(documentBuffer, out textDocument))
            {
                return(null);
            }

            var filename       = textDocument.FilePath;
            var repositoryPath = GitCommands.GetGitRepository(Path.GetFullPath(filename));

            if (repositoryPath == null)
            {
                return(null);
            }

            return(textViewHost.TextView.Properties.GetOrCreateSingletonProperty(
                       () => new MarginCore(textViewHost.TextView, TextDocumentFactoryService, ClassificationFormatMapService, EditorFormatMapService, GitCommands)));
        }
Ejemplo n.º 30
0
        private void CreateDrawing(Document doc)
        {
            double viewScale   = 0.05;
            string templateLoc = "/Autodesk/Skid Packaging Layout.idw";

            // This gets the working directory of the Assembly
            DirectoryInfo parentDir = Directory.GetParent(Path.GetFullPath(doc.FullFileName));

            // Need one more directory up to get to the templates
            DirectoryInfo baseDir = Directory.GetParent(parentDir.FullName);

            string templateFile = baseDir.FullName + templateLoc;

            LogTrace("Adding Drawing template: " + templateFile);
            DrawingDocument drawingDoc = (DrawingDocument)inventorApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templateFile);
            Sheet           sheet      = drawingDoc.Sheets[1];

            Point2d point1 = inventorApplication.TransientGeometry.CreatePoint2d(80, 40); // front view
            Point2d point2 = inventorApplication.TransientGeometry.CreatePoint2d(21, 29); // top view

            LogTrace("Adding Drawing Views...");
            DrawingView baseView      = sheet.DrawingViews.AddBaseView((_Document)doc, point1, viewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "My View");
            DrawingView projectedView = sheet.DrawingViews.AddProjectedView(baseView, point2, DrawingViewStyleEnum.kShadedDrawingViewStyle, viewScale);
        }