///<summary> /// Calculate branch offsets. ///</summary> private void CalcBranchOffsets(ArrayList actionRecord) { if (actionRecord.Count < 1) { return; } ArrayList jumpList = new ArrayList(); Hashtable labelPos = new Hashtable(); int pos = 0; for (int i = 0; i < actionRecord.Count; i++) { BaseAction action = (BaseAction)actionRecord[i]; ActionLabel label = action as ActionLabel; IJump jump = action as IJump; if (label != null) { labelPos[label.LabelId] = pos; } if (jump != null) { jumpList.Add(new JumpPos(pos, jump)); } // recursively step through function blocks ActionDefineFunction f = actionRecord[i] as ActionDefineFunction; if (f != null) { CalcBranchOffsets(f.ActionRecord); } ActionDefineFunction2 f2 = actionRecord[i] as ActionDefineFunction2; if (f2 != null) { CalcBranchOffsets(f2.ActionRecord); } pos += action.ByteCount; } for (int i = 0; i < jumpList.Count; i++) { JumpPos j = (JumpPos)jumpList[i]; int offset = (int)labelPos[j.Jump.LabelId] - j.Position - 5; j.Jump.Offset = offset; } }
protected ActionLabel AddActionLabel(string text, Vector2 start, Vector2 end, float time, int fontSize, Color color) { ActionLabel label = new ActionLabel(text, start, end, time); GUIStyle style = new GUIStyle(); style.alignment = TextAnchor.UpperLeft; style.fontSize = fontSize; style.normal.textColor = color; label.SetGUIStyle(style); mActionLabels.Add(label); return label; }
/// <summary> /// Constructor /// </summary> /// <param name="actions">ArrayList of action objects derived from BaseAction.</param> public CodeTraverser(ArrayList actions) { actionRec = actions; labelIndexTable = new SortedList(); // fill labelIndexTable for (int i = 0; i < actions.Count; i++) { ActionLabel lbl = actions[i] as ActionLabel; if (lbl != null) { labelIndexTable[lbl.LabelId] = i; } } }
private void Walk(int index, IActionExaminer examiner, ArrayList visitedLabels) { while (index < actionRec.Count) { BaseAction a = (BaseAction)actionRec[index]; if (a is ActionLabel) { ActionLabel l = a as ActionLabel; if (visitedLabels.Contains(l.LabelId)) { //examiner.End(); return; } else { visitedLabels.Add(l.LabelId); } } examiner.Examine(index, a); if (a is ActionJump) { ActionJump j = a as ActionJump; index = (int)labelIndexTable[j.LabelId] - 1; } if (a is ActionIf) { ActionIf ai = a as ActionIf; if (!visitedLabels.Contains(ai.LabelId)) { Walk((int)labelIndexTable[ai.LabelId], examiner.Clone(), (ArrayList)visitedLabels.Clone()); } } if (a is ActionReturn) { //examiner.End(); return; } index++; } //examiner.End(); }
/// <summary> /// Checks for completeness of the text input /// </summary> /// <param name="_pValue"></param> private void _CheckForCompleteInput(string _pValue) { // Update value to match cache _pValue = _textValueCache; // Breakout if the value is unchanged if (_pValue == "") { return; } // Reset text input if applicable ActionLabel _label = _textLabels.Find(l => textValues[l.name][GameManager.playerCountry.countryName] == _pValue.ToUpper()); _textInput.text = _label != null ? "" : _textValueCache; _label?.Invoke(); }
public void Patch(Lifetime lifetime, [NotNull] IActionBar actionBar) { if (actionBar.ActionGroup.ActionId == TodoExplorerActionBarActionGroup.ID) { _separator = actionBar.InjectSeparator(int.MaxValue); _label = actionBar.InjectLabel(int.MaxValue, "Updating...", lifetime); _label.NotNull().MouseDoubleClick += Label_MouseDoubleClick; lifetime.OnTermination(() => { _label.NotNull().MouseDoubleClick -= Label_MouseDoubleClick; _label = null; _separator = null; }); _separator = actionBar.InjectSeparator(int.MaxValue); _shellLocks.Tasks.Queue(lifetime, () => UpdateRequestSignal.Fire(), TaskPriority.BelowNormal); } }
/// <summary> /// Shows the download action view. /// </summary> /// <param name="publication">Publication.</param> /// <param name="startDownload">Start download.</param> /// <param name="cancelDownloadAlert">Cancel download alert.</param> /// <param name="hasFailed">If set to <c>true</c> has failed.</param> public void ShowDownloadActionView(Publication publication, DoPublicationDownload startDownload, ShowAlert cancelDownloadAlert, bool hasFailed = false) { RemoveActionSubview(); if (publication.PublicationStatus == PublicationStatusEnum.NotDownloaded) { UIImageView downloadImageView = hasFailed ? new UIImageView(new UIImage("Images/Publication/Cover/DownloadFailed.png")) : new UIImageView(new UIImage("Images/Publication/Cover/CloudInstall.png")); if (!hasFailed) { downloadImageView.Frame = new CGRect(0, 0, ACTION_VIEW_WIDTH, ACTION_VIEW_WIDTH); } else { TriangleBackgroundColor = UIColor.FromRGB(253, 59, 47); SetNeedsDisplay(); } downloadImageView.UserInteractionEnabled = false; ActionView.AddSubview(downloadImageView); } ActionView.AddGestureRecognizer(new UITapGestureRecognizer(delegate() { startDownload(publication, (PublicationView)Superview); ShowDownloadProgressView(); })); ActionView.UserInteractionEnabled = true; this.publication = publication; this.cancelDownloadAlert = cancelDownloadAlert; if (ActionLabel != null) { ActionLabel.Hidden = false; ActionLabel.AddGestureRecognizer(new UITapGestureRecognizer(delegate() { startDownload(publication, (PublicationView)Superview); ShowDownloadProgressView(); })); } }
private void ConnectionWorker_DoWork(object sender, DoWorkEventArgs e) { while (true) { if (PhysLayer.DsrSignal()) { label3.Invoke((MethodInvoker) delegate { label3.Text = "Соединение активно"; label3.ForeColor = Color.Green; }); UpdateButton.Invoke((MethodInvoker) delegate { if (!DataLink.FileRecieving && !DataLink.FileSending) { UpdateButton.Enabled = true; } else { UpdateButton.Enabled = false; } }); ActionLabel.Invoke((MethodInvoker) delegate { if (!DataLink.FileRecieving && !DataLink.FileSending) { ActionLabel.Text = ""; } }); // Если есть соединение логическое, то пишем название порта к которому подключены if (PhysLayer.PortReciever != "" && DataLink.Connection) { label1.Invoke((MethodInvoker) delegate { label1.Text = "Подключение через " + PhysLayer.GetPortName() + " к " + PhysLayer.PortReciever; }); } else { label1.Invoke((MethodInvoker) delegate { label1.Text = "Подключен к порту " + PhysLayer.GetPortName(); }); if (!DataLink.Connection) { DataLink.EstablishConnection(); DataLink.Connection = true; } } } else { label3.Invoke((MethodInvoker) delegate { label3.Text = "Соединение отсутствует"; label3.ForeColor = Color.Red; }); UpdateButton.Invoke((MethodInvoker) delegate { UpdateButton.Enabled = false; }); label1.Invoke((MethodInvoker) delegate { if (PhysLayer.IsOpen()) { label1.Text = "Подключен к порту " + PhysLayer.GetPortName(); } else { label1.Text = "Порт закрыт"; } }); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Value = 0; }); ActionLabel.Invoke((MethodInvoker) delegate { ActionLabel.Text = ""; }); DataLink.Connection = false; PhysLayer.PortReciever = ""; } System.Threading.Thread.Sleep(1000); } }
private void TransmittingWorker_DoWork(object sender, DoWorkEventArgs e) { while (true) { if (!DataLink.FileSending && !DataLink.FileRecieving) { if (!DataLink.SendQueue.IsEmpty) { File F; if (DataLink.SendQueue.TryDequeue(out F)) { DataLink.FileSending = true; DataLink.StartSendingFile(F); /****** установка элементов формы ******/ DownloadButton.Invoke((MethodInvoker) delegate { DownloadButton.Enabled = false; }); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Maximum = (int)(F.Size / 1024); }); ActionLabel.Invoke((MethodInvoker) delegate { ActionLabel.Text = "Идет передача файла..."; }); /**************************************/ FileStream Stream = new FileStream(F.Name, FileMode.Open, FileAccess.Read); byte R; byte[] buffer = new byte[1024]; int counter = 0; // счетчик ошибок while (DataLink.FileSending) { if (!PhysLayer.DsrSignal()) { Stream.Close(); MessageBox.Show("Ошибка передачи!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); PhysLayer.ShutDown(); } if (PhysLayer.Responses.TryDequeue(out R)) { if (R == Convert.ToByte('A')) { counter = 0; try { int BytesRead = Stream.Read(buffer, 0, buffer.Length); if (BytesRead > 0) { byte[] clean = new byte[BytesRead]; for (int i = 0; i < BytesRead; i++) { clean[i] = buffer[i]; } int step = clean.Length; clean = DataLink.pack('I', clean); clean = DataLink.EncodeFrame(clean); PhysLayer.Write(clean); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Step = step / 1024; progressBar1.PerformStep(); }); } else { Stream.Close(); DataLink.EOF(); DataLink.FileSending = false; progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Value = 0; }); ActionLabel.Invoke((MethodInvoker) delegate { ActionLabel.Text = ""; }); MessageBox.Show("Передача файла завершена!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.None); } } catch (ArgumentException) { MessageBox.Show("ISKLUCHENIE"); } } if (R == Convert.ToByte('N')) { if (counter < 5) { counter++; PhysLayer.Write(buffer); } else { MessageBox.Show("Ошибка передачи!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); PhysLayer.ShutDown(); } } } } } } } if (DataLink.FileRecieving) { DownloadButton.Invoke((MethodInvoker) delegate { DownloadButton.Enabled = false; }); string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string fullPath = desktop + "\\(NEW)" + DataLink.FileRecievingName; FileStream Stream = new FileStream(fullPath, FileMode.Create, FileAccess.Write); while (DataLink.FileRecieving) { if (!PhysLayer.DsrSignal()) { Stream.Close(); System.IO.File.Delete(fullPath); MessageBox.Show("Ошибка передачи!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); PhysLayer.ShutDown(); } byte[] result; if (PhysLayer.FramesRecieved.TryDequeue(out result)) { if (Encoding.Default.GetString(result) == "EOF") { Stream.Close(); DataLink.FileRecieving = false; MessageBox.Show("Прием файла завершен!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.None); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Value = 0; }); break; } if (Encoding.Default.GetString(result) == "FNF") { Stream.Close(); System.IO.File.Delete(fullPath); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Value = 0; }); PhysLayer.ShutDown(); MessageBox.Show("Файл не найден.\r\nВыберите другой файл.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } if (Encoding.Default.GetString(result) == "SIZE") { progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Maximum = DataLink.FileRecievingSize / 1024; }); } else { try { Stream.Write(result, 0, result.Length); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Step = result.Length / 1024; progressBar1.PerformStep(); }); } catch (IOException) { MessageBox.Show("Ошибка передачи!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); PhysLayer.ShutDown(); progressBar1.Invoke((MethodInvoker) delegate { progressBar1.Value = 0; }); } } } } Stream.Close(); PhysLayer.ShutDown(); } DownloadButton.Invoke((MethodInvoker) delegate { if (listBox1.Text != "") { DownloadButton.Enabled = true; } }); Thread.Sleep(1000); } }
public CubanoHeader() : base(0.0f, 0.0f, 1.0f, 0.0f) { var action_service = ServiceManager.Get <InterfaceActionService> (); var table = new Table(2, 3, false) { ColumnSpacing = 20, RowSpacing = 8 }; table.Attach(new Alignment(0.0f, 0.0f, 0.0f, 0.0f) { (SourceBackButton = new ActionLabel() { Text = "\u2190", CurrentFontSizeEm = 2.0, DefaultFontSizeEm = 2.0, FontFamily = "DejaVu Sans" }) }, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink | AttachOptions.Shrink, 0, 0); table.Attach(new Alignment(0.0f, 0.0f, 1.0f, 0.0f) { (SearchEntry = new SearchEntry()) }, 1, 2, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand, 0, 0); var action_box = new HBox(); var align = new Alignment(0.0f, 0.0f, 0.0f, 0.0f) { action_box }; table.Attach(align, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, 0, 0); var import = new ActionLabel() { Text = Banshee.I18n.Catalog.GetString("banshee-1", "Import") }; import.Activated += (o, e) => action_service.GlobalActions["ImportAction"].Activate(); action_box.PackStart(import, false, false, 0); action_box.PackStart(new ActionLabel() { Text = "|", CanActivate = false }, false, false, 6); var preferences = new ActionLabel() { Text = Banshee.I18n.Catalog.GetString("banshee-1", "Preferences") }; preferences.Activated += (o, e) => action_service.GlobalActions["PreferencesAction"].Activate(); action_box.PackStart(preferences, false, false, 0); var close = new ActionLabel() { Text = " \u2715", CurrentFontSizeEm = 1.2 }; close.Activated += (o, e) => action_service.GlobalActions["QuitAction"].Activate(); action_box.PackStart(close, false, false, 0); // Second row Toolbar = (Toolbar)action_service.UIManager.GetWidget("/HeaderToolbar"); Toolbar.ShowArrow = false; Toolbar.ToolbarStyle = ToolbarStyle.BothHoriz; Toolbar.IconSize = IconSize.Menu; // Hide all default toolbar items, we only want the Banshee toolbar // for sources that install action items there... ultimately sucky var children = Toolbar.Children; for (int i = 0; i < children.Length; i++) { children[i].Visible = false; } var box = new HBox(); box.PackStart(new CategorySourceView(), false, false, 0); box.PackEnd(Toolbar, false, false, 0); table.Attach(box, 0, 3, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0); Add(table); ShowAll(); }