コード例 #1
0
        public static void saveConfig(Expandable exa, Expandable.IConfig config, Hotkey[] hks)
        {
            if (!exa.isConfigChanged)
            {
                return;
            }
            if (!Directory.Exists(CONFIG_PATH))
            {
                Directory.CreateDirectory(CONFIG_PATH);
            }

            string module = exa.dllFileName;
            string file   = module == CORE_ID ? CORE_CONFIG_PATH : CONFIG_PATH + module + ".ini";

            List <Expandable.Property> property    = convertConfig(config);
            List <HotkeyInfo>          hotkeyInfos = getHotkeyInfo(hks);
            Config targetConfig = new Config(property, hotkeyInfos);

            using (Stream str = File.Create(file))
            {
                try
                {
                    XmlSerializer xs = new XmlSerializer(typeof(Config));
                    xs.Serialize(str, targetConfig);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
            exa.isConfigChanged = false;
        }
コード例 #2
0
        private ToolStripMenuItem createMenuItem(Expandable exa, MenuStruct menuStruct)
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem();

            exa.strRes.TryGetValue("str_" + menuStruct.id, out string name);
            menuItem.Text     = name != null ? name : menuStruct.name;
            menuItem.Name     = exa.dllFileName + menuStruct.id;
            menuItem.AutoSize = true;

            if (menuStruct.action != null)
            {
                menuItem.Click += menuStruct.action;
            }

            if (menuStruct.dropDownItems != null)
            {
                List <ToolStripMenuItem> items = new List <ToolStripMenuItem>();
                foreach (MenuStruct ms in menuStruct.dropDownItems)
                {
                    items.Add(createMenuItem(exa, ms));
                }
                menuItem.DropDownItems.AddRange(items.ToArray());
            }

            return(menuItem);
        }
コード例 #3
0
        private void removeMenuStripItems(Expandable exa)
        {
            foreach (ToolStripMenuItem bItem in MainMenuStrip.Items)
            {
                if (bItem.Text == _Core.getString("str_modules"))
                {
                    continue;
                }
                List <ToolStripMenuItem> removes = new List <ToolStripMenuItem>();

                foreach (ToolStripMenuItem item in bItem.DropDownItems)
                {
                    if (item.Tag == null)
                    {
                        continue;
                    }
                    if ((string)item.Tag == exa.dllFileName)
                    {
                        removes.Add(item);
                    }
                }
                foreach (ToolStripMenuItem item in removes)
                {
                    bItem.DropDownItems.Remove(item);
                }

                if (bItem.DropDownItems.Count == 0)
                {
                    bItem.Visible = false;
                }
            }
        }
コード例 #4
0
ファイル: Form_Settings.cs プロジェクト: dust120125/MWinTool
        private void saveSettings()
        {
            string lang = Core.setting.language;

            foreach (TabPage page in tabControl1.TabPages)
            {
                if (page.Tag == null)
                {
                    continue;
                }
                object[] tags = (object[])page.Tag;

                Expandable exa = (Expandable)tags[0];
                exa.isConfigChanged = true;

                Control[]          controls = (Control[])tags[1];
                Expandable.IConfig config   = (Expandable.IConfig)tags[2];

                saveSetting(controls, config);
            }

            if (Core.setting.language == lang)
            {
                return;
            }
            Core core = Core.getInstance();

            if (core == null)
            {
                return;
            }
            MessageBox.Show(core.getString("str_change_lang_msg"));
        }
コード例 #5
0
 public LitSurfaceInputsUIBlock(Expandable expandableBit, int layerCount = 1, int layerIndex = 0, Features features = Features.All, Color dotColor = default(Color))
 {
     m_ExpandableBit = expandableBit;
     m_Features      = features;
     m_LayerCount    = layerCount;
     m_LayerIndex    = layerIndex;
     m_DotColor      = dotColor;
 }
コード例 #6
0
 private void InitalizeRightsSection(Expandable rightsSection)
 {
     rightsSection.Title    = Translator.Translate("RightsSection.Title");
     rightsSection.Expanded = true;
     RightsContainer        = rightsSection.AddGeneric("div", div =>
     {
         div.AddClass("rights");
     });
 }
コード例 #7
0
 public ConwayCubeSimulator(
     IEnumerable <KeyValuePair <Cube, State> > cubes,
     Expandable universe,
     Scanable scanner)
 {
     this.cubes    = new Dictionary <Cube, State>(cubes);
     this.universe = universe;
     this.scanner  = scanner;
 }
コード例 #8
0
 static bool GetAdvanced(Expandable mask, SerializedDensityVolume serialized, Editor owner)
 {
     //only one possibility for now, change to bit mask if several later (see HDLightUI)
     if (mask == Expandable.Volume)
     {
         return(serialized.editorAdvancedFade.boolValue);
     }
     return(false);
 }
コード例 #9
0
 static void SetAdvanced(Expandable mask, bool value, SerializedDensityVolume serialized, Editor owner)
 {
     //only one possibility for now, change to bit mask if several later (see HDLightUI)
     if (mask != Expandable.Volume)
     {
         return;
     }
     DensityVolumeEditor.s_BlendBox.monoHandle = !value;
     serialized.editorAdvancedFade.boolValue   = value;
 }
コード例 #10
0
        private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl.TabPages.Count == 0)
            {
                return;
            }
            Expandable exa = (Expandable)tabControl.SelectedTab.Tag;

            Core.globalHotkey.availableHotkeys = exa.dllFileName;
        }
コード例 #11
0
        private void switchToPage(params object[] args)
        {
            Expandable exa  = (Expandable)args[0];
            Type       type = exa.GetType();
            TabPage    page = tabControl.TabPages.Cast <TabPage>().FirstOrDefault(_ => _.Tag.GetType().Equals(type));

            if (page != null)
            {
                tabControl.SelectedTab = page;
            }
        }
コード例 #12
0
 private void InitalizeGeneralSection(Expandable generalSection)
 {
     generalSection.Title    = FieldsTranslator.Translate("GeneralSection.Title");
     generalSection.Expanded = true;
     generalSection.AddGeneric("table", table =>
     {
         table.AddClass("summary-grid");
         InitializeNameIn(table);
         InitializeDataTypeIn(table);
         InitializeScopeIn(table);
         InitializePropagationModeIn(table);
         InitializeIsActiveIn(table);
     });
 }
コード例 #13
0
 private void loadMenuStripItems(Expandable exa)
 {
     MenuStruct[] menuStructs = exa.menuStructs;
     if (menuStructs == null)
     {
         return;
     }
     foreach (MenuStruct ms in menuStructs)
     {
         ToolStripMenuItem menuItem = createMenuItem(exa, ms);
         menuItem.Tag = exa.dllFileName;
         addMenuItem(ms.field, exa, menuItem);
     }
 }
コード例 #14
0
        public TransparencyUIBlock(Expandable expandableBit, Features features = Features.All)
        {
            m_ExpandableBit = expandableBit;
            m_Features      = features;

            m_TransparencyBlocks = new MaterialUIBlockList(parent);
            if ((features & Features.Refraction) != 0)
            {
                m_TransparencyBlocks.Add(new RefractionUIBlock(1));  // This block will not be used in by a layered shader so we can safely set the layer count to 1
            }
            if ((features & Features.Distortion) != 0)
            {
                m_TransparencyBlocks.Add(new DistortionUIBlock());
            }
        }
コード例 #15
0
        private void unloadModule(Expandable exa)
        {
            Type type = exa.GetType();
            IEnumerable <Control> ien = tabControl.Controls.Cast <Control>();
            TabPage page = (TabPage)ien.Where(_ => type.Equals(_.Tag.GetType())).First();

            removeMenuStripItems(exa);

            Core.saveConfig(exa, exa.config, exa.hotkeys);
            tabControl.Controls.Remove(page);
            exa.quit();

            Core.runningModules.Remove(exa);
            Core.setModuleEnabled(exa.dllFileName, false);
        }
コード例 #16
0
        private void loadModule(Expandable exa)
        {
            SuspendLayout();

            if (exa.dllFileName == Core.CORE_ID)
            {
                exa.run();
                return;
            }

            TabPage tpage = new TabPage(exa.getTitle())
            {
                Padding  = new Padding(3),
                TabIndex = tabControl.TabCount,
                UseVisualStyleBackColor = true,
                Tag = exa
            };

            tpage.Controls.Add(exa.mainPanel);


            tabControl.Controls.Add(tpage);
            ToolStripMenuItem item = modulesToolStripMenuItem.DropDown.Items.Cast <ToolStripMenuItem>()
                                     .Where(_ => _.Tag.GetType().Equals(exa.GetType())).First();

            loadMenuStripItems(exa);

            exa.run();
            Core.runningModules.Add(exa);

            exa.mainPanel.Size = new Size(1, 1);
            exa.mainPanel.Dock = DockStyle.Fill;

            if (exa.hotkeys != null)
            {
                Core.enableHotkeys(exa.dllFileName, exa.hotkeys);
            }
            if (Core.globalHotkey.availableHotkeys == null ||
                Core.globalHotkey.availableHotkeys == string.Empty)
            {
                Core.globalHotkey.availableHotkeys = exa.dllFileName;
            }

            Core.setModuleEnabled(exa.dllFileName, true);
            item.Checked = true;

            ResumeLayout();
        }
コード例 #17
0
        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            if (item.Checked)
            {
                Expandable exa = (Expandable)item.Tag;
                unloadModule(exa);
                item.Checked          = false;
                item.DropDown.Enabled = false;
            }
            else
            {
                loadModule((Expandable)item.Tag);
                item.DropDown.Enabled = true;
                //item.Checked = true;
            }
        }
コード例 #18
0
        private void addMenuItem(MenuStripField field, Expandable exa, ToolStripMenuItem item)
        {
            ToolStripMenuItem menu;

            switch (field)
            {
            case MenuStripField.File:
                menu = fileToolStripMenuItem;
                menu.DropDownItems.Insert(0, item);
                break;

            case MenuStripField.View:
                menu = viewToolStripMenuItem;
                menu.DropDownItems.Insert(0, item);
                break;

            case MenuStripField.Tool:
                menu = toolToolStripMenuItem;
                menu.DropDownItems.Insert(0, item);
                break;

            case MenuStripField.Option:
                menu = optionToolStripMenuItem;
                menu.DropDownItems.Insert(0, item);
                break;

            case MenuStripField.Self:
                IEnumerable <ToolStripMenuItem> menuItems
                     = modulesToolStripMenuItem.DropDownItems.Cast <ToolStripMenuItem>();
                menu = menuItems.First(_ => ((Expandable)_.Tag).dllFileName == exa.dllFileName);
                menu.DropDownItems.Insert(0, item);
                break;

            case MenuStripField.Others:
            default:
                menu = othersToolStripMenuItem;
                menu.DropDownItems.Insert(0, item);
                break;
            }
            menu.Visible = true;
        }
コード例 #19
0
        private void lvPeople_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            var item = (Expandable <Entities.Person>)e.Item;

            // hide the previous item
            if (old != null)
            {
                old.IsVisible = false;
            }

            if (old == item)
            {
                old = null;
            }
            else
            {
                // toggle the tapped item
                item.IsVisible = !item.IsVisible;
                old            = item;
            }
        }
コード例 #20
0
        private void saveHotkeys()
        {
            foreach (TabPage page in tabControl1.TabPages)
            {
                if (page.Tag == null)
                {
                    continue;
                }
                object[]   tags = (object[])page.Tag;
                Expandable exa  = (Expandable)tags[0];
                exa.isConfigChanged = true;

                List <TextBox> textBoxes = (List <TextBox>)tags[1];

                foreach (TextBox tb in textBoxes)
                {
                    Hotkey hk = (Hotkey)tb.Tag;
                    exa.editHotkey(hk.id, hk.keys);
                }
                Core.ModuleHotkeys[exa.dllFileName] = exa.hotkeys;
                Core.globalHotkey.setHotkeys(exa.dllFileName, exa.hotkeys);
            }
        }
コード例 #21
0
 public EmissionUIBlock(Expandable expandableBit, Features features = Features.All)
 {
     m_ExpandableBit = expandableBit;
     m_Features      = features;
 }
コード例 #22
0
 public MaterialToCopyUIBlock(Expandable expandableBit)
 {
     m_ExpandableBit = expandableBit;
     m_WithUV        = new bool[] { true, true, true, true };
 }
コード例 #23
0
 public TessellationOptionsUIBlock(Expandable expandableBit)
 {
     m_ExpandableBit = expandableBit;
 }
コード例 #24
0
        private void InitPages()
        {
            foreach (string module in Core.ModuleHotkeys.Keys)
            {
                Expandable exa = Core.loadedModules.Where(_ => _.dllFileName == module).First();
                Hotkey[]   hks = Core.ModuleHotkeys[module];
                if (hks == null || hks.Length == 0)
                {
                    continue;
                }

                string text = module == Core.CORE_ID ? "General" : exa.getTitle();

                Hotkey[] tmpHks = hks.ToArray();
                TabPage  page   = new TabPage
                {
                    Text       = text,
                    AutoScroll = true,
                    Location   = new Point(4, 22),
                    Padding    = new Padding(3),
                    Size       = new Size(290, 294),
                    TabIndex   = tabControl1.TabCount,
                    UseVisualStyleBackColor = true,
                    Name = module
                };

                List <TextBox> textBoxes = new List <TextBox>();

                for (int i = 0; i < tmpHks.Length; i++)
                {
                    TextBox tb = new TextBox
                    {
                        Anchor   = (AnchorStyles.Top | AnchorStyles.Right),
                        Location = new Point(101, 6 + i * 28),
                        Size     = new Size(155, 22),
                        //tb.TabIndex = i * 2;
                        Tag = tmpHks[i]
                    };
                    tb.KeyDown += HotkeyBox_KeyDown;
                    textBoxes.Add(tb);
                    if (tmpHks[i].keys != null)
                    {
                        tb.Text = getHotKeyString(tmpHks[i].keys.ToList());
                    }

                    Button bt = new Button
                    {
                        Anchor   = (AnchorStyles.Top | AnchorStyles.Right),
                        Location = new Point(262, 6 + i * 28),
                        Size     = new Size(22, 22),
                        //bt.TabIndex = i * 2 + 1;
                        Text = "☓",
                        UseVisualStyleBackColor = true,
                        Tag = tb
                    };
                    bt.Click += Delete_Click;

                    Label lab = new Label
                    {
                        AutoSize = true,
                        Location = new Point(8, 11 + i * 28),
                        Size     = new Size(33, 12)
                    };
                    bool got = exa.strRes.TryGetValue("str_" + tmpHks[i].id, out string desc);
                    lab.Text = got ? desc : tmpHks[i].name;

                    page.Controls.Add(tb);
                    page.Controls.Add(bt);
                    page.Controls.Add(lab);
                }

                page.Tag = new object[] { exa, textBoxes };
                tabControl1.Controls.Add(page);
            }
        }
コード例 #25
0
 public AxfSurfaceInputsUIBlock(Expandable expandableBit)
 {
     m_ExpandableBit = expandableBit;
 }
コード例 #26
0
 public AdvancedOptionsUIBlock(Expandable expandableBit, Features features = Features.All)
 {
     m_ExpandableBit = expandableBit;
     m_Features      = features;
 }
コード例 #27
0
 public ShaderGraphUIBlock(Expandable expandableBit = Expandable.ShaderGraph, Features features = Features.All)
 {
     m_ExpandableBit = expandableBit;
     m_Features      = features;
 }
コード例 #28
0
 public DecalSortingInputsUIBlock(Expandable expandableBit, Features features = Features.All)
 {
     m_ExpandableBit = expandableBit;
     m_Features      = features;
 }
コード例 #29
0
 public LayeringOptionsUIBlock(Expandable expandableBit, int layerIndex)
 {
     m_ExpandableBit = expandableBit;
     m_LayerIndex    = layerIndex;
 }
コード例 #30
0
 internal static bool Foldout(GUIContent label, Expandable expandable, GUIStyle style = null)
 {
     k_Foldouts.SetExpandedAreas(expandable, EditorGUILayout.Foldout(k_Foldouts[expandable], label, true, style ?? Styles.boldFoldout));
     return(k_Foldouts[expandable]);
 }