Example #1
0
        public Creature(string Directory, string filename)
        {
            //this constructor creates the object by parsing it from an XML file
            //bulky. Consider reconfiguring all save-load classes to store variables in an array/list, then we could make use of a generic parser
            XmlDocument LoadFile = new XmlDocument();

            LoadFile.Load(Directory + filename);
            Name            = LoadFile.DocumentElement.SelectSingleNode("Name").Value;
            Size            = (enumSize)int.Parse(LoadFile.DocumentElement.SelectSingleNode("Size").Value);
            Type            = (enumType)int.Parse(LoadFile.DocumentElement.SelectSingleNode("Type").Value);
            Alignment       = (enumAlignment)int.Parse(LoadFile.DocumentElement.SelectSingleNode("Alignment").Value);
            ArmorClass      = int.Parse(LoadFile.DocumentElement.SelectSingleNode("ArmorClass").Value);
            HitPoints       = int.Parse(LoadFile.DocumentElement.SelectSingleNode("HitPoints").Value);
            Speed           = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Speed").Value);
            ChallengeRating = int.Parse(LoadFile.DocumentElement.SelectSingleNode("ChallengeRating").Value);
            XP           = int.Parse(LoadFile.DocumentElement.SelectSingleNode("XP").Value);
            Strength     = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Strength").Value);
            Dexterity    = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Desterity").Value);
            Constitution = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Constitution").Value);
            Intelligence = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Intelligence").Value);
            Wisdom       = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Wisdom").Value);
            Charisma     = int.Parse(LoadFile.DocumentElement.SelectSingleNode("Charisma").Value);

            //proposed model for loading lists, provided parellel saving method implemented
            int ActionCount = int.Parse(LoadFile.DocumentElement.SelectSingleNode("ActionCount").Value);

            for (int i = 1; i <= ActionCount; i++)
            {
                Action newAction = new Action();
                newAction.Name        = LoadFile.DocumentElement.SelectSingleNode("Action" + i + "Name").Value;
                newAction.Description = LoadFile.DocumentElement.SelectSingleNode("Action" + i + "Description").Value;
            }
        }
Example #2
0
        /// <summary>
        /// Creates a UID based on NIC MAC address (format: 0080C78F6C96) plus a sequence number of length 7
        /// Format with sequence number: prefix+0080C78F6C96+0000000 (0000000 is sequence number) - total: 1+12+7=20
        /// If sequence number = 0, then sequence number is built based on month+day (1byte), hour (1byte), minutes (1byte), seconds (1byte) and miliseconds (string)
        /// Format with generated number: prefix+0080C78F6C96+BBBB000 - total: 1+12+7=20 (where B is Byte in 32-127 range)
        ///  byte of month+day(12-1+31-1=41) + 32 = ascii range 32-73
        ///  byte of hour(23) + 32 = ascii range 32-55
        ///  byte of min(59) + 32 = ascii range 32-91
        ///  byte of sec(59) + 32 = ascii range 32-91
        ///  string of milisec(999) = 000-999
        /// </summary>
        /// <param name="iSequence"></param>
        /// <remarks></remarks>
        public void NewMAC(int iSequence = 0)
        {
            string      nicId     = "";
            string      sMAC      = GetMacAddress(ref nicId);
            string      sSequence = "";
            List <byte> aSequence = new List <byte>();
            //Dim nowdt As New DateTime(Now.Year, 12, 31, 23, 59, 59, 999)
            DateTime nowdt = DateTime.Now;

            if (iSequence == 0)
            {
                aSequence.Add((byte)(nowdt.Month - 1 + 32));
                aSequence.Add((byte)(nowdt.Day - 1 + 32));
                aSequence.Add((byte)(nowdt.Hour + 32));
                aSequence.Add((byte)(nowdt.Minute + 32));
                aSequence.Add((byte)(nowdt.Second + 32));
                aSequence.AddRange(System.Text.Encoding.UTF8.GetBytes(nowdt.Millisecond.ToString().PadLeft(3, '0')));
            }
            else
            {
                aSequence.AddRange(System.Text.Encoding.UTF8.GetBytes(iSequence.ToString().PadLeft(iMACSequenceNumberLength, '0')));
            }
            m_UID  = sMAC + System.Text.Encoding.UTF8.GetString(aSequence.ToArray());
            m_Type = enumType.MAC;
        }
Example #3
0
        /// <summary>
        /// Creates a UID based on a GUID
        /// Memory format: xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx (8+4+4+4+12+4hyphen = 32 characters)
        /// Station format: 32 ASCII bytes on range 32-127 (36 memory format without hyphens)
        /// </summary>
        /// <remarks></remarks>
        public void NewGUIDS()
        {
            Guid g = Guid.NewGuid();

            m_UID  = g.ToString().Replace("-", "");
            m_Type = enumType.GUIDS;
        }
Example #4
0
        /// <summary>
        /// Creates a UID based on a GUID
        /// Memory format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx (8+4+4+4+12+4hyphen = 36 characters)
        /// Station format: GUID converted to 16 bytes on range 0-255
        /// </summary>
        /// <remarks></remarks>
        public void NewGUIDB()
        {
            Guid g = Guid.NewGuid();

            m_UID  = g.ToString();
            m_Type = enumType.GUIDB;
        }
Example #5
0
        /// <summary>
        /// Creates object and builds a new MAC (NIC MAC Address) or GUID station UID
        /// </summary>
        /// <param name="type">MAC or GUID type</param>
        /// <param name="iSequence">Optional, for MAC type. If zero, sequence will be based on
        /// month (1byte), day (1byte), hour (1byte), minutes (1byte), seconds (1byte) and miliseconds (string)</param>
        /// <remarks></remarks>
        public clsStationUID(enumType type, int iSequence = 0)
        {
            switch (type)
            {
            case enumType.GUIDB:
                NewGUIDB();
                break;

            case enumType.GUIDS:
                NewGUIDS();
                break;

            case enumType.MAC:
                NewMAC(iSequence);
                break;

            case enumType.CUSTOM:
                m_Type = enumType.EMPTY;
                m_UID  = "";
                break;

            default:
                m_Type = enumType.EMPTY;
                m_UID  = "";
                break;
            }
        }
        /// <summary>
        /// 상태 표시 창을 보여줍니다.
        /// </summary>
        /// <param name="msg">전달할 메세지 string</param>
        /// <param name="type">메세지 타입 Enum</param>
        public EventForm(string msg, enumType type)
        {
            InitializeComponent();

            timer1.Tick += timer1_Tick;

            showAlert(msg, type);
        }
Example #7
0
 public structCol(enumType _colType, string _enname, string _displayName = "", string _remark = null, bool _isPk = false)
 {
     this.enumColType = _colType;
     this.enname      = _enname;
     this.displayname = _displayName;
     this.remark      = _remark;
     this.isPK        = _isPk;
 }
 // http://developers.facebook.com/docs/reference/api/album/
 public Album(String id, Reference from, String name, enumType type, String link, int count, enumPrivacy privacy, DateTime createdTime)
 {
     this.ID          = id;
     this.From        = from;
     this.Name        = name;
     this.Link        = link;
     this.Privacy     = privacy;
     this.Count       = count;
     this.Type        = type;
     this.CreatedTime = createdTime;
 }
		// http://developers.facebook.com/docs/reference/api/album/
		public Album(String id, Reference from, String name, enumType type, String link, int count, enumPrivacy privacy, DateTime createdTime)
		{
			this.ID          = id         ;
			this.From        = from       ;
			this.Name        = name       ;
			this.Link        = link       ;
			this.Privacy     = privacy    ;
			this.Count       = count      ;
			this.Type        = type       ;
			this.CreatedTime = createdTime;
		}
Example #10
0
 /// <summary>
 /// Custom UID
 /// </summary>
 /// <param name="sUid"></param>
 /// <remarks></remarks>
 public void NewCustomUID(string sUid, int iSequence = 0)
 {
     if (iSequence > 0)
     {
         m_UID = PrefixCUSTOM + sUid + iSequence.ToString();
     }
     else
     {
         m_UID = PrefixCUSTOM + sUid;
     }
     m_Type = enumType.CUSTOM;
 }
Example #11
0
        public void showAlert(string msg, enumType type)
        {
            this.Opacity       = 0.0f;
            this.StartPosition = FormStartPosition.Manual;
            string fname;

            for (int i = 0; i < 10; i++)
            {
                fname = "alert" + i.ToString();
                StatusDisplay frm = (StatusDisplay)Application.OpenForms[fname];

                if (frm == null)
                {
                    this.Name     = fname;
                    this.x        = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15;
                    this.y        = Screen.PrimaryScreen.WorkingArea.Height - (this.Height * i + this.Height);
                    this.Location = new Point(this.x, this.y);
                    break;
                }
            }

            this.x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5;

            switch (type)
            {
            case enumType.Success:
                this.IconMessage.IconChar = FontAwesome.Sharp.IconChar.CheckCircle;
                this.BackColor            = Color.SeaGreen;
                break;

            case enumType.Error:
                this.IconMessage.IconChar = FontAwesome.Sharp.IconChar.Bomb;
                this.BackColor            = Color.DarkRed;
                break;

            case enumType.Info:
                this.IconMessage.IconChar = FontAwesome.Sharp.IconChar.InfoCircle;
                this.BackColor            = Color.RoyalBlue;
                break;

            case enumType.Warning:
                this.IconMessage.IconChar = FontAwesome.Sharp.IconChar.ExclamationCircle;
                this.BackColor            = Color.DarkOrange;
                break;
            }

            this.LabelMessageText.Text = msg;
            this.Show();
            this.action          = enumAction.start;
            this.timer1.Interval = 1;
            timer1.Start();
        }
Example #12
0
        /// <summary>
        /// 获取枚举数组
        /// </summary>
        /// <typeparam name="enumType">枚举类型</typeparam>
        /// <returns>枚举数组</returns>
        public static enumType[] Array <enumType>()
        {
            Array array = System.Enum.GetValues(typeof(enumType));

            enumType[] values = new enumType[array.Length];
            int        count  = 0;

            foreach (enumType value in array)
            {
                values[count++] = value;
            }
            return(values);
        }
Example #13
0
        private void fromMemory(string memoryUID)
        {
            m_UID  = "";
            m_Type = enumType.EMPTY;

            if (memoryUID.Length < 2)
            {
                return;
            }

            // UID
            List <byte> aUID = new List <byte>();
            // custom prefix
            string sPrefix = memoryUID.Substring(0, PrefixCUSTOM.Length);

            if (sPrefix == PrefixCUSTOM)
            {
                m_UID  = memoryUID;
                m_Type = enumType.CUSTOM;
            }
            else
            {
                switch (memoryUID.Length)
                {
                case 36:
                    // build GUID based on bytes
                    // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
                    m_UID  = memoryUID;
                    m_Type = enumType.GUIDB;
                    break;

                case 32:
                    // build GUID based on bytes
                    // xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx
                    m_UID  = memoryUID;
                    m_Type = enumType.GUIDS;
                    break;

                case 20:
                    // UID is of format 0080C78F6C96+seq
                    m_UID  = memoryUID;
                    m_Type = enumType.MAC;
                    break;

                default:
                    m_UID  = memoryUID;
                    m_Type = enumType.UNKNOWN;
                    break;
                }
            }
        }
Example #14
0
 public IAsyncEnumerable <ResultItem> EnumerateItems(enumType itemType)
 {
     return(new AsyncEnumerable <ResultItem>(async yield => {
         Boolean keepGoing = true;
         while (keepGoing)
         {
             // 100 records max per call
             var w = new WebServiceClient();
             request.enumType = itemType;
             // MUST BE ASYNC CALL
             var response = await w.responseAsync();
             foreach (ResultItem cr in response.ResultList)
             {
                 await yield.ReturnAsync(cr);
             }
             keepGoing = response.moreRecordsExist;
         }
     }));
 }
Example #15
0
        /// <summary>Get label.</summary>
        public static string GetLabel(enumType type, string custom)
        {
            switch (type)
            {
            case enumType.Custom:
                return(custom);

            case enumType.ContactEmail:
            case enumType.ContactPhone:
            case enumType.ContactAddress:
            case enumType.ContactWebsite:
            case enumType.ContactMessenger:
            case enumType.Date:
            case enumType.Person:
                return(custom);

            default:
                return(Enum.GetName(typeof(enumType), type));
            }
        }
Example #16
0
 value          = GetEnumFieldsInner(enumType, culture);
Example #17
0
        /// <summary>
        /// Used to build the UID based on bytes read from station
        /// </summary>
        /// <param name="stationUID"></param>
        /// <remarks></remarks>
        private void fromStationBytes(byte[] stationUID)
        {
            m_UID  = "";
            m_Type = enumType.EMPTY;

            if (stationUID.Length < 2)
            {
                return;
            }

            // UID
            List <byte> aUID = new List <byte>();

            // custom prefix
            byte[] aPrefix = new byte[PrefixCUSTOM.Length - 1 + 1];
            Array.Copy(stationUID, 0, aPrefix, 0, aPrefix.Length);
            string sPrefix = System.Text.Encoding.UTF8.GetString(aPrefix);

            if (sPrefix == PrefixCUSTOM)
            {
                m_UID  = System.Text.Encoding.UTF8.GetString(stationUID);
                m_Type = enumType.CUSTOM;
            }
            else
            {
                switch (stationUID.Length)
                {
                case 16:
                    // build GUID based on bytes
                    aUID.AddRange(stationUID);
                    Guid g = new Guid(aUID.ToArray());
                    m_UID  = g.ToString();
                    m_Type = enumType.GUIDB;
                    break;

                case 32:
                    // build GUID based on ASCII bytes (without hyphens)
                    // xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx
                    string sGUID = System.Text.Encoding.UTF8.GetString(stationUID);
                    //For i = 1 To sGUID.Length
                    //    Select Case i
                    //        Case 9, 13, 17, 21
                    //            m_UID += "-"
                    //        Case Else
                    //    End Select
                    //    m_UID += Mid(sGUID, i, 1)
                    //Next
                    m_UID  = sGUID;
                    m_Type = enumType.GUIDS;
                    break;

                case 20:
                    // UID is of format 0080C78F6C96+seq
                    m_UID  = System.Text.Encoding.UTF8.GetString(stationUID);
                    m_Type = enumType.MAC;
                    break;

                default:
                    m_UID  = System.Text.Encoding.UTF8.GetString(stationUID);
                    m_Type = enumType.UNKNOWN;
                    break;
                }
            }
        }
Example #18
0
        public void showAlert(string msg, enumType type)
        {
            this.Opacity       = 0.0;
            this.StartPosition = FormStartPosition.Manual;
            string fname;

            for (int i = 0; i < 10; i++)
            {
                fname = "alert" + i.ToString();
                Form_Alert frm = (Form_Alert)Application.OpenForms[fname];

                if (frm == null)
                {
                    this.Name = fname;
                    this.x    = Screen.PrimaryScreen.WorkingArea.Width - this.Width - 20;

                    //this.y = Screen.PrimaryScreen.Bounds.Height - this.Height * i -5 * i;
                    //if (fname == "alert0")
                    //{
                    this.y = Screen.PrimaryScreen.Bounds.Top - this.Top * i + 53 * i;
                    //}
                    this.Location = new Point(this.x, this.y);
                    break;
                }
            }
            this.x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5;

            switch (type)
            {
            case enumType.Success:
                this.pictureBox1.Image = Resources.Success;
                this.BackColor         = Color.SeaGreen;
                break;

            case enumType.Error:
                this.pictureBox1.Image = Resources.Error;
                this.BackColor         = Color.DarkRed;
                break;

            case enumType.Info:
                this.pictureBox1.Image = Resources.Info;
                this.BackColor         = Color.RoyalBlue;
                break;

            case enumType.Warning:
                this.pictureBox1.Image = Resources.Warning;
                this.BackColor         = Color.DarkOrange;
                break;

            case enumType.Edit:
                this.pictureBox1.Image = Resources.Edit;
                this.BackColor         = Color.Black;
                break;
            }

            this.lbl_Msg.Text = msg;

            // home.home2.addControlsTopanel2(this);
            // home.home2.panel5.Visible = true;
            // home.home2.Show();
            this.Show();

            //this.Focus();
            this.action          = enmAction.start;
            this.timer1.Interval = 1;
            timer1.Start();
        }
Example #19
0
 public HelpDragAndDrop(enumType et, string data)
 {
     type       = et;
     CarrayData = data;
 }
Example #20
0
 /// <summary>
 /// Creates object with an empty station UID
 /// </summary>
 /// <remarks></remarks>
 public clsStationUID()
 {
     m_Type = enumType.EMPTY;
     m_UID  = "";
 }
 public void SetSymbolTypeSpecial(enumType enumSymbolType)
 {
     try
     {
         this.SymbolType = enumSymbolType;
     }
     catch (Exception ex)
     {
         if (this._SendErrorMsg != null)
         {
             this._SendErrorMsg("Sub SetSymbolTypeSpecial ", ex.Message);
         }
     }
 }
Example #22
0
        /// <summary>
        /// 상태 표시 창을 보여줍니다.
        /// </summary>
        /// <param name="msg">전달할 메세지 string</param>
        /// <param name="type">메세지 타입 Enum</param>
        public StatusDisplay(string msg, enumType type)
        {
            InitializeComponent();

            showAlert(msg, type);
        }
 private void SetSymbolType()
 {
     try
     {
         if (!string.IsNullOrEmpty(this.oGraphPanel.strSymbolList) && this.SymbolListSet.Contains(this.oGraphPanel.strSymbolList))
         {
             this.SymbolType = enumType.eSet;
         }
         else if (!string.IsNullOrEmpty(this.oGraphPanel.strSymbolList) && this.SymbolListTfex.Contains(this.oGraphPanel.strSymbolList))
         {
             this.SymbolType = enumType.eTfex;
         }
         if (this.eOldSymbolType != this.SymbolType)
         {
             this.eOldSymbolType = this.SymbolType;
         }
     }
     catch (Exception ex)
     {
         if (this._SendErrorMsg != null)
         {
             this._SendErrorMsg("Sub SetSymbolType ", ex.Message);
         }
     }
 }