void VoxelSetHiddenOne(VoxelChunk chunk, int voxelIndex, bool hidden, HideStyle hiddenStyle)
        {
            if (chunk.voxels [voxelIndex].hasContent != 1)
            {
                return;
            }

            int typeIndex = chunk.voxels [voxelIndex].typeIndex;

            if (typeIndex < 0 || typeIndex >= voxelDefinitions.Length)
            {
                return;
            }
            if (voxelDefinitions [typeIndex].seeThroughMode == SeeThroughMode.NotSupported)
            {
                return;
            }

            if (chunk.voxelsExtraData == null)
            {
                if (!hidden)
                {
                    return;
                }
                chunk.voxelsExtraData = new FastHashSet <VoxelExtraData> ();
            }
            VoxelExtraData hiddenVoxel = new VoxelExtraData();

            hiddenVoxel.hidden      = hidden;
            hiddenVoxel.hiddenStyle = hiddenStyle;
            chunk.voxelsExtraData.Add(voxelIndex, hiddenVoxel, true);
        }
Example #2
0
        void loadOptions()
        {
            StreamReader file = new StreamReader("options.txt");
            string line;
            string[] args;
            string fontFamily = "Arial";
            int fontSize = 10;
            bool bold = false, italic = false;

            while (!file.EndOfStream)
            {
                line = file.ReadLine();

                if (line != "" && line.Substring(0, 2) != "//")
                {
                    args = line.Split('=');

                    switch (args[0])
                    {
                        case "x":
                            x = int.Parse(args[1]);
                            this.Left = x;
                            break;
                        case "y":
                            y = int.Parse(args[1]);
                            this.Top = y;
                            break;
                        case "width":
                            this.Width = Math.Max(int.Parse(args[1]), 50);
                            break;
                        case "min_height":
                            minH = Math.Max(int.Parse(args[1]), 50);
                            this.Height = minH;
                            break;
                        case "max_height":
                            maxH = Math.Max(int.Parse(args[1]), 50);
                            break;
                        case "global_hotkey":
                            Hotkey.StringToHotkey(args[1], out hotkey, out hotkeyCtrl, out hotkeyAlt, out hotkeyShift);
                            Hotkey.RegisterHotKey(this, hotkey, hotkeyCtrl, hotkeyAlt, hotkeyShift, false);
                            break;
                        case "hide_delay":
                            autoHideDelay = int.Parse(args[1]);
                            break;
                        case "hide_style":
                            hideStyle = (HideStyle)Enum.Parse(typeof(HideStyle), args[1]);
                            break;
                        case "opacity_passive":
                            opacityPassive = double.Parse(args[1]);
                            break;
                        case "opacity_active":
                            opacityActive = double.Parse(args[1]);
                            break;
                        case "background_color":
                            txtCMD.BackColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "text_color":
                            txtCMD.ForeColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "text_font":
                            fontFamily = args[1];
                            break;
                        case "text_size":
                            fontSize = int.Parse(args[1]);
                            break;
                        case "text_bold":
                            bold = bool.Parse(args[1]);
                            break;
                        case "text_italic":
                            italic = bool.Parse(args[1]);
                            break;
                        case "print_delay":
                            setDelay(timerPrint, int.Parse(args[1]));
                            break;
                        case "print_atonce":
                            printAtOnce = int.Parse(args[1]);
                            printAtOnce = Math.Min(Math.Max(printAtOnce, 1), 50);
                            break;
                        case "start_dir":
                            dir = args[1];
                            break;
                        case "prompt":
                            prompt = bool.Parse(args[1]);
                            break;
                        case "blank_line":
                            blankLine = bool.Parse(args[1]);
                            break;
                        case "echo":
                            echo = bool.Parse(args[1]);
                            break;
                        case "echo_color":
                            echoColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "error_color":
                            errorColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "todo_dir":
                            todoDir = args[1];
                            if (todoDir.Length > 0 && todoDir[todoDir.Length - 1] != '\\')
                                todoDir += "\\";
                            break;
                        case "todo_hide_done":
                            todoHideDone = bool.Parse(args[1]);
                            break;
                        case "todo_auto_transfer":
                            todoAutoTransfer = bool.Parse(args[1]);
                            break;
                        case "todo_misc_color":
                            todoMiscColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "todo_item_color":
                            todoItemColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "todo_done_color":
                            todoDoneColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "token":
                            token = args[1];
                            break;
                        case "secret":
                            secret = args[1];
                            break;
                        case "last_tweet":
                            lastTweet = long.Parse(args[1]);
                            break;
                        case "update_on_new_tweet":
                            twUpdateOnNewTweet = bool.Parse(args[1]);
                            break;
                        case "update_on_focus":
                            twUpdateOnFocus = bool.Parse(args[1]);
                            break;
                        case "min_tweet_period":
                            minTweetPeriod = int.Parse(args[1]);
                            break;
                        case "display_pictures":
                            twDisplayPictures = bool.Parse(args[1]);
                            break;
                        case "display_instagrams":
                            twDisplayInstagrams = bool.Parse(args[1]);
                            break;
                        case "mail_period":
                            timerMailCheck.Interval = int.Parse(args[1]) * 60000; //convert from minutes to miliseconds
                            break;
                        case "mail_update_on_new_mail":
                            mailUpdateOnNewMail = bool.Parse(args[1]);
                            break;
                        case "mail_update_on_focus":
                            mailUpdateOnFocus = bool.Parse(args[1]);
                            break;
                        case "mail_sound":
                            mailSound = args[1];
                            break;
                        case "mail_sound_threshold":
                            mailSoundThreshold = int.Parse(args[1]);
                            break;
                        case "mail_count_color":
                            mailCountColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "mail_header_color":
                            mailHeaderColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "mail_summary_color":
                            mailSummaryColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "tw_sound":
                            twSound = args[1];
                            break;
                        case "tw_sound_threshold":
                            twSoundThreshold = int.Parse(args[1]);
                            break;
                        case "tw_user_color":
                            twUserColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "tw_misc_color":
                            twMiscColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "tw_tweet_color":
                            twTweetColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "tw_link_color":
                            twLinkColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "tw_time_color":
                            twTimeColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "tw_count_color":
                            twCountColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "reddit_link_color":
                            redditLinkColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "reddit_misc_color":
                            redditMiscColor = Color.FromArgb(int.Parse(args[1]));
                            break;
                        case "pad_width":
                            padW = int.Parse(args[1]);
                            break;
                        case "pad_height":
                            padH = int.Parse(args[1]);
                            break;
                        case "pad_word_wrap":
                            padMenusViewWordWrap.Checked = bool.Parse(args[1]);

                            if (padMenusViewWordWrap.Checked)
                                sciPad.LineWrapping.Mode = LineWrappingMode.Word;
                            else
                                sciPad.LineWrapping.Mode = LineWrappingMode.None;
                            break;
                        case "pad_line_numbers":
                            padMenusViewShowLineNumbers.Checked = bool.Parse(args[1]);

                            if (padMenusViewShowLineNumbers.Checked)
                                sciPad.Margins[0].Width = 20;
                            else
                                sciPad.Margins[0].Width = 0;
                            break;
                        case "pad_languages":
                            padLanguages = new Dictionary<string, string>();

                            foreach (string lang in args[1].Split(new string[] { " / " }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                string[] kvPair = lang.Split('>');
                                padLanguages.Add(kvPair[0], kvPair[1]);
                            }
                            break;
                        case "launcher_hotkey":
                            Hotkey.StringToHotkey(args[1], out launcherHotkey, out launcherHotkeyCtrl, out launcherHotkeyAlt, out launcherHotkeyShift);
                            Hotkey.RegisterHotKey(this, launcherHotkey, launcherHotkeyCtrl, launcherHotkeyAlt, launcherHotkeyShift, true);
                            break;
                        case "launcher_max_suggestions":
                            launcherMaxSuggestions = int.Parse(args[1]);
                            break;
                        case "launcher_autohide":
                            launcherAutohide = bool.Parse(args[1]);
                            break;
                        case "launcher_scan_period":
                             launcherScanPeriod = int.Parse(args[1]);
                            break;
                        case "launcher_scan_dirs":
                            launcherScanDirs = args[1];
                            break;
                        case "weather_location":
                            weatherLocation = args[1];
                            break;
                        case "weather_metric":
                            weatherMetric = bool.Parse(args[1]);
                            break;
                        case "weather_show_on_start":
                            weatherShowOnStart = bool.Parse(args[1]);
                            break;
                        case "weather_lang":
                            weatherLang = args[1];
                            break;
                        case "weather_webcam":
                            weatherWebcam = args[1];
                            break;
                        case "user":
                            user = args[1];
                            break;
                    }
                }
            }

            file.Close();

            //construct and apply font
            FontStyle fontStyle;

            if (bold && italic)
                fontStyle = FontStyle.Bold | FontStyle.Italic;
            else if (bold)
                fontStyle = FontStyle.Bold;
            else if (italic)
                fontStyle = FontStyle.Italic;
            else
                fontStyle = FontStyle.Regular;

            txtCMD.Font = new Font(fontFamily, fontSize, fontStyle);

            //apply console style to other UI controls
            applyUIStyle();

            setPrompt();

            //load mail username/password
            if (File.Exists(Application.StartupPath + "\\mail_login.dat"))
            {
                AES alg = new AES();
                alg.Decrypt(Application.StartupPath + "\\mail_login.dat", Application.StartupPath + "\\temp.dat");

                StreamReader login = new StreamReader(Application.StartupPath + "\\temp.dat");
                mailUser = login.ReadLine();
                mailPass = login.ReadLine();
                login.Close();

                File.Delete(Application.StartupPath + "\\temp.dat");
            }

            //update static values in Chunk
            Chunk.Font = txtCMD.Font;
            Chunk.PrintAtOnce = printAtOnce;
            Chunk.InstantOutput = timerPrint.Interval == ZERO_DELAY;
        }
Example #3
0
        public void UpdateOptions(formOptions options)
        {
            //if todo dir changed copy existing todo lists there
            if (options.txtTodoDir.Text != todoDir)
            {
                string dest = options.txtTodoDir.Text;
                if (dest[dest.Length - 1] != '\\')
                    dest += "\\";

                foreach (string file in Directory.GetFiles(todoDir))
                    File.Copy(file, dest + Path.GetFileName(file));
            }

            int prevHotkey = hotkey, prevLauncherHotkey = launcherHotkey;

            //assign new options
            x = (int)options.numX.Value;
            y = (int)options.numY.Value;
            this.Width = (int)options.numW.Value;
            minH = (int)options.numMinH.Value;
            maxH = (int)options.numMaxH.Value;
            Hotkey.StringToHotkey(options.txtHotkey.Text, out hotkey, out hotkeyCtrl, out hotkeyAlt, out hotkeyShift);
            autoHideDelay = (int)options.numAutoHideDelay.Value;
            hideStyle = (HideStyle)Enum.Parse(typeof(HideStyle), options.comboHideStyle.Text);
            opacityActive = (double)options.numOpacityActive.Value / 100;
            opacityPassive = (double)options.numOpacityPassive.Value / 100;

            txtCMD.BackColor = options.picBackColor.BackColor;

            FontStyle style;
            if (options.chkBold.Checked && options.chkItalic.Checked)
                style = FontStyle.Bold | FontStyle.Italic;
            else if (options.chkBold.Checked)
                style = FontStyle.Bold;
            else if (options.chkItalic.Checked)
                style = FontStyle.Italic;
            else
                style = FontStyle.Regular;

            Font prevFont = lblPrompt.Font;

            txtCMD.Font = new Font(options.comboFont.Text, (float)options.numFontSize.Value, style);
            txtCMD.ForeColor = options.picTextColor.BackColor;

            if (lblPrompt.Font != prevFont)
            {
                this.OnResize(new EventArgs());

                foreach (Chunk chunk in chunks)
                    chunk.SetTextBounds(new Rectangle(0, 0, measureWidth(chunk.ToString()), lineH));

                update();
            }

            applyUIStyle();

            dir = options.txtStartDir.Text;
            setDelay(timerPrint, (int)options.numPrintDelay.Value);
            printAtOnce = (int)options.numPrintAtOnce.Value;
            prompt = options.chkPrompt.Checked;
            blankLine = options.chkBlankLine.Checked;
            echo = options.chkEcho.Checked;
            echoColor = options.picEchoColor.BackColor;
            errorColor = options.picErrorColor.BackColor;

            todoDir = options.txtTodoDir.Text;
            todoHideDone = options.chkTodoHideDone.Checked;
            todoAutoTransfer = options.chkTodoAutoTransfer.Checked;
            todoMiscColor = options.picTodoMiscColor.BackColor;
            todoItemColor = options.picTodoItemColor.BackColor;
            todoDoneColor = options.picTodoDoneColor.BackColor;

            mailUser = options.txtUser.Text;
            mailPass = options.txtPass.Text;
            mailUpdateOnNewMail = options.chkMailCountOnNewMail.Checked;
            mailUpdateOnFocus = options.chkMailCountOnFocus.Checked;
            timerMailCheck.Interval = (int)options.numMailCheckPeriod.Value * 60000;
            mailSound = options.txtMailSound.Text;
            mailSoundThreshold = (int)options.numMailSoundThreshold.Value;
            mailCountColor = options.picMailCountColor.BackColor;
            mailHeaderColor = options.picMailHeaderColor.BackColor;
            mailSummaryColor = options.picMailSummaryColor.BackColor;

            twUpdateOnNewTweet = options.chkTwCountOnNewTweet.Checked;
            twUpdateOnFocus = options.chkTwCountOnFocus.Checked;
            minTweetPeriod = (int)options.numTwCountMinPeriod.Value;
            twDisplayPictures = options.chkTwDisplayPictures.Checked;
            twDisplayInstagrams = options.chkTwDisplayInstagrams.Checked;
            twSound = options.txtTwSound.Text;
            twSoundThreshold = (int)options.numTwSoundThreshold.Value;
            twUserColor = options.picTwUsernameColor.BackColor;
            twMiscColor = options.picTwMiscColor.BackColor;
            twTweetColor = options.picTwTweetColor.BackColor;
            twLinkColor = options.picTwLinkColor.BackColor;
            twTimeColor = options.picTwTimestampColor.BackColor;
            twCountColor = options.picTwCountColor.BackColor;

            redditLinkColor = options.picRedditLinkColor.BackColor;
            redditMiscColor = options.picRedditMiscColor.BackColor;

            Hotkey.StringToHotkey(options.txtLauncherHotkey.Text, out launcherHotkey, out launcherHotkeyCtrl, out launcherHotkeyAlt, out launcherHotkeyShift);
            launcherMaxSuggestions = (int)options.numLauncherMaxSuggestions.Value;
            launcherAutohide = options.chkLauncherAutohide.Checked;
            launcherScanPeriod = (int)options.numLauncherScanPeriod.Value;
            launcherScanDirs = options.GetLauncherScanDirs();

            weatherWebcam = options.txtWeatherWebcam.Text;
            weatherLocation = options.txtWeatherLocation.Text;
            weatherMetric = options.rdbWeatherMetric.Checked;
            weatherShowOnStart = options.chkWeatherShowOnStart.Checked;
            weatherLang = options.comboWeatherLang.Text.Substring(options.comboWeatherLang.Text.IndexOf('/') + 1);

            //apply changes & save
            Chunk.Font = txtCMD.Font;
            Chunk.PrintAtOnce = printAtOnce;
            Chunk.InstantOutput = timerPrint.Interval == ZERO_DELAY;
            Chunk.ErrorColor = errorColor;

            if (hotkey != prevHotkey)
            {
                Hotkey.UnregisterHotKey(this, false);
                Hotkey.RegisterHotKey(this, hotkey, hotkeyCtrl, hotkeyAlt, hotkeyShift, false);
            }

            if (launcherHotkey != prevLauncherHotkey)
            {
                Hotkey.UnregisterHotKey(this, true);
                Hotkey.RegisterHotKey(this, launcherHotkey, launcherHotkeyCtrl, launcherHotkeyAlt, launcherHotkeyShift, true);
            }

            Twitter.DisplayPictures = twDisplayPictures;
            Twitter.DisplayInstagrams = twDisplayInstagrams;

            this.Top = y;
            this.Left = x;

            initGrafx();
            windowAutosize();
            setPrompt();

            if (gmail != null)
                gmail.ChangeLogin(mailUser, mailPass);

            saveOptions();
        }