public void Show_instructions(WorkingMode working_mode)
        {
            _input_output.Output_line("Here's how it works:");
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_01);
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_02);
            _input_output.Output_line(ReconConsts.Instructions_line_03);
            _input_output.Output_line(ReconConsts.Instructions_line_04);
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_05);
            _input_output.Output_line(ReconConsts.Instructions_line_06);
            _input_output.Output_line(ReconConsts.Instructions_line_07);
            _input_output.Output_line(ReconConsts.Instructions_line_08);
            _input_output.Output_line(ReconConsts.Instructions_line_09);
            _input_output.Output_line("                                      ****");
            _input_output.Output_line(ReconConsts.Instructions_line_10);
            _input_output.Output_line(ReconConsts.Instructions_line_11);
            _input_output.Output_line("");

            switch (working_mode)
            {
            case WorkingMode.DebugA: Show_debug_a_data_message(); break;

            case WorkingMode.DebugB: Show_debug_b_data_message(); break;

            case WorkingMode.DebugC: Show_debug_c_data_message(); break;

            case WorkingMode.Real: Show_real_data_message(); break;
            }
        }
Exemplo n.º 2
0
        public EarnedInterest(
            AConnection oDB,
            WorkingMode nMode,
            bool bAccountingMode,
            DateTime oDateOne,
            DateTime oDateTwo,
            ASafeLog oLog = null
            ) : base(oLog)
        {
            VerboseLogging = false;

            this.m_oDB = oDB;

            if (oDateTwo < oDateOne)
            {
                DateTime tmp = oDateOne;
                oDateOne = oDateTwo;
                oDateTwo = tmp;
            }             // if

            this.m_oDateStart = oDateOne;
            this.m_oDateEnd   = oDateTwo;

            this.m_oLoans         = new SortedDictionary <int, LoanData>();
            this.m_oFreezePeriods = new SortedDictionary <int, InterestFreezePeriods>();
            this.m_oBadPeriods    = new SortedDictionary <int, BadPeriods>();

            this.m_nMode = nMode;

            this.m_bAccountingMode = bAccountingMode;
        }         // constructor
Exemplo n.º 3
0
        private void ChangeMode(WorkingMode newMode)
        {
            this.WorkMode = newMode;
            switch (newMode)
            {
            case WorkingMode.Create:
                CreateToolStripMenuItem.Checked = true;
                LearnToolStripMenuItem.Checked  = false;
                QuizToolStripMenuItem.Checked   = false;
                break;

            case WorkingMode.Learn:
                CreateToolStripMenuItem.Checked = false;
                LearnToolStripMenuItem.Checked  = true;
                QuizToolStripMenuItem.Checked   = false;
                SetupLearningMode();
                break;

            case WorkingMode.Quiz:
                CreateToolStripMenuItem.Checked = false;
                LearnToolStripMenuItem.Checked  = false;
                QuizToolStripMenuItem.Checked   = true;
                break;
            }
        }
Exemplo n.º 4
0
        public void GetStatus()
        {
            try
            {
                if (!_WebSocket.IsAlive)
                {
                    _WebSocket.Connect();
                }

                XfsCommandBase <GetInfoCommand> xfsCommand = new XfsCommandBase <GetInfoCommand>
                {
                    CommandType = CommandType.Getinfo,
                    ServiceType = ServiceTypes.BCR,
                    XfsCommand  = new GetInfoCommand
                    {
                        CommandCode = BCRDefinition.WFS_INF_BCR_STATUS,
                        StatusType  = typeof(WFSBCRSTATUS),
                        Status      = new WFSBCRSTATUS(),
                        Result      = IntPtr.Zero,
                    }
                };
                workingMode = WorkingMode.GettingStatus;
                _WebSocket.Send(Newtonsoft.Json.JsonConvert.SerializeObject(xfsCommand, Formatting.Indented));
            }
            catch (Exception ex)
            {
                L4Logger.Error(ex);
            }
        }
    public string ChangeMode(string mode)
    {
        this.mode = (WorkingMode)Enum.Parse(typeof(WorkingMode), mode);

        List <IHarvester> reminder = new List <IHarvester>();

        foreach (var harvester in this.harvesters)
        {
            try
            {
                harvester.Broke();
            }
            catch (Exception)
            {
                reminder.Add(harvester);
            }
        }

        foreach (var harvester in reminder)
        {
            this.harvesters.Remove(harvester);
        }

        return(string.Format(Constants.ChangeMode, mode));
    }
Exemplo n.º 6
0
        public ClusterProvider(ClusteringOption option, WorkingMode workingMode, IClusterItemExecuteLogger logger)
        {
            this.option = option;

            clusters = new List <ICluster>();
            switch (workingMode)
            {
            case WorkingMode.Async:
                for (var i = 0; i < option.MaxConcurrentCluster; i++)
                {
                    var createOption = option.ClusterCreationOptionFactory.Create(i);
                    var cluster      = new AsyncCluster(i, createOption.Title,
                                                        createOption.ItemProcessorFactory.Create(i),
                                                        logger, option.MaxItemInQueue);
                    clusters.Add(cluster);
                }

                break;

            case WorkingMode.Sync:
                for (var i = 0; i < option.MaxConcurrentCluster; i++)
                {
                    var createOption = option.ClusterCreationOptionFactory.Create(i);
                    var cluster      = new SyncCluster(i, createOption.Title,
                                                       createOption.ItemProcessorFactory.Create(i),
                                                       logger, option.MaxItemInQueue);
                    clusters.Add(cluster);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 7
0
 public void SetStep(double offset, double delay, double riseTime)
 {
     this.Mode     = WorkingMode.Step;
     this.Offset   = offset;
     this.Delay    = delay;
     this.RiseTime = riseTime;
 }
    public HarvesterController(IEnergyRepository energyRepository)
    {
        this.energyRepository = energyRepository;
        this.harvesters       = new List <IHarvester>();

        this.mode = WorkingMode.Full;
    }
Exemplo n.º 9
0
        private void RenderToolButtons()
        {
            // ButtonLeft
            // ButtonMid
            // ButtonRight

            GUI.enabled = Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <Tilemap>() != null;
            active      = GUI.enabled ? Selection.activeGameObject.GetComponent <Tilemap>() : null;

            var j = 30;
            var i = active != null ? j : j / 3;
            var o = 10;
            var d = 2;

            if (GUI.Toggle(new Rect(o + i + 2 * j + 3 * d, 10, i, EditorGUIUtility.singleLineHeight), 3 == (int)mode, "P", "GUIEditor.BreadcrumbMid"))
            {
                mode = (WorkingMode)3;
            }
            if (GUI.Toggle(new Rect(o + 2 * j + 2 * d, 10, i, EditorGUIUtility.singleLineHeight), 2 == (int)mode, "M", "GUIEditor.BreadcrumbMid"))
            {
                mode = (WorkingMode)2;
            }
            GUI.enabled = true;


            if (GUI.Toggle(new Rect(o, 10, j, EditorGUIUtility.singleLineHeight), 0 == (int)mode, "X", "GUIEditor.BreadcrumbLeft"))
            {
                mode = (WorkingMode)0;
            }
            if (GUI.Toggle(new Rect(o + j + d, 10, j, EditorGUIUtility.singleLineHeight), 1 == (int)mode, "S", "GUIEditor.BreadcrumbMid"))
            {
                mode = (WorkingMode)1;
            }
        }
Exemplo n.º 10
0
        static void Main()
        {
            Console.WriteLine("Выберите режим работы: ");
            PrintModeMenu();
            Console.Write("Ваш выбор:");
            int choice = int.Parse(Console.ReadLine());

            if (choice == 1)
            {
                workingMode = WorkingMode.Listening;
                FileSystemListner fileSystemListner = new FileSystemListner("../../../Main");
                fileSystemListner.Start();
                Console.WriteLine("Приложение запущено в режиме Прослушивания"
                                  + Environment.NewLine + "Чтобы выйти нажмите любую кнопку");
                Console.ReadKey();
            }
            else
            {
                workingMode = WorkingMode.Backaping;

                Console.WriteLine("Приложение запущено в режиме отката Изменений!");
                while (true)
                {
                    DateTime backupDate = EnterDateTime();
                    FileSystemBackuper.Rollback(backupDate, "../../../Conservation", "../../../Main");
                }
            }
        }
        public ISpreadsheetRepoFactory Decide_on_debug()
        {
            _input_output.Output_line("");
            _input_output.Output_options(new List <string>
            {
                $"1. Debug Mode A: Copy live sheet to debug version in [live location]/{ReconConsts.Backup_sub_folder}, and work on it from there.",
                $"2. Debug Mode B: Copy sheet from {ReconConsts.Source_debug_spreadsheet_path} to [live location]/{ReconConsts.Backup_sub_folder}, and work on it from there.",
                "3. Debug Mode C: Use fake spreadsheet repo (like you would get in .Net Core).",
                "4. Work in REAL mode"
            });

            string input = _input_output.Get_generic_input(ReconConsts.DebugOrReal);

            WorkingMode             working_mode        = WorkingMode.DebugA;
            ISpreadsheetRepoFactory spreadsheet_factory = new FakeSpreadsheetRepoFactory();;

            switch (input)
            {
            case "1": { working_mode = WorkingMode.DebugA; spreadsheet_factory = Debug_mode_a(); } break;

            case "2": { working_mode = WorkingMode.DebugB; spreadsheet_factory = Debug_mode_b(); } break;

            case "3": { working_mode = WorkingMode.DebugC; spreadsheet_factory = Debug_mode_c(); } break;

            case "4": { working_mode = WorkingMode.Real; spreadsheet_factory = Real_mode(); } break;
            }

            new Communicator(_input_output).Show_instructions(working_mode);

            return(spreadsheet_factory);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Set Working Mode
        /// </summary>
        /// <param name="mode">Working Mode</param>
        public void SetWorkingMode(WorkingMode mode)
        {
            ce.Write(GpioPinValue.Low);

            byte[] value = new byte[1];
            sensor.TransferSequential(new byte[] { R_REGISTER + CONFIG }, value);

            byte setting;

            switch (mode)
            {
            case WorkingMode.RX:
                setting = (byte)(value[0] | 1);
                sensor.Write(new byte[] { W_REGISTER + CONFIG, setting });
                ce.Write(GpioPinValue.High);
                break;

            case WorkingMode.TX:
                setting = (byte)(value[0] & ~1);
                sensor.Write(new byte[] { W_REGISTER + CONFIG, setting });
                break;

            default:
                setting = (byte)(value[0] | 1);
                sensor.Write(new byte[] { W_REGISTER + CONFIG, setting });
                ce.Write(GpioPinValue.High);
                break;
            }
        }
Exemplo n.º 13
0
 public void SetSquare(double offset, double frequency, double delay, double dutyCycle)
 {
     this.Mode      = WorkingMode.Square;
     this.Offset    = offset;
     this.Frequency = frequency;
     this.Delay     = delay;
     this.DutyCycle = dutyCycle;
 }
Exemplo n.º 14
0
 public void SetSine(double offset, double frequency, double delay, double initialPhase)
 {
     this.Mode         = WorkingMode.Sine;
     this.Offset       = offset;
     this.Frequency    = frequency;
     this.Delay        = delay;
     this.InitialPhase = initialPhase;
 }
Exemplo n.º 15
0
 public DraftManager()
 {
     this.harvesters   = new Dictionary <string, Harvester>();
     this.providers    = new Dictionary <string, Provider>();
     this.energyStored = 0;
     this.oreMined     = 0;
     this.mode         = WorkingMode.Full;
 }
Exemplo n.º 16
0
 public StationMemoryOperation(string iniFilePath, WorkingMode workingMode, bool[] battArray, WorkingMode nextMode, int raderOrder, bool sleepLog) : this()
 {
     _workingMode      = workingMode;
     _androidDevice    = new AndroidDevice(iniFilePath);
     isUseBatteryArray = battArray;
     _nextMode         = nextMode;
     useRadarOrder     = raderOrder;
     fSleepLog         = sleepLog;
 }
Exemplo n.º 17
0
 public DraftManager()
 {
     this.workingMode      = WorkingMode.Full;
     this.harvesters       = new List <Harvester>();
     this.providers        = new List <Provider>();
     this.harvesterFactory = new HarvesterFactory();
     this.providerFactory  = new ProviderFactory();
     this.byId             = new Dictionary <string, Unit>();
 }
Exemplo n.º 18
0
        public SourcePrototype(string name, double value, Node positive, Node negative)
        {
            // Initialize a current/voltage source.
            this.Name     = name;
            this.Value    = value;
            this.Positive = positive;
            this.Negative = negative;

            // The default working mode is Constant.
            this.Mode = WorkingMode.Constant;
        }
Exemplo n.º 19
0
 internal ClusterInfo(int index, string title, int itemInQueueCount, int totalItemsEnqueueCount,
                      int totalItemsDequeueCount, WorkingMode workingMode, int id)
 {
     Index                  = index;
     Title                  = title;
     ItemInQueueCount       = itemInQueueCount;
     TotalItemsEnqueueCount = totalItemsEnqueueCount;
     TotalItemsDequeueCount = totalItemsDequeueCount;
     WorkingMode            = workingMode;
     Id = id;
 }
Exemplo n.º 20
0
        public void reloadPolicy(string jsonContent)
        {
            FilterPolicy newPolicy = JSONBaseClass.FromJSONString <FilterPolicy>(jsonContent, defValue: null);

            if (newPolicy != null)
            {
                proxyMode      = newPolicy.proxyMode;
                BlockedPhrases = newPolicy.BlockedPhrases;
                AllowedDomains = newPolicy.AllowedDomains;
            }
        }
Exemplo n.º 21
0
        private IManager GetManagerByMode(WorkingMode mode)
        {
            switch (mode)
            {
            case WorkingMode.DbRepository:
                return(new DbRepositoryManager());

            case WorkingMode.CloudService:
                return(new CloudServiceManager());
            }
            throw new Exception("Unknown working mode");
        }
Exemplo n.º 22
0
        private void SwitchWorkingView(WorkingMode workingMode)
        {
            switch (workingMode)
            {
            case WorkingMode.Sensorstatus: { this.SwitchSensorstatus(); break; }

            case WorkingMode.Easybuilder: { this.SwitchEasybuilder(); break; }

            default: break;
            }
            this.RaisePropertiesChanged();
            General.WorkingMode = workingMode;
        }
Exemplo n.º 23
0
        private ServerTreeNode(IServiceProvider serviceProvider, string name, string hostName, string credentials, string hash, ServerManager server, bool isLocalhost, WorkingMode mode, bool ignoreInCache)
            : base(GetNodeName(name, credentials, isLocalhost), serviceProvider)
        {
            Tag           = server;
            ServerManager = server;
            DisplayName   = name;
            HostName      = hostName;
            Credentials   = credentials;
            Mode          = mode;
            if (Mode == WorkingMode.Iis)
            {
                ImageIndex         = 8;
                SelectedImageIndex = 8;
            }
            else
            {
                ImageIndex         = 1;
                SelectedImageIndex = 1;
            }

            IsLocalhost     = isLocalhost;
            CertificateHash = hash;
            IgnoreInCache   = ignoreInCache;

            Handler = (sender1, certificate, chain, sslPolicyErrors) =>
            {
                var remoteHash = certificate.GetCertHashString();
                if (remoteHash == CertificateHash)
                {
                    return(true);
                }

                var dialog = new CertificateErrorsDialog(certificate);
                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    MainForm.SaveMenuItem.Enabled = true;
                }

                if (result != DialogResult.OK)
                {
                    return(false);
                }

                CertificateHash = remoteHash;
                return(true);
            };
        }
Exemplo n.º 24
0
        public override AsyncUnaryCall <WorkingMode> UpdateWorkingModeAsync(UpdateWorkingModeRequest request, Metadata headers = null, DateTime?deadline = null, CancellationToken cancellationToken = default)
        {
            WorkingMode workingMode = WorkingModes[request.DeviceId];

            if (request.UpdateMask == null)
            {
                workingMode.MergeFrom(request.WorkingMode);
            }
            else
            {
                request.UpdateMask.Merge(request.WorkingMode, workingMode);
            }

            return(TestCalls.AsyncUnaryCall(
                       Task.FromResult(workingMode),
                       Task.FromResult(new Metadata()),
                       () => Status.DefaultSuccess,
                       () => new Metadata(),
                       () => { }));
        }
Exemplo n.º 25
0
        }         // Run

        private bool Do(WorkingMode mode)
        {
            bool result;

            if (mode == WorkingMode.Dropbox)
            {
                result = (this.workingMode == WorkingMode.All) || (this.workingMode == mode);
            }
            else
            {
                result =
                    (this.workingMode == WorkingMode.All) ||
                    (this.workingMode == WorkingMode.ExceptDropbox) ||
                    (this.workingMode == mode);
            }             // if

            this.log.Msg("Step {0}: {1}processing.", mode, result ? string.Empty : "not ");

            return(result);
        }         // Do
Exemplo n.º 26
0
        public IpcWrapper(WorkingMode mode, int busId, int timeout = 1000)
        {
            ResetCounters();
            _timeout = timeout;
            Mode     = mode;

            switch (mode)
            {
            case WorkingMode.SignalServer:
                _sender   = new CircularBuffer($@"milsigs2c_{busId}", 8, 65536 * sizeof(byte));
                _reciever = new CircularBuffer($@"milsigc2s_{busId}", 8, 65536 * sizeof(byte));
                break;

            case WorkingMode.SignalClient:
                _sender   = new CircularBuffer($@"milsigc2s_{busId}");
                _reciever = new CircularBuffer($@"milsigs2c_{busId}");
                break;

            case WorkingMode.DataServer:
                _sender   = null;
                _reciever = new CircularBuffer($@"mildatc2s_{busId}", 64, 65536 * sizeof(byte));;
                break;

            case WorkingMode.DataClient:
                _sender   = new CircularBuffer($@"mildatc2s_{busId}");
                _reciever = null;
                break;
            }

            if (_sender != null)
            {
                Task.Run(StartSending);
            }

            if (_reciever != null)
            {
                Task.Run(StartReceiving);
            }
        }
Exemplo n.º 27
0
        private void toolPipe_Click(object sender, EventArgs e)
        {
            //flowly.CreateChange("0");
            SetTrackBarVisibility(false);
            nudCapacity.Enabled = false;
            nudFlow.Enabled = false;
            currentWorkingMode = WorkingMode.pipe;

            HighlightCurrentPB(sender as PictureBox);
        }
Exemplo n.º 28
0
        private void GetWorkMode(string upsStatus, int voltType, string batyType)
        {
            WorkingMode workingMode = WorkingMode.Common;

            this.WorkingMode = workingMode;
            string s1       = upsStatus[0].ToString();
            string s2       = upsStatus[6].ToString();
            char   upsStatu = upsStatus[2];
            double result1;
            double result2;
            int    result3;
            int    result4;

            if (!double.TryParse(this.InputVoltage, out result1) || !double.TryParse(this.InputFrequency, out result2) || (!int.TryParse(s2, out result3) || !int.TryParse(s1, out result4)))
            {
                return;
            }
            int num;

            switch (upsStatu)
            {
            case '\x001E':
                num = 0;
                break;

            case '\x001F':
                num = 1;
                break;

            case '2':
                num = 2;
                break;

            default:
                num = 0;
                break;
            }
            double result5;

            if (!double.TryParse(this.OutputVoltage, out result5))
            {
                return;
            }
            if (result1 < 10.0 || result2 > 80.0 || result2 < 40.0)
            {
                this.InputFrequency = "0";
            }
            if (!this.Abnormity.Contains("Normal"))
            {
                workingMode = WorkingMode.Fail;
            }
            else if (result1 < 50.0 && result5 >= 50.0)
            {
                workingMode        = WorkingMode.InvertOnly;
                this.ChargeCurrent = 0.0;
            }
            else if (result1 <= 73.0 && result3 == 0 && voltType == 120 || result1 >= 140.0 && result3 == 0 && voltType == 120 || (result1 <= 90.0 && result3 == 0 && voltType == 230 || result1 >= 272.0 && result3 == 0 && voltType == 230) || (result2 > 80.0 || result2 < 40.0) && result3 == 0)
            {
                workingMode        = WorkingMode.GridFailAndInvert;
                this.ChargeCurrent = 0.0;
            }
            else if (result3 == 1 && result1 <= 80.0)
            {
                workingMode = WorkingMode.GridAndInvertFail;
            }
            else if (result1 >= 130.0 && voltType == 120 || result4 == 0 || result1 >= 260.0 && voltType == 230)
            {
                switch (num)
                {
                case 0:
                    workingMode = WorkingMode.BatteryPriority;
                    break;

                case 1:
                    workingMode        = WorkingMode.Bypass;
                    this.LoadFrequency = this.InputFrequency;
                    break;

                case 2:
                    workingMode = WorkingMode.InvertOnly;
                    break;
                }
            }
            else
            {
                workingMode        = WorkingMode.GridFailAndInvert;
                this.ChargeCurrent = 0.0;
            }
            this.WorkingMode = workingMode;
            List <global::Infrastructure.Models.EarlyWarning> source = new List <global::Infrastructure.Models.EarlyWarning>();
            double result6;

            if (double.TryParse(this.BatteryVoltage, out result6))
            {
                if (!(batyType == "12V"))
                {
                    if (!(batyType == "24V"))
                    {
                        if (batyType == "48V")
                        {
                            if (result6 < 40.0)
                            {
                                source.Add(global::Infrastructure.Models.EarlyWarning.Battery_too_low);
                            }
                            if (result6 >= 64.0)
                            {
                                source.Add(global::Infrastructure.Models.EarlyWarning.Battery_too_high);
                            }
                        }
                    }
                    else
                    {
                        if (result6 < 20.0)
                        {
                            source.Add(global::Infrastructure.Models.EarlyWarning.Battery_too_low);
                        }
                        if (result6 >= 32.0)
                        {
                            source.Add(global::Infrastructure.Models.EarlyWarning.Battery_too_high);
                        }
                    }
                }
                else
                {
                    if (result6 < 10.0)
                    {
                        source.Add(global::Infrastructure.Models.EarlyWarning.Battery_too_low);
                    }
                    if (result6 >= 16.0)
                    {
                        source.Add(global::Infrastructure.Models.EarlyWarning.Battery_too_high);
                    }
                }
            }
            double result7;

            if (double.TryParse(this.Temperature, out result7) && result7 > 95.0)
            {
                source.Add(global::Infrastructure.Models.EarlyWarning.Invert_temp_high);
            }
            double result8;

            if (double.TryParse(this.OutputCurrent, out result8) && result8 > 110.0)
            {
                source.Add(global::Infrastructure.Models.EarlyWarning.Over_load);
            }
            if (!this.Abnormity.Contains("Normal") || !source.Any <global::Infrastructure.Models.EarlyWarning>())
            {
                return;
            }
            this.EarlyWarning = source;
        }
Exemplo n.º 29
0
 public string Mode(List <string> arguments)
 {
     this.mode = (WorkingMode)Enum.Parse(typeof(WorkingMode), arguments[0]);
     return($"Successfully changed working mode to {this.mode.ToString()} Mode");
 }
Exemplo n.º 30
0
        private void OnScene(SceneView view)
        {
            if (EditorWindow.focusedWindow != view)
            {
                toSelect = null;
            }
            if (toSelect != null)
            {
                Selection.activeObject = toSelect;
            }

            using (HandleGUIDispose.BeginGUI()) {
                // editMode = GUI.Toggle(new Rect(10, 10, 80, EditorGUIUtility.singleLineHeight), editMode, "Edit Tilemap", "Button");
                RenderToolButtons();
                if (mode == WorkingMode.Disable)
                {
                    toSelect = null;
                    return;
                }
                if (mode == WorkingMode.Select)
                {
                    SelectTilemap(view);
                }
                if (active == null && (int)mode >= 2)
                {
                    mode = WorkingMode.Disable;
                }

                if (mode == WorkingMode.Paint)
                {
                    int sel_x = selectedTile % active.TilesetWidth;
                    int sel_y = selectedTile / active.TilesetWidth;

                    GUI.DrawTextureWithTexCoords(new Rect(10, 50, 128, 128), active.TilesetMaterial.mainTexture, new Rect(sel_x * 1f / 16, 1 - (1 + sel_y) * 1 / 16f, 1 / 16f, 1 / 16f));
                    selectedTile = EditorGUI.IntField(new Rect(10 + 32, 50 + 8, 64, EditorGUIUtility.singleLineHeight), selectedTile);

                    if (GUI.Button(new Rect(10 - 8, 50 + 64 - 8, 16, 16), EditorGUIUtility.FindTexture("node1 hex")))
                    {
                        selectedTile = (active.TilesetWidth * active.TilesetHeight + selectedTile - 1) % (active.TilesetWidth * active.TilesetHeight);
                    }
                    if (GUI.Button(new Rect(10 - 8 + 128, 50 + 64 - 8, 16, 16), EditorGUIUtility.FindTexture("node1 hex")))
                    {
                        selectedTile = (active.TilesetWidth * active.TilesetHeight + selectedTile + 1) % (active.TilesetWidth * active.TilesetHeight);
                    }

                    if (GUI.Button(new Rect(10 + 64 - 8, 50 - 8, 16, 16), EditorGUIUtility.FindTexture("node1 hex")))
                    {
                        selectedTile = (active.TilesetWidth * active.TilesetHeight + selectedTile - active.TilesetWidth) % (active.TilesetWidth * active.TilesetHeight);
                    }

                    if (GUI.Button(new Rect(10 + 64 - 8, 50 + 120, 16, 16), EditorGUIUtility.FindTexture("node1 hex")))
                    {
                        selectedTile = (active.TilesetWidth * active.TilesetHeight + selectedTile + active.TilesetWidth) % (active.TilesetWidth * active.TilesetHeight);
                    }
                }
            }

            if (mode == WorkingMode.Paint)
            {
                var planes = GeometryUtility.CalculateFrustumPlanes(view.camera);
                var plane  = new Plane(Vector3.forward, active.TilemapBounds.center);

                float enter;
                var   ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                plane.Raycast(ray, out enter);
                var hitpoint = ray.GetPoint(enter);

                if (!active.TilemapBounds.Contains(hitpoint))
                {
                    return;
                }

                var tilepos = (hitpoint - active.transform.position);
                var tile_x  = Mathf.RoundToInt(tilepos.x);
                var tile_y  = Mathf.RoundToInt(tilepos.y);

                if (Handles.Button(new Vector3(tile_x, tile_y, 0) + active.transform.position, Quaternion.identity, active.TileSize / 2f, 1f, Handles.RectangleCap))
                {
                    active.Tiles[tile_y * active.TileMapWidth + tile_x] = selectedTile;
                    active.OnValidate();
                    EditorUtility.SetDirty(active);
                }
            }



            if (mode == WorkingMode.Modify)
            {
                #region Modify

                var p  = active.TilemapBounds.center;
                var d  = active.TilemapBounds.extents;
                var dx = new Vector3(d.x, 0, 0);
                var dy = new Vector3(0, d.y, 0);

                var size = 0.25f;
                Handles.color = Color.yellow;
                EditorGUI.BeginChangeCheck();
                var pos = Handles.FreeMoveHandle(p + dx, Quaternion.identity, 0.25f, Vector3.right, Handles.RectangleCap);
                if (EditorGUI.EndChangeCheck())
                {
                    var delta = pos - (p + dx);
                    if (delta.x > 0.75f * active.TileSize)
                    {
                        var rows = active.Tiles.Count / active.TileMapWidth;
                        for (int i = 0; i < rows; ++i)
                        {
                            active.Tiles.Insert(active.TileMapWidth * (i + 1) + i, 0);
                        }
                        active.TileMapWidth += 1;
                    }
                    else
                    if (delta.x < -0.75f * active.TileSize)
                    {
                        if (active.TileMapWidth < 2)
                        {
                            return;
                        }

                        var rows = active.Tiles.Count / active.TileMapWidth;
                        for (int r = 1; r < rows; ++r)
                        {
                            for (int i = 0; i < active.TileMapWidth; ++i)
                            {
                                active.Tiles[i - r + r * active.TileMapWidth] = active.Tiles[i + r * active.TileMapWidth];
                            }
                        }
                        active.Tiles.RemoveRange(active.Tiles.Count - 1 - rows, rows);

                        active.TileMapWidth -= 1;
                    }

                    active.OnValidate();
                    EditorUtility.SetDirty(active);
                }

                EditorGUI.BeginChangeCheck();
                pos = Handles.FreeMoveHandle(p + dy, Quaternion.identity, 0.25f, Vector3.up, Handles.RectangleCap);
                if (EditorGUI.EndChangeCheck())
                {
                    var delta = pos - (p + dy);
                    if (delta.y > 0.75f * active.TileSize)
                    {
                        active.Tiles.AddRange(new int[StepUp(active.TileMapWidth, active.Tiles.Count) - active.Tiles.Count]);
                    }
                    if (delta.y < -0.75f * active.TileSize)
                    {
                        var n = StepDown(active.TileMapWidth, active.Tiles.Count);
                        active.Tiles.RemoveRange(n, active.Tiles.Count - n);
                    }

                    active.OnValidate();
                    EditorUtility.SetDirty(active);
                }

                #endregion
            }
        }
Exemplo n.º 31
0
 public void SetWorkingMana()
 {
     this.CurrentWorkingMode = WorkingMode.Mana;
     this.CurrentCommand     = new WorkManaCommand();
 }
Exemplo n.º 32
0
 private void toolRemove_Click(object sender, EventArgs e)
 {
     SetTrackBarVisibility(false);
     ResetProperties();
     RefreshGridFromMode();
     currentWorkingMode = WorkingMode.remove;
     HighlightCurrentPB(sender as PictureBox);
 }
Exemplo n.º 33
0
        private void ActivateCreating(PictureBox pb)
        {
            ResetProperties();

            RefreshGridFromMode();
            currentWorkingMode = WorkingMode.create;
            HighlightCurrentPB(pb);

            /*

              switch (currentComponentName)
                            {
                                case ComponentName.Pump:
                                    nudCapacity.Enabled = true;
                                    nudFlow.Enabled = true;
                                    btnUpdate.Enabled = true;
                                    break;
                                case ComponentName.Sink:
                                    nudCapacity.Enabled = true;
                                    btnUpdate.Enabled = true;
                                    break;
                                case ComponentName.SplitterAdj:
                                    trackBarLeft.Enabled = true;
                                    trackBarRight.Enabled = true;
                                    trackBarRight.Visible = true;
                                    trackBarLeft.Visible = true;
                                    btnUpdate.Enabled = true;
                                    break;

                                default:
                                    //
                                    break;

                            }
              */

            switch (pb.Name)
            {
                case "toolPump":
                    nudCapacity.Enabled = true;
                    nudFlow.Enabled = true;
                    SetTrackBarVisibility(false);
                    break;

                case "toolSink":
                    nudCapacity.Enabled = true;
                    SetTrackBarVisibility(false);
                    break;
                case "toolSplitterAdj":
                    SetTrackBarVisibility(true);
                    break;

                case "toolSplitter":
                    SetTrackBarVisibility(false);
                    break;
                case "toolMerger":
                    SetTrackBarVisibility(false);
                    break;
                default:

                    //
                    break;

            }
        }
Exemplo n.º 34
0
 private void toolEdit_Click(object sender, EventArgs e)
 {
     SetTrackBarVisibility(false);
     RefreshGridFromMode();
     currentWorkingMode = WorkingMode.edit;
     HighlightCurrentPB(sender as PictureBox);
 }