/// <summary> /// 將一張顏色圖片,只顯示單色。 /// </summary> /// <param name="Source">來源圖片</param> /// <param name="HC">選擇顏色</param> /// <returns>結果圖片</returns> static public Bitmap Threecolorimg(Bitmap Source, HColor HC) { int Width = Source.Width, Height = Source.Height; BitmapData SourceData = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Bitmap Result = new Bitmap(Width, Height); BitmapData ResultData = Result.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); int X, Y; byte * SourcePointer = (byte *)SourceData.Scan0.ToPointer(); byte * ResultPointer = (byte *)ResultData.Scan0.ToPointer(); for (Y = 0; Y < Height; ++Y) { for (X = 0; X < Width; ++X) { ResultPointer[0] = SourcePointer[(int)HC]; ResultPointer[1] = SourcePointer[(int)HC]; ResultPointer[2] = SourcePointer[(int)HC]; ResultPointer[3] = 255; SourcePointer += 4; ResultPointer += 4; } } Source.UnlockBits(SourceData); Result.UnlockBits(ResultData); return(Result); }
// Set the style for active item private void setItemActive(ToolStripMenuItem item) { Color activeItemColor = HColor.color(Properties.Menu.Default.ActiveTaskColor); item.Font = new Font(item.Font, FontStyle.Bold); item.BackColor = activeItemColor; }
/// <summary> /// On mouse enter, if default text, remove it and change text color. /// </summary> void ReminderText_MouseEnter(object sender, EventArgs e) { if (((ToolStripTextBox)sender).Text == Properties.Menu.Default.ReminderTextWatermarkText) { ((ToolStripTextBox)sender).Text = ""; ((ToolStripTextBox)sender).ForeColor = HColor.color(Properties.Menu.Default.NewItemTextColor); } }
/// <summary> /// On mouse leave, if no text was entered, unfocus and reset default text and color. /// </summary> void NewInterval_MouseLeave(object sender, EventArgs e) { if (((ToolStripTextBox)sender).Text == "") { ((ToolStripDropDownMenu)(((ToolStripTextBox)sender).Owner)).Focus(); ((ToolStripTextBox)sender).ForeColor = HColor.color(Properties.Menu.Default.WatermarkTextColor); ((ToolStripTextBox)sender).Text = Properties.Menu.Default.NewIntervalWatermarkText; } }
/// <summary> /// On mouse leave, if no text was entered, unfocus and reset default text and color. /// </summary> void NewItem_MouseLeave(object sender, EventArgs e) { if (((ToolStripTextBox)sender).Text == "") { ((ContextMenuStrip)(((ToolStripTextBox)sender).Owner)).Focus(); ((ToolStripTextBox)sender).ForeColor = HColor.color(Properties.Menu.Default.WatermarkTextColor); ((ToolStripTextBox)sender).Text = Properties.Menu.Default.NewProjectWatermarkText; } }
/// <summary> /// If the item exists sets it, otherwise first creates it and then sets it /// </summary> public void StoreItemColor(GameObject go, HColor hColor) { foreach (CustomizedItem customizedItem in customizedItems) { if (customizedItem.gameObject != go) { continue; } // Item exists, replace it customizedItem.hColor = hColor; return; } // Item doesn't exist, add it customizedItems.Add(new CustomizedItem(go, hColor)); }
static void Main(string[] args) { try { if (args.Length >= 4) { HColor HC = (HColor)(Convert.ToInt32(args[3])); Bitmap Source = new Bitmap(args[0]); Bitmap Result = ImgF.Threecolorimg(Source, HC); Result.Save(args[1], ImgF.ChooseImageFormat(args[2])); Environment.Exit(0); } else { Environment.Exit(1); } } catch { Environment.Exit(2); } }
/// <summary> /// Create menu on right-click /// </summary> /// <param name="menu"></param> public void createMenuList(ContextMenuStrip menu) { menu.Items.Clear(); ToolStripMenuItem item; ToolStripTextBox newItemBox; ToolStripSeparator sep; // Task list in desired order + current task if relevant string[] taskNames = getTaskNames(); int numberOfTasks = taskNames.Length; string actualTask; bool actual = TimerFile.Instance.getLastItem(out actualTask); string[] intervals = Ini.GetStringArray(Program.secManualReminder, Program.paramsIntervals, "10 mins"); int maxItemsInList = Ini.GetInt(Program.secGeneral, Program.paramsMaxItems, numberOfTasks); if (maxItemsInList <= 0) { maxItemsInList = numberOfTasks; } // Actually creating the menu ToolStripMenuItem startOfList = new ToolStripMenuItem(); startOfList.Text = "More..."; startOfList.Font = new Font(startOfList.Font, FontStyle.Italic); if (numberOfTasks > maxItemsInList) { menu.Items.Add(startOfList); } int i; for (i = 0; i < numberOfTasks - maxItemsInList; i++) { string taskName = taskNames[i]; if (taskName != "") { item = new ToolStripMenuItem(); item.Text = taskName; if (actual && taskName.Equals(actualTask)) { setItemActive(item); menu.Items.Add(item); } else { item.Font = new Font(item.Font, FontStyle.Regular); item.Click += new EventHandler(Task_Click); startOfList.DropDownItems.Add(item); } } } for (; i < numberOfTasks; i++) { string taskName = taskNames[i]; if (taskName != "") { item = new ToolStripMenuItem(); item.Text = taskName; item.Click += new EventHandler(Task_Click); menu.Items.Add(item); if (actual && taskName.Equals(actualTask)) { setItemActive(item); } } } // Textbox for adding new project newItemBox = new ToolStripTextBox("NewProject"); newItemBox.Text = Properties.Menu.Default.NewProjectWatermarkText; newItemBox.ForeColor = HColor.color(Properties.Menu.Default.WatermarkTextColor); newItemBox.KeyUp += new KeyEventHandler(NewItem_KeyUp); newItemBox.MouseEnter += new EventHandler(NewItem_MouseEnter); newItemBox.MouseLeave += new EventHandler(NewItem_MouseLeave); menu.Items.Add(newItemBox); // Separator. sep = new ToolStripSeparator(); menu.Items.Add(sep); // Pause. item = new ToolStripMenuItem(); item.Text = "Pause"; item.Click += new EventHandler(Pause_Click); //item.Image = Resources.Pause; menu.Items.Add(item); // Pause and remind. item = new ToolStripMenuItem(); item.Text = "Pause and remind in..."; //item.Image = Resources.Pause; menu.Items.Add(item); ToolStripMenuItem subItem; foreach (string interval in intervals) { if (interval != "") { subItem = new ToolStripMenuItem(); subItem.Text = interval; subItem.Click += new EventHandler(PauseAndRemindIn_Click); item.DropDownItems.Add(subItem); } } // Textbox for adding new project newItemBox = new ToolStripTextBox("How long?"); newItemBox.Text = Properties.Menu.Default.NewIntervalWatermarkText; newItemBox.ForeColor = HColor.color(Properties.Menu.Default.WatermarkTextColor); newItemBox.KeyUp += new KeyEventHandler(NewInterval_KeyUp); newItemBox.MouseEnter += new EventHandler(NewInterval_MouseEnter); newItemBox.MouseLeave += new EventHandler(NewInterval_MouseLeave); item.DropDownItems.Add(newItemBox); // Reminder. item = new ToolStripMenuItem(); item.Text = "Simple reminder..."; //item.Image = Resources.Pause; menu.Items.Add(item); // Textbox for adding reminder text newItemBox = new ToolStripTextBox(Properties.Menu.Default.ReminderTextWatermarkText); newItemBox.Text = Properties.Menu.Default.ReminderTextWatermarkText; newItemBox.Font = new Font(newItemBox.Font, FontStyle.Italic); newItemBox.KeyUp += new KeyEventHandler(ReminderText_KeyUp); newItemBox.MouseEnter += new EventHandler(ReminderText_MouseEnter); newItemBox.MouseLeave += new EventHandler(ReminderText_MouseLeave); item.DropDownItems.Add(newItemBox); // Separator. sep = new ToolStripSeparator(); item.DropDownItems.Add(sep); foreach (string interval in intervals) { if (interval != "") { subItem = new ToolStripMenuItem(); subItem.Text = interval; subItem.Click += new EventHandler(ReminderIn_Click); item.DropDownItems.Add(subItem); } } // Textbox for adding new time for reminder newItemBox = new ToolStripTextBox("How long?"); newItemBox.Text = Properties.Menu.Default.NewIntervalWatermarkText; newItemBox.ForeColor = HColor.color(Properties.Menu.Default.WatermarkTextColor); newItemBox.KeyUp += new KeyEventHandler(ReminderIn_KeyUp); newItemBox.MouseEnter += new EventHandler(NewInterval_MouseEnter); newItemBox.MouseLeave += new EventHandler(NewInterval_MouseLeave); item.DropDownItems.Add(newItemBox); // Separator. sep = new ToolStripSeparator(); menu.Items.Add(sep); item = new ToolStripMenuItem(); item.Text = "Remove..."; menu.Items.Add(item); foreach (string taskName in taskNames) { if (taskName != "") { ToolStripMenuItem remItem = new ToolStripMenuItem(); remItem.Text = taskName; if (actual && taskName.Equals(actualTask)) { remItem.Enabled = false; remItem.Text += " (active)"; } else { remItem.Click += new EventHandler(RemoveTask_Click); } item.DropDownItems.Add(remItem); } } // Separator. sep = new ToolStripSeparator(); menu.Items.Add(sep); // Timesheet. item = new ToolStripMenuItem(); item.Text = "TimeSheet"; item.Font = new Font(item.Font, FontStyle.Bold); item.Click += new EventHandler(TimeSheet_Click); //item.Image = Resources.Timesheet; menu.Items.Add(item); // Separator. sep = new ToolStripSeparator(); menu.Items.Add(sep); // Files item = new ToolStripMenuItem(); item.Text = "Files..."; menu.Items.Add(item); subItem = new ToolStripMenuItem(); subItem.Text = "Settings"; subItem.Click += new EventHandler(Open_Click); item.DropDownItems.Add(subItem); subItem = new ToolStripMenuItem(); subItem.Text = "Time file"; subItem.Click += new EventHandler(Open_Click); item.DropDownItems.Add(subItem); // Ordering string order = Ini.GetString(Program.secGeneral, Program.paramsOrder, ""); item = new ToolStripMenuItem(); item.Text = "Order..."; menu.Items.Add(item); subItem = new ToolStripMenuItem(); subItem.Text = "Ascending"; subItem.Click += new EventHandler(Order_Click); if (string.Compare(subItem.Text, order, true) == 0) { setItemActive(subItem); } item.DropDownItems.Add(subItem); subItem = new ToolStripMenuItem(); subItem.Text = "Descending"; subItem.Click += new EventHandler(Order_Click); if (string.Compare(subItem.Text, order, true) == 0) { setItemActive(subItem); } item.DropDownItems.Add(subItem); subItem = new ToolStripMenuItem(); subItem.Text = "Chronological"; subItem.Click += new EventHandler(Order_Click); if (string.Compare(subItem.Text, order, true) == 0) { setItemActive(subItem); } item.DropDownItems.Add(subItem); // Separator. sep = new ToolStripSeparator(); menu.Items.Add(sep); // About. item = new ToolStripMenuItem(); item.Text = "About"; item.Click += new EventHandler(About_Click); item.Image = SystemIcons.Information.ToBitmap(); //item.Image = Resources.About; menu.Items.Add(item); // Separator. sep = new ToolStripSeparator(); menu.Items.Add(sep); // Exit. item = new ToolStripMenuItem(); item.Text = "Exit"; item.Click += new System.EventHandler(Exit_Click); item.Image = SystemIcons.Error.ToBitmap(); //item.Image = Resources.Exit; menu.Items.Add(item); }
public CustomizedItem(GameObject gameObject, HColor hColor) { this.gameObject = gameObject; this.hColor = hColor; }