Inheritance: EnumClass
Exemplo n.º 1
0
        static PlacementResult Sort(MyType[] array, MyType typeA, MyType typeB, int left, int right)
        {
            int placeLeft = left;
            int placeRight = right;

            while (array[placeLeft] == typeA)
            {
                placeLeft++;
            }

            while (array[placeRight] == typeB)
            {
                placeRight--;
            }

            for (int i = placeLeft; i <= placeRight;)
            {
                if (array[i] == typeA)
                {
                    array.Swap(i, placeLeft++);
                }
                else if (array[i] == typeB)
                {
                    array.Swap(i, placeRight--);
                }
                else
                {
                    i++;
                }
            }

            return new PlacementResult() { LeftPlace = placeLeft, RightPlace = placeRight };
        }
Exemplo n.º 2
0
 public AddBaseRoleDialog(MyType type)
 {
     InitializeComponent();
     switch (type)
     {
         case MyType.User:
             {
                 lbl.Content = "好友ID";
                 break;
             }
         case MyType.UserGroup:
             {
                 lbl.Content = "分组名";
                 break;
             }
         case MyType.Group:
             {
                 lbl.Content = "群组名";
                 break;
             }
         case MyType.UserInGroup:
             {
                 lbl.Content="成员ID";
                 break;
             }
     }
 }
Exemplo n.º 3
0
        public static void Execute()
        {
            var xMyType = new MyType();

            xMyType.IntField = 42;
            xMyType.ReferenceField = new object();

            var xCloneType = xMyType.Clone();
            
            Assert.AreEqual(xMyType.IntField, xCloneType.IntField, "Cloned object has a different IntField value!");
            Assert.IsTrue(ReferenceEquals(xMyType.ReferenceField, xCloneType.ReferenceField), "References of field aren't the same!");

            xCloneType.IntField = 56;

            Assert.AreEqual(xMyType.IntField, 42, "Cloned object is linked to original object!");
        }
Exemplo n.º 4
0
        public static void Sort(MyType[] array, MyType[] typeArray)
        {
            int placeLeft = 0;
            int placeRight = array.Length - 1;

            int typeLeft = 0;
            int typeRight = typeArray.Length - 1;

            while (placeLeft < placeRight && typeLeft < typeRight)
            {
                var result = Sort(array, typeArray[typeLeft], typeArray[typeRight], placeLeft, placeRight);
                typeLeft++;
                typeRight--;
                placeLeft = result.LeftPlace;
                placeRight = result.RightPlace;
            }
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            using (IObjectContainer container = OpenContainer())
            {
                // #example: Store the non storable type
                MyType testType = new MyType();
                container.Store(testType);
                // #end example
            }

            using (IObjectContainer container = OpenContainer())
            {
                // #example: Load the non storable type
                MyType builder = container.Query<MyType>()[0];
                Console.WriteLine(builder);
                // #end example
            }
        }
        public void Stringifying_and_destringifying_should_be_reversive()
        {
            var myType = new MyType()
                             {
                                 MyFloat = 123.456f,
                                 MyInt = 543,
                                 MyString = "HelloWorld",
                                 SubType = new MySubType()
                                               {
                                                   A = "Piotr",
                                                   B = 5
                                               },
                                 SubTypes = new List<MySubType>()
                                                {
                                                    new MySubType()
                                                        {
                                                            A = "Ewelinka",
                                                            B = 6
                                                        },
                                                    new MySubType()
                                                        {
                                                            A = "Micha³",
                                                            B = 7
                                                        }
                                                }
                             };

            var stringifier = new JsonMessageStringifier(null);

            var res = stringifier.Destringify(stringifier.Stringify(myType));

            res.Should().BeOfType<MyType>();

            var resT = (MyType) res;

            resT.MyFloat.Should().Be(myType.MyFloat);
            resT.MyInt.Should().Be(myType.MyInt);
            resT.MyString.Should().Be(myType.MyString);

            resT.SubType.A.Should().Be(myType.SubType.A);
            resT.SubType.B.Should().Be(myType.SubType.B);

            resT.SubTypes.Count().Should().Be(myType.SubTypes.Count());
        }
Exemplo n.º 7
0
 public static void MyFunction(out MyType mType)
 {
     mType = new MyType();
     FieldInfo[] fInfo = mType.GetType().GetFields();
 }
Exemplo n.º 8
0
        /// <summary>
        /// 设置DataGridView
        /// </summary>
        /// <param name="tblName"></param>
        private void SetGridView(MyType myType)
        {

            this._bmb = this.BindingContext[dgvInfo.DataSource];

            switch (myType)
            {
                case MyType.Service:
                    SetService();
                    break;
                case MyType.Lift:
                    SetLift();
                    break;
                case MyType.ErrorLift:
                    break;
                case MyType.ErrorList:
                    break;
                case MyType.Parts:
                    break;
                case MyType.Contract:
                    break;
                case MyType.Employee:
                    break;
                case MyType.Login:
                    break;
                default:
                    break;
            }

            //switch (tblName)
            //{
            //    case "Service":
            //        SetService();
            //        break;
            //    case "Lift":
            //        SetLift();
            //        break;
            //    default:
            //        break;
            //}
        }
Exemplo n.º 9
0
	public static MyType operator /(MyType lhs, int rhs){
		MyType result = new MyType(lhs.IntField);
		result.IntField /= rhs;
		return result;
	}
Exemplo n.º 10
0
 public void Types()
 {
     MyType.Test();
 }
Exemplo n.º 11
0
	public void OnEnable()
	{
		m_Instance = target as MyType;
		m_fields = ExposeProperties.GetProperties( m_Instance );
	}
Exemplo n.º 12
0
        public MyButton GetButton(MyType myType, string id)
        {
            MyButton button = null;
            switch (myType)
            {
                case MyType.User:
                    {
                        foreach (MyButton btn in this.Children)
                        {
                            if ((btn.baseRole as Member).id == id)
                            {
                                button = btn;
                                break;
                            }
                        }
                        break;
                    }
                case MyType.UserGroup:
                    {
                        foreach (MyButton btn in this.Children)
                        {
                            if ((btn.baseRole as UserGroup).userGroupId == id)
                            {
                                button = btn;
                                break;
                            }
                        }
                        break;
                    }
                case MyType.Group:
                    {
                        foreach (MyButton btn in this.Children)
                        {
                            if ((btn.baseRole as Group).GroupId == id)
                            {
                                button = btn;
                                break;
                            }
                        }
                        break;
                    }

                case MyType.UserInGroup:
                    {
                        foreach (MyButton btn in this.Children)
                        {
                            if ((btn.baseRole as Member).id == id)
                            {
                                button = btn;
                                break;
                            }
                        }
                        break;
                    }


            }

            return button;
        }
Exemplo n.º 13
0
 static Test()
 {
     myType = new MyType();
 }
Exemplo n.º 14
0
    public void Log_ObjectConverter()
    {
        UT_INIT();

        Log.AddDebugLogger();

        Log.SetDomain( "OBJECT_CONV",       Scope.Method );
        MemoryLogger ml= new MemoryLogger();
        ml.MetaInfo.Format._();
        Log.SetVerbosity( ml, Verbosity.Verbose );

        StringConverter mainConverter= (StringConverter) ml.ObjectConverters[0];
        // test without my converter
        MyType mytype= new MyType();
        Log.Info( "Test" ); UT_TRUE( ml.MemoryLog.IndexOf( "Test" ) >= 0 );                        ml.MemoryLog._();
        Log.Info( null   ); UT_TRUE( ml.MemoryLog.IndexOf( mainConverter.FmtNullObject ) >= 0 );   ml.MemoryLog._();
        Log.Info( mytype ); UT_EQ  ( mytype.ToString(), ml.MemoryLog );                            ml.MemoryLog._();
        Log.Info( null   ); UT_EQ  ( mainConverter.FmtNullObject,  ml.MemoryLog );                 ml.MemoryLog._();

        // test without my converter
                     ml.ObjectConverters.Add( new MyObjectConverter() );
        Log.DebugLogger.ObjectConverters.Add( new MyObjectConverter() );
        Log.Info( "Test" ); UT_TRUE( ml.MemoryLog.IndexOf( "Test" ) >= 0 );                        ml.MemoryLog._();
        Log.Info( null   ); UT_EQ  ( "MyObjectConverter: null" , ml.MemoryLog );                   ml.MemoryLog._();
        Log.Info( mytype   ); UT_EQ( "my type"                 , ml.MemoryLog );                   ml.MemoryLog._();

        // cleanup
        Log.RemoveLogger( ml );
        Log.RemoveDebugLogger();
    }
Exemplo n.º 15
0
 internal string SerializeApi(MyType api) => JsonConvert.SerializeObject(api, Formatting.Indented, _serializerSettings);
Exemplo n.º 16
0
 class Foo { public static void Main()
             {
                 object foo = new MyType <Base> ();
             }
Exemplo n.º 17
0
        public static void Test()
        {
            MyType[] array = new MyType[] { MyType.A, MyType.B, MyType.C, MyType.A, MyType.B, MyType.C, MyType.A, MyType.B, MyType.C };

            array.PrintToConsole();
            SortByType_Jorge.Sort(array, new MyType[] { MyType.A, MyType.B, MyType.C });
            array.PrintToConsole();
        }
        public string GetDataUsingDataContract()
        {
            MyType myType = new MyType();

            return(string.Format("My name is {0} and I am {1} years old", myType.Name, myType.DataOfBirth));
        }
        public string GetData(int value)
        {
            var myType = new MyType();

            return(string.Format("My name is {0}, and i am {1} years old!", myType.Name, myType.DataOfBirth));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 获得指定MyType的中文解释
        /// </summary>
        /// <param name="myType"></param>
        /// <returns></returns>
        private string GetTypeName(MyType myType)
        {
            string str = null;

            switch (myType)
            {
                case MyType.Service:
                    str = "维保计划";
                    break;
                case MyType.Lift:
                    str = "维保电梯";
                    break;
                case MyType.ErrorLift:
                    str = "电梯病例";
                    break;
                case MyType.ErrorList:
                    str = "故障记录";
                    break;
                case MyType.Parts:
                    str = "电梯零件";
                    break;
                case MyType.Contract:
                    str = "维保合同";
                    break;
                case MyType.Employee:
                    str = "维保员工";
                    break;
                case MyType.Login:
                    str = "登陆管理";
                    break;
                default:
                    break;
            }

            return str;

        }
Exemplo n.º 21
0
        public No03_CastByIsOrAs()
        {
            //目的:
            //①as,isはユーザー定義の変換を行わないため安全かつ実行効率もよい
            //②as,is実行時の型が一致しているか派生系かをチェックするだけでキャストは行わないため、情報の損失がない

            //例:
            //--------------------------------------------------------------------------------------
            //1)可読性とキャストとの違い
            object o = new object();
            //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            //メリット①:これしかない。みやすい。try句不要。nullチェックも兼用
            //パターン1
            MyType t1 = o as MyType;

            if (t1 != null)
            {
                //処理
            }
            else
            {
                //例外
            }

            //パターン2
            try {
                //仮に実行時の型がSecondTypeで、ユーザー定義の変換演算子が定義されていても、キャストはコンパイル時に走査するため、エラーとなる
                MyType t2 = (MyType)o;
                //処理
            } catch {
                //例外
            }

            //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            //メリット②:ダウンキャストを回避できる。数値に生じる暗黙的型変換と精度。
            //as以降の型か派生の型のみ成功
            string t3 = o as string;
            //ダウンキャスト可能なら成功
            string t4 = (string)o;

            //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            //デメリット①:null許容でないと使用できない
            int?t5 = o as int?;

            //=>varと合わせて利用すると後続処理までnull許容を引っ張らない
            var t6 = o as int?;

            //比較:
            //--------------------------------------------------------------------------------------
            //結果がoの型に応じて変わる
            var cast = (MyType)o;

            //結果がoの型にかかわらず一定
            var asis = o as MyType;

            //検証:
            //--------------------------------------------------------------------------------------
            //実行時の厳密な型を検証
            var isValid = cast.GetType() == typeof(MyType);

            //派生クラスも許容する検証
            var isValid1 = cast is MyType;
        }
Exemplo n.º 22
0
	public static MyType operator ++(MyType mt){
		MyType result = new MyType(mt.IntField);
		++result.IntField;
		return result;
	}
Exemplo n.º 23
0
 public void MethodOfClass1(T a, MyType b)
 {
     a.MethodOfMyBaseType();
 }
Exemplo n.º 24
0
  /// <summary>
  /// Main entry point.
  /// </summary>
  /// <param name="args"></param>
  public static void Main(string [] args)
  {
    // DateTime built in formats

    Console.WriteLine("DateTime build-in formats using current date and time.");
    Console.WriteLine("");
    Console.WriteLine ("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine ("{0}\t{1}" ,"----", "------");

    DateTime d = DateTime.Now;

    PrintFormat(d, "d");
    PrintFormat(d, "D");
    PrintFormat(d, "f");
    PrintFormat(d, "F");
    PrintFormat(d, "g");
    PrintFormat(d, "G");
    PrintFormat(d, "m");
    PrintFormat(d, "r");
    PrintFormat(d, "s");
    PrintFormat(d, "t");
    PrintFormat(d, "T");
    PrintFormat(d, "u");
    PrintFormat(d, "U");
    PrintFormat(d, "y");

    TryUserFormat(d);

    //DateTime custom format patterns
    
/*
d	        The day of the month. Single-digit days will not have a leading zero.
dd	      The day of the month. Single-digit days will have a leading zero.
ddd	      The abbreviated name of the day of the week, as defined in AbbreviatedDayNames.
dddd	    The full name of the day of the week, as defined in DayNames.
M	        The numeric month. Single-digit months will not have a leading zero.
MM	      The numeric month. Single-digit months will have a leading zero.
MMM	      The abbreviated name of the month, as defined in AbbreviatedMonthNames.
MMMM	    The full name of the month, as defined in MonthNames.
y	        The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero.
yy	      The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.
yyyy	    The year in four digits, including the century.
gg	      The period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.
h	        The hour in a 12-hour clock. Single-digit hours will not have a leading zero.
hh	      The hour in a 12-hour clock. Single-digit hours will have a leading zero.
H	        The hour in a 24-hour clock. Single-digit hours will not have a leading zero.
HH	      The hour in a 24-hour clock. Single-digit hours will have a leading zero.
m	        The minute. Single-digit minutes will not have a leading zero.
mm	      The minute. Single-digit minutes will have a leading zero.
s	        The second. Single-digit seconds will not have a leading zero.
ss	      The second. Single-digit seconds will have a leading zero.
f	        The fraction of a second in single-digit precision. The remaining digits are truncated.
ff	      The fraction of a second in double-digit precision. The remaining digits are truncated.
fff	      The fraction of a second in three-digit precision. The remaining digits are truncated.
ffff	    The fraction of a second in four-digit precision. The remaining digits are truncated.
fffff	    The fraction of a second in five-digit precision. The remaining digits are truncated.
ffffff	  The fraction of a second in six-digit precision. The remaining digits are truncated.
fffffff	  The fraction of a second in seven-digit precision. The remaining digits are truncated.
t	        The first character in the AM/PM designator defined in AMDesignator or PMDesignator.
tt	      The AM/PM designator defined in AMDesignator or PMDesignator.
z	        The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will not have a leading zero. For example, Pacific Standard Time is "-8".
zz	      The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will have a leading zero. For example, Pacific Standard Time is "-08".
zzz	      The full time zone offset ("+" or "-" followed by the hour and minutes). Single-digit hours and minutes will have leading zeros. For example, Pacific Standard Time is "-08:00".
:	        The default time separator defined in TimeSeparator.
/	        The default date separator defined in DateSeparator.
% c       Where c is a format pattern if used alone. The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns.
\ c	      Where c is any character. Displays the character literally. To display the backslash character, use "\\".
*/

    Console.WriteLine("DateTime Formatting:  user-defined custom format patterns");
    Console.WriteLine("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine("{0}\t{1}" ,"----", "------");
    PrintFormat(d, "ddd");
    PrintFormat(d, "MMMM dd, yyyy");
    PrintFormat(d, "gg");
    PrintFormat(d, "hh");
    PrintFormat(d, "HH");
    PrintFormat(d, "f");
    PrintFormat(d, "ffff");

    TryUserFormat(d);

    Console.WriteLine("-----------------------------------------------------------------------------");
    Console.WriteLine("Using Modified DateTimeFormatInfo provider\n");
    Console.WriteLine("AbbreviatedDayNames = new string [] {Sund, Mond, Tues, Weds, Thur, Frid, Satu}");
    DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
    dtfi.AbbreviatedDayNames = 
               new string [] {"Sund", "Mond", "Tues", "Weds", "Thur", "Frid", "Satu"};
    PrintFormat(d, "ddd", dtfi);
    Console.WriteLine("------------------------------------------------------------------------------\n");

    /*
    Alignment
    To specify the alignment for a formatted string in the
    composite formatting scheme, you can place a comma after the
    parameter specifier and before the colon used to separate
    the parameter specifier and the format specifier. A number
    indicating the field width should follow the comma. A
    negative number indicates that this parameter should be
    right-aligned within that field, and a positive number
    indicates it should be left-aligned. For right-aligned
    fields, the alignment is calculated so that the last field
    in the new alignment is the last character in the string
    being aligned. For left-aligned fields, the alignment is
    calculated so that the first field in the new alignment is
    the first character of the string being aligned. Alignment
    is always achieved using white spaces. The text is never
    shortened to meet the specified width; instead, the width is
    expanded to allow the full text to be displayed. Therefore,
    in order for alignment to be meaningful, the number you pass
    should be greater than the length of the original string you
    are aligning.
    The following code examples demonstrate the use of alignment
    in formatting. The arguments that are formatted are placed
    between '|' characters to highlight the resulting alignment.
    */   
    // Formatting a table
    Console.WriteLine("Composite formatting in a table");
    string [] names = {"Mary-Beth", "Aunt Alma", "Sue", "My Really Long Name", "Matt"};
    for (int k = 0; k < 5; k++)
    {
      Console.WriteLine ("| {0,-4}{1,-20} |", k, names[k]);
    }
    double [] nums = {123.456, 888.999, -12.33333, 333.45678, -99.77777};
    Console.WriteLine();
    for (int k = 0; k < 5; k++)
    {
      Console.WriteLine ("| {0,-4:d}{1,-20:e9} |", k, nums[k]);
    }
    Console.WriteLine();


    // Enum formatting
    Console.WriteLine("Enum Formatting");
    Console.WriteLine 
      (
      "Name: {0}, Enum Value: {1}, Enum Value Hex: {2}", 
      Color.Green.ToString("G"), 
      Color.Green.ToString("D"), 
      Color.Green.ToString("X")
      );
    Console.WriteLine();

    //Number standard formats
    double num = System.Math.PI * -3.0;

    Console.WriteLine("Numeric Formatting:  Predefined floating point formats");
    Console.WriteLine("Double data is System.Math.PI * -3.0: {0}", num);
    Console.WriteLine("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine("{0}\t{1}" ,"----", "------");
    PrintFormat(num, "c");
    PrintFormat(num, "c4");
    PrintFormat(num, "e");
    PrintFormat(num, "e4");
    PrintFormat(num, "e10");
    PrintFormat(num, "f");
    PrintFormat(num, "f0");
    PrintFormat(num, "f6");
    PrintFormat(num, "g");
    PrintFormat(num, "g2");
    PrintFormat(num, "g7");
    PrintFormat(num, "n");
    PrintFormat(num, "p");
    PrintFormat(num, "p8");
    PrintFormat(num, "r");

    TryUserFormat(num);
    
    int i = 77;
    Console.WriteLine("Numeric Formatting:  Predefined integer point formats");
    Console.WriteLine("Integer data is {0}", i);
    Console.WriteLine("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine("{0}\t{1}" ,"----", "------");
    PrintFormat(i, "d");
    PrintFormat(i, "d8");
    PrintFormat(i, "g");
    PrintFormat(i, "g8");
    PrintFormat(i, "x");
    PrintFormat(i, "x8");

    TryUserFormat(i);

    decimal dec = new System.Decimal(-122345678.123456789012345678901234567890);
    Console.WriteLine("Numeric Formatting:  Predefined decimal formats");
    Console.WriteLine("Decimal data is {0}", dec);
    Console.WriteLine("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine("{0}\t{1}" ,"----", "------");
    PrintFormat(dec, "c");
    PrintFormat(dec, "f");
    PrintFormat(dec, "g");
    PrintFormat(dec, "n");

    TryUserFormat(dec);

    // Numeric user-defined format patterns
/*
0 Zero placeholder
If the value being formatted has a digit in the position
where the '0' appears in the format string, then that digit
is copied to the output string. The position of the leftmost
'0' before the decimal point and the rightmost '0' after the
decimal point determines the range of digits that are always
present in the output string.

# Digit placeholder
If the value being formatted has a digit in the position
where the '#' appears in the format string, then that digit
is copied to the output string. Otherwise, nothing is stored
in that position in the output string. Note that this
specifier never displays the '0' character if it is not a
significant digit, even if '0' is the only digit in the
string. It will display the '0' character if it is a
significant digit in the number being displayed.

. Decimal point
The first '.' character in the format string determines the
location of the decimal separator in the formatted value;
any additional '.' characters are ignored. The actual
character used as the decimal separator is determined by the
NumberDecimalSeparator property of the NumberFormatInfo
object that controls formatting.

, Thousand separator and number scaling
The ',' character serves two purposes. First, if the format
string contains a ',' character between two digit
placeholders (0 or #) and to the left of the decimal point
if one is present, then the output will have thousand
separators inserted between each group of three digits to
the left of the decimal separator. The actual character used
as the decimal separator in the output string is determined
by the NumberGroupSeparator property of the current
NumberFormatInfo object that controls formatting.
Second, if the format string contains one or more ','
characters immediately to the left of the decimal point,
then the number will be divided by the number of ','
characters multiplied by 1000 before it is formatted. For
example, the format string '0,,' will represent 100 million
as simply 100. Use of the ',' character to indicate scaling
does not include thousand separators in the formatted
number. Thus, to scale a number by 1 million and insert
thousand separators you would use the format string
'#,##0,,'.

% Percentage placeholder
The presence of a '%' character in a format string causes a
number to be multiplied by 100 before it is formatted. The
appropriate symbol is inserted in the number itself at the
location where the '%' appears in the format string. The
percent character used is dependent on the current
NumberFormatInfo class.

E0, E+0, E-0, e0, e+0, e-0 Scientific notation
If any of the strings 'E', 'E+', 'E-', 'e', 'e+', or 'e-'
are present in the format string and are followed
immediately by at least one '0' character, then the number
is formatted using scientific notation with an 'E' or 'e'
inserted between the number and the exponent. The number of
'0' characters following the scientific notation indicator
determines the minimum number of digits to output for the
exponent. The 'E+' and 'e+' formats indicate that a sign
character (plus or minus) should always precede the
exponent. The 'E', 'E-', 'e', or 'e-' formats indicate that
a sign character should only precede negative exponents.

\ Escape character
In C# the backslash character causes the next character in the 
format string to be interpreted as an escape sequence. 
It is used with traditional formatting sequences like "\n" (new line).
Use the string "\\" to display "\".

'ABC' , "ABC"
 Literal string Characters enclosed in single or double
quotes are copied to the output string literally, and do not
affect formatting.

; Section separator
The ';' character is used to separate sections for positive,
negative, and zero numbers in the format string.
*/

    //Demonstrate some numeric user-defined format patterns

    i = 1234356789;
    num = 8976543.21;
    int hexnum = 1102;

    Console.WriteLine("Numeric Formatting:  user-defined custom format patterns");
    Console.WriteLine("Integer data is {0}", i);
    Console.WriteLine ("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine ("{0}\t{1}" ,"----", "------");
    PrintFormat(i, "#");
    PrintFormat(i, "###");
    PrintFormat(i, "#.00");
    PrintFormat(i, "(###) ### - ####");
    PrintFormat(i, "D4");
    PrintFormat(i, "#0.##%");
    PrintFormat(num, "%#");
    PrintFormat(num, "#,,");
    PrintFormat(num, "0.###E+000");
    PrintFormat(hexnum, "x");
    PrintFormat(hexnum, "x8");

    TryUserFormat(i);

    Console.WriteLine("-----------------------------------------------------------------------------");
    Console.WriteLine("Using Modified NumberFormatInfo\n");
    NumberFormatInfo nfi = new NumberFormatInfo();
    long n = 7654321445511;
    Console.WriteLine("\nPercentDecimalDigits = 5");
    Console.WriteLine("PercentGroupSizes = new int [] {1, 2, 3, 0}\n");
    nfi.PercentDecimalDigits = 5;
    nfi.PercentGroupSizes = new int [] {1, 2, 3, 0};
    PrintFormat(n, "p", nfi);
    Console.WriteLine("-----------------------------------------------------------------------------\n");


    // User defined types can specify their own formatting that works in exactly the same way.
    // See the definition of MyType below

    Console.WriteLine("Formatting Custom Types Example");
    Console.WriteLine("This uses the formats defined in type MyType and data 43");
    Console.WriteLine("{0}\t{1}" ,"Code", "Format");
    Console.WriteLine("{0}\t{1}" ,"----", "------");

    MyType t = new MyType (43);

    PrintFormat (t, "b");
    PrintFormat (t, "o");
    PrintFormat (t, "d");
    PrintFormat (t, "h");

    TryUserFormat(t);

    // It is also possible to add new formatting codes to existing types (such as Int32 in this example).
    // See the definition for NBaseFormatter below
    int j = 100;
    Console.WriteLine("Example of adding additional formatting codes to existing types.");
    Console.WriteLine("Uses NBaseFormatter with data value of 100.\n");

    NBaseFormatter nbf = new NBaseFormatter();

    PrintFormat(j, "B8", nbf);
    PrintFormat(j, "B16", nbf);
    
    Console.WriteLine(string.Format(nbf, "{0} in the non-custom format 'c' is {1:c}", j, j));
    Console.WriteLine(string.Format(nbf, "{0} with no formatting is {1}", j, j));

  } //Main()
Exemplo n.º 25
0
 private void MyComboBox_SelectionChanged(object sender, selectionChangedEventArgs e)
 {
     SelectedItem = (MyType)MyComboBox.SelectedValue;
     //display string with SelectedItem.Text;
 }
Exemplo n.º 26
0
        public MyGrid(MyType type, string baseRoleuserGroupId = "-1")
            : base()
        {

            this.baseRoleId = baseRoleuserGroupId;

            int i = 0;
            Random random = new Random((int)DateTime.Now.Ticks);

            switch (type)
            {
                case MyType.User:
                    {


                        List<Member> friends = DataUtil.GetMemberList(baseRoleuserGroupId);
                        rowCount = friends.Count / columnCount + 1;
                        InitRowAndColumn();



                        for (i = 0; i < friends.Count; i++)
                        {

                            MyButton button = new MyButton(MyType.User, friends[i], imageSouce, baseRoleuserGroupId);
                            Grid.SetColumn(button, i % columnCount);
                            Grid.SetRow(button, i / columnCount);
                            this.Children.Add(button);


                            var tabItem = new MyMessageTabItem(MyType.User, friends[i]);
                            DataUtil.MessageTabControl.Items.Add(tabItem);
                            DataUtil.FriendMessageTabItems.Add(friends[i].id, tabItem);
                        }



                        break;

                    }
                case MyType.UserGroup:
                    {

                        List<UserGroup> userGroups = DataUtil.UserGroups;
                        rowCount = userGroups.Count / columnCount + 1;
                        InitRowAndColumn();




                        for (i = 0; i < userGroups.Count; i++)
                        {

                            MyButton button = new MyButton(MyType.UserGroup, userGroups[i], null);
                            Grid.SetColumn(button, i % columnCount);
                            Grid.SetRow(button, i / columnCount);
                            this.Children.Add(button);

                        }
                        break;
                    }

                case MyType.UserInGroup:
                    {
                        List<Member> friends = DataUtil.GetGroupMemberList(baseRoleuserGroupId);
                        rowCount = friends.Count / columnCount + 1;
                        InitRowAndColumn();



                        for (i = 0; i < friends.Count; i++)
                        {

                            MyButton button = new MyButton(MyType.UserInGroup, friends[i], imageSouce, baseRoleuserGroupId);
                            Grid.SetColumn(button, i % columnCount);
                            Grid.SetRow(button, i / columnCount);
                            this.Children.Add(button);


                            //var tabItem = new MyMessageTabItem(MyType.UserInGroup, friends[i]);
                            //DataUtil.MessageTabControl.Items.Add(tabItem);
                            //DataUtil.MessageTabItems.Add(friends[i].id, tabItem);
                        }

                        break;

                    }

                case MyType.Group:
                    {
                        List<Group> groups = DataUtil.Groups;
                        rowCount = groups.Count / columnCount + 1;
                        InitRowAndColumn();




                        for (i = 0; i < groups.Count; i++)
                        {

                            MyButton button = new MyButton(MyType.Group, groups[i], null);
                            Grid.SetColumn(button, i % columnCount);
                            Grid.SetRow(button, i / columnCount);
                            this.Children.Add(button);


                            var tabItem = new MyMessageTabItem(MyType.Group, groups[i]);
                            DataUtil.MessageTabControl.Items.Add(tabItem);
                            DataUtil.GroupMessageTabItems.Add(groups[i].GroupId, tabItem);

                        }

                        break;
                    }
            }




        }
Exemplo n.º 27
0
 public Destination(MyType myType)
 {
     _myType = myType;
 }
Exemplo n.º 28
0
        /// <summary>
        /// MyButton构造函数
        /// </summary>
        /// <param name="type">Button类型</param>
        /// <param name="baseRole">Member或者UserGroup或者Group</param>
        /// <param name="imagesouce">如果是用户,用户头像,其他目前为空</param>
        /// <param name="color">Button颜色</param>
        public MyButton(MyType type, BaseRole baseRole, string imagesouce, string baserRoleId = "-1")
            : base()
        {
            ///设置分组ID
            this.baseRoleId = baserRoleId;
            ///设置类型
            this.type = type;
            ///设置对象Member或者UserGroup或者Group
            this.baseRole = baseRole;
            this.onlineColor = DataUtil.GetRandomColor();


            #region 分组
            if (type == MyType.UserGroup)
            {
                UserGroup userGroup = baseRole as UserGroup;
                ///分组名称
                txtName = new TextBlock();
                txtName.Text = userGroup.userGroupName;
                txtName.FontSize = fontSize;
                txtName.Foreground = new SolidColorBrush(Colors.White);
                txtName.VerticalAlignment = VerticalAlignment.Center;
                txtName.HorizontalAlignment = HorizontalAlignment.Center;
                this.Children.Add(txtName);





                ///右键菜单
                ContextMenu cm = new ContextMenu();
                ///菜单的背景色
                cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                ///菜单的前景色
                cm.Foreground = new SolidColorBrush(Colors.White);
                ///删除分组菜单项
                MenuItem deleteUserGroupMenuItem = new MenuItem();
                deleteUserGroupMenuItem.Header = "删除分组";
                ///删除分组事件
                deleteUserGroupMenuItem.Click += deleteUserGroupMenuItem_Click;
                cm.Items.Add(deleteUserGroupMenuItem);

                ///更改分组名菜单项
                MenuItem changeUserGroupNameItem = new MenuItem();
                changeUserGroupNameItem.Header = "更改分组名";
                ///更改分组名事件
                changeUserGroupNameItem.Click += changeUserGroupNameItem_Click;

                cm.Items.Add(changeUserGroupNameItem);

                this.ContextMenu = cm;
                this.Background = new SolidColorBrush(onlineColor);
            }
            #endregion

            #region 好友
            else if (type == MyType.User)
            {
                Member member = baseRole as Member;

                ///第一行用来放置头像
                RowDefinition row1 = new RowDefinition();
                row1.Height = new GridLength(zoomImageSize);
                ///第二行用来放置昵称
                RowDefinition row2 = new RowDefinition();
                //  row2.Height = new GridLength(imageHeight);
                this.RowDefinitions.Add(row1);
                this.RowDefinitions.Add(row2);

                ///用户头像
                image = new Image();
                image.Source = new BitmapImage(new Uri(imagesouce, UriKind.Relative));
                image.Height = imageSize;
                image.Width = imageSize;
                Grid.SetRow(image, 0);
                ///用户昵称
                txtName = new TextBlock();
                txtName.Text = member.nickName;
                txtName.FontSize = fontSize;
                txtName.Foreground = new SolidColorBrush(Colors.White);
                txtName.VerticalAlignment = VerticalAlignment.Center;
                txtName.HorizontalAlignment = HorizontalAlignment.Center;
                Grid.SetRow(txtName, 1);
                ///添加用户头像
                this.Children.Add(image);
                ///添加昵称
                this.Children.Add(txtName);



                ///右键菜单
                ContextMenu cm = new ContextMenu();
                ///菜单的背景色
                cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                ///菜单的前景色
                cm.Foreground = new SolidColorBrush(Colors.White);
                ///删除好友菜单项
                MenuItem deleteFriendMenuItem = new MenuItem();
                deleteFriendMenuItem.Header = "删除好友";
                ///删除好友事件
                deleteFriendMenuItem.Click += deleteFriendMenuItem_Click;
                cm.Items.Add(deleteFriendMenuItem);

                ///查看好友资料菜单项
                MenuItem viewFriendMenuItemItem = new MenuItem();
                viewFriendMenuItemItem.Header = "查看资料";
                ///更改分组名事件
                viewFriendMenuItemItem.Click += viewFriendMenuItemItem_Click;

                cm.Items.Add(viewFriendMenuItemItem);

                this.ContextMenu = cm;
                if (member.status == MemberStatus.Online)
                    this.Background = new SolidColorBrush(onlineColor);
                else if (member.status == MemberStatus.Offline)
                    this.Background = new SolidColorBrush(offlineColor);



            }
            #endregion

            #region 群组成员
            else if (type == MyType.UserInGroup)
            {
                Member member = baseRole as Member;

                ///第一行用来放置头像
                RowDefinition row1 = new RowDefinition();
                row1.Height = new GridLength(zoomImageSize);
                ///第二行用来放置昵称
                RowDefinition row2 = new RowDefinition();
                //  row2.Height = new GridLength(imageHeight);
                this.RowDefinitions.Add(row1);
                this.RowDefinitions.Add(row2);

                ///成员头像
                image = new Image();
                image.Source = new BitmapImage(new Uri(imagesouce, UriKind.Relative));
                image.Height = imageSize;
                image.Width = imageSize;
                Grid.SetRow(image, 0);
                ///成员昵称
                txtName = new TextBlock();
                txtName.Text = member.nickName;
                txtName.FontSize = fontSize;
                txtName.Foreground = new SolidColorBrush(Colors.White);
                txtName.VerticalAlignment = VerticalAlignment.Center;
                txtName.HorizontalAlignment = HorizontalAlignment.Center;
                Grid.SetRow(txtName, 1);
                ///添加成员头像
                this.Children.Add(image);
                ///添加昵称
                this.Children.Add(txtName);



                ///右键菜单
                ContextMenu cm = new ContextMenu();
                ///菜单的背景色
                cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                ///菜单的前景色
                cm.Foreground = new SolidColorBrush(Colors.White);

                if (DataUtil.GetGroupById(baserRoleId).OwnerId == DataUtil.Member.id)
                {
                    ///删除成员菜单项
                    MenuItem deleteMemberFromGroupMenuItem = new MenuItem();
                    deleteMemberFromGroupMenuItem.Header = "删除成员";
                    ///删除成员事件
                    deleteMemberFromGroupMenuItem.Click += deleteMemberFromGroupMenuItem_Click;
                    cm.Items.Add(deleteMemberFromGroupMenuItem);
                }
                ///查看好友资料菜单项
                MenuItem viewFriendMenuItemItem = new MenuItem();
                viewFriendMenuItemItem.Header = "查看资料";
                ///更改分组名事件
                viewFriendMenuItemItem.Click += viewFriendMenuItemItem_Click;

                cm.Items.Add(viewFriendMenuItemItem);

                this.ContextMenu = cm;
                if (member.status == MemberStatus.Online)
                    this.Background = new SolidColorBrush(onlineColor);
                else if (member.status == MemberStatus.Offline)
                    this.Background = new SolidColorBrush(offlineColor);
            }
            #endregion

            #region 群组
            else  if (type == MyType.Group)
            {
                Group group = baseRole as Group;
                ///群组名称
                txtName = new TextBlock();
                txtName.Text = group.Name;
                txtName.FontSize = fontSize;
                txtName.Foreground = new SolidColorBrush(Colors.White);
                txtName.VerticalAlignment = VerticalAlignment.Center;
                txtName.HorizontalAlignment = HorizontalAlignment.Center;
                this.Children.Add(txtName);





                ///右键菜单
                ContextMenu cm = new ContextMenu();
                ///菜单的背景色
                cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                ///菜单的前景色
                cm.Foreground = new SolidColorBrush(Colors.White);

                if (group.OwnerId == DataUtil.Member.id)
                {
                    ///解散群组菜单项
                    MenuItem dismissGroupMenuItem = new MenuItem();
                    dismissGroupMenuItem.Header = "解散群组";
                    ///解散分组事件
                    dismissGroupMenuItem.Click += dismissGroupMenuItem_Click;
                    cm.Items.Add(dismissGroupMenuItem); 
                    this.ContextMenu = cm;
                }
               
              

               
                this.Background = new SolidColorBrush(onlineColor);
            }
            #endregion

            ///背景色为MyGrid里面传进来的颜色

            this.Width = weight;
            this.Height = height;

            ///鼠标进入事件,放大
            this.MouseEnter += MyButton_MouseEnter;
            ///鼠标离开事件,恢复
            this.MouseLeave += MyButton_MouseLeave;

            ///鼠标点击事件
            this.MouseLeftButtonUp += MyButton_LeftButtonUp;

        }
Exemplo n.º 29
0
 public static void Method (MyType mt) {
     Console.WriteLine("Method({0})", mt);
 }
Exemplo n.º 30
0
        public MyTabItem(MyType type,string baseRoleId="-1")
        {

 
         
            ///设置分组ID
            this.baseRoleId = baseRoleId;

            ///滚动条设置
            scrollViewer = new ScrollViewer();
            ///垂直对齐stretch
            scrollViewer.VerticalAlignment = VerticalAlignment.Stretch;
            ///垂直滚动条可见性设置为Auto,当需要时候出现
            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            ///水平对齐为Stretch
            scrollViewer.HorizontalAlignment = HorizontalAlignment.Stretch;
           



            switch (type)
            {
                    ///用户分组
                case MyType.UserGroup:
                    {

                      
                        
                        ///右键菜单
                        ContextMenu cm = new ContextMenu();
                        ///添加分组
                        MenuItem addUserGroupMenuItem = new MenuItem();
                        cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                        cm.Foreground = new SolidColorBrush(Colors.White);
                        
                        addUserGroupMenuItem.Header = "添加分组";
                        addUserGroupMenuItem.Click += addUserGroupMenuItem_Click;
                        cm.Items.Add(addUserGroupMenuItem);
                        this.ContextMenu = cm;
                        
                        ///新建分组MyGrid
                         myGrid = new MyGrid(MyType.UserGroup);
                        ///添加分组结束后回调函数,此行代码不能放到事件处理函数中,因为会多次注册事件
                         DataUtil.Client.AddUserGroupCompleted += client_AddUserGroupCompleted;
                       
                        break;
                    }

                    ///好友
                case MyType.User:
                    {

                    
                        ///右键菜单
                        ContextMenu cm = new ContextMenu();
                        MenuItem addFriendMenuItem = new MenuItem();
                        cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                        cm.Foreground = new SolidColorBrush(Colors.White);

                        addFriendMenuItem.Header = "添加好友";
                        addFriendMenuItem.Click += addFriendMenuItem_Click;
                        cm.Items.Add(addFriendMenuItem);
                        this.ContextMenu = cm;
                     
                         myGrid = new MyGrid(MyType.User,this.baseRoleId);

                    

                        break;
                    }

                case MyType.UserInGroup:
                    {

                        if (DataUtil.GetGroupById(baseRoleId).OwnerId == DataUtil.Member.id)
                        {
                            ///右键菜单
                            ContextMenu cm = new ContextMenu();
                            MenuItem addMemberToGroupMenuItem = new MenuItem();
                            cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                            cm.Foreground = new SolidColorBrush(Colors.White);

                            addMemberToGroupMenuItem.Header = "添加成员";
                            addMemberToGroupMenuItem.Click += addMemberToGroupMenuItem_Click;
                            cm.Items.Add(addMemberToGroupMenuItem);
                            this.ContextMenu = cm;

                            myGrid = new MyGrid(MyType.UserInGroup, this.baseRoleId);

                        }

                        myGrid = new MyGrid(MyType.UserInGroup, this.baseRoleId);
                        break;
                    }


                case MyType.Group:
                        {
                            ///右键菜单
                            ContextMenu cm = new ContextMenu();
                            MenuItem addGroupMenuItem = new MenuItem();
                            cm.Background = new SolidColorBrush(Color.FromArgb(255, 114, 119, 123));
                            cm.Foreground = new SolidColorBrush(Colors.White);

                            addGroupMenuItem.Header = "建立群组";
                            addGroupMenuItem.Click += addGroupMenuItem_Click;
                            cm.Items.Add(addGroupMenuItem);
                            this.ContextMenu = cm;

                            myGrid = new MyGrid(MyType.Group,this.baseRoleId);
                            DataUtil.Client.AddGroupCompleted += Client_AddGroupCompleted;
                            break;
                        }
            }


            ///将控件加到当前TabItem
            scrollViewer.Content = myGrid;
            this.Content = scrollViewer;
            
        }
Exemplo n.º 31
0
 public CompositeType(T2 d)
 {
     this.d = d;
     myType = MyType.T2;
 }
 public void AddToList(MyType <T> thing, Func <MyType <T>, bool> func)
 {
     _innerList.Add(() => func(thing));
 }
Exemplo n.º 33
0
 public void WriteApiToFile(ProjectInfo projectInfo, Type type, MyType api)
 {
     File.WriteAllText(projectInfo.GetApiFilePath(type), SerializeApi(api));
 }
Exemplo n.º 34
0
 protected int GetRequestInt(string key)
 {
     return(MyType.ToInt(GetRequest(key)));
 }
Exemplo n.º 35
0
 public static void MyExtensionMethod(this MyType myType)
 {
     MyDataContextFactory.CreateContext().DoAwesomeThing();
 }
Exemplo n.º 36
0
            public static int MainMethod(string[] args)
            {
                var v = new MyType();

                return(v.RunTest() ? 0 : 1);
            }
Exemplo n.º 37
0
 /// <summary>
 /// 单 Class 单个添加
 /// </summary>
 /// <typeparam name="T">那个类</typeparam>
 /// <param name="tree">树</param>
 /// <param name="subString">菜单项名</param>
 /// <param name="color">字体颜色</param>
 protected void AddNew <R>(OdinMenuTree tree, string subString, MyEnumColor color = MyEnumColor.Blue)
     where R : new()
 {
     tree.AddObjectAtPath(subString, MyType.NewTypeClass <R>(), false, color);
 }
Exemplo n.º 38
0
 public CompositeType(T1 i)
 {
     this.i = i;
     myType = MyType.T1;
 }
Exemplo n.º 39
0
        public void Move(GameWorld gameworld)
        {
            //Finds the destinations.
            if (firstTime || destinations.Count() <= 0 || destinations == null)
            {
                Destinations(gameworld);
                firstTime = false;
            }
            //Sets the current destination.
            if (currentDes == null)
            {
                //Stops the game if there is no more destinations.
                if (orderOfBuisness.Count() <= 0)
                {
                    gameworld.gameRun = false;
                    return;
                }

                MyType temp = orderOfBuisness.Dequeue();

                Node  tempN = null;
                float dis   = 10000;
                foreach (Node node in destinations)
                {
                    //If the next disstination is a key.
                    if (temp == MyType.key && node.myType == MyType.key)
                    {
                        if (tempN == null)
                        {
                            tempN = node;
                            dis   = Distance(current.position, node.position);
                        }
                        else
                        {
                            if (dis < Distance(current.position, node.position))
                            {
                                tempN = node;
                            }
                        }
                    }
                    //If the next disstination is the stormtower.
                    if (temp == MyType.stormTower && node.myType == MyType.stormTower)
                    {
                        tempN = node;
                    }
                    //If the next disstination is the icetower.
                    if (temp == MyType.iceTower && node.myType == MyType.iceTower)
                    {
                        tempN = node;
                    }
                }
                currentDes = tempN;
            }

            //Finds the path.
            if (path.Count() <= 0 || path == null)
            {
                foreach (Node node in gameworld.map.nodes)
                {
                    node.colorPathfinding = ConsoleColor.White;
                }
                if (aStar)
                {
                    path = Pathfinding.AStarQueue(current, currentDes, ref gameworld.map);
                }
                if (dijkstra)
                {
                    path = Pathfinding.DijkstraQueue(current, currentDes, ref gameworld.map);
                }
            }

            //Moves to the next position.
            current.SetWizardHere(false, this);
            current = path.Dequeue();
            current.SetWizardHere(true, this);
            if (path.Count() <= 0)
            {
                currentDes = null;
            }

            //Does so we wait before moving on, so the wizard moves at a slower pace
            Stopwatch stopwatch          = Stopwatch.StartNew();
            int       millisecondsToWait = 500;

            gameworld.map.Render(false);
            while (true)
            {
                //some other processing to do STILL POSSIBLE
                if (stopwatch.ElapsedMilliseconds >= millisecondsToWait)
                {
                    break;
                }
                Thread.Sleep(1); //so processor can rest for a while
            }
        }
Exemplo n.º 40
0
        /// <summary>
        /// 获得排序方式
        /// </summary>
        /// <param name="tblName"></param>
        /// <returns></returns>
        private string GetSort(MyType myType)
        {
            string strSort = null;

            switch (myType)
            {
                case MyType.Service:
                    strSort = "维保到期时间, 所属区域 DESC, 具体位置 DESC";
                    break;
                case MyType.Lift:
                    break;
                case MyType.ErrorLift:
                    break;
                case MyType.ErrorList:
                    break;
                case MyType.Parts:
                    break;
                case MyType.Contract:
                    break;
                case MyType.Employee:
                    break;
                case MyType.Login:
                    break;
                default:
                    break;
            }

            //switch (tblName)
            //{
            //    case "Service":
            //        strSort = "维保到期时间, 所属区域 DESC, 具体位置 DESC";
            //        break;
            //    default:
            //        break;
            //}

            return strSort;
        }
Exemplo n.º 41
0
 public static string DoSomething <T>(this MyType <T> v)
 {
     return("");
 }
Exemplo n.º 42
0
        /// <summary>
        /// 打开维护计划表
        /// </summary>
        private void LoadData(MyType myType)
        {
            if (tsbExit.Visible)
            {
                tsbExit_Click(null, null);
            }
            if (tsbExitPrint.Visible)
            {
                tsbExitPrint_Click(null, null);
            }

            this._myType = myType;

            BLL.BaseBll bll = new BLL.BaseBll();

            DataTable dtbl = bll.GetViewInfo(myType.ToString());

            DataView dvw = new DataView(dtbl);
            SetDataView(ref dvw, "", GetSort(myType));

            //给dgv重新指定数据源
            dgvInfo.Columns.Clear();

            dgvInfo.DataSource = dvw;

            //展示查询到的记录数
            lblNumber.Text = dgvInfo.RowCount.ToString();

            //给字段名加载信息
            cbxColumnName.Items.Clear();

            for (int i = 0; i < dgvInfo.Columns.Count; i++)
            {
                cbxColumnName.Items.Add(dgvInfo.Columns[i].Name);
            }

            SetGridView(myType);
        }
Exemplo n.º 43
0
 // OR
 public static void DoSomething <T>(this MyType <T> v)
 {
     //...
 }
Exemplo n.º 44
0
	public static MyType operator |(MyType lhs, MyType rhs){
		MyType result = new MyType(lhs.IntField);
		result.IntField |= rhs.IntField;
		return result;
	}
 private static void Foo()
 {
     var myType = new MyType();
     Console.WriteLine("MyType Created");
 }
Exemplo n.º 46
0
	static void test (MyType x)
	{
		x++;
	}
Exemplo n.º 47
0
 public Ship(MyType position)
 {
     _Position       = position;
     ChangeListeners = new List <IShipChanged>();
 }
Exemplo n.º 48
0
 public void SetType(MyType type)
 {
 }
Exemplo n.º 49
0
 static void test(MyType x)
 {
     x++;
 }
Exemplo n.º 50
0
 public Destination(MyType myType)
 {
     _myType = myType;
 }
Exemplo n.º 51
0
 public EmbellishmentGroup()
 {
     Type = new MyType();
 }
Exemplo n.º 52
0
            AddButton(MyType type, BaseRole role)
        {

            if (type == MyType.UserGroup)
            {

                UserGroup userGroup = role as UserGroup;
                int index = DataUtil.UserGroups.Count;

                rowCount = (index) / columnCount + 1;
                InitRowAndColumn();




                MyButton button = new MyButton(MyType.UserGroup, role, null);
                Grid.SetColumn(button, index % columnCount);
                Grid.SetRow(button, index / columnCount);
                this.Children.Add(button);
               // if(!DataUtil.UserGroups.Contains(userGroup))
                 DataUtil.UserGroups.Add(userGroup);

            }

            else if (type == MyType.User)
            {

                Member member = role as Member;
                int index = DataUtil.GetMemberList(baseRoleId).Count;

                rowCount = (index) / columnCount + 1;
                InitRowAndColumn();


                Random random = new Random((int)DateTime.Now.Ticks);


                MyButton button = new MyButton(MyType.User, role, imageSouce, baseRoleId);
                Grid.SetColumn(button, index % columnCount);
                Grid.SetRow(button, index / columnCount);
                this.Children.Add(button);

               if( !DataUtil.IsFriend(member.id))
                 DataUtil.AddFriendTo(member,baseRoleId);
            }

            else if (type == MyType.Group)
            {
                Group g = role as Group;
                int index = DataUtil.Groups.Count ;

                rowCount = (index) / columnCount + 1;
                InitRowAndColumn();


                Random random = new Random((int)DateTime.Now.Ticks);


                MyButton button = new MyButton(MyType.Group, role, imageSouce);
                Grid.SetColumn(button, index % columnCount);
                Grid.SetRow(button, index / columnCount);
                this.Children.Add(button);
                ///将组添加到记录里面
                if(!DataUtil.Groups.Contains(g))
                    DataUtil.Groups.Add(role as Group);

            }
            else if (type == MyType.UserInGroup)
            {
                int index = DataUtil.GetGroupMemberList(baseRoleId).Count;

                rowCount = (index) / columnCount + 1;
                InitRowAndColumn();


                Random random = new Random((int)DateTime.Now.Ticks);


                MyButton button = new MyButton(MyType.UserInGroup, role, imageSouce, baseRoleId);
                Grid.SetColumn(button, index % columnCount);
                Grid.SetRow(button, index / columnCount);
                this.Children.Add(button);

                DataUtil.AddMember2Group(role as Member, baseRoleId);
            }


        }
Exemplo n.º 53
0
    /// <summary>
    /// Main entry point.
    /// </summary>
    /// <param name="args"></param>
    public static void Main(string [] args)
    {
        // DateTime built in formats

        Console.WriteLine("DateTime build-in formats using current date and time.");
        Console.WriteLine("");
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");

        DateTime d = DateTime.Now;

        PrintFormat(d, "d");
        PrintFormat(d, "D");
        PrintFormat(d, "f");
        PrintFormat(d, "F");
        PrintFormat(d, "g");
        PrintFormat(d, "G");
        PrintFormat(d, "m");
        PrintFormat(d, "r");
        PrintFormat(d, "s");
        PrintFormat(d, "t");
        PrintFormat(d, "T");
        PrintFormat(d, "u");
        PrintFormat(d, "U");
        PrintFormat(d, "y");

        TryUserFormat(d);

        //DateTime custom format patterns

/*
 * d	        The day of the month. Single-digit days will not have a leading zero.
 * dd	      The day of the month. Single-digit days will have a leading zero.
 * ddd	      The abbreviated name of the day of the week, as defined in AbbreviatedDayNames.
 * dddd	    The full name of the day of the week, as defined in DayNames.
 * M	        The numeric month. Single-digit months will not have a leading zero.
 * MM	      The numeric month. Single-digit months will have a leading zero.
 * MMM	      The abbreviated name of the month, as defined in AbbreviatedMonthNames.
 * MMMM	    The full name of the month, as defined in MonthNames.
 * y	        The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero.
 * yy	      The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.
 * yyyy	    The year in four digits, including the century.
 * gg	      The period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.
 * h	        The hour in a 12-hour clock. Single-digit hours will not have a leading zero.
 * hh	      The hour in a 12-hour clock. Single-digit hours will have a leading zero.
 * H	        The hour in a 24-hour clock. Single-digit hours will not have a leading zero.
 * HH	      The hour in a 24-hour clock. Single-digit hours will have a leading zero.
 * m	        The minute. Single-digit minutes will not have a leading zero.
 * mm	      The minute. Single-digit minutes will have a leading zero.
 * s	        The second. Single-digit seconds will not have a leading zero.
 * ss	      The second. Single-digit seconds will have a leading zero.
 * f	        The fraction of a second in single-digit precision. The remaining digits are truncated.
 * ff	      The fraction of a second in double-digit precision. The remaining digits are truncated.
 * fff	      The fraction of a second in three-digit precision. The remaining digits are truncated.
 * ffff	    The fraction of a second in four-digit precision. The remaining digits are truncated.
 * fffff	    The fraction of a second in five-digit precision. The remaining digits are truncated.
 * ffffff	  The fraction of a second in six-digit precision. The remaining digits are truncated.
 * fffffff	  The fraction of a second in seven-digit precision. The remaining digits are truncated.
 * t	        The first character in the AM/PM designator defined in AMDesignator or PMDesignator.
 * tt	      The AM/PM designator defined in AMDesignator or PMDesignator.
 * z	        The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will not have a leading zero. For example, Pacific Standard Time is "-8".
 * zz	      The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will have a leading zero. For example, Pacific Standard Time is "-08".
 * zzz	      The full time zone offset ("+" or "-" followed by the hour and minutes). Single-digit hours and minutes will have leading zeros. For example, Pacific Standard Time is "-08:00".
 * :	        The default time separator defined in TimeSeparator.
 * /	        The default date separator defined in DateSeparator.
 * % c       Where c is a format pattern if used alone. The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns.
 \ c	      Where c is any character. Displays the character literally. To display the backslash character, use "\\".
 */

        Console.WriteLine("DateTime Formatting:  user-defined custom format patterns");
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");
        PrintFormat(d, "ddd");
        PrintFormat(d, "MMMM dd, yyyy");
        PrintFormat(d, "gg");
        PrintFormat(d, "hh");
        PrintFormat(d, "HH");
        PrintFormat(d, "f");
        PrintFormat(d, "ffff");

        TryUserFormat(d);

        Console.WriteLine("-----------------------------------------------------------------------------");
        Console.WriteLine("Using Modified DateTimeFormatInfo provider\n");
        Console.WriteLine("AbbreviatedDayNames = new string [] {Sund, Mond, Tues, Weds, Thur, Frid, Satu}");
        DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

        dtfi.AbbreviatedDayNames =
            new string [] { "Sund", "Mond", "Tues", "Weds", "Thur", "Frid", "Satu" };
        PrintFormat(d, "ddd", dtfi);
        Console.WriteLine("------------------------------------------------------------------------------\n");

        /*
         * Alignment
         * To specify the alignment for a formatted string in the
         * composite formatting scheme, you can place a comma after the
         * parameter specifier and before the colon used to separate
         * the parameter specifier and the format specifier. A number
         * indicating the field width should follow the comma. A
         * negative number indicates that this parameter should be
         * right-aligned within that field, and a positive number
         * indicates it should be left-aligned. For right-aligned
         * fields, the alignment is calculated so that the last field
         * in the new alignment is the last character in the string
         * being aligned. For left-aligned fields, the alignment is
         * calculated so that the first field in the new alignment is
         * the first character of the string being aligned. Alignment
         * is always achieved using white spaces. The text is never
         * shortened to meet the specified width; instead, the width is
         * expanded to allow the full text to be displayed. Therefore,
         * in order for alignment to be meaningful, the number you pass
         * should be greater than the length of the original string you
         * are aligning.
         * The following code examples demonstrate the use of alignment
         * in formatting. The arguments that are formatted are placed
         * between '|' characters to highlight the resulting alignment.
         */
        // Formatting a table
        Console.WriteLine("Composite formatting in a table");
        string [] names = { "Mary-Beth", "Aunt Alma", "Sue", "My Really Long Name", "Matt" };
        for (int k = 0; k < 5; k++)
        {
            Console.WriteLine("| {0,-4}{1,-20} |", k, names[k]);
        }
        double [] nums = { 123.456, 888.999, -12.33333, 333.45678, -99.77777 };
        Console.WriteLine();
        for (int k = 0; k < 5; k++)
        {
            Console.WriteLine("| {0,-4:d}{1,-20:e9} |", k, nums[k]);
        }
        Console.WriteLine();


        // Enum formatting
        Console.WriteLine("Enum Formatting");
        Console.WriteLine
        (
            "Name: {0}, Enum Value: {1}, Enum Value Hex: {2}",
            Color.Green.ToString("G"),
            Color.Green.ToString("D"),
            Color.Green.ToString("X")
        );
        Console.WriteLine();

        //Number standard formats
        double num = System.Math.PI * -3.0;

        Console.WriteLine("Numeric Formatting:  Predefined floating point formats");
        Console.WriteLine("Double data is System.Math.PI * -3.0: {0}", num);
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");
        PrintFormat(num, "c");
        PrintFormat(num, "c4");
        PrintFormat(num, "e");
        PrintFormat(num, "e4");
        PrintFormat(num, "e10");
        PrintFormat(num, "f");
        PrintFormat(num, "f0");
        PrintFormat(num, "f6");
        PrintFormat(num, "g");
        PrintFormat(num, "g2");
        PrintFormat(num, "g7");
        PrintFormat(num, "n");
        PrintFormat(num, "p");
        PrintFormat(num, "p8");
        PrintFormat(num, "r");

        TryUserFormat(num);

        int i = 77;

        Console.WriteLine("Numeric Formatting:  Predefined integer point formats");
        Console.WriteLine("Integer data is {0}", i);
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");
        PrintFormat(i, "d");
        PrintFormat(i, "d8");
        PrintFormat(i, "g");
        PrintFormat(i, "g8");
        PrintFormat(i, "x");
        PrintFormat(i, "x8");

        TryUserFormat(i);

        decimal dec = new System.Decimal(-122345678.123456789012345678901234567890);

        Console.WriteLine("Numeric Formatting:  Predefined decimal formats");
        Console.WriteLine("Decimal data is {0}", dec);
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");
        PrintFormat(dec, "c");
        PrintFormat(dec, "f");
        PrintFormat(dec, "g");
        PrintFormat(dec, "n");

        TryUserFormat(dec);

        // Numeric user-defined format patterns

/*
 * 0 Zero placeholder
 * If the value being formatted has a digit in the position
 * where the '0' appears in the format string, then that digit
 * is copied to the output string. The position of the leftmost
 * '0' before the decimal point and the rightmost '0' after the
 * decimal point determines the range of digits that are always
 * present in the output string.
 *
 # Digit placeholder
 # If the value being formatted has a digit in the position
 # where the '#' appears in the format string, then that digit
 # is copied to the output string. Otherwise, nothing is stored
 # in that position in the output string. Note that this
 # specifier never displays the '0' character if it is not a
 # significant digit, even if '0' is the only digit in the
 # string. It will display the '0' character if it is a
 # significant digit in the number being displayed.
 #
 # . Decimal point
 # The first '.' character in the format string determines the
 # location of the decimal separator in the formatted value;
 # any additional '.' characters are ignored. The actual
 # character used as the decimal separator is determined by the
 # NumberDecimalSeparator property of the NumberFormatInfo
 # object that controls formatting.
 #
 # , Thousand separator and number scaling
 # The ',' character serves two purposes. First, if the format
 # string contains a ',' character between two digit
 # placeholders (0 or #) and to the left of the decimal point
 # if one is present, then the output will have thousand
 # separators inserted between each group of three digits to
 # the left of the decimal separator. The actual character used
 # as the decimal separator in the output string is determined
 # by the NumberGroupSeparator property of the current
 # NumberFormatInfo object that controls formatting.
 # Second, if the format string contains one or more ','
 # characters immediately to the left of the decimal point,
 # then the number will be divided by the number of ','
 # characters multiplied by 1000 before it is formatted. For
 # example, the format string '0,,' will represent 100 million
 # as simply 100. Use of the ',' character to indicate scaling
 # does not include thousand separators in the formatted
 # number. Thus, to scale a number by 1 million and insert
 # thousand separators you would use the format string
 # '#,##0,,'.
 #
 # % Percentage placeholder
 # The presence of a '%' character in a format string causes a
 # number to be multiplied by 100 before it is formatted. The
 # appropriate symbol is inserted in the number itself at the
 # location where the '%' appears in the format string. The
 # percent character used is dependent on the current
 # NumberFormatInfo class.
 #
 # E0, E+0, E-0, e0, e+0, e-0 Scientific notation
 # If any of the strings 'E', 'E+', 'E-', 'e', 'e+', or 'e-'
 # are present in the format string and are followed
 # immediately by at least one '0' character, then the number
 # is formatted using scientific notation with an 'E' or 'e'
 # inserted between the number and the exponent. The number of
 # '0' characters following the scientific notation indicator
 # determines the minimum number of digits to output for the
 # exponent. The 'E+' and 'e+' formats indicate that a sign
 # character (plus or minus) should always precede the
 # exponent. The 'E', 'E-', 'e', or 'e-' formats indicate that
 # a sign character should only precede negative exponents.
 #
 \ Escape character
 \ In C# the backslash character causes the next character in the
 \ format string to be interpreted as an escape sequence.
 \ It is used with traditional formatting sequences like "\n" (new line).
 \ Use the string "\\" to display "\".
 \
 \ 'ABC' , "ABC"
 \ Literal string Characters enclosed in single or double
 \ quotes are copied to the output string literally, and do not
 \ affect formatting.
 \
 \ ; Section separator
 \ The ';' character is used to separate sections for positive,
 \ negative, and zero numbers in the format string.
 */

        //Demonstrate some numeric user-defined format patterns

        i   = 1234356789;
        num = 8976543.21;
        int hexnum = 1102;

        Console.WriteLine("Numeric Formatting:  user-defined custom format patterns");
        Console.WriteLine("Integer data is {0}", i);
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");
        PrintFormat(i, "#");
        PrintFormat(i, "###");
        PrintFormat(i, "#.00");
        PrintFormat(i, "(###) ### - ####");
        PrintFormat(i, "D4");
        PrintFormat(i, "#0.##%");
        PrintFormat(num, "%#");
        PrintFormat(num, "#,,");
        PrintFormat(num, "0.###E+000");
        PrintFormat(hexnum, "x");
        PrintFormat(hexnum, "x8");

        TryUserFormat(i);

        Console.WriteLine("-----------------------------------------------------------------------------");
        Console.WriteLine("Using Modified NumberFormatInfo\n");
        NumberFormatInfo nfi = new NumberFormatInfo();
        long             n   = 7654321445511;

        Console.WriteLine("\nPercentDecimalDigits = 5");
        Console.WriteLine("PercentGroupSizes = new int [] {1, 2, 3, 0}\n");
        nfi.PercentDecimalDigits = 5;
        nfi.PercentGroupSizes    = new int [] { 1, 2, 3, 0 };
        PrintFormat(n, "p", nfi);
        Console.WriteLine("-----------------------------------------------------------------------------\n");


        // User defined types can specify their own formatting that works in exactly the same way.
        // See the definition of MyType below

        Console.WriteLine("Formatting Custom Types Example");
        Console.WriteLine("This uses the formats defined in type MyType and data 43");
        Console.WriteLine("{0}\t{1}", "Code", "Format");
        Console.WriteLine("{0}\t{1}", "----", "------");

        MyType t = new MyType(43);

        PrintFormat(t, "b");
        PrintFormat(t, "o");
        PrintFormat(t, "d");
        PrintFormat(t, "h");

        TryUserFormat(t);

        // It is also possible to add new formatting codes to existing types (such as Int32 in this example).
        // See the definition for NBaseFormatter below
        int j = 100;

        Console.WriteLine("Example of adding additional formatting codes to existing types.");
        Console.WriteLine("Uses NBaseFormatter with data value of 100.\n");

        NBaseFormatter nbf = new NBaseFormatter();

        PrintFormat(j, "B8", nbf);
        PrintFormat(j, "B16", nbf);

        Console.WriteLine(string.Format(nbf, "{0} in the non-custom format 'c' is {1:c}", j, j));
        Console.WriteLine(string.Format(nbf, "{0} with no formatting is {1}", j, j));
    } //Main()
Exemplo n.º 54
0
        public void RemoveButton(MyType type, MyButton btn)
        {


            switch (type)
            {
                case MyType.User:
                    {
                        #region 好友
                        Member member = btn.baseRole as Member;

                        int currentIndex = this.Children.IndexOf(btn);

                        ///删掉分组
                        this.Children.Remove(btn);

                        ///删除全局的分组记录
                        DataUtil.DeleteFriend(member.id, this.baseRoleId);

                        ///将后面的分组移除
                        List<MyButton> temp = new List<MyButton>();
                        for (; currentIndex < this.Children.Count; )
                        {
                            temp.Add(this.Children[currentIndex] as MyButton);
                            this.Children.RemoveAt(currentIndex);

                        }
                        ///将后面的分组前移后加上
                        foreach (MyButton button in temp)
                        {
                            Grid.SetRow(button, currentIndex / 3);
                            Grid.SetColumn(button, currentIndex % 3);
                            this.Children.Add(button);
                            currentIndex++;
                        }


                        ///将message windows 删掉
                        DataUtil.MessageTabControl.Items.Remove(DataUtil.FriendMessageTabItems[member.id]);
                        DataUtil.FriendMessageTabItems.Remove(member.id);
                        break;
                        #endregion
                    }

                case MyType.UserInGroup:
                    {
                        #region 群组成员
                        Member member = btn.baseRole as Member;



                        int currentIndex = this.Children.IndexOf(btn);

                        ///删掉成员
                        this.Children.Remove(btn);

                        ///删除组中的成员记录
                        DataUtil.DeleteMemberFromGroup(member.id, this.baseRoleId);

                        ///将后面的成员移除
                        List<MyButton> temp = new List<MyButton>();
                        for (; currentIndex < this.Children.Count; )
                        {
                            temp.Add(this.Children[currentIndex] as MyButton);
                            this.Children.RemoveAt(currentIndex);

                        }
                        ///将后面的成员前移后加上
                        foreach (MyButton button in temp)
                        {
                            Grid.SetRow(button, currentIndex / 3);
                            Grid.SetColumn(button, currentIndex % 3);
                            this.Children.Add(button);
                            currentIndex++;
                        }




                        break;
                        #endregion
                    }

                case MyType.UserGroup:
                    {
                        #region 分组
                        UserGroup userGroup = btn.baseRole as UserGroup;
                        ///将好友移至默认分组

                        MyTabItem tabItem = DataUtil.FriendTabItems[userGroup.userGroupId];
                        MyButton[] friendArray = new MyButton[tabItem.myGrid.Children.Count];
                        tabItem.myGrid.Children.CopyTo(friendArray, 0);

                        MyTabItem defaultTabItem = DataUtil.FriendTabItems["0"];
                        for (int i = 0; i < friendArray.Length; i++)
                        {
                            defaultTabItem.myGrid.AddButton(MyType.User, (friendArray[i].baseRole as Member));
                        }


                        foreach (Member member in userGroup.members)
                        {
                            DataUtil.AddFriendTo(member, "0");
                        }


                        int currentIndex = this.Children.IndexOf(btn);
                        ///删掉分组对应的好友分组
                        btn.ParentTabControl.Items.Remove(DataUtil.FriendTabItems[userGroup.userGroupId]);
                        DataUtil.FriendTabItems.Remove(userGroup.userGroupId);
                        ///删掉分组
                        this.Children.Remove(btn);

                        ///删除全局的分组记录
                        DataUtil.DeleteUserGroup(userGroup.userGroupId);

                        ///将后面的分组移除
                        List<MyButton> temp = new List<MyButton>();
                        for (; currentIndex < this.Children.Count; )
                        {
                            temp.Add(this.Children[currentIndex] as MyButton);
                            this.Children.RemoveAt(currentIndex);

                        }
                        ///将后面的分组前移后加上
                        foreach (MyButton button in temp)
                        {
                            Grid.SetRow(button, currentIndex / 3);
                            Grid.SetColumn(button, currentIndex % 3);
                            this.Children.Add(button);
                            currentIndex++;
                        }
                        #endregion
                        break;
                    }

                case MyType.Group:
                    {
                        #region 群组

                        Group group = btn.baseRole as Group;
                        ///将好友移至默认分组




                        int currentIndex = this.Children.IndexOf(btn);
                        ///删掉群组对应的成员列表
                        DataUtil.TabControl.Items.Remove(DataUtil.GroupMemberTabItems[group.GroupId]);
                        DataUtil.GroupMemberTabItems.Remove(group.GroupId);
                        ///删除群组对应的聊天窗口
                        DataUtil.MessageTabControl.Items.Remove(DataUtil.GroupMessageTabItems[group.GroupId]);
                        DataUtil.GroupMessageTabItems.Remove(group.GroupId);
              


                        ///删掉分组
                        this.Children.Remove(btn);

                        ///删除全局的分组记录
                        DataUtil.DeleteGroup(group.GroupId);

                        ///将后面的分组移除
                        List<MyButton> temp = new List<MyButton>();
                        for (; currentIndex < this.Children.Count; )
                        {
                            temp.Add(this.Children[currentIndex] as MyButton);
                            this.Children.RemoveAt(currentIndex);

                        }
                        ///将后面的分组前移后加上
                        foreach (MyButton button in temp)
                        {
                            Grid.SetRow(button, currentIndex / 3);
                            Grid.SetColumn(button, currentIndex % 3);
                            this.Children.Add(button);
                            currentIndex++;
                        }

                        break;
                        #endregion
                    }

            }


        }
Exemplo n.º 55
0
 public abstract bool Apply(MyType e);
Exemplo n.º 56
0
        public MyMessageTabItem(MyType type, BaseRole role)
        {
            this.type = type;
            this.role = role;

            switch (type)
            {
                case MyType.User:
                    {

                        Member member = role as Member;
                        sendFileMenu = new MyMenu(role,MessageType.File);
                        audioMenu = new MyMenu(role,MessageType.Audio);
                        
                        RowDefinition row1 = new RowDefinition();
                        row1.Height = new GridLength(50);
                        RowDefinition row2 = new RowDefinition();
                        RowDefinition row3 = new RowDefinition();
                        RowDefinition row4 = new RowDefinition();
                        row4.Height = new GridLength(10);
                        row3.Height = new GridLength(80);
                        grid.RowDefinitions.Add(row1);
                        grid.RowDefinitions.Add(row2);
                        grid.RowDefinitions.Add(row3);
                        grid.RowDefinitions.Add(row4);


                        this.rtxtBox.Background = new SolidColorBrush(Colors.Transparent);
                        rtxtBox.IsReadOnly = true;
                        rtxtBox.FontSize = 17;
                        rtxtBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                        rtxtBox.Foreground = new SolidColorBrush(Colors.White);
                        rtxtBox.Document.LineHeight = 0.1;
                        rtxtBox.Document.Blocks.Clear();



                        Grid.SetRow(rtxtBox, 1);
                        grid.Children.Add(rtxtBox);



                        menuGrid = new Grid();
                        ColumnDefinition column1 = new ColumnDefinition();
                        column1.Width = new GridLength(40);
                        ColumnDefinition column2 = new ColumnDefinition();
                        column2.Width = new GridLength(200);
                        ColumnDefinition column3 = new ColumnDefinition();
                        column3.Width = new GridLength(40);
                        ColumnDefinition column4 = new ColumnDefinition();
                        column4.Width = new GridLength(40);
                        ColumnDefinition column5 = new ColumnDefinition();
                        column5.Width = new GridLength(40);

                        menuGrid.ColumnDefinitions.Add(column1);
                        menuGrid.ColumnDefinitions.Add(column2);
                        menuGrid.ColumnDefinitions.Add(column3);
                        menuGrid.ColumnDefinitions.Add(column4);
                        menuGrid.ColumnDefinitions.Add(column5);


                        image = new Image();
                        image.Source = new BitmapImage(new Uri(imageSouce, UriKind.Relative));
                        image.Height = imageSize;
                        image.Width = imageSize;
                        Grid.SetRow(image, 0);


                        TextBlock txtName = new TextBlock();
                        txtName.Text = member.nickName;
                        txtName.FontSize = 25;
                        txtName.Foreground = new SolidColorBrush(Colors.White);





                        Grid.SetColumn(image, 0);
                        menuGrid.Children.Add(image);
                        Grid.SetColumn(txtName, 1);
                        menuGrid.Children.Add(txtName);
                        Grid.SetColumn(sendFileMenu, 2);
                        menuGrid.Children.Add(sendFileMenu);
                        Grid.SetColumn(audioMenu, 3);
                        menuGrid.Children.Add(audioMenu);



                        Grid.SetRow(menuGrid, 0);
                        grid.Children.Add(menuGrid);



                        txtInput = new TextBox();
                        txtInput.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                        txtInput.KeyDown += txtInput_KeyDown;
                        txtInput.FontSize = 15;
                        txtInput.TextWrapping = TextWrapping.Wrap;


                        Border border = new Border();
                        border.BorderThickness = new Thickness(2);
                        border.BorderBrush = new SolidColorBrush(Colors.SkyBlue);

                        border.Child = txtInput;


                        Grid.SetRow(border, 2);
                        grid.Children.Add(border);

                        this.AddChild(grid);


                        break;
                    }


                case MyType.Group:
                    {

                        Group group = role as Group;

                        RowDefinition row1 = new RowDefinition();
                        row1.Height = new GridLength(50);
                        RowDefinition row2 = new RowDefinition();
                        RowDefinition row3 = new RowDefinition();
                        RowDefinition row4 = new RowDefinition();
                        row4.Height = new GridLength(10);
                        row3.Height = new GridLength(80);
                        grid.RowDefinitions.Add(row1);
                        grid.RowDefinitions.Add(row2);
                        grid.RowDefinitions.Add(row3);
                        grid.RowDefinitions.Add(row4);


                        this.rtxtBox.Background = new SolidColorBrush(Colors.Transparent);
                        rtxtBox.IsReadOnly = true;
                        rtxtBox.FontSize = 17;
                        rtxtBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                        rtxtBox.Foreground = new SolidColorBrush(Colors.White);
                        rtxtBox.Document.LineHeight = 0.1;
                        rtxtBox.Document.Blocks.Clear();



                        Grid.SetRow(rtxtBox, 1);
                        grid.Children.Add(rtxtBox);



                        menuGrid = new Grid();
                        ColumnDefinition column1 = new ColumnDefinition();
                        column1.Width = new GridLength(40);
                        ColumnDefinition column2 = new ColumnDefinition();
                        column2.Width = new GridLength(200);
                        ColumnDefinition column3 = new ColumnDefinition();
                        column3.Width = new GridLength(40);
                        ColumnDefinition column4 = new ColumnDefinition();
                        column4.Width = new GridLength(40);
                        ColumnDefinition column5 = new ColumnDefinition();
                        column5.Width = new GridLength(40);

                        menuGrid.ColumnDefinitions.Add(column1);
                        menuGrid.ColumnDefinitions.Add(column2);
                        menuGrid.ColumnDefinitions.Add(column3);
                        menuGrid.ColumnDefinitions.Add(column4);
                        menuGrid.ColumnDefinitions.Add(column5);


                        image = new Image();
                        image.Source = new BitmapImage(new Uri(imageSouce, UriKind.Relative));
                        image.Height = imageSize;
                        image.Width = imageSize;
                        Grid.SetRow(image, 0);


                        TextBlock txtName = new TextBlock();
                        txtName.Text = group.Name;
                        txtName.FontSize = 25;
                        txtName.Foreground = new SolidColorBrush(Colors.White);





                        Grid.SetColumn(image, 0);
                        menuGrid.Children.Add(image);
                        Grid.SetColumn(txtName, 1);
                        menuGrid.Children.Add(txtName);





                        Grid.SetRow(menuGrid, 0);
                        grid.Children.Add(menuGrid);



                        txtInput = new TextBox();
                        txtInput.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                        txtInput.KeyDown += txtInput_KeyDown;
                        txtInput.FontSize = 15;
                        txtInput.TextWrapping = TextWrapping.Wrap;


                        Border border = new Border();
                        border.BorderThickness = new Thickness(2);
                        border.BorderBrush = new SolidColorBrush(Colors.SkyBlue);

                        border.Child = txtInput;


                        Grid.SetRow(border, 2);
                        grid.Children.Add(border);

                        this.AddChild(grid);


                        break;
                    }
            }




        }
Exemplo n.º 57
0
        private void setupMenu()
        {
            try{
                string line;
                file = new System.IO.StreamReader("RealityCPWorlds.cfg");
                buildWorldListCombo.DisplayMember = "world";
                buildWorldListCombo.ValueMember = "worldbuild";
                while ((line = file.ReadLine()) != null)
                {
                    var fields = line.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string _world = fields[0];
                    string _worldbuild = fields[1];
                    string _worldversion = fields[2];
                    worldList.Add(_world + "," + _worldbuild + "," + _worldversion);
                    item = new MyType { world = _world, worldbuild = _worldbuild, worldversion = _worldversion };
                    buildWorldListCombo.Items.Add(item); // Add the item
                    buildWorldListCombo.SelectedIndex = 0; // Selects the first item

                }
            }
            catch (Exception up)
            {
                throw up;
            }
        }