/// <summary> /// Функция запуска ядра CAD-системы. /// </summary> public static void CreateCADManagement(ITick timer) { Log._Init(Thread.CurrentThread, "Log" + DateTime.Now.ToString().Replace('.', '_').Replace(':', '_') + ".txt"); if (timer == null) { Log.Fatal("No timer!"); return; } timer.TickEvent += new ManagementControl().ManagementTick; OperationsDictionary.Add("Create Line", typeof(CreateLine)); OperationsDictionary.Add("Create Circle", typeof(CreateCircle)); }
public async void BeginOperation(string operationName) { if (CurrentDocument == null) { return; } _oldObjects.Clear(); _oldObjects.AddRange(CurrentDocument.ObjectsDictionary.Values); CurrentDocument.ObjectsDictionary.StartAccessList(); //call operation if (OperationsDictionary.ContainsKey(operationName)) { var operation = (UserOperation)Activator.CreateInstance(OperationsDictionary[operationName]); operation.OwnerDocument = CurrentDocument; ActiveOperations.Add(operation); OperationReturnValue result = OperationReturnValue.CancelOperation; Task <OperationReturnValue> task = new Task <OperationReturnValue>(operation.Execute); try { task.Start(); result = await task; } catch (Exception e) { Log.Error(e.Message); } if (result == OperationReturnValue.EndOperation) { ActiveOperations.Remove(operation); foreach (var o in new Dictionary <int, CADObject>(operation.TemporaryObjectsDictionary)) { CurrentDocument.PostCreateCADObject(o.Value); o.Value.LockOperation = null; } EndOperation(operation); } else { ActiveOperations.Remove(operation); operation.TemporaryObjectsDictionary.Clear(); } } }
public static int GetNumberOfArguments(string expression) { var separator = new char[] { ' ' }; HashSet <string> argSet = new HashSet <string>(); var exp = FormatExpression(expression); var lexemes = exp.Split(separator, StringSplitOptions.RemoveEmptyEntries); foreach (var lexeme in lexemes) { if ((!OperationsDictionary.ContainsKey(lexeme)) && (lexeme != "1") && (lexeme != "0")) { argSet.Add(lexeme); } } CountBool = argSet.Count; return(argSet.Count); }