Stránka 1 z 1
Ovládání pomocí tří tlačítek na select, plus, minus
Napsal: ned 23. led 2011, 18:11
od M4r1hu4n3
Kdysi jsem měl program u kterého se tlačítkem select rotovaly obrazovky s různýma proměnnýma a tlačítky plus a mínus se hodnota proměnné navyšovala nebo snižovala ale jen té proměnné která byla aktuálně zobrazena. Teď když jsem to chtěl udělat zas, tak už si nepamatuju jak jsem to vyřešil a po předchozím programu ani památky. Kdyby měl někdo nějaký nápad jak by to šlo, tak bych byl vděčný. Je to v C.
Re: Ovládání pomocí tří tlačítek na select, plus, minus
Napsal: ned 23. led 2011, 21:01
od arxeiss
Nechápu, jak myslíš více obrazovek, kdy se hodnota navyšovala? když jsi zmáčkl to plus nebo jak?
Re: Ovládání pomocí tří tlačítek na select, plus, minus
Napsal: ned 23. led 2011, 21:06
od M4r1hu4n3
Ano hodnota se navyšovala když jsem zmáčkl plus a snižovala minusem, a mezi těma proměnnýma který se dali navyšovat a snižovat se volilo klasicky rotací přes klasický switch.
Re: Ovládání pomocí tří tlačítek na select, plus, minus
Napsal: ned 23. led 2011, 21:07
od arxeiss
A ty obrazovky jsou co?
Teda mělo to nějaký vzhled? nebo napsané v konzoli?
Re: Ovládání pomocí tří tlačítek na select, plus, minus
Napsal: ned 23. led 2011, 21:23
od Saphire
Pokusil jsem se něco co popisuješ udělat v c#:
Kód: Vybrat vše
/*
* Created by SharpDevelop.
* Date: 2011-01-23
* Time: 21:11
*
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace plusminus
{
public class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
}
void NimusButtonClick(object sender, EventArgs e)
{
Int64 num = System.Int64.Parse(this.listBox.SelectedItem.ToString());
this.listBox.Items[this.listBox.SelectedIndex] = num-1;
}
void PlusButtonClick(object sender, EventArgs e)
{
Int64 num = System.Int64.Parse(this.listBox.SelectedItem.ToString());
this.listBox.Items[this.listBox.SelectedIndex] = num+1;
}
void DeleteButtonClick(object sender, EventArgs e)
{
this.listBox.Items.RemoveAt(this.listBox.SelectedIndex);
}
void AddButtonClick(object sender, EventArgs e)
{
this.listBox.Items.Add(0);
}
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.listBox = new System.Windows.Forms.ListBox();
this.nimusButton = new System.Windows.Forms.Button();
this.plusButton = new System.Windows.Forms.Button();
this.deleteButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listBox
//
this.listBox.FormattingEnabled = true;
this.listBox.Location = new System.Drawing.Point(32, 30);
this.listBox.Name = "listBox";
this.listBox.Size = new System.Drawing.Size(205, 95);
this.listBox.TabIndex = 0;
//
// nimusButton
//
this.nimusButton.Location = new System.Drawing.Point(291, 41);
this.nimusButton.Name = "nimusButton";
this.nimusButton.Size = new System.Drawing.Size(43, 31);
this.nimusButton.TabIndex = 1;
this.nimusButton.Text = "-";
this.nimusButton.UseVisualStyleBackColor = true;
this.nimusButton.Click += new System.EventHandler(this.NimusButtonClick);
//
// plusButton
//
this.plusButton.Location = new System.Drawing.Point(358, 41);
this.plusButton.Name = "plusButton";
this.plusButton.Size = new System.Drawing.Size(43, 31);
this.plusButton.TabIndex = 1;
this.plusButton.Text = "+";
this.plusButton.UseVisualStyleBackColor = true;
this.plusButton.Click += new System.EventHandler(this.PlusButtonClick);
//
// deleteButton
//
this.deleteButton.Location = new System.Drawing.Point(32, 158);
this.deleteButton.Name = "deleteButton";
this.deleteButton.Size = new System.Drawing.Size(75, 23);
this.deleteButton.TabIndex = 2;
this.deleteButton.Text = "Delete";
this.deleteButton.UseVisualStyleBackColor = true;
this.deleteButton.Click += new System.EventHandler(this.DeleteButtonClick);
//
// addButton
//
this.addButton.Location = new System.Drawing.Point(142, 158);
this.addButton.Name = "addButton";
this.addButton.Size = new System.Drawing.Size(75, 23);
this.addButton.TabIndex = 3;
this.addButton.Text = "Add";
this.addButton.UseVisualStyleBackColor = true;
this.addButton.Click += new System.EventHandler(this.AddButtonClick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(508, 216);
this.Controls.Add(this.addButton);
this.Controls.Add(this.deleteButton);
this.Controls.Add(this.plusButton);
this.Controls.Add(this.nimusButton);
this.Controls.Add(this.listBox);
this.Name = "MainForm";
this.Text = "plusminus";
this.ResumeLayout(false);
}
private System.Windows.Forms.Button addButton;
private System.Windows.Forms.Button deleteButton;
private System.Windows.Forms.Button plusButton;
private System.Windows.Forms.Button nimusButton;
private System.Windows.Forms.ListBox listBox;
}
}
[/size]
Re: Ovládání pomocí tří tlačítek na select, plus, minus
Napsal: pon 24. led 2011, 15:31
od M4r1hu4n3
Saphire je dost blízko, vím že jsem tam nějak používal mezi článek ve formě proměnné. Jinak to nemělo žádný design, bylo čistě textové, v podstatě mi jde jen o ten princip.