Пример #1
0
        public void SetupPunchTypes()
        {
            IsolatedStorageSettings          appSet = IsolatedStorageSettings.ApplicationSettings;
            ObservableCollection <PunchType> ptc    = new ObservableCollection <PunchType>();

            AddStartPunchTypes(ptc);

            String BreakList;

            if (appSet.TryGetValue <String>("Breaks", out BreakList))
            {
                foreach (String BreakName in BreakList.Split(','))
                {
                    if (BreakName.Trim().Length != 0)
                    {
                        ptc.Add(new PunchType("Start " + BreakName, StartEnd.Start, Category.Break));
                    }
                }
            }
            String ProjList;

            if (appSet.TryGetValue <String>("Projects", out ProjList))
            {
                foreach (String ProjName in ProjList.Split(','))
                {
                    if (ProjName.Trim().Length != 0)
                    {
                        ptc.Add(new PunchType("Start " + ProjName, StartEnd.Start, Category.Project));
                    }
                }
            }
            AddEndPunchTypes(ptc);
            App.Inst.PunchList = ptc;
        }
Пример #2
0
 public override void Draw(Vector2 OFFSET, Color COLOR)
 {
     base.Draw(OFFSET, COLOR);
     canvasY.Draw(OFFSET);
     canvasX.Draw(OFFSET);
     cancelBtn.Draw(OFFSET);
     OKBtn.Draw(OFFSET);
     ProjName.Draw(OFFSET);
     Globals.primitives.DrawTxt("width:", new Vector2(10, 65) + pos, Globals.fontSize, Color.Gray);
     Globals.primitives.DrawTxt("height:", new Vector2(125, 65) + pos, Globals.fontSize, Color.Gray);
     Globals.primitives.DrawTxt("name:", new Vector2(10, 35) + pos, Globals.fontSize, Color.Gray);
 }
Пример #3
0
        public CreateEquipementWindow(string name, string type, string os, string version, string ip, string macAddress, string notes)
        {
            InitializeComponent();
            ProjName.Text = name;
            Type.Text     = type;
            Os.Text       = os;
            Version.Text  = version;
            Ip.Text       = ip;
            MacAddr.Text  = macAddress;
            Notes.Text    = notes;

            ProjName.Focus();
        }
Пример #4
0
        private void CreateBaseCommandClass()
        {
            string core = GetProjCoreDirectory();

            if (File.Exists(core + "\\Models\\BaseCommand.cs"))
            {
                MessageBox.Show("This file already exist!", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                File.Create(core + "\\Models\\BaseCommand.cs").Close();

                string content = Resources.BaseCommand;
                content = content.Replace("namespace Models", $"namespace {ProjName}.Models");

                using (StreamWriter sw = new StreamWriter(core + "\\Models\\BaseCommand.cs", false))
                {
                    sw.Write(content);
                }


                if (ProjectType == ProjectType.WPF)
                {
                    bool isCompileAdded = false;

                    XDocument xdoc       = XDocument.Load(core + $"\\{ProjName.Replace("_", " ")}.csproj");
                    var       itemGroups = xdoc.Root.Descendants().Where(x => x.Name.LocalName.Equals("ItemGroup"));

                    foreach (var itemGroup in itemGroups)
                    {
                        var compiles = itemGroup.Descendants().Where(x => x.Name.LocalName.Equals("Compile")).ToList();
                        var pages    = itemGroup.Descendants().Where(x => x.Name.LocalName.Equals("Page")).ToList();

                        if (compiles.Count != 0 || pages.Count != 0)
                        {
                            XElement   compile   = new XElement("Compile");
                            XAttribute attribute = new XAttribute("Include", "Models\\BaseCommand.cs");

                            compile.Add(attribute);
                            itemGroup.Add(compile);

                            xdoc.Save(core + $"\\{ProjName.Replace("_", " ")}.csproj");

                            isCompileAdded = true;

                            break;
                        }
                    }
                }
            }
        }
Пример #5
0
 public override void Update(Vector2 OFFSET)
 {
     if (canvasX.content != "" && int.Parse(canvasX.content) > 1000)
     {
         canvasX.content = "1000";
     }
     if (canvasY.content != "" && int.Parse(canvasY.content) > 1000)
     {
         canvasY.content = "1000";
     }
     base.Update(OFFSET);
     canvasX.Update(OFFSET);
     canvasY.Update(OFFSET);
     cancelBtn.Update(OFFSET);
     OKBtn.Update(OFFSET);
     ProjName.Update(OFFSET);
 }
Пример #6
0
        private string GetProjCoreDirectory()
        {
            string initialDirectory = slnPath;

            if (ProjectType == ProjectType.WPF)
            {
                initialDirectory  = initialDirectory.Replace(Path.GetFileName(slnPath), "");
                initialDirectory += ProjName.Replace("_", " ");

                return(initialDirectory);
            }
            else if (ProjectType == ProjectType.XamarinForms)
            {
                initialDirectory  = initialDirectory.Replace(Path.GetFileName(slnPath), "");
                initialDirectory += $"{ProjName.Replace("_", " ")}\\{ProjName.Replace("_", " ")}";

                return(initialDirectory);
            }
            else
            {
                return("C:\\");
            }
        }
Пример #7
0
        private void ImplementFiles()
        {
            string core = GetProjCoreDirectory();

            if (!Directory.Exists(core + "\\Models"))
            {
                Directory.CreateDirectory(core + "\\Models");
            }
            if (!Directory.Exists(core + "\\Views"))
            {
                Directory.CreateDirectory(core + "\\Views");
            }
            if (!Directory.Exists(core + "\\ViewModels"))
            {
                Directory.CreateDirectory(core + "\\ViewModels");
            }


            if (models.Count == 0)
            {
                CreateBaseCommandClass();
            }
            else
            {
                foreach (DataGridItem model in models)
                {
                    string endPath = core + $"\\Model\\{model.FileName}";

                    string modelContent = "";
                    using (StreamReader sr = new StreamReader(model.FilePath))
                    {
                        modelContent = sr.ReadToEnd();
                    }

                    modelContent = modelContent.Replace($"namespace {ProjName}", $"namespace {ProjName}.Models");

                    using (StreamWriter sw = new StreamWriter(model.FilePath, false))
                    {
                        sw.Write(modelContent);
                    }

                    File.Move(model.FilePath, endPath);

                    if (ProjectType == ProjectType.WPF)
                    {
                        string csprojContent = "";
                        using (StreamReader sr = new StreamReader(core + $"\\{ProjName.Replace("_", " ")}.csproj"))
                        {
                            csprojContent = sr.ReadToEnd();
                        }

                        csprojContent = csprojContent.Replace($"Compile Include=\"{model.FileName}\"", $"Compile Include=\"Models\\{model.FileName}\"");

                        using (StreamWriter sw = new StreamWriter(core + $"\\{ProjName.Replace("_", " ")}.csproj", false))
                        {
                            sw.Write(csprojContent);
                        }
                    }
                }
            }

            if (views.Count == 0)
            {
                if (ProjectType == ProjectType.WPF)
                {
                    File.Create(core + "\\Views\\MainWindow.xaml").Close();
                    File.Create(core + "\\Views\\MainWindow.xaml.cs").Close();

                    string xamlContent = Resources.MainWindow;
                    string csContent   = Resources.MainWindow_xaml;

                    xamlContent = xamlContent.Replace("x:Class=\"Views.MainWindow\"", $"x:Class=\"{ProjName}.Views.MainWindow\"");
                    csContent   = csContent.Replace("using ViewModels;", $"using {ProjName}.ViewModels");
                    csContent   = csContent.Replace("namespace Views", $"namespace {ProjName}.Views");

                    using (StreamWriter sw = new StreamWriter(core + "\\Views\\MainWindow.xaml", false))
                    {
                        sw.Write(xamlContent);
                    }
                    using (StreamWriter sw = new StreamWriter(core + "\\Views\\MainWindow.xaml.cs", false))
                    {
                        sw.Write(csContent);
                    }

                    bool isPageAdded = false;

                    XDocument xdoc       = XDocument.Load(core + $"\\{ProjName.Replace("_", " ")}.csproj");
                    var       itemGroups = xdoc.Root.Descendants().Where(node => node.Name.LocalName.Equals("ItemGroup"));

                    foreach (XElement itemGroup in itemGroups)
                    {
                        var compiles = itemGroup.Descendants().Where(node => node.Name.LocalName.Equals("Compile")).ToList();
                        var pages    = itemGroup.Descendants().Where(node => node.Name.LocalName.Equals("Page")).ToList();

                        if (compiles.Count != 0 || pages.Count != 0)
                        {
                            XElement compile = new XElement("Compile");

                            XAttribute attribute     = new XAttribute("Include", "Views\\MainWindow.xaml.cs");
                            XElement   dependentUpon = new XElement("DependentUpon", "MainWindow.xaml");
                            XElement   subType       = new XElement("SubType", "Code");

                            compile.Add(attribute);
                            compile.Add(dependentUpon);
                            compile.Add(subType);

                            XElement page = new XElement("Page");

                            attribute = new XAttribute("Include", "Views\\MainWindow.xaml");
                            XElement generator = new XElement("Generator", "MSBuils:Compile");
                            subType = new XElement("SubType", "Designer");

                            page.Add(attribute);
                            page.Add(generator);
                            page.Add(subType);

                            itemGroup.Add(page);
                            itemGroup.Add(compile);

                            xdoc.Save(core + $"\\{ProjName.Replace("_", " ")}.csproj");

                            isPageAdded = true;

                            break;
                        }
                    }
                }
                else if (ProjectType == ProjectType.XamarinForms)
                {
                    File.Create(core + "\\Views\\MainPage.xaml");
                    File.Create(core + "\\Views\\MainPage.xaml.cs");

                    string xamlContent = Resources.MainPage;
                    string csContent   = Resources.MainPage_xaml;

                    xamlContent = xamlContent.Replace("x:Class=\"Views.MainPage\"", $"x:Class=\"{ProjName}.Views.MainPage\"");
                    csContent   = csContent.Replace("using ViewModels;", $"using {ProjName}.ViewModels");
                    csContent   = csContent.Replace("namespace Views", $"namespace {ProjName}.Views");

                    using (StreamWriter sw = new StreamWriter(core + "\\Views\\MainPage.xaml", false))
                    {
                        sw.Write(xamlContent);
                    }
                    using (StreamWriter sw = new StreamWriter(core + "\\Views\\MainPage.xaml.cs", false))
                    {
                        sw.Write(csContent);
                    }
                }
            }
            else
            {
                foreach (DataGridItem view in views)
                {
                    string endPath = core + $"\\Views\\{view.FileName}";

                    string viewContent = "";
                    using (StreamReader sr = new StreamReader(view.FilePath))
                    {
                        viewContent = sr.ReadToEnd();
                    }

                    viewContent = viewContent.Replace($"x:Class=\"{ProjName}.{Path.GetFileNameWithoutExtension(view.FilePath)}\"", $"x:Class=\"{ProjName}.Views.{Path.GetFileNameWithoutExtension(view.FilePath)}\"");

                    using (StreamWriter sw = new StreamWriter(view.FilePath, false))
                    {
                        sw.Write(viewContent);
                    }

                    File.Move(view.FilePath, endPath);

                    if (ProjectType == ProjectType.WPF)
                    {
                        string csprojContent = "";
                        using (StreamReader sr = new StreamReader(core + $"\\{ProjName.Replace("_", " ")}.csproj"))
                        {
                            csprojContent = sr.ReadToEnd();
                        }

                        csprojContent = csprojContent.Replace($"Page Include=\"{view.FileName}\"", $"Page Include=\"Views\\{view.FileName}\"");
                        csprojContent = csprojContent.Replace($"Compile Include=\"{view.FileName}.cs\"", $"Compile Include=\"Views\\{view.FileName}.cs\"");

                        using (StreamWriter sw = new StreamWriter(core + $"\\{ProjName.Replace("_", " ")}.csproj", false))
                        {
                            sw.Write(csprojContent);
                        }
                    }


                    view.FilePath += ".cs";


                    endPath = core + $"\\Views\\{view.FileName}";

                    viewContent = "";
                    using (StreamReader sr = new StreamReader(view.FilePath))
                    {
                        viewContent = sr.ReadToEnd();
                    }

                    viewContent = viewContent.Replace($"namespace {ProjName}", $"namespace {ProjName}.Views");

                    using (StreamWriter sw = new StreamWriter(view.FilePath, false))
                    {
                        sw.WriteLine($"using {ProjName}.ViewModels;");
                        sw.Write(viewContent);
                    }

                    File.Move(view.FilePath, endPath);
                }
            }

            if (viewModels.Count == 0)
            {
                CreateBaseViewModelClass();
            }
            else
            {
                foreach (DataGridItem viewModel in viewModels)
                {
                    string endPath = core + $"\\ViewModels\\{viewModel.FileName}";

                    string viewModelContent = "";
                    using (StreamReader sr = new StreamReader(viewModel.FilePath))
                    {
                        viewModelContent = sr.ReadToEnd();
                    }

                    viewModelContent = viewModelContent.Replace($"namespace {ProjName}", $"namespace {ProjName}.ViewModels");

                    using (StreamWriter sw = new StreamWriter(viewModel.FilePath, false))
                    {
                        sw.WriteLine($"using {ProjName}.Models;");
                        sw.Write(viewModelContent);
                    }

                    File.Move(viewModel.FilePath, endPath);

                    if (ProjectType == ProjectType.WPF)
                    {
                        string csprojContent = "";
                        using (StreamReader sr = new StreamReader(core + $"\\{ProjName.Replace("_", " ")}.csproj"))
                        {
                            csprojContent = sr.ReadToEnd();
                        }

                        csprojContent = csprojContent.Replace($"Compile Include=\"{viewModel.FileName}\"", $"Compile Include=\"ViewModels\\{viewModel.FileName}\"");

                        using (StreamWriter sw = new StreamWriter(core + $"\\{ProjName.Replace("_", " ")}.csproj", false))
                        {
                            sw.Write(csprojContent);
                        }
                    }
                }
            }


            if (ProjectType == ProjectType.WPF)
            {
                string appContent = "";
                using (StreamReader sr = new StreamReader(core + "\\App.xaml"))
                {
                    appContent = sr.ReadToEnd();
                }

                string startupUri = "";
                Match  match      = Regex.Match(appContent, $"StartupUri=\"(.*)\" ");

                if (match.Groups.Count > 0)
                {
                    startupUri = match.Groups[0].Value;
                }

                appContent = appContent.Replace($"StartupUri=\"{startupUri}\"", $"StartupUri=\"Views/{startupUri}\"");

                using (StreamWriter sw = new StreamWriter(core + "\\App.xaml", false))
                {
                    sw.Write(appContent);
                }
            }
            else if (ProjectType == ProjectType.XamarinForms)
            {
                string appContent = "";
                using (StreamReader sr = new StreamReader(core + "\\App.xaml.cs"))
                {
                    appContent = sr.ReadToEnd();
                }

                using (StreamWriter sw = new StreamWriter(core + "\\App.xaml.cs", false))
                {
                    sw.WriteLine($"using {ProjName}.Views;");
                    sw.Write(appContent);
                }
            }
        }