Beispiel #1
0
        /// <summary>
        /// Add an item to be considered for the average.
        /// </summary>
        override public void Add(double _item)
        {
            // add the item to the batch
            batch.Add(_item);
            if (batch.Count == batchSize)
            {
                // get the average of the complete batch
                average = 0;
                foreach (double item in batch)
                {
                    average += item;
                }
                average /= batch.Count;

                // calculate the deviation of the complete batch
                deviation = 0;
                foreach (double item in batch)
                {
                    deviation += Meth.Square(item - average);
                }
                deviation = Math.Sqrt(deviation / (batch.Count - 1));

                batch.Reset();
                if (filled)
                {
                    // set a batch average
                    batches[index] = average / batch.Count;
                    ++index;
                    if (index == batches.Count)
                    {
                        index = 0;
                    }
                }
                else
                {
                    // add a new batch average
                    batches.Add(average / batch.Count);
                    filled = batches.Count == batchCount;
                }
            }
            refresh = true;
        }
Beispiel #2
0
        public static void GenerateAngles()
        {
            if (cosines != null && sines != null && bellCurve != null)
            {
                return;
            }
            cosines = new double[anglePercision];
            sines   = new double[anglePercision];

            for (int i = 0; i < anglePercision; i++)
            {
                double t = 2.0 * Math.PI * i / anglePercision;
                cosines[i] = Math.Cos(t);
                sines[i]   = Math.Sin(t);
            }
            bellCurve    = new double[3];
            bellCurve[0] = Meth.BellCurve(-1);
            bellCurve[1] = Meth.BellCurve(+0);
            bellCurve[2] = Meth.BellCurve(+1);
        }
Beispiel #3
0
        ///<summary> dateStart and dateEnd can be MinVal/MaxVal to indicate "forever".</summary>
        public static DataTable GetDowntime(DateTime dateStart, DateTime dateEnd)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd));
            }
            DataTable table = new DataTable();

            table.Columns.Add("Provider");
            table.Columns.Add("Provider Number");
            table.Columns.Add("Total Down-time");

            DataRow row;
            string  command = @"
            
            SELECT  appointment.ProvNum , sec_to_time((sum((CHAR_LENGTH(appointment.Pattern) - CHAR_LENGTH(REPLACE(appointment.Pattern, 'X', ''))) ))*5*60)  AS DownTime
				FROM appointment 
                           
                WHERE EXISTS (	SELECT *
								FROM procedurelog
                                LEFT JOIN procedurecode ON (procedurecode.CodeNum = procedurelog.CodeNum)
                                WHERE procedurelog.AptNum = appointment.AptNum
								AND (procedurecode.ProcCode = 99999 OR procedurecode.ProcCode = 99998) 
                                )
                AND appointment.AptStatus = 5
				AND appointment.AptDateTime BETWEEN "                 + POut.DateT(dateStart) + @" AND " + POut.DateT(dateEnd) + @"
                GROUP BY appointment.ProvNum";

            DataTable raw = ReportsComplex.GetTable(command);

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                row                    = table.NewRow();
                row["Provider"]        = Providers.GetFormalName(PIn.Long(raw.Rows[i]["ProvNum"].ToString()));
                row["Provider Number"] = raw.Rows[i]["ProvNum"].ToString();
                row["Total Down-time"] = raw.Rows[i]["DownTime"].ToString();
                table.Rows.Add(row);
            }

            return(table);
        }
Beispiel #4
0
        ///<summary>Gets all entries from the Signalod table.</summary>
        public static List <Signalod> GetAllSignalods()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <Signalod> >(MethodBase.GetCurrentMethod()));
            }
            List <Signalod> listSignals = null;

            try {
                string command = "";
                if (DataConnection.DBtype == DatabaseType.MySql)
                {
                    command     = "SELECT * FROM signalod";
                    listSignals = OpenDentBusiness.Crud.SignalodCrud.TableToList(DataCore.GetTable(command));
                }
            }
            catch {
                listSignals = new List <Signalod>();
            }
            return(listSignals);
        }
Beispiel #5
0
        public RegistrationKey GetByKey(string regKey)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <RegistrationKey>(MethodBase.GetCurrentMethod(), regKey));
            }
            if (!Regex.IsMatch(regKey, @"^[A-Z0-9]{16}$"))
            {
                throw new ApplicationException("Invalid registration key format.");
            }
            string    command = "SELECT * FROM  registrationkey WHERE RegKey='" + POut.String(regKey) + "'";
            DataTable table   = db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                throw new ApplicationException("Invalid registration key.");
            }
            RegistrationKey key = null;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                key = new RegistrationKey();
                key.RegistrationKeyNum = PIn.Int(table.Rows[i][0].ToString());
                key.PatNum             = PIn.Int(table.Rows[i][1].ToString());
                key.RegKey             = PIn.String(table.Rows[i][2].ToString());
                key.Note         = PIn.String(table.Rows[i][3].ToString());
                key.DateStarted  = PIn.Date(table.Rows[i][4].ToString());
                key.DateDisabled = PIn.Date(table.Rows[i][5].ToString());
                key.DateEnded    = PIn.Date(table.Rows[i][6].ToString());
                key.IsForeign    = PIn.Bool(table.Rows[i][7].ToString());
                //key.UsesServerVersion     =PIn.PBool(table.Rows[i][8].ToString());
                key.IsFreeVersion    = PIn.Bool(table.Rows[i][9].ToString());
                key.IsOnlyForTesting = PIn.Bool(table.Rows[i][10].ToString());
                //key.VotesAllotted         =PIn.PInt(table.Rows[i][11].ToString());
            }
            //if(key.DateDisabled.Year>1880){
            //	throw new ApplicationException("This key has been disabled.  Please call for assistance.");
            //}
            return(key);
        }
Beispiel #6
0
        public static DataTable GetPendingTreatmentProcsPerPat(DateTime dateStart, DateTime dateEnd, String patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd));
            }
            DataTable table = new DataTable();

            table.Columns.Add("Procedure Code");
            table.Columns.Add("Treatment Planned");


            DataRow row;

            string command = @"
				SELECT  pc.Descript, pc.ProcCode 
                FROM procedurelog pl
                JOIN procedurecode pc ON pl.CodeNum = pc.CodeNum
                JOIN appointment a ON a.AptNum = pl.PlannedAptNum
                JOIN patient p ON a.PatNum = p.PatNum
                WHERE pl.AptNum = 0
                AND a.AptStatus = 6
                AND pc.ProcCode != 01202
                AND p.PatNum = '" + patNum + @"'
            ";

            DataTable raw = ReportsComplex.GetTable(command);

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                row = table.NewRow();
                row["Procedure Code"]    = raw.Rows[i]["ProcCode"].ToString();
                row["Treatment Planned"] = raw.Rows[i]["Descript"].ToString();

                table.Rows.Add(row);
            }


            return(table);
        }
Beispiel #7
0
    public void Delete(Entry entry)
    {
        Frame warn = new Frame(30, 30, 5, 60, "Error", ColorScheme.Warning);

        if (entry.type == Entry.Type.Directory)
        {
            try
            {
                DirectoryInfo di = new DirectoryInfo(entry.Path);
                di.Delete(true);
                Meth.WriteLog($"Directory {entry.Path} deleted.");
            }
            catch (Exception e)
            {
                warn.Show(true);
                warn.WriteText(e.Message);
                Meth.WriteLog(e.Message);
                Console.ResetColor();
                Console.ReadKey(true);
            }
        }
        else if (entry.type == Entry.Type.File)
        {
            try
            {
                FileInfo fi = new FileInfo(entry.Path);
                fi.Delete();
                Meth.WriteLog($"File {entry.Path} deleted.");
            }
            catch (Exception e)
            {
                warn.Show(true);
                warn.WriteText(e.Message);
                Meth.WriteLog(e.Message);
                Console.ResetColor();
                Console.ReadKey(true);
            }
        }
    }
Beispiel #8
0
    public void Move(Entry entry, string destinationPath)
    {
        Frame warn = new Frame(30, 30, 5, 60, "Error", ColorScheme.Warning);

        if (entry.type == Entry.Type.Directory)
        {
            try
            {
                DirectoryInfo di = new DirectoryInfo(entry.Path);
                di.MoveTo(destinationPath);
                Meth.WriteLog($"Directory {entry.Path} moved to {destinationPath}");
            }
            catch (Exception e)
            {
                warn.Show(true);
                warn.WriteText(e.Message);
                Meth.WriteLog(e.Message);
                Console.ResetColor();
                Console.ReadKey(true);
            }
        }
        else if (entry.type == Entry.Type.File)
        {
            try
            {
                File.Move(entry.Path, destinationPath);
                Meth.WriteLog($"File {entry.Path} moved to {destinationPath}");
            }
            catch (Exception e)
            {
                warn.Show(true);
                warn.WriteText(e.Message);
                Meth.WriteLog(e.Message);
                Console.ResetColor();
                Console.ReadKey(true);
            }
        }
    }
Beispiel #9
0
    // Update is called once per frame
    void Update()
    {
        transform.localScale = new Vector3(Player.Scale() * (transform.position.x - Player.instance.transform.position.x < 0 ? 1 : -1), Player.Scale(), 1);

        List <Prop> p = new List <Prop>(allProps);

        foreach (var curProp in p)
        {
            if (Meth.distance(curProp.transform.position, transform.position) < Player.Scale() * eatRange)
            {
                ConsumeProp(curProp);
            }
        }


        if (allProps.Count < 1 && Meth.distance(Player.instance.transform.position, transform.position) < Player.Scale() * eatRange && Player.instance.movement.spriteRenderer.enabled)
        {
            sceneSwitchTime = Time.time + 4;
            Player.instance.movement.spriteRenderer.enabled = false;
        }

        if (Time.time < sceneSwitchTime)
        {
            SceneManager.LoadScene(nextLevel);
        }

        // if (allProps.Count < 1 && Meth.distance(Player.instance.transform.position, transform.position) < Player.Scale() * eatRange)
        // {
        //     // Player.instance.transform.position = Vector3.MoveTowards(Player.instance.transform.position, transform.position, Time.deltaTime * 18);
        //     // PlayerCamera.instance.overrideZoomAmount = 0.01f;
        // }
        // else
        // {
        //     PlayerCamera.instance.overrideZoomAmount = -1f;
        // }

        upperMouth.localEulerAngles = Vector3.LerpUnclamped(upperMouth.localEulerAngles, new Vector3(0, 0, 0), Time.deltaTime * 3);
    }
Beispiel #10
0
        ///<summary>Retrieves all registration keys for a particular customer's family. There can be multiple keys assigned to a single customer, or keys assigned to individual family members, since the customer may have multiple physical locations of business.</summary>
        public RegistrationKey[] GetForPatient(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <RegistrationKey[]>(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = "SELECT * FROM registrationkey WHERE ";
            Family fam     = Patients.GetFamily(patNum);

            for (int i = 0; i < fam.ListPats.Length; i++)
            {
                command += "PatNum=" + POut.Long(fam.ListPats[i].PatNum) + " ";
                if (i < fam.ListPats.Length - 1)
                {
                    command += "OR ";
                }
            }
            DataTable table = db.GetTable(command);

            RegistrationKey[] keys = new RegistrationKey[table.Rows.Count];
            for (int i = 0; i < keys.Length; i++)
            {
                keys[i] = new RegistrationKey();
                keys[i].RegistrationKeyNum = PIn.Long(table.Rows[i][0].ToString());
                keys[i].PatNum             = PIn.Long(table.Rows[i][1].ToString());
                keys[i].RegKey             = PIn.String(table.Rows[i][2].ToString());
                keys[i].Note              = PIn.String(table.Rows[i][3].ToString());
                keys[i].DateStarted       = PIn.Date(table.Rows[i][4].ToString());
                keys[i].DateDisabled      = PIn.Date(table.Rows[i][5].ToString());
                keys[i].DateEnded         = PIn.Date(table.Rows[i][6].ToString());
                keys[i].IsForeign         = PIn.Bool(table.Rows[i][7].ToString());
                keys[i].UsesServerVersion = PIn.Bool(table.Rows[i][8].ToString());
                keys[i].IsFreeVersion     = PIn.Bool(table.Rows[i][9].ToString());
                keys[i].IsOnlyForTesting  = PIn.Bool(table.Rows[i][10].ToString());
                keys[i].VotesAllotted     = PIn.Int(table.Rows[i][11].ToString());
            }
            return(keys);
        }
Beispiel #11
0
        private void InvokeMessageReceiveMethod(object ReceiverObject, object MessageToPublish)
        {
            List <MethodInfo> MethodsToCall = new List <MethodInfo>();

            MethodInfo[] Methods = ReceiverObject.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance);

            foreach (MethodInfo Meth in Methods)
            {
                object[] AttributesFound = Meth.GetCustomAttributes(typeof(ReceiveMessageAttribute), false);

                if (AttributesFound.Length == 1)
                {
                    ReceiveMessageAttribute AttributeFound = AttributesFound.FirstOrDefault() as ReceiveMessageAttribute;

                    if (AttributeFound != null)
                    {
                        if (AttributeFound.IsAllowReceive)
                        {
                            ParameterInfo[] Parameters = Meth.GetParameters();

                            if (Parameters.Length == 1)
                            {
                                if (Parameters[0].ParameterType == typeof(object))
                                {
                                    MethodsToCall.Add(Meth);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < MethodsToCall.Count; i++)
            {
                MethodsToCall[i].Invoke(ReceiverObject, new Object[] { MessageToPublish });
            }
        }
Beispiel #12
0
        //-------------------------------------------//

        override protected void Calculate()
        {
            average = 0;
            // add items from current unfinished batch
            foreach (double item in batch)
            {
                average += item;
            }
            // add previous batches, optionally with weights.
            if (batchWeightSet)
            {
                foreach (double item in batches)
                {
                    average += item * batchWeight;
                }
                average /= (batch.Count + batches.Count * batchWeight);
            }
            else
            {
                foreach (double item in batches)
                {
                    average += item;
                }
                average /= (batch.Count + batches.Count);
            }
            // calculate the deviation
            deviation = 0;
            foreach (double item in batch)
            {
                deviation += Meth.Square(item - average);
            }
            foreach (double item in batches)
            {
                deviation += Meth.Square(item - average);
            }
            deviation = Math.Sqrt(deviation / (batch.Count + batches.Count - 1));
        }
Beispiel #13
0
            public SettingPage()
            {
                this.Name = "Settings";
                this.Dock = DockStyle.Fill;
                Meth.HandleTheme(this);

                CheckBox ToggleDarkMode = new CheckBox();

                if (Settings.DarkTheme)
                {
                    ToggleDarkMode.Checked = true;
                }
                ToggleDarkMode.Text     = "Enable Dark Mode";
                ToggleDarkMode.AutoSize = true;
                ToggleDarkMode.Click   += (s, e) => {
                    Settings.DarkTheme = ToggleDarkMode.Checked;
                    GDTools.SaveKeyToUserData("dark-mode", ToggleDarkMode.Checked ? "1" : "0");
                    Program.MainForm.Reload();
                };

                CheckBox ToggleBackupCompression = new CheckBox();

                if (Settings.CompressBackups)
                {
                    ToggleBackupCompression.Checked = true;
                }
                ToggleBackupCompression.Text     = "Compress backups";
                ToggleBackupCompression.AutoSize = true;
                ToggleBackupCompression.Click   += (s, e) => {
                    Settings.CompressBackups = ToggleBackupCompression.Checked;
                    GDTools.SaveKeyToUserData("compress-backups", ToggleBackupCompression.Checked ? "1" : "0");
                };

                CheckBox ToggleDevMode = new CheckBox();

                if (Settings.DevMode)
                {
                    ToggleDevMode.Checked = true;
                }
                ToggleDevMode.Text     = "Enable Developer Mode (Experimental features)";
                ToggleDevMode.AutoSize = true;
                ToggleDevMode.Click   += (s, e) => {
                    Settings.DevMode = ToggleDevMode.Checked;
                    GDTools.SaveKeyToUserData("dev-mode", ToggleDevMode.Checked ? "1" : "0");
                };

                Elem.Input CCPathInput = new Elem.Input("__inp_cc_path", "ANY", "", GDTools.GetCCPath(""), true, false, true);

                this.Controls.Add(ToggleDarkMode);
                this.Controls.Add(ToggleBackupCompression);
                this.Controls.Add(ToggleDevMode);

                this.Controls.Add(new Elem.BigNewLine());
                this.Controls.Add(new Elem.Text("GeometryDash data folder path:"));
                this.Controls.Add(CCPathInput);
                this.Controls.Add(new Elem.Div(new Control[] {
                    new Elem.But("Set", (s, e) => {
                        try {
                            SetCCFolder(CCPathInput.Text);
                        } catch (Exception) {};
                    }),
                    new Elem.But("Browse", (s, e) => {
                        using (FolderBrowserDialog ofd = new FolderBrowserDialog()) {
                            ofd.Description = "Select CC directory";

                            if (ofd.ShowDialog() == DialogResult.OK)
                            {
                                CCPathInput.Text = ofd.SelectedPath;
                            }
                        }
                    })
                }));

                this.Controls.Add(new Elem.BigNewLine());

                this.Controls.Add(new Elem.But("Check for updates", (s, e) => {
                    Program.CheckForUpdates();
                }));
                this.Controls.Add(new Elem.But("Help", (s, e) => {
                    Elem.ChooseForm Help = new Elem.ChooseForm("Help",
                                                               new string[] { "Exporting / Importing levels", "Backups" },
                                                               "What would you like help with?");

                    Help.Show();

                    Help.Finish += s => {
                        switch (s)
                        {
                        case 0: ShowHelp("share"); break;

                        case 1: ShowHelp("backups"); break;
                        }
                    };
                }));
                this.Controls.Add(new Elem.But("Reload app", (s, e) => Program.MainForm.FullReload()));

                this.Controls.Add(new Elem.BigNewLine());

                this.Controls.Add(new Elem.Text("In case you need specific help, message HJfod on Discord at HJfod#1795.\r\n"));

                this.Controls.Add(new Elem.Link("Support server", "https://discord.gg/ZvV7zjj"));
                this.Controls.Add(new Elem.Link("Github repository", "https://github.com/HJfod/gdtools"));
            }
Beispiel #14
0
            public Collabs()
            {
                this.Name = "Collab";
                this.Dock = DockStyle.Fill;
                Meth.HandleTheme(this);

                TableLayoutPanel con = new TableLayoutPanel();

                con.AutoSize = true;
                con.Visible  = Settings.DevMode;

                MergeList = new Elem.Select(false);
                MergeBase = new Elem.Text("Base not selected");

                FlowLayoutPanel MergeControls = new FlowLayoutPanel();

                MergeControls.AutoSize = true;

                MergeControls.Controls.Add(new Elem.But("Set base", (s, e) => {
                    Elem.ChooseForm Select = new Elem.ChooseForm("Select base source",
                                                                 new string[] { "Set base from file", "Set base from local levels", "Set base by ID" });

                    Select.Show();

                    Select.Finish += res => {
                        if (res == 0)
                        {
                            using (OpenFileDialog ofd = new OpenFileDialog()) {
                                ofd.InitialDirectory = "c:\\";
                                ofd.Filter           = GDTools.Ext.Filter;
                                ofd.FilterIndex      = 1;
                                ofd.RestoreDirectory = true;
                                ofd.Multiselect      = true;

                                if (ofd.ShowDialog() == DialogResult.OK)
                                {
                                    foreach (string file in ofd.FileNames)
                                    {
                                        Elem.MsgBox LoadInfo = new Elem.MsgBox("Loading...");
                                        LoadInfo.Show();
                                        AddBase(file);
                                        LoadInfo.Close();
                                        LoadInfo.Dispose();
                                    }
                                }
                            }
                        }
                        else if (res == 1)
                        {
                            Form Choose = new Form();
                            Choose.Text = "Double-click to select";
                            Choose.Size = new Size(400, 300);
                            Meth.HandleTheme(Choose);

                            Elem.Select ExportSelect = new Elem.Select(false);

                            EventHandler Pick = (s, e) => {
                                if (ExportSelect.SelectedItem == null)
                                {
                                    return;
                                }
                                AddBase(((Elem.Select.SelectItem)ExportSelect.SelectedItem).Text);
                                Choose.Close();
                                Choose.Dispose();
                            };

                            ExportSelect.DoubleClick += Pick;

                            foreach (dynamic lvl in GDTools.GetLevelList())
                            {
                                ExportSelect.AddItem(lvl.Name);
                            }

                            Choose.Controls.Add(ExportSelect);

                            Choose.Show();
                        }
                        else if (res == 2)
                        {
                            Elem.ChooseForm c = new Elem.ChooseForm("Type Level ID",
                                                                    new string[] { "IS-INPUT::INT", "::Add", "Cancel" },
                                                                    "Type in level ID"
                                                                    );

                            c.Show();

                            c.FinishStr += resc => {
                                if (resc != "")
                                {
                                    Elem.MsgBox LoadInfo = new Elem.MsgBox("Loading...");
                                    LoadInfo.Show();

                                    string r = GDTools.RequestGDLevel(resc);

                                    if (r.StartsWith("-"))
                                    {
                                        MessageBox.Show($"Error: {GDTools.VerifyRequest(r)}", "Could not get level!");
                                    }

                                    AddBase($"{resc} ({GDTools.GetRequestKey(r, "2")})");

                                    LoadInfo.Dispose();
                                }
                            };
                        }
                    };
                }));
                MergeControls.Controls.Add(new Elem.But("Add part(s)", (s, e) => {
                    Elem.ChooseForm Select = new Elem.ChooseForm("Select part source",
                                                                 new string[] { "Add part(s) from file", "Add part(s) from local levels", "Add part(s) by ID" });

                    Select.Show();

                    Select.Finish += res => {
                        if (res == 0)
                        {
                            using (OpenFileDialog ofd = new OpenFileDialog()) {
                                ofd.InitialDirectory = "c:\\";
                                ofd.Filter           = GDTools.Ext.Filter;
                                ofd.FilterIndex      = 1;
                                ofd.RestoreDirectory = true;
                                ofd.Multiselect      = true;

                                if (ofd.ShowDialog() == DialogResult.OK)
                                {
                                    foreach (string file in ofd.FileNames)
                                    {
                                        Elem.MsgBox LoadInfo = new Elem.MsgBox("Loading...");
                                        LoadInfo.Show();
                                        AddMerge(file);
                                        LoadInfo.Close();
                                        LoadInfo.Dispose();
                                    }
                                }
                            }
                        }
                        else if (res == 1)
                        {
                            Form Choose = new Form();
                            Choose.Text = "Double-click to select";
                            Choose.Size = new Size(400, 300);
                            Meth.HandleTheme(Choose);

                            Elem.Select ExportSelect = new Elem.Select();

                            EventHandler Pick = (s, e) => {
                                if (ExportSelect.SelectedItems[0] == null)
                                {
                                    return;
                                }
                                foreach (Elem.Select.SelectItem x in ExportSelect.SelectedItems)
                                {
                                    AddMerge(x.Text);
                                }
                                Choose.Close();
                                Choose.Dispose();
                            };

                            ExportSelect.DoubleClick += Pick;

                            foreach (dynamic lvl in GDTools.GetLevelList())
                            {
                                ExportSelect.AddItem(lvl.Name);
                            }

                            Choose.Controls.Add(new Elem.Div(new Control[] {
                                ExportSelect,
                                new Elem.But("Select", Pick)
                            }));

                            Choose.ShowDialog(Select);
                        }
                        else if (res == 2)
                        {
                            Elem.ChooseForm c = new Elem.ChooseForm("Type Level ID(s)",
                                                                    new string[] { "IS-INPUT-BIG::INS", "::Add", "Cancel" },
                                                                    "Type in level ID(s) (Separated by spaces)"
                                                                    );

                            c.Show();

                            c.FinishStr += resc => {
                                if (resc != "")
                                {
                                    int i          = 0;
                                    string[] rescs = resc.Split(" ");
                                    foreach (string ress in rescs)
                                    {
                                        i++;
                                        Elem.MsgBox LoadInfo = new Elem.MsgBox($"Loading ({i}/{rescs.Length})...");
                                        LoadInfo.Show();

                                        if (ress.Length < 3)
                                        {
                                            LoadInfo.Dispose();
                                            continue;
                                        }

                                        string r = GDTools.RequestGDLevel(ress);

                                        if (r.StartsWith("-"))
                                        {
                                            MessageBox.Show($"Error with {ress}: {GDTools.VerifyRequest(r)}", "Could not get level!");
                                            LoadInfo.Dispose();
                                            continue;
                                        }

                                        AddMerge($"{ress} ({GDTools.GetRequestKey(r, "2")})");

                                        LoadInfo.Dispose();
                                    }
                                }
                            };
                        }
                    };
                }));
                MergeControls.Controls.Add(new Elem.But("Remove part", (s, e) => {
                    if (MergeList.SelectedItem == null)
                    {
                        return;
                    }
                    MergeList.Items.Remove(MergeList.SelectedItem);
                }));
                MergeControls.Controls.Add(new Elem.But("Merge", (s, e) => {
                    string err = MergeParts();
                    if (err.Length > 0)
                    {
                        MessageBox.Show(err, "Error merging");
                    }
                }));

                CheckBox UseReferenceToggle = new CheckBox();

                UseReferenceToggle.Text     = "Use reference objects";
                UseReferenceToggle.AutoSize = true;
                UseReferenceToggle.Checked  = UseReferenceObjects;
                UseReferenceToggle.Click   += (s, e) =>
                                              UseReferenceObjects = UseReferenceToggle.Checked;

                CheckBox MergeLinkToggle = new CheckBox();

                MergeLinkToggle.Text                           = "Link part objects";
                MergeLinkToggle.AutoSize                       = true;
                MergeLinkToggle.Click                         += (s, e) =>
                                                     MergeLink = MergeLinkToggle.Checked;

                CheckBox AutoReassignToggle = new CheckBox();

                AutoReassignToggle.Text     = "Reassign groups and colours";
                AutoReassignToggle.AutoSize = true;
                AutoReassignToggle.Checked  = AutoReassignGroups;
                AutoReassignToggle.Click   += (s, e) =>
                                              AutoReassignGroups = AutoReassignToggle.Checked;

                con.Controls.Add(new Elem.Text("Part merging"));
                con.Controls.Add(MergeList);
                con.Controls.Add(MergeBase);
                con.Controls.Add(MergeControls);
                con.Controls.Add(MergeLinkToggle);
                con.Controls.Add(AutoReassignToggle);
                con.Controls.Add(UseReferenceToggle);

                this.Controls.Add(con);
                if (!Settings.DevMode)
                {
                    this.Controls.Add(new Elem.DevToolWarning((s, e) => { con.Visible = true; }));
                }
            }
Beispiel #15
0
        ///<summary>If not using clinics then supply an empty list of clinicNums. dateStart and dateEnd can be MinVal/MaxVal to indicate "forever".</summary>
        public static DataTable GetByReferralSource(DateTime dateStart, DateTime dateEnd)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd));
            }
            DataTable table = new DataTable();

            table.Columns.Add("Name");
            table.Columns.Add("Gender");
            table.Columns.Add("Age");
            table.Columns.Add("Date of Service");
            table.Columns.Add("Referral Source");
            DataRow row;
            string  command = @"
                SELECT p.LName AS PLName, p.FName AS PFName, p.MiddleI, p.Gender, p.Preferred, l.ProcDate, p.Birthdate, 
						r.LName, r.FName, r.IsDoctor
		        FROM patient p
                    INNER JOIN procedurelog l ON l.PatNum = p.PatNum 
                    INNER JOIN procedurecode c ON c.CodeNum = l.CodeNum
                    INNER JOIN refattach a ON p.PatNum = a.PatNum
                    INNER JOIN referral r ON a.ReferralNum = r.ReferralNum
                        WHERE (c.ProcCode = 01101 OR c.ProcCode = 01102 OR c.ProcCode = 01103) AND
                        (l.ProcDate BETWEEN " + POut.DateT(dateStart) + @" AND " + POut.DateT(dateEnd) + @") 
                        GROUP BY p.PatNum";

            DataTable raw = ReportsComplex.GetTable(command);
            Patient   pat;
            String    referralsource;

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                row            = table.NewRow();
                pat            = new Patient();
                referralsource = raw.Rows[i]["Lname"].ToString() + ", " + raw.Rows[i]["FName"].ToString();
                if (raw.Rows[i]["IsDoctor"].ToString() == "1")
                {
                    referralsource += " (Doctor)";
                }
                pat.LName     = raw.Rows[i]["PLName"].ToString();
                pat.FName     = raw.Rows[i]["PFName"].ToString();
                pat.MiddleI   = raw.Rows[i]["MiddleI"].ToString();
                pat.Preferred = raw.Rows[i]["Preferred"].ToString();

                row["Name"]   = pat.GetNameLF();
                row["Gender"] = genderFormat(raw.Rows[i]["Gender"].ToString());

                if (birthdate_to_age(raw.Rows[i]["Birthdate"].ToString()) < 150)
                {
                    row["Age"] = birthdate_to_age(raw.Rows[i]["Birthdate"].ToString());
                }
                else
                {
                    row["Age"] = "N/A";
                }

                row["Date of Service"] = raw.Rows[i]["ProcDate"].ToString();
                row["Referral Source"] = referralsource;
                table.Rows.Add(row);
            }
            return(resort(table, "Referral Source", "ASC"));
        }
Beispiel #16
0
        public static DataTable GetPendingTreatments(DateTime dateStart, DateTime dateEnd)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd));
            }
            DataTable table = new DataTable();

            table.Columns.Add("PatNum");
            table.Columns.Add("Name");
            table.Columns.Add("Home Phone");
            table.Columns.Add("Work Phone");
            table.Columns.Add("Wireless Phone");
            table.Columns.Add("Email");
            table.Columns.Add("Procedure Code");
            table.Columns.Add("Treatment Planned");


            DataRow row;

            string command = @"
				SELECT p.PatNum, p.LName, p.FName, p.MiddleI, p.Gender, p.Zip, p.PriProv, 
                           p.HmPhone, p.WkPhone, p.WirelessPhone, p.Email, pc.Descript, pc.ProcCode 
                FROM procedurelog pl
                JOIN procedurecode pc ON pl.CodeNum = pc.CodeNum
                JOIN appointment a ON a.AptNum = pl.PlannedAptNum
                JOIN patient p ON a.PatNum = p.PatNum
                WHERE pl.AptNum = 0
                AND a.AptStatus = 6
                AND pc.ProcCode != 01202
                ";


            DataTable raw = ReportsComplex.GetTable(command);
            Patient   pat;

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                row               = table.NewRow();
                pat               = new Patient();
                pat.LName         = raw.Rows[i]["LName"].ToString();
                pat.FName         = raw.Rows[i]["FName"].ToString();
                pat.MiddleI       = raw.Rows[i]["MiddleI"].ToString();
                row["Name"]       = pat.GetNameLF();
                pat.HmPhone       = raw.Rows[i]["HmPhone"].ToString();
                pat.WkPhone       = raw.Rows[i]["WkPhone"].ToString();
                pat.WirelessPhone = raw.Rows[i]["WirelessPhone"].ToString();
                pat.Email         = raw.Rows[i]["Email"].ToString();

                row["Home Phone"]     = raw.Rows[i]["HmPhone"].ToString();
                row["Work Phone"]     = raw.Rows[i]["WkPhone"].ToString();
                row["Wireless Phone"] = raw.Rows[i]["WirelessPhone"].ToString();
                row["Email"]          = raw.Rows[i]["Email"].ToString();

                row["Procedure Code"]    = raw.Rows[i]["ProcCode"].ToString();
                row["Treatment Planned"] = raw.Rows[i]["Descript"].ToString();

                table.Rows.Add(row);
            }
            return(table);
        }
Beispiel #17
0
        ///<summary>If not using clinics then supply an empty list of clinicNums. dateStart and dateEnd can be MinVal/MaxVal to indicate "forever".</summary>
        public static DataTable GetNewToRecall(DateTime dateStart, DateTime dateEnd)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd));
            }
            DataTable table = new DataTable();

            table.Columns.Add("Name");
            table.Columns.Add("Gender");
            table.Columns.Add("Age");
            table.Columns.Add("Type of Recall");
            DataRow row;
            string  command = @"
               SELECT p.LName, p.FName, p.MiddleI, p.Gender, p.Preferred, p.Birthdate, t1.Description  
	FROM patient p 
		INNER JOIN procedurelog l ON l.PatNum = p.PatNum 
		INNER JOIN procedurecode c ON c.CodeNum = l.CodeNum
        INNER JOIN recalltrigger t2 ON c.CodeNum = t2.CodeNum
        INNER JOIN recalltype t1 ON t2.RecallTypeNum = t1.RecallTypeNum
                WHERE c.ProcCode = 01202 AND
					  (l.ProcDate BETWEEN "                     + POut.DateT(dateStart) + @" AND " + POut.DateT(dateEnd) + @") AND
                      l.PatNum IN (SELECT p2.PatNum
								FROM patient p2
									INNER JOIN procedurelog l2 ON l2.PatNum = p2.PatNum 
									INNER JOIN procedurecode c2 ON c2.CodeNum = l2.CodeNum
								WHERE (c2.ProcCode = 01101 OR c2.ProcCode = 01102 OR c2.ProcCode = 01103) AND
										l2.ProcDate < l.ProcDate AND
                                        l2.ProcDate > (DATE_SUB(l.ProcDate,INTERVAL 1 YEAR)))
                GROUP BY p.PatNum";

            DataTable rawrecall = ReportsComplex.GetTable(command);

            Patient pat;
            String  recalltype;

            for (int j = 0; j < rawrecall.Rows.Count; j++)
            {
                row = table.NewRow();
                pat = new Patient();

                recalltype = rawrecall.Rows[j]["Description"].ToString();
                if (recalltype == null || recalltype == "")
                {
                    recalltype = "Default";
                }
                pat.LName     = rawrecall.Rows[j]["LName"].ToString();
                pat.FName     = rawrecall.Rows[j]["FName"].ToString();
                pat.MiddleI   = rawrecall.Rows[j]["MiddleI"].ToString();
                pat.Preferred = rawrecall.Rows[j]["Preferred"].ToString();

                row["Name"]   = pat.GetNameLF();
                row["Gender"] = genderFormat(rawrecall.Rows[j]["Gender"].ToString());

                if (birthdate_to_age(rawrecall.Rows[j]["Birthdate"].ToString()) < 150)
                {
                    row["Age"] = birthdate_to_age(rawrecall.Rows[j]["Birthdate"].ToString());
                }
                else
                {
                    row["Age"] = "N/A";
                }

                row["Type of Recall"] = recalltype;
                table.Rows.Add(row);
            }

            return(table);
        }
        ///<summary> dateStart and dateEnd can be MinVal/MaxVal to indicate "forever".</summary>
        public static List <object> GetNonProductivePracticeTime(DateTime dateStart, DateTime dateEnd)
        {
            List <object> tableAndTotal = new List <object>();

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                tableAndTotal.Add(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd));
                tableAndTotal.Add("");
                return(tableAndTotal);
            }
            DataTable table = new DataTable();

            table.Columns.Add("Name");
            table.Columns.Add("Gender");
            table.Columns.Add("Age");
            table.Columns.Add("Postal Code");
            table.Columns.Add("Date of Service");
            table.Columns.Add("Primary Provider");
            table.Columns.Add("Procedure Description");
            table.Columns.Add("Non-Productive Practice Time");
            DataRow row;
            string  command = @"
            SELECT p.LName, p.FName, p.MiddleI, p.Gender, p.Zip, p.PriProv, p.Preferred, p.Birthdate, r.ProcDate, a.ProcDescript, a.Pattern
                FROM patient p 
                JOIN procedurelog r ON r.PatNum = p.PatNum
                JOIN procedurecode c ON r.CodeNum = c.CodeNum
                JOIN appointment a ON a.AptNum = r.AptNum
                WHERE c.ProcCode = 99999 OR 99998 AND 
                a.AptStatus = 5 AND 
                a.AptDateTime BETWEEN " + POut.DateT(dateStart) + @" AND " + POut.DateT(dateEnd);

            int runningTimeTotal = 0;

            DataTable raw = ReportsComplex.GetTable(command);
            Patient   pat;

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                runningTimeTotal = runningTimeTotal + PatternToSeconds(raw.Rows[i]["Pattern"].ToString());
                row                                 = table.NewRow();
                pat                                 = new Patient();
                pat.LName                           = raw.Rows[i]["LName"].ToString();
                pat.FName                           = raw.Rows[i]["FName"].ToString();
                pat.MiddleI                         = raw.Rows[i]["MiddleI"].ToString();
                pat.Preferred                       = raw.Rows[i]["Preferred"].ToString();
                row["Name"]                         = pat.GetNameLF();
                row["Primary Provider"]             = Providers.GetAbbr(PIn.Long(raw.Rows[i]["PriProv"].ToString()));
                row["Gender"]                       = genderFormat(raw.Rows[i]["Gender"].ToString());
                row["Postal Code"]                  = raw.Rows[i]["Zip"].ToString();
                row["Date of Service"]              = raw.Rows[i]["ProcDate"].ToString().Substring(0, 10);
                row["Procedure Description"]        = raw.Rows[i]["ProcDescript"].ToString();
                row["Age"]                          = birthdate_to_age(raw.Rows[i]["Birthdate"].ToString());
                row["Non-Productive Practice Time"] = sec_to_time(PatternToSeconds(raw.Rows[i]["Pattern"].ToString()));
                table.Rows.Add(row);
            }

            tableAndTotal.Add(table);
            tableAndTotal.Add(sec_to_time(runningTimeTotal));

            return(tableAndTotal);
        }
Beispiel #19
0
 ///<summary>Fills the missing data field on the queueItem that was passed in.  This contains all missing data on this claim.  Claim will not be allowed to be sent electronically unless this string comes back empty.</summary>
 public static ClaimSendQueueItem GetMissingData(Clearinghouse clearinghouseClin, ClaimSendQueueItem queueItem)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetObject <ClaimSendQueueItem>(MethodBase.GetCurrentMethod(), clearinghouseClin, queueItem));
     }
     queueItem.Warnings    = "";
     queueItem.MissingData = "";
     //this is usually just the default clearinghouse or the clearinghouse for the PayorID.
     if (clearinghouseClin == null)
     {
         if (queueItem.MedType == EnumClaimMedType.Dental)
         {
             queueItem.MissingData += "No default dental clearinghouse set.";
         }
         else
         {
             queueItem.MissingData += "No default medical/institutional clearinghouse set.";
         }
         return(queueItem);
     }
     #region Data Sanity Checking (for Replication)
     //Example: We had one replication customer who was able to delete an insurance plan for which was attached to a claim.
     //Imagine two replication servers, server A and server B.  An insplan is created which is not associated to any claims.
     //Both databases have a copy of the insplan.  The internet connection is lost.  On server A, a user deletes the insurance
     //plan (which is allowed because no claims are attached).  On server B, a user creates a claim with the insurance plan.
     //When the internet connection returns, the delete insplan statement is run on server B, which then creates a claim with
     //an invalid InsPlanNum on server B.  Without the checking below, the send claims window would crash for this one scenario.
     Claim   claim   = Claims.GetClaim(queueItem.ClaimNum); //This should always exist, because we just did a select to get the queue item.
     InsPlan insPlan = InsPlans.RefreshOne(claim.PlanNum);
     if (insPlan == null)                                   //Check for missing PlanNums
     {
         queueItem.MissingData = Lans.g("Eclaims", "Claim insurance plan record missing.  Please recreate claim.");
         return(queueItem);
     }
     if (claim.InsSubNum2 != 0)
     {
         InsPlan insPlan2 = InsPlans.RefreshOne(claim.PlanNum2);
         if (insPlan2 == null)               //Check for missing PlanNums
         {
             queueItem.MissingData = Lans.g("Eclaims", "Claim other insurance plan record missing.  Please recreate claim.");
             return(queueItem);                   //This will let the office send other claims that passed validation without throwing an exception.
         }
     }
     #endregion Data Sanity Checking (for Replication)
     if (clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_4010)
     {
         X837_4010.Validate(clearinghouseClin, queueItem);               //,out warnings);
         //return;
     }
     else if (clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_5010_dental ||
              clearinghouseClin.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
     {
         X837_5010.Validate(clearinghouseClin, queueItem);               //,out warnings);
         //return;
     }
     else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Renaissance)
     {
         queueItem.MissingData = Renaissance.GetMissingData(queueItem);
         //return;
     }
     else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Canadian)
     {
         queueItem.MissingData = Canadian.GetMissingData(queueItem);
         //return;
     }
     else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Dutch)
     {
         Dutch.GetMissingData(queueItem);                //,out warnings);
         //return;
     }
     else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Ramq)
     {
         Ramq.GetMissingData(queueItem);
     }
     return(queueItem);
 }
Beispiel #20
0
    public void Create(Entry entry, char type)
    {
        Frame warn     = new Frame(30, 30, 5, 60, "Error", ColorScheme.Warning);
        Frame readLine = new Frame(30, 30, 5, 60, "Input Name", ColorScheme.BIOS);

        string name;

        switch (type)
        {
        case 'D':
        case 'd':
            readLine.Show(true);
            readLine.SetColor(ColorsPreset.ContextNormal);
            readLine.WriteText("".PadRight(readLine.Geometry.Cols - 2, ' '));
            readLine.SetCursorPosition(0, 0);
            name = Console.ReadLine();
            if (!Directory.Exists($"{entry.Path}\\{name}"))
            {
                try
                {
                    DirectoryInfo di = new DirectoryInfo($"{entry.Path}\\{name}");
                    di.Create();
                    Meth.WriteLog($"Created new directory {entry.Path}\\{name}");
                }
                catch (Exception e)
                {
                    warn.Show(true);
                    warn.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            else
            {
                warn.Show(true);
                warn.WriteText("Directory already exist.");
                Meth.WriteLog($"Failed to create new directory {entry.Path}\\{name}");
                Console.ResetColor();
                Console.ReadKey(true);
            }
            break;

        case 'F':
        case 'f':
            readLine.Show(true);
            readLine.SetColor(ColorsPreset.ContextNormal);
            readLine.WriteText("".PadRight(readLine.Geometry.Cols - 2, ' '));
            readLine.SetCursorPosition(0, 0);
            name = Console.ReadLine();
            if (!File.Exists($"{entry.Path}\\{name}"))
            {
                try
                {
                    FileStream fs = File.Create($"{entry.Path}\\{name}");
                    fs.Close();
                    Meth.WriteLog($"Created new file {entry.Path}\\{name}");
                }
                catch (Exception e)
                {
                    warn.Show(true);
                    warn.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            else
            {
                warn.Show(true);
                warn.WriteText("File already exist.");
                Meth.WriteLog($"Failed to create new file {entry.Path}\\{name}");
                Console.ResetColor();
                Console.ReadKey(true);
            }
            break;

        default: break;
        }
    }
Beispiel #21
0
    public void Copy(Entry entry, string destinationPath)
    {
        Frame warn      = new Frame(30, 30, 5, 60, "Error", ColorScheme.Warning);
        Frame question  = new Frame((30, 30, 5, 60), "Overwrite?", ColorScheme.Warning);
        bool  overwrite = false;

        if (entry.type == Entry.Type.File)
        {
            if (File.Exists(destinationPath))
            {
                question.Show(true);
                question.WriteText("File already exist, overwrite this? [Y/N]");
                Console.ReadKey(true);
                if (Console.ReadKey(true).Key == ConsoleKey.Y)
                {
                    overwrite = true;
                }
                else
                {
                    return;
                }
            }
            FileInfo fi = new FileInfo($@"{entry.Path}\{entry.Name}");
            try
            {
                logger.WriteLog($"Try Copy {fi.FullName} to {destinationPath}.");
                fi.CopyTo(destinationPath, overwrite);
                logger.WriteLog($"{fi.FullName} Copyed to {destinationPath}.");
            }
            catch (Exception e)
            {
                logger.WriteLog(e.Message);
                warn.Show(true);
                warn.WriteText(e.Message);
                Meth.WriteLog(e.Message);
                Console.ResetColor();
                Console.ReadKey(true);
            }
        }
        else if (entry.type == Entry.Type.Directory)
        {
            if (Directory.Exists(destinationPath))
            {
                question.Show(true);
                question.WriteText("Directory already exist, overwrite all entryes? [Y/N]");
                Console.ReadKey(true);
                if (Console.ReadKey(true).Key == ConsoleKey.Y)
                {
                    overwrite = true;
                }
                else
                {
                    return;
                }
            }
            try
            {
                DirectoryInfo dis = new DirectoryInfo($@"{entry.Path}\{entry.Name}");
                DirectoryInfo dit = new DirectoryInfo(destinationPath);
                CopyDir(dis, dit);
            }
            catch (Exception e)
            {
                logger.WriteLog(e.Message);
                warn.Show(true);
                warn.WriteText(e.Message);
                Meth.WriteLog(e.Message);
                Console.ResetColor();
                Console.ReadKey(true);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Grab();
        }

        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            UnGrab();
        }

        if (currentProp)
        {
            // currentProp.transform.localPosition = Vector3.MoveTowards(currentProp.transform.localPosition, Vector2.zero, Time.deltaTime);
            // currentProp.transform.localPosition = Vector3.MoveTowards(currentProp.transform.localPosition, lockPoint.InverseTransformPoint(currentProp.transform.TransformPoint(grabbedOffset)), Time.deltaTime);
        }

        if (Input.GetKey(KeyCode.Mouse1) || currentProp)
        {
            // armParent.eulerAngles = new Vector3(0, 0, Meth.pointToDegree(Mice.worldMousePosition(), armParent.position) + offset);
            armParent.eulerAngles = new Vector3(0, 0, Mathf.LerpAngle(armParent.eulerAngles.z, Meth.pointToDegree(Mice.worldMousePosition(), armParent.position) + offset, Time.deltaTime * 6f));
        }
        else
        {
            float targetAngle = (((player.xMoveInput * -40) - 90 + offset) % 360);
            armParent.eulerAngles = new Vector3(0, 0, Mathf.LerpAngle(armParent.eulerAngles.z, targetAngle, Time.deltaTime * 3));
        }

        // Time.timeScale = Mathf.MoveTowards(Time.time, currentProp && !player.onGround ? 0.8f : 1, Time.deltaTime * 3);
    }
Beispiel #23
0
    public void Reader(string str, ref Tree tree, Entry entry, out bool reFreshFrame)
    {
        //string[] inLine = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        Frame Error = new Frame(30, 30, 5, 40, "Error", ColorScheme.Warning);

        reFreshFrame = false;
        string comand    = null;
        string path      = null;
        string attr      = null;
        int    charCount = 0;

        for (int i = 0; i < str.Length && !char.IsWhiteSpace(str[i]); i++, charCount++)
        {
            comand += str[i];
        }
        for (int i = ++charCount; i < str.Length && str[i] != '-'; i++, charCount++)
        {
            path += str[i];
        }
        for (int i = ++charCount; i < str.Length && !char.IsWhiteSpace(str[i]); i++, charCount++)
        {
            if (str[i] == '-')
            {
                continue;
            }
            else
            {
                attr += str[i];
            }
        }
        path.Trim();
        switch (comand)
        {
        case "CD":
        case "cd":
            if (path == "\\")
            {
                tree.ChangeDirectory(tree.Pages[0][0].Parent);
            }
            else if (Directory.Exists(path + '\\'))
            {
                tree.ChangeDirectory(path + '\\');
            }
            else if (Directory.Exists(entry.Path + path + '\\'))
            {
                tree.ChangeDirectory(entry.Path + path + '\\');
            }
            else
            {
                Console.Write("Bad Path!");
            }
            reFreshFrame = true;
            break;

        case "del":
        case "DEL":
        case "Del":
            if (Directory.Exists(path))
            {
                try
                {
                    DirectoryInfo dif = new DirectoryInfo(entry.Path + path);
                    dif.Delete(true);
                    reFreshFrame = true;
                }
                catch (Exception e)
                {
                    Error.Show(true);
                    Error.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            else if (File.Exists(path))
            {
                try
                {
                    FileInfo fi = new FileInfo(entry.Path + path);
                    fi.Delete();
                }
                catch (Exception e)
                {
                    Error.Show(true);
                    Error.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            break;

        case "new":
        case "New":
        case "NEW":
            if (attr == "d" | attr == "D")
            {
                try
                {
                    DirectoryInfo dif = new DirectoryInfo(tree.CurrentPath + path + '\\');
                    dif.Create();
                    reFreshFrame = true;
                }
                catch (Exception e)
                {
                    Error.Show(true);
                    Error.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            else if (attr == "f" | attr == "F")
            {
                try
                {
                    FileInfo fi = new FileInfo(tree.CurrentPath + path);
                    fi.Create();
                    reFreshFrame = true;
                }
                catch (Exception e)
                {
                    Error.Show(true);
                    Error.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            break;

        case "move":
        case "Move":
        case "MOVE":
            if (Directory.Exists(attr) & (Directory.Exists(path) | File.Exists(path)))
            {
                try
                {
                    Directory.Move(path, attr);
                }
                catch (Exception e)
                {
                    Error.Show(true);
                    Error.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            break;

        case "copy":
        case "COPY":
        case "Copy":
            if (File.Exists(entry.Path + path) & !File.Exists(attr))
            {
                try
                {
                    File.Copy(entry.Path + path, attr);
                }
                catch (Exception e)
                {
                    Error.Show(true);
                    Error.WriteText(e.Message);
                    Meth.WriteLog(e.Message);
                    Console.ResetColor();
                    Console.ReadKey(true);
                }
            }
            else if (File.Exists(attr))
            {
                string errorStr = $"File {attr} already exist";
                Error.Show(true);
                Error.WriteText(errorStr);
                Meth.WriteLog(errorStr);
                Console.ResetColor();
                Console.ReadKey(true);
            }
            else if (!File.Exists(entry.Path + path))
            {
                string errorStr = $"File {path} not exist";
                Error.Show(true);
                Error.WriteText(errorStr);
                Meth.WriteLog(errorStr);
                Console.ResetColor();
                Console.ReadKey(true);
            }
            break;

        default:
            Console.Write("Bad Comand!");
            Meth.WriteLog("Bad Comand!");
            break;
        }
    }
Beispiel #24
0
            public Backups()
            {
                this.Name = "Backups";
                this.Dock = DockStyle.Fill;
                Meth.HandleTheme(this);

                EventHandler ViewBackup = (s, e) => {
                    if (BackupSelect.SelectedItem != null)
                    {
                        Elem.Select.SelectItem backup = (Elem.Select.SelectItem)BackupSelect.SelectedItem;

                        Form Info = new Form();
                        Info.Size        = new Size(Meth._S(350), Meth._S(400));
                        Info.Text        = $"Viewing {backup.Text}";
                        Info.Icon        = new Icon(Settings.IconPath);
                        Info.FormClosed += (s, e) => Info.Dispose();

                        Meth.HandleTheme(Info);

                        Elem.Text Load = new Elem.Text("Loading...");

                        Info.Show();

                        Info.Controls.Add(Load);

                        dynamic BackupInfo = GDTools.Backups.GetBackupInfo(backup.Text);

                        string User = "";

                        Elem.Select Levels = new Elem.Select(false);
                        Levels.DoubleClick += (s, e) => {
                            if (Levels.SelectedItem != null)
                            {
                                Elem.Select.SelectItem lvl = (Elem.Select.SelectItem)Levels.SelectedItem;
                                dynamic LevelInfo          = GDTools.GetLevelInfo(lvl.Text, BackupInfo.Levels);

                                string Info = "";

                                foreach (PropertyInfo i in LevelInfo.GetType().GetProperties())
                                {
                                    if (i.Name != "Name" && i.Name != "Creator" && i.Name != "Description")
                                    {
                                        Info += $"{i.Name.Replace("_", " ")}: {i.GetValue(LevelInfo)}\n";
                                    }
                                }

                                MessageBox.Show(Info, $"Info for {lvl.Text}", MessageBoxButtons.OK, MessageBoxIcon.None);
                            }
                        };

                        foreach (PropertyInfo i in BackupInfo.User.Stats.GetType().GetProperties())
                        {
                            User += $"{i.Name.Replace("_", " ")}: {i.GetValue(BackupInfo.User.Stats)}\r\n";
                        }

                        foreach (dynamic lvl in BackupInfo.Levels)
                        {
                            Levels.AddItem(lvl.Name);
                        }

                        Info.Controls.Remove(Load);

                        FlowLayoutPanel Contain = new FlowLayoutPanel();
                        Contain.Dock     = DockStyle.Fill;
                        Contain.AutoSize = true;

                        Contain.Controls.Add(new Elem.Text(User));
                        Contain.Controls.Add(new Elem.BigNewLine());
                        Contain.Controls.Add(Levels);
                        Contain.Controls.Add(new Elem.Text("Double-click to view level"));

                        Info.Controls.Add(Contain);
                    }
                };

                GDTools.Backups.InitBackups();

                BackupSelect              = new Elem.Select(false);
                BackupSelect.DoubleClick += ViewBackup;

                BackupPath  = new Elem.Text();
                BackupsSize = new Elem.Text();

                RefreshBackupList();

                ContextMenuStrip CM = new ContextMenuStrip();

                CM.Items.Add(new ToolStripMenuItem("View selected backup", null, ViewBackup));
                BackupSelect.ContextMenuStrip = CM;

                this.Controls.Add(BackupSelect);

                this.Controls.Add(BackupsSize);

                this.Controls.Add(new Elem.Div(new Control[] {
                    new Elem.But("View", ViewBackup, "This button shows info about the backup. (You can do the same by double-clicking a backup on the list)"),
                    new Elem.But("Load", (s, e) => {
                        Elem.ChooseForm BackupCurrent = new Elem.ChooseForm(
                            "Backup current progress?",
                            new string[] { "Yes", "No", "Cancel" },
                            "Would you like to backup your current GD progress before loading?"
                            );

                        BackupCurrent.Show();

                        BackupCurrent.Finish += (s) => {
                            if (s == 2)
                            {
                                return;
                            }
                            if (BackupSelect.SelectedItem != null)
                            {
                                if (s == 0)
                                {
                                    GDTools.Backups.CreateNewBackup();
                                }

                                GDTools.Backups.SwitchToBackup(((Elem.Select.SelectItem)BackupSelect.SelectedItem).Text);

                                Program.MainForm.FullReload();
                            }
                        };
                    }, "Switches your current GD progress to that of the backup. Asks you before switching if you'd like to save your current progress."),
                    new Elem.But("Delete", (s, e) => {
                        if (BackupSelect.SelectedItem != null)
                        {
                            Elem.ChooseForm Y = new Elem.ChooseForm("Are you sure?", new string[] { "Yes", "Cancel" }, "Are you sure you want to delete this backup?");

                            Y.Show();

                            Y.Finish += s => {
                                if (s != 0)
                                {
                                    return;
                                }

                                GDTools.Backups.DeleteBackup(((Elem.Select.SelectItem)BackupSelect.SelectedItem).Text);

                                RefreshBackupList();
                            };
                        }
                    }, "Deletes the selected backup permanently.")
                }));

                this.Controls.Add(new Elem.Div(new Control[] {
                    new Elem.But("New", (s, e) => {
                        GDTools.Backups.CreateNewBackup();
                        RefreshBackupList();
                    }, "Creates a new backup of your current GD progress."),
                    new Elem.But("Import Backup", (s, e) => {
                        Elem.ChooseForm FileOrFolder = new Elem.ChooseForm("Select backup type", new string[] { "Folder", $"Compressed file (.zip / .{GDTools.Ext.Backup})" });

                        FileOrFolder.Show();

                        FileOrFolder.Finish += (s) => {
                            if (s == 0)
                            {
                                using (FolderBrowserDialog ofd = new FolderBrowserDialog()) {
                                    ofd.Description = "Select a backup folder";

                                    if (ofd.ShowDialog() == DialogResult.OK)
                                    {
                                        GDTools.Backups.ImportBackup(ofd.SelectedPath);
                                        RefreshBackupList();
                                    }
                                }
                            }
                            else
                            {
                                using (OpenFileDialog ofd = new OpenFileDialog()) {
                                    ofd.InitialDirectory = "c:\\";
                                    ofd.Filter           = GDTools.Ext.BackupFilter;
                                    ofd.FilterIndex      = 1;
                                    ofd.RestoreDirectory = true;
                                    ofd.Multiselect      = true;

                                    if (ofd.ShowDialog() == DialogResult.OK)
                                    {
                                        foreach (string file in ofd.FileNames)
                                        {
                                            ImportBackup(file);
                                        }
                                    }
                                }
                            }
                        };
                    }, "This button lets you import backups you've made before.")
                }));

                this.Controls.Add(new Elem.BigNewLine());
                this.Controls.Add(BackupPath);

                this.Controls.Add(new Elem.Div(new Control[] {
                    new Elem.But("Change Folder", (s, e) => {
                        using (FolderBrowserDialog ofd = new FolderBrowserDialog()) {
                            ofd.Description = "Select backup directory";

                            if (ofd.ShowDialog() == DialogResult.OK)
                            {
                                GDTools.Backups.SetBackupLocation(ofd.SelectedPath);
                                RefreshBackupList();
                            }
                        }
                    }, "Change the folder where backups are saved. All backups are automatically moved to the new location."),
                    new Elem.But("Open Folder", (s, e) => Process.Start("explorer.exe", GDTools._BackupDirectory), "Opens the backup folder in File Explorer."),
                    new Elem.But("Refresh Folder", (s, e) => RefreshBackupList(), "Reloads the backup list.")
                }));
                this.Controls.Add(new Elem.BigNewLine());
                this.Controls.Add(new Elem.But("Help", (s, e) => Pages.SettingPage.ShowHelp("backups")));
                //this.Controls.Add(new Elem.BigNewLine());
                //this.Controls.Add(new Elem.But("Link backups to Google Drive"));
            }