Exemple #1
0
 private void AddBasic(OptionEnum aOption)
 {
     aOption.AddDefault(kPrompt);
     aOption.Add(kAlways);
     aOption.Add(kNever);
     Add(aOption);
 }
Exemple #2
0
            public static void Foo(
                [Parameter(Aliases = "t", Description = "A string parameter with an additional alias")]
                string text,

                [Parameter(Default = 5, Description = "An int parameter with a default")]
                int number,

                [MoreThan(10)]
                [LessThan(100)]
                [Parameter(Default = 42.3, Description = "A double parameter with validation and a default value")]
                double percent,

                [Parameter(Description = "A bool parameter, which can be used as a switch")]
                bool verbose,

                [Parameter(Description = "An enum parameter")]
                OptionEnum option,

                [Parameter(Description = "An array of strings")]
                string[] array)
            {
                Console.WriteLine("text = {0}", text);
                Console.WriteLine("number = {0}", number);
                Console.WriteLine("percent = {0}", percent);
                Console.WriteLine("verbose = {0}", verbose);
                Console.WriteLine("option = {0}", option);
                Console.WriteLine("array = [{0}]", string.Join(",", array));
            }
Exemple #3
0
        public OptionPageWizard()
            : base("Wizard")
        {
            iConfig = new OptionEnum("wizardchangeconfig", "Change Configuration Settings", "Determines if the wizard will execute this step each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iConfig);

            iImportSavedPresets = new OptionEnum("wizardimport", "Import Saved Presets", "Determines if the wizard will execute this step each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iImportSavedPresets);

            iClearImport = new OptionEnum("wizardclear", "Clear Presets Window before Import", "Determines if the wizard will clear the presets window before importing your saved presets each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iClearImport);

            iCorrectIp = new OptionEnum("wizardipcorrect", "Correct IP Address Mismatches on Import", "Determines if the wizard will correct any IP address matches found when importing your presets each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iCorrectIp);

            iUseCurrentScan = new OptionEnum("wizardusescan", "Use Available Scan Data", "Determines if the wizard will use any existing scan data rather than re-scanning each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iUseCurrentScan);

            iScanType = new OptionEnum("wizardscantype", "Scan Type", "Determines if the wizard will perform a full scan (entire collection) or a quick scan (ie single album) each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            iScanType.AddDefault(kPrompt);
            iScanType.Add(kFullScan);
            iScanType.Add(kQuickScan);
            Add(iScanType);

            iSyncDs = new OptionEnum("wizardsync", "Sync Location with Linn DS", "Determines if the wizard will execute this step each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iSyncDs);

            iPrint = new OptionEnum("wizardprint", "Print Catalog", "Determines if the wizard will execute this step each time it is run. If 'Prompt' is selected, you will be prompted each time the wizard is run.");
            AddBasic(iPrint);
        }
 public bool Equals(OptionEnum obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value));
 }
Exemple #5
0
        // -01-02-
        private (string key, string alias, Type valType) GetKey(Expression bodyL, OptionEnum option)
        {
            if (bodyL.NodeType == ExpressionType.Convert)
            {
                var exp   = bodyL as UnaryExpression;
                var opMem = exp.Operand;
                return(GetKey(opMem, option));
            }
            else if (bodyL.NodeType == ExpressionType.MemberAccess)
            {
                var leftBody = bodyL as MemberExpression;
                var info     = default(PropertyInfo);

                //
                var paramType = default(Type);
                var alias     = GetAlias(leftBody);
                if (option == OptionEnum.CharLength)
                {
                    var clMemExpr = leftBody.Expression as MemberExpression;
                    paramType = clMemExpr.Expression.Type;
                    info      = paramType.GetProperty(clMemExpr.Member.Name);
                }
                else
                {
                    paramType = leftBody.Expression.Type;
                    info      = paramType.GetProperty(leftBody.Member.Name);
                }

                //
                var type  = info.PropertyType;
                var field = StaticCache
                            .EHCache
                            .GetOrAdd($"{paramType.FullName}:{info.Module.GetHashCode()}", moduleKey => new ConcurrentDictionary <Int32, String>())
                            .GetOrAdd(info.MetadataToken, innnerKey =>
                {
                    if (info.IsDefined(typeof(ColumnXAttribute), false))
                    {
                        var attr = (ColumnXAttribute)info.GetCustomAttributes(typeof(ColumnXAttribute), false)[0];
                        return(attr.Name);
                    }
                    return(info.Name);
                });

                //
                return(field, alias, type);
            }
            else if (bodyL.NodeType == ExpressionType.Call)
            {
                var mcExpr = bodyL as MethodCallExpression;
                var mem    = mcExpr.Arguments[0];
                if (option == OptionEnum.In)
                {
                    return(GetKey(mem, option));
                }
            }

            return(default(string), default(string), default(Type));
        }
Exemple #6
0
        protected static string Option(OptionEnum option)
        {
            switch (option)
            {
            case OptionEnum.None:
                return("<<<<<");

            case OptionEnum.Insert:
                return("");

            case OptionEnum.InsertTVP:
                return("");

            case OptionEnum.Set:
                return("=");

            case OptionEnum.ChangeAdd:
                return("+");

            case OptionEnum.ChangeMinus:
                return("-");

            case OptionEnum.Column:
                return("");

            case OptionEnum.ColumnAs:
                break;

            case OptionEnum.Compare:
                return("");

            case OptionEnum.Like:
                return(" like ");

            case OptionEnum.Count:
                return(" count");

            case OptionEnum.Sum:
                return(" sum");

            case OptionEnum.OneEqualOne:
                return("");

            case OptionEnum.IsNull:
                return(" is null ");

            case OptionEnum.IsNotNull:
                return(" is not null ");

            case OptionEnum.Asc:
                return(" asc ");

            case OptionEnum.Desc:
                return(" desc ");
            }
            return(" ");
        }
Exemple #7
0
 private void ShowPage(OptionEnum showPage)
 {
     TraversalOpsAndDoAction(op =>
     {
         if (showPage == op.OptionType)
         {
             ShowPage(op);
         }
     });
 }
        static void Main(string[] args)
        {
            int draws        = 0;
            int userWins     = 0;
            int computerWins = 0;

            //int userWins = 0, computerWins = 0, draws = 0;

            while (true)
            {
                try
                {
                    OptionEnum userSelection     = SelectOption();
                    OptionEnum computerSelection = ComputerOption();

                    ResultEnum result = DecideWinner(userSelection, computerSelection);

                    switch (result)
                    {
                    case ResultEnum.PlayerWins:
                        userWins++;
                        break;

                    case ResultEnum.ComputerWins:
                        computerWins++;
                        break;

                    case ResultEnum.Draw:
                        draws++;
                        break;

                    default:
                        throw new Exception("Invalid outcome");
                    }

                    int playedGames = userWins + draws + computerWins;

                    Console.WriteLine($"===={userSelection}=====||====={computerSelection}====");
                    Console.WriteLine($"========{result}========");
                    Console.WriteLine($"{"Player",10}|{"Wins",6}|{"%",6}");

                    //Console.WriteLine($"{"User",10}|{userWins,6}|{$"{CalculatePercentage(userWins, playedGames).ToString("P")}",6}");
                    Console.WriteLine($"{"User",10}|{userWins,6}|{$"{CalculatePercentage(userWins, playedGames):P}",6}");
                    Console.WriteLine($"{"Computer",10}|{computerWins,6}|{$"{CalculatePercentage(computerWins, playedGames):P}",6}");
                    Console.WriteLine($"{"Draw",10}|{draws,6}|{$"{CalculatePercentage(draws, playedGames):P}",6}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemple #9
0
        public void OptionEnum_Clone()
        {
            var optionEnum = new OptionEnum
            {
                Name  = "MyEnum",
                Value = (int)MyEnum.Option2
            };

            var cloneOptionEnum = optionEnum.Clone() as OptionEnum;

            Assert.AreEqual(optionEnum.Name, cloneOptionEnum.Name);
            Assert.AreEqual(optionEnum.Value, cloneOptionEnum.Value);
        }
Exemple #10
0
        protected static void Option(OptionEnum option, StringBuilder sb)
        {
            switch (option)
            {
            case OptionEnum.None:
            case OptionEnum.Insert:
            case OptionEnum.Column:
            case OptionEnum.ColumnAs:
            case OptionEnum.Compare:
            case OptionEnum.OneEqualOne:
                return;

            case OptionEnum.Set:
                sb.Append("=");
                return;

            case OptionEnum.ChangeAdd:
                sb.Append("+");
                return;

            case OptionEnum.ChangeMinus:
                sb.Append("-");
                return;

            case OptionEnum.Like:
                sb.Append(" like ");
                return;

            case OptionEnum.IsNull:
                sb.Append(" is null ");
                return;

            case OptionEnum.IsNotNull:
                sb.Append(" is not null ");
                return;

            case OptionEnum.Asc:
                sb.Append(" asc ");
                return;

            case OptionEnum.Desc:
                sb.Append(" desc ");
                return;

            default:
                throw new Exception($"{XConfig.EC._022} - [[{option}]] 不能解析!!!");
            }
        }
Exemple #11
0
        public void OptionEnum_CompareTo()
        {
            var optionEnum = new OptionEnum
            {
                Name  = "MyEnum",
                Value = (int)MyEnum.Option2
            };

            var expectedValue = optionEnum.CompareTo(null);

            Assert.AreEqual(-1, expectedValue);

            expectedValue = optionEnum.CompareTo(new object { });
            Assert.AreEqual(-1, expectedValue);

            expectedValue = optionEnum.CompareTo(optionEnum);
            Assert.AreEqual(0, expectedValue);
        }
Exemple #12
0
 private static string EnsureSuffix(string input, OptionEnum type)
 {
     switch (type) {
         case OptionEnum.Url:
             if (!input.EndsWith("/")) {
                 input = input + "/";
             }
             break;
         case OptionEnum.DirectoryPath:
             if (!input.EndsWith(@"\")) {
                 input = input + @"\";
             }
             break;
         default:
             throw new ArgumentOutOfRangeException("type", type, null);
     }
     return input;
 }
Exemple #13
0
        public ApplicationOptions(IHelper aHelper)
        {
            iLeftSplitterLocation = new OptionInt("leftsplitter", "Left Splitter Location", "Graphical location in pixels of left splitter", 300);
            aHelper.AddOption(iLeftSplitterLocation);

            iRightSplitterLocation = new OptionInt("rightsplitter", "Right Splitter Location", "Graphical location in pixels of right splitter", 300);
            aHelper.AddOption(iRightSplitterLocation);

            iWindowWidth = new OptionInt("width", "Window Width", "Width of application window in pixels", 900);
            aHelper.AddOption(iWindowWidth);

            iWindowHeight = new OptionInt("height", "Window Height", "Height of application window in pixels", 600);
            aHelper.AddOption(iWindowHeight);

            iWindowMaximised = new OptionBool("maximised", "Window Maximised", "Flag to determine if the application window is maximised", false);
            aHelper.AddOption(iWindowMaximised);

            iWindowMinimised = new OptionBool("minimised", "Window Minimised", "Flag to determine if the application window is minimised", false);
            aHelper.AddOption(iWindowMinimised);

            iPrintPagesPerSheetIndex = new OptionInt("printpagespersheet", "Print Pages Per Sheet Index", "Index value of pages per sheet selection for printing a catalog (last selected by user)", 0);
            aHelper.AddOption(iPrintPagesPerSheetIndex);

            iPrintPageLayout = new OptionEnum("printpagelayout", "Print Page Layout", "Page layout selection for printing a catalog (last selected by user)");
            iPrintPageLayout.AddDefault(kPotraitTrackDetails);
            iPrintPageLayout.Add(kLandscapeTrackDetails);
            iPrintPageLayout.Add(kPotrait);
            iPrintPageLayout.Add(kLandscape);
            aHelper.AddOption(iPrintPageLayout);

            iPrintOrderBooklet = new OptionBool("printorderbooklet", "Print Order Booklet", "Booklet order selection for printing a catalog (last selected by user)", false);
            aHelper.AddOption(iPrintOrderBooklet);

            iPrintDocumentType = new OptionEnum("printdoctype", "Print Document Type", "Document type selection for printing a catalog (last selected by user)");
            iPrintDocumentType.AddDefault(kPdf);
            iPrintDocumentType.Add(kRtf);
            aHelper.AddOption(iPrintDocumentType);

            iPrintSections = new OptionListString("printsections", "Print Sections", "User selected sections to print when creating a catalog", new List <string>()
            {
                kToc
            });
            aHelper.AddOption(iPrintSections);
        }
Exemple #14
0
        internal protected static void Option(OptionEnum option, StringBuilder sb, Context dc)
        {
            switch (option)
            {
            case OptionEnum.None:
            case OptionEnum.Insert:
            case OptionEnum.Column:
            case OptionEnum.ColumnAs:
            case OptionEnum.Compare:
            case OptionEnum.OneEqualOne:
                return;

            case OptionEnum.Set:
                sb.Append("=");
                return;

            case OptionEnum.ChangeAdd:
                sb.Append("+");
                return;

            case OptionEnum.ChangeMinus:
                sb.Append("-");
                return;

            case OptionEnum.IsNull:
                sb.Append(" is null ");
                return;

            case OptionEnum.IsNotNull:
                sb.Append(" is not null ");
                return;

            case OptionEnum.Asc:
                sb.Append(" asc ");
                return;

            case OptionEnum.Desc:
                sb.Append(" desc ");
                return;

            default:
                throw XConfig.EC.Exception(XConfig.EC._022, option.ToString());
            }
        }
Exemple #15
0
        public void OptionEnum_Default()
        {
            var optionEnum = new OptionEnum();

            Assert.IsNull(optionEnum.Name);
            optionEnum.Name = "MyEnum";
            Assert.AreEqual("MyEnum", optionEnum.Name);

            Assert.IsNotNull(optionEnum.Value);
            optionEnum.Value = (int)MyEnum.Option2;
            Assert.AreEqual((int)MyEnum.Option2, optionEnum.Value);

            Assert.IsNotNull(optionEnum.Default);
            optionEnum.Default = (int)MyEnum.Option1;
            Assert.AreEqual((int)MyEnum.Option1, optionEnum.Default);

            Assert.AreEqual("OptionEnumHelpText", optionEnum.HelpText);
            Assert.AreEqual("OptionEnumTooltip", optionEnum.Tooltip);
        }
Exemple #16
0
        internal UIBarButtonItemPlay(OptionEnum aOptionInsertMode, UIBarButtonItemStyle aStyle, EventHandler aHandler)
            : base(string.Empty, aStyle, aHandler)
        {
            iOptionInsertMode = aOptionInsertMode;

            if (aOptionInsertMode.Value == OptionInsertMode.kPlayNow)
            {
                State = EInsertMode.ePlayNow;
            }
            else if (aOptionInsertMode.Value == OptionInsertMode.kPlayNext)
            {
                State = EInsertMode.ePlayNext;
            }
            else if (aOptionInsertMode.Value == OptionInsertMode.kPlayLater)
            {
                State = EInsertMode.ePlayLater;
            }

            Clicked += EventClicked;
        }
Exemple #17
0
        public static void MyShow(string seller, WndAssist owner = null, OptionEnum showPage = OptionEnum.Unknown, Action uiCallback = null)
        {
            Util.Assert(!string.IsNullOrEmpty(seller));
            var wndOp = EtWindow.ShowSameNickOneInstance <WndOption>(seller, () => {
                return(new WndOption(seller));
            }, owner, true);

            if (uiCallback != null)
            {
                wndOp.Closed += (s, e) => {
                    if (uiCallback != null)
                    {
                        uiCallback();
                    }
                };
            }
            if (showPage > OptionEnum.Unknown)
            {
                wndOp.ShowPage(showPage);
            }
        }
Exemple #18
0
        public ActionResult Index()
        {
            if (!SchoolContext.CanConnect())
            {
                return(RedirectToAction("Index", "Error"));
            }

            OptionEnum selectedOption = OptionEnum.Rooms;

            if (TempData["selected"] != null)
            {
                selectedOption = (OptionEnum)TempData["selected"];
            }

            OptionList optionList = new OptionList();

            switch (selectedOption)
            {
            case OptionEnum.Rooms:
                optionList.entities = db.Rooms.Cast <Entity>().ToList();
                break;

            case OptionEnum.ClassGroups:
                optionList.entities = db.ClassGroups.Cast <Entity>().ToList();
                break;

            case OptionEnum.Subjects:
                optionList.entities = db.Subjects.Cast <Entity>().ToList();
                break;

            case OptionEnum.Teachers:
                optionList.entities = db.Teachers.Cast <Entity>().ToList();
                break;
            }
            optionList.selectedOption = selectedOption;
            ViewData["optionList"]    = optionList;
            ViewBag.optionList        = optionList;

            return(View());
        }
Exemple #19
0
        private async Task SetInsertValue <M>(M m, OptionEnum option, int index)
        {
            var props   = SC.GetModelProperys(m.GetType(), this);
            var columns = (SC.GetColumnInfos(SC.GetKey(typeof(M).FullName, Conn.Database), this)).GetAwaiter().GetResult();

            foreach (var prop in props)
            {
                var val = GH.GetTypeValue(prop.PropertyType, prop, m);
                AddConditions(new DicModel
                {
                    ColumnOne  = prop.Name,
                    Param      = prop.Name,
                    ParamRaw   = prop.Name,
                    CsValue    = val,
                    ValueType  = prop.PropertyType,
                    ColumnType = columns.First(it => it.ColumnName.Equals(prop.Name, StringComparison.OrdinalIgnoreCase)).DataType,
                    Action     = ActionEnum.Insert,
                    Option     = option,
                    TvpIndex   = index
                });
            }
        }
Exemple #20
0
        public void OptionEnum_OptionNames()
        {
            var optionEnum = new OptionEnum();

            var values = new List <KeyValuePair <string, int> >
            {
                new KeyValuePair <string, int>("Yes", 0),
                new KeyValuePair <string, int>("No", 1)
            };

            optionEnum.Values = values;

            Assert.AreEqual(2, optionEnum.OptionNames.Count);
            Assert.AreEqual("Yes", optionEnum.OptionNames[0].ToString());
            Assert.AreEqual("No", optionEnum.OptionNames[1].ToString());

            Assert.IsNull(optionEnum.OptionName);

            optionEnum.OptionName = "No";

            Assert.AreEqual(1, optionEnum.Value);
        }
Exemple #21
0
        public OptionPageFonts()
            : base("Fonts")
        {
            iSize = new OptionEnum("fontsize", "Font size", "The size of fonts to use in the application");
            iSize.AddDefault("small");
            iSize.Add("medium");
            iSize.Add("large");
            Add(iSize);

            iSmallSizes  = new float[3];
            iMediumSizes = new float[3];
            iLargeSizes  = new float[3];

            iSmallSizes[0]  = 9.0f;
            iMediumSizes[0] = 11.0f;
            iLargeSizes[0]  = 18.0f;

            for (int i = 1; i < 3; i++)
            {
                iSmallSizes[i]  = iSmallSizes[i - 1] * 1.1f;
                iMediumSizes[i] = iMediumSizes[i - 1] * 1.1f;
                iLargeSizes[i]  = iLargeSizes[i - 1] * 1.1f;
            }
        }
        public OptionPageGeneral(string aName)
            : base(aName)
        {
            iOptionExtendedTrackInfo = new OptionBool("trackinfo", "Extended track info", "Show extended track information for the current track", true);
            Add(iOptionExtendedTrackInfo);

            iOptionEnableRocker = new OptionBool("rocker", "Button controls", "Enable button controls for controlling volume and seeking", false);
            Add(iOptionEnableRocker);

            iOptionEnableLargeControls = new OptionBool("largecontrols", "Large controls", "Enable large controls for controlling volume and seeking", false);
            //Add(iOptionEnableLargeControls);

            iOptionGroupTracks = new OptionBool("groupplaylist", "Group playlist tracks", "Grouping tracks by album within the playlist window", true);
            Add(iOptionGroupTracks);

            iOptionAutoLock = new OptionEnum("autolock", "Prevent auto-lock", "When to prevent auto-lock");
            iOptionAutoLock.AddDefault("Never");
            iOptionAutoLock.Add("When charging");
            iOptionAutoLock.Add("Always");
            Add(iOptionAutoLock);

            iOptionAutoSendCrashLog = new OptionBool("autosendcrashlog", "Auto send crash log", "Automatically send crash logs to Linn", false);
            Add(iOptionAutoSendCrashLog);
        }
Exemple #23
0
 public ActionResult SelectOption(OptionEnum selectedOption)
 {
     TempData["selected"] = selectedOption;
     return(RedirectToAction("Index"));
 }
Exemple #24
0
        public async Task <ActionResult> Delete(OptionEnum selectedOption, int id)
        {
            Entity entityToDelete;

            switch (selectedOption)
            {
            case OptionEnum.Rooms:
                entityToDelete = await db.Rooms
                                 .Include(r => r.Activities)
                                 .Where(r => r.Id == id)
                                 .SingleOrDefaultAsync();

                if (entityToDelete == null)
                {
                    TempData["ConcurrencyAlert"] = @"Entity was already deleted by another user.
                        Your operation was cancelled";
                }
                else if (entityToDelete.Activities != null && entityToDelete.Activities.Any())
                {
                    TempData["Alert"] = "The entity is used in an activity";
                }
                else
                {
                    db.Rooms.Remove((Room)entityToDelete);
                }

                break;

            case OptionEnum.ClassGroups:
                entityToDelete = await db.ClassGroups
                                 .Include(cg => cg.Activities)
                                 .Where(cg => cg.Id == id)
                                 .SingleAsync();

                if (entityToDelete == null)
                {
                    TempData["ConcurrencyAlert"] = @"Entity was already deleted by another user.
                        Your operation was cancelled";
                }
                else if (entityToDelete.Activities != null && entityToDelete.Activities.Any())
                {
                    TempData["Alert"] = "The entity is used in an activity";
                }
                else
                {
                    db.ClassGroups.Remove((ClassGroup)entityToDelete);
                }

                break;

            case OptionEnum.Subjects:
                entityToDelete = await db.Subjects
                                 .Include(s => s.Activities)
                                 .Where(s => s.Id == id)
                                 .SingleAsync();

                if (entityToDelete == null)
                {
                    TempData["ConcurrencyAlert"] = @"Entity was already deleted by another user.
                        Your operation was cancelled";
                }
                else if (entityToDelete.Activities != null && entityToDelete.Activities.Any())
                {
                    TempData["Alert"] = "The entity is used in an activity";
                }
                else
                {
                    db.Subjects.Remove((Subject)entityToDelete);
                }

                break;

            case OptionEnum.Teachers:
                entityToDelete = await db.Teachers
                                 .Include(t => t.Activities)
                                 .Where(t => t.Id == id)
                                 .SingleAsync();

                if (entityToDelete == null)
                {
                    TempData["ConcurrencyAlert"] = @"Entity was already deleted by another user.
                        Your operation was cancelled";
                }
                else if (entityToDelete.Activities != null && entityToDelete.Activities.Any())
                {
                    TempData["Alert"] = "The entity is used in an activity";
                }
                else
                {
                    db.Teachers.Remove((Teacher)entityToDelete);
                }

                break;
            }
            await db.SaveChangesAsync();

            TempData["selected"] = selectedOption;
            return(RedirectToAction("Index"));
        }
Exemple #25
0
        public async Task <ActionResult> Add(OptionEnum selectedOption, Entity entity)
        {
            if (entity.Name != null)
            {
                switch (selectedOption)
                {
                case OptionEnum.Rooms:
                    Room newRoom = new Room(entity);
                    if (await db.Rooms.AnyAsync(r => r.Name == newRoom.Name))
                    {
                        TempData["Alert"] = "Entity your are trying to add already exists";
                    }
                    else
                    {
                        await db.Rooms.AddAsync(newRoom);
                    }
                    break;

                case OptionEnum.ClassGroups:
                    ClassGroup newClassGroup = new ClassGroup(entity);
                    if (await db.ClassGroups.AnyAsync(cg => cg.Name == newClassGroup.Name))
                    {
                        TempData["Alert"] = "Entity your are trying to add already exists";
                    }
                    else
                    {
                        await db.ClassGroups.AddAsync(newClassGroup);
                    }
                    break;

                case OptionEnum.Subjects:
                    Subject newSubject = new Subject(entity);
                    if (await db.Subjects.AnyAsync(s => s.Name == newSubject.Name))
                    {
                        TempData["Alert"] = "Entity your are trying to add already exists";
                    }
                    else
                    {
                        await db.Subjects.AddAsync(newSubject);
                    }
                    break;

                case OptionEnum.Teachers:
                    Teacher newTeacher = new Teacher(entity);
                    if (await db.Teachers.AnyAsync(t => t.Name == newTeacher.Name))
                    {
                        TempData["Alert"] = "Entity your are trying to add already exists";
                    }
                    else
                    {
                        await db.Teachers.AddAsync(newTeacher);
                    }
                    break;
                }
                await db.SaveChangesAsync();
            }
            else
            {
                TempData["Alert"] = "Cannot add entity with empty value";
            }
            TempData["selected"] = selectedOption;
            return(RedirectToAction("Index"));
        }
Exemple #26
0
        static void Main(string[] args)
        {
            Console.Title = "*** ** *MS Network 18 - Neum* ** ***";

            DIProvider.CreateServiceCollection();

            bool runApp = true;

            while (runApp)
            {
                Console.Clear();
                ProgramHelper.Stars();
                ProgramHelper.Title();
                ProgramHelper.Stars();
                Option();
                Console.Write("> ");
                OptionEnum option = (OptionEnum)Convert.ToInt16(Console.ReadLine());

                switch (option)
                {
                    #region << EXIT >>
                case OptionEnum.EXIT:
                {
                    runApp = false;
                    break;
                }

                    #endregion << EXIT >>

                    #region << Database options >>
                case OptionEnum.CreateDatabase:
                {
                    DatabaseProgram program = new DatabaseProgram();
                    Task.Run(() => program.CreateDatabase()).Wait();
                    break;
                }

                case OptionEnum.DeleteDatabase:
                {
                    DatabaseProgram program = new DatabaseProgram();
                    Task.Run(() => program.DeleteDatabase()).Wait();
                    break;
                }

                case OptionEnum.ListDatabase:
                {
                    DatabaseProgram program = new DatabaseProgram();
                    Task.Run(() => program.ListDatabase()).Wait();
                    break;
                }
                    #endregion << Database options >>

                    #region << Collection options >>
                case OptionEnum.CreateCollection:
                {
                    CollectionProgram program = new CollectionProgram();
                    Task.Run(() => program.CreateCollection()).Wait();
                    break;
                }

                case OptionEnum.DeleteCollection:
                {
                    CollectionProgram program = new CollectionProgram();
                    Task.Run(() => program.DeleteCollection()).Wait();
                    break;
                }

                case OptionEnum.ReadCollectionsOfDatabase:
                {
                    CollectionProgram program = new CollectionProgram();
                    Task.Run(() => program.ReadAllCollectionsFromDatabase()).Wait();
                    break;
                }

                    #endregion << Collection options >>

                    #region << Document options >>

                case OptionEnum.ReadDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.ReadDocument().Wait();
                    break;
                }

                case OptionEnum.DeleteDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.DeleteDocument().Wait();
                    break;
                }

                case OptionEnum.InsertDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.InsertDocument().Wait();
                    break;
                }

                case OptionEnum.UpdateDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.UpdateDocument().Wait();
                    break;
                }

                    #endregion << Document options >>

                    #region << Stored procedure

                case OptionEnum.CallStoredProcedure:
                {
                    StoredProcedureProgram program = new StoredProcedureProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << Stored procedure

                    #region << Trigger >>

                case OptionEnum.ExecuteWithTrigger:
                {
                    TriggerProgram program = new TriggerProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << Trigger >>

                    #region << UDF >>

                case OptionEnum.UseUDF:
                {
                    UDFProgram program = new UDFProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << UDF >>

                    #region << Exception >>

                case OptionEnum.Exception:
                {
                    ExceptionProgram program = new ExceptionProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << Exception >>

                    #region << Default >>
                default:
                {
                    runApp = false;
                    break;
                }
                    #endregion << Default >>
                }

                if (runApp)
                {
                    ProgramHelper.Wait();
                }
            }
        }
        static ResultEnum DecideWinner(OptionEnum userSelection, OptionEnum computerSelection)
        {
            #region StepByStep control

            //if (userSelection == OptionEnum.Rock && computerSelection == OptionEnum.Scissors)
            //{
            //    return ResultEnum.PlayerWins;
            //}

            //if (userSelection == OptionEnum.Paper && computerSelection == OptionEnum.Rock)
            //{
            //    return ResultEnum.PlayerWins;
            //}

            //if (userSelection == OptionEnum.Scissors && computerSelection == OptionEnum.Paper)
            //{
            //    return ResultEnum.PlayerWins;
            //}

            //if (userSelection == OptionEnum.Rock && computerSelection == OptionEnum.Paper)
            //{
            //    return ResultEnum.ComputerWins;
            //}

            //if (userSelection == OptionEnum.Paper && computerSelection == OptionEnum.Scissors)
            //{
            //    return ResultEnum.ComputerWins;
            //}

            //if (userSelection == OptionEnum.Scissors && computerSelection == OptionEnum.Rock)
            //{
            //    return ResultEnum.ComputerWins;
            //}

            //if (userSelection == OptionEnum.Rock && computerSelection == OptionEnum.Rock)
            //{
            //    return ResultEnum.Draw;
            //}

            //if (userSelection == OptionEnum.Paper && computerSelection == OptionEnum.Paper)
            //{
            //    return ResultEnum.Draw;
            //}

            //if (userSelection == OptionEnum.Scissors && computerSelection == OptionEnum.Scissors)
            //{
            //    return ResultEnum.Draw;
            //}

            //throw new Exception("Invalid scenario");



            #endregion


            #region Optimal solution with all win cases
            //if (userSelection == OptionEnum.Rock && computerSelection == OptionEnum.Scissors ||
            //    userSelection == OptionEnum.Paper && computerSelection == OptionEnum.Rock ||
            //    userSelection == OptionEnum.Scissors && computerSelection == OptionEnum.Paper)
            //{
            //    return ResultEnum.PlayerWins;
            //}

            //if (userSelection == OptionEnum.Rock && computerSelection == OptionEnum.Paper ||
            //    userSelection == OptionEnum.Paper && computerSelection == OptionEnum.Scissors ||
            //    userSelection == OptionEnum.Scissors && computerSelection == OptionEnum.Rock)
            //{
            //    return ResultEnum.ComputerWins;
            //}

            //return ResultEnum.Draw;
            #endregion


            if (userSelection == OptionEnum.Rock && computerSelection == OptionEnum.Scissors ||
                userSelection == OptionEnum.Paper && computerSelection == OptionEnum.Rock ||
                userSelection == OptionEnum.Scissors && computerSelection == OptionEnum.Paper)
            {
                return(ResultEnum.PlayerWins);
            }

            //if (userSelection == computerSelection)
            //{
            //    return ResultEnum.Draw;
            //}

            //return ResultEnum.ComputerWins;
            return(userSelection == computerSelection ? ResultEnum.Draw : ResultEnum.ComputerWins);
        }
Exemple #28
0
        internal void InitialiseStack()
        {
            OptionPage generalOptionsPage = new OptionPage("General");

            iHideCursorOption = new OptionBool("hidecursor", "Hide Cursor", "Hide Cursor", false);
            generalOptionsPage.Add(iHideCursorOption);
            iRotaryControlsOption = new OptionBool("rotarycontrol", "Use rotary controls", "Use rotary controls", true);
            generalOptionsPage.Add(iRotaryControlsOption);
            iShowToolTipsOption = new OptionBool("tooltips", "Show tooltips", "Show tooltips", true);
            generalOptionsPage.Add(iShowToolTipsOption);
            iShowExtendedTrackInfoOption = new OptionBool("trackinfo", "Extended track info", "Show extended track information", true);
            generalOptionsPage.Add(iShowExtendedTrackInfoOption);
            iGroupPlaylistOption = new OptionBool("groupplaylist", "Group playlist items by album", "Allows grouping of items within the playlist window", false);
            generalOptionsPage.Add(iGroupPlaylistOption);
            iTransparentOption = new OptionBool("customwindow", "Transparent window (requires restart)", "Toggles custom window", true);
            generalOptionsPage.Add(iTransparentOption);
            iSoftwareRenderingOption = new OptionBool("softwarerendering", "Force software rendering (requires restart)", "Disables hardware rendering for troublesome display cards", false);
            generalOptionsPage.Add(iSoftwareRenderingOption);
            iHelper.AddOptionPage(generalOptionsPage);

            iOptionPageUpdates = new OptionPageUpdates(iHelper);
            iHelper.AddOptionPage(iOptionPageUpdates);



            OptionPage fontsOptionPage = new OptionPage("Fonts");

            iFontsOption = new OptionEnum("fontsize", "Font size", "Font size");
            iFontsOption.AddDefault(kFontOptionNormal);
            iFontsOption.Add(kFontOptionLarge);
            fontsOptionPage.Add(iFontsOption);

            iHideCursorOption.EventValueChanged            += OnOptionChanged;
            iRotaryControlsOption.EventValueChanged        += OnOptionChanged;
            iShowToolTipsOption.EventValueChanged          += OnOptionChanged;
            iShowExtendedTrackInfoOption.EventValueChanged += OnOptionChanged;
            iFontsOption.EventValueChanged              += OnOptionChanged;
            iTransparentOption.EventValueChanged        += OnOptionChanged;
            iOptionPageUpdates.EventBetaVersionsChanged += OnUpdatesChanged;
            iOptionPageUpdates.EventAutoUpdateChanged   += OnUpdatesChanged;

            iHelper.AddOptionPage(fontsOptionPage);

            iViewMaster = new ViewMaster();
            iHttpServer = new HttpServer(HttpServer.kPortKinskyDesktop);
            iHttpClient = new HttpClient();

            iLibrary         = new MediaProviderLibrary(iHelper);
            iSharedPlaylists = new SharedPlaylists(iHelper);
            iLocalPlaylists  = new LocalPlaylists(iHelper, true);

            iSupport = new MediaProviderSupport(iHttpServer);

            PluginManager pluginManager = new PluginManager(iHelper, iHttpClient, iSupport);

            iLocator = new ContentDirectoryLocator(pluginManager, new AppRestartHandler());
            OptionBool optionSharedPlaylists = iLocator.Add(SharedPlaylists.kRootId, iSharedPlaylists);
            OptionBool optionLocalPlaylists  = iLocator.Add(LocalPlaylists.kRootId, iLocalPlaylists);

            iLocator.Add(MediaProviderLibrary.kLibraryId, iLibrary);
            iHelper.AddOptionPage(iLocator.OptionPage);

            iSaveSupport     = new SaveSupport(iHelper, iSharedPlaylists, optionSharedPlaylists, iLocalPlaylists, optionLocalPlaylists);
            iViewSaveSupport = new ViewSaveSupport(RequestLocalPlaylistFilename, iSaveSupport);
            iPlaySupport     = new PlaySupport();

            iHelper.ProcessOptionsFileAndCommandLine();
            SetUpdateTypes();
        }
Exemple #29
0
        public BrowserToolbar(UITableViewController aTableViewController, ConfigController aConfigController, OptionEnum aOptionInsertMode)
        {
            iTableViewController = aTableViewController;
            iConfigController    = aConfigController;

            iButtonConfig           = new UIBarButtonItem(new UIImage("Settings.png"), UIBarButtonItemStyle.Bordered, null);
            iButtonConfig.TintColor = UIColor.White;
            //iButtonConfig.SetBackgroundImage(new UIImage("Button.png"), UIControlState.Normal, UIBarMetrics.Default);
            iButtonConfig.Width = 40.0f;

            iBadgeView                 = new BadgeView(new CGRect(40, 0, 14, 14));
            iBadgeView.Value           = 1;
            iBadgeView.Font            = iBadgeView.Font.WithSize(10);
            iBadgeView.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0);        // transparent
            iBadgeView.FillColor       = UIColor.FromRGB(15, 151, 179);       // #0F9783
            iBadgeView.StrokeColor     = UIColor.White;
            iBadgeView.TextColor       = UIColor.White;
            iBadgeView.Hidden          = NotificationView.Instance.Current == null || NotificationView.Instance.Current.HasBeenAcknowledged;
            NotificationView.Instance.EventCurrentChanged += (s, e) =>
            {
                iBadgeView.Hidden = NotificationView.Instance.Current == null || NotificationView.Instance.Current.HasBeenAcknowledged;
            };

            iButtonPlay           = new UIBarButtonItemPlay(aOptionInsertMode, UIBarButtonItemStyle.Bordered, null);
            iButtonPlay.TintColor = UIColor.White;
            //iButtonPlay.SetBackgroundImage(new UIImage("Button.png"), UIControlState.Normal, UIBarMetrics.Default);
            iButtonSpacer1        = new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace);
            iButtonSpacer1.Width  = 20.0f;
            iButtonEdit           = new UIBarButtonItem(UIBarButtonSystemItem.Edit);
            iButtonEdit.TintColor = UIColor.White;
            //iButtonEdit.SetBackgroundImage(new UIImage("Button.png"), UIControlState.Normal, UIBarMetrics.Default);
            iButtonDone           = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            iButtonDone.TintColor = UIColor.White;
            //iButtonDone.SetBackgroundImage(new UIImage("Button.png"), UIControlState.Normal, UIBarMetrics.Default);
            iButtonSpacer2 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            //iButtonSpacer2.Width = 30.0f;

            iButtonConfig.Clicked    += ConfigClicked;
            iButtonEdit.Clicked      += EditClicked;
            iButtonDone.Clicked      += DoneClicked;
            iBadgeView.TouchUpInside += ConfigClicked;

            iTableViewController.SetToolbarItems(new UIBarButtonItem[] { iButtonConfig, iButtonPlay, iButtonSpacer1, iButtonSpacer2 }, false);
            iTableViewController.NavigationController.Toolbar.AddSubview(iBadgeView);
        }
Exemple #30
0
        public BrowserToolbar(UITableViewController aTableViewController, ConfigController aConfigController, OptionEnum aOptionInsertMode)
        {
            iTableViewController = aTableViewController;
            iConfigController    = aConfigController;

            iButtonConfig        = new UIBarButtonItem(new UIImage("Settings.png"), UIBarButtonItemStyle.Bordered, null);
            iButtonPlay          = new UIBarButtonItemPlay(aOptionInsertMode, UIBarButtonItemStyle.Bordered, null);
            iButtonSpacer1       = new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace);
            iButtonSpacer1.Width = 20.0f;
            iButtonEdit          = new UIBarButtonItem(UIBarButtonSystemItem.Edit);
            iButtonDone          = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            iButtonSpacer2       = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            //iButtonSpacer2.Width = 30.0f;

            iButtonConfig.Clicked += ConfigClicked;
            iButtonEdit.Clicked   += EditClicked;
            iButtonDone.Clicked   += DoneClicked;

            iTableViewController.SetToolbarItems(new UIBarButtonItem[] { iButtonConfig, iButtonPlay, iButtonSpacer1, iButtonSpacer2 }, false);
        }
Exemple #31
0
        /****************************************************************************************************************************************/

        internal void SetChangeHandle <M, F>(Expression <Func <M, F> > propertyFunc, F modVal, OptionEnum option)
            where M : class
        {
            var keyDic = DC.XE.FuncMFExpression(propertyFunc);
            var key    = keyDic.TbCol;
            var val    = default(ValueInfo);

            if (modVal == null)
            {
                val = null;
            }
            else
            {
                val = DC.VH.ExpandoObjectValue(modVal);
            }
            DC.Option  = option;
            DC.Compare = CompareXEnum.None;
            DC.DPH.AddParameter(DC.DPH.SetDic(typeof(M), key, key, val, typeof(F)));
        }